@qe-libs/qeviz 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -1
- package/dist/qeviz.es.js +2025 -1525
- package/dist/qeviz.es.js.map +1 -1
- package/dist/qeviz.umd.js +5 -5
- package/dist/qeviz.umd.js.map +1 -1
- package/package.json +4 -2
package/dist/qeviz.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(O,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(O=typeof globalThis<"u"?globalThis:O||self,U(O.QEViz={}))})(this,(function(O){"use strict";var Hi=Object.defineProperty;var fi=O=>{throw TypeError(O)};var c=(O,U)=>Hi(O,"name",{value:U,configurable:!0});var pi=(O,U,_t)=>U.has(O)||fi("Cannot "+_t);var R=(O,U,_t)=>(pi(O,U,"read from private field"),_t?_t.call(O):U.get(O)),nt=(O,U,_t)=>U.has(O)?fi("Cannot add the same private member more than once"):U instanceof WeakSet?U.add(O):U.set(O,_t),X=(O,U,_t,Ot)=>(pi(O,U,"write to private field"),Ot?Ot.call(O,_t):U.set(O,_t),_t);var xe,we,ve,xt,Ae,Se,wt,Kt,$t,Mt,at,Ee,qt,It,te,ee,ze;const us=class us extends Array{constructor(e,s,i,n,r){super(...s);nt(this,xe);nt(this,we);nt(this,ve);nt(this,xt);nt(this,Ae);X(this,ve,e),X(this,we,i),X(this,xt,n),X(this,Ae,n==null?void 0:n.classes),X(this,xe,r)}get parent(){return R(this,xt)}get names(){return R(this,ve)}get rowName(){return R(this,we)}get types(){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).types}get classes(){return R(this,Ae)}get rowNumber(){return R(this,xe)}col(e){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).col(e)}cols(...e){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};xe=new WeakMap,we=new WeakMap,ve=new WeakMap,xt=new WeakMap,Ae=new WeakMap,c(us,"DataFrameRow");let U=us;var _t=(m=>(m.Character="character",m.Double="double",m.Logical="logical",m.Integer="integer",m))(_t||{});const ds=class ds extends Array{constructor(e,s,i,n){super(s.length);nt(this,Se);nt(this,wt);nt(this,Kt);nt(this,$t);for(let r=0;r<s.length;r++)this[r]=s[r];if(X(this,Se,e),s.type!==void 0?X(this,wt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?X(this,wt,"character"):s.every(r=>Number.isInteger(r)||r===null||r===void 0)?s.every(r=>r===0||r===1||r===null||r===void 0)?X(this,wt,"logical"):X(this,wt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?X(this,wt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?X(this,wt,"logical"):X(this,wt,"character"),X(this,$t,n),i&&i.length!==this.length)throw new Error("Row names length must match the number of rows in the DataFrameColumn.");i&&i.length>0?X(this,Kt,i):X(this,Kt,void 0)}get name(){return R(this,Se)}get type(){return R(this,wt)}get rowNames(){return R(this,Kt)}row(e){if(!R(this,$t))throw new Error("No parent DataFrame attached to this column.");return R(this,$t).row(e)}rows(...e){if(!R(this,$t))throw new Error("No parent DataFrame attached to this column.");return R(this,$t).rows(...e)}};Se=new WeakMap,wt=new WeakMap,Kt=new WeakMap,$t=new WeakMap,c(ds,"DataFrameColumn");let Ot=ds;const Me=class Me extends Array{constructor(e,s,i,n){if((!e||!s)&&(s=[],e=[]),s.map(r=>r.length).every(r=>r===e.length)){const r=[];for(let a=0;a<e.length;a++){const h=[];for(let o=0;o<s.length;o++)h.push(s[o][a]);r.push(h)}s=r}super(s.length);nt(this,Mt);nt(this,at);nt(this,Ee);if(s.forEach((r,a)=>{r instanceof Ot?this[a]=r:this[a]=new Ot(e[a],r,i,this)}),X(this,Mt,e),i&&this[0]&&i.length!==this[0].length)throw new Error("Row names length must match the number of rows in the DataFrame.");if(i&&i.length>0&&X(this,at,i),n&&n.length!==this.length)throw new Error("Classes length must match the number of columns in the DataFrame.");n&&n.length>0&&X(this,Ee,n)}get classes(){return R(this,Ee)}getColumnByName(e){const s=R(this,Mt).indexOf(e);return s>=0?this[s]:void 0}getRowByIndex(e){if(this&&this.length===0)return console.warn("DataFrame is empty, cannot get row by index",e),new U(R(this,Mt),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new U(R(this,Mt),s,R(this,at)?R(this,at)[e]:void 0,this,e)}getRowByName(e){if(!R(this,at))return;const s=R(this,at).indexOf(e);if(s!==-1)return this.getRowByIndex(s)}get types(){return this.map(e=>e.type)}type(e){var s;if(typeof e=="number")return(s=this[e])==null?void 0:s.type;if(typeof e=="string"){const i=this.getColumnByName(e);return i?i.type:void 0}}row(e){if(typeof e=="number")return this.getRowByIndex(e);if(typeof e=="string")return this.getRowByName(e)}rows(...e){let s,i=[],n=[];if(e.length===0){if(!this[0]||this.length===0)return[];const r=this[0].length;i=Array.from({length:r},(a,h)=>this.getRowByIndex(h)),n=R(this,at)}else e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map((r,a)=>{let h=this.row(r);return R(this,at)&&h&&(n==null||n.push(R(this,at)[a])),h}).filter(r=>r!==void 0);return i}col(e){if(typeof e=="number")return this[e];if(typeof e=="string")return this.getColumnByName(e)}cols(...e){let s,i,n=[];return e.length===0?(i=this.slice(),n=R(this,Mt)):(e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map(r=>this.col(r)).filter(r=>r!==void 0),n=i.map(r=>r.name)),new Me(n,i,R(this,at))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new Me(i.map(n=>n.name),i.map(n=>n.values),R(this,at))}get names(){return R(this,Mt)}get rowNames(){return R(this,at)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};Mt=new WeakMap,at=new WeakMap,Ee=new WeakMap,c(Me,"DataFrame");let Ft=Me;const gs=class gs{constructor(t={}){this.unit_id_col="id",this.node_id_col="id",this.group_col=null,this.directed=!1,this.palette=[],this._points=t.points??new Ft,this._nodes=t.nodes??new Ft,this._edges=t.edges??new Ft,this._dimensions=t.dimensions??[],this._confidence=void 0,this._outlier=void 0,this._groups=void 0}get updated(){return this._updated}set updated(t){this._updated=t}get points(){return this._points}set points(t){this._points=t}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get edges(){return this._edges}set edges(t){this._edges=t}get confidence(){return this._confidence}set confidence(t){this._confidence=t}get outlier(){return this._outlier}set outlier(t){this._outlier=t}get groups(){return this._groups}set groups(t){this._groups=t}get trajectories(){return this._trajectories}set trajectories(t){this._trajectories=t}get networks(){return this._networks}set networks(t){this._networks=t}get pointsets(){return this._pointsets}set pointsets(t){this._pointsets=t}get dimensions(){return this._dimensions}set dimensions(t){this._dimensions=t}get params(){return this._params}set params(t){this._params=t}point(t){return this._points.row(t)}setByKey(t,e){this[t]=e}};c(gs,"Model");let is=gs;const bi=globalThis.__QEVIZ_DEBUG__===!0;function Xt(...m){bi&&console.log(...m)}c(Xt,"dbg");const yi={get:c(m=>{const t=[...document.querySelectorAll("qe-graph")];return typeof m=="number"&&m>=0?t[m]:t},"get")},Jt=class Jt extends HTMLElement{constructor(){super(),this._isVisible=!0,this.output="",this._updated="",this._active_points=[],this._points=new Map,this._edges=new Map,this._labels=new Map,this._model=new is;const t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Jt.styles,t.appendChild(e),this._outputElement=document.createElement("div"),t.appendChild(this._outputElement)}static get observedAttributes(){return["updated"]}get model(){return this._model}get updated(){return this._updated}set updated(t){this._updated=t,this.setAttribute("updated",t),this.dispatchEvent(new CustomEvent("model-updated",{detail:this._model,bubbles:!0,composed:!0}))}get points(){return this._points}set points(t){this._points.clear(),t instanceof Map?this._points=t:Array.isArray(t)&&t.forEach(e=>this._points.set(e.ID,e))}get active_points(){return Array.from(this._active_points.values())}get edges(){return this._edges}set edges(t){this._edges.clear(),t instanceof Map?this._edges=t:Array.isArray(t)&&(this._edges=new Map,t.forEach(e=>this._edges.set(e.ID,e)))}get labels(){return this._labels}connectedCallback(){Xt("QEVisualElement connected"),this.render()}setModelData(t){var r,a,h,o;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(_=>{var z;const g=t[_];if(!((z=g==null?void 0:g.data)!=null&&z.length))return;const p=g.data,u=g.types||{},d=Object.keys(p[0]),l=p.map(j=>Object.values(j)),b=d.map(j=>u[j]??"character");let f;_==="networks"?f="name":_==="pointsets"?f="id":_==="nodes"?f=t.node_id_col??d.find(j=>(u[j]??"character")==="character"):_==="edges"||_==="points"||_==="trajectories"?f=t.id_col??d.find(j=>(u[j]??"character")==="character"):f=t.group_col??d.find(j=>(u[j]??"character")==="character");const w=f?d.indexOf(f):0,T=l.map(j=>String(j[w]));this._model.setByKey(_,new Ft(d,l,T,b))}),t.updated!==void 0&&this._model.setByKey("updated",t.updated),t.directed!==void 0&&(this._model.directed=t.directed),Array.isArray(t.palette)&&(this._model.palette=t.palette.map(String));const s=this._model.nodes;this._model.node_id_col=t.node_id_col??((r=s==null?void 0:s.names)==null?void 0:r.find(_=>{var g;return((g=s.col(_))==null?void 0:g.type)==="character"}))??"id";const i=this._model.points;this._model.unit_id_col=t.id_col??((a=i==null?void 0:i.names)==null?void 0:a.find(_=>{var g;return((g=i.col(_))==null?void 0:g.type)==="character"}))??"id";const n=this._model.unit_id_col;if(this._model.group_col=t.group_col??((h=i==null?void 0:i.names)==null?void 0:h.find(_=>{var g;return _!==n&&((g=i.col(_))==null?void 0:g.type)==="character"}))??null,(o=s==null?void 0:s.names)!=null&&o.length){const _=this._model.node_id_col,g=t.x_col,p=t.y_col;if(g&&p)this._model.dimensions=[g,p];else{const u=s.names.filter(d=>{if(d===_)return!1;const l=s.col(d);return l&&l.type!=="character"&&l.type!=="logical"});u.length>=2&&(this._model.dimensions=[g??u[0],p??u[1]])}}this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Xt("Model updated via setModelData:",this.updated),this.render()}async calculate(){}render(){var t;this._isVisible?this.classList.remove("hidden"):this.classList.add("hidden"),((t=this._model)==null?void 0:t.updated)!==void 0&&this._model.updated!==null?this._outputElement.innerHTML=`${this.output}<slot></slot>`:this._outputElement.innerHTML="Define the model on the left."}};c(Jt,"QEVisualElement"),Jt.tagName="qe-visual",Jt.styles=`
|
|
1
|
+
(function(O,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(O=typeof globalThis<"u"?globalThis:O||self,H(O.QEViz={}))})(this,(function(O){"use strict";var In=Object.defineProperty;var Ri=O=>{throw TypeError(O)};var l=(O,H)=>In(O,"name",{value:H,configurable:!0});var $i=(O,H,mt)=>H.has(O)||Ri("Cannot "+mt);var R=(O,H,mt)=>($i(O,H,"read from private field"),mt?mt.call(O):H.get(O)),ct=(O,H,mt)=>H.has(O)?Ri("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(O):H.set(O,mt),V=(O,H,mt,$t)=>($i(O,H,"write to private field"),$t?$t.call(O,mt):H.set(O,mt),mt);var Le,Pe,Re,xt,$e,Te,wt,re,Yt,zt,dt,Fe,Wt,Ot,he,le,Be;const Rs=class Rs extends Array{constructor(e,s,i,n,r){super(...s);ct(this,Le);ct(this,Pe);ct(this,Re);ct(this,xt);ct(this,$e);V(this,Re,e),V(this,Pe,i),V(this,xt,n),V(this,$e,n==null?void 0:n.classes),V(this,Le,r)}get parent(){return R(this,xt)}get names(){return R(this,Re)}get rowName(){return R(this,Pe)}get types(){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).types}get classes(){return R(this,$e)}get rowNumber(){return R(this,Le)}col(e){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).col(e)}cols(...e){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};Le=new WeakMap,Pe=new WeakMap,Re=new WeakMap,xt=new WeakMap,$e=new WeakMap,l(Rs,"DataFrameRow");let H=Rs;var mt=(c=>(c.Character="character",c.Double="double",c.Logical="logical",c.Integer="integer",c))(mt||{});const $s=class $s extends Array{constructor(e,s,i,n){super(s.length);ct(this,Te);ct(this,wt);ct(this,re);ct(this,Yt);for(let r=0;r<s.length;r++)this[r]=s[r];if(V(this,Te,e),s.type!==void 0?V(this,wt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?V(this,wt,"character"):s.every(r=>Number.isInteger(r)||r===null||r===void 0)?s.every(r=>r===0||r===1||r===null||r===void 0)?V(this,wt,"logical"):V(this,wt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?V(this,wt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?V(this,wt,"logical"):V(this,wt,"character"),V(this,Yt,n),i&&i.length!==this.length)throw new Error("Row names length must match the number of rows in the DataFrameColumn.");i&&i.length>0?V(this,re,i):V(this,re,void 0)}get name(){return R(this,Te)}get type(){return R(this,wt)}get rowNames(){return R(this,re)}row(e){if(!R(this,Yt))throw new Error("No parent DataFrame attached to this column.");return R(this,Yt).row(e)}rows(...e){if(!R(this,Yt))throw new Error("No parent DataFrame attached to this column.");return R(this,Yt).rows(...e)}};Te=new WeakMap,wt=new WeakMap,re=new WeakMap,Yt=new WeakMap,l($s,"DataFrameColumn");let $t=$s;const De=class De extends Array{constructor(e,s,i,n){if((!e||!s)&&(s=[],e=[]),s.map(r=>r.length).every(r=>r===e.length)){const r=[];for(let o=0;o<e.length;o++){const a=[];for(let h=0;h<s.length;h++)a.push(s[h][o]);r.push(a)}s=r}super(s.length);ct(this,zt);ct(this,dt);ct(this,Fe);if(s.forEach((r,o)=>{r instanceof $t?this[o]=r:this[o]=new $t(e[o],r,i,this)}),V(this,zt,e),i&&this[0]&&i.length!==this[0].length)throw new Error("Row names length must match the number of rows in the DataFrame.");if(i&&i.length>0&&V(this,dt,i),n&&n.length!==this.length)throw new Error("Classes length must match the number of columns in the DataFrame.");n&&n.length>0&&V(this,Fe,n)}get classes(){return R(this,Fe)}getColumnByName(e){const s=R(this,zt).indexOf(e);return s>=0?this[s]:void 0}getRowByIndex(e){if(this&&this.length===0)return console.warn("DataFrame is empty, cannot get row by index",e),new H(R(this,zt),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new H(R(this,zt),s,R(this,dt)?R(this,dt)[e]:void 0,this,e)}getRowByName(e){if(!R(this,dt))return;const s=R(this,dt).indexOf(e);if(s!==-1)return this.getRowByIndex(s)}get types(){return this.map(e=>e.type)}type(e){var s;if(typeof e=="number")return(s=this[e])==null?void 0:s.type;if(typeof e=="string"){const i=this.getColumnByName(e);return i?i.type:void 0}}row(e){if(typeof e=="number")return this.getRowByIndex(e);if(typeof e=="string")return this.getRowByName(e)}rows(...e){let s,i=[],n=[];if(e.length===0){if(!this[0]||this.length===0)return[];const r=this[0].length;i=Array.from({length:r},(o,a)=>this.getRowByIndex(a)),n=R(this,dt)}else e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map((r,o)=>{let a=this.row(r);return R(this,dt)&&a&&(n==null||n.push(R(this,dt)[o])),a}).filter(r=>r!==void 0);return i}col(e){if(typeof e=="number")return this[e];if(typeof e=="string")return this.getColumnByName(e)}cols(...e){let s,i,n=[];return e.length===0?(i=this.slice(),n=R(this,zt)):(e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map(r=>this.col(r)).filter(r=>r!==void 0),n=i.map(r=>r.name)),new De(n,i,R(this,dt))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new De(i.map(n=>n.name),i.map(n=>n.values),R(this,dt))}get names(){return R(this,zt)}get rowNames(){return R(this,dt)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};zt=new WeakMap,dt=new WeakMap,Fe=new WeakMap,l(De,"DataFrame");let Gt=De;const Ts=class Ts{constructor(t={}){this.unit_id_col="id",this.node_id_col="id",this.group_col=null,this.directed=!1,this.palette=[],this._points=t.points??new Gt,this._nodes=t.nodes??new Gt,this._edges=t.edges??new Gt,this._dimensions=t.dimensions??[],this._confidence=void 0,this._outlier=void 0,this._groups=void 0}get updated(){return this._updated}set updated(t){this._updated=t}get points(){return this._points}set points(t){this._points=t}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get edges(){return this._edges}set edges(t){this._edges=t}get confidence(){return this._confidence}set confidence(t){this._confidence=t}get outlier(){return this._outlier}set outlier(t){this._outlier=t}get groups(){return this._groups}set groups(t){this._groups=t}get trajectories(){return this._trajectories}set trajectories(t){this._trajectories=t}get networks(){return this._networks}set networks(t){this._networks=t}get pointsets(){return this._pointsets}set pointsets(t){this._pointsets=t}get dimensions(){return this._dimensions}set dimensions(t){this._dimensions=t}get params(){return this._params}set params(t){this._params=t}point(t){return this._points.row(t)}setByKey(t,e){this[t]=e}};l(Ts,"Model");let He=Ts;const Ti=globalThis.__QEVIZ_DEBUG__===!0;function Jt(...c){Ti&&console.log(...c)}l(Jt,"dbg");function Ns(c,t){var r,o,a,h;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(g=>{var j;const f=t[g];if(!((j=f==null?void 0:f.data)!=null&&j.length))return;const m=f.data,_=f.types||{},d=Object.keys(m[0]),u=m.map(Y=>Object.values(Y)),b=d.map(Y=>_[Y]??"character");let p;g==="networks"?p="name":g==="pointsets"?p="id":g==="nodes"?p=t.node_id_col??d.find(Y=>(_[Y]??"character")==="character"):g==="edges"||g==="points"||g==="trajectories"?p=t.id_col??d.find(Y=>(_[Y]??"character")==="character"):p=t.group_col??d.find(Y=>(_[Y]??"character")==="character");const w=p?d.indexOf(p):0,I=u.map(Y=>String(Y[w]));c.setByKey(g,new Gt(d,u,I,b))}),c.setByKey("updated",t.updated??Date.now()),t.directed!==void 0&&(c.directed=t.directed),Array.isArray(t.palette)&&(c.palette=t.palette.map(String));const s=c.nodes;c.node_id_col=t.node_id_col??((r=s==null?void 0:s.names)==null?void 0:r.find(g=>{var f;return((f=s.col(g))==null?void 0:f.type)==="character"}))??"id";const i=c.points;c.unit_id_col=t.id_col??((o=i==null?void 0:i.names)==null?void 0:o.find(g=>{var f;return((f=i.col(g))==null?void 0:f.type)==="character"}))??"id";const n=c.unit_id_col;if(c.group_col=t.group_col??((a=i==null?void 0:i.names)==null?void 0:a.find(g=>{var f;return g!==n&&((f=i.col(g))==null?void 0:f.type)==="character"}))??null,(h=s==null?void 0:s.names)!=null&&h.length){const g=c.node_id_col,f=t.x_col,m=t.y_col;if(f&&m)c.dimensions=[f,m];else{const _=s.names.filter(d=>{if(d===g)return!1;const u=s.col(d);return u&&u.type!=="character"&&u.type!=="logical"});_.length>=2&&(c.dimensions=[f??_[0],m??_[1]])}}}l(Ns,"ingestModelData");function oi(c){const t=new He;return Ns(t,c),t}l(oi,"modelFromData");const ai="http://www.w3.org/1999/xhtml",as=class as{constructor(t){this.data=t,this.nodeType=3,this.parentNode=null}get textContent(){return this.data}set textContent(t){this.data=String(t)}get nodeValue(){return this.data}cloneNode(){return new as(this.data)}};l(as,"HeadlessText");let Qt=as;const Fs=class Fs extends Qt{};l(Fs,"HeadlessRaw");let fe=Fs;const hi=l(c=>c.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),"camelToKebab"),qt=class qt{constructor(t,e=ai){this.nodeType=1,this.parentNode=null,this.childNodes=[],this.shadowRoot=null,this._attrs=new Map,this._style=new Map,this.tagName=t??this.constructor.tagName??"div",this.namespaceURI=e;const s=this;this.style=new Proxy({},{get(r,o){if(typeof o=="string")return o==="cssText"?s._cssText():o==="setProperty"?(a,h)=>s._setStyle(a,h):o==="removeProperty"?a=>s._setStyle(a,""):o==="getPropertyValue"?a=>s._style.get(a)??"":s._style.get(hi(o))??""},set(r,o,a){return typeof o=="string"&&s._setStyle(hi(o),a==null?"":String(a)),!0}});const i=l(()=>(this._attrs.get("class")??"").split(/\s+/).filter(Boolean),"classes"),n=l(r=>{r.length?this.setAttribute("class",r.join(" ")):this.removeAttribute("class")},"write");this.classList={add:l((...r)=>{const o=i();r.forEach(a=>{o.includes(a)||o.push(a)}),n(o)},"add"),remove:l((...r)=>n(i().filter(o=>!r.includes(o))),"remove"),contains:l(r=>i().includes(r),"contains"),toggle:l((r,o)=>{const a=i().includes(r),h=o??!a;return h&&!a&&s.classList.add(r),!h&&a&&s.classList.remove(r),h},"toggle")}}_setStyle(t,e){e===""?this._style.delete(t):this._style.set(t,e);const s=this._cssText();s?this.setAttribute("style",s):this.removeAttribute("style")}_cssText(){return[...this._style.entries()].map(([t,e])=>`${t}: ${e};`).join(" ")}getAttribute(t){return this._attrs.has(t)?this._attrs.get(t):null}hasAttribute(t){return this._attrs.has(t)}setAttribute(t,e){this._attrs.set(t,String(e)),t==="style"&&this._syncStyleFromAttribute()}removeAttribute(t){this._attrs.delete(t),t==="style"&&this._style.clear()}getAttributeNames(){return[...this._attrs.keys()]}_syncStyleFromAttribute(){const t=this._attrs.get("style")??"",e=new Map;t.split(";").forEach(s=>{const i=s.indexOf(":");if(i<0)return;const n=s.slice(0,i).trim(),r=s.slice(i+1).trim();n&&r&&e.set(n,r)}),this._style=e}get id(){return this.getAttribute("id")??""}set id(t){this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){this.setAttribute("class",t)}get nodeName(){return this.tagName}get localName(){return this.tagName.toLowerCase()}get parentElement(){return this.parentNode}get children(){return this.childNodes.filter(t=>t instanceof qt)}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get firstElementChild(){return this.children[0]??null}get isConnected(){return!0}get ownerSVGElement(){let t=this.parentNode;for(;t;){if(t.tagName.toLowerCase()==="svg")return t;t=t.parentNode}return null}appendChild(t){return this.insertBefore(t,null)}insertBefore(t,e){t.parentNode&&t.parentNode.removeChild(t);const s=e?this.childNodes.indexOf(e):-1;return s<0?this.childNodes.push(t):this.childNodes.splice(s,0,t),t.parentNode=this,t}removeChild(t){const e=this.childNodes.indexOf(t);return e>=0&&(this.childNodes.splice(e,1),t.parentNode=null),t}replaceChild(t,e){const s=this.childNodes.indexOf(e);return s<0||(t.parentNode&&t.parentNode.removeChild(t),this.childNodes[s]=t,t.parentNode=this,e.parentNode=null),e}remove(){var t;(t=this.parentNode)==null||t.removeChild(this)}replaceWith(t){var e;(e=this.parentNode)==null||e.replaceChild(t,this)}contains(t){let e=t;for(;e;){if(e===this)return!0;e=e.parentNode}return!1}get textContent(){return this.childNodes.map(t=>t.textContent).join("")}set textContent(t){this.childNodes.forEach(e=>{e.parentNode=null}),this.childNodes=[],t!=null&&t!==""&&this.appendChild(new Qt(String(t)))}set innerHTML(t){this.textContent="",t&&this.appendChild(new fe(t))}get innerHTML(){return this.childNodes.map(t=>t instanceof qt?Ze(t,!1):t instanceof fe?t.data:li(t.data)).join("")}cloneNode(t=!1){const e=new qt(this.tagName,this.namespaceURI);return this._attrs.forEach((s,i)=>e._attrs.set(i,s)),e._syncStyleFromAttribute(),t&&this.childNodes.forEach(s=>e.appendChild(s instanceof qt?s.cloneNode(!0):s.cloneNode())),e}attachShadow(t){return this.shadowRoot=new qt("#shadow-root",null),this.shadowRoot.parentNode=this,this.shadowRoot}matches(t){return t.split(",").some(e=>Fi(this,e.trim()))}closest(t){let e=this;for(;e;){if(e.tagName!=="#shadow-root"&&e.matches(t))return e;e=e.parentNode}return null}querySelector(t){for(const e of this.children){if(e.matches(t))return e;const s=e.querySelector(t);if(s)return s}return null}querySelectorAll(t){const e=[],s=l(i=>i.children.forEach(n=>{n.matches(t)&&e.push(n),s(n)}),"walk");return s(this),e}getElementById(t){return this.querySelector(`#${t}`)}getBoundingClientRect(){const t=l(i=>{const n=Number(this.getAttribute(i));return Number.isFinite(n)&&n>0?n:0},"num"),e=t("width"),s=t("height");return{x:0,y:0,left:0,top:0,width:e,height:s,right:e,bottom:s}}get clientWidth(){return this.getBoundingClientRect().width}get clientHeight(){return this.getBoundingClientRect().height}addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};l(qt,"HeadlessElement");let te=qt;function Fi(c,t){if(!t||t==="*")return!!t;const s=/^([a-zA-Z][\w-]*)?((?:#[\w-]+|\.[\w-]+|\[[^\]]+\])*)$/.exec(t);return!s||s[1]&&s[1].toLowerCase()!==c.tagName.toLowerCase()?!1:(s[2].match(/#[\w-]+|\.[\w-]+|\[[^\]]+\]/g)??[]).every(n=>{if(n[0]==="#")return c.getAttribute("id")===n.slice(1);if(n[0]===".")return c.classList.contains(n.slice(1));const r=/^\[([^=~|^$*\]]+)(?:([~|^$*]?)=["']?([^"'\]]*)["']?)?\]$/.exec(n);if(!r)return!1;const o=r[1].trim();if(r[3]===void 0)return c.hasAttribute(o);const a=c.getAttribute(o);if(a==null)return!1;switch(r[2]){case"^":return a.startsWith(r[3]);case"$":return a.endsWith(r[3]);case"*":return a.includes(r[3]);case"~":return a.split(/\s+/).includes(r[3]);default:return a===r[3]}})}l(Fi,"matchesSimple");const Ds=class Ds{constructor(){this.headless=!0}createElement(t){return new te(t.toLowerCase(),ai)}createElementNS(t,e){return new te(e,t)}createTextNode(t){return new Qt(t)}};l(Ds,"HeadlessDocument");let Ve=Ds;const me=new Ve,Di=l(c=>c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),"escapeAttr"),li=l(c=>c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapeText");function Ze(c,t=!0){const e=[],s=l((i,n)=>{if(i instanceof fe){e.push(i.data);return}if(i instanceof Qt){e.push(li(i.data));return}if(i.tagName!=="#shadow-root"){if(e.push("<",i.tagName),t&&i.namespaceURI&&i.namespaceURI!==n&&!i.hasAttribute("xmlns")&&e.push(` xmlns="${i.namespaceURI}"`),i.getAttributeNames().forEach(r=>e.push(` ${r}="${Di(i.getAttribute(r))}"`)),i.childNodes.length===0){e.push("/>");return}e.push(">"),i.childNodes.forEach(r=>s(r,i.namespaceURI)),e.push("</",i.tagName,">")}},"write");return s(c,null),e.join("")}l(Ze,"serializeElement");const ji=.6,Yi=1.2,qi=.9;function Bi(c){const t=c.textContent??"",e=Number(c.getAttribute("font-size")),s=Number(c.getAttribute("x")??0),i=Number(c.getAttribute("y")??0);if(!t||!(e>0)||!Number.isFinite(s)||!Number.isFinite(i))return null;const n=t.length*e*ji,r=c.getAttribute("text-anchor")??"start";return{x:r==="end"?s-n:r==="middle"?s-n/2:s,y:i-e*qi,width:n,height:e*Yi}}l(Bi,"estimateTextBox");function Gi(c){let t=[1,0,0,1,0,0];if(!c)return t;const e=l((s,i)=>[s[0]*i[0]+s[2]*i[1],s[1]*i[0]+s[3]*i[1],s[0]*i[2]+s[2]*i[3],s[1]*i[2]+s[3]*i[3],s[0]*i[4]+s[2]*i[5]+s[4],s[1]*i[4]+s[3]*i[5]+s[5]],"mul");for(const s of c.matchAll(/(matrix|translate|scale)\s*\(([^)]*)\)/g)){const i=s[2].trim().split(/[\s,]+/).map(Number);s[1]==="matrix"&&i.length===6?t=e(t,i):s[1]==="translate"?t=e(t,[1,0,0,1,i[0]||0,i[1]||0]):s[1]==="scale"&&(t=e(t,[i[0]??1,0,0,i[1]??i[0]??1,0,0]))}return t}l(Gi,"parseTransform");function Ui(c){const[t,e,s,i,n,r]=c,o=t*i-e*s;return o?[i/o,-e/o,-s/o,t/o,(s*r-i*n)/o,(e*n-t*r)/o]:null}l(Ui,"invertTransform");function Xi(c,t,e){const s=(c??"").trim().split(/[\s,]+/).map(Number);if(s.length!==4||!s.every(Number.isFinite)||!(s[2]>0)||!(s[3]>0))return null;const[i,n,r,o]=s;if(!(t>0)||!(e>0))return{left:i,right:i+r,top:n,bottom:n+o};const a=Math.min(t/r,e/o),h=t/a,g=e/a,f=i-(h-r)/2,m=n-(g-o)/2;return{left:f,right:f+h,top:m,bottom:m+g}}l(Xi,"visibleViewBox");function ci(){return typeof document<"u"?document:me}l(ci,"defaultDocument");function ui(c){return!!c&&c.headless===!0}l(ui,"isHeadlessDocument");const St=typeof HTMLElement<"u"?HTMLElement:te;function Et(c,t){typeof customElements>"u"||customElements.get(c)||customElements.define(c,t)}l(Et,"defineElement");const Wi={get:l(c=>{const t=[...document.querySelectorAll("qe-graph")];return typeof c=="number"&&c>=0?t[c]:t},"get")},oe=class oe extends St{constructor(){super(),this._isVisible=!0,this.output="",this._updated="",this._active_points=[],this._points=new Map,this._edges=new Map,this._labels=new Map,this._model=new He;const t=this.attachShadow({mode:"open"}),e=ci(),s=e.createElement("style");s.textContent=oe.styles,t.appendChild(s),this._outputElement=e.createElement("div"),t.appendChild(this._outputElement)}static get observedAttributes(){return["updated"]}get model(){return this._model}get updated(){return this._updated}set updated(t){this._updated=t,this.setAttribute("updated",t),this.dispatchEvent(new CustomEvent("model-updated",{detail:this._model,bubbles:!0,composed:!0}))}get points(){return this._points}set points(t){this._points.clear(),t instanceof Map?this._points=t:Array.isArray(t)&&t.forEach(e=>this._points.set(e.ID,e))}get active_points(){return Array.from(this._active_points.values())}get edges(){return this._edges}set edges(t){this._edges.clear(),t instanceof Map?this._edges=t:Array.isArray(t)&&(this._edges=new Map,t.forEach(e=>this._edges.set(e.ID,e)))}get labels(){return this._labels}connectedCallback(){Jt("QEVisualElement connected"),this.render()}setModelData(t){Ns(this._model,t),this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Jt("Model updated via setModelData:",this.updated),this.render()}async calculate(){}render(){var t;this._isVisible?this.classList.remove("hidden"):this.classList.add("hidden"),((t=this._model)==null?void 0:t.updated)!==void 0&&this._model.updated!==null?this._outputElement.innerHTML=`${this.output}<slot></slot>`:this._outputElement.innerHTML="Define the model on the left."}};l(oe,"QEVisualElement"),oe.tagName="qe-visual",oe.styles=`
|
|
2
2
|
:host { display: block; width: 100%; }
|
|
3
3
|
:host(.hidden) { display: none !important; }
|
|
4
4
|
/* The output wrapper and the slotted graph fill the host so the plot
|
|
5
5
|
stretches to its container instead of collapsing to intrinsic size. */
|
|
6
6
|
div { display: block; width: 100%; height: 100%; }
|
|
7
7
|
::slotted(qe-graph) { display: block; width: 100%; height: 100%; }
|
|
8
|
-
`;let oe=Jt;customElements.define(oe.tagName,oe);const ut=class ut{constructor(t){return this.base=typeof t=="string"?t:t.base,new Proxy(this,{get(e,s){if(typeof s=="string"&&/^[0-2]$/.test(s)){const{r:i,g:n,b:r}=ut.parseColor(e.base);return[i,n,r][Number(s)]}return e[s]}})}toString(){return this.base}setBase(t){this.base=t}static parseColor(t){const e=String(t).trim();if(/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e)){const n=parseInt(e.slice(1,7),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}if(/^#[0-9a-f]{3}$/i.test(e)){const[n,r,a]=[1,2,3].map(h=>parseInt(e[h]+e[h],16));return{r:n,g:r,b:a}}const s=e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);if(s)return{r:Math.round(+s[1]),g:Math.round(+s[2]),b:Math.round(+s[3])};const i=ut.resolveCss(e);if(i)return ut.parseColor(i);throw new Error(`Unsupported color format: ${t}`)}static resolveCss(t){if(ut._cssCache.has(t))return ut._cssCache.get(t);ut._ctx===void 0&&(ut._ctx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let e=null;const s=ut._ctx;if(s){s.fillStyle="#000000",s.fillStyle=t;const i=s.fillStyle;s.fillStyle="#ffffff",s.fillStyle=t;const n=s.fillStyle;i===n&&(e=String(i))}return ut._cssCache.set(t,e),e}static rgb(t,e,s){return`rgb(${t}, ${e}, ${s})`}};c(ut,"Color"),ut._cssCache=new Map;let tt=ut;const Ie=class Ie extends tt{constructor(t,e,s){super(t),this.weight=e,this.alpha=s}static toHSV(t){const{r:e,g:s,b:i}=tt.parseColor(t),n=e/255,r=s/255,a=i/255,h=Math.max(n,r,a),o=Math.min(n,r,a),_=h-o,g=h,p=h===0?0:_/h;let u=0;if(_>0)switch(h){case n:u=((r-a)/_+(r<a?6:0))/6;break;case r:u=((a-n)/_+2)/6;break;default:u=((n-r)/_+4)/6}return{h:u*360,s:p,v:g}}static hsvToRgba(t,e,s,i){const n=s*e,r=n*(1-Math.abs(t/60%2-1)),a=s-n;let h=0,o=0,_=0;return t<60?(h=n,o=r,_=0):t<120?(h=r,o=n,_=0):t<180?(h=0,o=n,_=r):t<240?(h=0,o=r,_=n):t<300?(h=r,o=0,_=n):(h=n,o=0,_=r),`rgba(${Math.round((h+a)*255)},${Math.round((o+a)*255)},${Math.round((_+a)*255)},${i.toFixed(4)})`}toString(){const{h:t,v:e}=Ie.toHSV(this.base),s=Math.min(1,Math.abs(this.weight)),i=this.alpha===void 0?s:Math.min(1,Math.max(0,this.alpha));return Ie.hsvToRgba(t,s,e,i)}};c(Ie,"WeightedColor");let ae=Ie;const ms=class ms{constructor(t=null){this._values=[1,0,0,1,0,0],this._keys=["a","b","c","d","e","f"],t&&(this.values=t)}get values(){return this._values}set values(t){t&&t.length===6&&(this._values=t)}get keys(){return this._keys}set keys(t){t&&t.length===6&&(this._keys=t)}toString(){return`matrix(${this.keys.map((e,s)=>this.values[s]).join(" ")})`}toMatrix(){return Object.fromEntries(this._keys.map((t,e)=>[t,this._values[e]]))}toArray(){return this._values}set(t,e){const s=this._keys.indexOf(t);s>=0&&Number.isFinite(e)&&(this._values[s]=e)}get(t){return this._values[this._keys.findIndex(e=>e===t)]}scale(t,e=t){this.a=t,this.d=e}zoom(t){this.a=t,this.d=t}pan(t,e){this.e=this.e+t,this.f=this.f+e}set a(t){this.set("a",t)}set b(t){this.set("b",t)}set c(t){this.set("c",t)}set d(t){this.set("d",t)}set e(t){this.set("e",t)}set f(t){this.set("f",t)}get a(){return this.get("a")}get b(){return this.get("b")}get c(){return this.get("c")}get d(){return this.get("d")}get e(){return this.get("e")}get f(){return this.get("f")}};c(ms,"Transform");let he=ms;var le;(m=>{(t=>{function e(s){return`matrix(${["a","b","c","d","e","f"].map(n=>s[n]).join(" ")})`}c(e,"matrixString"),t.matrixString=e})(m.Matrix||(m.Matrix={})),(t=>{(s=>{function i(r,a,h){const o=e.toRad(a);return[r[0]+h*Math.cos(o),r[1]+h*Math.sin(o)]}c(i,"translate"),s.translate=i;function n(r,a,h){const o=e.toRad(a);function _(g,p){return[g[0]*Math.cos(p)-g[1]*Math.sin(p),g[0]*Math.sin(p)+g[1]*Math.cos(p)]}if(c(_,"rotatePoint"),!h||h[0]===0&&h[1]===0)return _(r,o);{const g=r.map((u,d)=>u-h[d]);return _(g,o).map((u,d)=>u+h[d])}}c(n,"rotate"),s.rotate=n})(t.Point||(t.Point={})),(s=>{function i(l,b){return(b[1]-l[1])/(b[0]-l[0])}c(i,"slope"),s.slope=i;function n(l,b){const f=i(l,b);return l[1]-f*l[0]}c(n,"intercept"),s.intercept=n;function r(l,b){return{slope:i(l,b),intercept:n(l,b)}}c(r,"slopeIntercept"),s.slopeIntercept=r;function a(l,b=0){const f=b,w=(1-f)*l[0][0]+f*l[1][0],T=(1-f)*l[0][1]+f*l[1][1];return[w,T]}c(a,"point_along"),s.point_along=a;function h(l,b,f=.5){return Array.isArray(l[0])&&(b=l[1],l=l[0]),[0,1].map(w=>(parseFloat(l[w])+parseFloat(b[w]))*f)}c(h,"midpoint"),s.midpoint=h;function o(l,b){return Array.isArray(l[0])&&(b=l[1],l=l[0]),Math.sqrt([0,1].map(f=>Math.pow(b[f]-l[f],2)).reduce((f,w)=>f+w,0))}c(o,"length"),s.length=o;function _(l,b=[0,0]){const f=[l[1][0]-b[0],l[1][1]-b[1]],w=[-f[1],f[0]],T=[-w[0],-w[1]],z=[w[0]+b[0],w[1]+b[1]],j=[T[0]+b[0],T[1]+b[1]];return[z,j]}c(_,"rotate"),s.rotate=_;function g(l,b,f=90){const w=m.Geometry.Line.slope(l[0],l[1]),T=m.Geometry.Line.intercept(l[0],l[1]),z=[0,T],j=[1,w+T];l=[z,j];const dt=[l[0][0],l[1][0]],gt=[l[0][1],l[1][1]],et=b[0],mt=b[1],Q=-2*Math.PI*f/360,Tt=dt.map((Gt,Nt)=>(Gt-et)*Math.cos(Q)-(gt[Nt]-mt)*Math.sin(Q)+et),Os=gt.map((Gt,Nt)=>(dt[Nt]-et)*Math.sin(Q)-(Gt-mt)*Math.cos(Q)+mt);return[[Tt[0],Os[0]],[Tt[1],Os[1]]]}c(g,"rotate2"),s.rotate2=g;function p(l,b){const[[f,w],[T,z]]=l,[[j,dt],[gt,et]]=b,mt=(f-T)*(dt-et)-(w-z)*(j-gt),Q=(f*z-w*T)*(j-gt)-(f-T)*(j*et-dt*gt),Tt=(f*z-w*T)*(dt-et)-(w-z)*(j*et-dt*gt);return[Q/mt,Tt/mt]}c(p,"intersection"),s.intersection=p;function u(l,b,f){let{slope:w,intercept:T}=m.Geometry.Line.slopeIntercept(l[0],l[1]),z=1+Math.pow(w,2),j=2*w*T-2*b[1]*w-2*b[0],dt=Math.pow(b[0],2)+Math.pow(T,2)+Math.pow(b[1],2)-2*b[1]*T-Math.pow(f,2),gt=[[1/0,1/0],[1/0,1/0]];if(Math.sqrt(Math.pow(j,2)-4*z*dt)>=0){let et=(-j+Math.sqrt(Math.pow(j,2)-4*z*dt))/(2*z),mt=(-j-Math.sqrt(Math.pow(j,2)-4*z*dt))/(2*z),Q=w*et+T,Tt=w*mt+T;gt=[[et,Q],[mt,Tt]]}else console.error("The line and the circumference do not intersect");return gt}c(u,"intersect_circle"),s.intersect_circle=u;function d(l){return b=>b===0?l[0]:b===1?l[1]:m.Geometry.Point.translate(l[0],m.Geometry.Angle.line(l),m.Geometry.Line.length(l)*b)}c(d,"interpolate"),s.interpolate=d})(t.Line||(t.Line={}));let e;(s=>{function i(a){return a/180*Math.PI}c(i,"toRad"),s.toRad=i;function n(a){return a*180/Math.PI}c(n,"toDeg"),s.toDeg=n;function r(a){if(a.length!==2||!Array.isArray(a[0])||!Array.isArray(a[1])||a[0].length!==2||a[1].length!==2)throw new Error("Invalid line format. Expected [[x1, y1], [x2, y2]].");return m.Geometry.Angle.toDeg(Math.atan2(a[1][1]-a[0][1],a[1][0]-a[0][0]))}c(r,"line"),s.line=r})(e=t.Angle||(t.Angle={}))})(m.Geometry||(m.Geometry={})),(t=>{function e(n){return[...new Set(n)]}c(e,"unique"),t.unique=e;function s(n,r){if(Array.isArray(n)){if(Array.isArray(r)){if(n.length!==r.length)throw new Error("Arrays must be of equal length");return n.map((a,h)=>a/r[h])}return n.map(a=>a/r)}return n/r}c(s,"divide"),t.divide=s;function i(n){return typeof Array.isArray=="function"?Array.isArray(n):n&&typeof n=="object"&&n.constructor.name==="Array"}c(i,"isArray"),t.isArray=i})(m.ArrayTools||(m.ArrayTools={})),(t=>{function e(n){return n.reduce((r,a)=>r+a,0)}c(e,"sum"),t.sum=e;function s(n){return e(n)/n.length}c(s,"mean"),t.mean=s;function i(n,r){const a=Math.pow(10,r);return Math.round(n*a)/a}c(i,"round"),t.round=i})(m.Mathematics||(m.Mathematics={})),(t=>{function e(s,i,n){return new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{element:i,data:n||(i?i.__data__:void 0)}})}c(e,"createEvent"),t.createEvent=e})(m.Events||(m.Events={})),(t=>{function e(){return location.hash.replace(/#/,"").split(/\//).filter(i=>i).map(i=>i.split(/:/))}c(e,"parts"),t.parts=e;function s(i){return e().flat().findIndex(n=>n===i)>=0}c(s,"exists"),t.exists=s})(m.Hash||(m.Hash={})),(t=>{function e(n,r,a=!1){if(a){if(typeof n!="object"||n===null)return n;for(const h in n)Object.prototype.hasOwnProperty.call(n,h)&&(n[h]=e(n[h],r,a));return new Proxy(n,r)}else return new Proxy(n,r)}c(e,"proxy"),t.proxy=e,t.handler={set(n,r,a){return n[r]=a,window.dispatchEvent(m.Events.createEvent("settingUpdate",window,{target:n,property:r,value:a})),!0},get(n,r){return n[r]}};function s(n,r){const a=r.split(".");let h=n;for(const o of a)if(h&&typeof h=="object"&&Object.prototype.hasOwnProperty.call(h,o))h=h[o];else return;return h}c(s,"get"),t.get=s;function i(n,r,a){const h=r.split(".");let o=n,_;for(_=0;_<h.length-1;_++){const g=h[_];if(o&&typeof o=="object")Object.prototype.hasOwnProperty.call(o,g)||(o[g]={}),o=o[g];else return!1}return o&&typeof o=="object"?(o[h[_]]=a,!0):!1}c(i,"set"),t.set=i})(m.Objects||(m.Objects={})),(t=>{function e(s=window.location){return Object.fromEntries(new URLSearchParams(s.search))}c(e,"parse"),t.parse=e,(s=>{function i(a=window.location.search){return Object.fromEntries(a.replace(/^\?/,"").split(/&/).map(h=>h.split(/=/)))}c(i,"parse2"),s.parse=i;function n(a=window.location.search){return a.replace(/^\?/,"").split(/&/).map(h=>h.split(/=/)[0])}c(n,"keys"),s.keys=n;function r(a,h=window.location.search){return n(h).findIndex(o=>o===a)>=0}c(r,"has"),s.has=r})(t.Query||(t.Query={}))})(m.URL||(m.URL={}))})(le||(le={}));const fs=class fs{constructor(){this._state=new Map,this.listeners=new Map}get state(){return this._state}hasVariable(t){return this._state.has(t)}getVariable(t){return this._state.get(t)}setVariable(t,e,s){const i=this._state.get(t);this._state.set(t,e),s!=null&&s.lazy||this.notifyListeners(t,e,i)}addListener(t,e,s){this.listeners.has(t)||this.listeners.set(t,new Map);const i=this.listeners.get(t);i.has(e)||i.set(e,new Set),i.get(e).add(s)}removeListener(t,e,s){var i,n;(n=(i=this.listeners.get(t))==null?void 0:i.get(e))==null||n.delete(s)}getListeners(t,e){var s;return Array.from(((s=this.listeners.get(t))==null?void 0:s.get(e))??[])}notifyListeners(t,e,s){const i=this.listeners.get(t);if(i)for(const n of i.values())n.forEach(r=>{typeof r=="function"?r({key:t,newValue:e,oldValue:s}):typeof r.calculate=="function"&&r.calculate.call(r,{key:t,newValue:e,oldValue:s})})}};c(fs,"EventBus");let Le=fs;const{ArrayTools:Ps}=le,Ne=class Ne extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}c(i,"fn");function n(r,a,h=null){if(Ps.isArray(r)){for(const[o,_]of r.entries())if(s=n(_,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Ps.isArray(r[t])){for(const[o,_]of r[t].entries())if(s=n(_,o,r),s)return s}}return s}return c(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}recurse(t,e,s=null,i=0){let n=new Ne;for(const r of this){let a=e(r,s,i);if(r[t]&&Array.isArray(r[t])){let h=new Ne(...r[t]).recurse(t,e,r,i+1);h!==void 0&&n.push(...h)}n.push(a)}return Xt("Recurse results: ",n),n}};c(Ne,"LayerArray");let Wt=Ne;const ps=class ps{constructor(t,e,s){this.__state__=new Le,this.scale_x=1,this.scale_y=1,this.scale_objects=!0,this.layers=new Wt,this.objects=new Map,this.visible=!0,this.ID=t,this.name=e.name||`layer-${t}`,this.tabindex=e.tabindex,this.parent=s,this._transform=new he,s==null||s.__state__.addListener("graph_updated","live",({key:i,newValue:n,oldValue:r})=>{}),s==null||s.__state__.addListener(`graph_updated_${this.name}`,"live",({key:i,newValue:n,oldValue:r})=>{this.objects=n,this.__state__.setVariable("layer_updated",this)})}get transform(){return this._transform}set transform(t){this._transform=t}};c(ps,"Layer");let ns=ps;const Be=class Be extends Array{constructor(...e){super(arguments.length);nt(this,qt,!1);nt(this,It);for(let s=0;s<e.length;s++)this[s]=e[s];X(this,qt,!1)}static fromArray(e){const s=new Be;return e.forEach((i,n)=>{s.push(i)}),X(s,It,e.names),s}flip(){X(this,qt,!R(this,qt));for(let e=0;e<this.length;e++)this[e]=-this[e];return this}get(e){return typeof e=="number"?this[e]:R(this,It)&&R(this,It).includes(e)?this[R(this,It).indexOf(e)]:void 0}get flipped(){return R(this,qt)}get names(){return R(this,It)?R(this,It):this.map((e,s)=>`V${s+1}`)}};qt=new WeakMap,It=new WeakMap,c(Be,"DimensionVector");let Dt=Be;const bs=class bs{constructor(t,e){this.scale_x=1,this.scale_y=1,this.scale_size=.05,this.active=!1,this.visible=!1,this.highlighting=!1,this.meta={},this._x=0,this._y=0,this._highlight_default=new tt("#000000"),this._size=0,this.ID=e.ID,this._transform=new he,t instanceof Dt?this._dimensions=t:t instanceof U?this._dimensions=Dt.fromArray(t):Array.isArray(t)?this._dimensions=new Dt(...t):(console.warn("Invalid dimensions provided, using default DimensionVector(0, 0)"),this._dimensions=new Dt(0,0));let s={...e};this._original={...s},this.ID=s.ID,this.x=s.x||this._dimensions[0],this.y=s.y||this._dimensions[1],this._size=s.size||1,this._color=s.color||new tt("#000000"),this.active=s.active||!1,this.shape=s.shape||null,this.meta=s.meta||{},this._highlight=this._highlight_default,s.highlight&&(this._highlight=s.highlight)}get dimensions(){return this._dimensions}get color(){return this.highlighting&&this._highlight?this._highlight:this._color}set color(t){this._color=t}get highlight(){return this._highlight||this._highlight_default}set highlight(t){this._highlight=t}get size(){return this._size}set size(t){this._size=t}get original(){return this._original}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}dimension(t){return this._dimensions.get(t)}get transform(){return this._transform}set transform(t){this._transform=t}};c(bs,"PlottedObject");let Pt=bs;const ys=class ys extends Pt{constructor(t,e,s){super([],{}),this.from=e,this.to=s}get line(){return[[this.from.x,this.from.y],[this.to.x,this.to.y]]}get midpoint(){return[(this.from.x+this.to.x)/2,(this.from.y+this.to.y)/2]}get length(){return Math.sqrt(Math.pow(this.to.x-this.from.x,2)+Math.pow(this.to.y-this.from.y,2))}get color(){return this._color}set color(t){this._color=t}};c(ys,"Line");let Ht=ys;const ke=class ke extends Pt{constructor(t){var n,r;let e,s,i;t?t instanceof U?(e=(n=t.classes)==null?void 0:n.map((a,h)=>a==="ena.co.occurrence"||a==="ena.dimension"?t[h]:-1).filter(a=>a!==-1),s=(r=t.classes)==null?void 0:r.map((a,h)=>a==="ena.metadata"?[t.names[h],t[h]]:null).filter(a=>a!==null).reduce((a,h)=>(a[h[0]]=h[1],a),{}),i=t.rowName||`point-${Math.random().toString(36).substring(2,9)}`):typeof t=="object"?(e=t.dimensions||[],s=t.meta||{},i=t.ID||`point-${Math.random().toString(36).substring(2,9)}`):(console.warn("Invalid data provided for Point, using default values"),e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`):(e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`),super(e??[],{meta:s,ID:i}),this.edges=new Map,this.shape=ke.SHAPES.CIRCLE}set label(t){this._label=t}get label(){return this._label}get x(){return this._x}get y(){return this._y}set x(t){this._x=parseFloat(t)}set y(t){this._y=parseFloat(t)}};c(ke,"Point"),ke.SHAPES={CIRCLE:"circle",SQUARE:"rect"};let J=ke;const Qt=class Qt extends Pt{constructor(t,e){super(e.dimensions,e),this._visible=!1,this.offset=0,this.text=t,this.ID=e.ID,this.object=e,this.x=this.dimensions[0],this.y=this.dimensions[1],this.offset=e.size||0,this.size=this.offset/4,this.visible=!1,this._transform.set("e",1),this._transform.set("f",1)}get x(){return parseFloat(this._x)}get y(){return parseFloat(this._y)}set x(t){this._x=t}set y(t){this._y=t}get transform(){return console.warn("transform is disabled - need updated reference for the graph options"),this._transform}set transform(t){this._transform=t}};c(Qt,"Label"),Qt.DISPLAY_TYPES={OFF:0,AUTO:1,CLICK:2,ON:3},Qt.HIGHLIGHT={OFF:0,ON:2},Qt.POSITION={OBJECT:1,STATIC:2,CONTAINER:3,CUSTOM:4};let q=Qt;const xs=class xs{constructor(t,e,s=0,i=0){this.x_max=t,this.y_max=e,this.cx=s,this.cy=i}as_viewBox(t=1.2){let e=this.x_max*t,s=this.y_max*t;return`${this.cx-e} ${this.cy-s} ${e*2} ${s*2}`}get height(){return this.y_max*2}get width(){return this.x_max*2}get top(){return this.y_max*-1}get bottom(){return this.y_max}get left(){return this.x_max*-1}get right(){return this.x_max}};c(xs,"Extremes");let Lt=xs;const ws=class ws extends Pt{constructor(t,e){super(t,e),this.visible=!0,this.size=e.size}set size(t){this._size=t}get size(){return this._size}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}get transform(){return this._transform}};c(ws,"AxisPoint");let rs=ws,Ls={GRAPH:{ratio:1,x_max:1,y_max:1,selector:"body",width:1,height:1,axes:!0,SIZE_EFFECT:1,dimensions:[0,1]},NODE:{size:1,highlight:{color:"yellow",labels:q.DISPLAY_TYPES.ON},labels:q.DISPLAY_TYPES.ON,labelposition:q.POSITION.OBJECT},POINT:{active:2,size:.05,color:"#000",shape:J.SHAPES.CIRCLE,labels:q.DISPLAY_TYPES.AUTO,labelposition:q.POSITION.OBJECT},MEAN:{shape:J.SHAPES.SQUARE,labels:q.DISPLAY_TYPES.AUTO},LABEL:{highlight:q.HIGHLIGHT.OFF,position:["top","left"],container:"#label-container"},EDGE:{multiplier:1}};const vs=class vs{constructor(t={...Ls}){this.__state__=new Le,this.name="unnamed-graph",this.origin=void 0,this.points=new Map,this.nodes=new Map,this.edges=new Map,this.trajectories=new Map,this.labels=new Map,this.transform=new he,this.scale_x=1,this.scale_y=1,this.SIZE_EFFECT=1,this._mirror_y=!0,this._mirror_x=!1,this._layers=new Wt({name:"graph",tabindex:0,layers:[{name:"axes",layers:[{name:"axis_lines",tabindex:0,layers:[],objects:[]},{name:"axis_labels",tabindex:0,layers:[],objects:[]},{name:"axis_points",tabindex:0,layers:[],objects:[this.origin]}]},{name:"network",layers:[{name:"edges",layers:[],tabindex:0},{name:"nodes",layers:[],tabindex:0},{name:"edgenodes",layers:[],tabindex:0}]},{name:"trajectories",layers:[],tabindex:0},{name:"points",layers:[],tabindex:0},{name:"labels",layers:[],tabindex:0}]}),this.options=t,this.origin=new rs(new Dt(0,0),{ID:"origin",x:0,y:0,size:0,meta:{},graph:this,color:new tt("#FFFFFF"),highlight:new tt("#FFFFFF"),active:!1});let e=1;function s(r,a,h){const o=new ns(`${e}`,r,h);return e+=1,o.parent=a||void 0,r.layers&&Array.isArray(r.layers)&&(o.layers=new Wt(...r.layers.map(_=>s(_,o,h)))),o}c(s,"buildLayerTree"),this.layers=new Wt(...this._layers.map(r=>s(r,null,this)));let i=this.layers.search("layers","axis_points");i&&i.objects.set(this.origin.ID,this.origin);let n=this.layers.search("layers","axis_lines");if(n){let r=this.extremes||new Lt(1,1),a=new Ht({},new J({ID:"axis-x-start",dimensions:[-r.x_max,0],classes:["ena.dimension","ena.dimension"]}),new J({ID:"axis-x-end",dimensions:[r.x_max,0],classes:["ena.dimension","ena.dimension"]}));a.ID="axis-x",n.objects.set(a.ID,a);let h=new Ht({},new J({ID:"axis-y-start",dimensions:[0,-r.y_max],classes:["ena.dimension","ena.dimension"]}),new J({ID:"axis-y-end",dimensions:[0,r.y_max],classes:["ena.dimension","ena.dimension"]}));h.ID="axis-y",n.objects.set(h.ID,h),Xt("Added axis lines to layer: ",n)}this.extremes=new Lt(t.GRAPH.x_max,t.GRAPH.y_max)}set extremes(t){this._extremes=t}get extremes(){return this._extremes}get mirror_x(){return this._mirror_x}set mirror_x(t){this._mirror_x=t}get mirror_y(){return this._mirror_y}set mirror_y(t){this._mirror_y=t}x_mirror(){return this.mirror_x?-1:1}y_mirror(){return this.mirror_y?-1:1}add_point(t){const e=new J(t);this.points.set(e.ID,e)}add_points(t){let e=this;t.rows().forEach(s=>{e.add_point(s)})}add_nodes(t){let e=this;t.forEach(s=>{s.label=new q(s.ID,s),e.labels.set(s.label.ID,s.label),e.nodes.set(s.ID,s);const i=e.layers.search("layers","nodes");i&&i.objects.push(s)}),e.update_extremes()}add_edge(t,e,s){return this.edges.set(t.ID,t),this.add_nodes([e||t.from,s||t.to]),t}add_edges(t){let e=t.map(i=>this.add_edge(i));const s=this.layers.search("layers","edges");return s&&s.objects.push(...e),e}update_extremes(t=!1){const e=[this.layers.search("layers","points"),this.layers.search("layers","nodes")].filter(s=>s!==void 0);if(e.length===0)this.extremes=new Lt(1,1);else{let s=1/0,i=-1/0,n=1/0,r=-1/0;e.forEach(p=>p.objects.forEach(u=>{Number.isFinite(u.x)&&(s=Math.min(s,u.x),i=Math.max(i,u.x)),Number.isFinite(u.y)&&(n=Math.min(n,u.y),r=Math.max(r,u.y))}));const a=Number.isFinite(s)&&Number.isFinite(n),h=t&&a?(s+i)/2:0,o=t&&a?(n+r)/2:0,_=a?Math.max(Math.abs(s-h),Math.abs(i-h),Math.abs(n-o),Math.abs(r-o)):0,g=(_>0?_:1)*1.3;this.extremes=new Lt(g,g,h,o)}}nodeExtentFrom(t,e){const s=this.layers.search("layers","nodes");let i=0;return s==null||s.objects.forEach(n=>{Number.isFinite(n.x)&&Number.isFinite(n.y)&&(i=Math.max(i,Math.abs(n.x-t),Math.abs(n.y-e)))}),i}base_point_size(t=8){let e=Math.min(this.extremes.x_max,this.extremes.y_max),s=this.points.size+this.nodes.size;return Math.min(1,e/(Math.sqrt(s)*t))}};c(vs,"Graph");let Re=vs;const Ue=class Ue extends HTMLElement{constructor(){super(),this.element=null,this.object=null;const t=this,e=t.attachShadow({mode:"open"}),s=document.createElement("style"),i=document.createElement("div");s.textContent=this.constructor.style,e.appendChild(s),i.setAttribute("class","wrapper"),e.appendChild(i)}get wrapper(){const t=this,e=t.shadowRoot;return e==null?void 0:e.querySelector(".wrapper")}};c(Ue,"DrawableElement"),Ue.style=`
|
|
8
|
+
`;let pe=oe;Et(pe.tagName,pe);const ot=class ot{constructor(t){return this.base=typeof t=="string"?t:t.base,new Proxy(this,{get(e,s){if(typeof s=="string"&&/^[0-2]$/.test(s)){const{r:i,g:n,b:r}=ot.parseColor(e.base);return[i,n,r][Number(s)]}return e[s]}})}toString(){return this.base}setBase(t){this.base=t}static parseColor(t){const e=String(t).trim();if(/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e)){const n=parseInt(e.slice(1,7),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}if(/^#[0-9a-f]{3}$/i.test(e)){const[n,r,o]=[1,2,3].map(a=>parseInt(e[a]+e[a],16));return{r:n,g:r,b:o}}const s=e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);if(s)return{r:Math.round(+s[1]),g:Math.round(+s[2]),b:Math.round(+s[3])};const i=ot.resolveCss(e);if(i)return ot.parseColor(i);throw new Error(`Unsupported color format: ${t}`)}static namedColor(t){ot._named||(ot._named=new Map(Hi.split(" ").map(s=>s.split(":"))));const e=ot._named.get(t.trim().toLowerCase());return e?`#${e}`:null}static resolveCss(t){if(ot._cssCache.has(t))return ot._cssCache.get(t);const e=ot.namedColor(t);if(e)return ot._cssCache.set(t,e),e;ot._ctx===void 0&&(ot._ctx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let s=null;const i=ot._ctx;if(i){i.fillStyle="#000000",i.fillStyle=t;const n=i.fillStyle;i.fillStyle="#ffffff",i.fillStyle=t;const r=i.fillStyle;n===r&&(s=String(n))}return ot._cssCache.set(t,s),s}static rgb(t,e,s){return`rgb(${t}, ${e}, ${s})`}};l(ot,"Color"),ot._cssCache=new Map;let rt=ot;const je=class je extends rt{constructor(t,e,s){super(t),this.weight=e,this.alpha=s}static toHSV(t){const{r:e,g:s,b:i}=rt.parseColor(t),n=e/255,r=s/255,o=i/255,a=Math.max(n,r,o),h=Math.min(n,r,o),g=a-h,f=a,m=a===0?0:g/a;let _=0;if(g>0)switch(a){case n:_=((r-o)/g+(r<o?6:0))/6;break;case r:_=((o-n)/g+2)/6;break;default:_=((n-r)/g+4)/6}return{h:_*360,s:m,v:f}}static hsvToRgba(t,e,s,i){const n=s*e,r=n*(1-Math.abs(t/60%2-1)),o=s-n;let a=0,h=0,g=0;return t<60?(a=n,h=r,g=0):t<120?(a=r,h=n,g=0):t<180?(a=0,h=n,g=r):t<240?(a=0,h=r,g=n):t<300?(a=r,h=0,g=n):(a=n,h=0,g=r),`rgba(${Math.round((a+o)*255)},${Math.round((h+o)*255)},${Math.round((g+o)*255)},${i.toFixed(4)})`}toString(){const{h:t,v:e}=je.toHSV(this.base),s=Math.min(1,Math.abs(this.weight)),i=this.alpha===void 0?s:Math.min(1,Math.max(0,this.alpha));return je.hsvToRgba(t,s,e,i)}};l(je,"WeightedColor");let be=je;const Hi="aliceblue:f0f8ff antiquewhite:faebd7 aqua:00ffff aquamarine:7fffd4 azure:f0ffff beige:f5f5dc bisque:ffe4c4 black:000000 blanchedalmond:ffebcd blue:0000ff blueviolet:8a2be2 brown:a52a2a burlywood:deb887 cadetblue:5f9ea0 chartreuse:7fff00 chocolate:d2691e coral:ff7f50 cornflowerblue:6495ed cornsilk:fff8dc crimson:dc143c cyan:00ffff darkblue:00008b darkcyan:008b8b darkgoldenrod:b8860b darkgray:a9a9a9 darkgreen:006400 darkgrey:a9a9a9 darkkhaki:bdb76b darkmagenta:8b008b darkolivegreen:556b2f darkorange:ff8c00 darkorchid:9932cc darkred:8b0000 darksalmon:e9967a darkseagreen:8fbc8f darkslateblue:483d8b darkslategray:2f4f4f darkslategrey:2f4f4f darkturquoise:00ced1 darkviolet:9400d3 deeppink:ff1493 deepskyblue:00bfff dimgray:696969 dimgrey:696969 dodgerblue:1e90ff firebrick:b22222 floralwhite:fffaf0 forestgreen:228b22 fuchsia:ff00ff gainsboro:dcdcdc ghostwhite:f8f8ff gold:ffd700 goldenrod:daa520 gray:808080 green:008000 greenyellow:adff2f grey:808080 honeydew:f0fff0 hotpink:ff69b4 indianred:cd5c5c indigo:4b0082 ivory:fffff0 khaki:f0e68c lavender:e6e6fa lavenderblush:fff0f5 lawngreen:7cfc00 lemonchiffon:fffacd lightblue:add8e6 lightcoral:f08080 lightcyan:e0ffff lightgoldenrodyellow:fafad2 lightgray:d3d3d3 lightgreen:90ee90 lightgrey:d3d3d3 lightpink:ffb6c1 lightsalmon:ffa07a lightseagreen:20b2aa lightskyblue:87cefa lightslategray:778899 lightslategrey:778899 lightsteelblue:b0c4de lightyellow:ffffe0 lime:00ff00 limegreen:32cd32 linen:faf0e6 magenta:ff00ff maroon:800000 mediumaquamarine:66cdaa mediumblue:0000cd mediumorchid:ba55d3 mediumpurple:9370db mediumseagreen:3cb371 mediumslateblue:7b68ee mediumspringgreen:00fa9a mediumturquoise:48d1cc mediumvioletred:c71585 midnightblue:191970 mintcream:f5fffa mistyrose:ffe4e1 moccasin:ffe4b5 navajowhite:ffdead navy:000080 oldlace:fdf5e6 olive:808000 olivedrab:6b8e23 orange:ffa500 orangered:ff4500 orchid:da70d6 palegoldenrod:eee8aa palegreen:98fb98 paleturquoise:afeeee palevioletred:db7093 papayawhip:ffefd5 peachpuff:ffdab9 peru:cd853f pink:ffc0cb plum:dda0dd powderblue:b0e0e6 purple:800080 rebeccapurple:663399 red:ff0000 rosybrown:bc8f8f royalblue:4169e1 saddlebrown:8b4513 salmon:fa8072 sandybrown:f4a460 seagreen:2e8b57 seashell:fff5ee sienna:a0522d silver:c0c0c0 skyblue:87ceeb slateblue:6a5acd slategray:708090 slategrey:708090 snow:fffafa springgreen:00ff7f steelblue:4682b4 tan:d2b48c teal:008080 thistle:d8bfd8 tomato:ff6347 turquoise:40e0d0 violet:ee82ee wheat:f5deb3 white:ffffff whitesmoke:f5f5f5 yellow:ffff00 yellowgreen:9acd32",js=class js{constructor(t=null){this._values=[1,0,0,1,0,0],this._keys=["a","b","c","d","e","f"],t&&(this.values=t)}get values(){return this._values}set values(t){t&&t.length===6&&(this._values=t)}get keys(){return this._keys}set keys(t){t&&t.length===6&&(this._keys=t)}toString(){return`matrix(${this.keys.map((e,s)=>this.values[s]).join(" ")})`}toMatrix(){return Object.fromEntries(this._keys.map((t,e)=>[t,this._values[e]]))}toArray(){return this._values}set(t,e){const s=this._keys.indexOf(t);s>=0&&Number.isFinite(e)&&(this._values[s]=e)}get(t){return this._values[this._keys.findIndex(e=>e===t)]}scale(t,e=t){this.a=t,this.d=e}zoom(t){this.a=t,this.d=t}pan(t,e){this.e=this.e+t,this.f=this.f+e}set a(t){this.set("a",t)}set b(t){this.set("b",t)}set c(t){this.set("c",t)}set d(t){this.set("d",t)}set e(t){this.set("e",t)}set f(t){this.set("f",t)}get a(){return this.get("a")}get b(){return this.get("b")}get c(){return this.get("c")}get d(){return this.get("d")}get e(){return this.get("e")}get f(){return this.get("f")}};l(js,"Transform");let ye=js;var xe;(c=>{(t=>{function e(s){return`matrix(${["a","b","c","d","e","f"].map(n=>s[n]).join(" ")})`}l(e,"matrixString"),t.matrixString=e})(c.Matrix||(c.Matrix={})),(t=>{(s=>{function i(r,o,a){const h=e.toRad(o);return[r[0]+a*Math.cos(h),r[1]+a*Math.sin(h)]}l(i,"translate"),s.translate=i;function n(r,o,a){const h=e.toRad(o);function g(f,m){return[f[0]*Math.cos(m)-f[1]*Math.sin(m),f[0]*Math.sin(m)+f[1]*Math.cos(m)]}if(l(g,"rotatePoint"),!a||a[0]===0&&a[1]===0)return g(r,h);{const f=r.map((_,d)=>_-a[d]);return g(f,h).map((_,d)=>_+a[d])}}l(n,"rotate"),s.rotate=n})(t.Point||(t.Point={})),(s=>{function i(u,b){return(b[1]-u[1])/(b[0]-u[0])}l(i,"slope"),s.slope=i;function n(u,b){const p=i(u,b);return u[1]-p*u[0]}l(n,"intercept"),s.intercept=n;function r(u,b){return{slope:i(u,b),intercept:n(u,b)}}l(r,"slopeIntercept"),s.slopeIntercept=r;function o(u,b=0){const p=b,w=(1-p)*u[0][0]+p*u[1][0],I=(1-p)*u[0][1]+p*u[1][1];return[w,I]}l(o,"point_along"),s.point_along=o;function a(u,b,p=.5){return Array.isArray(u[0])&&(b=u[1],u=u[0]),[0,1].map(w=>(parseFloat(u[w])+parseFloat(b[w]))*p)}l(a,"midpoint"),s.midpoint=a;function h(u,b){return Array.isArray(u[0])&&(b=u[1],u=u[0]),Math.sqrt([0,1].map(p=>Math.pow(b[p]-u[p],2)).reduce((p,w)=>p+w,0))}l(h,"length"),s.length=h;function g(u,b=[0,0]){const p=[u[1][0]-b[0],u[1][1]-b[1]],w=[-p[1],p[0]],I=[-w[0],-w[1]],j=[w[0]+b[0],w[1]+b[1]],Y=[I[0]+b[0],I[1]+b[1]];return[j,Y]}l(g,"rotate"),s.rotate=g;function f(u,b,p=90){const w=c.Geometry.Line.slope(u[0],u[1]),I=c.Geometry.Line.intercept(u[0],u[1]),j=[0,I],Y=[1,w+I];u=[j,Y];const st=[u[0][0],u[1][0]],A=[u[0][1],u[1][1]],U=b[0],nt=b[1],Mt=-2*Math.PI*p/360,Lt=st.map((Bt,ue)=>(Bt-U)*Math.cos(Mt)-(A[ue]-nt)*Math.sin(Mt)+U),ws=A.map((Bt,ue)=>(st[ue]-U)*Math.sin(Mt)-(Bt-nt)*Math.cos(Mt)+nt);return[[Lt[0],ws[0]],[Lt[1],ws[1]]]}l(f,"rotate2"),s.rotate2=f;function m(u,b){const[[p,w],[I,j]]=u,[[Y,st],[A,U]]=b,nt=(p-I)*(st-U)-(w-j)*(Y-A),Mt=(p*j-w*I)*(Y-A)-(p-I)*(Y*U-st*A),Lt=(p*j-w*I)*(st-U)-(w-j)*(Y*U-st*A);return[Mt/nt,Lt/nt]}l(m,"intersection"),s.intersection=m;function _(u,b,p){let{slope:w,intercept:I}=c.Geometry.Line.slopeIntercept(u[0],u[1]),j=1+Math.pow(w,2),Y=2*w*I-2*b[1]*w-2*b[0],st=Math.pow(b[0],2)+Math.pow(I,2)+Math.pow(b[1],2)-2*b[1]*I-Math.pow(p,2),A=[[1/0,1/0],[1/0,1/0]];if(Math.sqrt(Math.pow(Y,2)-4*j*st)>=0){let U=(-Y+Math.sqrt(Math.pow(Y,2)-4*j*st))/(2*j),nt=(-Y-Math.sqrt(Math.pow(Y,2)-4*j*st))/(2*j),Mt=w*U+I,Lt=w*nt+I;A=[[U,Mt],[nt,Lt]]}else console.error("The line and the circumference do not intersect");return A}l(_,"intersect_circle"),s.intersect_circle=_;function d(u){return b=>b===0?u[0]:b===1?u[1]:c.Geometry.Point.translate(u[0],c.Geometry.Angle.line(u),c.Geometry.Line.length(u)*b)}l(d,"interpolate"),s.interpolate=d})(t.Line||(t.Line={}));let e;(s=>{function i(o){return o/180*Math.PI}l(i,"toRad"),s.toRad=i;function n(o){return o*180/Math.PI}l(n,"toDeg"),s.toDeg=n;function r(o){if(o.length!==2||!Array.isArray(o[0])||!Array.isArray(o[1])||o[0].length!==2||o[1].length!==2)throw new Error("Invalid line format. Expected [[x1, y1], [x2, y2]].");return c.Geometry.Angle.toDeg(Math.atan2(o[1][1]-o[0][1],o[1][0]-o[0][0]))}l(r,"line"),s.line=r})(e=t.Angle||(t.Angle={}))})(c.Geometry||(c.Geometry={})),(t=>{function e(n){return[...new Set(n)]}l(e,"unique"),t.unique=e;function s(n,r){if(Array.isArray(n)){if(Array.isArray(r)){if(n.length!==r.length)throw new Error("Arrays must be of equal length");return n.map((o,a)=>o/r[a])}return n.map(o=>o/r)}return n/r}l(s,"divide"),t.divide=s;function i(n){return typeof Array.isArray=="function"?Array.isArray(n):n&&typeof n=="object"&&n.constructor.name==="Array"}l(i,"isArray"),t.isArray=i})(c.ArrayTools||(c.ArrayTools={})),(t=>{function e(n){return n.reduce((r,o)=>r+o,0)}l(e,"sum"),t.sum=e;function s(n){return e(n)/n.length}l(s,"mean"),t.mean=s;function i(n,r){const o=Math.pow(10,r);return Math.round(n*o)/o}l(i,"round"),t.round=i})(c.Mathematics||(c.Mathematics={})),(t=>{function e(s,i,n){return new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{element:i,data:n||(i?i.__data__:void 0)}})}l(e,"createEvent"),t.createEvent=e})(c.Events||(c.Events={})),(t=>{function e(){return location.hash.replace(/#/,"").split(/\//).filter(i=>i).map(i=>i.split(/:/))}l(e,"parts"),t.parts=e;function s(i){return e().flat().findIndex(n=>n===i)>=0}l(s,"exists"),t.exists=s})(c.Hash||(c.Hash={})),(t=>{function e(n,r,o=!1){if(o){if(typeof n!="object"||n===null)return n;for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&(n[a]=e(n[a],r,o));return new Proxy(n,r)}else return new Proxy(n,r)}l(e,"proxy"),t.proxy=e,t.handler={set(n,r,o){return n[r]=o,window.dispatchEvent(c.Events.createEvent("settingUpdate",window,{target:n,property:r,value:o})),!0},get(n,r){return n[r]}};function s(n,r){const o=r.split(".");let a=n;for(const h of o)if(a&&typeof a=="object"&&Object.prototype.hasOwnProperty.call(a,h))a=a[h];else return;return a}l(s,"get"),t.get=s;function i(n,r,o){const a=r.split(".");let h=n,g;for(g=0;g<a.length-1;g++){const f=a[g];if(h&&typeof h=="object")Object.prototype.hasOwnProperty.call(h,f)||(h[f]={}),h=h[f];else return!1}return h&&typeof h=="object"?(h[a[g]]=o,!0):!1}l(i,"set"),t.set=i})(c.Objects||(c.Objects={})),(t=>{function e(s=window.location){return Object.fromEntries(new URLSearchParams(s.search))}l(e,"parse"),t.parse=e,(s=>{function i(o=window.location.search){return Object.fromEntries(o.replace(/^\?/,"").split(/&/).map(a=>a.split(/=/)))}l(i,"parse2"),s.parse=i;function n(o=window.location.search){return o.replace(/^\?/,"").split(/&/).map(a=>a.split(/=/)[0])}l(n,"keys"),s.keys=n;function r(o,a=window.location.search){return n(a).findIndex(h=>h===o)>=0}l(r,"has"),s.has=r})(t.Query||(t.Query={}))})(c.URL||(c.URL={}))})(xe||(xe={}));const Ys=class Ys{constructor(){this._state=new Map,this.listeners=new Map}get state(){return this._state}hasVariable(t){return this._state.has(t)}getVariable(t){return this._state.get(t)}setVariable(t,e,s){const i=this._state.get(t);this._state.set(t,e),s!=null&&s.lazy||this.notifyListeners(t,e,i)}addListener(t,e,s){this.listeners.has(t)||this.listeners.set(t,new Map);const i=this.listeners.get(t);i.has(e)||i.set(e,new Set),i.get(e).add(s)}removeListener(t,e,s){var i,n;(n=(i=this.listeners.get(t))==null?void 0:i.get(e))==null||n.delete(s)}getListeners(t,e){var s;return Array.from(((s=this.listeners.get(t))==null?void 0:s.get(e))??[])}notifyListeners(t,e,s){const i=this.listeners.get(t);if(i)for(const n of i.values())n.forEach(r=>{typeof r=="function"?r({key:t,newValue:e,oldValue:s}):typeof r.calculate=="function"&&r.calculate.call(r,{key:t,newValue:e,oldValue:s})})}};l(Ys,"EventBus");let Ke=Ys;const{ArrayTools:_i}=xe,Ye=class Ye extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}l(i,"fn");function n(r,o,a=null){if(_i.isArray(r)){for(const[h,g]of r.entries())if(s=n(g,h,a),s)return s}else{if(s=i(r),s)return s;if(r&&_i.isArray(r[t])){for(const[h,g]of r[t].entries())if(s=n(g,h,r),s)return s}}return s}return l(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}recurse(t,e,s=null,i=0){let n=new Ye;for(const r of this){let o=e(r,s,i);if(r[t]&&Array.isArray(r[t])){let a=new Ye(...r[t]).recurse(t,e,r,i+1);a!==void 0&&n.push(...a)}n.push(o)}return Jt("Recurse results: ",n),n}};l(Ye,"LayerArray");let ee=Ye;const qs=class qs{constructor(t,e,s){this.__state__=new Ke,this.scale_x=1,this.scale_y=1,this.scale_objects=!0,this.layers=new ee,this.objects=new Map,this.visible=!0,this.ID=t,this.name=e.name||`layer-${t}`,this.tabindex=e.tabindex,this.parent=s,this._transform=new ye,s==null||s.__state__.addListener("graph_updated","live",({key:i,newValue:n,oldValue:r})=>{}),s==null||s.__state__.addListener(`graph_updated_${this.name}`,"live",({key:i,newValue:n,oldValue:r})=>{this.objects=n,this.__state__.setVariable("layer_updated",this)})}get transform(){return this._transform}set transform(t){this._transform=t}};l(qs,"Layer");let Ms=qs;const hs=class hs extends Array{constructor(...e){super(arguments.length);ct(this,Wt,!1);ct(this,Ot);for(let s=0;s<e.length;s++)this[s]=e[s];V(this,Wt,!1)}static fromArray(e){const s=new hs;return e.forEach((i,n)=>{s.push(i)}),V(s,Ot,e.names),s}flip(){V(this,Wt,!R(this,Wt));for(let e=0;e<this.length;e++)this[e]=-this[e];return this}get(e){return typeof e=="number"?this[e]:R(this,Ot)&&R(this,Ot).includes(e)?this[R(this,Ot).indexOf(e)]:void 0}get flipped(){return R(this,Wt)}get names(){return R(this,Ot)?R(this,Ot):this.map((e,s)=>`V${s+1}`)}};Wt=new WeakMap,Ot=new WeakMap,l(hs,"DimensionVector");let Ut=hs;const Bs=class Bs{constructor(t,e){this.scale_x=1,this.scale_y=1,this.scale_size=.05,this.active=!1,this.visible=!1,this.highlighting=!1,this.meta={},this._x=0,this._y=0,this._highlight_default=new rt("#000000"),this._size=0,this.ID=e.ID,this._transform=new ye,t instanceof Ut?this._dimensions=t:t instanceof H?this._dimensions=Ut.fromArray(t):Array.isArray(t)?this._dimensions=new Ut(...t):(console.warn("Invalid dimensions provided, using default DimensionVector(0, 0)"),this._dimensions=new Ut(0,0));let s={...e};this._original={...s},this.ID=s.ID,this.x=s.x||this._dimensions[0],this.y=s.y||this._dimensions[1],this._size=s.size||1,this._color=s.color||new rt("#000000"),this.active=s.active||!1,this.shape=s.shape||null,this.meta=s.meta||{},this._highlight=this._highlight_default,s.highlight&&(this._highlight=s.highlight)}get dimensions(){return this._dimensions}get color(){return this.highlighting&&this._highlight?this._highlight:this._color}set color(t){this._color=t}get highlight(){return this._highlight||this._highlight_default}set highlight(t){this._highlight=t}get size(){return this._size}set size(t){this._size=t}get original(){return this._original}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}dimension(t){return this._dimensions.get(t)}get transform(){return this._transform}set transform(t){this._transform=t}};l(Bs,"PlottedObject");let Tt=Bs;const Gs=class Gs extends Tt{constructor(t,e,s){super([],{}),this.from=e,this.to=s}get line(){return[[this.from.x,this.from.y],[this.to.x,this.to.y]]}get midpoint(){return[(this.from.x+this.to.x)/2,(this.from.y+this.to.y)/2]}get length(){return Math.sqrt(Math.pow(this.to.x-this.from.x,2)+Math.pow(this.to.y-this.from.y,2))}get color(){return this._color}set color(t){this._color=t}};l(Gs,"Line");let se=Gs;const qe=class qe extends Tt{constructor(t){var n,r;let e,s,i;t?t instanceof H?(e=(n=t.classes)==null?void 0:n.map((o,a)=>o==="ena.co.occurrence"||o==="ena.dimension"?t[a]:-1).filter(o=>o!==-1),s=(r=t.classes)==null?void 0:r.map((o,a)=>o==="ena.metadata"?[t.names[a],t[a]]:null).filter(o=>o!==null).reduce((o,a)=>(o[a[0]]=a[1],o),{}),i=t.rowName||`point-${Math.random().toString(36).substring(2,9)}`):typeof t=="object"?(e=t.dimensions||[],s=t.meta||{},i=t.ID||`point-${Math.random().toString(36).substring(2,9)}`):(console.warn("Invalid data provided for Point, using default values"),e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`):(e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`),super(e??[],{meta:s,ID:i}),this.edges=new Map,this.shape=qe.SHAPES.CIRCLE}set label(t){this._label=t}get label(){return this._label}get x(){return this._x}get y(){return this._y}set x(t){this._x=parseFloat(t)}set y(t){this._y=parseFloat(t)}};l(qe,"Point"),qe.SHAPES={CIRCLE:"circle",SQUARE:"rect"};let it=qe;const ae=class ae extends Tt{constructor(t,e){super(e.dimensions,e),this._visible=!1,this.offset=0,this.text=t,this.ID=e.ID,this.object=e,this.x=this.dimensions[0],this.y=this.dimensions[1],this.offset=e.size||0,this.size=this.offset/4,this.visible=!1,this._transform.set("e",1),this._transform.set("f",1)}get x(){return parseFloat(this._x)}get y(){return parseFloat(this._y)}set x(t){this._x=t}set y(t){this._y=t}get transform(){return console.warn("transform is disabled - need updated reference for the graph options"),this._transform}set transform(t){this._transform=t}};l(ae,"Label"),ae.DISPLAY_TYPES={OFF:0,AUTO:1,CLICK:2,ON:3},ae.HIGHLIGHT={OFF:0,ON:2},ae.POSITION={OBJECT:1,STATIC:2,CONTAINER:3,CUSTOM:4};let G=ae;const Us=class Us{constructor(t,e,s=0,i=0){this.x_max=t,this.y_max=e,this.cx=s,this.cy=i}as_viewBox(t=1.2){let e=this.x_max*t,s=this.y_max*t;return`${this.cx-e} ${this.cy-s} ${e*2} ${s*2}`}get height(){return this.y_max*2}get width(){return this.x_max*2}get top(){return this.y_max*-1}get bottom(){return this.y_max}get left(){return this.x_max*-1}get right(){return this.x_max}};l(Us,"Extremes");let Ft=Us;const Xs=class Xs extends Tt{constructor(t,e){super(t,e),this.visible=!0,this.size=e.size}set size(t){this._size=t}get size(){return this._size}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}get transform(){return this._transform}};l(Xs,"AxisPoint");let ks=Xs,di={GRAPH:{ratio:1,x_max:1,y_max:1,selector:"body",width:1,height:1,axes:!0,SIZE_EFFECT:1,dimensions:[0,1]},NODE:{size:1,highlight:{color:"yellow",labels:G.DISPLAY_TYPES.ON},labels:G.DISPLAY_TYPES.ON,labelposition:G.POSITION.OBJECT},POINT:{active:2,size:.05,color:"#000",shape:it.SHAPES.CIRCLE,labels:G.DISPLAY_TYPES.AUTO,labelposition:G.POSITION.OBJECT},MEAN:{shape:it.SHAPES.SQUARE,labels:G.DISPLAY_TYPES.AUTO},LABEL:{highlight:G.HIGHLIGHT.OFF,position:["top","left"],container:"#label-container"},EDGE:{multiplier:1}};const Ws=class Ws{constructor(t={...di}){this.__state__=new Ke,this.name="unnamed-graph",this.origin=void 0,this.points=new Map,this.nodes=new Map,this.edges=new Map,this.trajectories=new Map,this.labels=new Map,this.transform=new ye,this.scale_x=1,this.scale_y=1,this.SIZE_EFFECT=1,this._mirror_y=!0,this._mirror_x=!1,this._layers=new ee({name:"graph",tabindex:0,layers:[{name:"axes",layers:[{name:"axis_lines",tabindex:0,layers:[],objects:[]},{name:"axis_labels",tabindex:0,layers:[],objects:[]},{name:"axis_points",tabindex:0,layers:[],objects:[this.origin]}]},{name:"network",layers:[{name:"edges",layers:[],tabindex:0},{name:"nodes",layers:[],tabindex:0},{name:"edgenodes",layers:[],tabindex:0}]},{name:"trajectories",layers:[],tabindex:0},{name:"points",layers:[],tabindex:0},{name:"labels",layers:[],tabindex:0}]}),this.options=t,this.origin=new ks(new Ut(0,0),{ID:"origin",x:0,y:0,size:0,meta:{},graph:this,color:new rt("#FFFFFF"),highlight:new rt("#FFFFFF"),active:!1});let e=1;function s(r,o,a){const h=new Ms(`${e}`,r,a);return e+=1,h.parent=o||void 0,r.layers&&Array.isArray(r.layers)&&(h.layers=new ee(...r.layers.map(g=>s(g,h,a)))),h}l(s,"buildLayerTree"),this.layers=new ee(...this._layers.map(r=>s(r,null,this)));let i=this.layers.search("layers","axis_points");i&&i.objects.set(this.origin.ID,this.origin);let n=this.layers.search("layers","axis_lines");if(n){let r=this.extremes||new Ft(1,1),o=new se({},new it({ID:"axis-x-start",dimensions:[-r.x_max,0],classes:["ena.dimension","ena.dimension"]}),new it({ID:"axis-x-end",dimensions:[r.x_max,0],classes:["ena.dimension","ena.dimension"]}));o.ID="axis-x",n.objects.set(o.ID,o);let a=new se({},new it({ID:"axis-y-start",dimensions:[0,-r.y_max],classes:["ena.dimension","ena.dimension"]}),new it({ID:"axis-y-end",dimensions:[0,r.y_max],classes:["ena.dimension","ena.dimension"]}));a.ID="axis-y",n.objects.set(a.ID,a),Jt("Added axis lines to layer: ",n)}this.extremes=new Ft(t.GRAPH.x_max,t.GRAPH.y_max)}set extremes(t){this._extremes=t}get extremes(){return this._extremes}get mirror_x(){return this._mirror_x}set mirror_x(t){this._mirror_x=t}get mirror_y(){return this._mirror_y}set mirror_y(t){this._mirror_y=t}x_mirror(){return this.mirror_x?-1:1}y_mirror(){return this.mirror_y?-1:1}add_point(t){const e=new it(t);this.points.set(e.ID,e)}add_points(t){let e=this;t.rows().forEach(s=>{e.add_point(s)})}add_nodes(t){let e=this;t.forEach(s=>{s.label=new G(s.ID,s),e.labels.set(s.label.ID,s.label),e.nodes.set(s.ID,s);const i=e.layers.search("layers","nodes");i&&i.objects.push(s)}),e.update_extremes()}add_edge(t,e,s){return this.edges.set(t.ID,t),this.add_nodes([e||t.from,s||t.to]),t}add_edges(t){let e=t.map(i=>this.add_edge(i));const s=this.layers.search("layers","edges");return s&&s.objects.push(...e),e}update_extremes(t=!1){const e=[this.layers.search("layers","points"),this.layers.search("layers","nodes")].filter(s=>s!==void 0);if(e.length===0)this.extremes=new Ft(1,1);else{let s=1/0,i=-1/0,n=1/0,r=-1/0;e.forEach(m=>m.objects.forEach(_=>{Number.isFinite(_.x)&&(s=Math.min(s,_.x),i=Math.max(i,_.x)),Number.isFinite(_.y)&&(n=Math.min(n,_.y),r=Math.max(r,_.y))}));const o=Number.isFinite(s)&&Number.isFinite(n),a=t&&o?(s+i)/2:0,h=t&&o?(n+r)/2:0,g=o?Math.max(Math.abs(s-a),Math.abs(i-a),Math.abs(n-h),Math.abs(r-h)):0,f=(g>0?g:1)*1.3;this.extremes=new Ft(f,f,a,h)}}nodeExtentFrom(t,e){const s=this.layers.search("layers","nodes");let i=0;return s==null||s.objects.forEach(n=>{Number.isFinite(n.x)&&Number.isFinite(n.y)&&(i=Math.max(i,Math.abs(n.x-t),Math.abs(n.y-e)))}),i}base_point_size(t=8){let e=Math.min(this.extremes.x_max,this.extremes.y_max),s=this.points.size+this.nodes.size;return Math.min(1,e/(Math.sqrt(s)*t))}};l(Ws,"Graph");let Je=Ws;const ls=class ls extends St{constructor(t=ci()){if(super(),this.element=null,this.object=null,this.doc=t,ui(t))return;const e=this,s=e.attachShadow({mode:"open"}),i=t.createElement("style"),n=t.createElement("div");i.textContent=this.constructor.style,s.appendChild(i),n.setAttribute("class","wrapper"),s.appendChild(n)}get wrapper(){const t=this,e=t.shadowRoot;return e==null?void 0:e.querySelector(".wrapper")}};l(ls,"DrawableElement"),ls.style=`
|
|
9
9
|
:host {
|
|
10
10
|
max-width: 100%;
|
|
11
11
|
display: block;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
display: flex;
|
|
16
16
|
justify-content: center;
|
|
17
17
|
}
|
|
18
|
-
`;let $e=Ue;const Rs=1e-8;function os(m,t=Rs){return m.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}c(os,"nearOriginFilter");function $s(m){if(m<=0)return[];if(m===1)return[0];const t=new Array(m);for(let e=0;e<m;e++)t[e]=e/(m-1);return t}c($s,"normalizedT");function Ts(m,t){return m.map(e=>{const s=new Array(t+1);let i=1;for(let n=0;n<=t;n++)s[n]=i,i*=e;return s})}c(Ts,"design");function Fs(m){const t=m.length,e=m[0].length,s=m.map(n=>n.slice()),i=Array.from({length:e},()=>new Array(e).fill(0));for(let n=0;n<e;n++){let r=0;for(let a=0;a<t;a++)r+=s[a][n]*s[a][n];if(r=Math.sqrt(r),i[n][n]=r,r>1e-300)for(let a=0;a<t;a++)s[a][n]/=r;for(let a=n+1;a<e;a++){let h=0;for(let o=0;o<t;o++)h+=s[o][n]*s[o][a];i[n][a]=h;for(let o=0;o<t;o++)s[o][a]-=h*s[o][n]}}return{Q:s,R:i}}c(Fs,"qr");function as(m,t){const e=m.length,s=m[0].length,i=new Array(s).fill(0);for(let n=0;n<s;n++){let r=0;for(let a=0;a<e;a++)r+=m[a][n]*t[a];i[n]=r}return i}c(as,"qtY");function hs(m,t){const e=t.length,s=new Array(e).fill(0);for(let i=e-1;i>=0;i--){let n=t[i];for(let r=i+1;r<e;r++)n-=m[i][r]*s[r];s[i]=Math.abs(m[i][i])>1e-12?n/m[i][i]:0}return s}c(hs,"backSolve");function xi(m){return m.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}c(xi,"leverages");function Ds(m,t,e){const s=Ts(m,e),{Q:i,R:n}=Fs(s);return hs(n,as(i,t))}c(Ds,"fitCoeffs");function Te(m,t){let e=0,s=1;for(let i=0;i<m.length;i++)e+=m[i]*s,s*=t;return e}c(Te,"evalPoly");function wi(m,t,e,s){const i=Ts(m,s),{Q:n,R:r}=Fs(i),a=xi(n),h=hs(r,as(n,t)),o=hs(r,as(n,e));let _=0;for(let g=0;g<m.length;g++){const p=1-a[g];if(p<=0)return 1/0;const u=t[g]-Te(h,m[g]),d=e[g]-Te(o,m[g]);_+=(u/p)**2+(d/p)**2}return _}c(wi,"loocv2d");function js(m,t,e){const s=m.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=$s(s),r=m.map(_=>_.x),a=m.map(_=>_.y);let h=1,o=1/0;for(let _=1;_<=i;_++){const g=wi(n,r,a,_);g<o&&(o=g,h=_)}return h}c(js,"selectDegree");function Ys(m,t){const e=os(m);if(e.length<3)return null;const s=t.selectionSet?os(t.selectionSet):e,i=s.length>=3?s:e;let n=js(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=$s(e.length),a=Ds(r,e.map(o=>o.x),n),h=Ds(r,e.map(o=>o.y),n);return{degree:n,coeffsX:a,coeffsY:h}}c(Ys,"fitTrajectory");function ls(m,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:Te(m.coeffsX,i),y:Te(m.coeffsY,i)})}return e}c(ls,"sampleCurve");const qs=100,As=class As extends Pt{constructor(t={}){const e=t.color instanceof tt?t.color:new tt(typeof t.color=="string"?t.color:"#000000");super([],{ID:t.ID||`traj-${Math.random().toString(36).substring(2,9)}`,size:t.size||1,color:e,highlight:null,active:t.active||!1,meta:t.meta||{},...t}),this._typeName="Trajectory",this.trajPoints=[],this.smooth="none",this.maxDegree=3,this.degreeSelection="loocv_2d",this.selectedDegree=-1,this.polyCoeffsX=[],this.polyCoeffsY=[],this.currentTime=1/0,this.showPoints=!0,this.showTips=!0,this.lineStyle="uniform",this.strokeWidth=2,this.strokeWidthRange=[1,6],this.opacityRange=[.3,1],this.smooth=t.smooth||"none",this.maxDegree=t.maxDegree!==void 0?t.maxDegree:3,this.degreeSelection=t.degreeSelection||"loocv_2d",this.polyCoeffsX=t.polyCoeffsX||[],this.polyCoeffsY=t.polyCoeffsY||[],this.currentTime=t.currentTime!==void 0?t.currentTime:1/0,this.showPoints=t.showPoints!==void 0?t.showPoints:!0,this.showTips=t.showTips!==void 0?t.showTips:!0,this.lineStyle=t.lineStyle||"uniform",this.strokeWidth=t.strokeWidth||2,this.strokeWidthRange=t.strokeWidthRange||[1,6],this.opacityRange=t.opacityRange||[.3,1],t.points&&Array.isArray(t.points)&&(this.trajPoints=t.points.map(s=>{if(s instanceof J)return s;const i=new J({dimensions:[s.x,s.y],meta:{time:s.time,label:s.label}});return i.x=s.x,i.y=s.y,i}))}get activePoints(){return this.currentTime===1/0?this.trajPoints:this.trajPoints.filter(t=>(t.meta&&typeof t.meta.time=="number"?t.meta.time:0)<=this.currentTime)}get path(){return this.pathPoints.reduce((t,e,s)=>s===0?`M${e.x},${e.y}`:`${t} L${e.x},${e.y}`,"")}get pathPoints(){const t=this.activePoints;if(t.length<2)return[];if(this.smooth==="poly"){if(this.polyCoeffsX.length>0&&this.polyCoeffsY.length>0)return ls({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},qs);const e=Ys(t.map(s=>({x:s.x,y:s.y})),{maxDegree:this.maxDegree,degreeSelection:this.degreeSelection,selectionSet:this.trajPoints.map(s=>({x:s.x,y:s.y}))});if(e)return this.selectedDegree=e.degree,ls(e,qs)}return t.map(e=>({x:e.x,y:e.y}))}};c(As,"Trajectory");let ce=As;const Gs=1,Ss=class Ss extends Ht{constructor(t,e,s,i=0){super(t,e,s),this._totalweight=0,this._weight=i}get base_color(){return this._color}get color(){const t=this._color||new tt("#000000");return new ae(t,Math.abs(this.weight))}set color(t){this._color=t}base_weight(){return this._weight}get weight(){return Array.isArray(this._weight)?this._weight[0]-this._weight[1]:this._weight}set weight(t){this._weight=t}get totalweight(){return this.weight}set totalweight(t){this._totalweight=t}};c(Ss,"Edge");let _e=Ss;const Es=class Es extends Pt{constructor(e){super(e.dimensions||[],e);nt(this,te);X(this,te,e)}get edge(){return R(this,te)}get path(){const e=R(this,te),s=[e.to.x,e.to.y],i=e.from_point,[n,r]=e.base_pts,a=Math.hypot(i[0]-s[0],i[1]-s[1]),h=Math.hypot(n[0]-r[0],n[1]-r[1]);if(!(a>0)||!(h>0))return"";const o=[(i[0]-s[0])/a,(i[1]-s[1])/a],_=Math.hypot(n[0]-s[0],n[1]-s[1]),g=[(n[0]-s[0])/_,(n[1]-s[1])/_],p=c(T=>h/2*Math.max(0,1-T/a),"halfW"),u=c((T,z)=>`${s[0]+o[0]*T+g[0]*z} ${s[1]+o[1]*T+g[1]*z}`,"at"),d=.2*a,l=Math.min(.15*a,.8*2*p(d)),b=d+l/2,f=d+l;return`M${u(d,0)} L${u(b,p(b))} L${u(f,p(f))} L${u(b,0)} L${u(f,-p(f))} L${u(b,-p(b))}z`}};te=new WeakMap,c(Es,"EdgeArrow");let Fe=Es;const Xe=class Xe extends _e{constructor(e,s,i){super(e,s,i);nt(this,ee);nt(this,ze);this._path="",X(this,ee,!1),this._directions=["from","to"],this.towards="to",R(this,ee)===!0&&X(this,ze,new Fe(this))}get path(){return`M${this.from.x} ${this.from.y} L${this.base_pts[0].join(" ")} L${this.base_pts[1].join(" ")}z`}static calculate_base_points(e){const s=e.towards,i=e._directions.find(b=>b!==e.towards),n=e[i].x,r=e[i].y,a=e[s].x,h=e[s].y,o=a-n,_=h-r,g=Math.hypot(o,_),p=(e.weight??0)*Gs;if(g===0||!isFinite(p)||p===0)return[[a,h],[a,h]];const u=-_/g,d=o/g,l=p/2;return[[a+u*l,h+d*l],[a-u*l,h-d*l]]}get base_pts(){return Xe.calculate_base_points(this)}get arrow(){return R(this,ze)}get with_arrow(){return R(this,ee)}get from_point(){return[this.from.x,this.from.y]}};ee=new WeakMap,ze=new WeakMap,c(Xe,"TaperedEdge");let jt=Xe;const We=class We extends jt{constructor(t,e,s){super(t,e,s),this._dataWeight=0,this._totalweight=t.totalweight??0,this._dataWeight=t.weight??this._weight}get weighted_midpoint(){return le.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return jt.calculate_base_points(this)}static build_path(t){return t._totalweight>0?`M${t.weighted_midpoint[0]} ${t.weighted_midpoint[1]} L${t.base_pts[0].join(" ")} L${t.base_pts[1].join(" ")}z`:(console.error("TaperedWeightedMidpointEdge: No totalweight, returning empty path"),"")}get path(){return We.build_path(this)}get from_point(){return this.weighted_midpoint}};c(We,"TaperedWeightedMidpointEdge");let cs=We;const He=class He extends _e{constructor(t,e,s){super(t,e,s)}static build_path(t,e){let s=t/2,i=e.x-s,n=s*2;return`M ${i}, ${e.y} a ${s},${s} 0 1,0 ${n},0 a ${s},${s} 0 1,0 -${n},0`}get path(){let t=this.weight*Gs;return He.build_path(t,this.to)}};c(He,"NodeEdge");let Vt=He;const Ms=class Ms{constructor(t,e,s,i=new Rt){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.svg_element=this.create()}get_size(){return this.__data__.size}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}update(t,e=!0){}animateSVGAttribute(t,e,s){const i=parseFloat(t.getAttribute(e)||"0");if(i===s)return;const n=5e3,r=performance.now();function a(h){const o=Math.min(1,(h-r)/n),_=i+(s-i)*o;t.setAttribute(e,_.toString()),o<1?requestAnimationFrame(a):t.setAttribute(e,s.toString())}c(a,"animate"),requestAnimationFrame(a)}};c(Ms,"Drawable");let ue=Ms;const vi=.04,Ai=[.25,1],Si=[.3,1];function Bs(m,t,e,s){const i=Math.abs(m);if(!(i>0))return 0;if(!(e>t))return s[1];const n=Math.min(1,Math.max(0,(i-t)/(e-t)));return s[0]+n*(s[1]-s[0])}c(Bs,"rampFor");const Ei=.011,Mi=.75,Ii=.8,Ni=.75,Us=.006,ki=.6;function zi(m){return 2*m}c(zi,"widthPerWeight");function Ci(m,t){return m*t/(2*Us)}c(Ci,"nodeSizeForEdges");function Oi(m){const t=/rgba?\(([^)]+)\)/.exec(m);if(!t)return m;const[e,s,i,n=1]=t[1].split(",").map(Number),r=c(a=>Math.round(255+(a-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}c(Oi,"flattenOnWhite");function Pi(m,t){const e=/rgba?\(([^)]+)\)/.exec(m);if(!e)return m;const[s,i,n,r=1]=e[1].split(",").map(Number);return`rgba(${Math.round(s*t)},${Math.round(i*t)},${Math.round(n*t)},${r})`}c(Pi,"darkenRgba");const Is=class Is extends ue{constructor(t,e,s,i=new Rt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-line",this._arrow_el=null,this._hit_el=null,this.svg_element=this.create()}_stampEdge(t){const e=this.__data__.meta??{};if(!e.isMeanEdge)return;t.setAttribute("data-edge-source",String(e.source??"")),t.setAttribute("data-edge-target",String(e.target??"")),t.setAttribute("data-edge-weight",String(e.weight??0)),t.setAttribute("data-edge-directed",e.isDirected?"true":"false");const s=c((i,n)=>n!=null&&n!==!1?t.setAttribute(i,n===!0?"true":String(n)):t.removeAttribute(i),"opt");s("data-edge-self",!!e.isSelf),s("data-edge-group",e.group),s("data-edge-unit",e.unit)}create(){if(this.__data__ instanceof Vt){const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}if(this.__data__ instanceof jt){const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}const t=document.createElementNS("http://www.w3.org/2000/svg","line");return t.setAttribute("x1",this.__data__.from.x.toString()),t.setAttribute("y1",this.__data__.from.y.toString()),t.setAttribute("x2",this.__data__.to.x.toString()),t.setAttribute("y2",this.__data__.to.y.toString()),t.setAttribute("stroke-width",this.get_size().toString()),t.setAttribute("stroke",this.__data__.color.toString()),this.svg_element=t,t}get drawsPath(){return this.__data__ instanceof Vt||this.__data__ instanceof jt}update(){var i,n,r,a;if(this.svg_element||this.create(),this.svg_element.tagName.toLowerCase()==="path"!==this.drawsPath){const h=this.svg_element;this.create(),h.parentElement&&h.replaceWith(this.svg_element)}this.drawsPath&&((i=this._hit_el)==null||i.remove(),this._hit_el=null),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=((n=this.graph.__data__.extremes)==null?void 0:n.x_max)??1,e=this.__data__.meta??{};let s=!1;if(e.isMeanEdge){this._stampEdge(this.svg_element);const h=typeof e.weight=="number"?e.weight:0,o=typeof e.maxWeight=="number"?e.maxWeight:1,_=typeof e.opacity=="number"?e.opacity:Math.min(1,h/(o||1)),g=t>0?t:1,p=e.fixedSize&&this.graph.zoom_level||1,u=(typeof e.widthFrac=="number"?g*e.widthFrac*h:g*Ei*(h/(o||1)))/p,d=this.__data__._color||new tt("#000000"),l=typeof e.saturation=="number"?e.saturation:_,b=new ae(d,l,_).toString();if(this.__data__ instanceof Vt){const f=typeof e.selfSize=="number"&&e.selfSize>0?e.selfSize:null,w=f!=null?(a=(r=this.graph)._nodeRadius)==null?void 0:a.call(r,String(e.source)):null;this.__data__.weight=typeof w=="number"?2*f*w:u,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke","none")}else if(this.__data__ instanceof jt){if(this.__data__.weight=u,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke",b),this.svg_element.setAttribute("stroke-width",String(Mi)),this.svg_element.setAttribute("vector-effect","non-scaling-stroke"),this.svg_element.setAttribute("stroke-linejoin","round"),e.isDirected)try{const w=new Fe(this.__data__).path;w&&!w.includes("NaN")&&!w.includes("Infinity")&&(this._arrow_el||(this._arrow_el=document.createElementNS("http://www.w3.org/2000/svg","path"),this._arrow_el.setAttribute("stroke","none")),this._arrow_el.parentElement||this.parent.appendChild(this._arrow_el),this._arrow_el.setAttribute("d",w),this._arrow_el.setAttribute("fill",Pi(Oi(b),Ii)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(Ni)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"),s=!0)}catch{}}else{const f=this.__data__.from.x,w=this.__data__.from.y,T=this.__data__.to.x,z=this.__data__.to.y;this.svg_element.setAttribute("x1",f.toString()),this.svg_element.setAttribute("y1",w.toString()),this.svg_element.setAttribute("x2",T.toString()),this.svg_element.setAttribute("y2",z.toString()),this.svg_element.setAttribute("stroke-width",u.toString()),this.svg_element.setAttribute("stroke",b),this.svg_element.setAttribute("pointer-events","stroke"),this.svg_element.removeAttribute("marker-end"),this._hit_el||(this._hit_el=document.createElementNS("http://www.w3.org/2000/svg","line"),this._hit_el.setAttribute("stroke","transparent"),this._hit_el.setAttribute("stroke-linecap","round"),this._hit_el.setAttribute("pointer-events","stroke")),this._hit_el.parentElement||this.parent.appendChild(this._hit_el),this._hit_el.setAttribute("x1",f.toString()),this._hit_el.setAttribute("y1",w.toString()),this._hit_el.setAttribute("x2",T.toString()),this._hit_el.setAttribute("y2",z.toString()),this._hit_el.setAttribute("stroke-width",Math.max(u,t*.03/p).toString()),this._stampEdge(this._hit_el)}}else{this.svg_element.setAttribute("x1",this.__data__.from.x.toString()),this.svg_element.setAttribute("y1",this.__data__.from.y.toString()),this.svg_element.setAttribute("x2",this.__data__.to.x.toString()),this.svg_element.setAttribute("y2",this.__data__.to.y.toString());const h=this.graph._axesFixedSize&&String(this.__data__.ID).startsWith("axis-")&&this.graph.zoom_level||1,o=(t>0?t:1)*.004*this.get_size()/h;this.svg_element.setAttribute("stroke-width",o.toString()),this.svg_element.setAttribute("stroke-opacity","1"),this.svg_element.setAttribute("stroke",this.__data__.color.toString())}!s&&this._arrow_el&&(this._arrow_el.remove(),this._arrow_el=null)}remove(){var t,e,s;(t=this.svg_element)==null||t.remove(),(e=this._hit_el)==null||e.remove(),(s=this._arrow_el)==null||s.remove()}draw(){var t,e,s;this._hit_el&&((t=this.parent)==null||t.appendChild(this._hit_el)),(e=this.parent)==null||e.appendChild(this.svg_element),this._arrow_el&&((s=this.parent)==null||s.appendChild(this._arrow_el))}};c(Is,"QELine");let St=Is;const Ns=class Ns extends ue{constructor(t,e,s,i=new Rt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-point",this.svg_element=this.create()}get x(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[0]]}get y(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[1]]}get isSquare(){return this.__data__.shape==="rect"}get shapeKind(){const t=this.__data__.shape;return t==="rect"||t==="square"?"rect":t==="triangle"||t==="diamond"?t:"circle"}get tag(){const t=this.shapeKind;return t==="circle"?"circle":t==="rect"?"rect":"path"}setGeometry(t,e){const s=this.x,i=this.y;switch(this.shapeKind){case"rect":t.setAttribute("x",(s-e).toString()),t.setAttribute("y",(i-e).toString()),t.setAttribute("width",(e*2).toString()),t.setAttribute("height",(e*2).toString());break;case"triangle":{const n=e*1.15;t.setAttribute("d",`M${s} ${i-n} L${s+n*.866} ${i+n*.5} L${s-n*.866} ${i+n*.5}Z`);break}case"diamond":t.setAttribute("d",`M${s} ${i-e*1.2} L${s+e} ${i} L${s} ${i+e*1.2} L${s-e} ${i}Z`);break;default:t.setAttribute("cx",s.toString()),t.setAttribute("cy",i.toString()),t.setAttribute("r",e.toString())}}computeRadius(){var s;const t=this.baseRadius(),e=(s=this.__data__.meta)==null?void 0:s.maxRadius;return typeof e=="number"&&e>0?Math.min(t,e):t}baseRadius(){var e;const t=this.dataRadius();return(e=this.__data__.meta)!=null&&e.zoomFixed?t/(this.graph.zoom_level||1):t}dataRadius(){var i,n,r,a,h,o,_;const t=this.graph.__data__.extremes.x_max||1,e=((i=this.__data__.meta)==null?void 0:i.sizeScale)??1,s=(n=this.__data__.meta)==null?void 0:n.sizePx;if(typeof s=="number"&&s>0){const g=(a=(r=this.graph.svg_element)==null?void 0:r.getBoundingClientRect)==null?void 0:a.call(r),p=g&&g.width>0?2*t/g.width:t*.004;return s/2*p}if((h=this.__data__.meta)!=null&&h.fixedSize){const g=(_=(o=this.graph.svg_element)==null?void 0:o.getBoundingClientRect)==null?void 0:_.call(o),p=this.graph.zoom_level||1,u=g&&g.width>0?g.width/(2*t):1;return this.__data__.size*2*e/u/p}return t*Us*this.__data__.size*e}applyStroke(t){var s;const e=(s=this.__data__.meta)==null?void 0:s.stroke;e&&(t.setAttribute("stroke",e),t.setAttribute("stroke-width",(this.computeRadius()*.22).toString()))}stampIdentity(t){t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{},s=c((i,n)=>n!=null&&n!==""?t.setAttribute(i,String(n)):t.removeAttribute(i),"opt");s("data-kind",e.kind),s("data-name",e.name),s("data-group",e.group),s("data-unit",e.unit)}create(){const t=document.createElementNS("http://www.w3.org/2000/svg",this.tag);return this.stampIdentity(t),t.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(t),this.setGeometry(t,this.computeRadius()),this.svg_element=t,t.addEventListener("click",()=>{this.__data__.active=!this.__data__.active,this.update();const e=new CustomEvent("point-clicked",{detail:{pointData:this.__data__},bubbles:!0,composed:!0});this.svg_element.dispatchEvent(e)}),t.addEventListener("mouseover",()=>{}),t}update(){if(this.svg_element||this.parent.__data__.__children__.push(this.create()),this.svg_element.tagName.toLowerCase()!==this.tag){const t=this.svg_element;this.create(),t.parentElement&&t.replaceWith(this.svg_element)}this.svg_element.parentElement||this.parent.appendChild(this.svg_element),this.stampIdentity(this.svg_element),this.svg_element.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(this.svg_element),this.setGeometry(this.svg_element,this.computeRadius())}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}};c(Ns,"QEPoint");let Zt=Ns;const ks=class ks extends ue{constructor(t,e,s,i=new Rt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="trajectory",this._path_el=null,this._segments_group=null,this._tip_el=null,this._points_group=null,this.svg_element=this.create()}graphUnitsForPixels(t){var i;const e=this.graph.__data__.extremes.x_max||1,s=((i=this.graph.svg_element)==null?void 0:i.getBoundingClientRect().width)||0;return s>0?t*(2*e/s):t*e*.006}create(){const t=document.createElementNS("http://www.w3.org/2000/svg","g");t.setAttribute("class","qe-trajectory-group");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","none"),e.setAttribute("stroke",this.__data__.color.toString()),e.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),t.appendChild(e),this._path_el=e;const s=document.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","qe-trajectory-segments"),t.appendChild(s),this._segments_group=s;const i=document.createElementNS("http://www.w3.org/2000/svg","g");if(i.setAttribute("class","qe-trajectory-points"),t.appendChild(i),this._points_group=i,this.__data__.showTips){const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("fill",this.__data__.color.toString()),n.setAttribute("r",this.graphUnitsForPixels(4).toString()),n.setAttribute("stroke","#ffffff"),n.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),t.appendChild(n),this._tip_el=n}return this.svg_element=t,t}update(){this.svg_element||this.create(),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=this.__data__.path;if(this._path_el&&(this._path_el.setAttribute("d",t),this._path_el.setAttribute("stroke",this.__data__.color.toString()),this._path_el.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),this._path_el.style.display=this.__data__.lineStyle==="tapered"?"none":"block"),this._segments_group)if(this._segments_group.innerHTML="",this.__data__.lineStyle==="tapered"){const s=this.__data__.pathPoints,i=s.length-1,[n,r]=this.__data__.strokeWidthRange,[a,h]=this.__data__.opacityRange;for(let o=0;o<i;o++){const _=s[o],g=s[o+1],p=i<=1?1:o/(i-1),u=n+(r-n)*p,d=a+(h-a)*p,l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",`M${_.x},${_.y} L${g.x},${g.y}`),l.setAttribute("fill","none"),l.setAttribute("stroke",this.__data__.color.toString()),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("stroke-width",this.graphUnitsForPixels(u).toString()),l.setAttribute("opacity",d.toString()),this._segments_group.appendChild(l)}this._segments_group.style.display="block"}else this._segments_group.style.display="none";const e=this.__data__.activePoints;if(this._points_group&&(this.__data__.showPoints&&e.length>0?(this._points_group.innerHTML="",e.forEach(s=>{var n;const i=document.createElementNS("http://www.w3.org/2000/svg","circle");i.setAttribute("cx",s.x.toString()),i.setAttribute("cy",s.y.toString()),i.setAttribute("r",this.graphUnitsForPixels(2.5).toString()),i.setAttribute("fill",this.__data__.color.toString()),i.setAttribute("opacity","0.7"),(n=this._points_group)==null||n.appendChild(i)}),this._points_group.style.display="block"):this._points_group.style.display="none"),this._tip_el&&this.__data__.showTips)if(e.length>0){const s=e[e.length-1];this._tip_el.setAttribute("cx",s.x.toString()),this._tip_el.setAttribute("cy",s.y.toString()),this._tip_el.setAttribute("fill",this.__data__.color.toString()),this._tip_el.setAttribute("r",this.graphUnitsForPixels(4).toString()),this._tip_el.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),this._tip_el.style.display="block"}else this._tip_el.style.display="none"}draw(){this.svg_element&&!this.svg_element.parentElement&&this.parent.appendChild(this.svg_element),this.update()}};c(ks,"QETrajectory");let de=ks;const{ArrayTools:Xs}=le,zs=class zs extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}c(i,"fn");function n(r,a,h=null){if(Xs.isArray(r)){for(const[o,_]of r.entries())if(s=n(_,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Xs.isArray(r[t])){for(const[o,_]of r[t].entries())if(s=n(_,o,r),s)return s}}return s}return c(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};c(zs,"QEArray");let Rt=zs;const Li={AxisPoint:Zt,AxisLine:St,Point:Zt,Line:St,Edge:St,TaperedEdge:St,TaperedWeightedMidpointEdge:St,NodeEdge:St,Trajectory:de},se=class se{constructor(t,e,s,i=new Rt){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__=t.name||"unnamed-layer",t.__state__.addListener("layer_updated","live",({key:n,newValue:r,oldValue:a})=>{const h=c(p=>{var u;return(u=p.__data__)==null?void 0:u.ID},"childId"),o=this.__children__.filter(p=>!r.objects.has(h(p))),_=this.__children__.filter(p=>r.objects.has(h(p)));[...r.objects.values()].filter(p=>!this.__children__.some(u=>h(u)===p.ID)).forEach(p=>{const u=p._typeName||p.constructor.name;let d=Li[u];d||(p instanceof ce?d=de:p instanceof J?d=Zt:d=St);const l=new d(p,this.svg_element,this.graph);this.__children__.push(l)}),_.forEach(p=>{const u=r.objects.get(h(p));u&&(p.__data__=u),p.update()}),o.forEach(p=>{var d;typeof p.remove=="function"?p.remove():(d=p.svg_element.parentElement)==null||d.removeChild(p.svg_element);const u=this.__children__.indexOf(p);u>=0&&this.__children__.splice(u,1)}),this.update()}),this.svg_element=this.create()}get name(){return this.__name__}create(){if(!this.__data__)throw new Error("Layer is null");let t=this.__data__;return this.svg_element=document.createElementNS("http://www.w3.org/2000/svg",se.tagName),this.svg_element.setAttribute("data-layer-name",t.name),this.svg_element.setAttribute("data-layer-id",t.ID),this.svg_element.__data__=t,this.svg_element.classList.add("ena-layer"),this.__data__.layers&&this.__data__.layers.length>0&&this.__data__.layers.forEach(e=>{const s=new se(e,this.svg_element,this.graph);this.__children__.push(s)}),this.svg_element}update(){if(!this.__data__)throw new Error("Layer is null");this.__data__.visible&&(this.parent.nodeName.toLowerCase(),this.__children__.forEach(t=>{t.update()}),this.__data__.scale_objects===!0&&this.__name__)}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()})}add(t){this.__children__.push(t)}};c(se,"QELayer"),se.tagName="g";let De=se;const Cs=class Cs{constructor(t,e,s,i,n=q.DISPLAY_TYPES.ON,r=q.POSITION.OBJECT,a,h){this.text=t,this.parent=s,this.graph=i,this.displayMode=n,this.position=r,this.customX=a,this.customY=h,this._visible=!1,this._offsetX=0,this._offsetY=0,this.pinned=!1,this._hostPinned=!1,this.fontWeight=null,this._point=e,this.svg_element=this._create(),n===q.DISPLAY_TYPES.ON?(this._visible=!0,this.svg_element.setAttribute("display","block")):(this._visible=!1,this.svg_element.setAttribute("display","none"))}get point(){return this._point}_create(){const t=document.createElementNS("http://www.w3.org/2000/svg","text");return t.textContent=this.text,t.setAttribute("data-label-for",this.point.ID),t.setAttribute("pointer-events","auto"),t.style.cursor="grab",this._attachDrag(t),this.parent.appendChild(t),t}setPoint(t){this._point=t,this.svg_element.setAttribute("data-label-for",t.ID)}setOffset(t,e){this._offsetX=Number.isFinite(t)?t:0,this._offsetY=Number.isFinite(e)?e:0}setHostPinned(t){t!==this._hostPinned&&(this._hostPinned=t,t?this.show():this.displayMode!==q.DISPLAY_TYPES.ON&&this.hide())}_attachDrag(t){t.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,"mouse")}),t.addEventListener("pointerdown",e=>{e.pointerType==="touch"&&(e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,e.pointerId))})}_drag(t,e,s,i){const n=t.parentNode??t.ownerSVGElement,r=t.ownerSVGElement;if(!r||!n)return;const a=c((u,d)=>{const l=r.createSVGPoint();l.x=u,l.y=d;const b=n.getScreenCTM();return b?l.matrixTransform(b.inverse()):{x:0,y:0}},"toUser"),h=a(e,s),o=this._offsetX,_=this._offsetY;t.style.cursor="grabbing";const g=c((u,d)=>{const l=a(u,d);this._offsetX=o+(l.x-h.x),this._offsetY=_+(l.y-h.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"move"),p=c(()=>{t.style.cursor="grab",this.graph.dispatchEvent(new CustomEvent("qe-label-move",{detail:{id:this.point.ID,transform:{x:this._offsetX,y:this._offsetY}},bubbles:!0,composed:!0}))},"done");if(i==="mouse"){const u=c(l=>g(l.clientX,l.clientY),"onMove"),d=c(()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",d),p()},"onUp");document.addEventListener("mousemove",u),document.addEventListener("mouseup",d)}else{const u=c(l=>{l.pointerId===i&&g(l.clientX,l.clientY)},"onMove"),d=c(l=>{l.pointerId===i&&(document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d),p())},"onUp");document.addEventListener("pointermove",u),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d)}}update(){var h;if(!this._visible)return;const t=this.graph.__data__.extremes.x_max;if(t<=0)return;const e=this.graph._labelFont??{},s=e.size?e.size*this.graph.unitsPerPixel():t*.06,i=s*1.2;let n,r,a;switch(this.position){case q.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,a="middle";break}case q.POSITION.CONTAINER:{const{cx:o,cy:_}=this.graph.__data__.extremes,g=this.point.x-o,p=this.point.y-_,u=Math.sqrt(g*g+p*p)||1,d=t*.93/u;n=o+g*d,r=_+p*d-i*.3,a=g>=0?"start":"end";break}case q.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,a="start";break}default:case q.POSITION.OBJECT:{const o=this.point.x>=0?i:-i;a=this.point.x>=0?"start":"end",n=this.point.x+o,r=this.point.y-i*.4;break}}this.svg_element.setAttribute("x",n.toString()),this.svg_element.setAttribute("y",r.toString()),this._offsetX||this._offsetY?this.svg_element.setAttribute("transform",`translate(${this._offsetX}, ${this._offsetY})`):this.svg_element.removeAttribute("transform"),this.svg_element.setAttribute("font-size",s.toString()),this.svg_element.setAttribute("font-family",e.family??"system-ui, sans-serif"),this.svg_element.setAttribute("font-weight",this.fontWeight??"500"),this.svg_element.setAttribute("text-anchor",a),this.svg_element.setAttribute("fill",e.color??((h=this.point.color)==null?void 0:h.toString())??"#333333"),!this._offsetX&&!this._offsetY&&this.position!==q.POSITION.CUSTOM&&this.fitInside(n,r,a,i,s*.3)}visibleBounds(){var h;const t=this.svg_element,e=t.ownerSVGElement,s=(h=t.getScreenCTM)==null?void 0:h.call(t);if(!e||!s)return null;const i=e.getBoundingClientRect();if(!(i.width>0&&i.height>0))return null;const n=s.inverse(),r=new DOMPoint(i.left,i.top).matrixTransform(n),a=new DOMPoint(i.right,i.bottom).matrixTransform(n);return{left:Math.min(r.x,a.x),right:Math.max(r.x,a.x),top:Math.min(r.y,a.y),bottom:Math.max(r.y,a.y)}}bbox(){try{const t=this.svg_element.getBBox();return t.width>0?t:null}catch{return null}}fitInside(t,e,s,i,n){const r=this.visibleBounds();let a=this.bbox();if(!r||!a)return;const h=r.left+n,o=r.right-n,_=r.top+n,g=r.bottom-n,p=c(b=>Math.max(0,h-b.x)+Math.max(0,b.x+b.width-o),"over"),u=this.svg_element;if(p(a)>0&&this.position===q.POSITION.OBJECT&&s!=="middle"){const b=s==="end"?"start":"end",f=s==="end"?this.point.x+i:this.point.x-i;u.setAttribute("text-anchor",b),u.setAttribute("x",f.toString());const w=this.bbox();w&&p(w)<p(a)?(a=w,t=f):(u.setAttribute("text-anchor",s),u.setAttribute("x",t.toString()))}let d=0,l=0;a.x<h?d=h-a.x:a.x+a.width>o&&(d=Math.max(o-(a.x+a.width),h-a.x)),a.y<_?l=_-a.y:a.y+a.height>g&&(l=Math.max(g-(a.y+a.height),_-a.y)),d&&u.setAttribute("x",(t+d).toString()),l&&u.setAttribute("y",(e+l).toString())}show(){this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()}hide(){this.pinned||this._hostPinned||(this._visible=!1,this.svg_element.setAttribute("display","none"))}toggle(){this._visible?this.hide():this.show()}get visible(){return this._visible}remove(){this.svg_element.remove()}};c(Cs,"QELabel");let _s=Cs;const Ve=class Ve extends HTMLElement{};c(Ve,"QENodesElement"),Ve.tagName="qe-nodes";let ge=Ve;const Ze=class Ze extends HTMLElement{};c(Ze,"QEMeansElement"),Ze.tagName="qe-means";let me=Ze;const Ke=class Ke extends HTMLElement{};c(Ke,"QEPointsElement"),Ke.tagName="qe-points";let fe=Ke;const Je=class Je extends HTMLElement{};c(Je,"QEEdgesElement"),Je.tagName="qe-edges";let pe=Je;const Qe=class Qe extends HTMLElement{};c(Qe,"QETrajectoriesElement"),Qe.tagName="qe-trajectories";let be=Qe;const ts=class ts extends HTMLElement{};c(ts,"QEAxesElement"),ts.tagName="qe-axes";let ye=ts;customElements.define(ge.tagName,ge),customElements.define(me.tagName,me),customElements.define(fe.tagName,fe),customElements.define(pe.tagName,pe),customElements.define(be.tagName,be),customElements.define(ye.tagName,ye);const Ws=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function Ri(m,t){for(const e of t)if(m===`${e}.${e}`)return[e,e];for(const e of t)if(m.startsWith(e+".")){const s=m.slice(e.length+1);if(t.includes(s))return[e,s]}return null}c(Ri,"parseEdgePair");function $i(m,t,e,s){const i=Math.max(1,e-1),n=i>=120?1.96:i>=60?2:i>=30?2.042:i>=20?2.086:i>=10?2.228:i>=5?2.571:4.303,r=Math.sqrt(Math.max(0,m)/e)*s,a=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*a}}c($i,"computeCIRect");const Ti=.5;function je(m,t,e){if(!m)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(m.meta={...m.meta??{},maxRadius:s*Ti})}c(je,"capMeanToInterval");function Ye(m,t,e,s=""){const i=c(o=>{const _=m.names.indexOf(o),g=_>=0?m[_]:null;if(g==null||g==="")return;const p=Number(g);return Number.isFinite(p)?p:void 0},"get"),n=i(`${t}.${s}low`)??i(`${t}_${s}low`),r=i(`${t}.${s}high`)??i(`${t}_${s}high`),a=i(`${e}.${s}low`)??i(`${e}_${s}low`),h=i(`${e}.${s}high`)??i(`${e}_${s}high`);return n==null||r==null||a==null||h==null?null:{x_low:n,x_high:r,y_low:a,y_high:h}}c(Ye,"readIntervalBounds");function qe(m,t){const e=c(o=>{if(!m)return;const _=m.names.indexOf(o);return _>=0?m[_]:void 0},"raw"),s=c(o=>o==null||o==="NA"||typeof o=="number"&&Number.isNaN(o),"isNA"),i=e("label"),n=s(i)?t:String(i)===""?null:String(i),r=c(o=>{const _=e(o),g=s(_)||_===""?0:Number(_);return Number.isFinite(g)?g:0},"num"),a=!!m&&(m.names.includes("label.dx")||m.names.includes("label.dy")),h=e("label.pinned");return{text:n,offset:a?{x:r("label.dx"),y:r("label.dy")}:null,pinned:h===!0||h===1||String(h).toLowerCase()==="true"}}c(qe,"readLabelSpec");function Fi(m){const t=m==null?void 0:m.trim().toLowerCase();if(!t)return null;if(t==="node")return .5;const e=Number(t);return Number.isFinite(e)&&e>0?e:null}c(Fi,"parseSelfSize");function Di(m){var i,n;const t=c(r=>m.getAttribute(r),"a"),e=((i=t("colors"))==null?void 0:i.split(",").map(r=>r.trim()).filter(Boolean))??[],s=((n=t("threshold"))==null?void 0:n.split(",").map(Number).filter(Number.isFinite))??[];return{group:t("group"),unit:t("unit"),compare:t("compare"),also:t("also"),network:t("network"),colors:e.length?[e[0],e[1]??null]:null,threshold:s.length?[s[0],s.length>1?s[1]:1/0]:null,name:t("name"),selfSize:Fi(t("self-size")),fixedSize:m.hasAttribute("fixed-size")}}c(Di,"parseEdgeLayer");function ji(m){const{r:t,g:e,b:s}=tt.parseColor(m),i=Math.max(t,e,s),n=Math.min(t,e,s),r=c(a=>(i+n-a).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}c(ji,"complementColor");function Yi(m){const t=m==null?void 0:m.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}c(Yi,"parseColorScale");function Ge(m,t){switch(m==null?void 0:m.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}c(Ge,"parseLabelMode");const it=class it extends $e{constructor(){super(),this.zoom_level=1,this.__children__=new Rt,this._hasModel=!1,this._renderPending=!1,this._childObserver=null,this._ciRects=new Map,this._outlierRects=new Map,this._ciCross=new Map,this._labelsGroup=null,this._nodeLabels=new Map,this._meanLabels=new Map,this._pointLabels=new Map,this._setLabels=new Map,this._showAxes=!1,this._axisXText=null,this._axisYText=null,this._axisLabelEls=new Map,this._magnifyText=null,this._magnifyEl=null,this._rangeExtent=null,this._rangeMode=null,this._centerContent=!1,this._edgesFixedSize=!1,this._meansFixedSize=!1,this._intervalBase=new WeakMap,this._axesFixedSize=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._zoomAnim=null,this._animateMs=0,this._tweenRaf=null,this._tween=null,this._tweenView=null,this._highlight={edges:new Set,nodes:new Set},this._highlightGroup=null,this._tooltipEl=null,this.graph=this,this.parent=null,this.__data__=new Re(Ls),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),Xt("Created qe-graph svg element: ",this.svg_element),document.addEventListener("model-updated",t=>{var Ks,Js,Qs,ti,ei,si,ii,ni,ri,oi,ai,hi,li,ci,_i,ui,di;const e=((Ks=t.composedPath)==null?void 0:Ks.call(t)[0])??t.target;if(this._vizena&&e!==this._vizena)return;const s=t.detail;if(!s)return;this._renderPending=!1,(Js=this._childObserver)==null||Js.takeRecords(),this._animateMs=this.hasAttribute("animate")?parseInt(this.getAttribute("animate")||"",10)||300:0;const i=this._animateMs>0&&this._hasModel?this._captureTweenState():null;this._stopTween(),this._hasModel=!0;const n=s.dimensions,r=s.unit_id_col,a=s.node_id_col,h=s.group_col,o=this._readLayerConfig();this._showAxes=o.showAxes,this._axisXText=o.axisXLabel===null?null:o.axisXLabel||String((n==null?void 0:n[0])??"x"),this._magnifyText=o.edgeMagnify==null?null:`(scaled ${o.edgeMagnify.toFixed(1)}x)`,this._axisYText=o.axisYLabel===null?null:o.axisYLabel||String((n==null?void 0:n[1])??"y");const _={},g=(Qs=s.palette)!=null&&Qs.length?s.palette:Ws;if(h&&((ti=s.points)!=null&&ti.names)){const I=s.points.col(h);I&&[...new Set([...I].map(String))].forEach((L,N)=>{_[L]=g[N%g.length]})}(ei=s.groups)!=null&&ei.rows&&s.groups.rows().length>0&&s.groups.rows().forEach(I=>{const k=I.rowName??String(I[0]),L=I.names.indexOf("color"),N=L>=0?I[L]:null;N&&String(N)!=="NA"?_[k]=String(N):_[k]||(_[k]=g[Object.keys(_).length%g.length])});const p=Object.keys(_),u=o.activeMeanGroups&&o.activeMeanGroups.trim()?new Set(o.activeMeanGroups.split(",").map(I=>I.trim()).filter(I=>_[I])):new Set(p),d=o.scalePoints,l=c(I=>{let k=0;return I.forEach(L=>{const N=L.names.indexOf(n[0]),S=n.length>1?L.names.indexOf(n[1]):-1;N>=0&&(k=Math.max(k,Math.abs(Number(L[N])))),S>=0&&(k=Math.max(k,Math.abs(Number(L[S]))))}),k},"getExtent"),b=(si=s.nodes)!=null&&si.rows?l(s.nodes.rows()):0,f=(ii=s.points)!=null&&ii.rows?l(s.points.rows()):0,w=(ni=s.trajectories)!=null&&ni.rows?l(s.trajectories.rows()):0,T=f>0?f:w,z=o.pointScale!==null?o.pointScale:d&&T>0&&b>0?b/T:1;this._rangeExtent=o.range==="network"?b*1.2:o.range==="points"?T*z*1.2:typeof o.range=="number"?o.range:null,this._rangeMode=o.range==="network"||o.range==="points"?o.range:typeof o.range=="number"?"number":null,this._centerContent=o.centerContent,this._edgesFixedSize=o.edgeLayers.some(I=>I.fixedSize),this._meansFixedSize=o.meanFixedSize,this._axesFixedSize=o.axesFixedSize,this._plotTitle=o.plotTitle,this._labelFont=o.labelFont;const j=o.labelNodes,dt=o.labelMeans,gt=o.labelPoints,et=this._labelsGroup,mt=c((I,k,L,N=1)=>{const S=I.names.indexOf(k),y=I.names.indexOf(n[0]),P=n.length>1?I.names.indexOf(n[1]):-1,v=new J({ID:S>=0?String(I[S]):I.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[y>=0?Number(I[y])*N:0,P>=0?-Number(I[P])*N:0],meta:{}});return L&&(v.color=new tt(L)),v},"rowToPoint"),Q={},Tt=o.showPoints;["points","nodes","edges","edgenodes"].map(I=>this.__children__.search("__children__",I)).filter(I=>!!I).forEach(I=>I.__data__.objects.clear()),this.__data__.points.clear();const Ce=s.pointsets,Gt=[];if(o.pointSets.length&&(Ce!=null&&Ce.rows)){const I=this.__children__.search("__children__","points"),k=c((L,N)=>{const S=L.names.indexOf(N);return S>=0?L[S]:null},"col");o.pointSets.forEach((L,N)=>{Ce.rows().forEach(S=>{if(String(k(S,"set"))!==L.set)return;const y=String(k(S,"id")),P=k(S,"group")!=null&&String(k(S,"group"))!=="NA"?String(k(S,"group")):null,v=k(S,"color")&&String(k(S,"color"))!=="NA"?String(k(S,"color")):P&&_[P]?_[P]:g[N%g.length],E=mt(S,"id",v,z);E.ID=`${L.set}::${y}`,E.size=L.size??o.pointSize??2.5;const D=k(S,"shape");D&&String(D)!=="NA"&&(E.shape=String(D));const W=k(S,"label");E.meta={stroke:"#ffffff",kind:"point",name:W!=null&&String(W)!=="NA"?String(W):y,group:P??void 0,unit:y,set:L.set,fixedSize:L.fixedSize},this.__data__.points.set(E.ID,E),I==null||I.__data__.objects.set(E.ID,E),Gt.push({pt:E,spec:qe(S,y),mode:L.labelMode,weight:L.labelWeight})})})}if(et){const I=new Set(Gt.map(k=>k.pt.ID));this._setLabels.forEach((k,L)=>{I.has(L)||(k.remove(),this._setLabels.delete(L))}),Gt.forEach(k=>this._syncLabel(this._setLabels,k.pt.ID,k.spec,k.pt,et,k.mode,k.weight))}if((ri=s.points)!=null&&ri.rows){const I=this.__children__.search("__children__","points");if(I){s.points.rows().forEach(N=>{const S=h?N.names.indexOf(h):-1,y=S>=0?String(N[S]):null,P=y?_[y]??"#888888":"#888888";if(Tt){const v=mt(N,r,P,z);v.size=o.pointSize??2.5,v.meta={...v.meta??{},stroke:"#ffffff",kind:"point",name:v.ID,group:y??void 0,unit:v.ID,fixedSize:o.pointFixedSize},this.__data__.points.set(v.ID,v),I.__data__.objects.set(v.ID,v)}if(y){const v=N.names.indexOf(n[0]),E=n.length>1?N.names.indexOf(n[1]):-1;Q[y]||(Q[y]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:P});const D=v>=0?Number(N[v]):0,W=E>=0?Number(N[E]):0;Q[y].x+=D,Q[y].y+=W,Q[y].x2+=D*D,Q[y].y2+=W*W,Q[y].xy+=D*W,Q[y].n+=1}});const k=!!((oi=s.groups)!=null&&oi.rows&&s.groups.rows().length>0),L=o.showMeans&&k?s.groups.rows().filter(N=>{const S=N.rowName??String(N[0]);return u.size===0||u.has(S)}):[];if(o.showMeans){const N=I.svg_element,S=this._rangeExtent?this._rangeExtent/1.2:b,y=(S>0?S:1)*.008;if(k){const P=new Set(L.map(v=>v.rowName??String(v[0])));this._ciRects.forEach((v,E)=>{P.has(E)||(v.remove(),this._ciRects.delete(E))}),this._outlierRects.forEach((v,E)=>{P.has(E)||(v.remove(),this._outlierRects.delete(E))}),this._ciCross.forEach((v,E)=>{P.has(E.slice(2))||(v.remove(),this._ciCross.delete(E))}),L.forEach(v=>{var ss,re,Ut;const E=v.rowName??String(v[0]),D=_[E]??"#888888",W=v.names.indexOf(n[0]),G=n.length>1?v.names.indexOf(n[1]):-1,V=W>=0?Number(v[W])*z:0,vt=G>=0?-Number(v[G])*z:0,H=new J({ID:`mean-${E}`,dimensions:[V,vt],meta:{kind:"mean",name:E,group:E,fixedSize:o.meanFixedSize}});H.color=new tt(D),H.size=4;const ht=v.names.indexOf("shape"),$=ht>=0?v[ht]:null;H.shape=$&&String($)!=="NA"?String($):"rect",this.__data__.points.set(H.ID,H),I.__data__.objects.set(H.ID,H);const ie=c(Y=>{const x=v.names.indexOf(Y),A=x>=0?v[x]:null;return A==null||String(A)==="NA"||String(A)===""?null:A},"cell"),pt=ie("intervals"),zt=pt==="box"||pt==="crosshairs"||pt==="none"?pt:o.intervals,Bt=ie("outlier"),B=(Bt==null?o.showOutlier:Bt===!0||String(Bt)==="true")?Ye(v,n[0],n[1],"o"):null;if(!B)(ss=this._outlierRects.get(E))==null||ss.remove(),this._outlierRects.delete(E);else{let Y=this._outlierRects.get(E);Y||(Y=document.createElementNS("http://www.w3.org/2000/svg","rect"),Y.setAttribute("data-outlier-group",E),this._outlierRects.set(E,Y)),Y.setAttribute("x",(B.x_low*z).toString()),Y.setAttribute("y",(-B.y_high*z).toString()),Y.setAttribute("width",((B.x_high-B.x_low)*z).toString()),Y.setAttribute("height",((B.y_high-B.y_low)*z).toString()),Y.setAttribute("fill","none"),Y.setAttribute("stroke",D),Y.setAttribute("stroke-width",y.toString()),Y.setAttribute("stroke-opacity","0.5"),Y.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(Y,y,[y*2,y*2]),N&&!Y.parentElement&&N.insertBefore(Y,N.firstChild)}const ot=zt!=="none"?Ye(v,n[0],n[1]):null,ne=`x:${E}`;if((!ot||zt!=="crosshairs")&&((re=this._ciCross.get(ne))==null||re.remove(),this._ciCross.delete(ne)),ot&&zt==="crosshairs"){(Ut=this._ciRects.get(E))==null||Ut.remove(),this._ciRects.delete(E);const Y=ot.x_low*z,x=ot.x_high*z,A=-ot.y_high*z,C=-ot.y_low*z;je(H,(x-Y)/2,(C-A)/2);let M=this._ciCross.get(ne);M||(M=document.createElementNS("http://www.w3.org/2000/svg","path"),M.setAttribute("data-ci-group",E),M.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(ne,M)),M.setAttribute("d",`M${Y} ${vt} L${x} ${vt} M${V} ${A} L${V} ${C}`),M.setAttribute("fill","none"),M.setAttribute("stroke",D),M.setAttribute("stroke-width",(y*1.25).toString()),this._intervalStroke(M,y*1.25,null),M.setAttribute("stroke-opacity","0.8"),N&&!M.parentElement&&N.insertBefore(M,N.firstChild)}else if(ot){const Y=ot.x_low*z,x=-ot.y_high*z,A=(ot.x_high-ot.x_low)*z,C=(ot.y_high-ot.y_low)*z;je(H,A/2,C/2);let M=this._ciRects.get(E);M||(M=document.createElementNS("http://www.w3.org/2000/svg","rect"),M.setAttribute("data-ci-group",E),this._ciRects.set(E,M)),M.setAttribute("x",Y.toString()),M.setAttribute("y",x.toString()),M.setAttribute("width",A.toString()),M.setAttribute("height",C.toString()),M.setAttribute("fill","none"),M.setAttribute("stroke",D),M.setAttribute("stroke-width",y.toString()),M.setAttribute("stroke-opacity","0.8"),M.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(M,y,[y*4,y*3]),N&&!M.parentElement&&N.insertBefore(M,N.firstChild)}else{const Y=this._ciRects.get(E);Y&&(Y.remove(),this._ciRects.delete(E))}})}else this._removeIntervals(this._ciCross),Object.entries(Q).forEach(([v,{x:E,y:D,n:W,color:G}])=>{const V=new J({ID:`mean-${v}`,dimensions:[E/W*z,-(D/W)*z],meta:{kind:"mean",name:v,group:v,fixedSize:o.meanFixedSize}});V.color=new tt(G),V.size=4,V.shape="rect",this.__data__.points.set(V.ID,V),I.__data__.objects.set(V.ID,V)}),o.showCI?(this._ciRects.forEach((v,E)=>{Q[E]||(v.remove(),this._ciRects.delete(E))}),(ai=s.confidence)!=null&&ai.rows?s.confidence.rows().forEach(v=>{const E=v.names.indexOf(h??"group"),D=E>=0?String(v[E]):v.rowName??null;if(!D)return;const W=_[D]??"#888888",G=Ye(v,n[0],n[1]);if(!G)return;const V=G.x_low*z,vt=-G.y_high*z,H=(G.x_high-G.x_low)*z,ht=(G.y_high-G.y_low)*z;je(this.__data__.points.get(`mean-${D}`),H/2,ht/2);let $=this._ciRects.get(D);$||($=document.createElementNS("http://www.w3.org/2000/svg","rect"),$.setAttribute("data-ci-group",D),this._ciRects.set(D,$)),$.setAttribute("x",V.toString()),$.setAttribute("y",vt.toString()),$.setAttribute("width",H.toString()),$.setAttribute("height",ht.toString()),$.setAttribute("fill","none"),$.setAttribute("stroke",W),$.setAttribute("stroke-width",y.toString()),$.setAttribute("stroke-opacity","0.8"),$.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke($,y,[y*4,y*3]),N&&!$.parentElement&&N.insertBefore($,N.firstChild)}):Object.entries(Q).forEach(([v,{x:E,y:D,x2:W,y2:G,n:V,color:vt}])=>{if(V<2)return;const H=E/V,ht=D/V,$=W/V-H*H,ie=G/V-ht*ht,{halfW:pt,halfH:zt}=$i($,ie,V,z),Bt=H*z,Oe=-ht*z;je(this.__data__.points.get(`mean-${v}`),pt,zt);let B=this._ciRects.get(v);B||(B=document.createElementNS("http://www.w3.org/2000/svg","rect"),B.setAttribute("data-ci-group",v),this._ciRects.set(v,B)),B.setAttribute("x",(Bt-pt).toString()),B.setAttribute("y",(Oe-zt).toString()),B.setAttribute("width",(pt*2).toString()),B.setAttribute("height",(zt*2).toString()),B.setAttribute("fill","none"),B.setAttribute("stroke",vt),B.setAttribute("stroke-width",y.toString()),B.setAttribute("stroke-opacity","0.8"),B.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(B,y,[y*4,y*3]),N&&!B.parentElement&&N.insertBefore(B,N.firstChild)})):this._removeIntervals(this._ciRects),(hi=s.outlier)!=null&&hi.rows?(this._outlierRects.forEach((v,E)=>{_[E]||(v.remove(),this._outlierRects.delete(E))}),s.outlier.rows().forEach(v=>{const E=v.names.indexOf(h??"group"),D=E>=0?String(v[E]):v.rowName??null;if(!D)return;const W=_[D]??"#888888",G=Ye(v,n[0],n[1]);if(!G)return;const V=G.x_low*z,vt=-G.y_high*z,H=(G.x_high-G.x_low)*z,ht=(G.y_high-G.y_low)*z;let $=this._outlierRects.get(D);$||($=document.createElementNS("http://www.w3.org/2000/svg","rect"),$.setAttribute("data-outlier-group",D),this._outlierRects.set(D,$)),$.setAttribute("x",V.toString()),$.setAttribute("y",vt.toString()),$.setAttribute("width",H.toString()),$.setAttribute("height",ht.toString()),$.setAttribute("fill","none"),$.setAttribute("stroke",W),$.setAttribute("stroke-width",y.toString()),$.setAttribute("stroke-opacity","0.5"),$.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke($,y,[y*2,y*2]),N&&!$.parentElement&&N.insertBefore($,N.firstChild)})):this._removeIntervals(this._outlierRects)}else[this._ciRects,this._outlierRects,this._ciCross].forEach(N=>this._removeIntervals(N));if(et){this._pointLabels.forEach((y,P)=>{I.__data__.objects.get(P)||(y.remove(),this._pointLabels.delete(P))}),this._meanLabels.forEach((y,P)=>{I.__data__.objects.get(`mean-${P}`)||(y.remove(),this._meanLabels.delete(P))}),gt!==0?s.points.rows().forEach(y=>{const P=y.names.indexOf(r),v=P>=0?String(y[P]):null;if(!v)return;const E=I.__data__.objects.get(v);E&&this._syncLabel(this._pointLabels,v,qe(null,v),E,et,gt,o.labelWeightPoints)}):this._clearLabels(this._pointLabels);const N=new Map(L.map(y=>[y.rowName??String(y[0]),y]));(k?[...N.keys()]:Object.keys(Q)).forEach(y=>{const P=`mean-${y}`,v=I.__data__.objects.get(P);v&&this._syncLabel(this._meanLabels,y,qe(N.get(y),y),v,et,dt,o.labelWeightMeans)})}I.__data__.__state__.setVariable("layer_updated",I.__data__)}}else{const I=this.__children__.search("__children__","points");I==null||I.__data__.__state__.setVariable("layer_updated",I.__data__)}const Nt=this.__children__.search("__children__","trajectories");if(o.showTrajectories&&Nt){Nt.__data__.objects.clear(),this.__data__.trajectories.clear();const I=(li=s.trajectories)!=null&&li.rows?s.trajectories:s.points;if(I!=null&&I.rows){const k={},L=o.trajectoryUnits?o.trajectoryUnits.split(",").map(S=>S.trim()):null;I.rows().forEach(S=>{const y=S.names.indexOf(r)>=0?S.names.indexOf(r):S.names.indexOf("unit")>=0?S.names.indexOf("unit"):S.names.indexOf("ENA_UNIT")>=0?S.names.indexOf("ENA_UNIT"):-1,P=y>=0?String(S[y]):S.rowName||"unit-1";if(L&&!L.includes(P))return;const v=S.names.indexOf(n[0]),E=n.length>1?S.names.indexOf(n[1]):-1,D=S.names.indexOf("time")>=0?S.names.indexOf("time"):S.names.indexOf("ActivityNumber")>=0?S.names.indexOf("ActivityNumber"):S.names.indexOf("RowID")>=0?S.names.indexOf("RowID"):-1,W=D>=0?Number(S[D]):k[P]?k[P].length+1:1;v>=0&&E>=0&&(k[P]||(k[P]=[]),k[P].push({x:Number(S[v])*z,y:-Number(S[E])*z,time:W}))}),Object.keys(k).forEach((S,y)=>{const P=k[S];if(P.length===0)return;const v=g[y%g.length],E=new ce({ID:`traj-${S}`,unitId:S,color:new tt(v),lineStyle:o.trajectoryLineStyle,strokeWidth:o.trajectoryStrokeWidth,strokeWidthRange:o.trajectoryStrokeWidthRange,opacityRange:o.trajectoryOpacityRange,smooth:o.trajectorySmooth,maxDegree:o.trajectoryMaxDegree,degreeSelection:o.trajectoryDegreeSelection,currentTime:o.trajectoryPlayhead??1/0,showPoints:o.trajectoryShowPoints,showTips:o.trajectoryShowTips,points:P.map(D=>({x:D.x,y:D.y,time:D.time}))});this.__data__.trajectories.set(S,E),Nt.__data__.objects.set(E.ID,E)})}Nt.__data__.__state__.setVariable("layer_updated",Nt.__data__)}const kt=this.__children__.search("__children__","network"),es=kt==null?void 0:kt.__children__.search("__children__","edges"),rt=kt==null?void 0:kt.__children__.search("__children__","nodes"),Hs=kt==null?void 0:kt.__children__.search("__children__","edgenodes"),Bi=o.showEdges;if((ci=s.nodes)!=null&&ci.rows&&rt){if(s.nodes.rows().forEach(k=>{const L=mt(k,a,"#444444");L.size=2;const N=k.names.indexOf("label"),S=N>=0?k[N]:null,y=k.names.indexOf("size"),P=y>=0&&k[y]!=null&&k[y]!==""?Number(k[y]):NaN;L.meta={...L.meta??{},kind:"node",name:S!=null&&String(S)!=="NA"&&String(S)!==""?String(S):L.ID,sizePx:Number.isFinite(P)&&P>0?P:void 0,zoomFixed:o.nodeFixedSize||void 0},rt.__data__.objects.set(L.ID,L)}),Bi&&es){const k={};h&&((_i=s.points)!=null&&_i.rows)&&s.points.rows().forEach(x=>{const A=x.names.indexOf(r),C=x.names.indexOf(h);A>=0&&C>=0&&(k[String(x[A])]=String(x[C]))});const L=s.nodes.rows().map(x=>{const A=x.names.indexOf(a);return A>=0?String(x[A]):""}).filter(Boolean),N=c(x=>{const A=[];return x.forEach(C=>{const M=Ri(C,L);M&&A.push({col:C,pair:M})}),A},"parsePairs"),S=(ui=s.edges)!=null&&ui.rows?s.edges.rows():[],y=s.networks,P=N(((di=s.edges)==null?void 0:di.names)??[]),v=N((y==null?void 0:y.names)??[]),E=c(x=>{const A={};return S.forEach(C=>{const M=C.names.indexOf(r);M<0||String(C[M])!==x||P.forEach(({col:F})=>{const Z=C.names.indexOf(F);Z>=0&&(A[F]=Number(C[Z])||0)})}),A},"getUnitEdges"),D=c(x=>{const A={};let C=0;if(S.forEach(F=>{const Z=F.names.indexOf(r),ft=Z>=0?String(F[Z]):null,bt=h?F.names.indexOf(h):-1;(bt>=0?String(F[bt]):ft?k[ft]:null)===x&&(C++,P.forEach(({col:At})=>{const yt=F.names.indexOf(At);if(yt>=0){const K=Number(F[yt]);isNaN(K)||(A[At]=(A[At]??0)+K)}}))}),C===0)return{};const M={};return P.forEach(({col:F})=>{M[F]=(A[F]??0)/C}),M},"getGroupEdges"),W=c(x=>{if(_[x])return{weights:D(x),color:_[x],label:x};const A=k[x]??null,C=A?_[A]??"#888888":"#888888";return{weights:E(x),color:C,label:x}},"resolve"),G=[],V=c(x=>{var M;const A=(M=y==null?void 0:y.rows)==null?void 0:M.call(y).find(F=>F.rowName===x);if(!A)return null;const C={};return v.forEach(({col:F})=>{const Z=A.names.indexOf(F);if(Z>=0){const ft=Number(A[Z]);Number.isFinite(ft)&&(C[F]=ft)}}),C},"networkRow"),vt=c((x,A)=>{if(!A)return x;const C=Math.abs(x);return C<A[0]?0:C>A[1]?Math.sign(x)*A[1]:x},"thresholded");o.edgeLayers.forEach((x,A)=>{const C=c((K,lt,st,Et,ct)=>{st=vt(st,x.threshold),!(Math.abs(st)<1e-6)&&G.push({col:`${A}:${K}`,pair:lt,weight:Math.abs(st),color:Et,layer:A,...ct})},"push"),M=c((K,lt)=>x.colors?[x.colors[0],x.colors[1]??ji(x.colors[0])]:[K,lt],"signColors");if(x.network){const K=V(x.network);if(!K)return;const[lt,st]=M(g[0],g[1]),Et={name:x.name??x.network};v.forEach(({col:ct,pair:gi})=>{const Pe=K[ct]??0;C(ct,gi,Pe,Pe>=0?lt:st,Et)});return}const F=x.unit??x.group??null;if(!F)return;const Z=W(F),ft=x.compare??x.also??null,bt=ft?W(ft):null,Ct={name:x.name??F,group:x.group??void 0,unit:x.unit??void 0},[At,yt]=M(Z.color,(bt==null?void 0:bt.color)??Z.color);bt&&x.compare?P.forEach(({col:K,pair:lt})=>{const st=(Z.weights[K]??0)-(bt.weights[K]??0);C(K,lt,st,st>0?At:yt,Ct)}):bt&&x.also?P.forEach(({col:K,pair:lt})=>{const st=Z.weights[K]??0,Et=bt.weights[K]??0;st>0&&C(K+"-a",lt,st,At,Ct),Et>0&&C(K+"-b",lt,Et,yt,{...Ct,name:x.also??void 0,group:x.also??void 0})}):P.forEach(({col:K,pair:lt})=>{const st=Z.weights[K]??0;st>0&&C(K,lt,st,At,Ct)})}),G.sort((x,A)=>A.weight-x.weight);const H=!!s.directed,ht=zi(o.edgeWidth)*(o.edgeMagnify??1),$=c(x=>{const A=x.map(Math.abs).filter(C=>C>0);return A.length?[Math.min(...A),Math.max(...A)]:[0,0]},"rangeOf"),[ie,pt]=S.length?[P,s.edges]:[v,y],zt=c(x=>{const A=[];return ie.forEach(({col:C,pair:M})=>{if(M[0]===M[1]!==x)return;const F=pt==null?void 0:pt.col(C);if(F)for(const Z of F)A.push(Number(Z))}),$(A)},"modelRange"),Bt=c(x=>$(G.filter(A=>A.pair[0]===A.pair[1]===x).map(A=>A.weight)),"plotRange"),Oe=o.edgeColorScale,B=c(x=>Oe==="plot"?Bt(x):zt(x),"colourRange"),ot=B(!1),ne=B(!0),ss=c((x,A)=>{if(Oe==="absolute"){const F=Math.min(1,Math.abs(x));return{saturation:F,opacity:F}}const[C,M]=A?ne:ot;return{saturation:Bs(x,C,M,Ai),opacity:Bs(x,C,M,Si)}},"colourOf"),re={};G.forEach(({pair:x,weight:A})=>{if(x[0]===x[1]&&!H)return;const M=c(F=>{re[F]=(re[F]??0)+Math.abs(A)},"add");if(H){M(x[1]);return}M(x[0]),M(x[1])}),s.nodes.rows().forEach(x=>{var ft;const A=x.names.indexOf(a),C=A>=0?String(x[A]):"";if(!C)return;const M=rt.__data__.objects.get(C);if(!M)return;const F=re[C]??0,Z=!(F>0);M.size=Z?o.hideUnconnectedNodes?0:ki:Ci(F,ht),M.meta={...M.meta??{},hidden:Z&&o.hideUnconnectedNodes,sizePx:Z||(ft=M.meta)==null?void 0:ft.sizePx}});const Ut={},Y=c((x,A,C,M)=>`${x}:${A??""}:${C}.${M}`,"pairKey");H&&G.forEach(({pair:x,weight:A,layer:C,name:M})=>{const F=Y(C,M,x[0],x[1]);Ut[F]=(Ut[F]??0)+A}),G.forEach(({col:x,pair:A,weight:C,color:M,layer:F,name:Z,group:ft,unit:bt})=>{var Pe,mi;const Ct=rt.__data__.objects.get(A[0]),At=rt.__data__.objects.get(A[1]);if(!Ct||!At)return;const yt=A[0]===A[1];if(yt&&!H)return;const{saturation:K,opacity:lt}=ss(C,yt),st=new J({ID:`${A[0]}-src`,dimensions:[Ct.x,Ct.y],meta:{}}),Et=new J({ID:`${A[1]}-dst`,dimensions:[At.x,At.y],meta:{}});let ct;if(yt)ct=new Vt({},st,Et),ct.weight=0;else if(H){const Ui=Ut[Y(F,Z,A[0],A[1])]??C,Xi=Ut[Y(F,Z,A[1],A[0])]??0,Wi=Ui+Xi;ct=new cs({weight:C,totalweight:Wi},st,Et)}else ct=new Ht({},st,Et);ct.ID=`edge-${x}`,ct.color=new tt(M),ct.meta={isMeanEdge:!0,weight:C,widthFrac:ht,saturation:K,opacity:lt,isDirected:H,isSelf:yt,source:A[0],target:A[1],group:ft,unit:bt,layer:Z,selfSize:yt?((Pe=o.edgeLayers[F])==null?void 0:Pe.selfSize)??void 0:void 0,fixedSize:((mi=o.edgeLayers[F])==null?void 0:mi.fixedSize)||void 0},(yt?Hs??es:es).__data__.objects.set(ct.ID,ct)})}const I=o.showNodes;rt.svg_element&&(rt.svg_element.style.display=I?"":"none"),I||this._clearLabels(this._nodeLabels),et&&I&&(this._nodeLabels.forEach((k,L)=>{rt.__data__.objects.get(L)||(k.remove(),this._nodeLabels.delete(L))}),s.nodes.rows().forEach(k=>{var y,P,v;const L=k.names.indexOf(a),N=L>=0?String(k[L]):"";if(!N)return;const S=rt.__data__.objects.get(N);if(S){if((y=S.meta)!=null&&y.hidden){(P=this._nodeLabels.get(N))==null||P.remove(),this._nodeLabels.delete(N);return}this._syncLabel(this._nodeLabels,N,qe(k,String(((v=S.meta)==null?void 0:v.name)??N)),S,et,j,o.labelWeightNodes)}})),rt.__data__.__state__.setVariable("layer_updated",rt.__data__)}else rt==null||rt.__data__.__state__.setVariable("layer_updated",rt.__data__);[es,Hs].forEach(I=>I==null?void 0:I.__data__.__state__.setVariable("layer_updated",I.__data__));const Vs=this.__children__.search("__children__","axis_points"),Zs=this.__children__.search("__children__","axis_lines");Vs&&this.__data__.__state__.setVariable("graph_updated_axis_points",Vs.__data__.objects),Zs&&this.__data__.__state__.setVariable("graph_updated_axis_lines",Zs.__data__.objects),this.update(),i&&this._startTween(i)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","view-padding","labels","label-nodes","label-means","label-points"]}get vizena(){return this._vizena}_viewPadding(){const t=Number(this.getAttribute("view-padding"));return this.hasAttribute("view-padding")&&Number.isFinite(t)&&t>0?t:1.2}unitsPerPixel(){var i,n;const t=this.__data__.extremes.x_max||1,e=(n=(i=this.svg_element)==null?void 0:i.getBoundingClientRect)==null?void 0:n.call(i),s=this.zoom_level||1;return e&&e.width>0?2*t/e.width/s:t*.004}_syncLabel(t,e,s,i,n,r,a){let h=t.get(e);const o=s.text!=null&&(r!==q.DISPLAY_TYPES.OFF||s.pinned);h&&(!o||h.text!==s.text||h.displayMode!==r)&&(h.remove(),t.delete(e),h=void 0),o&&(h?(h.setPoint(i),r===q.DISPLAY_TYPES.ON&&h.show()):(h=new _s(s.text,i,n,this,r),t.set(e,h)),s.offset&&h.setOffset(s.offset.x,s.offset.y),h.fontWeight=a,h.setHostPinned(s.pinned))}_nodeRadius(t){const e=this.__children__.search("__children__","nodes"),s=e==null?void 0:e.__children__.find(i=>{var n;return((n=i.__data__)==null?void 0:n.ID)===t});return s?s.computeRadius():null}_intervalStroke(t,e,s){this._intervalBase.set(t,{w:e,dash:s}),this._applyIntervalStroke(t)}_applyIntervalStroke(t){const e=this._intervalBase.get(t);if(!e)return;const s=this._meansFixedSize&&this.zoom_level||1;t.setAttribute("stroke-width",String(e.w/s)),e.dash&&t.setAttribute("stroke-dasharray",e.dash.map(i=>i/s).join(" "))}_removeIntervals(t){t.forEach(e=>e.remove()),t.clear()}_clearLabels(t){t.forEach(e=>e.remove()),t.clear()}_scheduleRerender(){!this._vizena||!this._hasModel||this._renderPending||(this._renderPending=!0,queueMicrotask(()=>{var t;this._renderPending&&(this._renderPending=!1,(t=this._vizena)==null||t.dispatchEvent(new CustomEvent("model-updated",{detail:this._vizena.model,bubbles:!0,composed:!0})))}))}_readLayerConfig(){var p;const t=this.querySelector("qe-nodes"),e=this.querySelector("qe-means"),s=[...this.querySelectorAll("qe-points")],i=s.find(u=>!u.hasAttribute("set"))??null,n=s.filter(u=>u.hasAttribute("set")),r=[...this.querySelectorAll("qe-edges")],a=c(u=>{var d;return((d=r.find(l=>l.hasAttribute(u)))==null?void 0:d.getAttribute(u))??null},"firstAttr"),h=r.find(u=>u.hasAttribute("magnify")),o=this.querySelector("qe-trajectories"),_=this.querySelector("qe-axes"),g=this.getAttribute("labels");return{labelNodes:Ge((t==null?void 0:t.getAttribute("label"))??this.getAttribute("label-nodes")??g,q.DISPLAY_TYPES.ON),labelWeightNodes:(t==null?void 0:t.getAttribute("label-font-weight"))||null,nodeFixedSize:!!t&&t.hasAttribute("fixed-size"),showNodes:!!t,range:(()=>{const u=this.getAttribute("range");if(u==="network"||u==="points")return u;const d=Number(u);return u!=null&&Number.isFinite(d)&&d>0?d:null})(),plotTitle:this.getAttribute("plot-title")||null,labelFont:{size:(()=>{const u=Number(this.getAttribute("label-font-size"));return Number.isFinite(u)&&u>0?u:null})(),family:this.getAttribute("label-font-family")||null,color:this.getAttribute("label-font-color")||null},edgeWidth:(()=>{const u=Number(this.getAttribute("edge-width"));return Number.isFinite(u)&&u>0&&u<=1?u:vi})(),hideUnconnectedNodes:((p=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:p.toLowerCase())==="hide",scalePoints:this.getAttribute("scale-points")!=="false",pointScale:(()=>{const u=Number(this.getAttribute("point-scale"));return this.hasAttribute("point-scale")&&Number.isFinite(u)&&u>0?u:null})(),centerContent:this.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const u=e==null?void 0:e.getAttribute("intervals");return u==="box"||u==="crosshairs"||u==="none"?u:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:Ge((e==null?void 0:e.getAttribute("label"))??this.getAttribute("label-means")??g,q.DISPLAY_TYPES.ON),labelWeightMeans:(e==null?void 0:e.getAttribute("label-font-weight"))||null,meanFixedSize:!!e&&e.hasAttribute("fixed-size"),showPoints:!!i,pointSets:n.map(u=>({set:u.getAttribute("set"),size:u.getAttribute("size")?parseFloat(u.getAttribute("size")):null,fixedSize:u.hasAttribute("fixed-size"),labelMode:Ge(u.getAttribute("label")??this.getAttribute("label-points")??g,q.DISPLAY_TYPES.OFF),labelWeight:u.getAttribute("label-font-weight")||null})),labelPoints:Ge((i==null?void 0:i.getAttribute("label"))??this.getAttribute("label-points")??g,q.DISPLAY_TYPES.OFF),labelWeightPoints:(i==null?void 0:i.getAttribute("label-font-weight"))||null,pointSize:i!=null&&i.getAttribute("size")?parseFloat(i.getAttribute("size")):null,pointFixedSize:!!i&&i.hasAttribute("fixed-size"),showEdges:r.length>0,edgeLayers:r.map(Di),edgeColorScale:Yi(a("color-scale")),edgeMagnify:h?(()=>{const u=Number(h.getAttribute("magnify"));return Number.isFinite(u)&&u>0?u:1})():null,showTrajectories:!!o,trajectoryUnits:(o==null?void 0:o.getAttribute("units"))??null,trajectorySmooth:(o==null?void 0:o.getAttribute("smooth"))??"none",trajectoryMaxDegree:o!=null&&o.getAttribute("max-degree")?parseInt(o.getAttribute("max-degree"),10):3,trajectoryDegreeSelection:(o==null?void 0:o.getAttribute("degree-selection"))??"loocv_2d",trajectoryShowPoints:(o==null?void 0:o.getAttribute("points"))!=="false",trajectoryShowTips:(o==null?void 0:o.getAttribute("tips"))!=="false",trajectoryPlayhead:o!=null&&o.getAttribute("playhead")?parseFloat(o.getAttribute("playhead")):null,trajectoryLineStyle:(o==null?void 0:o.getAttribute("line-style"))??"uniform",trajectoryStrokeWidth:o!=null&&o.getAttribute("stroke-width")?parseFloat(o.getAttribute("stroke-width")):2,trajectoryStrokeWidthRange:this._parseNumberPair(o==null?void 0:o.getAttribute("stroke-width-range"),[1,6]),trajectoryOpacityRange:this._parseNumberPair(o==null?void 0:o.getAttribute("opacity-range"),[.3,1]),showAxes:!!_,axesFixedSize:!!_&&_.hasAttribute("fixed-size"),axisXLabel:_!=null&&_.hasAttribute("x")?_.getAttribute("x")??"":null,axisYLabel:_!=null&&_.hasAttribute("y")?_.getAttribute("y")??"":null}}_parseNumberPair(t,e){if(!t)return e;const s=t.split(",").map(i=>Number(i.trim()));return s.length<2||!s.every(Number.isFinite)?e:[s[0],s[1]]}attributeChangedCallback(t,e,s){e!==s&&this._scheduleRerender()}connectedCallback(){var n;const t=this.getAttribute("width"),e=this.getAttribute("height");this.style.display="block",t&&(this.style.width=isNaN(Number(t))?t:`${t}px`),e&&(this.style.height=isNaN(Number(e))?e:`${e}px`),this.appendChild(this.svg_element),it._instances.add(this),this._childObserver=new MutationObserver(()=>this._scheduleRerender()),this._childObserver.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["group","unit","compare","also","color-scale","magnify","network","colors","threshold","name","groups","confidence","label","intervals","outlier","set","unconnected","scale-points","point-scale","edge-width","labels","range","center","view-padding","plot-title","label-font-size","label-font-family","label-font-color","label-font-weight","label-nodes","label-means","label-points","self-size","units","smooth","degree","points","tips","playhead","line-style","stroke-width","stroke-width-range","opacity-range","x","y","size","fixed-size"]});const s=this.getAttribute("for");this._vizena=(s?document.getElementById(s):null)??this.closest("qe-visual")??((n=this.parentElement)==null?void 0:n.closest("qe-visual"))??document.querySelector("qe-visual"),this.draw();const i=this.__children__.search("__children__","labels");if(i!=null&&i.svg_element)this._labelsGroup=i.svg_element;else{console.warn("[ena-graph] labels layer not found in layer tree; creating fallback <g>");const r=this.__children__[0];r!=null&&r.svg_element&&(this._labelsGroup=document.createElementNS("http://www.w3.org/2000/svg","g"),this._labelsGroup.setAttribute("data-layer-name","labels-fallback"),r.svg_element.appendChild(this._labelsGroup))}}disconnectedCallback(){var t,e,s;this._stopTween(),(t=this._childObserver)==null||t.disconnect(),this._childObserver=null,(e=this._resizeObs)==null||e.disconnect(),this._resizeObs=null,it._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...it._instances]}static getGraph(t){for(const e of it._instances)if(e.id===t||e.getAttribute("plot-group")===t)return e;return null}getNodes(){const t=this.__children__.search("__children__","nodes");return t?[...t.__data__.objects.values()].map(e=>{var s;return{id:e.ID,name:((s=e.meta)==null?void 0:s.name)??e.ID,x:e.x,y:e.y}}):[]}getEdges(){const t=c(e=>{const s=this.__children__.search("__children__",e);return s?[...s.__data__.objects.values()]:[]},"collect");return[...t("edges"),...t("edgenodes")].map(e=>{const s=e.meta??{};return{source:s.source,target:s.target,weight:s.weight??0,directed:!!s.isDirected,self:!!s.isSelf}}).filter(e=>e.source!=null&&e.target!=null)}_zoomLimits(){const t=c(e=>{const s=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(s)&&s>0?s:null},"num");return[t("zoom-min")??0,t("zoom-max")??1/0]}_clampZoom(t){const[e,s]=this._zoomLimits();return Math.min(s,Math.max(e,t))}_zoomStep(){const t=Number(this.getAttribute("zoom-step"));return this.hasAttribute("zoom-step")&&Number.isFinite(t)&&t>0?t:1.1}_clientToRoot(t,e){var n,r;const s=(r=(n=this.svg_element).getScreenCTM)==null?void 0:r.call(n);if(!s)return null;const i=new DOMPoint(t,e).matrixTransform(s.inverse());return[i.x,i.y]}_zoomAbout(t,e,s){if(!(Number.isFinite(t)&&t>0))return;t=this._clampZoom(t);const i=this.__data__.transform,n=t/(this.zoom_level||1);i.e=e-n*(e-i.e),i.f=s-n*(s-i.f),i.zoom(t),this.zoom_level=t,this.update()}_stopZoomAnim(){this._zoomAnim!==null&&cancelAnimationFrame(this._zoomAnim),this._zoomAnim=null}_animateZoomAbout(t,e,s,i){this._stopZoomAnim();const n=this.zoom_level||1,r=this._clampZoom(t);if(r===n)return;const a=performance.now(),h=c(o=>{const _=Math.min(1,Math.max(0,(o-a)/i));this._zoomAbout(_>=1?r:n*Math.pow(r/n,1-Math.pow(1-_,3)),e,s),this._zoomAnim=_<1?requestAnimationFrame(h):null},"step");this._zoomAnim=requestAnimationFrame(h)}zoomTo(t){this._stopZoomAnim();const{cx:e,cy:s}=this.__data__.extremes;this._zoomAbout(t,e,s)}zoomBy(t){Number.isFinite(t)&&t>0&&this.zoomTo((this.zoom_level||1)*t)}resetView(){this._stopZoomAnim();const t=this._clampZoom(1),{cx:e,cy:s}=this.__data__.extremes;this.zoom_level=t,this.__data__.transform.values=t===1?[1,0,0,1,0,0]:[t,0,0,t,e*(1-t),s*(1-t)],this.update()}static _ease(t){return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2}static _setXY(t,e,s){t.x=e,t.y=s,t.dimensions&&(t.dimensions[0]=e,t.dimensions[1]=s)}_layerObjects(t){var e;return(e=this.__children__.search("__children__",t))==null?void 0:e.__data__.objects}_intervalMarks(){return[...this._ciRects.values(),...this._outlierRects.values(),...this._ciCross.values()]}_boxGeom(t){return t.tagName.toLowerCase()==="rect"?["x","y","width","height"].map(e=>parseFloat(t.getAttribute(e)||"0")):((t.getAttribute("d")||"").match(it._PATH_NUM_RE)||[]).map(Number)}_captureTweenState(){var n;const t=new Map;for(const r of["points","nodes"])(n=this._layerObjects(r))==null||n.forEach((a,h)=>t.set(`${r}:${h}`,[a.x,a.y]));const e=new Map;this._intervalMarks().forEach(r=>e.set(r,this._boxGeom(r)));const s=this.__data__.extremes,i=this._tween;return{marks:t,boxes:e,view:[s.x_max,s.y_max,s.cx,s.cy],running:i?{t0:i.t0,k:i.k,marks:new Map(i.marks.map(r=>[r.key,[r.tx,r.ty]])),boxes:new Map(i.boxes.map(r=>[r.el,r.to])),view:i.view.to}:null}}_stopTween(){this._tweenRaf!==null&&cancelAnimationFrame(this._tweenRaf),this._tweenRaf=null,this._tween=null,this._tweenView=null}_startTween(t){var b;const e=performance.now(),s=c((f,w)=>!!w&&f.length===w.length&&f.every((T,z)=>T===w[z]),"same"),i=[];for(const f of["points","nodes"])(b=this._layerObjects(f))==null||b.forEach((w,T)=>{const z=`${f}:${T}`,j=t.marks.get(z);j&&i.push({key:z,o:w,tx:w.x,ty:w.y,cx:j[0],cy:j[1]})});const n=this._intervalMarks().map(f=>({el:f,to:this._boxGeom(f),cur:t.boxes.get(f)})).filter(f=>f.cur&&f.cur.length===f.to.length),r=this.__data__.extremes,a=[r.x_max,r.y_max,r.cx,r.cy],h=t.running,o=!!h&&h.k<.95&&s(a,h.view)&&i.every(f=>s([f.tx,f.ty],h.marks.get(f.key)??[f.cx,f.cy]))&&n.every(f=>s(f.to,h.boxes.get(f.el)??f.cur)),_=o?h.k:0,g=c((f,w)=>_>0?(f-_*w)/(1-_):f,"from"),p=i.map(f=>({key:f.key,o:f.o,tx:f.tx,ty:f.ty,fx:g(f.cx,f.tx),fy:g(f.cy,f.ty)})).filter(f=>f.fx!==f.tx||f.fy!==f.ty),u=n.map(f=>({el:f.el,to:f.to,from:f.cur.map((w,T)=>g(w,f.to[T])),attrs:Object.fromEntries(["x","y","width","height","d"].filter(w=>f.el.hasAttribute(w)).map(w=>[w,f.el.getAttribute(w)]))})).filter(f=>!s(f.from,f.to)),d=t.view.map((f,w)=>g(f,a[w]));if(!p.length&&!u.length&&s(d,a))return;this._tween={t0:o?h.t0:e,dur:this._animateMs,k:_,marks:p,boxes:u,view:{from:d,to:a}},this._tweenFrame(_);const l=c(f=>{const w=this._tween;if(!w)return;const T=(f-w.t0)/w.dur;if(T>=1){this._endTween();return}this._tweenFrame(Math.max(w.k,it._ease(Math.max(0,T)))),this._tweenRaf=requestAnimationFrame(l)},"step");this._tweenRaf=requestAnimationFrame(l)}_tweenFrame(t){const e=this._tween;if(!e)return;e.k=t;const s=c((i,n)=>i+(n-i)*t,"lerp");e.marks.forEach(i=>it._setXY(i.o,s(i.fx,i.tx),s(i.fy,i.ty))),this._attachEdges(),e.boxes.forEach(i=>{const n=i.from.map((r,a)=>s(r,i.to[a]));if("d"in i.attrs){let r=0;i.el.setAttribute("d",i.attrs.d.replace(it._PATH_NUM_RE,()=>String(n[r++])))}else["x","y","width","height"].forEach((r,a)=>i.el.setAttribute(r,String(n[a])))}),this._tweenView=e.view.from.map((i,n)=>s(i,e.view.to[n])),this.update()}_endTween(){const t=this._tween;t&&(t.marks.forEach(e=>it._setXY(e.o,e.tx,e.ty)),this._attachEdges(),t.boxes.forEach(e=>Object.entries(e.attrs).forEach(([s,i])=>e.el.setAttribute(s,i))),this._stopTween(),this.update())}_attachEdges(){var e;const t=this._layerObjects("nodes");if(t)for(const s of["edges","edgenodes"])(e=this._layerObjects(s))==null||e.forEach(i=>{var a,h;const n=t.get((a=i.meta)==null?void 0:a.source),r=t.get((h=i.meta)==null?void 0:h.target);n&&i.from&&it._setXY(i.from,n.x,n.y),r&&i.to&&it._setXY(i.to,r.x,r.y)})}toSVG(){const t=this.svg_element.cloneNode(!0);t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");const e=this.svg_element.getBoundingClientRect();return e.width&&t.setAttribute("width",String(Math.round(e.width))),e.height&&t.setAttribute("height",String(Math.round(e.height))),new XMLSerializer().serializeToString(t)}toPNG(t=2){const e=this.toSVG(),s=this.svg_element.getBoundingClientRect(),i=Math.max(1,Math.round(s.width)),n=Math.max(1,Math.round(s.height));return new Promise((r,a)=>{const h=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(h),_=new Image;_.onload=()=>{try{const g=document.createElement("canvas");g.width=i*t,g.height=n*t;const p=g.getContext("2d");if(!p){URL.revokeObjectURL(o),a(new Error("no 2d context"));return}p.scale(t,t),p.drawImage(_,0,0,i,n),URL.revokeObjectURL(o),r(g.toDataURL("image/png"))}catch(g){URL.revokeObjectURL(o),a(g)}},_.onerror=g=>{URL.revokeObjectURL(o),a(g)},_.src=o})}getPoints(){const t=this.__children__.search("__children__","points");return t?[...t.__data__.objects.values()].filter(e=>{var s;return((s=e.meta)==null?void 0:s.kind)==="point"}).map(e=>{var s,i,n;return{id:((s=e.meta)==null?void 0:s.unit)??e.ID,group:(i=e.meta)==null?void 0:i.group,set:(n=e.meta)==null?void 0:n.set,x:e.x,y:e.y}}):[]}pointsInRect(t){return this.getPoints().filter(e=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h).map(e=>e.id)}_edgeKey(t,e){return t<=e?`${t}\0${e}`:`${e}\0${t}`}setHighlight(t){this._highlight.edges=new Set((t.edges??[]).map(e=>this._edgeKey(e.source,e.target))),this._highlight.nodes=new Set((t.nodes??[]).map(String)),this._applyHighlights()}clearHighlight(){this._highlight.edges.clear(),this._highlight.nodes.clear(),this._applyHighlights()}_applyHighlights(){var _;if(!this.svg_element)return;this._highlightGroup||(this._highlightGroup=document.createElementNS("http://www.w3.org/2000/svg","g"),this._highlightGroup.setAttribute("data-layer-name","highlight"),this._highlightGroup.setAttribute("pointer-events","none"));const t=this._highlight.edges.size>0||this._highlight.nodes.size>0,e=(_=this.__children__[0])==null?void 0:_.svg_element;(t&&e?e:this.svg_element).appendChild(this._highlightGroup);const s=this._highlightGroup;s.textContent="";const i=this.__data__.extremes.x_max||1,n="#f5a623",r=this.zoom_level||1,a=this._edgesFixedSize?r:1,h=c(g=>{var d;const p=c(l=>{var b;return(b=this.__children__.search("__children__",l))==null?void 0:b.__data__.objects.get(g)},"find"),u=(d=p("nodes")??p("points"))==null?void 0:d.meta;return u!=null&&u.zoomFixed||u!=null&&u.fixedSize?r:1},"markK"),o=c((g,p)=>{const u=document.createElementNS("http://www.w3.org/2000/svg",g);for(const d in p)u.setAttribute(d,String(p[d]));return u},"mk");if(this._highlight.edges.size){const g={};this.getNodes().forEach(p=>{g[p.id]={x:p.x,y:p.y}}),this._highlight.edges.forEach(p=>{const[u,d]=p.split("\0"),l=g[u],b=g[d];!l||!b||s.appendChild(o("line",{x1:l.x,y1:l.y,x2:b.x,y2:b.y,stroke:n,"stroke-width":i*.02/a,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(g=>{var f;const p=this.svg_element.querySelector(`[data-point-id="${(f=window.CSS)!=null&&f.escape?CSS.escape(g):g}"]`);if(!p)return;const u=p.tagName.toLowerCase();let d,l,b;if(u==="rect"){const w=parseFloat(p.getAttribute("width")||"0");d=parseFloat(p.getAttribute("x")||"0")+w/2,l=parseFloat(p.getAttribute("y")||"0")+parseFloat(p.getAttribute("height")||"0")/2,b=w/2}else d=parseFloat(p.getAttribute("cx")||"0"),l=parseFloat(p.getAttribute("cy")||"0"),b=parseFloat(p.getAttribute("r")||"0");s.appendChild(o("circle",{cx:d,cy:l,r:b*1.7+i*.004/h(g),fill:"none",stroke:n,"stroke-width":i*.006/h(g)}))})}create(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.classList.add("graph"),t.style.display="block",t.style.width="100%",t.style.height="100%",t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.setAttribute("viewBox",this.__data__.extremes.as_viewBox()),t.setAttribute("transform",this.__data__.transform.toString()),t.setAttribute("role","figure"),t.setAttribute("data-graph-size",`${Math.min(this.__data__.extremes.width,this.__data__.extremes.height)}`),this.svg_element=t;const e=document.createElementNS("http://www.w3.org/2000/svg","defs"),s=.22,i=.15,n=c((r,a)=>{const h=document.createElementNS("http://www.w3.org/2000/svg","marker");h.setAttribute("id",r),h.setAttribute("markerWidth",String(s)),h.setAttribute("markerHeight",String(i)),h.setAttribute("refX",String(s)),h.setAttribute("refY",String(i/2)),h.setAttribute("orient","auto"),h.setAttribute("markerUnits","userSpaceOnUse");const o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",`M0,0 L0,${i} L${s},${i/2} z`),o.setAttribute("fill",a),h.appendChild(o),e.appendChild(h)},"makeArrow");return Ws.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const a=new De(r,this.svg_element,this);this.__children__.push(a)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){const t=c(()=>this.hasAttribute("view-locked"),"locked");this.svg_element.addEventListener("wheel",d=>{if(t())return;d.preventDefault();const l=d.deltaMode===1?33:d.deltaMode===2?this.svg_element.clientHeight||800:1,b=d.deltaY*l,f=d.ctrlKey?Math.exp(-b/100):Math.pow(this._zoomStep(),-b/100);this._stopZoomAnim();const w=this._clientToRoot(d.clientX,d.clientY);w?this._zoomAbout((this.zoom_level||1)*f,w[0],w[1]):this.zoomBy(f)},{passive:!1}),this.svg_element.addEventListener("dblclick",d=>{var b,f;if(t()||(f=(b=d.target)==null?void 0:b.closest)!=null&&f.call(b,"text[data-label-for]"))return;d.preventDefault();const l=this._clientToRoot(d.clientX,d.clientY);l&&this._animateZoomAbout((this.zoom_level||1)*2.2,l[0],l[1],200)});const e=new Map;let s=null;const i=c(()=>{const[d,l]=[...e.values()];return d?l?{mid:[(d[0]+l[0])/2,(d[1]+l[1])/2],dist:Math.hypot(d[0]-l[0],d[1]-l[1]),n:2}:{mid:d,dist:0,n:1}:null},"measure");this.svg_element.addEventListener("pointerdown",d=>{d.pointerType!=="touch"||t()||(e.set(d.pointerId,[d.clientX,d.clientY]),s=i(),this._stopZoomAnim())}),this.svg_element.addEventListener("pointermove",d=>{if(!e.has(d.pointerId))return;if(t()){e.clear(),s=null;return}e.set(d.pointerId,[d.clientX,d.clientY]);const l=i();if(l&&s&&l.n===s.n){const b=this._clientToRoot(...s.mid),f=this._clientToRoot(...l.mid);if(b&&f){const w=this.__data__.transform;w.pan(f[0]-b[0],f[1]-b[1]),l.n===2&&s.dist>0&&l.dist>0?this._zoomAbout((this.zoom_level||1)*l.dist/s.dist,f[0],f[1]):this.__children__[0].svg_element.setAttribute("transform",w.toString())}}s=l});const n=c(d=>{e.delete(d.pointerId)&&(s=i())},"touchEnd");this.svg_element.addEventListener("pointerup",n),this.svg_element.addEventListener("pointercancel",n);let r=!1,a=0,h=0;this.svg_element.addEventListener("mousedown",d=>{t()||(r=!0,a=d.clientX,h=d.clientY)});let o=null,_=null;const g=c(()=>{_&&(this.__data__.transform.pan(_.dx,_.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),_=null),o=null},"panUpdate");this.svg_element.addEventListener("mousemove",d=>{if(!r)return;if(d.buttons===0){r=!1;return}const l=this._clientToRoot(a,h),b=this._clientToRoot(d.clientX,d.clientY);a=d.clientX,h=d.clientY,!(!l||!b)&&(_={dx:((_==null?void 0:_.dx)??0)+b[0]-l[0],dy:((_==null?void 0:_.dy)??0)+b[1]-l[1]},o===null&&(o=requestAnimationFrame(g)))}),this.svg_element.addEventListener("mouseup",d=>{r=!1}),this.svg_element.addEventListener("point-clicked",(d=>{var f,w;const l=(w=(f=d.detail)==null?void 0:f.pointData)==null?void 0:w.ID;if(!l)return;const b=this._pointLabels.get(l)??this._setLabels.get(l)??this._meanLabels.get(l.replace("mean-",""))??this._nodeLabels.get(l);b&&b.displayMode===q.DISPLAY_TYPES.CLICK&&b.toggle()}));const p=c(d=>{var l;for(;d&&d!==this.svg_element;){const b=(l=d.getAttribute)==null?void 0:l.call(d,"data-point-id");if(b)return b;d=d.parentElement}return null},"findPointId"),u=c(d=>this._pointLabels.get(d)??this._setLabels.get(d)??this._meanLabels.get(d.replace(/^mean-/,""))??this._nodeLabels.get(d),"getAutoLabel");this.svg_element.addEventListener("mouseover",d=>{const l=p(d.target);if(!l)return;const b=u(l);(b==null?void 0:b.displayMode)===q.DISPLAY_TYPES.AUTO&&b.show()}),this.svg_element.addEventListener("mouseout",d=>{const l=p(d.target);if(!l)return;const b=d.relatedTarget;if(p(b)===l)return;const w=u(l);(w==null?void 0:w.displayMode)===q.DISPLAY_TYPES.AUTO&&w.hide()}),this._attachInteractionEvents()}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}_closestWith(t,e){var s,i;for(;t&&t!==this.svg_element;){if(((s=t.getAttribute)==null?void 0:s.call(t,e))!=null&&((i=t.hasAttribute)!=null&&i.call(t,e)))return t;t=t.parentElement}return null}_edgeDetail(t){const e=this._closestWith(t,"data-edge-source");if(!e)return null;const s={source:e.getAttribute("data-edge-source"),target:e.getAttribute("data-edge-target"),weight:parseFloat(e.getAttribute("data-edge-weight")||"0"),directed:e.getAttribute("data-edge-directed")==="true",self:e.getAttribute("data-edge-self")==="true"};return e.hasAttribute("data-edge-group")&&(s.group=e.getAttribute("data-edge-group")),e.hasAttribute("data-edge-unit")&&(s.unit=e.getAttribute("data-edge-unit")),s}_nodeDetail(t){const e=this._closestWith(t,"data-point-id");if(!e)return null;const s=e.tagName.toLowerCase();let i,n;s==="rect"?(i=parseFloat(e.getAttribute("x")||"0")+parseFloat(e.getAttribute("width")||"0")/2,n=parseFloat(e.getAttribute("y")||"0")+parseFloat(e.getAttribute("height")||"0")/2):(i=parseFloat(e.getAttribute("cx")||"0"),n=parseFloat(e.getAttribute("cy")||"0"));const r=e.getAttribute("data-point-id"),a={id:r,kind:e.getAttribute("data-kind")||"point",name:e.getAttribute("data-name")||r,x:i,y:n};return e.hasAttribute("data-group")&&(a.group=e.getAttribute("data-group")),e.hasAttribute("data-unit")&&(a.unit=e.getAttribute("data-unit")),a}_attachInteractionEvents(){const t=this.svg_element;t.addEventListener("click",i=>{const n=i.target,r=this._edgeDetail(n);if(r){this._emit("qe-edge-click",{...r,originalEvent:i});return}const a=this._nodeDetail(n);a&&this._emit("qe-node-click",{...a,originalEvent:i})});let e=null;const s=c((i,n)=>i==="edge"?`${n.source}\0${n.target}`:String(n.id),"keyOf");t.addEventListener("mousemove",i=>{const n=i.target,r=this._edgeDetail(n),a=r?null:this._nodeDetail(n),h=r?{type:"edge",detail:r}:a?{type:"node",detail:a}:null,o=h?s(h.type,h.detail):null;e&&(!h||e.key!==o)&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),h&&(!e||e.key!==o)&&(this._emit(h.type==="edge"?"qe-edge-hover":"qe-node-hover",{...h.detail,originalEvent:i}),e={type:h.type,key:o}),this.hasAttribute("tooltip")&&h?this._showTooltip(this._tooltipText(h.type,h.detail),i.clientX,i.clientY):this._hideTooltip()}),t.addEventListener("mouseleave",()=>{e&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),this._hideTooltip()})}_tooltipText(t,e){if(t==="edge"){const s=Number(e.weight),i=Number.isFinite(s)?` (${+s.toFixed(3)})`:"";return`${e.source} – ${e.target}${i}`}return String(e.name??e.id)}_showTooltip(t,e,s){if(!this._tooltipEl){const i=document.createElement("div");i.setAttribute("data-qe-tooltip",""),Object.assign(i.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",background:"rgba(20,20,20,0.92)",color:"#fff",font:"12px/1.4 system-ui, sans-serif",padding:"3px 7px",borderRadius:"4px",whiteSpace:"nowrap",transform:"translate(-50%, calc(-100% - 8px))"}),document.body.appendChild(i),this._tooltipEl=i}this._tooltipEl.textContent=t,this._tooltipEl.style.left=`${e}px`,this._tooltipEl.style.top=`${s}px`,this._tooltipEl.style.display="block"}_hideTooltip(){this._tooltipEl&&(this._tooltipEl.style.display="none")}draw(){var t;if(!this.svg_element){console.error("No element to draw to: ",this);return}if((t=this.wrapper)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()}),!this._resizeObs&&typeof ResizeObserver<"u"&&this.svg_element){let e=0;this._resizeObs=new ResizeObserver(s=>{var n;const i=((n=s[0])==null?void 0:n.contentRect.width)??0;i>0&&Math.abs(i-e)>.5&&(e=i,this.update_labels(),this.update_axes())}),this._resizeObs.observe(this.svg_element)}}update(){this.update_extremes(),this.update_layers(),[this._ciRects,this._outlierRects,this._ciCross].forEach(t=>t.forEach(e=>this._applyIntervalStroke(e))),this.update_labels(),this.update_extremes(),this.update_axes(),this._applyHighlights()}update_axes(){var g,p;const t=this.__children__.search("__children__","axes");t!=null&&t.svg_element&&(t.svg_element.style.display=this._showAxes?"":"none");const e=this._labelsGroup,s=this.__data__.extremes.x_max,{cx:i,cy:n}=this.__data__.extremes;if(!e||s<=0)return;const r=s*.06,a=r*.6,h=r/(this._axesFixedSize&&this.zoom_level||1),o=h*.6,_=c((u,d)=>{let l=this._axisLabelEls.get(u);if(!this._showAxes||d==null){l&&(l.remove(),this._axisLabelEls.delete(u));return}l||(l=document.createElementNS("http://www.w3.org/2000/svg","text"),l.setAttribute("data-axis-label",u),l.setAttribute("pointer-events","none"),e.appendChild(l),this._axisLabelEls.set(u,l)),l.textContent=d,l.setAttribute("font-size",h.toString()),l.setAttribute("font-family","system-ui, sans-serif"),l.setAttribute("font-weight","600"),l.setAttribute("fill","#556"),u==="x"?(l.setAttribute("x",(i+s-o).toString()),l.setAttribute("y",(-o).toString()),l.setAttribute("text-anchor","end")):(l.setAttribute("x",o.toString()),l.setAttribute("y",(n-s+h+o).toString()),l.setAttribute("text-anchor","start"))},"place");if(_("x",this._axisXText),_("y",this._axisYText),this._magnifyText==null)(g=this._magnifyEl)==null||g.remove(),this._magnifyEl=null;else{this._magnifyEl||(this._magnifyEl=document.createElementNS("http://www.w3.org/2000/svg","text"),this._magnifyEl.setAttribute("data-magnify-label",""),this._magnifyEl.setAttribute("pointer-events","none")),this._magnifyEl.parentElement||e.appendChild(this._magnifyEl);const u=this._magnifyEl;u.textContent=this._magnifyText,u.setAttribute("font-size",(r*.85).toString()),u.setAttribute("font-family","system-ui, sans-serif"),u.setAttribute("font-style","italic"),u.setAttribute("fill","#556"),u.setAttribute("x",(i-s+a).toString()),u.setAttribute("y",(n-s+r+a).toString()),u.setAttribute("text-anchor","start")}if(!this._plotTitle)(p=this._titleEl)==null||p.remove(),this._titleEl=null;else{this._titleEl||(this._titleEl=document.createElementNS("http://www.w3.org/2000/svg","text"),this._titleEl.setAttribute("data-plot-title",""),this._titleEl.setAttribute("pointer-events","none")),this._titleEl.parentElement||e.appendChild(this._titleEl);const d=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),l=this._titleEl;l.textContent=this._plotTitle,l.setAttribute("font-size",d.toString()),l.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),l.setAttribute("font-weight","600"),l.setAttribute("fill",this._labelFont.color??"#223"),l.setAttribute("x",i.toString()),l.setAttribute("y",(n-s+d*1.1).toString()),l.setAttribute("text-anchor","middle")}}update_labels(){this._nodeLabels.forEach(t=>t.update()),this._meanLabels.forEach(t=>t.update()),this._pointLabels.forEach(t=>t.update()),this._setLabels.forEach(t=>t.update())}update_extremes(){var s;const t=this.__data__;if(this._tweenView){const[i,n,r,a]=this._tweenView;t.extremes=new Lt(i,n,r,a)}else if(t.update_extremes(this._centerContent),this._rangeExtent&&this._rangeExtent>0){const{cx:i,cy:n}=t.extremes,r=this._centerContent&&this._rangeMode==="network"?t.nodeExtentFrom(i,n)*1.2:this._rangeExtent;t.extremes=new Lt(r,r,i,n)}const e=(s=this.svg_element)==null?void 0:s.getBoundingClientRect();if(this.svg_element&&e){Xt("SVG rect: ",e);let i,n;e.width===0||e.height===0?(i=1,n=1):(i=e.width,n=e.height),this.__data__.scale_x=1/(i/(4*this.__data__.extremes.x_max)),this.__data__.scale_y=1/(n/(4*this.__data__.extremes.y_max)),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),this.svg_element.setAttribute("viewBox",this.__data__.extremes.as_viewBox(this._viewPadding()));let r=this.__data__.layers.search("layers","axis_lines");if(r){let a=r.objects.get("axis-x"),h=r.objects.get("axis-y");if(a&&h){const o=this.__data__.extremes;a.from=new J({ID:"axis-x-start",dimensions:[o.cx-o.x_max,0],classes:["ena.dimension","ena.dimension"]}),a.to=new J({ID:"axis-x-end",dimensions:[o.cx+o.x_max,0],classes:["ena.dimension","ena.dimension"]}),h.from=new J({ID:"axis-y-start",dimensions:[0,o.cy-o.y_max],classes:["ena.dimension","ena.dimension"]}),h.to=new J({ID:"axis-y-end",dimensions:[0,o.cy+o.y_max],classes:["ena.dimension","ena.dimension"]})}}}}update_layers(){this.__children__.forEach(t=>{t.update()})}};c(it,"QEGraphElement"),it.tagName="qe-graph",it.style=`
|
|
19
|
-
${
|
|
18
|
+
`;let Qe=ls;const gi=1e-8;function Is(c,t=gi){return c.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}l(Is,"nearOriginFilter");function fi(c){if(c<=0)return[];if(c===1)return[0];const t=new Array(c);for(let e=0;e<c;e++)t[e]=e/(c-1);return t}l(fi,"normalizedT");function mi(c,t){return c.map(e=>{const s=new Array(t+1);let i=1;for(let n=0;n<=t;n++)s[n]=i,i*=e;return s})}l(mi,"design");function pi(c){const t=c.length,e=c[0].length,s=c.map(n=>n.slice()),i=Array.from({length:e},()=>new Array(e).fill(0));for(let n=0;n<e;n++){let r=0;for(let o=0;o<t;o++)r+=s[o][n]*s[o][n];if(r=Math.sqrt(r),i[n][n]=r,r>1e-300)for(let o=0;o<t;o++)s[o][n]/=r;for(let o=n+1;o<e;o++){let a=0;for(let h=0;h<t;h++)a+=s[h][n]*s[h][o];i[n][o]=a;for(let h=0;h<t;h++)s[h][o]-=a*s[h][n]}}return{Q:s,R:i}}l(pi,"qr");function Cs(c,t){const e=c.length,s=c[0].length,i=new Array(s).fill(0);for(let n=0;n<s;n++){let r=0;for(let o=0;o<e;o++)r+=c[o][n]*t[o];i[n]=r}return i}l(Cs,"qtY");function zs(c,t){const e=t.length,s=new Array(e).fill(0);for(let i=e-1;i>=0;i--){let n=t[i];for(let r=i+1;r<e;r++)n-=c[i][r]*s[r];s[i]=Math.abs(c[i][i])>1e-12?n/c[i][i]:0}return s}l(zs,"backSolve");function Vi(c){return c.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}l(Vi,"leverages");function bi(c,t,e){const s=mi(c,e),{Q:i,R:n}=pi(s);return zs(n,Cs(i,t))}l(bi,"fitCoeffs");function ts(c,t){let e=0,s=1;for(let i=0;i<c.length;i++)e+=c[i]*s,s*=t;return e}l(ts,"evalPoly");function Zi(c,t,e,s){const i=mi(c,s),{Q:n,R:r}=pi(i),o=Vi(n),a=zs(r,Cs(n,t)),h=zs(r,Cs(n,e));let g=0;for(let f=0;f<c.length;f++){const m=1-o[f];if(m<=0)return 1/0;const _=t[f]-ts(a,c[f]),d=e[f]-ts(h,c[f]);g+=(_/m)**2+(d/m)**2}return g}l(Zi,"loocv2d");function yi(c,t,e){const s=c.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=fi(s),r=c.map(g=>g.x),o=c.map(g=>g.y);let a=1,h=1/0;for(let g=1;g<=i;g++){const f=Zi(n,r,o,g);f<h&&(h=f,a=g)}return a}l(yi,"selectDegree");function xi(c,t){const e=Is(c);if(e.length<3)return null;const s=t.selectionSet?Is(t.selectionSet):e,i=s.length>=3?s:e;let n=yi(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=fi(e.length),o=bi(r,e.map(h=>h.x),n),a=bi(r,e.map(h=>h.y),n);return{degree:n,coeffsX:o,coeffsY:a}}l(xi,"fitTrajectory");function Os(c,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:ts(c.coeffsX,i),y:ts(c.coeffsY,i)})}return e}l(Os,"sampleCurve");const wi=100,Hs=class Hs extends Tt{constructor(t={}){const e=t.color instanceof rt?t.color:new rt(typeof t.color=="string"?t.color:"#000000");super([],{ID:t.ID||`traj-${Math.random().toString(36).substring(2,9)}`,size:t.size||1,color:e,highlight:null,active:t.active||!1,meta:t.meta||{},...t}),this._typeName="Trajectory",this.trajPoints=[],this.smooth="none",this.maxDegree=3,this.degreeSelection="loocv_2d",this.selectedDegree=-1,this.polyCoeffsX=[],this.polyCoeffsY=[],this.currentTime=1/0,this.showPoints=!0,this.showTips=!0,this.lineStyle="uniform",this.strokeWidth=2,this.strokeWidthRange=[1,6],this.opacityRange=[.3,1],this.smooth=t.smooth||"none",this.maxDegree=t.maxDegree!==void 0?t.maxDegree:3,this.degreeSelection=t.degreeSelection||"loocv_2d",this.polyCoeffsX=t.polyCoeffsX||[],this.polyCoeffsY=t.polyCoeffsY||[],this.currentTime=t.currentTime!==void 0?t.currentTime:1/0,this.showPoints=t.showPoints!==void 0?t.showPoints:!0,this.showTips=t.showTips!==void 0?t.showTips:!0,this.lineStyle=t.lineStyle||"uniform",this.strokeWidth=t.strokeWidth||2,this.strokeWidthRange=t.strokeWidthRange||[1,6],this.opacityRange=t.opacityRange||[.3,1],t.points&&Array.isArray(t.points)&&(this.trajPoints=t.points.map(s=>{if(s instanceof it)return s;const i=new it({dimensions:[s.x,s.y],meta:{time:s.time,label:s.label}});return i.x=s.x,i.y=s.y,i}))}get activePoints(){return this.currentTime===1/0?this.trajPoints:this.trajPoints.filter(t=>(t.meta&&typeof t.meta.time=="number"?t.meta.time:0)<=this.currentTime)}get path(){return this.pathPoints.reduce((t,e,s)=>s===0?`M${e.x},${e.y}`:`${t} L${e.x},${e.y}`,"")}get pathPoints(){const t=this.activePoints;if(t.length<2)return[];if(this.smooth==="poly"){if(this.polyCoeffsX.length>0&&this.polyCoeffsY.length>0)return Os({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},wi);const e=xi(t.map(s=>({x:s.x,y:s.y})),{maxDegree:this.maxDegree,degreeSelection:this.degreeSelection,selectionSet:this.trajPoints.map(s=>({x:s.x,y:s.y}))});if(e)return this.selectedDegree=e.degree,Os(e,wi)}return t.map(e=>({x:e.x,y:e.y}))}};l(Hs,"Trajectory");let we=Hs;const vi=1,Vs=class Vs extends se{constructor(t,e,s,i=0){super(t,e,s),this._totalweight=0,this._weight=i}get base_color(){return this._color}get color(){const t=this._color||new rt("#000000");return new be(t,Math.abs(this.weight))}set color(t){this._color=t}base_weight(){return this._weight}get weight(){return Array.isArray(this._weight)?this._weight[0]-this._weight[1]:this._weight}set weight(t){this._weight=t}get totalweight(){return this.weight}set totalweight(t){this._totalweight=t}};l(Vs,"Edge");let ve=Vs;const Zs=class Zs extends Tt{constructor(e){super(e.dimensions||[],e);ct(this,he);V(this,he,e)}get edge(){return R(this,he)}get path(){const e=R(this,he),s=[e.to.x,e.to.y],i=e.from_point,[n,r]=e.base_pts,o=Math.hypot(i[0]-s[0],i[1]-s[1]),a=Math.hypot(n[0]-r[0],n[1]-r[1]);if(!(o>0)||!(a>0))return"";const h=[(i[0]-s[0])/o,(i[1]-s[1])/o],g=Math.hypot(n[0]-s[0],n[1]-s[1]),f=[(n[0]-s[0])/g,(n[1]-s[1])/g],m=l(I=>a/2*Math.max(0,1-I/o),"halfW"),_=l((I,j)=>`${s[0]+h[0]*I+f[0]*j} ${s[1]+h[1]*I+f[1]*j}`,"at"),d=.2*o,u=Math.min(.15*o,.8*2*m(d)),b=d+u/2,p=d+u;return`M${_(d,0)} L${_(b,m(b))} L${_(p,m(p))} L${_(b,0)} L${_(p,-m(p))} L${_(b,-m(b))}z`}};he=new WeakMap,l(Zs,"EdgeArrow");let es=Zs;const cs=class cs extends ve{constructor(e,s,i){super(e,s,i);ct(this,le);ct(this,Be);this._path="",V(this,le,!1),this._directions=["from","to"],this.towards="to",R(this,le)===!0&&V(this,Be,new es(this))}get path(){return`M${this.from.x} ${this.from.y} L${this.base_pts[0].join(" ")} L${this.base_pts[1].join(" ")}z`}static calculate_base_points(e){const s=e.towards,i=e._directions.find(b=>b!==e.towards),n=e[i].x,r=e[i].y,o=e[s].x,a=e[s].y,h=o-n,g=a-r,f=Math.hypot(h,g),m=(e.weight??0)*vi;if(f===0||!isFinite(m)||m===0)return[[o,a],[o,a]];const _=-g/f,d=h/f,u=m/2;return[[o+_*u,a+d*u],[o-_*u,a-d*u]]}get base_pts(){return cs.calculate_base_points(this)}get arrow(){return R(this,Be)}get with_arrow(){return R(this,le)}get from_point(){return[this.from.x,this.from.y]}};le=new WeakMap,Be=new WeakMap,l(cs,"TaperedEdge");let Xt=cs;const us=class us extends Xt{constructor(t,e,s){super(t,e,s),this._dataWeight=0,this._totalweight=t.totalweight??0,this._dataWeight=t.weight??this._weight}get weighted_midpoint(){return xe.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return Xt.calculate_base_points(this)}static build_path(t){return t._totalweight>0?`M${t.weighted_midpoint[0]} ${t.weighted_midpoint[1]} L${t.base_pts[0].join(" ")} L${t.base_pts[1].join(" ")}z`:(console.error("TaperedWeightedMidpointEdge: No totalweight, returning empty path"),"")}get path(){return us.build_path(this)}get from_point(){return this.weighted_midpoint}};l(us,"TaperedWeightedMidpointEdge");let Ls=us;const _s=class _s extends ve{constructor(t,e,s){super(t,e,s)}static build_path(t,e){let s=t/2,i=e.x-s,n=s*2;return`M ${i}, ${e.y} a ${s},${s} 0 1,0 ${n},0 a ${s},${s} 0 1,0 -${n},0`}get path(){let t=this.weight*vi;return _s.build_path(t,this.to)}};l(_s,"NodeEdge");let ie=_s;const Ks=class Ks{constructor(t,e,s,i=new Dt){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.svg_element=this.create()}get_size(){return this.__data__.size}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}update(t,e=!0){}animateSVGAttribute(t,e,s){const i=parseFloat(t.getAttribute(e)||"0");if(i===s)return;const n=5e3,r=performance.now();function o(a){const h=Math.min(1,(a-r)/n),g=i+(s-i)*h;t.setAttribute(e,g.toString()),h<1?requestAnimationFrame(o):t.setAttribute(e,s.toString())}l(o,"animate"),requestAnimationFrame(o)}};l(Ks,"Drawable");let Ae=Ks;const Ki=.04,Ji=[.25,1],Qi=[.3,1];function Ai(c,t,e,s){const i=Math.abs(c);if(!(i>0))return 0;if(!(e>t))return s[1];const n=Math.min(1,Math.max(0,(i-t)/(e-t)));return s[0]+n*(s[1]-s[0])}l(Ai,"rampFor");const tn=.011,en=.75,sn=.8,nn=.75,Si=.006,rn=.6;function on(c){return 2*c}l(on,"widthPerWeight");function an(c,t){return c*t/(2*Si)}l(an,"nodeSizeForEdges");function hn(c){const t=/rgba?\(([^)]+)\)/.exec(c);if(!t)return c;const[e,s,i,n=1]=t[1].split(",").map(Number),r=l(o=>Math.round(255+(o-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}l(hn,"flattenOnWhite");function ln(c,t){const e=/rgba?\(([^)]+)\)/.exec(c);if(!e)return c;const[s,i,n,r=1]=e[1].split(",").map(Number);return`rgba(${Math.round(s*t)},${Math.round(i*t)},${Math.round(n*t)},${r})`}l(ln,"darkenRgba");const Js=class Js extends Ae{constructor(t,e,s,i=new Dt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-line",this._arrow_el=null,this._hit_el=null,this.svg_element=this.create()}_stampEdge(t){const e=this.__data__.meta??{};if(!e.isMeanEdge)return;t.setAttribute("data-edge-source",String(e.source??"")),t.setAttribute("data-edge-target",String(e.target??"")),t.setAttribute("data-edge-weight",String(e.weight??0)),t.setAttribute("data-edge-directed",e.isDirected?"true":"false");const s=l((i,n)=>n!=null&&n!==!1?t.setAttribute(i,n===!0?"true":String(n)):t.removeAttribute(i),"opt");s("data-edge-self",!!e.isSelf),s("data-edge-group",e.group),s("data-edge-unit",e.unit)}create(){if(this.__data__ instanceof ie){const e=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}if(this.__data__ instanceof Xt){const e=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}const t=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","line");return t.setAttribute("x1",this.__data__.from.x.toString()),t.setAttribute("y1",this.__data__.from.y.toString()),t.setAttribute("x2",this.__data__.to.x.toString()),t.setAttribute("y2",this.__data__.to.y.toString()),t.setAttribute("stroke-width",this.get_size().toString()),t.setAttribute("stroke",this.__data__.color.toString()),this.svg_element=t,t}get drawsPath(){return this.__data__ instanceof ie||this.__data__ instanceof Xt}update(){var i,n,r,o;if(this.svg_element||this.create(),this.svg_element.tagName.toLowerCase()==="path"!==this.drawsPath){const a=this.svg_element;this.create(),a.parentElement&&a.replaceWith(this.svg_element)}this.drawsPath&&((i=this._hit_el)==null||i.remove(),this._hit_el=null),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=((n=this.graph.__data__.extremes)==null?void 0:n.x_max)??1,e=this.__data__.meta??{};let s=!1;if(e.isMeanEdge){this._stampEdge(this.svg_element);const a=typeof e.weight=="number"?e.weight:0,h=typeof e.maxWeight=="number"?e.maxWeight:1,g=typeof e.opacity=="number"?e.opacity:Math.min(1,a/(h||1)),f=t>0?t:1,m=e.fixedSize&&this.graph.zoom_level||1,_=(typeof e.widthFrac=="number"?f*e.widthFrac*a:f*tn*(a/(h||1)))/m,d=this.__data__._color||new rt("#000000"),u=typeof e.saturation=="number"?e.saturation:g,b=e.exactColor?d.toString():new be(d,u,g).toString();if(this.__data__ instanceof ie){const p=typeof e.selfSize=="number"&&e.selfSize>0?e.selfSize:null,w=p!=null?(o=(r=this.graph)._nodeRadius)==null?void 0:o.call(r,String(e.source)):null;this.__data__.weight=typeof w=="number"?2*p*w:_,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke","none")}else if(this.__data__ instanceof Xt){if(this.__data__.weight=_,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke",b),this.svg_element.setAttribute("stroke-width",String(en)),this.svg_element.setAttribute("vector-effect","non-scaling-stroke"),this.svg_element.setAttribute("stroke-linejoin","round"),e.isDirected)try{const w=new es(this.__data__).path;w&&!w.includes("NaN")&&!w.includes("Infinity")&&(this._arrow_el||(this._arrow_el=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path"),this._arrow_el.setAttribute("stroke","none")),this._arrow_el.parentElement||this.parent.appendChild(this._arrow_el),this._arrow_el.setAttribute("d",w),this._arrow_el.setAttribute("fill",ln(hn(b),sn)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(nn)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"),s=!0)}catch{}}else{const p=this.__data__.from.x,w=this.__data__.from.y,I=this.__data__.to.x,j=this.__data__.to.y;this.svg_element.setAttribute("x1",p.toString()),this.svg_element.setAttribute("y1",w.toString()),this.svg_element.setAttribute("x2",I.toString()),this.svg_element.setAttribute("y2",j.toString()),this.svg_element.setAttribute("stroke-width",_.toString()),this.svg_element.setAttribute("stroke",b),this.svg_element.setAttribute("pointer-events","stroke"),this.svg_element.removeAttribute("marker-end"),this._hit_el||(this._hit_el=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","line"),this._hit_el.setAttribute("stroke","transparent"),this._hit_el.setAttribute("stroke-linecap","round"),this._hit_el.setAttribute("pointer-events","stroke")),this._hit_el.parentElement||this.parent.appendChild(this._hit_el),this._hit_el.setAttribute("x1",p.toString()),this._hit_el.setAttribute("y1",w.toString()),this._hit_el.setAttribute("x2",I.toString()),this._hit_el.setAttribute("y2",j.toString()),this._hit_el.setAttribute("stroke-width",Math.max(_,t*.03/m).toString()),this._stampEdge(this._hit_el)}}else{this.svg_element.setAttribute("x1",this.__data__.from.x.toString()),this.svg_element.setAttribute("y1",this.__data__.from.y.toString()),this.svg_element.setAttribute("x2",this.__data__.to.x.toString()),this.svg_element.setAttribute("y2",this.__data__.to.y.toString());const a=this.graph._axesFixedSize&&String(this.__data__.ID).startsWith("axis-")&&this.graph.zoom_level||1,h=(t>0?t:1)*.004*this.get_size()/a;this.svg_element.setAttribute("stroke-width",h.toString()),this.svg_element.setAttribute("stroke-opacity","1"),this.svg_element.setAttribute("stroke",this.__data__.color.toString())}!s&&this._arrow_el&&(this._arrow_el.remove(),this._arrow_el=null)}remove(){var t,e,s;(t=this.svg_element)==null||t.remove(),(e=this._hit_el)==null||e.remove(),(s=this._arrow_el)==null||s.remove()}draw(){var t,e,s;this._hit_el&&((t=this.parent)==null||t.appendChild(this._hit_el)),(e=this.parent)==null||e.appendChild(this.svg_element),this._arrow_el&&((s=this.parent)==null||s.appendChild(this._arrow_el))}};l(Js,"QELine");let Nt=Js;const Qs=class Qs extends Ae{constructor(t,e,s,i=new Dt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-point",this.svg_element=this.create()}get x(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[0]]}get y(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[1]]}get isSquare(){return this.__data__.shape==="rect"}get shapeKind(){const t=this.__data__.shape;return t==="rect"||t==="square"?"rect":t==="triangle"||t==="diamond"?t:"circle"}get tag(){const t=this.shapeKind;return t==="circle"?"circle":t==="rect"?"rect":"path"}setGeometry(t,e){const s=this.x,i=this.y;switch(this.shapeKind){case"rect":t.setAttribute("x",(s-e).toString()),t.setAttribute("y",(i-e).toString()),t.setAttribute("width",(e*2).toString()),t.setAttribute("height",(e*2).toString());break;case"triangle":{const n=e*1.15;t.setAttribute("d",`M${s} ${i-n} L${s+n*.866} ${i+n*.5} L${s-n*.866} ${i+n*.5}Z`);break}case"diamond":t.setAttribute("d",`M${s} ${i-e*1.2} L${s+e} ${i} L${s} ${i+e*1.2} L${s-e} ${i}Z`);break;default:t.setAttribute("cx",s.toString()),t.setAttribute("cy",i.toString()),t.setAttribute("r",e.toString())}}computeRadius(){var s;const t=this.baseRadius(),e=(s=this.__data__.meta)==null?void 0:s.maxRadius;return typeof e=="number"&&e>0?Math.min(t,e):t}baseRadius(){var e;const t=this.dataRadius();return(e=this.__data__.meta)!=null&&e.zoomFixed?t/(this.graph.zoom_level||1):t}dataRadius(){var i,n,r,o,a,h,g;const t=this.graph.__data__.extremes.x_max||1,e=((i=this.__data__.meta)==null?void 0:i.sizeScale)??1,s=(n=this.__data__.meta)==null?void 0:n.sizePx;if(typeof s=="number"&&s>0){const f=(o=(r=this.graph.svg_element)==null?void 0:r.getBoundingClientRect)==null?void 0:o.call(r),m=f&&f.width>0?2*t/f.width:t*.004;return s/2*m}if((a=this.__data__.meta)!=null&&a.fixedSize){const f=(g=(h=this.graph.svg_element)==null?void 0:h.getBoundingClientRect)==null?void 0:g.call(h),m=this.graph.zoom_level||1,_=f&&f.width>0?f.width/(2*t):1;return this.__data__.size*2*e/_/m}return t*Si*this.__data__.size*e}applyStroke(t){var s;const e=(s=this.__data__.meta)==null?void 0:s.stroke;e&&(t.setAttribute("stroke",e),t.setAttribute("stroke-width",(this.computeRadius()*.22).toString()))}stampIdentity(t){t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{},s=l((i,n)=>n!=null&&n!==""?t.setAttribute(i,String(n)):t.removeAttribute(i),"opt");s("data-kind",e.kind),s("data-name",e.name),s("data-group",e.group),s("data-unit",e.unit)}create(){const t=this.graph.doc.createElementNS("http://www.w3.org/2000/svg",this.tag);return this.stampIdentity(t),t.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(t),this.setGeometry(t,this.computeRadius()),this.svg_element=t,t.addEventListener("click",()=>{this.__data__.active=!this.__data__.active,this.update();const e=new CustomEvent("point-clicked",{detail:{pointData:this.__data__},bubbles:!0,composed:!0});this.svg_element.dispatchEvent(e)}),t.addEventListener("mouseover",()=>{}),t}update(){if(this.svg_element||this.parent.__data__.__children__.push(this.create()),this.svg_element.tagName.toLowerCase()!==this.tag){const t=this.svg_element;this.create(),t.parentElement&&t.replaceWith(this.svg_element)}this.svg_element.parentElement||this.parent.appendChild(this.svg_element),this.stampIdentity(this.svg_element),this.svg_element.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(this.svg_element),this.setGeometry(this.svg_element,this.computeRadius())}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}};l(Qs,"QEPoint");let ne=Qs;const ti=class ti extends Ae{constructor(t,e,s,i=new Dt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="trajectory",this._path_el=null,this._segments_group=null,this._tip_el=null,this._points_group=null,this.svg_element=this.create()}graphUnitsForPixels(t){var i;const e=this.graph.__data__.extremes.x_max||1,s=((i=this.graph.svg_element)==null?void 0:i.getBoundingClientRect().width)||0;return s>0?t*(2*e/s):t*e*.006}create(){const t=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");t.setAttribute("class","qe-trajectory-group");const e=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","none"),e.setAttribute("stroke",this.__data__.color.toString()),e.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),t.appendChild(e),this._path_el=e;const s=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","qe-trajectory-segments"),t.appendChild(s),this._segments_group=s;const i=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");if(i.setAttribute("class","qe-trajectory-points"),t.appendChild(i),this._points_group=i,this.__data__.showTips){const n=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("fill",this.__data__.color.toString()),n.setAttribute("r",this.graphUnitsForPixels(4).toString()),n.setAttribute("stroke","#ffffff"),n.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),t.appendChild(n),this._tip_el=n}return this.svg_element=t,t}update(){this.svg_element||this.create(),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=this.__data__.path;if(this._path_el&&(this._path_el.setAttribute("d",t),this._path_el.setAttribute("stroke",this.__data__.color.toString()),this._path_el.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),this._path_el.style.display=this.__data__.lineStyle==="tapered"?"none":"block"),this._segments_group)if(this._segments_group.innerHTML="",this.__data__.lineStyle==="tapered"){const s=this.__data__.pathPoints,i=s.length-1,[n,r]=this.__data__.strokeWidthRange,[o,a]=this.__data__.opacityRange;for(let h=0;h<i;h++){const g=s[h],f=s[h+1],m=i<=1?1:h/(i-1),_=n+(r-n)*m,d=o+(a-o)*m,u=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",`M${g.x},${g.y} L${f.x},${f.y}`),u.setAttribute("fill","none"),u.setAttribute("stroke",this.__data__.color.toString()),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-width",this.graphUnitsForPixels(_).toString()),u.setAttribute("opacity",d.toString()),this._segments_group.appendChild(u)}this._segments_group.style.display="block"}else this._segments_group.style.display="none";const e=this.__data__.activePoints;if(this._points_group&&(this.__data__.showPoints&&e.length>0?(this._points_group.innerHTML="",e.forEach(s=>{var n;const i=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","circle");i.setAttribute("cx",s.x.toString()),i.setAttribute("cy",s.y.toString()),i.setAttribute("r",this.graphUnitsForPixels(2.5).toString()),i.setAttribute("fill",this.__data__.color.toString()),i.setAttribute("opacity","0.7"),(n=this._points_group)==null||n.appendChild(i)}),this._points_group.style.display="block"):this._points_group.style.display="none"),this._tip_el&&this.__data__.showTips)if(e.length>0){const s=e[e.length-1];this._tip_el.setAttribute("cx",s.x.toString()),this._tip_el.setAttribute("cy",s.y.toString()),this._tip_el.setAttribute("fill",this.__data__.color.toString()),this._tip_el.setAttribute("r",this.graphUnitsForPixels(4).toString()),this._tip_el.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),this._tip_el.style.display="block"}else this._tip_el.style.display="none"}draw(){this.svg_element&&!this.svg_element.parentElement&&this.parent.appendChild(this.svg_element),this.update()}};l(ti,"QETrajectory");let Se=ti;const{ArrayTools:Ei}=xe,ei=class ei extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}l(i,"fn");function n(r,o,a=null){if(Ei.isArray(r)){for(const[h,g]of r.entries())if(s=n(g,h,a),s)return s}else{if(s=i(r),s)return s;if(r&&Ei.isArray(r[t])){for(const[h,g]of r[t].entries())if(s=n(g,h,r),s)return s}}return s}return l(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};l(ei,"QEArray");let Dt=ei;const cn={AxisPoint:ne,AxisLine:Nt,Point:ne,Line:Nt,Edge:Nt,TaperedEdge:Nt,TaperedWeightedMidpointEdge:Nt,NodeEdge:Nt,Trajectory:Se},ce=class ce{constructor(t,e,s,i=new Dt){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__=t.name||"unnamed-layer",t.__state__.addListener("layer_updated","live",({key:n,newValue:r,oldValue:o})=>{const a=l(m=>{var _;return(_=m.__data__)==null?void 0:_.ID},"childId"),h=this.__children__.filter(m=>!r.objects.has(a(m))),g=this.__children__.filter(m=>r.objects.has(a(m)));[...r.objects.values()].filter(m=>!this.__children__.some(_=>a(_)===m.ID)).forEach(m=>{const _=m._typeName||m.constructor.name;let d=cn[_];d||(m instanceof we?d=Se:m instanceof it?d=ne:d=Nt);const u=new d(m,this.svg_element,this.graph);this.__children__.push(u)}),g.forEach(m=>{const _=r.objects.get(a(m));_&&(m.__data__=_),m.update()}),h.forEach(m=>{var d;typeof m.remove=="function"?m.remove():(d=m.svg_element.parentElement)==null||d.removeChild(m.svg_element);const _=this.__children__.indexOf(m);_>=0&&this.__children__.splice(_,1)}),this.update()}),this.svg_element=this.create()}get name(){return this.__name__}create(){if(!this.__data__)throw new Error("Layer is null");let t=this.__data__;return this.svg_element=this.graph.doc.createElementNS("http://www.w3.org/2000/svg",ce.tagName),this.svg_element.setAttribute("data-layer-name",t.name),this.svg_element.setAttribute("data-layer-id",t.ID),this.svg_element.__data__=t,this.svg_element.classList.add("ena-layer"),this.__data__.layers&&this.__data__.layers.length>0&&this.__data__.layers.forEach(e=>{const s=new ce(e,this.svg_element,this.graph);this.__children__.push(s)}),this.svg_element}update(){if(!this.__data__)throw new Error("Layer is null");this.__data__.visible&&(this.parent.nodeName.toLowerCase(),this.__children__.forEach(t=>{t.update()}),this.__data__.scale_objects===!0&&this.__name__)}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()})}add(t){this.__children__.push(t)}};l(ce,"QELayer"),ce.tagName="g";let ss=ce;const si=class si{constructor(t,e,s,i,n=G.DISPLAY_TYPES.ON,r=G.POSITION.OBJECT,o,a){this.text=t,this.parent=s,this.graph=i,this.displayMode=n,this.position=r,this.customX=o,this.customY=a,this._visible=!1,this._offsetX=0,this._offsetY=0,this.pinned=!1,this._hostPinned=!1,this.fontWeight=null,this._point=e,this.svg_element=this._create(),n===G.DISPLAY_TYPES.ON?(this._visible=!0,this.svg_element.setAttribute("display","block")):(this._visible=!1,this.svg_element.setAttribute("display","none"))}get point(){return this._point}_create(){const t=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","text");return t.textContent=this.text,t.setAttribute("data-label-for",this.point.ID),t.setAttribute("pointer-events","auto"),t.style.cursor="grab",this._attachDrag(t),this.parent.appendChild(t),t}setPoint(t){this._point=t,this.svg_element.setAttribute("data-label-for",t.ID)}setOffset(t,e){this._offsetX=Number.isFinite(t)?t:0,this._offsetY=Number.isFinite(e)?e:0}setHostPinned(t){t!==this._hostPinned&&(this._hostPinned=t,t?this.show():this.displayMode!==G.DISPLAY_TYPES.ON&&this.hide())}_attachDrag(t){t.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,"mouse")}),t.addEventListener("pointerdown",e=>{e.pointerType==="touch"&&(e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,e.pointerId))})}_drag(t,e,s,i){const n=t.parentNode??t.ownerSVGElement,r=t.ownerSVGElement;if(!r||!n)return;const o=l((_,d)=>{const u=r.createSVGPoint();u.x=_,u.y=d;const b=n.getScreenCTM();return b?u.matrixTransform(b.inverse()):{x:0,y:0}},"toUser"),a=o(e,s),h=this._offsetX,g=this._offsetY;t.style.cursor="grabbing";const f=l((_,d)=>{const u=o(_,d);this._offsetX=h+(u.x-a.x),this._offsetY=g+(u.y-a.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"move"),m=l(()=>{t.style.cursor="grab",this.graph.dispatchEvent(new CustomEvent("qe-label-move",{detail:{id:this.point.ID,transform:{x:this._offsetX,y:this._offsetY}},bubbles:!0,composed:!0}))},"done");if(i==="mouse"){const _=l(u=>f(u.clientX,u.clientY),"onMove"),d=l(()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",d),m()},"onUp");document.addEventListener("mousemove",_),document.addEventListener("mouseup",d)}else{const _=l(u=>{u.pointerId===i&&f(u.clientX,u.clientY)},"onMove"),d=l(u=>{u.pointerId===i&&(document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d),m())},"onUp");document.addEventListener("pointermove",_),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d)}}update(){var a,h;if(!this._visible)return;const t=this.graph.__data__.extremes.x_max;if(t<=0)return;const e=this.graph._labelFont??{},s=e.size?e.size*this.graph.unitsPerPixel():t*.06,i=s*1.2;let n,r,o;switch(this.position){case G.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,o="middle";break}case G.POSITION.CONTAINER:{const{cx:g,cy:f}=this.graph.__data__.extremes,m=this.point.x-g,_=this.point.y-f,d=Math.sqrt(m*m+_*_)||1,u=t*.93/d;n=g+m*u,r=f+_*u-i*.3,o=m>=0?"start":"end";break}case G.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,o="start";break}default:case G.POSITION.OBJECT:{const g=this.point.x>=0?i:-i;o=this.point.x>=0?"start":"end",n=this.point.x+g,r=this.point.y-i*.4;break}}this.svg_element.setAttribute("x",n.toString()),this.svg_element.setAttribute("y",r.toString()),this._offsetX||this._offsetY?this.svg_element.setAttribute("transform",`translate(${this._offsetX}, ${this._offsetY})`):this.svg_element.removeAttribute("transform"),this.svg_element.setAttribute("font-size",s.toString()),this.svg_element.setAttribute("font-family",e.family??"system-ui, sans-serif"),this.svg_element.setAttribute("font-weight",this.fontWeight??"500"),this.svg_element.setAttribute("text-anchor",o),this.svg_element.setAttribute("fill",((a=this.point.meta)==null?void 0:a.labelColor)??e.color??((h=this.point.color)==null?void 0:h.toString())??"#333333"),!this._offsetX&&!this._offsetY&&this.position!==G.POSITION.CUSTOM&&this.fitInside(n,r,o,i,s*.3)}visibleBounds(){const t=this.svg_element,e=t.ownerSVGElement;if(!e)return null;const s=typeof t.getScreenCTM=="function"&&typeof DOMPoint<"u"?t.getScreenCTM():null;if(!s)return this.estimatedVisibleBounds(e);const i=e.getBoundingClientRect();if(!(i.width>0&&i.height>0))return null;const n=s.inverse(),r=new DOMPoint(i.left,i.top).matrixTransform(n),o=new DOMPoint(i.right,i.bottom).matrixTransform(n);return{left:Math.min(r.x,o.x),right:Math.max(r.x,o.x),top:Math.min(r.y,o.y),bottom:Math.max(r.y,o.y)}}estimatedVisibleBounds(t){var m;const e=(m=t.getBoundingClientRect)==null?void 0:m.call(t),s=l(_=>{const d=Number(t.getAttribute(_));return Number.isFinite(d)&&d>0?d:0},"size"),i=(e==null?void 0:e.width)||s("width"),n=(e==null?void 0:e.height)||s("height"),r=Xi(t.getAttribute("viewBox"),i,n);if(!r)return null;let o=[1,0,0,1,0,0];for(let _=this.svg_element.parentElement;_&&_!==t;_=_.parentElement){const d=Gi(_.getAttribute("transform"));o=[d[0]*o[0]+d[2]*o[1],d[1]*o[0]+d[3]*o[1],d[0]*o[2]+d[2]*o[3],d[1]*o[2]+d[3]*o[3],d[0]*o[4]+d[2]*o[5]+d[4],d[1]*o[4]+d[3]*o[5]+d[5]]}const a=Ui(o);if(!a)return null;const h=l((_,d)=>({x:a[0]*_+a[2]*d+a[4],y:a[1]*_+a[3]*d+a[5]}),"map"),g=h(r.left,r.top),f=h(r.right,r.bottom);return{left:Math.min(g.x,f.x),right:Math.max(g.x,f.x),top:Math.min(g.y,f.y),bottom:Math.max(g.y,f.y)}}bbox(){const t=this.svg_element;if(typeof t.getBBox!="function")return Bi(t);try{const e=t.getBBox();return e.width>0?e:null}catch{return null}}fitInside(t,e,s,i,n){const r=this.visibleBounds();let o=this.bbox();if(!r||!o)return;const a=r.left+n,h=r.right-n,g=r.top+n,f=r.bottom-n,m=l(b=>Math.max(0,a-b.x)+Math.max(0,b.x+b.width-h),"over"),_=this.svg_element;if(m(o)>0&&this.position===G.POSITION.OBJECT&&s!=="middle"){const b=s==="end"?"start":"end",p=s==="end"?this.point.x+i:this.point.x-i;_.setAttribute("text-anchor",b),_.setAttribute("x",p.toString());const w=this.bbox();w&&m(w)<m(o)?(o=w,t=p):(_.setAttribute("text-anchor",s),_.setAttribute("x",t.toString()))}let d=0,u=0;o.x<a?d=a-o.x:o.x+o.width>h&&(d=Math.max(h-(o.x+o.width),a-o.x)),o.y<g?u=g-o.y:o.y+o.height>f&&(u=Math.max(f-(o.y+o.height),g-o.y)),d&&_.setAttribute("x",(t+d).toString()),u&&_.setAttribute("y",(e+u).toString())}show(){this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()}hide(){this.pinned||this._hostPinned||(this._visible=!1,this.svg_element.setAttribute("display","none"))}toggle(){this._visible?this.hide():this.show()}get visible(){return this._visible}remove(){this.svg_element.remove()}};l(si,"QELabel");let Ps=si;const ds=class ds extends St{};l(ds,"QENodesElement"),ds.tagName="qe-nodes";let Ee=ds;const gs=class gs extends St{};l(gs,"QENodeElement"),gs.tagName="qe-node";let Ne=gs;const fs=class fs extends St{};l(fs,"QEMeansElement"),fs.tagName="qe-means";let Me=fs;const ms=class ms extends St{};l(ms,"QEPointsElement"),ms.tagName="qe-points";let ke=ms;const ps=class ps extends St{};l(ps,"QEEdgesElement"),ps.tagName="qe-edges";let Ie=ps;const bs=class bs extends St{};l(bs,"QEEdgeElement"),bs.tagName="qe-edge";let Ce=bs;const ys=class ys extends St{};l(ys,"QETrajectoriesElement"),ys.tagName="qe-trajectories";let ze=ys;const xs=class xs extends St{};l(xs,"QEAxesElement"),xs.tagName="qe-axes";let Oe=xs;Et(Ee.tagName,Ee),Et(Ne.tagName,Ne),Et(Me.tagName,Me),Et(ke.tagName,ke),Et(Ie.tagName,Ie),Et(Ce.tagName,Ce),Et(ze.tagName,ze),Et(Oe.tagName,Oe);const Ni=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function un(c,t){for(const e of t)if(c===`${e}.${e}`)return[e,e];for(const e of t)if(c.startsWith(e+".")){const s=c.slice(e.length+1);if(t.includes(s))return[e,s]}return null}l(un,"parseEdgePair");function _n(c,t,e,s){const i=Math.max(1,e-1),n=i>=120?1.96:i>=60?2:i>=30?2.042:i>=20?2.086:i>=10?2.228:i>=5?2.571:4.303,r=Math.sqrt(Math.max(0,c)/e)*s,o=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*o}}l(_n,"computeCIRect");const dn=.5;function is(c,t,e){if(!c)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(c.meta={...c.meta??{},maxRadius:s*dn})}l(is,"capMeanToInterval");function ns(c,t,e,s=""){const i=l(h=>{const g=c.names.indexOf(h),f=g>=0?c[g]:null;if(f==null||f==="")return;const m=Number(f);return Number.isFinite(m)?m:void 0},"get"),n=i(`${t}.${s}low`)??i(`${t}_${s}low`),r=i(`${t}.${s}high`)??i(`${t}_${s}high`),o=i(`${e}.${s}low`)??i(`${e}_${s}low`),a=i(`${e}.${s}high`)??i(`${e}_${s}high`);return n==null||r==null||o==null||a==null?null:{x_low:n,x_high:r,y_low:o,y_high:a}}l(ns,"readIntervalBounds");function rs(c,t){const e=l(h=>{if(!c)return;const g=c.names.indexOf(h);return g>=0?c[g]:void 0},"raw"),s=l(h=>h==null||h==="NA"||typeof h=="number"&&Number.isNaN(h),"isNA"),i=e("label"),n=s(i)?t:String(i)===""?null:String(i),r=l(h=>{const g=e(h),f=s(g)||g===""?0:Number(g);return Number.isFinite(f)?f:0},"num"),o=!!c&&(c.names.includes("label.dx")||c.names.includes("label.dy")),a=e("label.pinned");return{text:n,offset:o?{x:r("label.dx"),y:r("label.dy")}:null,pinned:a===!0||a===1||String(a).toLowerCase()==="true"}}l(rs,"readLabelSpec");function gn(c){const t=c==null?void 0:c.trim().toLowerCase();if(!t)return null;if(t==="node")return .5;const e=Number(t);return Number.isFinite(e)&&e>0?e:null}l(gn,"parseSelfSize");function Mi(c,t,e){return c?[...c.children].filter(s=>s.tagName.toLowerCase()===t).map(s=>Object.fromEntries(["color",...e].map(i=>[i,s.getAttribute(i)??""]))).filter(s=>s.color&&e.every(i=>s[i])):[]}l(Mi,"childColors");function fn(c){var i,n;const t=l(r=>c.getAttribute(r),"a"),e=((i=t("colors"))==null?void 0:i.split(",").map(r=>r.trim()).filter(Boolean))??[],s=((n=t("threshold"))==null?void 0:n.split(",").map(Number).filter(Number.isFinite))??[];return{group:t("group"),unit:t("unit"),compare:t("compare"),also:t("also"),network:t("network"),colors:e.length?[e[0],e[1]??null]:null,threshold:s.length?[s[0],s.length>1?s[1]:1/0]:null,name:t("name"),selfSize:gn(t("self-size")),fixedSize:c.hasAttribute("fixed-size"),edgeColors:Mi(c,"qe-edge",["source","target"])}}l(fn,"parseEdgeLayer");function mn(c){const{r:t,g:e,b:s}=rt.parseColor(c),i=Math.max(t,e,s),n=Math.min(t,e,s),r=l(o=>(i+n-o).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}l(mn,"complementColor");function pn(c){const t=c==null?void 0:c.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}l(pn,"parseColorScale");function os(c,t){switch(c==null?void 0:c.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}l(os,"parseLabelMode");const at=class at extends Qe{constructor(t,e){super(t),this.zoom_level=1,this.__children__=new Dt,this._hasModel=!1,this._renderPending=!1,this._childObserver=null,this._ciRects=new Map,this._outlierRects=new Map,this._ciCross=new Map,this._labelsGroup=null,this._nodeLabels=new Map,this._meanLabels=new Map,this._pointLabels=new Map,this._setLabels=new Map,this._showAxes=!1,this._axisXText=null,this._axisYText=null,this._axisLabelEls=new Map,this._magnifyText=null,this._magnifyEl=null,this._rangeExtent=null,this._rangeMode=null,this._centerContent=!1,this._edgesFixedSize=!1,this._meansFixedSize=!1,this._intervalBase=new WeakMap,this._axesFixedSize=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._host=this,this._zoomAnim=null,this._animateMs=0,this._tweenRaf=null,this._tween=null,this._tweenView=null,this._highlight={edges:new Set,nodes:new Set},this._highlightGroup=null,this._tooltipEl=null,this._headless=ui(this.doc),e&&(this._host=e),this.graph=this,this.parent=null,this.__data__=new Je(di),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),Jt("Created qe-graph svg element: ",this.svg_element),typeof document<"u"&&!this._headless&&document.addEventListener("model-updated",s=>{var r;const i=((r=s.composedPath)==null?void 0:r.call(s)[0])??s.target;if(this._vizena&&i!==this._vizena)return;const n=s.detail;n&&this.renderModel(n)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","view-padding","labels","label-nodes","label-means","label-points"]}get vizena(){return this._vizena}_viewPadding(){const t=Number(this._host.getAttribute("view-padding"));return this._host.hasAttribute("view-padding")&&Number.isFinite(t)&&t>0?t:1.2}unitsPerPixel(){var i,n;const t=this.__data__.extremes.x_max||1,e=(n=(i=this.svg_element)==null?void 0:i.getBoundingClientRect)==null?void 0:n.call(i),s=this.zoom_level||1;return e&&e.width>0?2*t/e.width/s:t*.004}renderModel(t){var e,s,i,n,r,o,a,h,g,f,m,_,d,u,b,p;{this._renderPending=!1,(e=this._childObserver)==null||e.takeRecords(),this._animateMs=this._host.hasAttribute("animate")?parseInt(this._host.getAttribute("animate")||"",10)||300:0;const w=this._animateMs>0&&this._hasModel?this._captureTweenState():null;this._stopTween(),this._hasModel=!0;const I=t.dimensions,j=t.unit_id_col,Y=t.node_id_col,st=t.group_col,A=this._readLayerConfig();this._showAxes=A.showAxes,this._axisXText=A.axisXLabel===null?null:A.axisXLabel||String((I==null?void 0:I[0])??"x"),this._magnifyText=A.edgeMagnify==null?null:`(scaled ${A.edgeMagnify.toFixed(1)}x)`,this._axisYText=A.axisYLabel===null?null:A.axisYLabel||String((I==null?void 0:I[1])??"y");const U={},nt=(s=t.palette)!=null&&s.length?t.palette:Ni;if(st&&((i=t.points)!=null&&i.names)){const C=t.points.col(st);C&&[...new Set([...C].map(String))].forEach(($,M)=>{U[$]=nt[M%nt.length]})}(n=t.groups)!=null&&n.rows&&t.groups.rows().length>0&&t.groups.rows().forEach(C=>{const z=C.rowName??String(C[0]),$=C.names.indexOf("color"),M=$>=0?C[$]:null;M&&String(M)!=="NA"?U[z]=String(M):U[z]||(U[z]=nt[Object.keys(U).length%nt.length])});const Mt=Object.keys(U),Lt=A.activeMeanGroups&&A.activeMeanGroups.trim()?new Set(A.activeMeanGroups.split(",").map(C=>C.trim()).filter(C=>U[C])):new Set(Mt),ws=A.scalePoints,vs=l(C=>{let z=0;return C.forEach($=>{const M=$.names.indexOf(I[0]),N=I.length>1?$.names.indexOf(I[1]):-1;M>=0&&(z=Math.max(z,Math.abs(Number($[M])))),N>=0&&(z=Math.max(z,Math.abs(Number($[N]))))}),z},"getExtent"),Bt=(r=t.nodes)!=null&&r.rows?vs(t.nodes.rows()):0,ue=(o=t.points)!=null&&o.rows?vs(t.points.rows()):0,wn=(a=t.trajectories)!=null&&a.rows?vs(t.trajectories.rows()):0,ii=ue>0?ue:wn,q=A.pointScale!==null?A.pointScale:ws&&ii>0&&Bt>0?Bt/ii:1;this._rangeExtent=A.range==="network"?Bt*1.2:A.range==="points"?ii*q*1.2:typeof A.range=="number"?A.range:null,this._rangeMode=A.range==="network"||A.range==="points"?A.range:typeof A.range=="number"?"number":null,this._centerContent=A.centerContent,this._edgesFixedSize=A.edgeLayers.some(C=>C.fixedSize),this._meansFixedSize=A.meanFixedSize,this._axesFixedSize=A.axesFixedSize,this._plotTitle=A.plotTitle,this._labelFont=A.labelFont;const vn=A.labelNodes,An=A.labelMeans,Ci=A.labelPoints,Ht=this._labelsGroup,ni=l((C,z,$,M=1)=>{const N=C.names.indexOf(z),y=C.names.indexOf(I[0]),L=I.length>1?C.names.indexOf(I[1]):-1,v=new it({ID:N>=0?String(C[N]):C.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[y>=0?Number(C[y])*M:0,L>=0?-Number(C[L])*M:0],meta:{}});return $&&(v.color=new rt($)),v},"rowToPoint"),pt={},Sn=A.showPoints;["points","nodes","edges","edgenodes"].map(C=>this.__children__.search("__children__",C)).filter(C=>!!C).forEach(C=>C.__data__.objects.clear()),this.__data__.points.clear();const As=t.pointsets,ri=[];if(A.pointSets.length&&(As!=null&&As.rows)){const C=this.__children__.search("__children__","points"),z=l(($,M)=>{const N=$.names.indexOf(M);return N>=0?$[N]:null},"col");A.pointSets.forEach(($,M)=>{As.rows().forEach(N=>{if(String(z(N,"set"))!==$.set)return;const y=String(z(N,"id")),L=z(N,"group")!=null&&String(z(N,"group"))!=="NA"?String(z(N,"group")):null,v=z(N,"color")&&String(z(N,"color"))!=="NA"?String(z(N,"color")):L&&U[L]?U[L]:nt[M%nt.length],k=ni(N,"id",v,q);k.ID=`${$.set}::${y}`,k.size=$.size??A.pointSize??2.5;const F=z(N,"shape");F&&String(F)!=="NA"&&(k.shape=String(F));const Z=z(N,"label");k.meta={stroke:"#ffffff",kind:"point",name:Z!=null&&String(Z)!=="NA"?String(Z):y,group:L??void 0,unit:y,set:$.set,fixedSize:$.fixedSize},this.__data__.points.set(k.ID,k),C==null||C.__data__.objects.set(k.ID,k),ri.push({pt:k,spec:rs(N,y),mode:$.labelMode,weight:$.labelWeight})})})}if(Ht){const C=new Set(ri.map(z=>z.pt.ID));this._setLabels.forEach((z,$)=>{C.has($)||(z.remove(),this._setLabels.delete($))}),ri.forEach(z=>this._syncLabel(this._setLabels,z.pt.ID,z.spec,z.pt,Ht,z.mode,z.weight))}if((h=t.points)!=null&&h.rows){const C=this.__children__.search("__children__","points");if(C){t.points.rows().forEach(M=>{const N=st?M.names.indexOf(st):-1,y=N>=0?String(M[N]):null,L=y?U[y]??"#888888":"#888888";if(Sn){const v=ni(M,j,L,q);v.size=A.pointSize??2.5,v.meta={...v.meta??{},stroke:"#ffffff",kind:"point",name:v.ID,group:y??void 0,unit:v.ID,fixedSize:A.pointFixedSize},this.__data__.points.set(v.ID,v),C.__data__.objects.set(v.ID,v)}if(y){const v=M.names.indexOf(I[0]),k=I.length>1?M.names.indexOf(I[1]):-1;pt[y]||(pt[y]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:L});const F=v>=0?Number(M[v]):0,Z=k>=0?Number(M[k]):0;pt[y].x+=F,pt[y].y+=Z,pt[y].x2+=F*F,pt[y].y2+=Z*Z,pt[y].xy+=F*Z,pt[y].n+=1}});const z=!!((g=t.groups)!=null&&g.rows&&t.groups.rows().length>0),$=A.showMeans&&z?t.groups.rows().filter(M=>{const N=M.rowName??String(M[0]);return Lt.size===0||Lt.has(N)}):[];if(A.showMeans){const M=C.svg_element,N=this._rangeExtent?this._rangeExtent/1.2:Bt,y=(N>0?N:1)*.008;if(z){const L=new Set($.map(v=>v.rowName??String(v[0])));this._ciRects.forEach((v,k)=>{L.has(k)||(v.remove(),this._ciRects.delete(k))}),this._outlierRects.forEach((v,k)=>{L.has(k)||(v.remove(),this._outlierRects.delete(k))}),this._ciCross.forEach((v,k)=>{L.has(k.slice(2))||(v.remove(),this._ciCross.delete(k))}),$.forEach(v=>{var Es,ge,Zt;const k=v.rowName??String(v[0]),F=U[k]??"#888888",Z=v.names.indexOf(I[0]),X=I.length>1?v.names.indexOf(I[1]):-1,J=Z>=0?Number(v[Z])*q:0,vt=X>=0?-Number(v[X])*q:0,tt=new it({ID:`mean-${k}`,dimensions:[J,vt],meta:{kind:"mean",name:k,group:k,fixedSize:A.meanFixedSize}});tt.color=new rt(F),tt.size=4;const gt=v.names.indexOf("shape"),T=gt>=0?v[gt]:null;tt.shape=T&&String(T)!=="NA"?String(T):"rect",this.__data__.points.set(tt.ID,tt),C.__data__.objects.set(tt.ID,tt);const _e=l(B=>{const x=v.names.indexOf(B),S=x>=0?v[x]:null;return S==null||String(S)==="NA"||String(S)===""?null:S},"cell"),bt=_e("intervals"),Rt=bt==="box"||bt==="crosshairs"||bt==="none"?bt:A.intervals,Vt=_e("outlier"),W=(Vt==null?A.showOutlier:Vt===!0||String(Vt)==="true")?ns(v,I[0],I[1],"o"):null;if(!W)(Es=this._outlierRects.get(k))==null||Es.remove(),this._outlierRects.delete(k);else{let B=this._outlierRects.get(k);B||(B=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),B.setAttribute("data-outlier-group",k),this._outlierRects.set(k,B)),B.setAttribute("x",(W.x_low*q).toString()),B.setAttribute("y",(-W.y_high*q).toString()),B.setAttribute("width",((W.x_high-W.x_low)*q).toString()),B.setAttribute("height",((W.y_high-W.y_low)*q).toString()),B.setAttribute("fill","none"),B.setAttribute("stroke",F),B.setAttribute("stroke-width",y.toString()),B.setAttribute("stroke-opacity","0.5"),B.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(B,y,[y*2,y*2]),M&&!B.parentElement&&M.insertBefore(B,M.firstChild)}const _t=Rt!=="none"?ns(v,I[0],I[1]):null,de=`x:${k}`;if((!_t||Rt!=="crosshairs")&&((ge=this._ciCross.get(de))==null||ge.remove(),this._ciCross.delete(de)),_t&&Rt==="crosshairs"){(Zt=this._ciRects.get(k))==null||Zt.remove(),this._ciRects.delete(k);const B=_t.x_low*q,x=_t.x_high*q,S=-_t.y_high*q,P=-_t.y_low*q;is(tt,(x-B)/2,(P-S)/2);let E=this._ciCross.get(de);E||(E=this.doc.createElementNS("http://www.w3.org/2000/svg","path"),E.setAttribute("data-ci-group",k),E.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(de,E)),E.setAttribute("d",`M${B} ${vt} L${x} ${vt} M${J} ${S} L${J} ${P}`),E.setAttribute("fill","none"),E.setAttribute("stroke",F),E.setAttribute("stroke-width",(y*1.25).toString()),this._intervalStroke(E,y*1.25,null),E.setAttribute("stroke-opacity","0.8"),M&&!E.parentElement&&M.insertBefore(E,M.firstChild)}else if(_t){const B=_t.x_low*q,x=-_t.y_high*q,S=(_t.x_high-_t.x_low)*q,P=(_t.y_high-_t.y_low)*q;is(tt,S/2,P/2);let E=this._ciRects.get(k);E||(E=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),E.setAttribute("data-ci-group",k),this._ciRects.set(k,E)),E.setAttribute("x",B.toString()),E.setAttribute("y",x.toString()),E.setAttribute("width",S.toString()),E.setAttribute("height",P.toString()),E.setAttribute("fill","none"),E.setAttribute("stroke",F),E.setAttribute("stroke-width",y.toString()),E.setAttribute("stroke-opacity","0.8"),E.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(E,y,[y*4,y*3]),M&&!E.parentElement&&M.insertBefore(E,M.firstChild)}else{const B=this._ciRects.get(k);B&&(B.remove(),this._ciRects.delete(k))}})}else this._removeIntervals(this._ciCross),Object.entries(pt).forEach(([v,{x:k,y:F,n:Z,color:X}])=>{const J=new it({ID:`mean-${v}`,dimensions:[k/Z*q,-(F/Z)*q],meta:{kind:"mean",name:v,group:v,fixedSize:A.meanFixedSize}});J.color=new rt(X),J.size=4,J.shape="rect",this.__data__.points.set(J.ID,J),C.__data__.objects.set(J.ID,J)}),A.showCI?(this._ciRects.forEach((v,k)=>{pt[k]||(v.remove(),this._ciRects.delete(k))}),(f=t.confidence)!=null&&f.rows?t.confidence.rows().forEach(v=>{const k=v.names.indexOf(st??"group"),F=k>=0?String(v[k]):v.rowName??null;if(!F)return;const Z=U[F]??"#888888",X=ns(v,I[0],I[1]);if(!X)return;const J=X.x_low*q,vt=-X.y_high*q,tt=(X.x_high-X.x_low)*q,gt=(X.y_high-X.y_low)*q;is(this.__data__.points.get(`mean-${F}`),tt/2,gt/2);let T=this._ciRects.get(F);T||(T=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-ci-group",F),this._ciRects.set(F,T)),T.setAttribute("x",J.toString()),T.setAttribute("y",vt.toString()),T.setAttribute("width",tt.toString()),T.setAttribute("height",gt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",Z),T.setAttribute("stroke-width",y.toString()),T.setAttribute("stroke-opacity","0.8"),T.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(T,y,[y*4,y*3]),M&&!T.parentElement&&M.insertBefore(T,M.firstChild)}):Object.entries(pt).forEach(([v,{x:k,y:F,x2:Z,y2:X,n:J,color:vt}])=>{if(J<2)return;const tt=k/J,gt=F/J,T=Z/J-tt*tt,_e=X/J-gt*gt,{halfW:bt,halfH:Rt}=_n(T,_e,J,q),Vt=tt*q,Ue=-gt*q;is(this.__data__.points.get(`mean-${v}`),bt,Rt);let W=this._ciRects.get(v);W||(W=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),W.setAttribute("data-ci-group",v),this._ciRects.set(v,W)),W.setAttribute("x",(Vt-bt).toString()),W.setAttribute("y",(Ue-Rt).toString()),W.setAttribute("width",(bt*2).toString()),W.setAttribute("height",(Rt*2).toString()),W.setAttribute("fill","none"),W.setAttribute("stroke",vt),W.setAttribute("stroke-width",y.toString()),W.setAttribute("stroke-opacity","0.8"),W.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(W,y,[y*4,y*3]),M&&!W.parentElement&&M.insertBefore(W,M.firstChild)})):this._removeIntervals(this._ciRects),(m=t.outlier)!=null&&m.rows?(this._outlierRects.forEach((v,k)=>{U[k]||(v.remove(),this._outlierRects.delete(k))}),t.outlier.rows().forEach(v=>{const k=v.names.indexOf(st??"group"),F=k>=0?String(v[k]):v.rowName??null;if(!F)return;const Z=U[F]??"#888888",X=ns(v,I[0],I[1]);if(!X)return;const J=X.x_low*q,vt=-X.y_high*q,tt=(X.x_high-X.x_low)*q,gt=(X.y_high-X.y_low)*q;let T=this._outlierRects.get(F);T||(T=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-outlier-group",F),this._outlierRects.set(F,T)),T.setAttribute("x",J.toString()),T.setAttribute("y",vt.toString()),T.setAttribute("width",tt.toString()),T.setAttribute("height",gt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",Z),T.setAttribute("stroke-width",y.toString()),T.setAttribute("stroke-opacity","0.5"),T.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(T,y,[y*2,y*2]),M&&!T.parentElement&&M.insertBefore(T,M.firstChild)})):this._removeIntervals(this._outlierRects)}else[this._ciRects,this._outlierRects,this._ciCross].forEach(M=>this._removeIntervals(M));if(Ht){this._pointLabels.forEach((y,L)=>{C.__data__.objects.get(L)||(y.remove(),this._pointLabels.delete(L))}),this._meanLabels.forEach((y,L)=>{C.__data__.objects.get(`mean-${L}`)||(y.remove(),this._meanLabels.delete(L))}),Ci!==0?t.points.rows().forEach(y=>{const L=y.names.indexOf(j),v=L>=0?String(y[L]):null;if(!v)return;const k=C.__data__.objects.get(v);k&&this._syncLabel(this._pointLabels,v,rs(null,v),k,Ht,Ci,A.labelWeightPoints)}):this._clearLabels(this._pointLabels);const M=new Map($.map(y=>[y.rowName??String(y[0]),y]));(z?[...M.keys()]:Object.keys(pt)).forEach(y=>{const L=`mean-${y}`,v=C.__data__.objects.get(L);v&&this._syncLabel(this._meanLabels,y,rs(M.get(y),y),v,Ht,An,A.labelWeightMeans)})}C.__data__.__state__.setVariable("layer_updated",C.__data__)}}else{const C=this.__children__.search("__children__","points");C==null||C.__data__.__state__.setVariable("layer_updated",C.__data__)}const Ge=this.__children__.search("__children__","trajectories");if(A.showTrajectories&&Ge){Ge.__data__.objects.clear(),this.__data__.trajectories.clear();const C=(_=t.trajectories)!=null&&_.rows?t.trajectories:t.points;if(C!=null&&C.rows){const z={},$=A.trajectoryUnits?A.trajectoryUnits.split(",").map(N=>N.trim()):null;C.rows().forEach(N=>{const y=N.names.indexOf(j)>=0?N.names.indexOf(j):N.names.indexOf("unit")>=0?N.names.indexOf("unit"):N.names.indexOf("ENA_UNIT")>=0?N.names.indexOf("ENA_UNIT"):-1,L=y>=0?String(N[y]):N.rowName||"unit-1";if($&&!$.includes(L))return;const v=N.names.indexOf(I[0]),k=I.length>1?N.names.indexOf(I[1]):-1,F=N.names.indexOf("time")>=0?N.names.indexOf("time"):N.names.indexOf("ActivityNumber")>=0?N.names.indexOf("ActivityNumber"):N.names.indexOf("RowID")>=0?N.names.indexOf("RowID"):-1,Z=F>=0?Number(N[F]):z[L]?z[L].length+1:1;v>=0&&k>=0&&(z[L]||(z[L]=[]),z[L].push({x:Number(N[v])*q,y:-Number(N[k])*q,time:Z}))}),Object.keys(z).forEach((N,y)=>{const L=z[N];if(L.length===0)return;const v=nt[y%nt.length],k=new we({ID:`traj-${N}`,unitId:N,color:new rt(v),lineStyle:A.trajectoryLineStyle,strokeWidth:A.trajectoryStrokeWidth,strokeWidthRange:A.trajectoryStrokeWidthRange,opacityRange:A.trajectoryOpacityRange,smooth:A.trajectorySmooth,maxDegree:A.trajectoryMaxDegree,degreeSelection:A.trajectoryDegreeSelection,currentTime:A.trajectoryPlayhead??1/0,showPoints:A.trajectoryShowPoints,showTips:A.trajectoryShowTips,points:L.map(F=>({x:F.x,y:F.y,time:F.time}))});this.__data__.trajectories.set(N,k),Ge.__data__.objects.set(k.ID,k)})}Ge.__data__.__state__.setVariable("layer_updated",Ge.__data__)}const Pt=this.__children__.search("__children__","network"),Ss=Pt==null?void 0:Pt.__children__.search("__children__","edges"),ut=Pt==null?void 0:Pt.__children__.search("__children__","nodes"),zi=Pt==null?void 0:Pt.__children__.search("__children__","edgenodes"),En=A.showEdges;if((d=t.nodes)!=null&&d.rows&&ut){if(t.nodes.rows().forEach(z=>{const $=A.nodeColors.get(String(z[z.names.indexOf(Y)])),M=ni(z,Y,$??"#444444");M.size=2;const N=z.names.indexOf("label"),y=N>=0?z[N]:null,L=z.names.indexOf("size"),v=L>=0&&z[L]!=null&&z[L]!==""?Number(z[L]):NaN;M.meta={...M.meta??{},kind:"node",labelColor:$,name:y!=null&&String(y)!=="NA"&&String(y)!==""?String(y):M.ID,sizePx:Number.isFinite(v)&&v>0?v:void 0,zoomFixed:A.nodeFixedSize||void 0},ut.__data__.objects.set(M.ID,M)}),En&&Ss){const z={};st&&((u=t.points)!=null&&u.rows)&&t.points.rows().forEach(x=>{const S=x.names.indexOf(j),P=x.names.indexOf(st);S>=0&&P>=0&&(z[String(x[S])]=String(x[P]))});const $=t.nodes.rows().map(x=>{const S=x.names.indexOf(Y);return S>=0?String(x[S]):""}).filter(Boolean),M=l(x=>{const S=[];return x.forEach(P=>{const E=un(P,$);E&&S.push({col:P,pair:E})}),S},"parsePairs"),N=(b=t.edges)!=null&&b.rows?t.edges.rows():[],y=t.networks,L=M(((p=t.edges)==null?void 0:p.names)??[]),v=M((y==null?void 0:y.names)??[]),k=l(x=>{const S={};return N.forEach(P=>{const E=P.names.indexOf(j);E<0||String(P[E])!==x||L.forEach(({col:D})=>{const et=P.names.indexOf(D);et>=0&&(S[D]=Number(P[et])||0)})}),S},"getUnitEdges"),F=l(x=>{const S={};let P=0;if(N.forEach(D=>{const et=D.names.indexOf(j),ht=et>=0?String(D[et]):null,Kt=st?D.names.indexOf(st):-1;(Kt>=0?String(D[Kt]):ht?z[ht]:null)===x&&(P++,L.forEach(({col:yt})=>{const It=D.names.indexOf(yt);if(It>=0){const At=Number(D[It]);isNaN(At)||(S[yt]=(S[yt]??0)+At)}}))}),P===0)return{};const E={};return L.forEach(({col:D})=>{E[D]=(S[D]??0)/P}),E},"getGroupEdges"),Z=l(x=>{if(U[x])return{weights:F(x),color:U[x],label:x};const S=z[x]??null,P=S?U[S]??"#888888":"#888888";return{weights:k(x),color:P,label:x}},"resolve"),X=[],J=l(x=>{var E;const S=(E=y==null?void 0:y.rows)==null?void 0:E.call(y).find(D=>D.rowName===x);if(!S)return null;const P={};return v.forEach(({col:D})=>{const et=S.names.indexOf(D);if(et>=0){const ht=Number(S[et]);Number.isFinite(ht)&&(P[D]=ht)}}),P},"networkRow"),vt=l((x,S)=>{if(!S)return x;const P=Math.abs(x);return P<S[0]?0:P>S[1]?Math.sign(x)*S[1]:x},"thresholded");A.edgeLayers.forEach((x,S)=>{const P=l(K=>{var lt;return(lt=x.edgeColors.find(Q=>Q.source===K[0]&&Q.target===K[1]||!t.directed&&Q.source===K[1]&&Q.target===K[0]))==null?void 0:lt.color},"ownColor"),E=l((K,lt,Q,Ct,ft)=>{if(Q=vt(Q,x.threshold),Math.abs(Q)<1e-6)return;const Xe=P(lt);X.push({col:`${S}:${K}`,pair:lt,weight:Math.abs(Q),color:Xe??Ct,exact:Xe!==void 0,layer:S,...ft})},"push"),D=l((K,lt)=>x.colors?[x.colors[0],x.colors[1]??mn(x.colors[0])]:[K,lt],"signColors");if(x.network){const K=J(x.network);if(!K)return;const[lt,Q]=D(nt[0],nt[1]),Ct={name:x.name??x.network};v.forEach(({col:ft,pair:Xe})=>{const We=K[ft]??0;E(ft,Xe,We,We>=0?lt:Q,Ct)});return}const et=x.unit??x.group??null;if(!et)return;const ht=Z(et),Kt=x.compare??x.also??null,kt=Kt?Z(Kt):null,yt={name:x.name??et,group:x.group??void 0,unit:x.unit??void 0},[It,At]=D(ht.color,(kt==null?void 0:kt.color)??ht.color);kt&&x.compare?L.forEach(({col:K,pair:lt})=>{const Q=(ht.weights[K]??0)-(kt.weights[K]??0);E(K,lt,Q,Q>0?It:At,yt)}):kt&&x.also?L.forEach(({col:K,pair:lt})=>{const Q=ht.weights[K]??0,Ct=kt.weights[K]??0;Q>0&&E(K+"-a",lt,Q,It,yt),Ct>0&&E(K+"-b",lt,Ct,At,{...yt,name:x.also??void 0,group:x.also??void 0})}):L.forEach(({col:K,pair:lt})=>{const Q=ht.weights[K]??0;Q>0&&E(K,lt,Q,It,yt)})}),X.sort((x,S)=>S.weight-x.weight);const tt=!!t.directed,gt=on(A.edgeWidth)*(A.edgeMagnify??1),T=l(x=>{const S=x.map(Math.abs).filter(P=>P>0);return S.length?[Math.min(...S),Math.max(...S)]:[0,0]},"rangeOf"),[_e,bt]=N.length?[L,t.edges]:[v,y],Rt=l(x=>{const S=[];return _e.forEach(({col:P,pair:E})=>{if(E[0]===E[1]!==x)return;const D=bt==null?void 0:bt.col(P);if(D)for(const et of D)S.push(Number(et))}),T(S)},"modelRange"),Vt=l(x=>T(X.filter(S=>S.pair[0]===S.pair[1]===x).map(S=>S.weight)),"plotRange"),Ue=A.edgeColorScale,W=l(x=>Ue==="plot"?Vt(x):Rt(x),"colourRange"),_t=W(!1),de=W(!0),Es=l((x,S)=>{if(Ue==="absolute"){const D=Math.min(1,Math.abs(x));return{saturation:D,opacity:D}}const[P,E]=S?de:_t;return{saturation:Ai(x,P,E,Ji),opacity:Ai(x,P,E,Qi)}},"colourOf"),ge={};X.forEach(({pair:x,weight:S})=>{const P=x[0]===x[1],E=l(D=>{ge[D]=(ge[D]??0)+Math.abs(S)},"add");if(tt||P){E(x[1]);return}E(x[0]),E(x[1])}),t.nodes.rows().forEach(x=>{var ht;const S=x.names.indexOf(Y),P=S>=0?String(x[S]):"";if(!P)return;const E=ut.__data__.objects.get(P);if(!E)return;const D=ge[P]??0,et=!(D>0);E.size=et?A.hideUnconnectedNodes?0:rn:an(D,gt),E.meta={...E.meta??{},hidden:et&&A.hideUnconnectedNodes,sizePx:et||(ht=E.meta)==null?void 0:ht.sizePx}});const Zt={},B=l((x,S,P,E)=>`${x}:${S??""}:${P}.${E}`,"pairKey");tt&&X.forEach(({pair:x,weight:S,layer:P,name:E})=>{const D=B(P,E,x[0],x[1]);Zt[D]=(Zt[D]??0)+S}),X.forEach(({col:x,pair:S,weight:P,color:E,exact:D,layer:et,name:ht,group:Kt,unit:kt})=>{var We,Pi;const yt=ut.__data__.objects.get(S[0]),It=ut.__data__.objects.get(S[1]);if(!yt||!It)return;const At=S[0]===S[1],{saturation:K,opacity:lt}=Es(P,At),Q=new it({ID:`${S[0]}-src`,dimensions:[yt.x,yt.y],meta:{}}),Ct=new it({ID:`${S[1]}-dst`,dimensions:[It.x,It.y],meta:{}});let ft;if(At)ft=new ie({},Q,Ct),ft.weight=0;else if(tt){const Nn=Zt[B(et,ht,S[0],S[1])]??P,Mn=Zt[B(et,ht,S[1],S[0])]??0,kn=Nn+Mn;ft=new Ls({weight:P,totalweight:kn},Q,Ct)}else ft=new se({},Q,Ct);ft.ID=`edge-${x}`,ft.color=new rt(E),ft.meta={isMeanEdge:!0,weight:P,widthFrac:gt,saturation:K,opacity:lt,exactColor:D||void 0,isDirected:tt,isSelf:At,source:S[0],target:S[1],group:Kt,unit:kt,layer:ht,selfSize:At?((We=A.edgeLayers[et])==null?void 0:We.selfSize)??void 0:void 0,fixedSize:((Pi=A.edgeLayers[et])==null?void 0:Pi.fixedSize)||void 0},(At?zi??Ss:Ss).__data__.objects.set(ft.ID,ft)})}const C=A.showNodes;ut.svg_element&&(ut.svg_element.style.display=C?"":"none"),C||this._clearLabels(this._nodeLabels),Ht&&C&&(this._nodeLabels.forEach((z,$)=>{ut.__data__.objects.get($)||(z.remove(),this._nodeLabels.delete($))}),t.nodes.rows().forEach(z=>{var y,L,v;const $=z.names.indexOf(Y),M=$>=0?String(z[$]):"";if(!M)return;const N=ut.__data__.objects.get(M);if(N){if((y=N.meta)!=null&&y.hidden){(L=this._nodeLabels.get(M))==null||L.remove(),this._nodeLabels.delete(M);return}this._syncLabel(this._nodeLabels,M,rs(z,String(((v=N.meta)==null?void 0:v.name)??M)),N,Ht,vn,A.labelWeightNodes)}})),ut.__data__.__state__.setVariable("layer_updated",ut.__data__)}else ut==null||ut.__data__.__state__.setVariable("layer_updated",ut.__data__);[Ss,zi].forEach(C=>C==null?void 0:C.__data__.__state__.setVariable("layer_updated",C.__data__));const Oi=this.__children__.search("__children__","axis_points"),Li=this.__children__.search("__children__","axis_lines");Oi&&this.__data__.__state__.setVariable("graph_updated_axis_points",Oi.__data__.objects),Li&&this.__data__.__state__.setVariable("graph_updated_axis_lines",Li.__data__.objects),this.update(),w&&this._startTween(w)}}_syncLabel(t,e,s,i,n,r,o){let a=t.get(e);const h=s.text!=null&&(r!==G.DISPLAY_TYPES.OFF||s.pinned);a&&(!h||a.text!==s.text||a.displayMode!==r)&&(a.remove(),t.delete(e),a=void 0),h&&(a?(a.setPoint(i),r===G.DISPLAY_TYPES.ON&&a.show()):(a=new Ps(s.text,i,n,this,r),t.set(e,a)),s.offset&&a.setOffset(s.offset.x,s.offset.y),a.fontWeight=o,a.setHostPinned(s.pinned))}_nodeRadius(t){const e=this.__children__.search("__children__","nodes"),s=e==null?void 0:e.__children__.find(i=>{var n;return((n=i.__data__)==null?void 0:n.ID)===t});return s?s.computeRadius():null}_intervalStroke(t,e,s){this._intervalBase.set(t,{w:e,dash:s}),this._applyIntervalStroke(t)}_applyIntervalStroke(t){const e=this._intervalBase.get(t);if(!e)return;const s=this._meansFixedSize&&this.zoom_level||1;t.setAttribute("stroke-width",String(e.w/s)),e.dash&&t.setAttribute("stroke-dasharray",e.dash.map(i=>i/s).join(" "))}_removeIntervals(t){t.forEach(e=>e.remove()),t.clear()}_clearLabels(t){t.forEach(e=>e.remove()),t.clear()}_scheduleRerender(){!this._vizena||!this._hasModel||this._renderPending||(this._renderPending=!0,queueMicrotask(()=>{var t;this._renderPending&&(this._renderPending=!1,(t=this._vizena)==null||t.dispatchEvent(new CustomEvent("model-updated",{detail:this._vizena.model,bubbles:!0,composed:!0})))}))}_readLayerConfig(){var m;const t=this._host.querySelector("qe-nodes"),e=this._host.querySelector("qe-means"),s=[...this._host.querySelectorAll("qe-points")],i=s.find(_=>!_.hasAttribute("set"))??null,n=s.filter(_=>_.hasAttribute("set")),r=[...this._host.querySelectorAll("qe-edges")],o=l(_=>{var d;return((d=r.find(u=>u.hasAttribute(_)))==null?void 0:d.getAttribute(_))??null},"firstAttr"),a=r.find(_=>_.hasAttribute("magnify")),h=this._host.querySelector("qe-trajectories"),g=this._host.querySelector("qe-axes"),f=this._host.getAttribute("labels");return{labelNodes:os((t==null?void 0:t.getAttribute("label"))??this._host.getAttribute("label-nodes")??f,G.DISPLAY_TYPES.ON),labelWeightNodes:(t==null?void 0:t.getAttribute("label-font-weight"))||null,nodeFixedSize:!!t&&t.hasAttribute("fixed-size"),showNodes:!!t,nodeColors:new Map(Mi(t,"qe-node",["node"]).map(_=>[_.node,_.color])),range:(()=>{const _=this._host.getAttribute("range");if(_==="network"||_==="points")return _;const d=Number(_);return _!=null&&Number.isFinite(d)&&d>0?d:null})(),plotTitle:this._host.getAttribute("plot-title")||null,labelFont:{size:(()=>{const _=Number(this._host.getAttribute("label-font-size"));return Number.isFinite(_)&&_>0?_:null})(),family:this._host.getAttribute("label-font-family")||null,color:this._host.getAttribute("label-font-color")||null},edgeWidth:(()=>{const _=Number(this._host.getAttribute("edge-width"));return Number.isFinite(_)&&_>0&&_<=1?_:Ki})(),hideUnconnectedNodes:((m=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:m.toLowerCase())==="hide",scalePoints:this._host.getAttribute("scale-points")!=="false",pointScale:(()=>{const _=Number(this._host.getAttribute("point-scale"));return this._host.hasAttribute("point-scale")&&Number.isFinite(_)&&_>0?_:null})(),centerContent:this._host.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const _=e==null?void 0:e.getAttribute("intervals");return _==="box"||_==="crosshairs"||_==="none"?_:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:os((e==null?void 0:e.getAttribute("label"))??this._host.getAttribute("label-means")??f,G.DISPLAY_TYPES.ON),labelWeightMeans:(e==null?void 0:e.getAttribute("label-font-weight"))||null,meanFixedSize:!!e&&e.hasAttribute("fixed-size"),showPoints:!!i,pointSets:n.map(_=>({set:_.getAttribute("set"),size:_.getAttribute("size")?parseFloat(_.getAttribute("size")):null,fixedSize:_.hasAttribute("fixed-size"),labelMode:os(_.getAttribute("label")??this._host.getAttribute("label-points")??f,G.DISPLAY_TYPES.OFF),labelWeight:_.getAttribute("label-font-weight")||null})),labelPoints:os((i==null?void 0:i.getAttribute("label"))??this._host.getAttribute("label-points")??f,G.DISPLAY_TYPES.OFF),labelWeightPoints:(i==null?void 0:i.getAttribute("label-font-weight"))||null,pointSize:i!=null&&i.getAttribute("size")?parseFloat(i.getAttribute("size")):null,pointFixedSize:!!i&&i.hasAttribute("fixed-size"),showEdges:r.length>0,edgeLayers:r.map(fn),edgeColorScale:pn(o("color-scale")),edgeMagnify:a?(()=>{const _=Number(a.getAttribute("magnify"));return Number.isFinite(_)&&_>0?_:1})():null,showTrajectories:!!h,trajectoryUnits:(h==null?void 0:h.getAttribute("units"))??null,trajectorySmooth:(h==null?void 0:h.getAttribute("smooth"))??"none",trajectoryMaxDegree:h!=null&&h.getAttribute("max-degree")?parseInt(h.getAttribute("max-degree"),10):3,trajectoryDegreeSelection:(h==null?void 0:h.getAttribute("degree-selection"))??"loocv_2d",trajectoryShowPoints:(h==null?void 0:h.getAttribute("points"))!=="false",trajectoryShowTips:(h==null?void 0:h.getAttribute("tips"))!=="false",trajectoryPlayhead:h!=null&&h.getAttribute("playhead")?parseFloat(h.getAttribute("playhead")):null,trajectoryLineStyle:(h==null?void 0:h.getAttribute("line-style"))??"uniform",trajectoryStrokeWidth:h!=null&&h.getAttribute("stroke-width")?parseFloat(h.getAttribute("stroke-width")):2,trajectoryStrokeWidthRange:this._parseNumberPair(h==null?void 0:h.getAttribute("stroke-width-range"),[1,6]),trajectoryOpacityRange:this._parseNumberPair(h==null?void 0:h.getAttribute("opacity-range"),[.3,1]),showAxes:!!g,axesFixedSize:!!g&&g.hasAttribute("fixed-size"),axisXLabel:g!=null&&g.hasAttribute("x")?g.getAttribute("x")??"":null,axisYLabel:g!=null&&g.hasAttribute("y")?g.getAttribute("y")??"":null}}_parseNumberPair(t,e){if(!t)return e;const s=t.split(",").map(i=>Number(i.trim()));return s.length<2||!s.every(Number.isFinite)?e:[s[0],s[1]]}attributeChangedCallback(t,e,s){e!==s&&this._scheduleRerender()}connectedCallback(){var i;const t=this._host.getAttribute("width"),e=this._host.getAttribute("height");this.style.display="block",t&&(this.style.width=isNaN(Number(t))?t:`${t}px`),e&&(this.style.height=isNaN(Number(e))?e:`${e}px`),this.appendChild(this.svg_element),at._instances.add(this),this._childObserver=new MutationObserver(()=>this._scheduleRerender()),this._childObserver.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["group","unit","compare","also","color-scale","magnify","network","colors","threshold","name","source","target","node","color","groups","confidence","label","intervals","outlier","set","unconnected","scale-points","point-scale","edge-width","labels","range","center","view-padding","plot-title","label-font-size","label-font-family","label-font-color","label-font-weight","label-nodes","label-means","label-points","self-size","units","smooth","degree","points","tips","playhead","line-style","stroke-width","stroke-width-range","opacity-range","x","y","size","fixed-size"]});const s=this._host.getAttribute("for");this._vizena=(s?document.getElementById(s):null)??this.closest("qe-visual")??((i=this.parentElement)==null?void 0:i.closest("qe-visual"))??document.querySelector("qe-visual"),this.mount()}mount(){this.draw();const t=this.__children__.search("__children__","labels");if(t!=null&&t.svg_element)this._labelsGroup=t.svg_element;else{console.warn("[ena-graph] labels layer not found in layer tree; creating fallback <g>");const e=this.__children__[0];e!=null&&e.svg_element&&(this._labelsGroup=this.doc.createElementNS("http://www.w3.org/2000/svg","g"),this._labelsGroup.setAttribute("data-layer-name","labels-fallback"),e.svg_element.appendChild(this._labelsGroup))}}disconnectedCallback(){var t,e,s;this._stopTween(),(t=this._childObserver)==null||t.disconnect(),this._childObserver=null,(e=this._resizeObs)==null||e.disconnect(),this._resizeObs=null,at._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...at._instances]}static getGraph(t){for(const e of at._instances)if(e.id===t||e.getAttribute("plot-group")===t)return e;return null}getNodes(){const t=this.__children__.search("__children__","nodes");return t?[...t.__data__.objects.values()].map(e=>{var s;return{id:e.ID,name:((s=e.meta)==null?void 0:s.name)??e.ID,x:e.x,y:e.y}}):[]}getEdges(){const t=l(e=>{const s=this.__children__.search("__children__",e);return s?[...s.__data__.objects.values()]:[]},"collect");return[...t("edges"),...t("edgenodes")].map(e=>{const s=e.meta??{};return{source:s.source,target:s.target,weight:s.weight??0,directed:!!s.isDirected,self:!!s.isSelf}}).filter(e=>e.source!=null&&e.target!=null)}_zoomLimits(){const t=l(e=>{const s=Number(this._host.getAttribute(e));return this._host.hasAttribute(e)&&Number.isFinite(s)&&s>0?s:null},"num");return[t("zoom-min")??0,t("zoom-max")??1/0]}_clampZoom(t){const[e,s]=this._zoomLimits();return Math.min(s,Math.max(e,t))}_zoomStep(){const t=Number(this._host.getAttribute("zoom-step"));return this._host.hasAttribute("zoom-step")&&Number.isFinite(t)&&t>0?t:1.1}_clientToRoot(t,e){var n,r;const s=(r=(n=this.svg_element).getScreenCTM)==null?void 0:r.call(n);if(!s)return null;const i=new DOMPoint(t,e).matrixTransform(s.inverse());return[i.x,i.y]}_zoomAbout(t,e,s){if(!(Number.isFinite(t)&&t>0))return;t=this._clampZoom(t);const i=this.__data__.transform,n=t/(this.zoom_level||1);i.e=e-n*(e-i.e),i.f=s-n*(s-i.f),i.zoom(t),this.zoom_level=t,this.update()}_stopZoomAnim(){this._zoomAnim!==null&&cancelAnimationFrame(this._zoomAnim),this._zoomAnim=null}_animateZoomAbout(t,e,s,i){this._stopZoomAnim();const n=this.zoom_level||1,r=this._clampZoom(t);if(r===n)return;const o=performance.now(),a=l(h=>{const g=Math.min(1,Math.max(0,(h-o)/i));this._zoomAbout(g>=1?r:n*Math.pow(r/n,1-Math.pow(1-g,3)),e,s),this._zoomAnim=g<1?requestAnimationFrame(a):null},"step");this._zoomAnim=requestAnimationFrame(a)}zoomTo(t){this._stopZoomAnim();const{cx:e,cy:s}=this.__data__.extremes;this._zoomAbout(t,e,s)}zoomBy(t){Number.isFinite(t)&&t>0&&this.zoomTo((this.zoom_level||1)*t)}resetView(){this._stopZoomAnim();const t=this._clampZoom(1),{cx:e,cy:s}=this.__data__.extremes;this.zoom_level=t,this.__data__.transform.values=t===1?[1,0,0,1,0,0]:[t,0,0,t,e*(1-t),s*(1-t)],this.update()}static _ease(t){return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2}static _setXY(t,e,s){t.x=e,t.y=s,t.dimensions&&(t.dimensions[0]=e,t.dimensions[1]=s)}_layerObjects(t){var e;return(e=this.__children__.search("__children__",t))==null?void 0:e.__data__.objects}_intervalMarks(){return[...this._ciRects.values(),...this._outlierRects.values(),...this._ciCross.values()]}_boxGeom(t){return t.tagName.toLowerCase()==="rect"?["x","y","width","height"].map(e=>parseFloat(t.getAttribute(e)||"0")):((t.getAttribute("d")||"").match(at._PATH_NUM_RE)||[]).map(Number)}_captureTweenState(){var n;const t=new Map;for(const r of["points","nodes"])(n=this._layerObjects(r))==null||n.forEach((o,a)=>t.set(`${r}:${a}`,[o.x,o.y]));const e=new Map;this._intervalMarks().forEach(r=>e.set(r,this._boxGeom(r)));const s=this.__data__.extremes,i=this._tween;return{marks:t,boxes:e,view:[s.x_max,s.y_max,s.cx,s.cy],running:i?{t0:i.t0,k:i.k,marks:new Map(i.marks.map(r=>[r.key,[r.tx,r.ty]])),boxes:new Map(i.boxes.map(r=>[r.el,r.to])),view:i.view.to}:null}}_stopTween(){this._tweenRaf!==null&&cancelAnimationFrame(this._tweenRaf),this._tweenRaf=null,this._tween=null,this._tweenView=null}_startTween(t){var b;const e=performance.now(),s=l((p,w)=>!!w&&p.length===w.length&&p.every((I,j)=>I===w[j]),"same"),i=[];for(const p of["points","nodes"])(b=this._layerObjects(p))==null||b.forEach((w,I)=>{const j=`${p}:${I}`,Y=t.marks.get(j);Y&&i.push({key:j,o:w,tx:w.x,ty:w.y,cx:Y[0],cy:Y[1]})});const n=this._intervalMarks().map(p=>({el:p,to:this._boxGeom(p),cur:t.boxes.get(p)})).filter(p=>p.cur&&p.cur.length===p.to.length),r=this.__data__.extremes,o=[r.x_max,r.y_max,r.cx,r.cy],a=t.running,h=!!a&&a.k<.95&&s(o,a.view)&&i.every(p=>s([p.tx,p.ty],a.marks.get(p.key)??[p.cx,p.cy]))&&n.every(p=>s(p.to,a.boxes.get(p.el)??p.cur)),g=h?a.k:0,f=l((p,w)=>g>0?(p-g*w)/(1-g):p,"from"),m=i.map(p=>({key:p.key,o:p.o,tx:p.tx,ty:p.ty,fx:f(p.cx,p.tx),fy:f(p.cy,p.ty)})).filter(p=>p.fx!==p.tx||p.fy!==p.ty),_=n.map(p=>({el:p.el,to:p.to,from:p.cur.map((w,I)=>f(w,p.to[I])),attrs:Object.fromEntries(["x","y","width","height","d"].filter(w=>p.el.hasAttribute(w)).map(w=>[w,p.el.getAttribute(w)]))})).filter(p=>!s(p.from,p.to)),d=t.view.map((p,w)=>f(p,o[w]));if(!m.length&&!_.length&&s(d,o))return;this._tween={t0:h?a.t0:e,dur:this._animateMs,k:g,marks:m,boxes:_,view:{from:d,to:o}},this._tweenFrame(g);const u=l(p=>{const w=this._tween;if(!w)return;const I=(p-w.t0)/w.dur;if(I>=1){this._endTween();return}this._tweenFrame(Math.max(w.k,at._ease(Math.max(0,I)))),this._tweenRaf=requestAnimationFrame(u)},"step");this._tweenRaf=requestAnimationFrame(u)}_tweenFrame(t){const e=this._tween;if(!e)return;e.k=t;const s=l((i,n)=>i+(n-i)*t,"lerp");e.marks.forEach(i=>at._setXY(i.o,s(i.fx,i.tx),s(i.fy,i.ty))),this._attachEdges(),e.boxes.forEach(i=>{const n=i.from.map((r,o)=>s(r,i.to[o]));if("d"in i.attrs){let r=0;i.el.setAttribute("d",i.attrs.d.replace(at._PATH_NUM_RE,()=>String(n[r++])))}else["x","y","width","height"].forEach((r,o)=>i.el.setAttribute(r,String(n[o])))}),this._tweenView=e.view.from.map((i,n)=>s(i,e.view.to[n])),this.update()}_endTween(){const t=this._tween;t&&(t.marks.forEach(e=>at._setXY(e.o,e.tx,e.ty)),this._attachEdges(),t.boxes.forEach(e=>Object.entries(e.attrs).forEach(([s,i])=>e.el.setAttribute(s,i))),this._stopTween(),this.update())}_attachEdges(){var e;const t=this._layerObjects("nodes");if(t)for(const s of["edges","edgenodes"])(e=this._layerObjects(s))==null||e.forEach(i=>{var o,a;const n=t.get((o=i.meta)==null?void 0:o.source),r=t.get((a=i.meta)==null?void 0:a.target);n&&i.from&&at._setXY(i.from,n.x,n.y),r&&i.to&&at._setXY(i.to,r.x,r.y)})}toSVG(){const t=this.svg_element.cloneNode(!0);t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");const e=this.svg_element.getBoundingClientRect();return e.width&&t.setAttribute("width",String(Math.round(e.width))),e.height&&t.setAttribute("height",String(Math.round(e.height))),typeof XMLSerializer<"u"&&!this._headless?new XMLSerializer().serializeToString(t):Ze(t)}toPNG(t=2){const e=this.toSVG(),s=this.svg_element.getBoundingClientRect(),i=Math.max(1,Math.round(s.width)),n=Math.max(1,Math.round(s.height));return new Promise((r,o)=>{const a=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(a),g=new Image;g.onload=()=>{try{const f=document.createElement("canvas");f.width=i*t,f.height=n*t;const m=f.getContext("2d");if(!m){URL.revokeObjectURL(h),o(new Error("no 2d context"));return}m.scale(t,t),m.drawImage(g,0,0,i,n),URL.revokeObjectURL(h),r(f.toDataURL("image/png"))}catch(f){URL.revokeObjectURL(h),o(f)}},g.onerror=f=>{URL.revokeObjectURL(h),o(f)},g.src=h})}getPoints(){const t=this.__children__.search("__children__","points");return t?[...t.__data__.objects.values()].filter(e=>{var s;return((s=e.meta)==null?void 0:s.kind)==="point"}).map(e=>{var s,i,n;return{id:((s=e.meta)==null?void 0:s.unit)??e.ID,group:(i=e.meta)==null?void 0:i.group,set:(n=e.meta)==null?void 0:n.set,x:e.x,y:e.y}}):[]}pointsInRect(t){return this.getPoints().filter(e=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h).map(e=>e.id)}_edgeKey(t,e){return t<=e?`${t}\0${e}`:`${e}\0${t}`}setHighlight(t){this._highlight.edges=new Set((t.edges??[]).map(e=>this._edgeKey(e.source,e.target))),this._highlight.nodes=new Set((t.nodes??[]).map(String)),this._applyHighlights()}clearHighlight(){this._highlight.edges.clear(),this._highlight.nodes.clear(),this._applyHighlights()}_applyHighlights(){var g;if(!this.svg_element)return;this._highlightGroup||(this._highlightGroup=this.doc.createElementNS("http://www.w3.org/2000/svg","g"),this._highlightGroup.setAttribute("data-layer-name","highlight"),this._highlightGroup.setAttribute("pointer-events","none"));const t=this._highlight.edges.size>0||this._highlight.nodes.size>0,e=(g=this.__children__[0])==null?void 0:g.svg_element;(t&&e?e:this.svg_element).appendChild(this._highlightGroup);const s=this._highlightGroup;s.textContent="";const i=this.__data__.extremes.x_max||1,n="#f5a623",r=this.zoom_level||1,o=this._edgesFixedSize?r:1,a=l(f=>{var d;const m=l(u=>{var b;return(b=this.__children__.search("__children__",u))==null?void 0:b.__data__.objects.get(f)},"find"),_=(d=m("nodes")??m("points"))==null?void 0:d.meta;return _!=null&&_.zoomFixed||_!=null&&_.fixedSize?r:1},"markK"),h=l((f,m)=>{const _=this.doc.createElementNS("http://www.w3.org/2000/svg",f);for(const d in m)_.setAttribute(d,String(m[d]));return _},"mk");if(this._highlight.edges.size){const f={};this.getNodes().forEach(m=>{f[m.id]={x:m.x,y:m.y}}),this._highlight.edges.forEach(m=>{const[_,d]=m.split("\0"),u=f[_],b=f[d];!u||!b||s.appendChild(h("line",{x1:u.x,y1:u.y,x2:b.x,y2:b.y,stroke:n,"stroke-width":i*.02/o,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(f=>{var p;const m=this.svg_element.querySelector(`[data-point-id="${(p=globalThis.CSS)!=null&&p.escape?globalThis.CSS.escape(f):f}"]`);if(!m)return;const _=m.tagName.toLowerCase();let d,u,b;if(_==="rect"){const w=parseFloat(m.getAttribute("width")||"0");d=parseFloat(m.getAttribute("x")||"0")+w/2,u=parseFloat(m.getAttribute("y")||"0")+parseFloat(m.getAttribute("height")||"0")/2,b=w/2}else d=parseFloat(m.getAttribute("cx")||"0"),u=parseFloat(m.getAttribute("cy")||"0"),b=parseFloat(m.getAttribute("r")||"0");s.appendChild(h("circle",{cx:d,cy:u,r:b*1.7+i*.004/a(f),fill:"none",stroke:n,"stroke-width":i*.006/a(f)}))})}create(){const t=this.doc.createElementNS("http://www.w3.org/2000/svg","svg");t.classList.add("graph"),t.style.display="block",t.style.width="100%",t.style.height="100%",t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.setAttribute("viewBox",this.__data__.extremes.as_viewBox()),t.setAttribute("transform",this.__data__.transform.toString()),t.setAttribute("role","figure"),t.setAttribute("data-graph-size",`${Math.min(this.__data__.extremes.width,this.__data__.extremes.height)}`),this.svg_element=t;const e=this.doc.createElementNS("http://www.w3.org/2000/svg","defs"),s=.22,i=.15,n=l((r,o)=>{const a=this.doc.createElementNS("http://www.w3.org/2000/svg","marker");a.setAttribute("id",r),a.setAttribute("markerWidth",String(s)),a.setAttribute("markerHeight",String(i)),a.setAttribute("refX",String(s)),a.setAttribute("refY",String(i/2)),a.setAttribute("orient","auto"),a.setAttribute("markerUnits","userSpaceOnUse");const h=this.doc.createElementNS("http://www.w3.org/2000/svg","path");h.setAttribute("d",`M0,0 L0,${i} L${s},${i/2} z`),h.setAttribute("fill",o),a.appendChild(h),e.appendChild(a)},"makeArrow");return Ni.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const o=new ss(r,this.svg_element,this);this.__children__.push(o)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){const t=l(()=>this._host.hasAttribute("view-locked"),"locked");this.svg_element.addEventListener("wheel",d=>{if(t())return;d.preventDefault();const u=d.deltaMode===1?33:d.deltaMode===2?this.svg_element.clientHeight||800:1,b=d.deltaY*u,p=d.ctrlKey?Math.exp(-b/100):Math.pow(this._zoomStep(),-b/100);this._stopZoomAnim();const w=this._clientToRoot(d.clientX,d.clientY);w?this._zoomAbout((this.zoom_level||1)*p,w[0],w[1]):this.zoomBy(p)},{passive:!1}),this.svg_element.addEventListener("dblclick",d=>{var b,p;if(t()||(p=(b=d.target)==null?void 0:b.closest)!=null&&p.call(b,"text[data-label-for]"))return;d.preventDefault();const u=this._clientToRoot(d.clientX,d.clientY);u&&this._animateZoomAbout((this.zoom_level||1)*2.2,u[0],u[1],200)});const e=new Map;let s=null;const i=l(()=>{const[d,u]=[...e.values()];return d?u?{mid:[(d[0]+u[0])/2,(d[1]+u[1])/2],dist:Math.hypot(d[0]-u[0],d[1]-u[1]),n:2}:{mid:d,dist:0,n:1}:null},"measure");this.svg_element.addEventListener("pointerdown",d=>{d.pointerType!=="touch"||t()||(e.set(d.pointerId,[d.clientX,d.clientY]),s=i(),this._stopZoomAnim())}),this.svg_element.addEventListener("pointermove",d=>{if(!e.has(d.pointerId))return;if(t()){e.clear(),s=null;return}e.set(d.pointerId,[d.clientX,d.clientY]);const u=i();if(u&&s&&u.n===s.n){const b=this._clientToRoot(...s.mid),p=this._clientToRoot(...u.mid);if(b&&p){const w=this.__data__.transform;w.pan(p[0]-b[0],p[1]-b[1]),u.n===2&&s.dist>0&&u.dist>0?this._zoomAbout((this.zoom_level||1)*u.dist/s.dist,p[0],p[1]):this.__children__[0].svg_element.setAttribute("transform",w.toString())}}s=u});const n=l(d=>{e.delete(d.pointerId)&&(s=i())},"touchEnd");this.svg_element.addEventListener("pointerup",n),this.svg_element.addEventListener("pointercancel",n);let r=!1,o=0,a=0;this.svg_element.addEventListener("mousedown",d=>{t()||(r=!0,o=d.clientX,a=d.clientY)});let h=null,g=null;const f=l(()=>{g&&(this.__data__.transform.pan(g.dx,g.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),g=null),h=null},"panUpdate");this.svg_element.addEventListener("mousemove",d=>{if(!r)return;if(d.buttons===0){r=!1;return}const u=this._clientToRoot(o,a),b=this._clientToRoot(d.clientX,d.clientY);o=d.clientX,a=d.clientY,!(!u||!b)&&(g={dx:((g==null?void 0:g.dx)??0)+b[0]-u[0],dy:((g==null?void 0:g.dy)??0)+b[1]-u[1]},h===null&&(h=requestAnimationFrame(f)))}),this.svg_element.addEventListener("mouseup",d=>{r=!1}),this.svg_element.addEventListener("point-clicked",(d=>{var p,w;const u=(w=(p=d.detail)==null?void 0:p.pointData)==null?void 0:w.ID;if(!u)return;const b=this._pointLabels.get(u)??this._setLabels.get(u)??this._meanLabels.get(u.replace("mean-",""))??this._nodeLabels.get(u);b&&b.displayMode===G.DISPLAY_TYPES.CLICK&&b.toggle()}));const m=l(d=>{var u;for(;d&&d!==this.svg_element;){const b=(u=d.getAttribute)==null?void 0:u.call(d,"data-point-id");if(b)return b;d=d.parentElement}return null},"findPointId"),_=l(d=>this._pointLabels.get(d)??this._setLabels.get(d)??this._meanLabels.get(d.replace(/^mean-/,""))??this._nodeLabels.get(d),"getAutoLabel");this.svg_element.addEventListener("mouseover",d=>{const u=m(d.target);if(!u)return;const b=_(u);(b==null?void 0:b.displayMode)===G.DISPLAY_TYPES.AUTO&&b.show()}),this.svg_element.addEventListener("mouseout",d=>{const u=m(d.target);if(!u)return;const b=d.relatedTarget;if(m(b)===u)return;const w=_(u);(w==null?void 0:w.displayMode)===G.DISPLAY_TYPES.AUTO&&w.hide()}),this._attachInteractionEvents()}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}_closestWith(t,e){var s,i;for(;t&&t!==this.svg_element;){if(((s=t.getAttribute)==null?void 0:s.call(t,e))!=null&&((i=t.hasAttribute)!=null&&i.call(t,e)))return t;t=t.parentElement}return null}_edgeDetail(t){const e=this._closestWith(t,"data-edge-source");if(!e)return null;const s={source:e.getAttribute("data-edge-source"),target:e.getAttribute("data-edge-target"),weight:parseFloat(e.getAttribute("data-edge-weight")||"0"),directed:e.getAttribute("data-edge-directed")==="true",self:e.getAttribute("data-edge-self")==="true"};return e.hasAttribute("data-edge-group")&&(s.group=e.getAttribute("data-edge-group")),e.hasAttribute("data-edge-unit")&&(s.unit=e.getAttribute("data-edge-unit")),s}_nodeDetail(t){const e=this._closestWith(t,"data-point-id");if(!e)return null;const s=e.tagName.toLowerCase();let i,n;s==="rect"?(i=parseFloat(e.getAttribute("x")||"0")+parseFloat(e.getAttribute("width")||"0")/2,n=parseFloat(e.getAttribute("y")||"0")+parseFloat(e.getAttribute("height")||"0")/2):(i=parseFloat(e.getAttribute("cx")||"0"),n=parseFloat(e.getAttribute("cy")||"0"));const r=e.getAttribute("data-point-id"),o={id:r,kind:e.getAttribute("data-kind")||"point",name:e.getAttribute("data-name")||r,x:i,y:n};return e.hasAttribute("data-group")&&(o.group=e.getAttribute("data-group")),e.hasAttribute("data-unit")&&(o.unit=e.getAttribute("data-unit")),o}_attachInteractionEvents(){const t=this.svg_element;t.addEventListener("click",i=>{const n=i.target,r=this._edgeDetail(n);if(r){this._emit("qe-edge-click",{...r,originalEvent:i});return}const o=this._nodeDetail(n);o&&this._emit("qe-node-click",{...o,originalEvent:i})});let e=null;const s=l((i,n)=>i==="edge"?`${n.source}\0${n.target}`:String(n.id),"keyOf");t.addEventListener("mousemove",i=>{const n=i.target,r=this._edgeDetail(n),o=r?null:this._nodeDetail(n),a=r?{type:"edge",detail:r}:o?{type:"node",detail:o}:null,h=a?s(a.type,a.detail):null;e&&(!a||e.key!==h)&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),a&&(!e||e.key!==h)&&(this._emit(a.type==="edge"?"qe-edge-hover":"qe-node-hover",{...a.detail,originalEvent:i}),e={type:a.type,key:h}),this._host.hasAttribute("tooltip")&&a?this._showTooltip(this._tooltipText(a.type,a.detail),i.clientX,i.clientY):this._hideTooltip()}),t.addEventListener("mouseleave",()=>{e&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),this._hideTooltip()})}_tooltipText(t,e){if(t==="edge"){const s=Number(e.weight),i=Number.isFinite(s)?` (${+s.toFixed(3)})`:"";return`${e.source} – ${e.target}${i}`}return String(e.name??e.id)}_showTooltip(t,e,s){if(!this._tooltipEl){const i=this.doc.createElement("div");i.setAttribute("data-qe-tooltip",""),Object.assign(i.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",background:"rgba(20,20,20,0.92)",color:"#fff",font:"12px/1.4 system-ui, sans-serif",padding:"3px 7px",borderRadius:"4px",whiteSpace:"nowrap",transform:"translate(-50%, calc(-100% - 8px))"}),document.body.appendChild(i),this._tooltipEl=i}this._tooltipEl.textContent=t,this._tooltipEl.style.left=`${e}px`,this._tooltipEl.style.top=`${s}px`,this._tooltipEl.style.display="block"}_hideTooltip(){this._tooltipEl&&(this._tooltipEl.style.display="none")}draw(){var t;if(!this.svg_element){console.error("No element to draw to: ",this);return}if(this._headless||(t=this.wrapper)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()}),!this._headless&&!this._resizeObs&&typeof ResizeObserver<"u"&&this.svg_element){let e=0;this._resizeObs=new ResizeObserver(s=>{var n;const i=((n=s[0])==null?void 0:n.contentRect.width)??0;i>0&&Math.abs(i-e)>.5&&(e=i,this.update_labels(),this.update_axes())}),this._resizeObs.observe(this.svg_element)}}update(){this.update_extremes(),this.update_layers(),[this._ciRects,this._outlierRects,this._ciCross].forEach(t=>t.forEach(e=>this._applyIntervalStroke(e))),this.update_labels(),this.update_extremes(),this.update_axes(),this._applyHighlights()}update_axes(){var f,m;const t=this.__children__.search("__children__","axes");t!=null&&t.svg_element&&(t.svg_element.style.display=this._showAxes?"":"none");const e=this._labelsGroup,s=this.__data__.extremes.x_max,{cx:i,cy:n}=this.__data__.extremes;if(!e||s<=0)return;const r=s*.06,o=r*.6,a=r/(this._axesFixedSize&&this.zoom_level||1),h=a*.6,g=l((_,d)=>{let u=this._axisLabelEls.get(_);if(!this._showAxes||d==null){u&&(u.remove(),this._axisLabelEls.delete(_));return}u||(u=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),u.setAttribute("data-axis-label",_),u.setAttribute("pointer-events","none"),e.appendChild(u),this._axisLabelEls.set(_,u)),u.textContent=d,u.setAttribute("font-size",a.toString()),u.setAttribute("font-family","system-ui, sans-serif"),u.setAttribute("font-weight","600"),u.setAttribute("fill","#556"),_==="x"?(u.setAttribute("x",(i+s-h).toString()),u.setAttribute("y",(-h).toString()),u.setAttribute("text-anchor","end")):(u.setAttribute("x",h.toString()),u.setAttribute("y",(n-s+a+h).toString()),u.setAttribute("text-anchor","start"))},"place");if(g("x",this._axisXText),g("y",this._axisYText),this._magnifyText==null)(f=this._magnifyEl)==null||f.remove(),this._magnifyEl=null;else{this._magnifyEl||(this._magnifyEl=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),this._magnifyEl.setAttribute("data-magnify-label",""),this._magnifyEl.setAttribute("pointer-events","none")),this._magnifyEl.parentElement||e.appendChild(this._magnifyEl);const _=this._magnifyEl;_.textContent=this._magnifyText,_.setAttribute("font-size",(r*.85).toString()),_.setAttribute("font-family","system-ui, sans-serif"),_.setAttribute("font-style","italic"),_.setAttribute("fill","#556"),_.setAttribute("x",(i-s+o).toString()),_.setAttribute("y",(n-s+r+o).toString()),_.setAttribute("text-anchor","start")}if(!this._plotTitle)(m=this._titleEl)==null||m.remove(),this._titleEl=null;else{this._titleEl||(this._titleEl=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),this._titleEl.setAttribute("data-plot-title",""),this._titleEl.setAttribute("pointer-events","none")),this._titleEl.parentElement||e.appendChild(this._titleEl);const d=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),u=this._titleEl;u.textContent=this._plotTitle,u.setAttribute("font-size",d.toString()),u.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),u.setAttribute("font-weight","600"),u.setAttribute("fill",this._labelFont.color??"#223"),u.setAttribute("x",i.toString()),u.setAttribute("y",(n-s+d*1.1).toString()),u.setAttribute("text-anchor","middle")}}update_labels(){this._nodeLabels.forEach(t=>t.update()),this._meanLabels.forEach(t=>t.update()),this._pointLabels.forEach(t=>t.update()),this._setLabels.forEach(t=>t.update())}update_extremes(){var s;const t=this.__data__;if(this._tweenView){const[i,n,r,o]=this._tweenView;t.extremes=new Ft(i,n,r,o)}else if(t.update_extremes(this._centerContent),this._rangeExtent&&this._rangeExtent>0){const{cx:i,cy:n}=t.extremes,r=this._centerContent&&this._rangeMode==="network"?t.nodeExtentFrom(i,n)*1.2:this._rangeExtent;t.extremes=new Ft(r,r,i,n)}const e=(s=this.svg_element)==null?void 0:s.getBoundingClientRect();if(this.svg_element&&e){Jt("SVG rect: ",e);let i,n;e.width===0||e.height===0?(i=1,n=1):(i=e.width,n=e.height),this.__data__.scale_x=1/(i/(4*this.__data__.extremes.x_max)),this.__data__.scale_y=1/(n/(4*this.__data__.extremes.y_max)),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),this.svg_element.setAttribute("viewBox",this.__data__.extremes.as_viewBox(this._viewPadding()));let r=this.__data__.layers.search("layers","axis_lines");if(r){let o=r.objects.get("axis-x"),a=r.objects.get("axis-y");if(o&&a){const h=this.__data__.extremes;o.from=new it({ID:"axis-x-start",dimensions:[h.cx-h.x_max,0],classes:["ena.dimension","ena.dimension"]}),o.to=new it({ID:"axis-x-end",dimensions:[h.cx+h.x_max,0],classes:["ena.dimension","ena.dimension"]}),a.from=new it({ID:"axis-y-start",dimensions:[0,h.cy-h.y_max],classes:["ena.dimension","ena.dimension"]}),a.to=new it({ID:"axis-y-end",dimensions:[0,h.cy+h.y_max],classes:["ena.dimension","ena.dimension"]})}}}}update_layers(){this.__children__.forEach(t=>{t.update()})}};l(at,"QEGraphElement"),at.tagName="qe-graph",at.style=`
|
|
19
|
+
${Qe.style}
|
|
20
20
|
|
|
21
21
|
:host {
|
|
22
22
|
display: block;
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
svg [data-layer-name="edges"] path:not([data-edge-source]) {
|
|
54
54
|
pointer-events: none;
|
|
55
55
|
}
|
|
56
|
-
`,
|
|
56
|
+
`,at._instances=new Set,at._PATH_NUM_RE=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi;let jt=at;Et(jt.tagName,jt);function ki(c,t){if(t)for(const[e,s]of Object.entries(t))s===!1||s==null||c.setAttribute(e,s===!0?"":String(s))}l(ki,"setAttrs");function Ii(c,t={}){const e=t.width??600,s=t.height??e;if(!(e>0)||!(s>0))throw new Error(`renderSVG: width and height must be positive (got ${e} × ${s})`);const i=me.createElement("qe-graph");ki(i,{width:e,height:s,...t.graph});for(const r of t.layers??[]){const[o,a]=typeof r=="string"?[r,void 0]:r,h=me.createElement(o);ki(h,a),i.appendChild(h)}const n=new jt(me,i);return n.svg_element.setAttribute("width",String(e)),n.svg_element.setAttribute("height",String(s)),n.mount(),n.renderModel(oi(c)),n}l(Ii,"renderHeadless");function bn(c,t={}){const e=Ii(c,t);return Ze(e.svg_element)}l(bn,"renderSVG");const yn=l(c=>jt.getGraph(c),"getGraph"),xn=l(()=>jt.instances(),"getGraphs");O.Color=rt,O.DataFrame=Gt,O.DataFrameColumn=$t,O.DataFrameColumnType=mt,O.DataFrameRow=H,O.Edge=ve,O.Graph=Je,O.HeadlessDocument=Ve,O.HeadlessElement=te,O.QEAxesElement=Oe,O.QEEdgeElement=Ce,O.QEEdgesElement=Ie,O.QEGraphElement=jt,O.QELayer=ss,O.QELine=Nt,O.QEMeansElement=Me,O.QENodeElement=Ne,O.QENodesElement=Ee,O.QEPoint=ne,O.QEPointsElement=ke,O.QETrajectoriesElement=ze,O.QETrajectory=Se,O.QEVisualElement=pe,O.TRAJECTORY_ZERO_EPS=gi,O.Trajectory=we,O.WeightedColor=be,O.fitTrajectory=xi,O.getGraph=yn,O.getGraphs=xn,O.headlessDocument=me,O.ingestModelData=Ns,O.modelFromData=oi,O.nearOriginFilter=Is,O.renderHeadless=Ii,O.renderSVG=bn,O.sampleCurve=Os,O.selectDegree=yi,O.serializeElement=Ze,O.vizENA=Wi,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
|
|
57
57
|
//# sourceMappingURL=qeviz.umd.js.map
|