mascot-vis 3.0.4 → 3.1.7
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/.github/workflows/publish.yml +38 -0
- package/README.md +13 -2
- package/dist/mascot-cjs.js +2 -186
- package/dist/mascot-esm.js +2 -186
- package/dist/mascot-umd.js +2 -186
- package/package.json +3 -3
package/dist/mascot-umd.js
CHANGED
|
@@ -1,186 +1,2 @@
|
|
|
1
|
-
/* version: 3.
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3")):"function"==typeof define&&define.amd?define(["exports","d3"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).msc={},e.d3)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);const i={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var e=this.getCanvas();return e?e.getContext("2d"):null}};class s{constructor(e,t,r){this._id="predicate_"+Vt(),this._type=e||a.POINT,this._variableType=t,this._variableName=r,this._value=void 0}get type(){return this._type}get value(){return this._value}set value(e){this._value=e}get id(){return this._id}get variableType(){return this._variableType}get variableName(){return this._variableName}}const a=Object.freeze({POINT:"point",INTERVAL:"interval",LIST:"list"});class o extends s{constructor(e,t,r){super(e,t,r)}testElement(e){let t;if("attribute"==this._variableType){if(!e.dataScope)return!1;t=e.dataScope.getAttributeValue(this._variableName)}else t=e[this._variableName];return this._value[0]<=t&&this._value[1]>=t}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value[0]<=t&&this._value[1]>=t}return!1}}class l extends s{constructor(e,t,r){super(e,t,r)}addValue(e){this._value||(this._value=[]),this._value.push(e)}resetValue(){this._value=void 0}testElement(e){if("attribute"==this._variableType){if(!e.dataScope)return!1;let t=e.dataScope.getAttributeValue(this._variableName);return this._value.indexOf(t)>=0}return this._value.indexOf(e[this._variableName])>=0}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value.indexOf(t)>=0}return!1}}class u extends s{constructor(e,t,r){super(e,t,r)}testElement(e){if("attribute"==this._variableType){if(!e.dataScope)return!1;return e.dataScope.getAttributeValue(this._variableName)==this._value}return e[this._variableName]==this._value}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value===t}return!1}}function c(e){let t,r="attribute"in e?"attribute":"property",n=e[r];switch(e.type){case a.LIST:t=new l(e.type,r,n);break;case a.INTERVAL:t=new o(e.type,r,n);break;case a.POINT:default:t=new u(e.type,r,n)}return e.value&&(t.value=e.value),t}function h(e,t){for(let r of t){if(!c(r).testElement(e))return!1}return!0}class d{constructor(e,t,r,n){this._x=e+r/2,this._y=t+n/2,this._width=r,this._height=n}translate(e,t){this._x+=e,this._y+=t}toJSON(){let e={};return e.x=this._x,e.y=this._y,e.width=this._width,e.height=this._height,e}union(e){let t=Math.min(this.left,e.left),r=Math.min(this.top,e.top),n=Math.max(this.right,e.right),i=Math.max(this.bottom,e.bottom);return new d(t,r,n-t,i-r)}clone(){return new d(this.left,this.top,this._width,this._height)}get left(){return this._x-this._width/2}set left(e){this._x=e+this._width/2}get right(){return this._x+this._width/2}set right(e){this._x=e-this._width/2}get top(){return this._y-this._height/2}set top(e){this._y=e+this._height/2}get bottom(){return this._y+this._height/2}set bottom(e){this._y=e-this._height/2}get x(){return this._x}get y(){return this._y}get center(){return this.x}get middle(){return this.y}get width(){return this._width}setWidth(e,t){switch(t){case y.RIGHT:this._x=this.right-e/2;break;case y.CENTER:this._width=2*e;break;default:this._x=this.left+e/2}this._width=e}get height(){return this._height}setHeight(e,t){switch(t){case y.TOP:this._y=this.top+e/2;break;case y.MIDDLE:this._height=2*e;break;default:this._y=this.bottom-e/2}this._height=e}contains(e,t){return this.left<=e&&this.right>=e&&this.top<=t&&this.bottom>=t}overlap(e){return!(this.right<e.left||this.bottom<e.top||this.left>e.right||this.top>e.bottom)}}function f(e){let t=e[0].clone();for(let r=1;r<e.length;r++)t=t.union(e[r]);return t}function p(e){return f(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.refBounds?e.refBounds:e.bounds)))}function _(e){return f(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.bounds)))}function g(e){let t=I(e);for(let e of t)e._updateBounds();let r=[];for(let e of t)e.parent&&!r.includes(e.parent)&&r.push(e.parent);for(let e of r)g(e)}const y=Object.freeze({TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",CENTER:"center",MIDDLE:"middle"});function m(e){return e.id+"-bg"}function b(e){return e.id+"-path"}function v(e){switch(e){case y.TOP:return"text-before-edge";case y.BOTTOM:return"auto";case y.LEFT:return"start";case y.RIGHT:return"end";case y.CENTER:case y.MIDDLE:return"middle";default:return e}}const x=Object.freeze({fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",strokeDash:"stroke-dasharray",opacity:"opacity",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",visibility:"visibility"});class E{constructor(e){let t=e||{};this._stops=[],this.type=Nt.LinearGradient,this.id=this.type+Vt(),this.x1="x1"in t?t.x1:0,this.x2="x2"in t?t.x2:100,this.y1="y1"in t?t.y1:0,this.y2="y2"in t?t.y2:0}toJSON(){let e={};return e.type=this.type,e.id=this.id,e.x1=this.x1,e.x2=this.x2,e.y1=this.y1,e.y2=this.y2,e.stops=this._stops,e}addStop(e,t,r){this._stops.push({offset:e,color:t,opacity:r})}get stops(){return this._stops}}class w{constructor(e){if(this._dataScope=void 0,this._type="type"in e?e.type:Nt.Mark,this._id=e.id?e.id:this._type+"_"+Vt(),this._classId=void 0,this._bounds=void 0,this._rotate=void 0,this._refBounds=void 0,this._styles={},void 0!==e)for(let t in x)t in e&&(this.styles[t]=e[t])}get scene(){return M(this)}set strokeColor(e){this.styles.strokeColor=e}get strokeColor(){return this.styles.strokeColor}set strokeWidth(e){this.styles.strokeWidth=e}get strokeWidth(){return this.styles.strokeWidth}set strokeDash(e){this.styles.strokeDash=e}get strokeDash(){return this.styles.strokeDash}set fillColor(e){this.styles.fillColor=e}get fillColor(){return this.styles.fillColor}get rotation(){return this._rotate}get id(){return this._id}set id(e){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=e,this.getScene()._itemMap[e]=this):this._id=e}get classId(){return this._classId?this._classId:this._id}set classId(e){this._classId=e}get type(){return this._type}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this._refBounds?this._refBounds:this.bounds}contains(e,t){if(!this.bounds)return!1;if(!this.bounds.contains(e,t))return!1;switch(this.type){case Nt.Rect:case Nt.PointText:return!0;case Nt.Circle:return Math.sqrt(Math.pow(e-this.x,2)+Math.pow(t-this.y,2))<=this.radius+this.strokeWidth;case Nt.Path:{let r=i.getContext(),n=new Path2D(this.getSVGPathData());return r.lineWidth=Math.max(this.strokeWidth,2.5),r.stroke(n),this.closed?r.isPointInPath(n,e,t):r.isPointInStroke(n,e,t)}case Nt.Line:{let r=i.getContext(),n=new Path2D(this.getSVGPathData());return r.lineWidth=Math.max(this.strokeWidth,2.5),r.stroke(n),r.isPointInStroke(n,e,t)}default:{let r=i.getContext(),n=new Path2D(this.getSVGPathData());return r.isPointInPath(n,e,t)}}}set dataScope(e){this._dataScope=e}get dataScope(){return this._dataScope}get styles(){return this._styles}set styles(e){this._styles=e}set visibility(e){this.styles.visibility=e}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(e){this.styles.opacity=e}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone())}}function A(e){return e instanceof w&&e.type!==Nt.Gridlines}const C=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"text",Polygon:"polygon",BezierCurve:"bezierCurve"});function R(e,t,r){const n=document.getElementById(e),i=n.createSVGPoint();i.x=t,i.y=r;const s=i.matrixTransform(n.getScreenCTM().inverse());return[s.x,s.y]}function k(e,t,r,n){return Math.sqrt(Math.pow(e-r,2)+Math.pow(t-n,2))}function S(e,t,r,n,i){const s=i*Math.PI/180,a=e-r,o=t-n;return{x:a*Math.cos(s)-o*Math.sin(s)+r,y:a*Math.sin(s)+o*Math.cos(s)+n}}const T={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}},O={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var e=this.getCanvas();return e?e.getContext("2d"):null}};function I(e,t){let r=M(e),n=t||r;if("vertex"===e.type){return N(e,V(n,[{property:"classId",value:e.parent.classId}]))}if("segment"===e.type){return L(e,V(n,[{property:"classId",value:e.parent.classId}]))}return e.classId?V(n,[{property:"classId",value:e.classId}]):[e]}function N(e,t){if(!e.classId){if(e.dataScope){let r=e.parent;if(!r)throw new Error("vertex has no parent mark");let n=[];if(r.type===Nt.Area){let i=r.vertices.indexOf(e)<r.vertices.length/2;for(let e of t){let t=i?e.vertices.slice(0,e.vertices.length/2):e.vertices.slice(e.vertices.length/2);n=n.concat(t.filter((e=>e.dataScope)))}}else for(let e of t)n=n.concat(e.vertices.filter((e=>e.dataScope)));return n}{let r=e.parent;if(!r)throw new Error("vertex has no parent mark");let n=r.vertices.indexOf(e),i=[];for(let e of t)i.push(e.vertices[n]);return i}}}function L(e,t){if(e.dataScope){if(!e.parent)throw new Error("segment has no parent mark");let r=[];for(let e of t)r=r.concat(e.segments);return r}{let r=e.parent;if(!r)throw new Error("segment has no parent mark");let n=r.segments.indexOf(e),i=[];for(let e of t)i.push(e.segments[n]);return i}}function V(e,t){let r=[];return B(e,t,r),r}function P(e,t){let r=e.children.filter((e=>e.type==Nt.Collection));if(0!==r.length)for(let e of r){let r=e;for(;r&&r.dataScope;){if(r.dataScope.hasAttribute(t))return r;r=r.children?r.children[0]:void 0}}}function D(e){return e.type==Nt.Collection?e:e.parent?D(e.parent):void 0}function B(e,t,r){if(e&&"axis"!=e.type&&"legend"!=e.type&&"gridlines"!=e.type)if(h(e,t)&&r.push(e),e.vertices)for(let n of e.vertices.concat(e.segments))h(n,t)&&r.push(n);else if(e.children&&e.children.length>0)for(let n of e.children)B(n,t,r)}function M(e){let t=e;for(;t;){if(t.type==Nt.Scene)return t;t=t.parent}}function G(e){let t=e;for("vertex"!=t.type&&"segment"!=t.type||(t=t.parent);t.parent&&[Nt.Collection,Nt.Glyph].includes(t.parent.type);)t=t.parent;return t}function j(e,t,r,n){let i=V(e,[{property:"type",value:t}]);for(let e of i)if(z(e,r,n))return e}function z(e,t,r){switch(e.type){case Nt.Path:case Nt.Arc:case Nt.BezierCurve:case Nt.Line:{let n=i.getContext(),s=new Path2D(e.getSVGPathData());return n.lineWidth=Math.max(e.strokeWidth,2.5),n.stroke(s),e.closed?n.isPointInPath(s,t,r):n.isPointInStroke(s,t,r)}case Nt.Circle:{let n=e.x,i=e.y;if(e.rotation){let t=S(n,i,e.rotation[1],e.rotation[2],e.rotation[0]);n=t.x,i=t.y}return Math.sqrt(Math.pow(t-n,2)+Math.pow(r-i,2))<=e.radius+e.strokeWidth}default:return e.bounds.contains(t,r)}}function F(e,t){let r=[];if(U(e,r),t){let e={};for(let t of r)e[t.classId]=t;return Object.values(e)}return r}function U(e,t){if(A(e))t.push(e);else if(e.type==Nt.Collection&&e.children)for(let r of e.children)U(r,t);else if(e.type==Nt.Glyph&&e.children)for(let r of e.children)U(r,t);else if(e.type==Nt.Composite&&e.children)for(let r of e.children)U(r,t)}class H{constructor(){this._refElements=[]}addRefElement(e){this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}const W=Object.freeze({GRID:"grid",STACK:"stack",PACKING:"packing",FORCE:"force",DIRECTED:"directedgraph",TIDYTREE:"tidytree",TREEMAP:"treemap",STRATA:"strata",CIRCULAR:"circular",CLUSTER:"cluster"});function Y(e,t){return!!(e.startsWith("h")&&[y.LEFT,y.CENTER,y.RIGHT].indexOf(t)>=0)||(!!(e.startsWith("v")&&[y.TOP,y.MIDDLE,y.BOTTOM].indexOf(t)>=0)||(console.warn("Invalid alignment:",t),!1))}class X{constructor(e){this._id=e+"_"+Vt(),this._type=e,this._inputVars=[],this._outputVars=[]}run(){console.log("-",this._type,this.outputVar.element?this.outputVar.element.type:"",this.outputVar.channel?this.outputVar.channel:"")}get id(){return this._id}get type(){return this._type}get inputVars(){return this._inputVars}get outputVars(){return this._outputVars}get outputVar(){return this._outputVars[0]}isIsolated(){return 0==this._inputVars.length&&0==this._outputVars.length}}const q=Object.freeze({CONDUIT:"conduit",ENCODER:"encoder",LAYOUT:"layout",LINK_PLACER:"linkRouter",CONSTRAINT:"constraint",EVAL_BBOX:"evalBBox",EVAL_REFBOUNDS:"evalRefBounds",AFFIXER:"affixer",ALIGNER:"aligner",DOMAIN_BUILDER:"domainBuilder",SCALE_BUILDER:"scaleBuilder",AXIS_PATH_PLACER:"axisPathPlacer",AXIS_TICKS_PLACER:"axisTicksPlacer",AXIS_LABELS_PLACER:"axisLabelsPlacer",AXIS_TITLE_PLACER:"axisTitlePlacer",GRIDLINES_PLACER:"gridlinesPlacer",GRID_LAYOUT:"gridLayout",STACK_LAYOUT:"stackLayout",PACK_LAYOUT:"packLayout",FORCE_LAYOUT:"forceLayout",DIRECTED_LAYOUT:"directedLayout",TIDY_TREE_LAYOUT:"tidyTreeLayout",TREEMAP_LAYOUT:"treemapLayout",STRATA_LAYOUT:"strataLayout",CIRCULAR_LAYOUT:"circularLayout",CLUSTER_LAYOUT:"clusterLayout",BIN_TRANSFORMER:"binTransformer",FILTER_TRANSFORMER:"filterTransformer",KDE_TRANSFORMER:"kdeTransformer",TARGET_EVALUATOR:"targetEvaluator"});class K{constructor(e){this._id="v_"+Vt(),this._type=e,this._incomings=[],this._outgoings=[],this._undirected=[]}get id(){return this._id}get incomingEdges(){return this._incomings}get outgoingEdges(){return this._outgoings}get undirectedEdges(){return this._undirected}get type(){return this._type}get incomingDataflow(){for(let e of this._incomings)if(e.fromNode&&e.fromNode instanceof X)return e.fromNode;return null}isIsolated(){return 0==this._incomings.length&&0==this._outgoings.length}}const Z=Object.freeze({CHANNEL:"channel",PROPERTY:"property",ATTRIBUTE:"attribute",ITEMS:"items",DATASCOPE:"datascope",DOMAIN:"domain",BOUNDS:"bounds",ORDER:"order",SCALE:"scale",COND_ENCODING:"condEncoding",AFFIXATION:"affixation",ALIGNMENT:"alignment",TRIGGER:"trigger"});class $ extends K{constructor(e,t){super(e),this._condEnc=t}get condEncoding(){return this._condEnc}}const J=Object.freeze({RowFirst:"rowFirst",ColumnFirst:"columnFirst"}),Q=Object.freeze({TopLeft:"topLeft",TopRight:"topRight",BottomLeft:"bottomLeft",BottomRight:"bottomRight"}),ee={HORIZONTAL:"horizontal",VERTICAL:"vertical",ANGULAR:"angular",RADIAL:"radial"},te={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"},re=Object.freeze({CLOCKWISE:"clockwise",ANTI_CLOCKWISE:"anti-clockwise"}),ne=Object.freeze({INWARD:"inward",OUTWARD:"outward"});class ie{constructor(e,t,r,n){this.type="vertex",this._id=n,this._x=e,this._y=t,this._dataScope=void 0,this.parent=r,this.shape=void 0,this.width=0,this.height=0,this.radius=0,this.fillColor="#555",this.opacity=1,this.strokeWidth=0,this.strokeColor="#aaa",this._polarAngle=void 0}get dataScope(){return this._dataScope}set dataScope(e){this._dataScope=e}get bounds(){switch(this.shape){case"rect":return new d(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new d(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new d(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}_clone(e){let t=new ie(this.x,this.y,e,this._id);return this._dataScope&&(t._dataScope=this._dataScope.clone()),t.shape=this.shape,t.width=this.width,t.height=this.height,t.radius=this.radius,t.fillColor=this.fillColor,t.opacity=this.opacity,t.strokeWidth=this.strokeWidth,t.strokeColor=this.strokeColor,t}get polarAngle(){return this._polarAngle}get scene(){return this.parent.scene}get x(){return this._x}get y(){return this._y}}ie.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class se{constructor(e,t,r,n){this.type="segment",this._id=n,this.vertex1=e,this.vertex2=t,this.dataScope=void 0,this.parent=r}get id(){return this.parent.id+"_s_"+this._id}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}get scene(){return this.parent.scene}}class ae extends w{constructor(e){super(e),this._type="type"in e?e.type:Nt.Path,this.vertices=[],this.vertexCounter=0,this._sortBy={},this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed=!1,this.curveMode="linear",this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1;for(let t of ie.styles)t in e&&(this["_"+t]=e[t]);"vertices"in e&&this._setVertices(e.vertices),this._sourceAnchor="sourceAnchor"in e?e.sourceAnchor:["center","middle"],this._targetAnchor="targetAnchor"in e?e.targetAnchor:["center","middle"],this._sourceOffset="sourceOffset"in e?e.sourceOffset:[0,0],this._targetOffset="targetOffset"in e?e.targetOffset:[0,0],this._strength="strength"in e?e.strength:.85,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}_setVertices(e){let t;this.vertices=[],this.segments=[],this.vertexCounter=0,this.segmentCounter=0;for(let r=0;r<e.length;r++)if(r!=e.length-1||e[r][0]!==e[0][0]||e[r][1]!==e[0][1]||this.type!==Nt.Path){t=new ie(e[r][0],e[r][1],this,this.vertexCounter++);for(let e of ie.styles)if(this[e]){let r=e.replace("vx","");t[r[0].toLowerCase()+r.slice(1)]=this[e]}this.vertices.push(t),r>0&&this.segments.push(new se(this.vertices[r-1],this.vertices[r],this,this.segmentCounter++))}let r=e[0],n=e[e.length-1];(r[0]===n[0]&&r[1]===n[1]||this.type===Nt.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new se(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(e){e.attrs=Object.assign({},this.attrs),e.styles=Object.assign({},this.styles);for(let t of ie.styles)this["_"+t]&&(e["_"+t]=this["_"+t]);this._dataScope&&(e._dataScope=this._dataScope.clone()),e.closed=this.closed,e.curveMode=this.curveMode,e.vertices=[],e.segments=[];for(let t of this.vertices)e.vertices.push(t._clone(e));e.segmentCounter=0;for(let t=1;t<e.vertices.length;t++)e.segments.push(new se(e.vertices[t-1],e.vertices[t],e,e.segmentCounter++));e.closed&&e.segments.push(new se(e.vertices[e.vertices.length-1],e.vertices[0],e,e.segmentCounter++)),e._sourceAnchor=this._sourceAnchor.slice(),e._targetAnchor=this._targetAnchor.slice(),e._sourceOffset=this._sourceOffset.slice(),e._targetOffset=this._targetOffset.slice(),e._beta=this._beta}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}get strokeColor(){return this.styles.strokeColor}get strokeWidth(){return this.styles.strokeWidth}get fillColor(){return this.styles.fillColor}set fillColor(e){this.styles.fillColor=e}get strokeDash(){return this.styles.strokeDash}set strokeDash(e){this.styles.strokeDash=e}resize(e,t,r,n){let i=this.bounds,s=0===i.width?1:i.width,a=0===i.height?1:i.height;if("right"===r)for(let t of this.vertices)t._x=i.right-e/s*(i.right-t.x);else for(let t of this.vertices)t._x=i.left+e/s*(t.x-i.left);if("top"===n)for(let e of this.vertices)e._y=i.top+t/a*(e.y-i.top);else for(let e of this.vertices)e._y=i.bottom-t/a*(i.bottom-e.y);this._updateBounds()}_updateBounds(){let e=[],t=[];if(this._d){const r=this._d.match(/[a-zA-Z][^a-zA-Z]*/g),n=" ";r.forEach((r=>{let i=r.slice(1).trim().split(n).map(Number);for(let[r,n]of i.entries())r%2==0?e.push(n):t.push(n)}))}else e=this.vertices.map((e=>e.x)),t=this.vertices.map((e=>e.y));let r=Math.min(...e),n=Math.min(...t),i=Math.max(...e),s=Math.max(...t),a=i-r,o=s-n;if(this._bounds=new d(r,n,a,o),this.type===Nt.Line||this.type===Nt.Path){let e=this.styles.strokeWidth?this.styles.strokeWidth:1;r===i?this._bounds=new d(r-e/2,n,i-r+e,s-n):n===s&&(this._bounds=new d(r,n-e/2,i-r,s-n+e))}}addVertex(e,t,r){let n=new ie(e,t,this,this.vertexCounter++);this.vertices.splice(r,0,n)}sortVertices(e,t){this.vertices.sort(((t,r)=>t[e]-r[e])),t&&this.vertices.reverse();for(let e=0;e<this.segments.length;e++){let t=this.segments[e];t.vertex1=this.vertices[e],t.vertex2=this.vertices[(e+1)%this.vertices.length]}}sortVerticesByData(e,t,r){let n;n=r?(t,n)=>r.indexOf(t.dataScope.getValue(e))-r.indexOf(n.dataScope.getAttributeValue(e)):(t,r)=>t.dataScope.getAttributeValue(e)<r.dataScope.getAttributeValue(e)?-1:1,this.vertices.sort(n),t&&this.vertices.reverse();for(let e=0;e<this.segments.length;e++){let t=this.segments[e];t.vertex1=this.vertices[e],t.vertex2=this.vertices[(e+1)%this.vertices.length]}}getSVGPathData(){if(this._d)return this._d;let e=n.path(),t=this._getD3CurveFunction(this.curveMode)(e);t.lineStart();for(let e of this.vertices)t.point(e.x,e.y);return this.closed&&t.point(this.vertices[0].x,this.vertices[0].y),t.lineEnd(),e._}get firstVertex(){return this.vertices[0]}get firstSegment(){return this.segments[0]}get lastVertex(){return this.vertices[this.vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_getD3CurveFunction(e){switch(e){case ue.Natural:return n.curveNatural;case ue.Basis:return n.curveBasis;case ue.BumpX:return n.curveBumpX;case ue.BumpY:return n.curveBumpY;case ue.Linear:return n.curveLinear;case ue.Step:return n.curveStep;case ue.CatmullRom:return n.curveCatmullRom;case ue.Cardinal:return n.curveCardinal;case ue.Bundle:return n.curveBundle.beta(.5);default:return n.curveLinear}}get vxShape(){return this._vxShape}get vxWidth(){return this._vxWidth}get vxHeight(){return this._vxHeight}get vxRadius(){return this._vxRadius}get vxFillColor(){return this._vxFillColor}get vxStrokeColor(){return this._vxStrokeColor}get vxStrokeWidth(){return this._vxStrokeWidth}get vxOpacity(){return this._vxOpacity}get sourceAnchor(){return this._sourceAnchor}get targetAnchor(){return this._targetAnchor}get sourceOffset(){return this._sourceOffset}get targetOffset(){return this._targetOffset}}function oe(e,t){const r=T.getSVG();let n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",e.getSVGPathData()),r.appendChild(n);let i=n.getTotalLength();return n.getPointAtLength(i*t)}function le(e){return e instanceof ae&&e.source&&e.target}const ue={Natural:"natural",Basis:"basis",BumpX:"bumpX",BumpY:"bumpY",Bundle:"bundle",Linear:"linear",Step:"step",CatmullRom:"CatmullRom",Cardinal:"cardinal"};function ce(e,t,r){const n=e.match(/[a-zA-Z][^a-zA-Z]*/g),i=",";return n.map((e=>{const n=e[0],s=e.slice(1).trim();if("M"===n||"L"===n||"T"===n){const[e,a]=s.split(i).map(Number);return`${n}${e+t} ${a+r}`}if("C"===n){const e=s.split(i).map(Number);return`${n}${e[0]+t} ${e[1]+r} ${e[2]+t} ${e[3]+r} ${e[4]+t} ${e[5]+r}`}if("Q"===n){const e=s.split(i).map(Number);return`${n}${e[0]+t} ${e[1]+r} ${e[2]+t} ${e[3]+r}`}if("A"===n){const e=s.split(i).map(Number);return`${n}${e[0]} ${e[1]} ${e[2]} ${e[3]} ${e[4]} ${e[5]+t} ${e[6]+r}`}return"Z"===n||"z"===n?n:e})).join(" ")}class he extends ae{constructor(e){super(e),this._type=Nt.Arc,this.closed=!0,this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._innerRadius="innerRadius"in e?e.innerRadius:100,this._outerRadius="outerRadius"in e?e.outerRadius:200,this._thickness="thickness"in e?e.thickness:this._outerRadius-this._innerRadius,this._startAngle="startAngle"in e?e.startAngle:0,this._endAngle="endAngle"in e?e.endAngle:90,this._sr=de(this._startAngle),this._er=de(this._endAngle),this._direction="direction"in e?e.direction:re.ANTI_CLOCKWISE;let t=this._x+this._innerRadius*Math.cos(this._sr),r=this._y-this._innerRadius*Math.sin(this._sr),n=this._x+this._innerRadius*Math.cos(this._er),i=this._y-this._innerRadius*Math.sin(this._er),s=this._x+this._outerRadius*Math.cos(this._sr),a=this._y-this._outerRadius*Math.sin(this._sr),o=this._x+this._outerRadius*Math.cos(this._er),l=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[t,r],[s,a],[o,l],[n,i]])}get type(){return 0===this._innerRadius?Nt.Pie:Nt.Arc}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}get direction(){return this._direction}get x(){return this._x}get y(){return this._y}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}setAngles(e,t){this._startAngle=e,this._endAngle=t,this._sr=de(this._startAngle),this._er=de(this._endAngle),this.vertices[0]._x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0]._y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1]._x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1]._y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2]._x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2]._y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3]._x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3]._y=this._y-this._innerRadius*Math.sin(this._er)}_updateBounds(){let e=this.vertices.map((e=>e.x)),t=this.vertices.map((e=>e.y)),r=Math.min(...e),n=Math.min(...t),i=Math.max(...e)-r,s=Math.max(...t)-n;this._bounds=new d(r,n,i,s)}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._innerRadius=this._innerRadius,e._outerRadius=this._outerRadius,e._startAngle=this._startAngle,e._endAngle=this._endAngle,e._thickness=this._thickness,e._direction=this._direction,e._sr=this._sr,e._er=this._er}getSVGPathData(){let e=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,t=e>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,e,t,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,e,t,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}}function de(e){return e*Math.PI/180}function fe(e){return 180*e/Math.PI}function pe(e){return(e%360+360)%360}function _e(e,t,r,n){let i=e-r,s=n-t;return Math.atan2(s,i)*(180/Math.PI)}class ge{constructor(e){this._attr2value={},this._dt=e,this._tuples=this._dt.data}isFullTable(){return 0===Object.keys(this._attr2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get attributes(){return Object.keys(this._attr2value)}get dataTable(){return this._dt}get filters(){return this._attr2value}merge(e){let t=new ge(this._dt);for(let e in this._attr2value)t=t.cross(e,this._attr2value[e]);for(let r in e._attr2value)t=t.cross(r,e._attr2value[r]);return t}cross(e,t){if(e in this._attr2value&&this._attr2value[e]!==t)return console.warn("Conflict in attribute values when merging dataScope:",e,this._attr2value[e],t),this;let r=this.clone();return r._attr2value[e]=t,r._updateTuples(e,t),r}clone(){let e=new ge(this._dt);return e._attr2value=Object.assign({},this._attr2value),e._tuples=this._tuples.map((e=>e)),e}getAttributeValue(e){let t=this.getAttributeValues(e);return t.length,t[0]}getAttributeValues(e){let t=this._tuples.map((t=>t[e]));return t=[...new Set(t)],t}getUniqueAttributeValues(e){let t=this._tuples.map((t=>t[e]));return[...new Set(t)]}hasAttribute(e){return e in this._attr2value}getAttributeType(e){return this._dt.getAttributeType(e)}aggregateNumericalAttribute(e,t){let r=this._tuples.map((t=>t[e]));switch(t){case me.Max:return Math.max(...r);case me.Min:return Math.min(...r);case me.Avg:case me.Mean:return n.mean(r);case me.Median:return n.median(r);case me.Count:return r.length;case me.Percentile25:return n.quantile(r,.25);case me.Percentile75:return n.quantile(r,.75);case me.Sum:default:return n.sum(r)}}_updateTuples(e,t){this._tuples=this._tuples.filter((r=>r[e]==t))}get tuples(){return this._tuples}}function ye(e){return"vertex"==e.type||"segment"==e.type?e.dataScope?e.dataScope:e.parent.dataScope:e.dataScope}const me={Max:"max",Min:"min",Avg:"avg",Median:"median",Sum:"sum",Count:"count",Mean:"mean",Percentile25:"percentile 25",Percentile75:"percentile 75"};class be{constructor(e,t){this._id=Nt.TreeData+Vt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._data=e,this._nodeList=[],this._linkList=[],this._nodeHash={},this._traverse(e,this._nodeList,this._linkList),this._nodeTable=new Pt(this._nodeList,"nodes"),this._linkTable=new Pt(this._linkList,"links"),this._nodeTable.tree=this,this._linkTable.tree=this}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}_traverse(e,t,r,n=0){let i={};Ae in e||(e[Ae]="n"+t.length),t.push(i),e._depth=n;for(let s in e)if("children"==s&&e[s]&&e[s].length>0)for(let i of e[s]){let s=this._traverse(i,t,r,n+1);r.push({parent:e[Ae],child:s})}else i[s]=e[s];return this._nodeHash[i[Ae]]=i,i[Ae]}getNodeDataScope(e){return new ge(this._nodeTable).cross(Bt,e[Bt])}getNode(e){return this._nodeHash[e]}getRoot(){return this._nodeTable.data[0]}getChildren(e){let t=e[Ae],r=[],n=this._linkTable.data,i=this._nodeTable.data;for(let e in n)if(n[e].parent==t){let t=n[e].child,s=i.findIndex((e=>e[Ae]==t));r.push(i[s])}return r}getParent(e){let t=e[Ae],r=this._linkTable.data,n=this._nodeTable.data;for(let e in r)if(r[e].child==t){let t=r[e].parent,i=n.findIndex((e=>e[Ae]==t));return n[i]}}}function ve(e){return e.dataScope._dt.tree}class xe{constructor(e,t){this._id=Nt.NetworkData+Vt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._nodeTable=new Pt(e.nodes,this._id+"_nodes"),this._linkTable=new Pt(e.links,this._id+"_links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._rawNodes=e.nodes,this._rawLinks=e.links,this._nodeHash={};for(let t of e.nodes)this._nodeHash[t[Ae]]=t}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodeList(){return this._rawNodes}get linkList(){return this._rawLinks}getNode(e){return this._nodeHash[e]}getLinks(e){let t=e[Ae],r=this._rawLinks,n=[];for(let e in r)r[e].target!==t&&r[e].source!==t||n.push(r[e]);return n}buildNodeHierarchy(e){let t={};return t[Ae]="root",we(t,this._rawNodes,e),new be(t,this.url)}}function Ee(e){return e.dataScope._dt.graph}function we(e,t,r){if(0===t.length||0===r.length)return;"children"in e||(e.children=[]);let n={};for(let e of t){let t=e[r[0]];t in n||(n[t]=[]),n[t].push(e)}if(1===r.length)for(let t in n){let r={children:n[t]};r[Ae]=t,e.children.push(r)}else for(let t in n){let i={};i[Ae]=t,e.children.push(i),we(i,n[t],r.slice(1))}}const Ae="id";function Ce(e,t){if(t.hasAttribute(e))return!0;if(t.tree&&t.tree.nodeTable.hasAttribute(e.split(".")[1]))return!0;throw new Error(["Attribute",e,"does not exist in the table",t.name].join(" "))}const Re=Object.freeze({Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"});function ke(e){var t=Object.values(Re);for(let r=0;r<e.length;r++){let n=e[r];if(null!=n){for(let e=0;e<t.length;e++)Se[t[e]](n)||(t.splice(e,1),e-=1);if(1==t.length)return t[0]}}return t[0]}const Se={boolean:function(e){return"true"===e||"false"===e||!0===e||!1===e||"[object Boolean]"==toString.call(e)},integer:function(e){return Se.number(e)&&(e=+e)==~~e},number:function(e){return!isNaN(+e)&&"[object Date]"!=toString.call(e)},date:function(e){let t=new Date(e);return null!=t&&!isNaN(t)},string:function(e){return!0}};function Te(e,t){let r={};switch(t){case Re.Boolean:r.trueCount=e.filter((e=>e)).length,r.falseCount=e.filter((e=>!e)).length;break;case Re.Date:r.min=n.min(e),r.max=n.max(e),r.extent=[r.min,r.max],r.unique=[...new Set(e)];break;case Re.String:r.unique=[...new Set(e)];break;default:r.min=n.min(e),r.max=n.max(e),r.extent=[r.min,r.max],r.mean=n.mean(e),r.median=n.median(e),r.unique=[...new Set(e)]}return r}function Oe(e,t,r,n,i){let s=i.getAttributeType(r);if(s!=Re.String&&s!=Re.Date&&s!=Re.Number&&s!=Re.Integer)throw new Error("Densify only works on a string or date attribute: "+r+" is "+s);if(!function(e){if([Nt.Line,Nt.Circle,Nt.Rect,Nt.Area].indexOf(e.type)<0)return!1;if(e.dataScope){let t=I(e,e.scene);for(let e of t)if(e.dataScope.numTuples>1)return!0;return!1}return!0}(t))throw new Error("The "+t.type+" is not dividable");switch(t.type){case Nt.Line:return function(e,t,r){let n,i,s=I(e);for(let a of s){let s=a.dataScope?a.dataScope:new ge(r),o=r.getUniqueAttributeValues(t).map((e=>s.cross(t,e)));o=o.filter((e=>!e.isEmpty())),1===o.length&&o.push(o[0].clone());let l=Object.assign({},a.styles);for(let e of ie.styles)a[e]&&(l[e]=a[e]);let u=a.vertices[0].x,c=a.vertices[0].y,h=[],d=a.vertices[1].x-u,f=a.vertices[1].y-c;for(let e=0;e<o.length;e++)h.push([u+e*d/(o.length-1),c+e*f/(o.length-1)]);l.vertices=h,l.type="path";let p=kt(l);i||(i=p.id),p._classId=i,p.dataScope=s,p._updateBounds(),p._refBounds=p.bounds.clone();let _=a.parent;_.addChild(p),_.removeChild(a);for(let[e,t]of p.vertices.entries())t.dataScope?t.dataScope=t.dataScope.merge(o[e]):t.dataScope=o[e];a==e&&(n=p)}return n}(t,r,i);case Nt.Circle:return function(e,t,r,n,i){let s,a,o=I(e),l=r.getAttributeType(t);for(let u of o){let o=u.dataScope?u.dataScope:new ge(r),c=r.getUniqueAttributeValues(t).map((e=>o.cross(t,e)));c=l==Re.Number?c:c.filter((e=>!e.isEmpty()));let h=c.length;if(h<3)throw new Error("INSUFFICIENT_DATA_SCOPES");let d=n||90,f=360/h,p=[],_=[],g="clockwise"==(i||"clockwise")?-1:1;for(let e=0;e<c.length;e++){let t=d+g*e*f;_[e]=t;let r=Ie(u.x,u.y,u.radius,_[e]);p.push(r)}let y=Object.assign({},u.styles);y.vertices=p,y.type="polygon",y.x=u.x,y.y=u.y,y.radius=u.radius;let m=kt(y);a||(a=m.id),m._classId=a,m.dataScope=o;let b=u.parent;b.addChild(m),b.removeChild(u);for(let[e,t]of m.vertices.entries())t._polarAngle=_[e],e>=c.length?t.dataScope=o.merge(c[2*c.length-1-e]):t.dataScope=o.merge(c[e]);u===e&&(s=m)}return s}(t,r,i);case Nt.Rect:return function(e,t,r,n){let i,s,a=I(e),o=t||ee.HORIZONTAL;if(o!=ee.HORIZONTAL&&o!=ee.VERTICAL)throw new Error("Unknown orientation: "+o);for(let t of a){let a=n.getAttributeType(r),l=t.dataScope?t.dataScope:new ge(n),u=n.getUniqueAttributeValues(r).map((e=>l.cross(r,e)));u=a==Re.Number?u:u.filter((e=>!e.isEmpty())),1===u.length&&u.push(u[0].clone()),a!=Re.Number&&a!=Re.Date||u.sort(((e,t)=>e._attr2value[r]>t._attr2value[r]?1:-1));let c=Object.assign({},t.styles),h=t.vertices[0].x,d=t.vertices[0].y,f=t.vertices[t.vertices.length-2].x,p=t.vertices[t.vertices.length-2].y,_=[],g=f-h,m=p-d;for(let e=0;e<u.length;e++)_.push(o==ee.VERTICAL?[f,d+e*m/(u.length-1)]:[h+e*g/(u.length-1),d]);for(let e=0;e<u.length;e++)_.push(o==ee.VERTICAL?[h,d+(u.length-1-e)*m/(u.length-1)]:[h+(u.length-1-e)*g/(u.length-1),p]);c.vertices=_,c.type="area";let b=kt(c);s||(s=b.id),b._classId=s,b.dataScope=l,b.orientation=o,b.baseline=o===ee.HORIZONTAL?y.BOTTOM:y.LEFT;let v=t.parent;v.addChild(b),v.removeChild(t);for(let[e,t]of b.vertices.entries())e>=u.length?t.dataScope=l.merge(u[2*u.length-1-e]):t.dataScope=l.merge(u[e]);t===e&&(i=b)}return i}(t,n,r,i)}}function Ie(e,t,r,n){return[r*Math.cos(de(n))+e,t-r*Math.sin(de(n))]}class Ne extends K{constructor(e,t,r){super(e),this._channel=t,this._elem=r}get channel(){return this._channel}get element(){return this._elem}}const Le=Object.freeze({X:"x",Y:"y",WIDTH:"width",HEIGHT:"height",RADIUS:"radius",FILLCOLOR:"fillColor",STROKECOLOR:"strokeColor",FILLGRADIENT:"fillGradient",TEXT:"text",ANGLE:"angle",THICKNESS:"thickness",AREA:"area",FONTSIZE:"fontSize",RADIALDISTANCE:"radialDistance",STROKEWIDTH:"strokeWidth",OPACITY:"opacity",VISIBILITY:"visibility",STRENGTH:"strength"});function Ve(e,t){delete t._encodings[Me(e.element)][e.channel]}function Pe(e,t){let r=e.scene._encodings[Me(e)],n=[];if(r&&(n=n.concat(Object.values(r))),t){let t=e.scene;for(let r in t._encodings){let i=r.split("_");i.pop(),i.join("_")===e.classId&&(n=n.concat(Object.values(t._encodings[r])))}}return n}function De(e,t,r){for(let n in r._encodings){let i=r._encodings[n];if(i[t]&&i[t].attribute==e)return i[t]}return null}function Be(e,t){let r=e.scene._encodings[Me(e)];return r&&r[t]?r[t]:null}function Me(e){if(e.classId)return e.classId;if("vertex"==e.type&&e.dataScope){if(e.parent.type===Nt.Area){let t=e.parent.vertices.indexOf(e)<e.parent.vertices.length/2;return e.parent.classId+"_v"+(t?0:e.parent.vertices.length-1)}return e.parent.classId+"_v"}return"vertex"==e.type?e.parent.classId+"_v"+e.parent.vertices.indexOf(e):"segment"==e.type&&e.dataScope?e.parent.classId+"_s":"segment"==e.type?e.parent.classId+"_s"+e.parent.segments.indexOf(e):null}function Ge(e,t){if(0==e.children.length)return[];let r=M(e),n=e.type===Nt.Composite?e.children:[e.children[0]],i=Object.keys(r._encodings),s=[];for(let e of n){let t=e;for(;t;){if(t.classId&&s.indexOf(t.classId)<0&&s.push(t.classId),t.type===Nt.Glyph){t.children.forEach((e=>s.push(e.classId)));break}if(!t.children)break;t=t.children[0]}}let a=[];for(let e of i)for(let n of s)0===e.indexOf(n)&&r._encodings[e][t]&&a.push(r._encodings[e][t]);return a}function je(e){let t=Be(e,"y"),r=Be(e,"height");return t||r&&r.scales[0].domain[0]<0}function ze(e){let t=Be(e,"x"),r=Be(e,"width");return t||r&&r.scales[0].domain[0]<0}function Fe(e,t){let r=function(e){let t=e.parent,r=[];for(;t.type!==Nt.Scene;)r.push(t),t=t.parent;return r}(e);for(let e of r)if(Be(e,t))return!1;return r.length>=2?r[r.length-2]:e}function Ue(e,t,r){switch(e.type){case Nt.Rect:case Nt.Path:case Nt.Line:case Nt.Area:!function(e,t,r){for(let n of e.vertices)He(n,t,r);e._updateBounds(),e._refBounds&&e._refBounds.translate(t,r)}(e,t,r);break;case Nt.Group:case Nt.Collection:case Nt.Glyph:!function(e,t,r){for(let n of e.children)Ue(n,t,r);e._layout&&(void 0!==e._layout._left&&(e._layout._left+=t),void 0!==e._layout._top&&(e._layout._top+=r),e._layout._cellBounds&&e._layout._cellBounds.forEach((e=>e.translate(t,r))))}(e,t,r);break;case"segment":!function(e,t,r){He(e.vertex1,t,r),He(e.vertex2,t,r)}(e,t,r);break;default:!function(e,t,r){e._x+=t,e._y+=r,e._refBounds&&e._refBounds.translate(t,r)}(e,t,r)}}function He(e,t,r){e._x+=t,e._y+=r}function We(e,t,r){switch(t){case"x":Xe(e,r);break;case"y":qe(e,r);break;case"width":!function(e,t){e.resize(t,e.height)}(e,r);break;case"height":!function(e,t){e.resize(e.width,t)}(e,r);break;case"radius":e.radius=r;break;case"strength":e._strength=r;break;case"area":e.type===Nt.Circle?e.radius=Math.sqrt(r/Math.PI):e.type===Nt.Rect&&e.resize(Math.sqrt(r),Math.sqrt(r)),e._updateBounds();break;case"text":e._text=r;break;case"curveMode":e.curveMode=r;break;case"baseline":e.baseline=r;break;case"angle":[Nt.Arc,Nt.Pie].includes(e.type)&&function(e,t){e._endAngle=pe(e._startAngle+t),e._sr=de(e._startAngle),e._er=de(e._endAngle),e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,r);break;case"startAngle":!function(e,t){let r=e.angle;e._startAngle=t,e._endAngle=pe(e._startAngle+r),e._sr=de(e._startAngle),e._er=de(e._endAngle),e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,r);break;case"thickness":!function(e,t){Ye(e,e._innerRadius+t)}(e,r);break;case"innerRadius":!function(e,t){e._innerRadius=t,e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,r);break;case"outerRadius":Ye(e,r);break;case"radialDistance":{let t=Ie(e.parent.x,e.parent.y,r,e.polarAngle);Xe(e,t[0]),qe(e,t[1]);break}case"visibility":e.visibility=r;break;default:if("vertex"===e.type)e[t]=r;else if(e instanceof yt)for(let n of e.children)We(n,t,r);else e.styles[t]=r}}function Ye(e,t){e._outerRadius=t,e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er)}function Xe(e,t){"vertex"==e.type?e._x=t:Ue(e,t-e.x,0)}function qe(e,t){"vertex"==e.type?e._y=t:Ue(e,0,t-e.y)}class Ke extends ae{constructor(e){super(e)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}resize(e,t,r,n){e!==this.width&&("right"===r?(this.vertices[1]._x=this.refBounds.right,this.vertices[2]._x=this.refBounds.right,this.vertices[0]._x=this.vertices[1]._x-e,this.vertices[3]._x=this.vertices[0]._x):(this.vertices[0]._x=this.refBounds.left,this.vertices[3]._x=this.refBounds.left,this.vertices[1]._x=this.vertices[0]._x+e,this.vertices[2]._x=this.vertices[1]._x)),t!==this.height&&("top"===n?(this.vertices[0]._y=this.refBounds.top,this.vertices[1]._y=this.refBounds.top,this.vertices[3]._y=this.vertices[0]._y+t,this.vertices[2]._y=this.vertices[3]._y):(this.vertices[2]._y=this.refBounds.bottom,this.vertices[3]._y=this.refBounds.bottom,this.vertices[0]._y=this.vertices[3]._y-t,this.vertices[1]._y=this.vertices[0]._y))}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class Ze extends ae{constructor(e){super(e),this._type=Nt.Area,this.closed=!0,this._orientation="orientation"in e?e.orientation:void 0,this._baseline="baseline"in e?e.baseline:void 0,e&&"vertices"in e&&this.segments.push(new se(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get topLeftVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[0]:this.vertices[this.vertices.length-1]}get bottomLeftVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[this.vertices.length-1]:this.vertices[this.vertices.length/2]}get topRightVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[this.vertices.length/2-1]:this.vertices[0]}get bottomRightVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[this.vertices.length/2]:this.vertices[this.vertices.length/2-1]}get baseline(){return this._baseline}set baseline(e){this._baseline=e}get orientation(){return this._orientation}set orientation(e){this._orientation=e}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(e){super.copyPropertiesTo(e),e._baseline=this._baseline,e._orientation=this._orientation}getSVGPathData(){return super.getSVGPathData()+" z"}}class $e extends K{constructor(e,t){super(e),this._encs=[t],this._initialized=!1}addLinkedEncoding(e){this._encs.push(e)}get encodings(){return this._encs}get initialized(){return this._initialized}set initialized(e){this._initialized=e}}class Je{constructor(e,t){this._event=t,this._type=e}get event(){return this._event}get type(){return this._type}}const Qe=Object.freeze({ELEMENT:"element",MOUSE:"mouse",ATTRIBUTE:"attribute",WIDGET:"widget",KEYBOARD:"keyboard"});Object.freeze({INPUT:"input",HOVER:"hover",BRUSH:"brush",BRUSH_X:"brushX",BRUSH_Y:"brushY",CLICK:"click"});class et extends X{constructor(e){super(e)}storeValues(e,t){this._storedValues={};let r=I(e);for(let e of r)this._storedValues[e.id]=e[t]}_restoreValues(e){let t=this.outputVar.channel;e.forEach((e=>{e.styles[t]=this._storedValues[e.id]}))}run(){super.run();let e=this.inputVars.find((e=>e instanceof $e)),t=this.outputVar,r=I(t.element);if(e){let r=e.encodings.find((e=>e.channel==t.channel&&Me(e.element)==Me(t.element)));for(let e of r.scales){let t=r.getElements(e);this._doMapping(t,e,r.attrValues,r),this._updateRefBounds(t,e,r)}}else this._restoreValues(r);let n=this._getUsableCondEncodings();n.length>0&&this._doCondEncoding(r,n.map((e=>e.condEncoding))),g(["vertex","segment"].includes(t.element.type)?t.element.parent:t.element)}_updateRefBounds(e,t,r){switch(this.outputVar.channel){case"width":e.forEach((e=>{e._refBounds.setWidth(t.rangeExtent)}));break;case"height":e.forEach((e=>{e._refBounds.setHeight(t.rangeExtent)}));break;case"radius":e.forEach((e=>{e._refBounds.setWidth(2*t.rangeExtent,y.CENTER),e._refBounds.setHeight(2*t.rangeExtent,y.MIDDLE)}));break;case"x":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let n=e.parent._refBounds;e.parent._refBounds=new d(r.flipScale?t.range[1]:t.range[0],n.top,t.rangeExtent,n.height)}));break;case"y":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let n=e.parent._refBounds;e.parent._refBounds=new d(n.left,r.flipScale?t.range[0]:t.range[1],n.width,t.rangeExtent)}))}}_doMapping(e,t,r,n){switch(this.outputVar.channel){case"width":t.domain[0]<0&&e[0]instanceof Ke?function(e,t,r){for(let n=0;n<e.length;n++){let i=e[n],s=i.refBounds.left+t.map(0),a=i.refBounds.left+t.map(r[i.id]);Ue(i.leftSegment,s-i.leftSegment.x,0),Ue(i.rightSegment,a-i.rightSegment.x,0)}}(e,t,r):t.domain[0]<0&&e[0]instanceof Ze||(e[0].type===Nt.Area?function(e,t,r){let n=e[0].baseline;if(e[0].orientation===ee.VERTICAL)switch(n){case"left":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"x",n.refBounds.left))),I(n.topRightVertex,n).forEach((e=>We(e,"x",n.refBounds.left+t.map(r[e.id]))));break;case"right":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"x",n.refBounds.right-t.map(r[e.id])))),I(n.topRightVertex,n).forEach((e=>We(e,"x",n.refBounds.right)));break;case"center":console.log("center");for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"x",n.refBounds.center-t.map(r[e.id])/2))),I(n.topRightVertex,n).forEach((e=>We(e,"x",n.refBounds.center+t.map(r[e.id])/2)))}}(e,t,r):this._doStandardMapping(e,t,r));break;case"height":t.domain[0]<0&&e[0]instanceof Ke?function(e,t,r){for(let n=0;n<e.length;n++){let i=e[n],s=i.refBounds.bottom-t.map(0),a=i.refBounds.bottom-t.map(r[i.id]);Ue(i.bottomSegment,0,s-i.bottomSegment.y),Ue(i.topSegment,0,a-i.topSegment.y)}}(e,t,r):t.domain[0]<0&&e[0]instanceof Ze?function(e,t,r){for(let n of e){let e=N(n.topLeftVertex,[n]);for(let i of e)We(i,"y",n.refBounds.bottom-t.map(r[i.id]));N(n.bottomLeftVertex,[n]).forEach((e=>We(e,"y",n.refBounds.bottom-t.map(0))))}}(e,t,r):e[0].type===Nt.Area?function(e,t,r){let n=e[0].baseline;if(e[0].orientation===ee.HORIZONTAL)switch(n){case"bottom":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.bottom-t.map(r[e.id])))),I(n.bottomLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.bottom)));break;case"top":for(let n of e)I(n.bottomLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.top+t.map(r[e.id])))),I(n.topLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.top)));break;case"middle":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.middle-t.map(r[e.id])/2))),I(n.bottomLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.middle+t.map(r[e.id])/2)))}}(e,t,r):this._doStandardMapping(e,t,r);break;case"text":this._doTextMapping(e,r);break;case"fillGradient":!function(e,t,r,n){for(let i of e){let e=i.vertices.map((e=>r[e.id])),s=Math.min(...e),a=Math.max(...e),o="horizontal"===i.orientation?new E({x1:0,y1:100,x2:0,y2:0}):new E({x1:0,y1:0,x2:100,y2:0});if(o.addStop(0,t.map(s),1),n._mapping){let e=Object.keys(n._mapping).map((e=>parseFloat(e))).sort();for(let r of e)r>s&&r<a&&o.addStop(100*(r-s)/(a-s),t.map(r),1)}else"divergingColor"===t.type&&o.addStop(100*-s/(a-s),t.map(0),1);"sequentialColor"===t.type&&o.addStop(100*-s/(a-s),t.map(0),1),o.addStop(100,t.map(a),1),i.fillColor=o}}(e,t,r,n);break;default:this._doStandardMapping(e,t,r)}}_doTextMapping(e,t){let r=this.outputVar.channel;e.forEach((e=>{We(e,r,t[e.id])}))}_doStandardMapping(e,t,r){let n=this.outputVar.channel;e.forEach((e=>{let i=t.map(r[e.id]);We(e,n,i),e instanceof ae&&e.firstVertex&&e.firstVertex.shape&&"strokeColor"===n&&e.vertices.forEach((e=>e.fillColor=i))}))}_doCondEncoding(e,t){for(let r of e){let e=t.map((e=>e.evalResult[r.id])).every((e=>e||void 0===e));t[0]._efxFn(e,t[0].trigger.elements[0],r,t[0].trigger.mouseEvent)}}_updateElement(e,t,r,n){let i;"object"==typeof n&&e.triggerElement?"property"in n?i=e.triggerElement[n.property]:"attribute"in n&&(i=e.triggerElement.dataScope.getAttributeValue(n.attribute)):i=n,["x","y"].includes(r)&&"offset"in n&&(i+=n.offset),We(t,r,i)}_getUsableCondEncodings(){return this.inputVars.filter((e=>e instanceof $))}}class tt extends K{constructor(e,t,r){super(e),this._property=t,this._elem=r}get property(){return this._property}get element(){return this._elem}}const rt=Object.freeze({AXIS_ORIENTATION:"axisOrientation",AXIS_PATH_POSITION:"axisPathPosition",AXIS_TICK_SIZE:"axisTickSize",AXIS_TICK_OFFSET:"axisTickOffset",AXIS_TICKS_POSITION:"axisTicksPosition",AXIS_LABELS_POSITION:"axisLabelsPosition",AXIS_TITLE_POSITION:"axisTitlePosition",AXIS_LABEL_OFFSET:"axisLabelOffset",AXIS_LABEL_FORMAT:"axisLabelFormat",AXIS_FONT_SIZE:"axisFontSize",LEGEND_POSITION:"legendPosition",GRIDLINES_POSITION:"gridlinesPosition",INCLUDE_ZERO:"includeZero",FLIP_SCALE:"flipScale",RANGE_START:"rangeStart",RANGE_EXTENT:"rangeExtent",BASE_LINE:"baseline"});function nt(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.createOneWayDependency(q.EVAL_BBOX);switch(t.connect(n,r),e.type){case Nt.Circle:case Nt.Polygon:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"radius",e),a=t.getVariable(Z.CHANNEL,"area",e);t.connect(s,n),t.connect(r,n),t.connect(i,n),t.connect(a,n);break}case Nt.Area:case Nt.Line:case Nt.BezierCurve:case Nt.Path:case Nt.Image:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n);break}case Nt.Rect:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e),o=t.getVariable(Z.CHANNEL,"area",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n),t.connect(o,n);break}case Nt.PointText:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"text",e);t.connect(r,n),t.connect(i,n),t.connect(s,n);break}case Nt.Ring:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"innerRadius",e),a=t.getVariable(Z.CHANNEL,"outerRadius",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n);break}case Nt.Pie:case Nt.Arc:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"innerRadius",e),a=t.getVariable(Z.CHANNEL,"outerRadius",e),o=t.getVariable(Z.CHANNEL,"startAngle",e),l=t.getVariable(Z.CHANNEL,"endAngle",e),u=t.getVariable(Z.CHANNEL,"angle",e),c=t.getVariable(Z.CHANNEL,"thickness",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n),t.connect(o,n),t.connect(l,n),t.connect(u,n),t.connect(c,n);break}}n.run()}function it(e,t){let r=t.findVariablesByElement(e);for(let e in r){let n=r[e];for(let e of n)t.deleteVariable(e)}}function st(e,t){let r=t.findVariable(Z.CHANNEL,[e.channel,e.element]);r||console.warn("cannot find encoding to remove from the dep graph");let n=r.incomingDataflow;t.deleteOperator(n)}function at(e,t){if(e.type===Nt.Axis){let r=t.findVariable(Z.PROPERTY,[rt.AXIS_PATH_POSITION,e]).incomingDataflow;t.deleteOperator(r),r=t.findVariable(Z.PROPERTY,[rt.AXIS_TICKS_POSITION,e]).incomingDataflow,t.deleteOperator(r),r=t.findVariable(Z.PROPERTY,[rt.AXIS_LABELS_POSITION,e]).incomingDataflow,t.deleteOperator(r)}else if(e.type===Nt.Gridlines){let r=t.findVariable(Z.PROPERTY,[rt.GRIDLINES_POSITION,e]).incomingDataflow;t.deleteOperator(r)}}function ot(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e),o=t.createOneWayDependency(q.EVAL_BBOX);t.connect(n,o),t.connect(i,o),t.connect(s,o),t.connect(a,o),t.connect(o,r),o.run()}function lt(e,t,r){let n=r.getVariable(Z.BOUNDS,e),i=r.getVariable(Z.BOUNDS,t),s=r.getIncomingDataflowOperator(q.EVAL_BBOX,n),a=i.outgoingEdges.find((e=>e.fromNode===i&&e.toNode===s));if(a&&r.disconnect(i,s,a),e.layout){let n=r.getVariable(Z.CHANNEL,"x",t),i=r.getIncomingDataflowOperator(ct(e.layout.type),n);i&&r.deleteOperator(i)}}function ut(e,t,r){let n=r.getVariable(Z.BOUNDS,e),i=r.getVariable(Z.BOUNDS,t),s=r.getIncomingDataflowOperator(q.EVAL_BBOX,n);r.connect(i,s),r.connect(s,n),e.layout&&dt(e,e.layout,r)}function ct(e){switch(e){case W.GRID:return q.GRID_LAYOUT;case W.STACK:return q.STACK_LAYOUT;case W.PACKING:return q.PACK_LAYOUT;case W.FORCE:return q.FORCE_LAYOUT;case W.DIRECTED:return q.DIRECTED_LAYOUT;case W.TIDYTREE:return q.TIDY_TREE_LAYOUT;case W.TREEMAP:return q.TREEMAP_LAYOUT;case W.STRATA:return q.STRATA_LAYOUT;case W.CIRCULAR:return q.CIRCULAR_LAYOUT;case W.CLUSTER:return q.CLUSTER_LAYOUT}}function ht(e,t,r){let n=r.getVariable(Z.ORDER,e),i=r.getOutgoingDataflowOperator(ct(t.type),n);r.deleteOperator(i)}function dt(e,t,r){let n=t?t.type:"none",i=n===W.TREEMAP?F(e)[0]:e.children[0];if(!i)return;let s=r.getVariable(Z.CHANNEL,"width",i),a=r.getVariable(Z.CHANNEL,"height",i),o=r.getVariable(Z.ORDER,e),l=r.getVariable(Z.CHANNEL,"x",i),u=r.getVariable(Z.CHANNEL,"y",i),c=r.getOutgoingDataflowOperator(ct(n),o);if(r.connect(s,c),r.connect(a,c),r.connect(o,c),r.connect(c,l),r.connect(c,u),r.disconnectChannelVarFromBBoxOperator(s),r.disconnectChannelVarFromBBoxOperator(a),i.type===Nt.Arc||i.type===Nt.Pie){let e=r.getVariable(Z.CHANNEL,"angle",i),t=r.getVariable(Z.CHANNEL,"thickness",i);r.connect(e,c),r.connect(t,c)}else if(i.type===Nt.Circle){let e=r.getVariable(Z.CHANNEL,"area",i),t=r.getVariable(Z.CHANNEL,"radius",i);r.connect(e,c),r.connect(t,c),r.disconnectChannelVarFromBBoxOperator(e),r.disconnectChannelVarFromBBoxOperator(t)}else if(i.type===Nt.Rect){let e=r.getVariable(Z.CHANNEL,"area",i);r.connect(e,c),r.disconnectChannelVarFromBBoxOperator(e)}if(c.run(),i.links&&ft(i,r),i.children&&i.children[0]){let e=r.getVariable(Z.BOUNDS,i.children[0]),t=r.getVariable(Z.CHANNEL,"x",i).incomingDataflow;t&&r.connect(e,t),r.disconnectChannelVarFromBBoxOperator(e)}}function ft(e,t){let r=e.links[0],n=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"x",r),s=t.getVariable(Z.CHANNEL,"strokeWidth",r),a=t.getVariable(Z.CHANNEL,"strength",r),o=t.createOneWayDependency(q.LINK_PLACER);t.connect(n,o),t.connect(s,o),t.connect(a,o),t.connect(o,i)}function pt(e,t){let r=t.getVariable(Z.PROPERTY,rt.AXIS_ORIENTATION,e),n=t.getVariable(Z.BOUNDS,e.elements[0].parent),i=t.getVariable(Z.PROPERTY,rt.AXIS_PATH_POSITION,e),s=t.createOneWayDependency(q.AXIS_PATH_PLACER);t.connect(r,s),t.connect(n,s),t.connect(s,i),s.run();let a=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_OFFSET,e),o=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(q.AXIS_TICKS_PLACER),u=t.getVariable(Z.PROPERTY,rt.AXIS_TICKS_POSITION,e);t.connect(i,l),t.connect(a,l),t.connect(o,l),t.connect(l,u),l.run();let c=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_OFFSET,e),h=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_FORMAT,e),d=t.getVariable(Z.PROPERTY,rt.AXIS_FONT_SIZE,e),f=t.createOneWayDependency(q.AXIS_LABELS_PLACER),p=t.getVariable(Z.PROPERTY,rt.AXIS_LABELS_POSITION,e);t.connect(i,f),t.connect(c,f),t.connect(h,f),t.connect(d,f),t.connect(f,p),f.run();let _=t.getVariable(Z.PROPERTY,rt.AXIS_TITLE_POSITION,e),g=t.createOneWayDependency(q.AXIS_TITLE_PLACER);t.connect(i,g),t.connect(g,_),g.run();let y=t.getVariable(Z.BOUNDS,e),m=t.getIncomingDataflowOperator(q.EVAL_BBOX,y);t.connect(u,m),t.connect(p,m),t.connect(m,y)}function _t(e,t){let r=t.getVariable(Z.PROPERTY,rt.AXIS_ORIENTATION,e),n=t.getVariable(Z.BOUNDS,G(e.elements[0])),i=t.getVariable(Z.PROPERTY,rt.AXIS_PATH_POSITION,e),s=t.createOneWayDependency(q.AXIS_PATH_PLACER);t.connect(r,s),t.connect(n,s),t.connect(s,i),s.run();let a=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_OFFSET,e),o=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(q.AXIS_TICKS_PLACER),u=t.getVariable(Z.PROPERTY,rt.AXIS_TICKS_POSITION,e);t.connect(i,l),t.connect(a,l),t.connect(o,l),t.connect(l,u),l.run();let c=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_OFFSET,e),h=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_FORMAT,e),d=t.getVariable(Z.PROPERTY,rt.AXIS_FONT_SIZE,e),f=t.createOneWayDependency(q.AXIS_LABELS_PLACER),p=t.getVariable(Z.PROPERTY,rt.AXIS_LABELS_POSITION,e);t.connect(i,f),t.connect(c,f),t.connect(h,f),t.connect(d,f),t.connect(f,p),f.run();let _=t.getVariable(Z.PROPERTY,rt.AXIS_TITLE_POSITION,e),g=t.createOneWayDependency(q.AXIS_TITLE_PLACER);t.connect(i,g),t.connect(g,_),g.run();let y=t.getVariable(Z.BOUNDS,e),m=t.getIncomingDataflowOperator(q.EVAL_BBOX,y);t.connect(u,m),t.connect(p,m),t.connect(m,y)}function gt(e,t){let r=t.getVariable(Z.BOUNDS,G(e.elements[0])),n=t.getVariable(Z.PROPERTY,rt.GRIDLINES_POSITION,e),i=t.createOneWayDependency(q.GRIDLINES_PLACER);t.connect(r,i),t.connect(i,n),i.run();let s=t.getVariable(Z.BOUNDS,e),a=t.getIncomingDataflowOperator(q.EVAL_BBOX,s);t.connect(n,a),t.connect(a,s)}class yt{constructor(){this._id=this.type+Vt(),this._type=Nt.Group,this._dataScope=void 0,this._bounds=void 0,this._layout=void 0,this._children=[],this._sortBy={}}get id(){return this._id}get type(){return this._type}contains(e,t){return this.bounds.contains(e,t)}get children(){return this._children}addChild(e){this.children.indexOf(e)>=0||(e.parent&&e.parent.removeChild(e),this.children.push(e),e.parent=this)}addChildAt(e,t){e.parent&&e.parent.removeChild(e),this.children.splice(t,0,e),e.parent=this}removeChild(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=null)}removeChildAt(e){this.children[e].parent=null,this.children.splice(e,1)}removeAll(){for(let e of this.children)e.parent=null;this._children=[]}get dataScope(){return this._dataScope}set dataScope(e){if(this._dataScope=e,void 0===e)for(let t of this.children)t.dataScope=e;else for(let t of this.children)t.dataScope?t.dataScope=t.dataScope.merge(e):t.dataScope=e}getInternalEncodings(e){if(0==this.children.length)return[];let t=this.children[0],r=this.getScene(),n=Object.keys(r.encodings),i=[];for(;t;){if(t.classId&&i.indexOf(t.classId)<0&&i.push(t.classId),t.type===Nt.Glyph){t.children.forEach((e=>i.push(e.classId)));break}if(!t.children)break;t=t.children[0]}let s=[];for(let t of n){let n=t.split("_");for(let a of i)n[0]==a&&r.encodings[t][e]&&s.push(r.encodings[t][e])}return s}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(e){if(this._layout=e,e&&(e.group=this),dt(this,e,this.scene._depGraph),this.children&&this.children.length>0){let e=F(this,!0);for(let t of e)this.scene.onChange(Z.CHANNEL,"x",t)}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let e=this.children.map((e=>e.refBounds)),t=Math.min(...e.map((e=>e.left))),r=Math.min(...e.map((e=>e.top))),n=Math.max(...e.map((e=>e.right))),i=Math.max(...e.map((e=>e.bottom)));return new d(t,r,n-t,i-r)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){let e=this.children;if(e.length>0){this._bounds=e[0].bounds.clone();for(let t=1;t<e.length;t++)"hidden"!=e[t].visibility&&(this._bounds=this._bounds.union(e[t].bounds))}else this._bounds=new d(0,0,0,0)}set visibility(e){this._visibility="hidden"==e?e:"visible";for(let t of this.children)t.visibility=e}get visibility(){return this._visibility?this._visibility:"visible"}get scene(){return M(this)}}class mt extends yt{constructor(){super(),this._type=Nt.Collection,this._id=this.type+"_"+Vt(),this._classId=this.id,this._childrenOrder=void 0}get classId(){return this._classId}contains(e,t){if([Nt.Arc,Nt.Pie,Nt.Polygon,Nt.Area].indexOf(this.firstChild.type)>=0){let r=this.getSVGPathData();if(""!==r){let n=i.getContext(),s=new Path2D(r);return n.lineWidth=Math.max(this.strokeWidth,2.5),n.stroke(s),n.isPointInPath(s,e,t)}}return this._bounds.contains(e,t)}getSVGPathData(){let e="";for(let t of this.children)if(t.getSVGPathData)e+=t.getSVGPathData();else if(t.bounds){let r=t.bounds;e+=["M",r.left,r.top].join(" "),e+=["L",r.right,r.top].join(" "),e+=["L",r.right,r.bottom].join(" "),e+=["L",r.left,r.bottom,"Z"].join(" ")}return e}}class bt extends yt{constructor(e){if(super(),this._type=Nt.Glyph,this._id=this.type+"_"+Vt(),this._classId=this._id,e)for(let t of e)this.addChild(t)}get classId(){return this._classId}}class vt extends ae{constructor(e){super(e),this._type=Nt.BezierCurve,this._orientation="orientation"in e?e.orientation:ee.HORIZONTAL}get type(){return this._type}get orientation(){return this._orientation}copyPropertiesTo(e){super.copyPropertiesTo(e),e._orientation=this._orientation}getSVGPathData(){if(this._d)return this._d;let e="M ";return e+=this.vertices[0].x+" "+this.vertices[0].y+" ",e+="C "+this.vertices[1].x+" "+this.vertices[1].y+" ",e+=this.vertices[2].x+" "+this.vertices[2].y+" ",e+=this.vertices[3].x+" "+this.vertices[3].y,e}}class xt extends w{constructor(e){super(e),this._type=Nt.Circle,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._radius="radius"in e?e.radius:100,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}set radius(e){this._radius=e}get area(){return Math.PI*Math.pow(this._radius,2)}_updateBounds(){if(this._rotate){let e=S(this._x,this._y,this._rotate[1],this._rotate[2],this._rotate[0]);this._bounds=new d(e.x-this._radius,e.y-this._radius,2*this._radius,2*this._radius)}else this._bounds=new d(this._x-this._radius,this._y-this._radius,2*this._radius,2*this._radius)}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._radius=this._radius}getSVGPathData(){return["M",this._x,this._y,"m",-this._radius,", 0 a",this._radius,",",this._radius,"0 1,0",2*this._radius,",0 a",this._radius,",",this._radius,"0 1,0",-2*this._radius,",0"].join(" ")}}class Et extends w{constructor(e){super(e),this._type=Nt.Image,this._src=e.src,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._width="width"in e?e.width:100,this._height="height"in e?e.height:100}get src(){return this._src}set src(e){this._src=e}get width(){return this._width}set width(e){this._width=e,this._updateBounds()}get height(){return this._height}set height(e){this._height=e,this._updateBounds()}get x(){return this._x}set x(e){this._x=e,this._updateBounds()}get y(){return this._y}set y(e){this._y=e,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new d(this._x,this._y,this._width,this._height)}copyPropertiesTo(e){e.attrs=Object.assign({},this.attrs),e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e.x=this._x,e.y=this._y,e.width=this._width,e.height=this._height,e.src=this._src}}class wt extends ae{constructor(e){super(e)}get x1(){return this.vertices[0].x}get y1(){return this.vertices[0].y}get x2(){return this.vertices[1].x}get y2(){return this.vertices[1].y}get x(){return(this.vertices[0].x+this.vertices[1].x)/2}get y(){return(this.vertices[0].y+this.vertices[1].y)/2}set x(e){let t=e-this.x;this.vertices[0]._x+=t,this.vertices[1]._x+=t}set y(e){let t=e-this.y;this.vertices[0]._y+=t,this.vertices[1]._y+=t}set x1(e){this.vertices[0]._x=e}set x2(e){this.vertices[1]._x=e}set y1(e){this.vertices[0]._y=e}set y2(e){this.vertices[1]._y=e}}class At extends w{constructor(e){super(e),this._type=Nt.PointText,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._text="text"in e?e.text:"",this._anchor="anchor"in e?e.anchor:[y.CENTER,y.MIDDLE],this._textPath=void 0,this._textPathOffset="50%","fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in e&&(this._backgroundColor=e.backgroundColor),"borderWidth"in e&&(this._borderWidth=e.borderWidth),"borderColor"in e&&(this._borderColor=e.borderColor),this._rotate="rotate"in e?e.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let e,t,r=function(e,t,r){let n=O.getContext();n.font=t;let i=n.measureText(e);return i.fontBoundingBoxAscent?{width:i.width,height:i.fontBoundingBoxAscent+i.fontBoundingBoxDescent}:i.actualBoundingBoxAscent?{width:i.width,height:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent}:{width:i.width,height:r}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),n=r.width,i=r.height;switch(this._anchor[0]){case y.LEFT:e=this._x;break;case y.RIGHT:e=this._x-n;break;case y.CENTER:e=this._x-n/2;break;default:e=this._x}switch(this._anchor[1]){case y.TOP:t=this._y;break;case y.BOTTOM:t=this._y-i;break;case y.MIDDLE:default:t=this._y-i/2}if(this._rotate&&3===this._rotate.length){let r=[{x:e,y:t},{x:e+n,y:t},{x:e,y:t+i},{x:e+n,y:t+i}].map((e=>S(e.x,e.y,this._rotate[1],this._rotate[2],this._rotate[0]))),s=Math.min(...r.map((e=>e.x))),a=Math.max(...r.map((e=>e.x))),o=Math.min(...r.map((e=>e.y))),l=Math.max(...r.map((e=>e.y)));this._bounds=new d(s,o,a-s,l-o)}else this._bounds=new d(e,t,n,i)}get x(){return this._x}get y(){return this._y}get text(){return this._text}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}get textPath(){return this._textPath}get textPathOffset(){return this._textPathOffset}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e._x=this._x,e._y=this._y,e._text=this._text,e._anchor=[this._anchor[0],this._anchor[1]],e._backgroundColor=this._backgroundColor,e._borderColor=this._borderColor,e._borderStroke=this._borderStroke}}class Ct extends ae{constructor(e){super(e),this._type=Nt.Polygon,this.closed=!0,"x"in e&&(this._x=e.x),"y"in e&&(this._y=e.y),"radius"in e&&(this._radius=e.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._radius=this._radius}}class Rt extends ae{constructor(e){super(e),this._type=Nt.Ring,this.closed=!0,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._innerRadius="innerRadius"in e?e.innerRadius:100,this._outerRadius="outerRadius"in e?e.outerRadius:200}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get x(){return this._x}get y(){return this._y}get thickness(){return this._outerRadius-this._innerRadius}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._innerRadius=this._innerRadius,e._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}function kt(e){let t=null;switch(e.type){case Nt.Circle:t=new xt(e);break;case Nt.Line:var r="x1"in e?e.x1:0,n="y1"in e?e.y1:0,i="x2"in e?e.x2:100,s="y2"in e?e.y2:100;e.vertices=[[r,n],[i,s]],t=new wt(e);break;case Nt.Rect:var a="top"in e?e.top:0,o="left"in e?e.left:0,l="width"in e?e.width:50,u="height"in e?e.height:30;e.vertices=[[o,a],[o+l,a],[o+l,a+u],[o,a+u]],t=new Ke(e);break;case Nt.PointText:t=new At(e);break;case Nt.Image:t=new Et(e);break;case Nt.BundledPath:case Nt.Chord:case Nt.Path:t=new ae(e);break;case Nt.Area:t=new Ze(e);break;case Nt.Ring:t=new Rt(e);break;case Nt.Arc:t=new he(e);break;case Nt.BezierCurve:"vertices"in e||(e.vertices=[[0,100],[20,120],[80,180],[100,200]]),t=new vt(e);break;case Nt.Polygon:t=new Ct(e)}return t&&t._updateBounds(),t}function St(e){let t=new mt;return e.addChild(t),e._itemMap[t.id]=t,t}function Tt(e){return new bt(e)}function Ot(e){switch(e.type){case Nt.Collection:return function(e){let t=St(e.scene);for(let r=0;r<e.children.length;r++){let n=e.children[r];t.addChild(Ot(n))}if(t._classId=e.classId,e._layout){let r=e._layout.clone();t._layout=r,r.group=t}return t._updateBounds(),t}(e);case Nt.Glyph:return function(e){let t=new bt;for(let r of e.children)t.addChild(Ot(r));t._classId=e.classId,e._dataScope&&(t.dataScope=e._dataScope.clone());return t}(e);default:return function(e){let t=kt({type:e.type});e.copyPropertiesTo(t),t._classId=e.classId,t._bounds=e.bounds.clone(),e._refBounds||(e._refBounds=e.bounds.clone());t._refBounds=e._refBounds.clone(),e.dataScope&&(t._dataScope=e.dataScope.clone());if(e.vertices)for(let r=0;r<e.vertices.length;r++)e.vertices[r].dataScope&&(t.vertices[r]._dataScope=e.vertices[r].dataScope.clone());return t}(e)}}const It=Object.freeze({Rect:"rect",Circle:"circle",Line:"line",Ring:"ring",Path:"path",Image:"image",PointText:"text",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord"}),Nt=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Line:"line",Path:"path",Image:"image",PointText:"text",Collection:"collection",Group:"group",Composite:"composite",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable",Layout:"layout",NetworkData:"networkdata",TreeData:"treedata"}),Lt=Object.freeze({Axis:"axis",Legend:"legend",Gridlines:"gridlines"});function Vt(){return Date.now().toString(36)+"_"+Math.random().toString(36).slice(2)}class Pt{constructor(e,t,r){this._id=Nt.DataTable+Vt(),this.initialize(e,t,r)}initialize(e,t,r){if(this.url=t,this._rawData=JSON.parse(JSON.stringify(e)),this._data=e,this._dateMap=new Map,this._attributes=0===this._data.length?[]:Object.keys(this._data[0]),this._newAttribute=0,r)this._attrTypes=r;else{this._attrTypes={};for(let e of this._attributes)this._attrTypes[e]=ke(this.data.map((t=>t[e]))),"year"==e.toLowerCase()&&this._attrTypes[e]==Re.Integer&&(this._attrTypes[e]=Re.Date)}this._validate(this.data,this._attrTypes),this._attrSummaries={};for(let e of this._attributes)this._attrSummaries[e]=Te(this.data.map((t=>t[e])),this._attrTypes[e]);this._attributes.indexOf(Bt)<0&&this._addAttribute(Bt,Re.String,this.data.map(((e,t)=>"r"+t)))}clone(){let e=[];for(let t of this._data)e.push(Object.assign({},t));let t=new Pt(e,this.url,Object.assign({},this._attrTypes));return t.sourceDataTable=this,t}get id(){return this._id}get name(){return this.url?function(e){var t=e.indexOf("\\")>=0?e.lastIndexOf("\\"):e.lastIndexOf("/"),r=e.substring(t);0!==r.indexOf("\\")&&0!==r.indexOf("/")||(r=r.substring(1));return r}(this.url):this.id}get data(){return this._data}getEncodableAttributes(e){switch(e){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.numericAttributes.concat(this.nonNumericAttributes);default:return this.numericAttributes}}_addAttribute(e,t,r){this._data.forEach(((t,n)=>t[e]=r[n])),e!==Bt&&this._rawData.forEach(((t,n)=>t[e]=r[n])),this._attrTypes[e]=t,this._attributes.push(e),this._attrSummaries[e]=Te(r,t)}getAttributeType(e){return this._attrTypes[e]}get attributes(){return this._attributes}getAttributeSummary(e){return this._attrSummaries[e]}getAttributeValues(e){return this.data.map((t=>t[e]))}getUniqueAttributeValues(e){return this._attrSummaries[e].unique}orderAttributeValues(e,t){this._attrSummaries[e].unique=t}getRowCount(){return this.data.length}hasAttribute(e){return this._attributes.indexOf(e)>=0}parseAttributeAsDate(e,t){let r=n.timeParse(t);for(let t of this.data){let n=t[e];null==n||null==n?(n="",t[e]=new Date(1899,11,31).getTime()):t[e]=r(n).getTime(),this._dateMap.set(t[e],n)}this._attrTypes[e]=Re.Date,this._attrSummaries[e]=Te(this.data.map((t=>t[e])),Re.Date)}getRawValue(e,t){return this.getAttributeType(e)===Re.Date?this._dateMap.get(t).toString():t}get nonNumericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!=Re.Number&&this._attrTypes[t]!=Re.Integer&&t!=Pt.RowID&&e.push(t);return e.sort(((e,t)=>this.getUniqueAttributeValues(e).length-this.getUniqueAttributeValues(t).length)),e}get numericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!==Re.Number&&this._attrTypes[t]!==Re.Integer||t==Pt.RowID||e.push(t);return e}getAttributesByType(e){let t=[];for(let r in this._attrTypes)this._attrTypes[r]===e&&r!=Pt.RowID&&t.push(r);return t}summarize(){for(let e of this._attributes)this._attrSummaries[e]=Te(this.data.map((t=>t[e])),this._attrTypes[e])}_validate(e,t){for(let r of e)for(let e in t){let n,i=t[e],s=r[e];if(null==r[e]||null==r[e])switch(i){case Re.Boolean:n=!1;break;case Re.Date:n=new Date(1899,11,31).getTime();break;case Re.String:n="";break;default:n=0}else switch(i){case Re.Boolean:n=s;break;case Re.Date:n=Number.isInteger(s)?new Date(s,0).getTime():new Date(s+"").getTime(),this._dateMap.set(n,s);break;case Re.String:n=s.toString();break;default:n=s}r[e]=n}}}function Dt(e){let t=ye(e);if(t)return t.dataTable}const Bt="mascot_rowId";function Mt(e,t){return fetch(t,{method:e}).then((e=>e.ok?e.text():(console.log(e.status),Promise.reject({status:e.status,statusText:e.statusText})))).catch((e=>(console.log(e),Promise.reject({status:e.status,statusText:e.statusText}))))}class Gt extends K{constructor(e,t){super(e),this._elem=t}get element(){return this._elem}}class jt extends K{constructor(e,t){super(e),this._item=t}get element(){return this._item}}class zt{constructor(e){this._id=e+"_"+Vt(),this._type=e,this._vars=[],this._edges=[]}get vars(){return this._vars}get edges(){return this._edges}run(){console.log("-",this._type)}}class Ft{constructor(e,t,r=!0){this._id="e_"+Vt(),this._fromNode=e,this._toNode=t,this._isDirected=r}get id(){return this._id}get fromNode(){return this._fromNode}get toNode(){return this._toNode}get isDirected(){return this._isDirected}get operator(){return this._fromNode instanceof X||this._fromNode instanceof zt?this._fromNode:this._toNode}}class Ut extends K{constructor(e,t,r){super(e),this._attribute=t,this._dataset=r}get attribute(){return this._attribute}get dataset(){return this._dataset}}class Ht extends K{constructor(e,t){super(e),this._encs=[t]}addLinkedEncoding(e){this._encs.push(e)}get encodings(){return this._encs}}class Wt extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=e.encodings[0],r=this.inputVars.find((e=>e instanceof Ut)).attribute,n=e.encodings[0].dataTable.getAttributeType(e.encodings[0].attribute),i=[];for(let t of e.encodings){let e=this._computeAttrValues(t,n);i=i.concat(e)}if("angle"===t.channel&&[Nt.Arc,Nt.Pie].indexOf(t.element.type)>=0)for(let n of e.encodings)for(let e of n.scales){let i=n.getElements(e).map((e=>n.attrValues[e.id]));e.domain=t._preferredDomain?t._preferredDomain:n.dataTable.tree?[0,n.dataTable.tree.getRoot()[r]]:this._getDomainForNumbers(i),console.log("domain for",r,e.domain)}else{let s;s=n==Re.String||"text"===e.encodings[0].channel?this._getDomainForStrings(i):this._getDomainForNumbers(i);for(let r of e.encodings)for(let e of r.scales)e.domain=t._preferredDomain?t._preferredDomain:s.slice();console.log("domain for",r,s)}}_getDomainForNumbers(e){let t=this.outputVar.encodings[0],r=[Math.min(...e),Math.max(...e)];if(t.includeZero&&r[0]>0&&(r=[0,Math.max(...e)]),t.mapping)r=Object.keys(t.mapping),r=r.map((e=>parseFloat(e))),r.sort(((e,t)=>e-t));else if("sequentialColor"===t.scales[0].type){if(r[0]<0&&r[1]>0){let e=Math.max(Math.abs(r[0]),Math.abs(r[1]));r=[-e,e]}}else if("angle"===t.channel){r=[0,Object.values(e).reduce(((e,t)=>e+t),0)]}return r}_getDomainForStrings(e){let t,r=this.outputVar,n=r.encodings[0];return t="count"==r.encodings[0].aggregator?[0,Math.max(...e)]:Array.from(new Set(e)),n.mapping&&(t=Object.keys(n.mapping)),t}_computeAttrValues(e,t){let r=I(e.element),n={};if(e.element.type===Nt.Area&&["width","height","fillGradient"].indexOf(e.channel)>=0)for(let t of r)for(let r of t.vertices)n[r.id]=ye(r).aggregateNumericalAttribute(e.attribute,e.aggregator);else switch(t){case Re.Boolean:break;case Re.Date:for(let t of r)n[t.id]=ye(t).getAttributeValue(e.attribute);break;case Re.String:try{if("count"==e.aggregator)for(let t of r)n[t.id]=ye(t).getAttributeValues(e.attribute).length;else for(let t of r)n[t.id]=ye(t).getAttributeValue(e.attribute)}catch(t){throw new Error("Cannot bind "+this.channel+" to "+e.attribute+" : "+t)}break;default:if(e.attribute.startsWith("parent.")||e.attribute.startsWith("child.")){let t=e.dataTable.tree.nodeTable,i=e.attribute.split(".")[0],s=e.attribute.split(".")[1];for(let e of r){let r=ye(e).getAttributeValue(i);n[e.id]=new ge(t).cross(Ae,r).getAttributeValue(s)}}else for(let t of r)n[t.id]=ye(t).aggregateNumericalAttribute(e.attribute,e.aggregator)}return e.attrValues=n,Object.values(n)}}class Yt{constructor(e,t){switch(this._id="scale_"+Vt(),this._type=e,t&&(this._args=t),e){case"linear":this._scale=n.scaleLinear();break;case"point":this._scale=n.scalePoint();break;case"ordinal":this._scale=n.scaleOrdinal();break;case"ordinalColor":this._scale=n.scaleOrdinal(n[t.scheme]);break;case"power":this._scale=n.scalePow().exponent(2);break;case"sqrt":this._scale=n.scalePow().exponent(.5);break;case"log":this._scale=n.scaleLog();break;case"identity":case"time":this._scale=n.scaleTime();break;case"sequentialColor":t.scheme?this._scale=n.scaleSequential(n[t.scheme]):this._scale=n.scaleSequential()}}get id(){return this._id}get domain(){return this._scale.domain()}set domain(e){this._scale.domain(e)}get range(){return this._scale.range()}set range(e){this._scale.range(e)}get rangeExtent(){let e=this._scale.range();return Math.abs(e[1]-e[0])}set rangeExtent(e){let t=this._scale.range();t[0]<t[1]?this._scale.range([t[0],t[0]+e]):this._scale.range([t[1]+e,t[1]])}get type(){return this._type}map(e){return this._scale(e)}}const Xt=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],qt=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class Kt extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=e.encodings,r=t[0],n=r.channel;for(let i=0;i<r.scales.length;i++){let s=r.scales[i],a=r.getElements(s),o=this._buildRange(n,a,r,e);if(o)for(let e of t)e.scales[i].range=o;console.log("range",r.scales[i].range)}e.initialized=!0}_buildRange(e,t,r,n){return"x"===e?this._buildXRange(t,r,n):"y"===e?this._buildYRange(t,r,n):["width","height","radius","area","fontSize","radialDistance","strokeWidth"].includes(e)?this._buildSizeRange(t,r,n):e.indexOf("Color")>0||"fillGradient"===e?this._buildColorRange(t,r):"angle"===e?this._buildAngleRange(t,r):"thickness"===e?this._buildThicknessRange(t,r,n):void 0}_buildThicknessRange(e,t,r){let n=e.map((e=>e.outerRadius-e.innerRadius));return[0,r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(...n)]}_buildAngleRange(e,t){return[0,360]}_buildColorRange(e,t){if(t.mapping){return t.scales[0].domain.map((e=>t.mapping[e+""]))}if("sequentialColor"===t.scales[0].type){let e=this.outputVar,r=t.scales[0].domain;for(let i of e.encodings)if(!t.colorScheme)for(let e of i.scales){let t=e.domain;e._scale=n.scaleSequential(r[0]<0&&r[1]>0?n.interpolatePuOr:n.interpolateTurbo),e._scale.domain(t)}}if((Xt.indexOf(t.colorScheme)>=0||qt.indexOf(t.colorScheme)>=0)&&"ordinalColor"===t.scales[0].type){let e=this.outputVar,r=t.scales[0].domain;for(let i of e.encodings)for(let e of i.scales){let i=e.domain;e._scale=n.scaleOrdinal(n[t.colorScheme][r.length]),e._scale.domain(i)}}}_buildSizeRange(e,t,r){let n,i;return n=0,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(...e.map((e=>"radius"===t.channel?e.refBounds.width/2:"strokeWidth"===t.channel?e.strokeWidth:"radialDistance"===t.channel?e.parent.radius:"area"===t.channel?e.type===Nt.Circle?Math.PI*Math.pow(e.radius,2):e.width*e.height:"fontSize"===t.channel?parseFloat(e.fontSize):e.refBounds[t.channel]))),[0,0+i]}_buildXRange(e,t,r){let n,i;switch(t.scales[0].type,e[0].type){case"vertex":case"segment":var s=e[0].parent.refBounds?e[0].parent.refBounds:e[0].parent.bounds;n=r.initialized?t.getRangeStart(e[0]):s.left,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:s.width;break;default:n=r.initialized?t.getRangeStart(e[0]):G(e[0]).bounds.left+e[0].bounds.width/2,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:450}return t.flipScale?[n+i,n]:[n,n+i]}_buildYRange(e,t,r){let n,i;switch(t.scales[0].type,e[0].type){case"vertex":case"segment":var s=e[0].parent.refBounds?e[0].parent.refBounds:e[0].parent.bounds;n=r.initialized?t.getRangeStart(e[0]):s.top,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:s.height;break;default:n=r.initialized?t.getRangeStart(e[0]):G(e[0]).bounds.top+e[0].bounds.height/2,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:450}return t.flipScale?[n,n+i]:[n+i,n]}}class Zt extends X{constructor(e){super(e)}run(){super.run()}}class $t extends yt{constructor(e){super(),this._type=Nt.Axis,this._id=this._type+Vt(),this._attribute=void 0,this._channel=void 0,this._orientation=void 0,this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._textColor="textColor"in e?e.textColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._tickOffset="tickOffset"in e?e.tickOffset:0,this._tickSize="tickSize"in e?e.tickSize:5,this._tickAnchor=e.tickAnchor,this._tickVisible=!("tickVisible"in e)||e.tickVisible,this._pathVisible=!("pathVisible"in e)||e.pathVisible,this._labelOffset="labelOffset"in e?e.labelOffset:this._tickSize+this._tickOffset+3,this._labelFormat="labelFormat"in e?e.labelFormat:"",this._titleOffset="titleOffset"in e?e.titleOffset:40,this._rotateYTitle=!("rotateTitle"in e&&!e.rotateTitle),this._showTitle=!("titleVisible"in e)||e.titleVisible,this._labelRotation="labelRotation"in e?e.labelRotation:0,this._ticks=new yt,this._ticks._id=this._id+"_ticks",this.addChild(this._ticks),this._labels=new yt,this._labels._id=this._id+"_labels",this.addChild(this._labels),this._title=new At({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title._id=this.id+"_title",this.addChild(this._title),this._showTitle||(this._title.visibility="hidden"),this._pathPos=void 0}get pathPos(){return this._pathPos}get attribute(){return this._attribute}get channel(){return this._channel}get orientation(){return this._orientation}get tickSize(){return this._tickSize}get tickOffset(){return this._tickOffset}get tickAnchor(){return this._tickAnchor?this._tickAnchor:"x"===this._channel||"width"===this._channel?"center":"middle"}get labelOffset(){return this._labelOffset}get tickValues(){return this._tickValues}get labelValues(){return this._labelValues}get titleOffset(){return this._titleOffset}get boundsWithoutTitle(){let e=this.children.filter((e=>e.type!==Nt.PointText)),t=e[0].bounds.clone();for(let r=1;r<e.length;r++)"hidden"!=e[r].visibility&&(t=t.union(e[r].bounds));return t}}const Jt="top",Qt="bottom",er="left";function tr(e,t,r,i){let s,a=e.domain,o=e.range;switch(e.type){case"linear":case"log":{let l=Math.abs(o[0]-o[1]);s="width"==t||"x"==t?45:30;let u,c=Math.max(2,Math.floor(l/s));if("width"==t||"height"==t){let n=!!i&&(i.elements[0].parent.layout&&i.elements[0].parent.layout.type==W.STACK);a[1]=e._scale.invert(n?_(r)[t]:p(r)[t])}if("log"===e.type){u=[];let t=e._scale.ticks();for(let e of t){let r=Math.log(e)/Math.log(10)+1e-6;Math.abs(r-Math.floor(r))<c/t.length&&u.push(e)}}else u=n.ticks(a[0],a[1],c);return u}case"point":{s="width"==t||"x"==t?80:30;let r=Math.floor(e.rangeExtent/a.length),n=Math.ceil(s/r);return"x"==t?a.filter(((e,t)=>t%n==0)):a}case"time":{s="width"==t||"x"==t?80:30;let e,r,i=Math.floor((o[1]-o[0])/s),l=Math.ceil((a[1]-a[0])/i)/1e3,u=[1,60,3600,86400,2628003,31536e3],c=[n.timeSeconds,n.timeMinutes,n.timeHours,n.timeDays,n.timeMonths,n.timeYears];for(let t=0;t<u.length-1;t++)if(l>=u[t]&&l<u[t+1])return e=Math.floor(l/u[t]),r=c[t],r(a[0],a[1],e);return l>u[u.length-1]?(e=Math.floor(l/u[u.length-1]),r=c[u.length-1],r(a[0],a[1],e)):[]}default:return[]}}function rr(e,t){t.removeChild(e)}class nr extends $t{constructor(e,t,r,n){super(n),this._encoding=e,this._attribute=this._encoding.attribute,this._channel=this._encoding.channel,this._scale=t,this._elems=r,this._flip="flip"in n&&n.flip,this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?Qt:er,this._titleText="title"in n?n.title:this._encoding.attribute,this._path="angle"===this._channel?new xt({strokeColor:this._strokeColor,id:this._id+"_path"}):new ae({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(n),e.dataTable.getAttributeType(this._attribute)!==Re.Date||"labelFormat"in n||(this._labelFormat="%m/%d/%y"),"radialDistance"===this._channel&&"rotation"in n&&(this._rotate=[-n.rotation,this._elems[0].parent.x,this._elems[0].parent.y])}isFlipped(){return this._flip}get elements(){return this._elems}get scale(){return this._scale}createTicksLabels(e){"tickValues"in e?(this._tickValues=e.tickValues,this._labelValues=e.tickValues):(this._tickValues=tr(this._scale,this._channel,this._elems,this),this._labelValues=this._tickValues),this._ticks.removeAll();for(let e=0;e<this._tickValues.length;e++){let t=new ae({strokeColor:this._strokeColor,id:this._id+"_tick"+e});this._tickVisible||(t.visibility="hidden"),this._ticks.addChild(t)}let t;switch(this._labels.removeAll(),this._encoding.dataTable.getAttributeType(this._attribute)){case Re.Date:t=n.timeFormat(this._labelFormat);break;case Re.String:t=function(e){return e};break;default:t=n.format(this._labelFormat)}for(let[e,r]of this._labelValues.entries()){let n=new At({text:t(r),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labels.addChild(n)}this._title._text=this._titleText}}class ir extends $t{constructor(e,t,r,n){super(n),this._elems=e,this._attribute=r,this._channel=t,this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._labelAttribute=n.labelAttribute,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?Qt:er,this._titleText="title"in n?n.title:this._attribute,this._path="angle"===this._channel?new xt({strokeColor:this._strokeColor,id:this._id+"_path"}):new ae({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(n),this._elems[0].dataScope.dataTable.getAttributeType(this._attribute)!==Re.Date||"labelFormat"in n||(this._labelFormat="%m/%d/%y")}get elements(){if(this.layout.type===W.CLUSTER){const e=new Map(this._elems.map((e=>[e.dataScope.getAttributeValue(Ae),e])));return this.layout._d3Root.leaves().map((t=>e.get(t.data[Ae])))}return this._elems}get layout(){return this._elems[0].parent.layout}createTicksLabels(e){"tickValues"in e?(this._tickValues=e.tickValues,this._labelValues=e.tickValues):(this._tickValues=this.elements.map((e=>e.dataScope.getAttributeValue(this._labelAttribute?this._labelAttribute:this._attribute))),this._labelValues=this._tickValues),this._ticks.removeAll();for(let e=0;e<this._tickValues.length;e++){let t=new ae({strokeColor:this._strokeColor,id:this._id+"_tick"+e});this._tickVisible||(t.visibility="hidden"),this._ticks.addChild(t)}let t;switch(this._labels.removeAll(),this._elems[0].dataScope.dataTable.getAttributeType(this._labelAttribute?this._labelAttribute:this._attribute)){case Re.Date:t=n.timeFormat(this._labelFormat);break;case Re.String:t=function(e){return e};break;default:t=n.format(this._labelFormat)}for(let[e,r]of this._labelValues.entries()){let n=new At({text:t(r),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labels.addChild(n)}this._title._text=this._titleText}}class sr extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_ORIENTATION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e),g(e._path)}_runForLayout(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?_(e.elements):p(e.elements),n=[];if("x"===t){let t=e.orientation===Jt?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,n.push([r.left,e._pathPos]),n.push([r.right,e._pathPos]),e._path._setVertices(n)}else if("y"===t){let t=e.orientation===er?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,n.push([e._pathPos,r.top]),n.push([e._pathPos,r.bottom]),e._path._setVertices(n)}else if("angle"===t){let t=e.elements[0].parent.layout;t.type===W.CLUSTER&&(e._path._x=t.x,e._path._y=t.y,e._path._radius=t.radius)}}_runForEncoding(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?_(e.elements):p(e.elements),n=[];if("x"===t){let t=e.orientation===Jt?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,n.push([e.scale.range[0],e._pathPos]),n.push([e.scale.range[1],e._pathPos])}else if("width"===t){let t=e.orientation===Jt?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,n.push([r.left,e._pathPos]),n.push([r.right,e._pathPos])}else if("radialDistance"===t){let t=e.elements[0].parent,r=t.y;e._pathPos=e._posArg?e._posArg:r,n.push([e.scale.range[0]+t.x,e._pathPos]),n.push([e.scale.range[1]+t.x,e._pathPos])}else if("y"===t){let t=e.orientation===er?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,n.push([e._pathPos,e.scale.range[0]]),n.push([e._pathPos,e.scale.range[1]])}else if("height"===t){let t=e.orientation===er?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,n.push([e._pathPos,r.bottom]),n.push([e._pathPos,r.top])}e._path._setVertices(n)}}class ar extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e);for(let t of e._ticks.children)t._updateBounds();g(e._ticks)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==Qt?e.tickSize:-e.tickSize;for(let[n,i]of e._ticks.children.entries()){let s=e.elements[n].bounds[e.tickAnchor];i._setVertices([[s,t],[s,t+r]])}}else if("y"===t){let t=e.orientation==er?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==er?-e.tickSize:e.tickSize;for(let[n,i]of e._ticks.children.entries()){let s=e.elements[n].bounds[e.tickAnchor];i._setVertices([[t,s],[t+r,s]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===W.CLUSTER){let r=t._d3Root.leaves();const n=new Map(r.map((e=>[e.data[Ae],[e.x,e.y]])));for(let[r,i]of e._ticks.children.entries()){let s=e.elements[r].dataScope.getAttributeValue(Ae),a=fe(n.get(s)[0])-90;i._setVertices([[t.x+n.get(s)[1]+e.elements[r].bounds.width/2,t.y],[t.x+n.get(s)[1]+e.elements[r].bounds.width/2+e.tickSize,t.y]]),i._rotate=[a,t.x,t.y]}}}}_runForEncoding(e){let t=e.channel,r=p(e.elements);if("x"==t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==Qt?e.tickSize:-e.tickSize;for(let[n,i]of e._ticks.children.entries())i._setVertices([[e.scale.map(e._tickValues[n]),t],[e.scale.map(e._tickValues[n]),t+r]])}else if("width"==t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,n=e.orientation==Qt?e.tickSize:-e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Nt.Area&&"right"===e.elements[0].baseline))for(let[i,s]of e._ticks.children.entries())s._setVertices([[r.left+e.scale.rangeExtent-e.scale.map(e._tickValues[i]),t],[r.left+e.scale.rangeExtent-e.scale.map(e._tickValues[i]),t+n]]);else for(let[i,s]of e._ticks.children.entries())s._setVertices([[e.scale.map(e._tickValues[i])+r.left,t],[e.scale.map(e._tickValues[i])+r.left,t+n]])}else if("y"===t){let t=e.orientation==er?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==er?-e.tickSize:e.tickSize;for(let[n,i]of e._ticks.children.entries())i._setVertices([[t,e.scale.map(e._tickValues[n])],[t+r,e.scale.map(e._tickValues[n])]])}else if("height"===t){let t=e.orientation==er?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,n=e.orientation==er?-e.tickSize:e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Nt.Area&&"top"===e.elements[0].baseline))for(let[i,s]of e._ticks.children.entries())s._setVertices([[t,r.top+e.scale.map(e._tickValues[i])],[t+n,r.top+e.scale.map(e._tickValues[i])]]);else for(let[i,s]of e._ticks.children.entries()){let a=r.bottom-e.scale.map(e._tickValues[i]);s._setVertices([[t,a],[t+n,a]])}}else if("radialDistance"===t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==Qt?e.tickSize:-e.tickSize,n=e.elements[0].parent;for(let[i,s]of e._ticks.children.entries())s._setVertices([[n.x+e.scale.map(e._tickValues[i]),t],[n.x+e.scale.map(e._tickValues[i]),t+r]])}}}class or extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e);for(let t of e._labels.children)t._updateBounds();g(e._labels)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,r=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM];for(let[n,i]of e._labels.children.entries()){let s=e.elements[n].bounds;i._x=s[e.tickAnchor],i._y=e.pathPos+t,i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,y.MIDDLE])}}else if("y"===t){let t=e.orientation==er?-e.labelOffset:e.labelOffset,r=e.orientation==er?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE];for(let[n,i]of e._labels.children.entries()){let s=e.elements[n].bounds;i._x=e.pathPos+t,i._y=e.tickAnchor==y.MIDDLE?s.y:s[e.tickAnchor],i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,r[1]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===W.CLUSTER){let r=t._d3Root.leaves();const n=new Map(r.map((e=>[e.data[Ae],[e.x,e.y]])));let i=5;for(let[r,s]of e._labels.children.entries()){let a=e.elements[r].dataScope.getAttributeValue(Ae);if(n.get(a)[0]<Math.PI){let o=fe(n.get(a)[0])-90;s._anchor=[y.LEFT,y.MIDDLE],s._x=t.x+n.get(a)[1]+e.elements[r].bounds.width/2+i,s._y=t.y,s._rotate=[o,t.x,t.y]}else{let o=fe(n.get(a)[0])+90;s._anchor=[y.RIGHT,y.MIDDLE],s._x=t.x-n.get(a)[1]-e.elements[r].bounds.width/2-i,s._y=t.y,s._rotate=[o,t.x,t.y]}}}}}_runForEncoding(e){let t=e.channel,r=p(e.elements);if("x"==t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,r=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM];for(let[n,i]of e._labels.children.entries())i._x=e.scale.map(e.labelValues[n]),i._y=e.pathPos+t,i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,r[1]])}else if("width"===t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,n=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM],i=!!(e.isFlipped()||e.elements[0].type===Nt.Area&&"right"===e.elements[0].baseline);for(let[s,a]of e._labels.children.entries())a._x=i?r.left+e.scale.rangeExtent-e.scale.map(e.labelValues[s]):e.scale.map(e.labelValues[s])+r.left,a._y=e.pathPos+t,a._anchor=n,e._labelRotation&&(a._rotate=[e._labelRotation,a.x,a.y],a._anchor=[y.RIGHT,n[1]])}else if("y"===t){let t=e.orientation==er?-e.labelOffset:e.labelOffset,r=e.orientation==er?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE];for(let[n,i]of e._labels.children.entries())i._x=e.pathPos+t,i._y=e.scale.map(e.labelValues[n]),i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,r[1]])}else if("height"===t){let t=e.orientation==er?-e.labelOffset:e.labelOffset,n=e.orientation==er?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE],i=e.elements[0].type===Nt.Area&&"top"===e.elements[0].baseline;for(let[s,a]of e._labels.children.entries())a._x=e.pathPos+t,a._y=i?r.top+e.scale.map(e.labelValues[s]):r.bottom-e.scale.map(e.labelValues[s]),a._anchor=n,e._labelRotation&&(a._rotate=[e._labelRotation,a.x,a.y],a._anchor=[y.RIGHT,n[1]])}else if("radialDistance"==t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,r=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM],n=e.elements[0].parent;for(let[i,s]of e._labels.children.entries())s._x=n.x+e.scale.map(e.labelValues[i]),s._y=e.pathPos+t,s._anchor=r,e._labelRotation&&(s._rotate=[e._labelRotation,s.x,s.y],s._anchor=[y.RIGHT,r[1]])}}}class lr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)return;this.fillGrid(e,t),this.computeCellBounds(e,t),this.placeElements(e,t)}let r=F(e,!0);for(let e of r)g(e)}placeElements(e,t){let r=Ge(e,"x"),n=Ge(e,"y");for(let r=0;r<e.children.length;r++){let n=e.children[r],i=t.cellBounds[r],s=0,a=0;switch(t._cellHorzAlignment){case y.LEFT:s=i.left-n.refBounds.left;break;case y.CENTER:s=i.x-n.refBounds.x;break;case y.RIGHT:s=i.right-n.refBounds.right}switch(t._cellVertAlignment){case y.TOP:a=i.top-n.refBounds.top;break;case y.MIDDLE:a=i.y-n.refBounds.y;break;case y.BOTTOM:a=i.bottom-n.refBounds.bottom}Ue(n,s,a)}if(r.length>0)for(let e of r)for(let r of e.scales){let n=e.getElements(r)[0],i=t.getIndex(n);if(i<0)continue;let s="point"===r.type?t.cellBounds[i].left+n.bounds.width/2:t.cellBounds[i].left,a=s+r.rangeExtent;r.range=r.range[0]<r.range[1]?[s,a]:[a,s]}if(n.length>0)for(let e of n)for(let r of e.scales){let n=e.getElements(r)[0],i=t.getIndex(n);if(i<0)continue;let s="point"===r.type?t.cellBounds[i].top+e.getElements(r)[0].bounds.height/2:t.cellBounds[i].top,a=s+r.rangeExtent;r.range=r.range[0]<r.range[1]?[s,a]:[a,s]}}fillGrid(e,t){t._grid=new Array(t.numRows).fill(null).map((()=>new Array(t.numCols).fill(null)));for(let r=0;r<e.children.length;r++){let e=t.getRowCol(r);t._grid[e.row][e.col]=r}}computeCellBounds(e,t){let r=e.children.map((e=>e.refBounds?e.refBounds:e.bounds)),n=t._colGap,i=t._rowGap;if(void 0===t._left){let e=r.map((e=>e.left)),n=r.map((e=>e.top));t._left=Math.min(...e),t._top=Math.min(...n)}let s=r.map((e=>e.width)),a=r.map((e=>e.height)),o=Math.max(...s),l=Math.max(...a);t._cellBounds=new Array(e.children.length).fill(null);for(let r=0;r<t.numRows;r++)for(let s=0;s<t.numCols;s++){let a=t._grid[r][s];a>=e.children.length||(t._cellBounds[a]=new d(t._left+(o+n)*s+0,t._top+(l+i)*r,o,l))}}}class ur extends X{constructor(e){super(e)}run(){let e=this.outputVar.element;e.scale?this._runForEncoding(e):this._runForLayout(e),g(e)}_runForLayout(e){let t=e.channel,r=p(e.elements),n=[];if("x"===t)for(let t=0;t<e.values.length;t++){let i=e.elements[t].refBounds;n.push({x1:i.x,y1:r.bottom,x2:i.x,y2:r.top})}else if("y"===t)for(let t=0;t<e.values.length;t++){let i=e.elements[t].refBounds;n.push({x1:r.left,y1:i.y,x2:r.right,y2:i.y})}e.lines=n}_runForEncoding(e){let t=e.channel,r=p(e.elements),n=[];if("x"===t)for(let t of e.values)n.push({x1:e.scale.map(t),y1:r.bottom,x2:e.scale.map(t),y2:r.top});else if("width"===t)for(let t of e.values)n.push({x1:e.scale.map(t)+r.left,y1:r.bottom,x2:e.scale.map(t)+r.left,y2:r.top});else if("y"===t)for(let t of e.values)n.push({x1:r.left,y1:e.scale.map(t),x2:r.right,y2:e.scale.map(t)});else if("height"===t)for(let t of e.values)n.push({x1:r.left,y1:r.bottom-e.scale.map(t),x2:r.right,y2:r.bottom-e.scale.map(t)});else if("radialDistance"===t){let t=e.elements[0].parent;for(let r=0;r<e.values.length;r++)n.push({x:t.x,y:t.y,r:e.scale.map(e.values[r])})}e.lines=n}}class cr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=F(e)[0],r=I(e.parent);for(let e of r){let r=e.layout;if(!r)return;switch(t.type){case Nt.Rect:case Nt.Circle:case Nt.Image:this._stackRects(e,r);break;case Nt.Area:e.children[0].orientation===ee.HORIZONTAL?this._stackAreasVert(e,r):this._stackAreasHorz(e,r);break;case Nt.Arc:case Nt.Pie:t.parent.classId===e.classId&&this._stackArcs(e,r)}}g(t)}_stackArcs(e,t){if(t.orientation===ee.ANGULAR){let t=90;if((this._direction?this._direction:re.Clockwise)===re.Clockwise)for(let r of e.children){let e=pe(t-r.angle);We(r,"startAngle",e),t=e}else for(let r of e.children){let e=pe(t+r.angle);We(r,"startAngle",e),t=e}}else if(t.orientation===ee.RADIAL){let t=Math.min(...e.children.map((e=>e.innerRadius)));for(let r of e.children){let e=r.outerRadius-r.innerRadius;We(r,"innerRadius",t),We(r,"outerRadius",t+e),t=r._outerRadius}}}_stackAreasVert(e,t){let r=e.children,n=e.bounds,i=t.vertCellAlignment===y.TOP?n.top:n.bottom,s=t.vertCellAlignment===y.TOP?1:-1,a=r[0].vertices.length/2,o=new Array(a).fill(0);for(let e of r){for(let t=0;t<a;t++){let r=e.vertices[t],n=e.vertices[2*a-t-1],l=Math.abs(r.y-n.y),u=i+o[t]*s,c=i+(o[t]+l)*s;Ue(r,0,u-r.y),Ue(n,0,c-n.y),o[t]+=l}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}if(t.vertCellAlignment===y.MIDDLE)for(let e of r){for(let t=0;t<a;t++){let r=e.vertices[t],i=e.vertices[2*a-t-1],s=n.middle+o[t]/2;Ue(r,0,s-n.bottom),Ue(i,0,s-n.bottom)}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}}_stackAreasHorz(e,t){}_stackRects(e,t){e.scene;let r=t._orientation,n=e.children.map((e=>e.bounds)),i=n.map((e=>e.left)),s=n.map((e=>e.top)),a=n.map((e=>e.width)),o=n.map((e=>e.height)),l=null==t._left?Math.min(...i):t._left,u=null==t._top?Math.min(...s):t._top,c=Math.max(...a),h=Math.max(...o);if(r==ee.VERTICAL)for(let r=0;r<e.children.length;r++){let n=e.children[r],i=0,s=u+n.bounds.height/2-n.bounds.y;u+=n.bounds.height+t._gap,Ue(n,i,s),n._updateBounds();let a=0,o=0;if(!ze(n))switch(t._horzCellAlignment){case y.LEFT:a=l-n.bounds.left;break;case y.CENTER:a=l+c/2-n.bounds.x;break;case y.RIGHT:a=l+c-n.bounds.right}Ue(n,a,o)}else for(let r=0;r<e.children.length;r++){let n=e.children[r],i=l+n.bounds.width/2-n.bounds.x,s=0;l+=n.bounds.width+t._gap,Ue(n,i,s),n._updateBounds();let a=0,o=0;if(!je(n))switch(t._vertCellAlignment){case y.TOP:o=u-n.bounds.top;break;case y.MIDDLE:o=u+h/2-n.bounds.y;break;case y.BOTTOM:o=u+h-n.bounds.bottom}Ue(n,a,o)}}}class hr extends X{constructor(e){super(e)}run(){super.run()}}class dr extends X{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,r=e.attribute,i=t.attribute,s=e.dataset,a=t.dataset,o=s.getAttributeValues(r),l=n.bin()(o),u=this._findBin,c=o.map((e=>{let t=u(e,l);return(t.x0+t.x1)/2+""})),h=l.map((e=>(e.x0+e.x1)/2+""));a._addAttribute(i,Re.String,c),a.orderAttributeValues(i,h)}_findBin(e,t){for(let r of t)if(r.indexOf(e)>=0)return r}}class fr extends X{constructor(e){super(e)}run(){let e=this.outputVar,t=e.dataset,r=e.predicate,n=[];for(let[e,i]of t.data.entries())r.testTuple(i)||n.push(e);n.sort(((e,t)=>t-e)),n.forEach((e=>{e>=0&&e<t.data.length&&(t._data.splice(e,1),t._rawData.splice(e,1))}));for(let e of t._attributes)t._attrSummaries[e]=Te(t.data.map((t=>t[e])),t._attrTypes[e])}}class pr extends K{constructor(e,t,r){super(e),this._dataset=r,this._predicate=t}get dataset(){return this._dataset}get predicate(){return this._predicate}}class _r extends K{constructor(e,t){super(e),this._group=t}get element(){return this._group}}class gr extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e.type===Z.AFFIXATION)).affixation,t=e.base,r=e.element,n=I(t),i=I(r),s=e.channels,a=e.attribute;if(A(r)&&A(t)){let e=n.map((e=>e.dataScope.getAttributeValue(a)));i=i.filter((t=>e.includes(t.dataScope.getAttributeValue(a))));let t=(e,t)=>e.dataScope.getAttributeValue(a)<t.dataScope.getAttributeValue(a)?-1:e.dataScope.getAttributeValue(a)>t.dataScope.getAttributeValue(a)?1:0;i.sort(t),n.sort(t)}if(s.includes("x")||s.includes("y"))for(let t of s)this._handleXY(t,i,n,e.getElementAnchor(t),e.getBaseAnchor(t),e.getOffset(t));(s.includes("radialDistance")||s.includes("angle"))&&this._handlePolar(i,n,e);let o=F(r,!0);for(let e of o)g(e)}_handlePolar(e,t,r){let n=r.hasChannel("radialDistance")?r.getBaseAnchor("radialDistance"):y.MIDDLE,i=r.hasChannel("radialDistance")?r.getElementAnchor("radialDistance"):y.MIDDLE,s=r.hasChannel("angle")?r.getBaseAnchor("angle"):y.CENTER;r.hasChannel("angle")?r.getElementAnchor("angle"):y.CENTER;let a=r.hasChannel("radialDistance")?r.getOffset("radialDistance"):0,o=r.hasChannel("angle")?r.getOffset("angle"):0;if([Nt.Arc,Nt.Ring].indexOf(t[0].type)>=0&&e[0].type==Nt.PointText)for(let r=0;r<e.length;r++){let i=t[r],o=e[r],l=n===y.MIDDLE?(i.outerRadius+i.innerRadius)/2:n===y.TOP?i.outerRadius-5:i.innerRadius+5;if(l+=a,i.type===Nt.Arc){let e=Ie(i.x,i.y,l,i.startAngle),t=Ie(i.x,i.y,l,i.endAngle);i.endAngle>=180&&i.endAngle<=360?o._textPath=["M",e[0],e[1],"A",l,l,i.angle,i.angle>=180?1:0,0,t[0],t[1]].join(" "):o._textPath=["M",t[0],t[1],"A",l,l,i.angle,i.angle>=180?1:0,1,e[0],e[1]].join(" ")}else if(i.type===Nt.Ring){let e=275,t=265,r=350,n=Ie(i.x,i.y,l,e),s=Ie(i.x,i.y,l,t);o._textPath=["M",s[0],s[1],"A",l,l,r,1,1,n[0],n[1]].join(" ")}o._textPathOffset=s===y.LEFT?"0%":"50%"}else for(let r=0;r<e.length;r++){let l,u,c=t[r],h=e[r];c.type==Nt.Arc||c.type==Nt.Ring?(u="left"==s?c.endAngle+o:"center"==s?c.startAngle+c.angle/2+o:c.startAngle+o,l="top"==n?c.outerRadius+a:"bottom"==n?c.innerRadius+a:(c.outerRadius+c.innerRadius)/2+a):c.type==Nt.Circle&&(u=90,l="top"==n?c.radius+a:"bottom"==n?a:c.radius/2+a),Ue(h,c.x-h.x,c.y-l-h.bounds[i]),h._rotate=[90-u,c.x,c.y]}}_handleXY(e,t,r,n,i,s){for(let a=0;a<t.length;a++){let o,l=r[a],u=t[a];if(le(l)){o=oe(l,[y.LEFT,y.TOP].includes(i)?0:[y.CENTER,y.MIDDLE].includes(i)?.5:1)[e]}else o=l.bounds[i]+s;t[0].type===Nt.PointText?(u.anchor["x"==e?0:1]=n,We(u,e,o)):"x"==e?Ue(u,o-u.bounds[n],0):Ue(u,0,o-u.bounds[n])}}}class yr extends K{constructor(e,t){super(e),this._affx=t}get affixation(){return this._affx}}class mr extends X{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,r=e.attribute,n=t.attribute,i=e.dataset,s=t.dataset,a=this.args,o="min"in a?a.min:i.getAttributeSummary(r).min,l="max"in a?a.max:i.getAttributeSummary(r).max,u=o,c=[];for(;u<l;)c.push(u),u+=a.interval;c.push(u);let h={},d={};if(a.groupBy)for(let e of i.data){let t=a.groupBy.map((t=>e[t])).join("-");t in h||(h[t]=[],d[t]=a.groupBy.map((t=>e[t]))),h[t].push(e[r])}else h[""]=i.data.map((e=>e[r])),d[""]="";let f=[];for(let e in d){let t=br(vr(a.bandwidth),c,h[e]);for(let i of t){let t={};""!==e&&a.groupBy.forEach(((r,n)=>t[r]=d[e][n])),t[r]=i[0],t[n]=i[1],f.push(t)}}let p={};if(p[r]=i.getAttributeType(r),p[n]=Re.Number,a.groupBy)for(let e of a.groupBy)p[e]=i.getAttributeType(e);s.initialize(f,s.url,p)}}function br(e,t,r){return t.map((t=>[t,n.mean(r,(r=>e(t-r)))]))}function vr(e){return t=>Math.abs(t/=e)<=1?.75*(1-t*t)/e:0}class xr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)return;let r=e.children.map((e=>({name:e.id,radius:e.radius,itm:e}))),i=r.reduce(((e,t)=>e+Math.pow(t.radius,2)),0),s=Math.sqrt(i);void 0===t._width&&(t._width=s),void 0===t._height&&(t._height=s);let a=n.hierarchy({name:"root",children:r}).sum((e=>e.radius?e.radius:0)).sort(((e,t)=>t.value-e.value));n.pack().size([t._width,t._height]).radius((e=>e.value))(a);for(let e of a.children){let r=e.data.itm;Ue(r,t._x-a.x+e.x-r.x,t._y-a.y+e.y-r.y)}}let r=F(e,!0);for(let e of r)g(e)}}class Er extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e),g(e._title)}_runForEncoding(e){let t=e.channel,r=p(e.elements);if("x"==t)e._title._x=(e.scale.range[0]+e.scale.range[1])/2,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("width"==t)e._title._x=r.left+e.scale.rangeExtent/2,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._rotateYTitle?(e._title._x=e.orientation==er?e.pathPos-e.titleOffset:e.pathPos+e.titleOffset,e._title._y=(e.scale.range[0]+e.scale.range[1])/2,e._title._rotate=e.orientation==er?[-90,e._title._x,e._title._y]:[90,e._title._x,e._title._y]):(e._title._x=e.orientation==er?e.pathPos-e.titleOffset:e.pathPos+e.titleOffset,e._title._y=Math.min(e.scale.range[0],e.scale.range[1])-25,e._title._rotate=void 0);else if("height"===t)e._title._x=r.center,e._title._y=(r.top+r.bottom)/2-r.width/2-e.titleOffset,e._title._rotate=e.orientation==er?[-90,r.center,r.middle]:[90,r.center,r.middle];else if("radialDistance"===t){let t=e.elements[0].parent;e._title._x=t.x+e.scale.rangeExtent/2,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset,e._rotate&&(e._title._rotate=e._rotate.slice())}}_runForLayout(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?_(e.elements):p(e.elements);if("x"==t)e._title._x=r.center,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._title._x=r.center,e._title._y=r.middle-r.width/2-e.titleOffset,e._title._rotate=e.orientation==er?[-90,r.center,r.middle]:[90,r.center,r.middle];else if("angle"===t){let t=e.elements[0].parent.layout;t.type===W.CLUSTER&&(e._title._x=t.x,e._title._y=t.y)}}}class wr extends zt{constructor(e){super(e)}run(){super.run();let e,t=this.vars.find((e=>e.type===Z.ALIGNMENT)).alignment,r=t.anchor,i=t.elements;r==y.Top||r==y.LEFT?e=Math.min(...i.map((e=>e.bounds[r]))):r==y.BOTTOM||r==y.RIGHT?e=Math.max(...i.map((e=>e.bounds[r]))):r!=y.CENTER&&r!=y.MIDDLE||(e=n.mean(i.map((e=>e.bounds[r]))));for(let n of i){let i=Fe(n,t.channel);if(i){let s=e-n.bounds[r];Ue(i,"x"===t.channel?s:0,"x"===t.channel?0:s)}}for(let e of i)g(e)}}class Ar extends K{constructor(e,t){super(e),this._aln=t}get alignment(){return this._aln}}class Cr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=Ee(e.children[0]);if(!r)continue;let i=r.linkList.map((e=>({source:r.getNode(e.source),target:r.getNode(e.target)}))),s=n.forceSimulation(r.nodeList).force("charge",n.forceManyBody().strength(-t._repulsion)).force("link",n.forceLink(i).id((e=>e.id)).distance(t._linkDistance)).force("x",n.forceX()).force("y",n.forceY()).force("center",n.forceCenter(t._x,t._y).strength(t._attraction));s.stop(),s.tick(t._iterations);for(let t=0;t<e.children.length;t++){let n=e.children[t],i=r.nodeList[t];Ue(n,i.x-n.x,i.y-n.y)}}let r=F(e,!0);for(let e of r)g(e)}}class Rr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e);switch(e.type){case Nt.Arc:this._updateArcLinks(t);break;case Nt.BezierCurve:this._updateBezierLinks(t);break;case Nt.BundledPath:this._updateBundledLinks(t);break;case Nt.Chord:this._updateChordLinks(t);break;case Nt.Line:default:this._updateLineLinks(t)}g(e)}_updateArcLinks(e){for(let t of e){let e=t.source.x<t.target.x?t.source:t.target,r=t.source.x<t.target.x?t.target:t.source;t._x=(e.x+r.x)/2,t._y=(e.y+r.y)/2,t._innerRadius=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))/2,t._outerRadius=t._innerRadius+t._thickness;let n=_e(e.x,e.y,t._x,t._y),i=_e(r.x,r.y,t._x,t._y);t.direction===re.CLOCKWISE&&([n,i]=[i,n]),We(t,"startAngle",n),We(t,"angle",Math.abs(i-n))}}_updateBezierLinks(e){let t=this._inputVars[0].element,r=I(t),n=t.parent.layout;n.type===W.DIRECTED||n.type===W.TIDYTREE?this._updateBezierLinksForDirectedGraph(r,e,n):n.type===W.CLUSTER&&this._updateBezierLinksForClusteredGraph(r,e,n)}_updateBezierLinksForClusteredGraph(e,t,r){const i=r._d3Root.descendants(),s=new Map(i.map((e=>[kr(e),e]))),a=new Map(i.map((e=>[e.data[Ae],kr(e)])));if(r.isRadial()){const e=n.linkRadial().angle((e=>e.x)).radius((e=>e.y));for(let n of t){let t=n.source,i=n.target,o=t.dataScope.getAttributeValue(Ae),l=i.dataScope.getAttributeValue(Ae),u=s.get(a.get(o)),c=s.get(a.get(l));n._d=ce(e({source:u,target:c}),r.x,r.y)}}else if(r.orientation===ee.VERTICAL){const e=n.linkVertical().x((e=>e.x)).y((e=>e.y));for(let n of t){let t=n.source,i=n.target,o=t.dataScope.getAttributeValue(Ae),l=i.dataScope.getAttributeValue(Ae),u=s.get(a.get(o)),c=s.get(a.get(l));n._d=ce(e({source:u,target:c}),r.left-r._x0,r.top)}}else if(r.orientation===ee.HORIZONTAL){const e=n.linkHorizontal().x((e=>e.y)).y((e=>e.x));for(let n of t){let t=n.source,i=n.target,o=t.dataScope.getAttributeValue(Ae),l=i.dataScope.getAttributeValue(Ae),u=s.get(a.get(o)),c=s.get(a.get(l));n._d=ce(e({source:u,target:c}),r.left,r.top-r._x0)}}}_updateBezierLinksForDirectedGraph(e,t,r){let n={},i={},s={},a={};for(let t of e){i[t.id]=0,n[t.id]=0;let e=t.links.filter((e=>e.source===t)),r=t.links.filter((e=>e.target===t));a[t.id]=r.map((e=>e.strokeWidth)).reduce(((e,t)=>e+t),0),s[t.id]=e.map((e=>e.strokeWidth)).reduce(((e,t)=>e+t),0)}r.spreadLinks&&("LR"===r.direction||"RL"===r.direction?t.sort(((e,t)=>_e(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y)-_e(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y))):t.sort(((e,t)=>_e(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y)-_e(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y))));for(let e of t){let t,o,l,u,c=e.source,h=e.target;r.spreadLinks?"LR"===r.direction||"RL"===r.direction?(t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0],l=h.bounds[e.targetAnchor[0]]+e.targetOffset[0],o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1]-s[c.id]/2+n[c.id]+e.strokeWidth/2,u=h.bounds[e.targetAnchor[1]]+e.targetOffset[1]-a[h.id]/2+i[h.id]+e.strokeWidth/2,n[c.id]+=e.strokeWidth,i[h.id]+=e.strokeWidth):(o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1],u=h.bounds[e.targetAnchor[1]]+e.targetOffset[1],t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0]-s[c.id]/2+n[c.id]+e.strokeWidth/2,l=h.bounds[e.targetAnchor[0]]+e.targetOffset[0]-a[h.id]/2+i[h.id]+e.strokeWidth/2,n[c.id]+=e.strokeWidth,i[h.id]+=e.strokeWidth):(t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0],o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1],l=h.bounds[e.targetAnchor[0]]+e.targetOffset[0],u=h.bounds[e.targetAnchor[1]]+e.targetOffset[1]),e.orientation===ee.HORIZONTAL?e._setVertices([[t,o],[(t+l)/2,o],[t,u],[l,u]]):e.orientation===ee.VERTICAL&&e._setVertices([[t,o],[t,(o+u)/2],[l,o],[l,u]])}}_updateBundledLinks(e){let t=this._inputVars[0].element.parent.layout;if(t.type!==W.CLUSTER)throw"Bundled links must work on a cluster layout";let r=t._d3Root.leaves();const i=new Map(r.map((e=>[kr(e),e]))),s=new Map(r.map((e=>[e.data[Ae],kr(e)]))),a=n.lineRadial().curve(n.curveBundle.beta(e[0]._strength)).radius((e=>e.y)).angle((e=>e.x));for(let r of e){let e=r.source.dataScope.getAttributeValue(Ae),n=r.target.dataScope.getAttributeValue(Ae),o=i.get(s.get(e)),l=i.get(s.get(n));(o.outgoing??=[]).push([o,l]),l.incoming??=[];let u=o.path(l);r._d=ce(a(u),t.x,t.y)}}_updateChordLinks(e){for(let t of e){let e=t.source,r=t.target,n=Ie(e.x,e.y,e.innerRadius,e.startAngle),i=Ie(e.x,e.y,e.innerRadius,e.endAngle),s=Ie(r.x,r.y,r.innerRadius,r.startAngle),a=Ie(r.x,r.y,r.innerRadius,r.endAngle);t._d=["M",n[0],n[1],"Q",e.x,e.y,a[0],a[1],"A",e.x,e.y,r.angle,r.angle>180?1:0,1,s[0],s[1],"Q",e.x,e.y,i[0],i[1],"A",e.x,e.y,e.angle,e.angle>180?1:0,1,n[0],n[1]].join(" ")}}_updateLineLinks(e){for(let t of e){let e=t.source,r=t.target;t.vertices[0]._x=e.bounds.x,t.vertices[0]._y=e.bounds.y,t.vertices[1]._x=r.bounds.x,t.vertices[1]._y=r.bounds.y}}}function kr(e){return`${e.parent?kr(e.parent)+".":""}${e.data[Ae]}`}var Sr,Tr,Or,Ir,Nr,Lr,Vr,Pr,Dr,Br,Mr,Gr,jr,zr,Fr,Ur,Hr,Wr,Yr,Xr,qr,Kr,Zr,$r,Jr,Qr,en,tn,rn,nn,sn,an,on,ln,un,cn,hn,dn,fn,pn,_n,gn,yn,mn,bn,vn,xn,En,wn,An,Cn,Rn,kn,Sn,Tn,On,In,Nn,Ln,Vn,Pn,Dn,Bn,Mn,Gn,jn,zn,Fn,Un,Hn,Wn,Yn,Xn,qn,Kn,Zn,$n,Jn,Qn,ei,ti,ri,ni,ii,si,ai,oi,li,ui,ci,hi,di,fi,pi,_i,gi,yi,mi,bi,vi,xi,Ei,wi,Ai,Ci,Ri,ki,Si,Ti="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Oi(){if(Ir)return Or;return Ir=1,Or=function(e,t){return e===t||e!=e&&t!=t}}function Ii(){if(Lr)return Nr;Lr=1;var e=Oi();return Nr=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function Ni(){if(Ur)return Fr;Ur=1;var e=Tr?Sr:(Tr=1,Sr=function(){this.__data__=[],this.size=0}),t=function(){if(Pr)return Vr;Pr=1;var e=Ii(),t=Array.prototype.splice;return Vr=function(r){var n=this.__data__,i=e(n,r);return!(i<0||(i==n.length-1?n.pop():t.call(n,i,1),--this.size,0))}}(),r=function(){if(Br)return Dr;Br=1;var e=Ii();return Dr=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function(){if(Gr)return Mr;Gr=1;var e=Ii();return Mr=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(zr)return jr;zr=1;var e=Ii();return jr=function(t,r){var n=this.__data__,i=e(n,t);return i<0?(++this.size,n.push([t,r])):n[i][1]=r,this}}();function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,Fr=s}function Li(){if(Qr)return Jr;Qr=1;var e="object"==typeof Ti&&Ti&&Ti.Object===Object&&Ti;return Jr=e}function Vi(){if(tn)return en;tn=1;var e=Li(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return en=r}function Pi(){if(nn)return rn;nn=1;var e=Vi().Symbol;return rn=e}function Di(){if(cn)return un;cn=1;var e=Pi(),t=function(){if(an)return sn;an=1;var e=Pi(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return sn=
|
|
3
|
-
/**
|
|
4
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
5
|
-
*
|
|
6
|
-
* @private
|
|
7
|
-
* @param {*} value The value to query.
|
|
8
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
9
|
-
*/
|
|
10
|
-
function(e){var t=r.call(e,i),s=e[i];try{e[i]=void 0;var a=!0}catch(e){}var o=n.call(e);return a&&(t?e[i]=s:delete e[i]),o}}(),r=function(){if(ln)return on;ln=1;var e=Object.prototype.toString;return on=function(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return un=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function Bi(){if(dn)return hn;return dn=1,hn=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Mi(){if(pn)return fn;pn=1;var e=Di(),t=Bi();return fn=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function Gi(){if(mn)return yn;mn=1;var e,t=function(){if(gn)return _n;gn=1;var e=Vi()["__core-js_shared__"];return _n=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return yn=function(e){return!!r&&r in e}}function ji(){if(vn)return bn;vn=1;var e=Function.prototype.toString;return bn=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function zi(){if(Rn)return Cn;Rn=1;var e=function(){if(En)return xn;En=1;var e=Mi(),t=Gi(),r=Bi(),n=ji(),i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,o=s.toString,l=a.hasOwnProperty,u=RegExp("^"+o.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return xn=function(s){return!(!r(s)||t(s))&&(e(s)?u:i).test(n(s))}}(),t=An?wn:(An=1,wn=function(e,t){return null==e?void 0:e[t]});return Cn=function(r,n){var i=t(r,n);return e(i)?i:void 0}}function Fi(){if(Sn)return kn;Sn=1;var e=zi()(Vi(),"Map");return kn=e}function Ui(){if(On)return Tn;On=1;var e=zi()(Object,"create");return Tn=e}function Hi(){if(Fn)return zn;Fn=1;var e=function(){if(Nn)return In;Nn=1;var e=Ui();return In=function(){this.__data__=e?e(null):{},this.size=0}}(),t=Vn?Ln:(Vn=1,Ln=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),r=function(){if(Dn)return Pn;Dn=1;var e=Ui(),t=Object.prototype.hasOwnProperty;return Pn=function(r){var n=this.__data__;if(e){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(n,r)?n[r]:void 0}}(),n=function(){if(Mn)return Bn;Mn=1;var e=Ui(),t=Object.prototype.hasOwnProperty;return Bn=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}(),i=function(){if(jn)return Gn;jn=1;var e=Ui();return Gn=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}();function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,zn=s}function Wi(){if(qn)return Xn;qn=1;var e=Yn?Wn:(Yn=1,Wn=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return Xn=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Yi(){if(ii)return ni;ii=1;var e=function(){if(Hn)return Un;Hn=1;var e=Hi(),t=Ni(),r=Fi();return Un=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}(),t=function(){if(Zn)return Kn;Zn=1;var e=Wi();return Kn=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}(),r=function(){if(Jn)return $n;Jn=1;var e=Wi();return $n=function(t){return e(this,t).get(t)}}(),n=function(){if(ei)return Qn;ei=1;var e=Wi();return Qn=function(t){return e(this,t).has(t)}}(),i=function(){if(ri)return ti;ri=1;var e=Wi();return ti=function(t,r){var n=e(this,t),i=n.size;return n.set(t,r),this.size+=n.size==i?0:1,this}}();function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,ni=s}function Xi(){if(li)return oi;li=1;var e=Ni(),t=function(){if(Wr)return Hr;Wr=1;var e=Ni();return Hr=function(){this.__data__=new e,this.size=0}}(),r=Xr?Yr:(Xr=1,Yr=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}),n=Kr?qr:(Kr=1,qr=function(e){return this.__data__.get(e)}),i=$r?Zr:($r=1,Zr=function(e){return this.__data__.has(e)}),s=function(){if(ai)return si;ai=1;var e=Ni(),t=Fi(),r=Yi();return si=function(n,i){var s=this.__data__;if(s instanceof e){var a=s.__data__;if(!t||a.length<199)return a.push([n,i]),this.size=++s.size,this;s=this.__data__=new r(a)}return s.set(n,i),this.size=s.size,this}}();function a(t){var r=this.__data__=new e(t);this.size=r.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=i,a.prototype.set=s,oi=a}
|
|
11
|
-
/**
|
|
12
|
-
* A specialized version of `_.forEach` for arrays without support for
|
|
13
|
-
* iteratee shorthands.
|
|
14
|
-
*
|
|
15
|
-
* @private
|
|
16
|
-
* @param {Array} [array] The array to iterate over.
|
|
17
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
18
|
-
* @returns {Array} Returns `array`.
|
|
19
|
-
*/function qi(){if(ci)return ui;return ci=1,ui=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}}function Ki(){if(di)return hi;di=1;var e=zi(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return hi=t}function Zi(){if(pi)return fi;pi=1;var e=Ki();return fi=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function $i(){if(gi)return _i;gi=1;var e=Zi(),t=Oi(),r=Object.prototype.hasOwnProperty;return _i=function(n,i,s){var a=n[i];r.call(n,i)&&t(a,s)&&(void 0!==s||i in n)||e(n,i,s)}}function Ji(){if(mi)return yi;mi=1;var e=$i(),t=Zi();return yi=function(r,n,i,s){var a=!i;i||(i={});for(var o=-1,l=n.length;++o<l;){var u=n[o],c=s?s(i[u],r[u],u,i,r):void 0;void 0===c&&(c=r[u]),a?t(i,u,c):e(i,u,c)}return i}}function Qi(){if(Ei)return xi;return Ei=1,xi=function(e){return null!=e&&"object"==typeof e}}function es(){if(Ri)return Ci;Ri=1;var e=function(){if(Ai)return wi;Ai=1;var e=Di(),t=Qi();return wi=function(r){return t(r)&&"[object Arguments]"==e(r)}}(),t=Qi(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,s=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!i.call(e,"callee")};return Ci=s}function ts(){if(Si)return ki;Si=1;var e=Array.isArray;return ki=e}var rs,ns,is,ss,as,os,ls,us,cs,hs,ds,fs={exports:{}};function ps(){return is||(is=1,function(e,t){var r=Vi(),n=ns?rs:(ns=1,rs=function(){return!1}),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?r.Buffer:void 0,o=(a?a.isBuffer:void 0)||n;e.exports=o}(fs,fs.exports)),fs.exports}function _s(){if(as)return ss;as=1;var e=/^(?:0|[1-9]\d*)$/;return ss=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function gs(){if(ls)return os;ls=1;return os=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function ys(){if(ds)return hs;return ds=1,hs=function(e){return function(t){return e(t)}}}fs.exports;var ms,bs,vs,xs,Es,ws,As,Cs,Rs,ks,Ss,Ts,Os,Is,Ns,Ls,Vs,Ps,Ds,Bs,Ms,Gs,js,zs,Fs,Us,Hs,Ws={exports:{}};function Ys(){return ms||(ms=1,function(e,t){var r=Li(),n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,s=i&&i.exports===n&&r.process,a=function(){try{var e=i&&i.require&&i.require("util").types;return e||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a}(Ws,Ws.exports)),Ws.exports}function Xs(){if(vs)return bs;vs=1;var e=function(){if(cs)return us;cs=1;var e=Di(),t=gs(),r=Qi(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,us=function(i){return r(i)&&t(i.length)&&!!n[e(i)]}}(),t=ys(),r=Ys(),n=r&&r.isTypedArray,i=n?t(n):e;return bs=i}function qs(){if(Es)return xs;Es=1;var e=vi?bi:(vi=1,bi=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}),t=es(),r=ts(),n=ps(),i=_s(),s=Xs(),a=Object.prototype.hasOwnProperty;return xs=function(o,l){var u=r(o),c=!u&&t(o),h=!u&&!c&&n(o),d=!u&&!c&&!h&&s(o),f=u||c||h||d,p=f?e(o.length,String):[],_=p.length;for(var g in o)!l&&!a.call(o,g)||f&&("length"==g||h&&("offset"==g||"parent"==g)||d&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||i(g,_))||p.push(g);return p}}function Ks(){if(As)return ws;As=1;var e=Object.prototype;return ws=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Zs(){if(Rs)return Cs;return Rs=1,Cs=function(e,t){return function(r){return e(t(r))}}}function $s(){if(Os)return Ts;Os=1;var e=Ks(),t=function(){if(Ss)return ks;Ss=1;var e=Zs()(Object.keys,Object);return ks=e}(),r=Object.prototype.hasOwnProperty;return Ts=function(n){if(!e(n))return t(n);var i=[];for(var s in Object(n))r.call(n,s)&&"constructor"!=s&&i.push(s);return i}}function Js(){if(Ns)return Is;Ns=1;var e=Mi(),t=gs();return Is=function(r){return null!=r&&t(r.length)&&!e(r)}}function Qs(){if(Vs)return Ls;Vs=1;var e=qs(),t=$s(),r=Js();return Ls=function(n){return r(n)?e(n):t(n)}}function ea(){if(js)return Gs;js=1;var e=Bi(),t=Ks(),r=Ms?Bs:(Ms=1,Bs=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}),n=Object.prototype.hasOwnProperty;return Gs=function(i){if(!e(i))return r(i);var s=t(i),a=[];for(var o in i)("constructor"!=o||!s&&n.call(i,o))&&a.push(o);return a}}function ta(){if(Fs)return zs;Fs=1;var e=qs(),t=ea(),r=Js();return zs=function(n){return r(n)?e(n,!0):t(n)}}Ws.exports;var ra,na,ia,sa,aa,oa,la,ua,ca,ha,da,fa,pa,_a,ga,ya,ma,ba,va,xa,Ea,wa,Aa,Ca,Ra,ka,Sa,Ta,Oa,Ia,Na,La,Va,Pa,Da,Ba,Ma,Ga,ja,za,Fa,Ua,Ha,Wa,Ya,Xa,qa,Ka,Za,$a,Ja,Qa,eo,to,ro,no,io,so,ao,oo,lo,uo,co,ho,fo,po,_o,go,yo,mo,bo,vo,xo,Eo,wo,Ao,Co,Ro,ko,So,To,Oo,Io,No,Lo,Vo,Po,Do,Bo,Mo,Go,jo,zo,Fo,Uo,Ho,Wo,Yo,Xo,qo,Ko,Zo,$o,Jo,Qo,el,tl,rl,nl,il,sl,al,ol,ll,ul,cl,hl,dl,fl,pl,_l,gl,yl,ml,bl,vl,xl,El,wl,Al,Cl,Rl,kl,Sl,Tl,Ol,Il,Nl,Ll,Vl,Pl,Dl,Bl,Ml,Gl,jl,zl,Fl,Ul,Hl,Wl,Yl,Xl,ql,Kl,Zl,$l,Jl,Ql,eu,tu,ru,nu,iu,su,au,ou,lu,uu,cu,hu,du,fu,pu,_u,gu,yu,mu,bu,vu,xu,Eu,wu,Au,Cu,Ru,ku,Su,Tu,Ou,Iu,Nu,Lu,Vu,Pu,Du,Bu,Mu,Gu,ju,zu,Fu,Uu,Hu,Wu,Yu,Xu,qu,Ku,Zu,$u,Ju,Qu,ec,tc,rc,nc,ic,sc,ac,oc,lc,uc,cc,hc,dc,fc,pc,_c,gc,yc,mc,bc,vc,xc,Ec,wc,Ac,Cc,Rc,kc,Sc,Tc,Oc,Ic,Nc,Lc,Vc,Pc,Dc,Bc,Mc,Gc,jc,zc,Fc,Uc,Hc,Wc,Yc,Xc,qc,Kc,Zc,$c,Jc,Qc,eh,th,rh,nh,ih,sh,ah,oh,lh,uh,ch,hh,dh,fh={exports:{}};function ph(){return ra||(ra=1,function(e,t){var r=Vi(),n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,s=i&&i.exports===n?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=a?a(r):new e.constructor(r);return e.copy(n),n}}(fh,fh.exports)),fh.exports}function _h(){if(ia)return na;return ia=1,na=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}
|
|
20
|
-
/**
|
|
21
|
-
* A specialized version of `_.filter` for arrays without support for
|
|
22
|
-
* iteratee shorthands.
|
|
23
|
-
*
|
|
24
|
-
* @private
|
|
25
|
-
* @param {Array} [array] The array to iterate over.
|
|
26
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
27
|
-
* @returns {Array} Returns the new filtered array.
|
|
28
|
-
*/function gh(){if(aa)return sa;return aa=1,sa=function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var a=e[r];t(a,r,e)&&(s[i++]=a)}return s}}function yh(){if(la)return oa;return la=1,oa=function(){return[]}}function mh(){if(ca)return ua;ca=1;var e=gh(),t=yh(),r=Object.prototype.propertyIsEnumerable,n=Object.getOwnPropertySymbols;return ua=n?function(t){return null==t?[]:(t=Object(t),e(n(t),(function(e){return r.call(t,e)})))}:t}function bh(){if(pa)return fa;return pa=1,fa=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}}function vh(){if(ga)return _a;ga=1;var e=Zs()(Object.getPrototypeOf,Object);return _a=e}function xh(){if(ma)return ya;ma=1;var e=bh(),t=vh(),r=mh(),n=yh(),i=Object.getOwnPropertySymbols;return ya=i?function(n){for(var i=[];n;)e(i,r(n)),n=t(n);return i}:n}function Eh(){if(Ea)return xa;Ea=1;var e=bh(),t=ts();return xa=function(r,n,i){var s=n(r);return t(r)?s:e(s,i(r))}}function wh(){if(Aa)return wa;Aa=1;var e=Eh(),t=mh(),r=Qs();return wa=function(n){return e(n,r,t)}}function Ah(){if(Na)return Ia;Na=1;var e=zi()(Vi(),"Set");return Ia=e}function Ch(){if(Da)return Pa;Da=1;var e=function(){if(Sa)return ka;Sa=1;var e=zi()(Vi(),"DataView");return ka=e}(),t=Fi(),r=function(){if(Oa)return Ta;Oa=1;var e=zi()(Vi(),"Promise");return Ta=e}(),n=Ah(),i=function(){if(Va)return La;Va=1;var e=zi()(Vi(),"WeakMap");return La=e}(),s=Di(),a=ji(),o="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(e),f=a(t),p=a(r),_=a(n),g=a(i),y=s;return(e&&y(new e(new ArrayBuffer(1)))!=h||t&&y(new t)!=o||r&&y(r.resolve())!=l||n&&y(new n)!=u||i&&y(new i)!=c)&&(y=function(e){var t=s(e),r="[object Object]"==t?e.constructor:void 0,n=r?a(r):"";if(n)switch(n){case d:return h;case f:return o;case p:return l;case _:return u;case g:return c}return t}),Pa=y}function Rh(){if(ja)return Ga;ja=1;var e=Vi().Uint8Array;return Ga=e}function kh(){if(Fa)return za;Fa=1;var e=Rh();return za=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function Sh(){if(Za)return Ka;Za=1;var e=kh();return Ka=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Th(){if(Ja)return $a;Ja=1;var e=kh(),t=function(){if(Ha)return Ua;Ha=1;var e=kh();return Ua=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}}(),r=function(){if(Ya)return Wa;Ya=1;var e=/\w*$/;return Wa=function(t){var r=new t.constructor(t.source,e.exec(t));return r.lastIndex=t.lastIndex,r}}(),n=function(){if(qa)return Xa;qa=1;var e=Pi(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;return Xa=function(e){return r?Object(r.call(e)):{}}}(),i=Sh();return $a=function(s,a,o){var l=s.constructor;switch(a){case"[object ArrayBuffer]":return e(s);case"[object Boolean]":case"[object Date]":return new l(+s);case"[object DataView]":return t(s,o);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(s,o);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(s);case"[object RegExp]":return r(s);case"[object Symbol]":return n(s)}}}function Oh(){if(eo)return Qa;eo=1;var e=Bi(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var i=new r;return r.prototype=void 0,i}}();return Qa=r}function Ih(){if(ro)return to;ro=1;var e=Oh(),t=vh(),r=Ks();return to=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function Nh(){if(ao)return so;ao=1;var e=function(){if(io)return no;io=1;var e=Ch(),t=Qi();return no=function(r){return t(r)&&"[object Map]"==e(r)}}(),t=ys(),r=Ys(),n=r&&r.isMap,i=n?t(n):e;return so=i}function Lh(){if(co)return uo;co=1;var e=function(){if(lo)return oo;lo=1;var e=Ch(),t=Qi();return oo=function(r){return t(r)&&"[object Set]"==e(r)}}(),t=ys(),r=Ys(),n=r&&r.isSet,i=n?t(n):e;return uo=i}function Vh(){if(fo)return ho;fo=1;var e=Xi(),t=qi(),r=$i(),n=function(){if(Ds)return Ps;Ds=1;var e=Ji(),t=Qs();return Ps=function(r,n){return r&&e(n,t(n),r)}}(),i=function(){if(Hs)return Us;Hs=1;var e=Ji(),t=ta();return Us=function(r,n){return r&&e(n,t(n),r)}}(),s=ph(),a=_h(),o=function(){if(da)return ha;da=1;var e=Ji(),t=mh();return ha=function(r,n){return e(r,t(r),n)}}(),l=function(){if(va)return ba;va=1;var e=Ji(),t=xh();return ba=function(r,n){return e(r,t(r),n)}}(),u=wh(),c=function(){if(Ra)return Ca;Ra=1;var e=Eh(),t=xh(),r=ta();return Ca=function(n){return e(n,r,t)}}(),h=Ch(),d=function(){if(Ma)return Ba;Ma=1;var e=Object.prototype.hasOwnProperty;return Ba=function(t){var r=t.length,n=new t.constructor(r);return r&&"string"==typeof t[0]&&e.call(t,"index")&&(n.index=t.index,n.input=t.input),n}}(),f=Th(),p=Ih(),_=ts(),g=ps(),y=Nh(),m=Bi(),b=Lh(),v=Qs(),x=ta(),E="[object Arguments]",w="[object Function]",A="[object Object]",C={};return C[E]=C["[object Array]"]=C["[object ArrayBuffer]"]=C["[object DataView]"]=C["[object Boolean]"]=C["[object Date]"]=C["[object Float32Array]"]=C["[object Float64Array]"]=C["[object Int8Array]"]=C["[object Int16Array]"]=C["[object Int32Array]"]=C["[object Map]"]=C["[object Number]"]=C[A]=C["[object RegExp]"]=C["[object Set]"]=C["[object String]"]=C["[object Symbol]"]=C["[object Uint8Array]"]=C["[object Uint8ClampedArray]"]=C["[object Uint16Array]"]=C["[object Uint32Array]"]=!0,C["[object Error]"]=C[w]=C["[object WeakMap]"]=!1,ho=function R(k,S,T,O,I,N){var L,V=1&S,P=2&S,D=4&S;if(T&&(L=I?T(k,O,I,N):T(k)),void 0!==L)return L;if(!m(k))return k;var B=_(k);if(B){if(L=d(k),!V)return a(k,L)}else{var M=h(k),G=M==w||"[object GeneratorFunction]"==M;if(g(k))return s(k,V);if(M==A||M==E||G&&!I){if(L=P||G?{}:p(k),!V)return P?l(k,i(L,k)):o(k,n(L,k))}else{if(!C[M])return I?k:{};L=f(k,M,V)}}N||(N=new e);var j=N.get(k);if(j)return j;N.set(k,L),b(k)?k.forEach((function(e){L.add(R(e,S,T,e,k,N))})):y(k)&&k.forEach((function(e,t){L.set(t,R(e,S,T,t,k,N))}));var z=B?void 0:(D?P?c:u:P?x:v)(k);return t(z||k,(function(e,t){z&&(e=k[t=e]),r(L,t,R(e,S,T,t,k,N))})),L},ho}function Ph(){if(_o)return po;_o=1;var e=Vh();return po=function(t){return e(t,4)}}function Dh(){if(yo)return go;return yo=1,go=function(e){return function(){return e}}}function Bh(){if(xo)return vo;xo=1;var e=(bo?mo:(bo=1,mo=function(e){return function(t,r,n){for(var i=-1,s=Object(t),a=n(t),o=a.length;o--;){var l=a[e?o:++i];if(!1===r(s[l],l,s))break}return t}}))();return vo=e}function Mh(){if(wo)return Eo;wo=1;var e=Bh(),t=Qs();return Eo=function(r,n){return r&&e(r,n,t)}}function Gh(){if(ko)return Ro;ko=1;var e=Mh(),t=function(){if(Co)return Ao;Co=1;var e=Js();return Ao=function(t,r){return function(n,i){if(null==n)return n;if(!e(n))return t(n,i);for(var s=n.length,a=r?s:-1,o=Object(n);(r?a--:++a<s)&&!1!==i(o[a],a,o););return n}}}()(e);return Ro=t}function jh(){if(To)return So;return To=1,So=function(e){return e}}function zh(){if(Io)return Oo;Io=1;var e=jh();return Oo=function(t){return"function"==typeof t?t:e}}function Fh(){if(Lo)return No;Lo=1;var e=qi(),t=Gh(),r=zh(),n=ts();return No=function(i,s){return(n(i)?e:t)(i,r(s))}}function Uh(){return Po?Vo:(Po=1,Vo=Fh())}function Hh(){if(Uo)return Fo;Uo=1;var e=Yi(),t=Go?Mo:(Go=1,Mo=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}),r=zo?jo:(zo=1,jo=function(e){return this.__data__.has(e)});function n(t){var r=-1,n=null==t?0:t.length;for(this.__data__=new e;++r<n;)this.add(t[r])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Fo=n}
|
|
29
|
-
/**
|
|
30
|
-
* A specialized version of `_.some` for arrays without support for iteratee
|
|
31
|
-
* shorthands.
|
|
32
|
-
*
|
|
33
|
-
* @private
|
|
34
|
-
* @param {Array} [array] The array to iterate over.
|
|
35
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
36
|
-
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
37
|
-
* else `false`.
|
|
38
|
-
*/function Wh(){if(Xo)return Yo;return Xo=1,Yo=function(e,t){return e.has(t)}}function Yh(){if(Ko)return qo;Ko=1;var e=Hh(),t=Wo?Ho:(Wo=1,Ho=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}),r=Wh();return qo=
|
|
39
|
-
/**
|
|
40
|
-
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
41
|
-
* partial deep comparisons.
|
|
42
|
-
*
|
|
43
|
-
* @private
|
|
44
|
-
* @param {Array} array The array to compare.
|
|
45
|
-
* @param {Array} other The other array to compare.
|
|
46
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
47
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
48
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
49
|
-
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
50
|
-
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
51
|
-
*/
|
|
52
|
-
function(n,i,s,a,o,l){var u=1&s,c=n.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(n),f=l.get(i);if(d&&f)return d==i&&f==n;var p=-1,_=!0,g=2&s?new e:void 0;for(l.set(n,i),l.set(i,n);++p<c;){var y=n[p],m=i[p];if(a)var b=u?a(m,y,p,i,n,l):a(y,m,p,n,i,l);if(void 0!==b){if(b)continue;_=!1;break}if(g){if(!t(i,(function(e,t){if(!r(g,t)&&(y===e||o(y,e,s,a,l)))return g.push(t)}))){_=!1;break}}else if(y!==m&&!o(y,m,s,a,l)){_=!1;break}}return l.delete(n),l.delete(i),_}}function Xh(){if(Qo)return Jo;return Qo=1,Jo=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}}function qh(){if(tl)return el;tl=1;var e=Pi(),t=Rh(),r=Oi(),n=Yh(),i=$o?Zo:($o=1,Zo=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}),s=Xh(),a=e?e.prototype:void 0,o=a?a.valueOf:void 0;return el=
|
|
53
|
-
/**
|
|
54
|
-
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
55
|
-
* the same `toStringTag`.
|
|
56
|
-
*
|
|
57
|
-
* **Note:** This function only supports comparing values with tags of
|
|
58
|
-
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
59
|
-
*
|
|
60
|
-
* @private
|
|
61
|
-
* @param {Object} object The object to compare.
|
|
62
|
-
* @param {Object} other The other object to compare.
|
|
63
|
-
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
64
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
65
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
66
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
67
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
68
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
69
|
-
*/
|
|
70
|
-
function(e,a,l,u,c,h,d){switch(l){case"[object DataView]":if(e.byteLength!=a.byteLength||e.byteOffset!=a.byteOffset)return!1;e=e.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=a.byteLength||!h(new t(e),new t(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return r(+e,+a);case"[object Error]":return e.name==a.name&&e.message==a.message;case"[object RegExp]":case"[object String]":return e==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=s),e.size!=a.size&&!p)return!1;var _=d.get(e);if(_)return _==a;u|=2,d.set(e,a);var g=n(f(e),f(a),u,c,h,d);return d.delete(e),g;case"[object Symbol]":if(o)return o.call(e)==o.call(a)}return!1}}function Kh(){if(sl)return il;sl=1;var e=Xi(),t=Yh(),r=qh(),n=function(){if(nl)return rl;nl=1;var e=wh(),t=Object.prototype.hasOwnProperty;return rl=
|
|
71
|
-
/**
|
|
72
|
-
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
73
|
-
* partial deep comparisons.
|
|
74
|
-
*
|
|
75
|
-
* @private
|
|
76
|
-
* @param {Object} object The object to compare.
|
|
77
|
-
* @param {Object} other The other object to compare.
|
|
78
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
79
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
80
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
81
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
82
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
83
|
-
*/
|
|
84
|
-
function(r,n,i,s,a,o){var l=1&i,u=e(r),c=u.length;if(c!=e(n).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?d in n:t.call(n,d)))return!1}var f=o.get(r),p=o.get(n);if(f&&p)return f==n&&p==r;var _=!0;o.set(r,n),o.set(n,r);for(var g=l;++h<c;){var y=r[d=u[h]],m=n[d];if(s)var b=l?s(m,y,d,n,r,o):s(y,m,d,r,n,o);if(!(void 0===b?y===m||a(y,m,i,s,o):b)){_=!1;break}g||(g="constructor"==d)}if(_&&!g){var v=r.constructor,x=n.constructor;v==x||!("constructor"in r)||!("constructor"in n)||"function"==typeof v&&v instanceof v&&"function"==typeof x&&x instanceof x||(_=!1)}return o.delete(r),o.delete(n),_}}(),i=Ch(),s=ts(),a=ps(),o=Xs(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return il=
|
|
85
|
-
/**
|
|
86
|
-
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
87
|
-
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
88
|
-
* references to be compared.
|
|
89
|
-
*
|
|
90
|
-
* @private
|
|
91
|
-
* @param {Object} object The object to compare.
|
|
92
|
-
* @param {Object} other The other object to compare.
|
|
93
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
94
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
95
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
96
|
-
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
97
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
98
|
-
*/
|
|
99
|
-
function(d,f,p,_,g,y){var m=s(d),b=s(f),v=m?u:i(d),x=b?u:i(f),E=(v=v==l?c:v)==c,w=(x=x==l?c:x)==c,A=v==x;if(A&&a(d)){if(!a(f))return!1;m=!0,E=!1}if(A&&!E)return y||(y=new e),m||o(d)?t(d,f,p,_,g,y):r(d,f,v,p,_,g,y);if(!(1&p)){var C=E&&h.call(d,"__wrapped__"),R=w&&h.call(f,"__wrapped__");if(C||R){var k=C?d.value():d,S=R?f.value():f;return y||(y=new e),g(k,S,p,_,y)}}return!!A&&(y||(y=new e),n(d,f,p,_,g,y))}}function Zh(){if(ol)return al;ol=1;var e=Kh(),t=Qi();return al=function r(n,i,s,a,o){return n===i||(null==n||null==i||!t(n)&&!t(i)?n!=n&&i!=i:e(n,i,s,a,r,o))},al}function $h(){if(hl)return cl;hl=1;var e=Bi();return cl=function(t){return t==t&&!e(t)}}function Jh(){if(_l)return pl;return _l=1,pl=function(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}}function Qh(){if(yl)return gl;yl=1;var e=function(){if(ul)return ll;ul=1;var e=Xi(),t=Zh();return ll=function(r,n,i,s){var a=i.length,o=a,l=!s;if(null==r)return!o;for(r=Object(r);a--;){var u=i[a];if(l&&u[2]?u[1]!==r[u[0]]:!(u[0]in r))return!1}for(;++a<o;){var c=(u=i[a])[0],h=r[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in r))return!1}else{var f=new e;if(s)var p=s(h,d,c,r,n,f);if(!(void 0===p?t(d,h,3,s,f):p))return!1}}return!0}}(),t=function(){if(fl)return dl;fl=1;var e=$h(),t=Qs();return dl=function(r){for(var n=t(r),i=n.length;i--;){var s=n[i],a=r[s];n[i]=[s,a,e(a)]}return n}}
|
|
100
|
-
/**
|
|
101
|
-
* A specialized version of `matchesProperty` for source values suitable
|
|
102
|
-
* for strict equality comparisons, i.e. `===`.
|
|
103
|
-
*
|
|
104
|
-
* @private
|
|
105
|
-
* @param {string} key The key of the property to get.
|
|
106
|
-
* @param {*} srcValue The value to match.
|
|
107
|
-
* @returns {Function} Returns the new spec function.
|
|
108
|
-
*/(),r=Jh();return gl=function(n){var i=t(n);return 1==i.length&&i[0][2]?r(i[0][0],i[0][1]):function(t){return t===n||e(t,n,i)}}}function ed(){if(bl)return ml;bl=1;var e=Di(),t=Qi();return ml=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function td(){if(xl)return vl;xl=1;var e=ts(),t=ed(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return vl=function(i,s){if(e(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!t(i))||(n.test(i)||!r.test(i)||null!=s&&i in Object(s))}}function rd(){if(Cl)return Al;Cl=1;var e=function(){if(wl)return El;wl=1;var e=Yi();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var e=arguments,t=n?n.apply(this,e):e[0],s=i.cache;if(s.has(t))return s.get(t);var a=r.apply(this,e);return i.cache=s.set(t,a)||s,a};return i.cache=new(t.Cache||e),i}return t.Cache=e,El=t}();return Al=
|
|
109
|
-
/**
|
|
110
|
-
* A specialized version of `_.memoize` which clears the memoized function's
|
|
111
|
-
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
112
|
-
*
|
|
113
|
-
* @private
|
|
114
|
-
* @param {Function} func The function to have its output memoized.
|
|
115
|
-
* @returns {Function} Returns the new memoized function.
|
|
116
|
-
*/
|
|
117
|
-
function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function nd(){if(Tl)return Sl;return Tl=1,Sl=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}}function id(){if(Ll)return Nl;Ll=1;var e=function(){if(Il)return Ol;Il=1;var e=Pi(),t=nd(),r=ts(),n=ed(),i=e?e.prototype:void 0,s=i?i.toString:void 0;return Ol=function e(i){if("string"==typeof i)return i;if(r(i))return t(i,e)+"";if(n(i))return s?s.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},Ol}();return Nl=function(t){return null==t?"":e(t)}}function sd(){if(Pl)return Vl;Pl=1;var e=ts(),t=td(),r=function(){if(kl)return Rl;kl=1;var e=rd(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e((function(e){var n=[];return 46===e.charCodeAt(0)&&n.push(""),e.replace(t,(function(e,t,i,s){n.push(i?s.replace(r,"$1"):t||e)})),n}));return Rl=n}
|
|
118
|
-
/**
|
|
119
|
-
* A specialized version of `_.map` for arrays without support for iteratee
|
|
120
|
-
* shorthands.
|
|
121
|
-
*
|
|
122
|
-
* @private
|
|
123
|
-
* @param {Array} [array] The array to iterate over.
|
|
124
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
125
|
-
* @returns {Array} Returns the new mapped array.
|
|
126
|
-
*/(),n=id();return Vl=function(i,s){return e(i)?i:t(i,s)?[i]:r(n(i))}}function ad(){if(Bl)return Dl;Bl=1;var e=ed();return Dl=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r}}function od(){if(Gl)return Ml;Gl=1;var e=sd(),t=ad();return Ml=function(r,n){for(var i=0,s=(n=e(n,r)).length;null!=r&&i<s;)r=r[t(n[i++])];return i&&i==s?r:void 0}}function ld(){if(Wl)return Hl;Wl=1;var e=sd(),t=es(),r=ts(),n=_s(),i=gs(),s=ad();return Hl=function(a,o,l){for(var u=-1,c=(o=e(o,a)).length,h=!1;++u<c;){var d=s(o[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&n(d,c)&&(r(a)||t(a))}}function ud(){if(Xl)return Yl;Xl=1;var e=Ul?Fl:(Ul=1,Fl=function(e,t){return null!=e&&t in Object(e)}),t=ld();return Yl=function(r,n){return null!=r&&t(r,n,e)}}function cd(){if(Kl)return ql;Kl=1;var e=Zh(),t=function(){if(zl)return jl;zl=1;var e=od();return jl=function(t,r,n){var i=null==t?void 0:e(t,r);return void 0===i?n:i}}(),r=ud(),n=td(),i=$h(),s=Jh(),a=ad();return ql=function(o,l){return n(o)&&i(l)?s(a(o),l):function(n){var i=t(n,o);return void 0===i&&i===l?r(n,o):e(l,i,3)}}}function hd(){if($l)return Zl;return $l=1,Zl=function(e){return function(t){return null==t?void 0:t[e]}}}function dd(){if(tu)return eu;tu=1;var e=hd(),t=function(){if(Ql)return Jl;Ql=1;var e=od();
|
|
127
|
-
/**
|
|
128
|
-
* A specialized version of `baseProperty` which supports deep paths.
|
|
129
|
-
*
|
|
130
|
-
* @private
|
|
131
|
-
* @param {Array|string} path The path of the property to get.
|
|
132
|
-
* @returns {Function} Returns the new accessor function.
|
|
133
|
-
*/return Jl=function(t){return function(r){return e(r,t)}}}(),r=td(),n=ad();return eu=function(i){return r(i)?e(n(i)):t(i)}}function fd(){if(nu)return ru;nu=1;var e=Qh(),t=cd(),r=jh(),n=ts(),i=dd();return ru=function(s){return"function"==typeof s?s:null==s?r:"object"==typeof s?n(s)?t(s[0],s[1]):e(s):i(s)}}function pd(){if(su)return iu;su=1;var e=gh(),t=function(){if(Bo)return Do;Bo=1;var e=Gh();return Do=function(t,r){var n=[];return e(t,(function(e,t,i){r(e,t,i)&&n.push(e)})),n}}(),r=fd(),n=ts();return iu=function(i,s){return(n(i)?e:t)(i,r(s,3))}}function _d(){if(uu)return lu;uu=1;var e=function(){if(ou)return au;ou=1;var e=Object.prototype.hasOwnProperty;return au=function(t,r){return null!=t&&e.call(t,r)}}(),t=ld();return lu=function(r,n){return null!=r&&t(r,n,e)}}function gd(){if(hu)return cu;hu=1;var e=$s(),t=Ch(),r=es(),n=ts(),i=Js(),s=ps(),a=Ks(),o=Xs(),l=Object.prototype.hasOwnProperty;return cu=function(u){if(null==u)return!0;if(i(u)&&(n(u)||"string"==typeof u||"function"==typeof u.splice||s(u)||o(u)||r(u)))return!u.length;var c=t(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!e(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function yd(){if(fu)return du;return fu=1,du=function(e){return void 0===e}}function md(){if(_u)return pu;_u=1;var e=Gh(),t=Js();return pu=function(r,n){var i=-1,s=t(r)?Array(r.length):[];return e(r,(function(e,t,r){s[++i]=n(e,t,r)})),s}}function bd(){if(yu)return gu;yu=1;var e=nd(),t=fd(),r=md(),n=ts();return gu=function(i,s){return(n(i)?e:r)(i,t(s,3))}}
|
|
134
|
-
/**
|
|
135
|
-
* A specialized version of `_.reduce` for arrays without support for
|
|
136
|
-
* iteratee shorthands.
|
|
137
|
-
*
|
|
138
|
-
* @private
|
|
139
|
-
* @param {Array} [array] The array to iterate over.
|
|
140
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
141
|
-
* @param {*} [accumulator] The initial value.
|
|
142
|
-
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
|
143
|
-
* the initial value.
|
|
144
|
-
* @returns {*} Returns the accumulated value.
|
|
145
|
-
*/function vd(){if(wu)return Eu;wu=1;var e=bu?mu:(bu=1,mu=function(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}),t=Gh(),r=fd(),n=xu?vu:(xu=1,vu=function(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}),i=ts();return Eu=function(s,a,o){var l=i(s)?e:n,u=arguments.length<3;return l(s,r(a,4),o,u,t)},Eu}function xd(){if(Lu)return Nu;Lu=1;var e=function(){if(ku)return Ru;ku=1;var e=hd()("length");return Ru=e}(),t=function(){if(Tu)return Su;Tu=1;var e=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return Su=function(t){return e.test(t)}}(),r=function(){if(Iu)return Ou;Iu=1;var e="\\ud800-\\udfff",t="["+e+"]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",n="\\ud83c[\\udffb-\\udfff]",i="[^"+e+"]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",o="(?:"+r+"|"+n+")?",l="[\\ufe0e\\ufe0f]?",u=l+o+"(?:\\u200d(?:"+[i,s,a].join("|")+")"+l+o+")*",c="(?:"+[i+r+"?",r,s,a,t].join("|")+")",h=RegExp(n+"(?="+n+")|"+c+u,"g");return Ou=function(e){for(var t=h.lastIndex=0;h.test(e);)++t;return t}}();return Nu=function(n){return t(n)?r(n):e(n)}}function Ed(){if(Pu)return Vu;Pu=1;var e=$s(),t=Ch(),r=Js(),n=function(){if(Cu)return Au;Cu=1;var e=Di(),t=ts(),r=Qi();return Au=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}(),i=xd();return Vu=function(s){if(null==s)return 0;if(r(s))return n(s)?i(s):s.length;var a=t(s);return"[object Map]"==a||"[object Set]"==a?s.size:e(s).length}}function wd(){if(Bu)return Du;Bu=1;var e=qi(),t=Oh(),r=Mh(),n=fd(),i=vh(),s=ts(),a=ps(),o=Mi(),l=Bi(),u=Xs();return Du=function(c,h,d){var f=s(c),p=f||a(c)||u(c);if(h=n(h,4),null==d){var _=c&&c.constructor;d=p?f?new _:[]:l(c)&&o(_)?t(i(c)):{}}return(p?e:r)(c,(function(e,t,r){return h(d,e,t,r)})),d}}function Ad(){if(zu)return ju;zu=1;var e=bh(),t=function(){if(Gu)return Mu;Gu=1;var e=Pi(),t=es(),r=ts(),n=e?e.isConcatSpreadable:void 0;return Mu=function(e){return r(e)||t(e)||!!(n&&e&&e[n])}}();return ju=function r(n,i,s,a,o){var l=-1,u=n.length;for(s||(s=t),o||(o=[]);++l<u;){var c=n[l];i>0&&s(c)?i>1?r(c,i-1,s,a,o):e(o,c):a||(o[o.length]=c)}return o},ju}function Cd(){if(Wu)return Hu;Wu=1;var e=Uu?Fu:(Uu=1,Fu=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}),t=Math.max;return Hu=
|
|
146
|
-
/**
|
|
147
|
-
* A specialized version of `baseRest` which transforms the rest array.
|
|
148
|
-
*
|
|
149
|
-
* @private
|
|
150
|
-
* @param {Function} func The function to apply a rest parameter to.
|
|
151
|
-
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
152
|
-
* @param {Function} transform The rest array transform.
|
|
153
|
-
* @returns {Function} Returns the new function.
|
|
154
|
-
*/
|
|
155
|
-
function(r,n,i){return n=t(void 0===n?r.length-1:n,0),function(){for(var s=arguments,a=-1,o=t(s.length-n,0),l=Array(o);++a<o;)l[a]=s[n+a];a=-1;for(var u=Array(n+1);++a<n;)u[a]=s[a];return u[n]=i(l),e(r,this,u)}},Hu}function Rd(){if($u)return Zu;$u=1;var e=function(){if(Xu)return Yu;Xu=1;var e=Dh(),t=Ki(),r=jh();return Yu=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:r}(),t=function(){if(Ku)return qu;Ku=1;var e=Date.now;return qu=function(t){var r=0,n=0;return function(){var i=e(),s=16-(i-n);if(n=i,s>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},qu}(),r=t(e);return Zu=r}function kd(){if(Qu)return Ju;Qu=1;var e=jh(),t=Cd(),r=Rd();return Ju=function(n,i){return r(t(n,i,e),n+"")}}function Sd(){if(tc)return ec;return tc=1,ec=function(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}}function Td(){if(oc)return ac;oc=1;var e=Sd(),t=nc?rc:(nc=1,rc=function(e){return e!=e}),r=sc?ic:(sc=1,ic=function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1});return ac=function(n,i,s){return i==i?r(n,i,s):e(n,t,s)}}function Od(){if(_c)return pc;_c=1;var e=Ah(),t=fc?dc:(fc=1,dc=function(){}),r=Xh(),n=e&&1/r(new e([,-0]))[1]==1/0?function(t){return new e(t)}:t;return pc=n}function Id(){if(yc)return gc;yc=1;var e=Hh(),t=function(){if(uc)return lc;uc=1;var e=Td();
|
|
156
|
-
/**
|
|
157
|
-
* A specialized version of `_.includes` for arrays without support for
|
|
158
|
-
* specifying an index to search from.
|
|
159
|
-
*
|
|
160
|
-
* @private
|
|
161
|
-
* @param {Array} [array] The array to inspect.
|
|
162
|
-
* @param {*} target The value to search for.
|
|
163
|
-
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
164
|
-
*/return lc=function(t,r){return!(null==t||!t.length)&&e(t,r,0)>-1}}(),r=hc?cc:(hc=1,cc=function(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}),n=Wh(),i=Od(),s=Xh();return gc=function(a,o,l){var u=-1,c=t,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=r;else if(h>=200){var _=o?null:i(a);if(_)return s(_);d=!1,c=n,p=new e}else p=o?[]:f;e:for(;++u<h;){var g=a[u],y=o?o(g):g;if(g=l||0!==g?g:0,d&&y==y){for(var m=p.length;m--;)if(p[m]===y)continue e;o&&p.push(y),f.push(g)}else c(p,y,l)||(p!==f&&p.push(y),f.push(g))}return f}}function Nd(){if(bc)return mc;bc=1;var e=Js(),t=Qi();return mc=function(r){return t(r)&&e(r)}}function Ld(){if(xc)return vc;xc=1;var e=Ad(),t=kd(),r=Id(),n=Nd(),i=t((function(t){return r(e(t,1,n,!0))}));return vc=i}function Vd(){if(Cc)return Ac;Cc=1;var e=function(){if(wc)return Ec;wc=1;var e=nd();return Ec=function(t,r){return e(r,(function(e){return t[e]}))}}(),t=Qs();return Ac=function(r){return null==r?[]:e(r,t(r))}}function Pd(){if(kc)return Rc;var e;kc=1;try{e={clone:Ph(),constant:Dh(),each:Uh(),filter:pd(),has:_d(),isArray:ts(),isEmpty:gd(),isFunction:Mi(),isUndefined:yd(),keys:Qs(),map:bd(),reduce:vd(),size:Ed(),transform:wd(),union:Ld(),values:Vd()}}catch(e){}return e||(e=window._),Rc=e}function Dd(){if(Tc)return Sc;Tc=1;var e=Pd();Sc=i;var t="\0",r="\0",n="";function i(t){this._isDirected=!e.has(t,"directed")||t.directed,this._isMultigraph=!!e.has(t,"multigraph")&&t.multigraph,this._isCompound=!!e.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function s(e,t){e[t]?e[t]++:e[t]=1}function a(e,t){--e[t]||delete e[t]}function o(r,i,s,a){var o=""+i,l=""+s;if(!r&&o>l){var u=o;o=l,l=u}return o+n+l+n+(e.isUndefined(a)?t:a)}function l(e,t){return o(e,t.v,t.w,t.name)}return i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(e){return this._label=e,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultNodeLabelFn=t,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var t=this;return e.filter(this.nodes(),(function(r){return e.isEmpty(t._in[r])}))},i.prototype.sinks=function(){var t=this;return e.filter(this.nodes(),(function(r){return e.isEmpty(t._out[r])}))},i.prototype.setNodes=function(t,r){var n=arguments,i=this;return e.each(t,(function(e){n.length>1?i.setNode(e,r):i.setNode(e)})),this},i.prototype.setNode=function(t,n){return e.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=r,this._children[t]={},this._children[r][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},i.prototype.node=function(e){return this._nodes[e]},i.prototype.hasNode=function(t){return e.has(this._nodes,t)},i.prototype.removeNode=function(t){var r=this;if(e.has(this._nodes,t)){var n=function(e){r.removeEdge(r._edgeObjs[e])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],e.each(this.children(t),(function(e){r.setParent(e)})),delete this._children[t]),e.each(e.keys(this._in[t]),n),delete this._in[t],delete this._preds[t],e.each(e.keys(this._out[t]),n),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},i.prototype.setParent=function(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(n))n=r;else{for(var i=n+="";!e.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this},i.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},i.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==r)return t}},i.prototype.children=function(t){if(e.isUndefined(t)&&(t=r),this._isCompound){var n=this._children[t];if(n)return e.keys(n)}else{if(t===r)return this.nodes();if(this.hasNode(t))return[]}},i.prototype.predecessors=function(t){var r=this._preds[t];if(r)return e.keys(r)},i.prototype.successors=function(t){var r=this._sucs[t];if(r)return e.keys(r)},i.prototype.neighbors=function(t){var r=this.predecessors(t);if(r)return e.union(r,this.successors(t))},i.prototype.isLeaf=function(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length},i.prototype.filterNodes=function(t){var r=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});r.setGraph(this.graph());var n=this;e.each(this._nodes,(function(e,n){t(n)&&r.setNode(n,e)})),e.each(this._edgeObjs,(function(e){r.hasNode(e.v)&&r.hasNode(e.w)&&r.setEdge(e,n.edge(e))}));var i={};function s(e){var t=n.parent(e);return void 0===t||r.hasNode(t)?(i[e]=t,t):t in i?i[t]:s(t)}return this._isCompound&&e.each(r.nodes(),(function(e){r.setParent(e,s(e))})),r},i.prototype.setDefaultEdgeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultEdgeLabelFn=t,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(t,r){var n=this,i=arguments;return e.reduce(t,(function(e,t){return i.length>1?n.setEdge(e,t,r):n.setEdge(e,t),t})),this},i.prototype.setEdge=function(){var t,r,n,i,a=!1,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(t=l.v,r=l.w,n=l.name,2===arguments.length&&(i=arguments[1],a=!0)):(t=l,r=arguments[1],n=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),t=""+t,r=""+r,e.isUndefined(n)||(n=""+n);var u=o(this._isDirected,t,r,n);if(e.has(this._edgeLabels,u))return a&&(this._edgeLabels[u]=i),this;if(!e.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(r),this._edgeLabels[u]=a?i:this._defaultEdgeLabelFn(t,r,n);var c=function(e,t,r,n){var i=""+t,s=""+r;if(!e&&i>s){var a=i;i=s,s=a}var o={v:i,w:s};n&&(o.name=n);return o}(this._isDirected,t,r,n);return t=c.v,r=c.w,Object.freeze(c),this._edgeObjs[u]=c,s(this._preds[r],t),s(this._sucs[t],r),this._in[r][u]=c,this._out[t][u]=c,this._edgeCount++,this},i.prototype.edge=function(e,t,r){var n=1===arguments.length?l(this._isDirected,arguments[0]):o(this._isDirected,e,t,r);return this._edgeLabels[n]},i.prototype.hasEdge=function(t,r,n){var i=1===arguments.length?l(this._isDirected,arguments[0]):o(this._isDirected,t,r,n);return e.has(this._edgeLabels,i)},i.prototype.removeEdge=function(e,t,r){var n=1===arguments.length?l(this._isDirected,arguments[0]):o(this._isDirected,e,t,r),i=this._edgeObjs[n];return i&&(e=i.v,t=i.w,delete this._edgeLabels[n],delete this._edgeObjs[n],a(this._preds[t],e),a(this._sucs[e],t),delete this._in[t][n],delete this._out[e][n],this._edgeCount--),this},i.prototype.inEdges=function(t,r){var n=this._in[t];if(n){var i=e.values(n);return r?e.filter(i,(function(e){return e.v===r})):i}},i.prototype.outEdges=function(t,r){var n=this._out[t];if(n){var i=e.values(n);return r?e.filter(i,(function(e){return e.w===r})):i}},i.prototype.nodeEdges=function(e,t){var r=this.inEdges(e,t);if(r)return r.concat(this.outEdges(e,t))},Sc}function Bd(){return Lc?Nc:(Lc=1,Nc={Graph:Dd(),version:Ic?Oc:(Ic=1,Oc="2.1.8")})}function Md(){if(Pc)return Vc;Pc=1;var e=Pd(),t=Dd();function r(t){return e.map(t.nodes(),(function(r){var n=t.node(r),i=t.parent(r),s={v:r};return e.isUndefined(n)||(s.value=n),e.isUndefined(i)||(s.parent=i),s}))}function n(t){return e.map(t.edges(),(function(r){var n=t.edge(r),i={v:r.v,w:r.w};return e.isUndefined(r.name)||(i.name=r.name),e.isUndefined(n)||(i.value=n),i}))}return Vc={write:function(t){var i={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:r(t),edges:n(t)};e.isUndefined(t.graph())||(i.value=e.clone(t.graph()));return i},read:function(r){var n=new t(r.options).setGraph(r.value);return e.each(r.nodes,(function(e){n.setNode(e.v,e.value),e.parent&&n.setParent(e.v,e.parent)})),e.each(r.edges,(function(e){n.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),n}}}function Gd(){if(Bc)return Dc;Bc=1;var e=Pd();return Dc=function(t){var r,n={},i=[];function s(i){e.has(n,i)||(n[i]=!0,r.push(i),e.each(t.successors(i),s),e.each(t.predecessors(i),s))}return e.each(t.nodes(),(function(e){r=[],s(e),r.length&&i.push(r)})),i},Dc}function jd(){if(Gc)return Mc;Gc=1;var e=Pd();function t(){this._arr=[],this._keyIndices={}}return Mc=t,t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map((function(e){return e.key}))},t.prototype.has=function(t){return e.has(this._keyIndices,t)},t.prototype.priority=function(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority},t.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(t,r){var n=this._keyIndices;if(t=String(t),!e.has(n,t)){var i=this._arr,s=i.length;return n[t]=s,i.push({key:t,priority:r}),this._decrease(s),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},t.prototype.decrease=function(e,t){var r=this._keyIndices[e];if(t>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)},t.prototype._heapify=function(e){var t=this._arr,r=2*e,n=r+1,i=e;r<t.length&&(i=t[r].priority<t[i].priority?r:i,n<t.length&&(i=t[n].priority<t[i].priority?n:i),i!==e&&(this._swap(e,i),this._heapify(i)))},t.prototype._decrease=function(e){for(var t,r=this._arr,n=r[e].priority;0!==e&&!(r[t=e>>1].priority<n);)this._swap(e,t),e=t},t.prototype._swap=function(e,t){var r=this._arr,n=this._keyIndices,i=r[e],s=r[t];r[e]=s,r[t]=i,n[s.key]=e,n[i.key]=t},Mc}function zd(){if(zc)return jc;zc=1;var e=Pd(),t=jd();jc=function(e,n,i,s){return function(e,r,n,i){var s,a,o={},l=new t,u=function(e){var t=e.v!==s?e.v:e.w,r=o[t],i=n(e),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+i);u<r.distance&&(r.distance=u,r.predecessor=s,l.decrease(t,u))};e.nodes().forEach((function(e){var t=e===r?0:Number.POSITIVE_INFINITY;o[e]={distance:t},l.add(e,t)}));for(;l.size()>0&&(s=l.removeMin(),(a=o[s]).distance!==Number.POSITIVE_INFINITY);)i(s).forEach(u);return o}(e,String(n),i||r,s||function(t){return e.outEdges(t)})};var r=e.constant(1);return jc}function Fd(){if(Uc)return Fc;Uc=1;var e=zd(),t=Pd();return Fc=function(r,n,i){return t.transform(r.nodes(),(function(t,s){t[s]=e(r,s,n,i)}),{})}}function Ud(){if(Wc)return Hc;Wc=1;var e=Pd();return Hc=function(t){var r=0,n=[],i={},s=[];function a(o){var l=i[o]={onStack:!0,lowlink:r,index:r++};if(n.push(o),t.successors(o).forEach((function(t){e.has(i,t)?i[t].onStack&&(l.lowlink=Math.min(l.lowlink,i[t].index)):(a(t),l.lowlink=Math.min(l.lowlink,i[t].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=n.pop(),i[u].onStack=!1,c.push(u)}while(o!==u);s.push(c)}}return t.nodes().forEach((function(t){e.has(i,t)||a(t)})),s},Hc}function Hd(){if(Xc)return Yc;Xc=1;var e=Pd(),t=Ud();return Yc=function(r){return e.filter(t(r),(function(e){return e.length>1||1===e.length&&r.hasEdge(e[0],e[0])}))}}function Wd(){if(Kc)return qc;Kc=1;var e=Pd();qc=function(e,r,n){return function(e,t,r){var n={},i=e.nodes();return i.forEach((function(e){n[e]={},n[e][e]={distance:0},i.forEach((function(t){e!==t&&(n[e][t]={distance:Number.POSITIVE_INFINITY})})),r(e).forEach((function(r){var i=r.v===e?r.w:r.v,s=t(r);n[e][i]={distance:s,predecessor:e}}))})),i.forEach((function(e){var t=n[e];i.forEach((function(r){var s=n[r];i.forEach((function(r){var n=s[e],i=t[r],a=s[r],o=n.distance+i.distance;o<a.distance&&(a.distance=o,a.predecessor=i.predecessor)}))}))})),n}(e,r||t,n||function(t){return e.outEdges(t)})};var t=e.constant(1);return qc}function Yd(){if($c)return Zc;$c=1;var e=Pd();function t(t){var n={},i={},s=[];if(e.each(t.sinks(),(function a(o){if(e.has(i,o))throw new r;e.has(n,o)||(i[o]=!0,n[o]=!0,e.each(t.predecessors(o),a),delete i[o],s.push(o))})),e.size(n)!==t.nodeCount())throw new r;return s}function r(){}return Zc=t,t.CycleException=r,r.prototype=new Error,Zc}function Xd(){if(Qc)return Jc;Qc=1;var e=Yd();return Jc=function(t){try{e(t)}catch(t){if(t instanceof e.CycleException)return!1;throw t}return!0}}function qd(){if(th)return eh;th=1;var e=Pd();function t(r,n,i,s,a,o){e.has(s,n)||(s[n]=!0,i||o.push(n),e.each(a(n),(function(e){t(r,e,i,s,a,o)})),i&&o.push(n))}return eh=function(r,n,i){e.isArray(n)||(n=[n]);var s=(r.isDirected()?r.successors:r.neighbors).bind(r),a=[],o={};return e.each(n,(function(e){if(!r.hasNode(e))throw new Error("Graph does not have node: "+e);t(r,e,"post"===i,o,s,a)})),a},eh}function Kd(){if(nh)return rh;nh=1;var e=qd();return rh=function(t,r){return e(t,r,"post")}}function Zd(){if(sh)return ih;sh=1;var e=qd();return ih=function(t,r){return e(t,r,"pre")}}function $d(){if(oh)return ah;oh=1;var e=Pd(),t=Dd(),r=jd();return ah=function(n,i){var s,a=new t,o={},l=new r;function u(e){var t=e.v===s?e.w:e.v,r=l.priority(t);if(void 0!==r){var n=i(e);n<r&&(o[t]=s,l.decrease(t,n))}}if(0===n.nodeCount())return a;e.each(n.nodes(),(function(e){l.add(e,Number.POSITIVE_INFINITY),a.setNode(e)})),l.decrease(n.nodes()[0],0);var c=!1;for(;l.size()>0;){if(s=l.removeMin(),e.has(o,s))a.setEdge(s,o[s]);else{if(c)throw new Error("Input graph is not connected: "+n);c=!0}n.nodeEdges(s).forEach(u)}return a}}fh.exports;try{dh=function(){if(hh)return ch;hh=1;var e=Bd();return ch={Graph:e.Graph,json:Md(),alg:uh?lh:(uh=1,lh={components:Gd(),dijkstra:zd(),dijkstraAll:Fd(),findCycles:Hd(),floydWarshall:Wd(),isAcyclic:Xd(),postorder:Kd(),preorder:Zd(),prim:$d(),tarjan:Ud(),topsort:Yd()}),version:e.version}}()}catch(e){}dh||(dh=window.graphlib);var Jd,Qd,ef,tf,rf,nf,sf,af,of,lf,uf,cf,hf,df,ff,pf,_f,gf,yf,mf,bf,vf,xf,Ef,wf,Af,Cf,Rf,kf,Sf,Tf,Of,If,Nf,Lf,Vf,Pf,Df,Bf,Mf,Gf,jf,zf,Ff,Uf,Hf,Wf,Yf,Xf,qf,Kf,Zf,$f,Jf,Qf,ep,tp,rp,np,ip,sp,ap,op,lp,up,cp,hp,dp,fp,pp,_p,gp,yp,mp,bp,vp,xp,Ep,wp,Ap,Cp,Rp,kp,Sp,Tp,Op,Ip,Np,Lp,Vp,Pp,Dp,Bp,Mp=dh;function Gp(){if(tf)return ef;tf=1;var e=Oi(),t=Js(),r=_s(),n=Bi();return ef=function(i,s,a){if(!n(a))return!1;var o=typeof s;return!!("number"==o?t(a)&&r(s,a.length):"string"==o&&s in a)&&e(a[s],i)}}function jp(){if(cf)return uf;cf=1;var e=function(){if(lf)return of;lf=1;var e=/\s/;return of=function(t){for(var r=t.length;r--&&e.test(t.charAt(r)););return r}}(),t=/^\s+/;return uf=function(r){return r?r.slice(0,e(r)+1).replace(t,""):r}}function zp(){if(pf)return ff;pf=1;var e=function(){if(df)return hf;df=1;var e=jp(),t=Bi(),r=ed(),n=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;return hf=function(o){if("number"==typeof o)return o;if(r(o))return NaN;if(t(o)){var l="function"==typeof o.valueOf?o.valueOf():o;o=t(l)?l+"":l}if("string"!=typeof o)return 0===o?o:+o;o=e(o);var u=i.test(o);return u||s.test(o)?a(o.slice(2),u?2:8):n.test(o)?NaN:+o}}(),t=1/0;return ff=function(r){return r?(r=e(r))===t||r===-1/0?17976931348623157e292*(r<0?-1:1):r==r?r:0:0===r?r:0}}function Fp(){if(mf)return yf;mf=1;var e=Sd(),t=fd(),r=function(){if(gf)return _f;gf=1;var e=zp();return _f=function(t){var r=e(t),n=r%1;return r==r?n?r-n:r:0}}(),n=Math.max;return yf=function(i,s,a){var o=null==i?0:i.length;if(!o)return-1;var l=null==a?0:r(a);return l<0&&(l=n(o+l,0)),e(i,t(s,3),l)}}function Up(){if(Ef)return xf;Ef=1;var e=Ad();return xf=function(t){return(null==t?0:t.length)?e(t,1):[]}}function Hp(){if(Of)return Tf;Of=1;var e=ed();return Tf=function(t,r,n){for(var i=-1,s=t.length;++i<s;){var a=t[i],o=r(a);if(null!=o&&(void 0===l?o==o&&!e(o):n(o,l)))var l=o,u=a}return u}}function Wp(){if(Df)return Pf;Df=1;var e=Zi(),t=Oi();return Pf=function(r,n,i){(void 0!==i&&!t(r[n],i)||void 0===i&&!(n in r))&&e(r,n,i)}}function Yp(){if(jf)return Gf;return jf=1,Gf=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function Xp(){if(Hf)return Uf;Hf=1;var e=Wp(),t=ph(),r=Sh(),n=_h(),i=Ih(),s=es(),a=ts(),o=Nd(),l=ps(),u=Mi(),c=Bi(),h=function(){if(Mf)return Bf;Mf=1;var e=Di(),t=vh(),r=Qi(),n=Function.prototype,i=Object.prototype,s=n.toString,a=i.hasOwnProperty,o=s.call(Object);return Bf=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var i=t(n);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&s.call(l)==o}}(),d=Xs(),f=Yp(),p=function(){if(Ff)return zf;Ff=1;var e=Ji(),t=ta();return zf=function(r){return e(r,t(r))}}();
|
|
165
|
-
/**
|
|
166
|
-
* A specialized version of `baseMerge` for arrays and objects which performs
|
|
167
|
-
* deep merges and tracks traversed objects enabling objects with circular
|
|
168
|
-
* references to be merged.
|
|
169
|
-
*
|
|
170
|
-
* @private
|
|
171
|
-
* @param {Object} object The destination object.
|
|
172
|
-
* @param {Object} source The source object.
|
|
173
|
-
* @param {string} key The key of the value to merge.
|
|
174
|
-
* @param {number} srcIndex The index of `source`.
|
|
175
|
-
* @param {Function} mergeFunc The function to merge values.
|
|
176
|
-
* @param {Function} [customizer] The function to customize assigned values.
|
|
177
|
-
* @param {Object} [stack] Tracks traversed source values and their merged
|
|
178
|
-
* counterparts.
|
|
179
|
-
*/return Uf=function(_,g,y,m,b,v,x){var E=f(_,y),w=f(g,y),A=x.get(w);if(A)e(_,y,A);else{var C=v?v(E,w,y+"",_,g,x):void 0,R=void 0===C;if(R){var k=a(w),S=!k&&l(w),T=!k&&!S&&d(w);C=w,k||S||T?a(E)?C=E:o(E)?C=n(E):S?(R=!1,C=t(w,!0)):T?(R=!1,C=r(w,!0)):C=[]:h(w)||s(w)?(C=E,s(E)?C=p(E):c(E)&&!u(E)||(C=i(w))):R=!1}R&&(x.set(w,C),b(C,w,m,v,x),x.delete(w)),e(_,y,C)}}}function qp(){if(Jf)return $f;return Jf=1,$f=function(e,t){return e<t}}function Kp(){if(lp)return op;lp=1;var e=od(),t=function(){if(ap)return sp;ap=1;var e=$i(),t=sd(),r=_s(),n=Bi(),i=ad();return sp=function(s,a,o,l){if(!n(s))return s;for(var u=-1,c=(a=t(a,s)).length,h=c-1,d=s;null!=d&&++u<c;){var f=i(a[u]),p=o;if("__proto__"===f||"constructor"===f||"prototype"===f)return s;if(u!=h){var _=d[f];void 0===(p=l?l(_,f,d):void 0)&&(p=n(_)?_:r(a[u+1])?[]:{})}e(d,f,p),d=d[f]}return s}}(),r=sd();return op=function(n,i,s){for(var a=-1,o=i.length,l={};++a<o;){var u=i[a],c=e(n,u);s(c,u)&&t(l,r(u,n),c)}return l}}function Zp(){if(mp)return yp;mp=1;var e=function(){if(gp)return _p;gp=1;var e=Math.ceil,t=Math.max;return _p=function(r,n,i,s){for(var a=-1,o=t(e((n-r)/(i||1)),0),l=Array(o);o--;)l[s?o:++a]=r,r+=i;return l}}(),t=Gp(),r=zp();return yp=function(n){return function(i,s,a){return a&&"number"!=typeof a&&t(i,s,a)&&(s=a=void 0),i=r(i),void 0===s?(s=i,i=0):s=r(s),a=void 0===a?i<s?1:-1:r(a),e(i,s,a,n)}}}function $p(){if(Rp)return Cp;Rp=1;var e=function(){if(Ap)return wp;Ap=1;var e=ed();return wp=function(t,r){if(t!==r){var n=void 0!==t,i=null===t,s=t==t,a=e(t),o=void 0!==r,l=null===r,u=r==r,c=e(r);if(!l&&!c&&!a&&t>r||a&&o&&u&&!l&&!c||i&&o&&u||!n&&u||!s)return 1;if(!i&&!a&&!c&&t<r||c&&n&&s&&!i&&!a||l&&n&&s||!o&&s||!u)return-1}return 0}}();return Cp=function(t,r,n){for(var i=-1,s=t.criteria,a=r.criteria,o=s.length,l=n.length;++i<o;){var u=e(s[i],a[i]);if(u)return i>=l?u:u*("desc"==n[i]?-1:1)}return t.index-r.index}}function Jp(){if(Sp)return kp;Sp=1;var e=nd(),t=od(),r=fd(),n=md(),i=Ep?xp:(Ep=1,xp=function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}),s=ys(),a=$p(),o=jh(),l=ts();return kp=function(u,c,h){c=c.length?e(c,(function(e){return l(e)?function(r){return t(r,1===e.length?e[0]:e)}:e})):[o];var d=-1;c=e(c,s(r));var f=n(u,(function(t,r,n){return{criteria:e(c,(function(e){return e(t)})),index:++d,value:t}}));return i(f,(function(e,t){return a(e,t,h)}))}}try{Bp={cloneDeep:function(){if(Qd)return Jd;Qd=1;var e=Vh();return Jd=function(t){return e(t,5)}}(),constant:Dh(),defaults:function(){if(nf)return rf;nf=1;var e=kd(),t=Oi(),r=Gp(),n=ta(),i=Object.prototype,s=i.hasOwnProperty,a=e((function(e,a){e=Object(e);var o=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&r(a[0],a[1],u)&&(l=1);++o<l;)for(var c=a[o],h=n(c),d=-1,f=h.length;++d<f;){var p=h[d],_=e[p];(void 0===_||t(_,i[p])&&!s.call(e,p))&&(e[p]=c[p])}return e}));return rf=a}(),each:Uh(),filter:pd(),find:function(){if(vf)return bf;vf=1;var e=function(){if(af)return sf;af=1;var e=fd(),t=Js(),r=Qs();return sf=function(n){return function(i,s,a){var o=Object(i);if(!t(i)){var l=e(s,3);i=r(i),s=function(e){return l(o[e],e,o)}}var u=n(i,s,a);return u>-1?o[l?i[u]:u]:void 0}}}()(Fp());return bf=e}(),flatten:Up(),forEach:Fh(),forIn:function(){if(Af)return wf;Af=1;var e=Bh(),t=zh(),r=ta();return wf=function(n,i){return null==n?n:e(n,t(i),r)}}(),has:_d(),isUndefined:yd(),last:Rf?Cf:(Rf=1,Cf=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}),map:bd(),mapValues:function(){if(Sf)return kf;Sf=1;var e=Zi(),t=Mh(),r=fd();return kf=function(n,i){var s={};return i=r(i,3),t(n,(function(t,r,n){e(s,r,i(t,r,n))})),s}}(),max:function(){if(Vf)return Lf;Vf=1;var e=Hp(),t=Nf?If:(Nf=1,If=function(e,t){return e>t}),r=jh();return Lf=function(n){return n&&n.length?e(n,r,t):void 0}}(),merge:function(){if(Zf)return Kf;Zf=1;var e=function(){if(Yf)return Wf;Yf=1;var e=Xi(),t=Wp(),r=Bh(),n=Xp(),i=Bi(),s=ta(),a=Yp();return Wf=function o(l,u,c,h,d){l!==u&&r(u,(function(r,s){if(d||(d=new e),i(r))n(l,u,s,c,o,h,d);else{var f=h?h(a(l,s),r,s+"",l,u,d):void 0;void 0===f&&(f=r),t(l,s,f)}}),s)},Wf}(),t=function(){if(qf)return Xf;qf=1;var e=kd(),t=Gp();return Xf=function(r){return e((function(e,n){var i=-1,s=n.length,a=s>1?n[s-1]:void 0,o=s>2?n[2]:void 0;for(a=r.length>3&&"function"==typeof a?(s--,a):void 0,o&&t(n[0],n[1],o)&&(a=s<3?void 0:a,s=1),e=Object(e);++i<s;){var l=n[i];l&&r(e,l,i,a)}return e}))}}()((function(t,r,n){e(t,r,n)}));return Kf=t}(),min:function(){if(ep)return Qf;ep=1;var e=Hp(),t=qp(),r=jh();return Qf=function(n){return n&&n.length?e(n,r,t):void 0}}(),minBy:function(){if(rp)return tp;rp=1;var e=Hp(),t=fd(),r=qp();return tp=function(n,i){return n&&n.length?e(n,t(i,2),r):void 0}}(),now:function(){if(ip)return np;ip=1;var e=Vi();return np=function(){return e.Date.now()}}(),pick:function(){if(pp)return fp;pp=1;var e=function(){if(cp)return up;cp=1;var e=Kp(),t=ud();return up=function(r,n){return e(r,n,(function(e,n){return t(r,n)}))}}(),t=function(){if(dp)return hp;dp=1;var e=Up(),t=Cd(),r=Rd();
|
|
180
|
-
/**
|
|
181
|
-
* A specialized version of `baseRest` which flattens the rest array.
|
|
182
|
-
*
|
|
183
|
-
* @private
|
|
184
|
-
* @param {Function} func The function to apply a rest parameter to.
|
|
185
|
-
* @returns {Function} Returns the new function.
|
|
186
|
-
*/return hp=function(n){return r(t(n,void 0,e),n+"")}}()((function(t,r){return null==t?{}:e(t,r)}));return fp=t}(),range:function(){if(vp)return bp;vp=1;var e=Zp()();return bp=e}(),reduce:vd(),sortBy:function(){if(Op)return Tp;Op=1;var e=Ad(),t=Jp(),r=kd(),n=Gp(),i=r((function(r,i){if(null==r)return[];var s=i.length;return s>1&&n(r,i[0],i[1])?i=[]:s>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(r,e(i,1),[])}));return Tp=i}(),uniqueId:function(){if(Np)return Ip;Np=1;var e=id(),t=0;return Ip=function(r){var n=++t;return e(r)+n},Ip}(),values:Vd(),zipObject:function(){if(Dp)return Pp;Dp=1;var e=$i(),t=Vp?Lp:(Vp=1,Lp=function(e,t,r){for(var n=-1,i=e.length,s=t.length,a={};++n<i;){var o=n<s?t[n]:void 0;r(a,e[n],o)}return a});return Pp=function(r,n){return t(r||[],n||[],e)}}()}}catch(e){}Bp||(Bp=window._);var Qp=Bp,e_=t_;function t_(){var e={};e._next=e._prev=e,this._sentinel=e}function r_(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function n_(e,t){if("_next"!==e&&"_prev"!==e)return t}t_.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return r_(t),t},t_.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&r_(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t},t_.prototype.toString=function(){for(var e=[],t=this._sentinel,r=t._prev;r!==t;)e.push(JSON.stringify(r,n_)),r=r._prev;return"["+e.join(", ")+"]"};var i_=Qp,s_=Mp.Graph,a_=e_,o_=function(e,t){if(e.nodeCount()<=1)return[];var r=function(e,t){var r=new s_,n=0,i=0;i_.forEach(e.nodes(),(function(e){r.setNode(e,{v:e,in:0,out:0})})),i_.forEach(e.edges(),(function(e){var s=r.edge(e.v,e.w)||0,a=t(e),o=s+a;r.setEdge(e.v,e.w,o),i=Math.max(i,r.node(e.v).out+=a),n=Math.max(n,r.node(e.w).in+=a)}));var s=i_.range(i+n+3).map((function(){return new a_})),a=n+1;return i_.forEach(r.nodes(),(function(e){c_(s,a,r.node(e))})),{graph:r,buckets:s,zeroIdx:a}}(e,t||l_),n=function(e,t,r){var n,i=[],s=t[t.length-1],a=t[0];for(;e.nodeCount();){for(;n=a.dequeue();)u_(e,t,r,n);for(;n=s.dequeue();)u_(e,t,r,n);if(e.nodeCount())for(var o=t.length-2;o>0;--o)if(n=t[o].dequeue()){i=i.concat(u_(e,t,r,n,!0));break}}return i}(r.graph,r.buckets,r.zeroIdx);return i_.flatten(i_.map(n,(function(t){return e.outEdges(t.v,t.w)})),!0)},l_=i_.constant(1);function u_(e,t,r,n,i){var s=i?[]:void 0;return i_.forEach(e.inEdges(n.v),(function(n){var a=e.edge(n),o=e.node(n.v);i&&s.push({v:n.v,w:n.w}),o.out-=a,c_(t,r,o)})),i_.forEach(e.outEdges(n.v),(function(n){var i=e.edge(n),s=n.w,a=e.node(s);a.in-=i,c_(t,r,a)})),e.removeNode(n.v),s}function c_(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}var h_=Qp,d_=o_,f_={run:function(e){var t="greedy"===e.graph().acyclicer?d_(e,function(e){return function(t){return e.edge(t).weight}}(e)):function(e){var t=[],r={},n={};function i(s){h_.has(n,s)||(n[s]=!0,r[s]=!0,h_.forEach(e.outEdges(s),(function(e){h_.has(r,e.w)?t.push(e):i(e.w)})),delete r[s])}return h_.forEach(e.nodes(),i),t}(e);h_.forEach(t,(function(t){var r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,h_.uniqueId("rev"))}))},undo:function(e){h_.forEach(e.edges(),(function(t){var r=e.edge(t);if(r.reversed){e.removeEdge(t);var n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}}))}};var p_=Qp,__=Mp.Graph,g_={addDummyNode:y_,simplify:function(e){var t=(new __).setGraph(e.graph());return p_.forEach(e.nodes(),(function(r){t.setNode(r,e.node(r))})),p_.forEach(e.edges(),(function(r){var n=t.edge(r.v,r.w)||{weight:0,minlen:1},i=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+i.weight,minlen:Math.max(n.minlen,i.minlen)})})),t},asNonCompoundGraph:function(e){var t=new __({multigraph:e.isMultigraph()}).setGraph(e.graph());return p_.forEach(e.nodes(),(function(r){e.children(r).length||t.setNode(r,e.node(r))})),p_.forEach(e.edges(),(function(r){t.setEdge(r,e.edge(r))})),t},successorWeights:function(e){var t=p_.map(e.nodes(),(function(t){var r={};return p_.forEach(e.outEdges(t),(function(t){r[t.w]=(r[t.w]||0)+e.edge(t).weight})),r}));return p_.zipObject(e.nodes(),t)},predecessorWeights:function(e){var t=p_.map(e.nodes(),(function(t){var r={};return p_.forEach(e.inEdges(t),(function(t){r[t.v]=(r[t.v]||0)+e.edge(t).weight})),r}));return p_.zipObject(e.nodes(),t)},intersectRect:function(e,t){var r,n,i=e.x,s=e.y,a=t.x-i,o=t.y-s,l=e.width/2,u=e.height/2;if(!a&&!o)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(o)*l>Math.abs(a)*u?(o<0&&(u=-u),r=u*a/o,n=u):(a<0&&(l=-l),r=l,n=l*o/a);return{x:i+r,y:s+n}},buildLayerMatrix:function(e){var t=p_.map(p_.range(m_(e)+1),(function(){return[]}));return p_.forEach(e.nodes(),(function(r){var n=e.node(r),i=n.rank;p_.isUndefined(i)||(t[i][n.order]=r)})),t},normalizeRanks:function(e){var t=p_.min(p_.map(e.nodes(),(function(t){return e.node(t).rank})));p_.forEach(e.nodes(),(function(r){var n=e.node(r);p_.has(n,"rank")&&(n.rank-=t)}))},removeEmptyRanks:function(e){var t=p_.min(p_.map(e.nodes(),(function(t){return e.node(t).rank}))),r=[];p_.forEach(e.nodes(),(function(n){var i=e.node(n).rank-t;r[i]||(r[i]=[]),r[i].push(n)}));var n=0,i=e.graph().nodeRankFactor;p_.forEach(r,(function(t,r){p_.isUndefined(t)&&r%i!=0?--n:n&&p_.forEach(t,(function(t){e.node(t).rank+=n}))}))},addBorderNode:function(e,t,r,n){var i={width:0,height:0};arguments.length>=4&&(i.rank=r,i.order=n);return y_(e,"border",i,t)},maxRank:m_,partition:function(e,t){var r={lhs:[],rhs:[]};return p_.forEach(e,(function(e){t(e)?r.lhs.push(e):r.rhs.push(e)})),r},time:function(e,t){var r=p_.now();try{return t()}finally{console.log(e+" time: "+(p_.now()-r)+"ms")}},notime:function(e,t){return t()}};function y_(e,t,r,n){var i;do{i=p_.uniqueId(n)}while(e.hasNode(i));return r.dummy=t,e.setNode(i,r),i}function m_(e){return p_.max(p_.map(e.nodes(),(function(t){var r=e.node(t).rank;if(!p_.isUndefined(r))return r})))}var b_=Qp,v_=g_,x_={run:function(e){e.graph().dummyChains=[],b_.forEach(e.edges(),(function(t){!function(e,t){var r,n,i,s=t.v,a=e.node(s).rank,o=t.w,l=e.node(o).rank,u=t.name,c=e.edge(t),h=c.labelRank;if(l===a+1)return;for(e.removeEdge(t),i=0,++a;a<l;++i,++a)c.points=[],n={width:0,height:0,edgeLabel:c,edgeObj:t,rank:a},r=v_.addDummyNode(e,"edge",n,"_d"),a===h&&(n.width=c.width,n.height=c.height,n.dummy="edge-label",n.labelpos=c.labelpos),e.setEdge(s,r,{weight:c.weight},u),0===i&&e.graph().dummyChains.push(r),s=r;e.setEdge(s,o,{weight:c.weight},u)}(e,t)}))},undo:function(e){b_.forEach(e.graph().dummyChains,(function(t){var r,n=e.node(t),i=n.edgeLabel;for(e.setEdge(n.edgeObj,i);n.dummy;)r=e.successors(t)[0],e.removeNode(t),i.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height),t=r,n=e.node(t)}))}};var E_=Qp,w_={longestPath:function(e){var t={};E_.forEach(e.sources(),(function r(n){var i=e.node(n);if(E_.has(t,n))return i.rank;t[n]=!0;var s=E_.min(E_.map(e.outEdges(n),(function(t){return r(t.w)-e.edge(t).minlen})));return s!==Number.POSITIVE_INFINITY&&null!=s||(s=0),i.rank=s}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var A_=Qp,C_=Mp.Graph,R_=w_.slack,k_=function(e){var t,r,n=new C_({directed:!1}),i=e.nodes()[0],s=e.nodeCount();n.setNode(i,{});for(;S_(n,e)<s;)t=T_(n,e),r=n.hasNode(t.v)?R_(e,t):-R_(e,t),O_(n,e,r);return n};function S_(e,t){return A_.forEach(e.nodes(),(function r(n){A_.forEach(t.nodeEdges(n),(function(i){var s=i.v,a=n===s?i.w:s;e.hasNode(a)||R_(t,i)||(e.setNode(a,{}),e.setEdge(n,a,{}),r(a))}))})),e.nodeCount()}function T_(e,t){return A_.minBy(t.edges(),(function(r){if(e.hasNode(r.v)!==e.hasNode(r.w))return R_(t,r)}))}function O_(e,t,r){A_.forEach(e.nodes(),(function(e){t.node(e).rank+=r}))}var I_=Qp,N_=k_,L_=w_.slack,V_=w_.longestPath,P_=Mp.alg.preorder,D_=Mp.alg.postorder,B_=g_.simplify,M_=G_;function G_(e){e=B_(e),V_(e);var t,r=N_(e);for(F_(r),j_(r,e);t=H_(r);)Y_(r,e,t,W_(r,e,t))}function j_(e,t){var r=D_(e,e.nodes());r=r.slice(0,r.length-1),I_.forEach(r,(function(r){!function(e,t,r){var n=e.node(r),i=n.parent;e.edge(r,i).cutvalue=z_(e,t,r)}(e,t,r)}))}function z_(e,t,r){var n=e.node(r).parent,i=!0,s=t.edge(r,n),a=0;return s||(i=!1,s=t.edge(n,r)),a=s.weight,I_.forEach(t.nodeEdges(r),(function(s){var o,l,u=s.v===r,c=u?s.w:s.v;if(c!==n){var h=u===i,d=t.edge(s).weight;if(a+=h?d:-d,o=r,l=c,e.hasEdge(o,l)){var f=e.edge(r,c).cutvalue;a+=h?-f:f}}})),a}function F_(e,t){arguments.length<2&&(t=e.nodes()[0]),U_(e,{},1,t)}function U_(e,t,r,n,i){var s=r,a=e.node(n);return t[n]=!0,I_.forEach(e.neighbors(n),(function(i){I_.has(t,i)||(r=U_(e,t,r,i,n))})),a.low=s,a.lim=r++,i?a.parent=i:delete a.parent,r}function H_(e){return I_.find(e.edges(),(function(t){return e.edge(t).cutvalue<0}))}function W_(e,t,r){var n=r.v,i=r.w;t.hasEdge(n,i)||(n=r.w,i=r.v);var s=e.node(n),a=e.node(i),o=s,l=!1;s.lim>a.lim&&(o=a,l=!0);var u=I_.filter(t.edges(),(function(t){return l===X_(e,e.node(t.v),o)&&l!==X_(e,e.node(t.w),o)}));return I_.minBy(u,(function(e){return L_(t,e)}))}function Y_(e,t,r,n){var i=r.v,s=r.w;e.removeEdge(i,s),e.setEdge(n.v,n.w,{}),F_(e),j_(e,t),function(e,t){var r=I_.find(e.nodes(),(function(e){return!t.node(e).parent})),n=P_(e,r);n=n.slice(1),I_.forEach(n,(function(r){var n=e.node(r).parent,i=t.edge(r,n),s=!1;i||(i=t.edge(n,r),s=!0),t.node(r).rank=t.node(n).rank+(s?i.minlen:-i.minlen)}))}(e,t)}function X_(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}G_.initLowLimValues=F_,G_.initCutValues=j_,G_.calcCutValue=z_,G_.leaveEdge=H_,G_.enterEdge=W_,G_.exchangeEdges=Y_;var q_=w_.longestPath,K_=k_,Z_=M_,$_=function(e){switch(e.graph().ranker){case"network-simplex":default:Q_(e);break;case"tight-tree":!function(e){q_(e),K_(e)}(e);break;case"longest-path":J_(e)}};var J_=q_;function Q_(e){Z_(e)}var eg=Qp,tg=function(e){var t=function(e){var t={},r=0;function n(i){var s=r;eg.forEach(e.children(i),n),t[i]={low:s,lim:r++}}return eg.forEach(e.children(),n),t}(e);eg.forEach(e.graph().dummyChains,(function(r){for(var n=e.node(r),i=n.edgeObj,s=function(e,t,r,n){var i,s,a=[],o=[],l=Math.min(t[r].low,t[n].low),u=Math.max(t[r].lim,t[n].lim);i=r;do{i=e.parent(i),a.push(i)}while(i&&(t[i].low>l||u>t[i].lim));s=i,i=n;for(;(i=e.parent(i))!==s;)o.push(i);return{path:a.concat(o.reverse()),lca:s}}(e,t,i.v,i.w),a=s.path,o=s.lca,l=0,u=a[l],c=!0;r!==i.w;){if(n=e.node(r),c){for(;(u=a[l])!==o&&e.node(u).maxRank<n.rank;)l++;u===o&&(c=!1)}if(!c){for(;l<a.length-1&&e.node(u=a[l+1]).minRank<=n.rank;)l++;u=a[l]}e.setParent(r,u),r=e.successors(r)[0]}}))};var rg=Qp,ng=g_,ig={run:function(e){var t=ng.addDummyNode(e,"root",{},"_root"),r=function(e){var t={};function r(n,i){var s=e.children(n);s&&s.length&&rg.forEach(s,(function(e){r(e,i+1)})),t[n]=i}return rg.forEach(e.children(),(function(e){r(e,1)})),t}(e),n=rg.max(rg.values(r))-1,i=2*n+1;e.graph().nestingRoot=t,rg.forEach(e.edges(),(function(t){e.edge(t).minlen*=i}));var s=function(e){return rg.reduce(e.edges(),(function(t,r){return t+e.edge(r).weight}),0)}(e)+1;rg.forEach(e.children(),(function(a){sg(e,t,i,s,n,r,a)})),e.graph().nodeRankFactor=i},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,rg.forEach(e.edges(),(function(t){e.edge(t).nestingEdge&&e.removeEdge(t)}))}};function sg(e,t,r,n,i,s,a){var o=e.children(a);if(o.length){var l=ng.addBorderNode(e,"_bt"),u=ng.addBorderNode(e,"_bb"),c=e.node(a);e.setParent(l,a),c.borderTop=l,e.setParent(u,a),c.borderBottom=u,rg.forEach(o,(function(o){sg(e,t,r,n,i,s,o);var c=e.node(o),h=c.borderTop?c.borderTop:o,d=c.borderBottom?c.borderBottom:o,f=c.borderTop?n:2*n,p=h!==d?1:i-s[a]+1;e.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),e.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),e.parent(a)||e.setEdge(t,l,{weight:0,minlen:i+s[a]})}else a!==t&&e.setEdge(t,a,{weight:0,minlen:r})}var ag=Qp,og=g_,lg=function(e){ag.forEach(e.children(),(function t(r){var n=e.children(r),i=e.node(r);if(n.length&&ag.forEach(n,t),ag.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var s=i.minRank,a=i.maxRank+1;s<a;++s)ug(e,"borderLeft","_bl",r,i,s),ug(e,"borderRight","_br",r,i,s)}}))};function ug(e,t,r,n,i,s){var a={width:0,height:0,rank:s,borderType:t},o=i[t][s-1],l=og.addDummyNode(e,"border",a,r);i[t][s]=l,e.setParent(l,n),o&&e.setEdge(o,l,{weight:1})}var cg=Qp,hg={adjust:function(e){var t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||dg(e)},undo:function(e){var t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){cg.forEach(e.nodes(),(function(t){pg(e.node(t))})),cg.forEach(e.edges(),(function(t){var r=e.edge(t);cg.forEach(r.points,pg),cg.has(r,"y")&&pg(r)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){cg.forEach(e.nodes(),(function(t){_g(e.node(t))})),cg.forEach(e.edges(),(function(t){var r=e.edge(t);cg.forEach(r.points,_g),cg.has(r,"x")&&_g(r)}))}(e),dg(e))}};function dg(e){cg.forEach(e.nodes(),(function(t){fg(e.node(t))})),cg.forEach(e.edges(),(function(t){fg(e.edge(t))}))}function fg(e){var t=e.width;e.width=e.height,e.height=t}function pg(e){e.y=-e.y}function _g(e){var t=e.x;e.x=e.y,e.y=t}var gg=Qp,yg=function(e){var t={},r=gg.filter(e.nodes(),(function(t){return!e.children(t).length})),n=gg.max(gg.map(r,(function(t){return e.node(t).rank}))),i=gg.map(gg.range(n+1),(function(){return[]}));function s(r){if(!gg.has(t,r)){t[r]=!0;var n=e.node(r);i[n.rank].push(r),gg.forEach(e.successors(r),s)}}var a=gg.sortBy(r,(function(t){return e.node(t).rank}));return gg.forEach(a,s),i};var mg=Qp,bg=function(e,t){for(var r=0,n=1;n<t.length;++n)r+=vg(e,t[n-1],t[n]);return r};function vg(e,t,r){for(var n=mg.zipObject(r,mg.map(r,(function(e,t){return t}))),i=mg.flatten(mg.map(t,(function(t){return mg.sortBy(mg.map(e.outEdges(t),(function(t){return{pos:n[t.w],weight:e.edge(t).weight}})),"pos")})),!0),s=1;s<r.length;)s<<=1;var a=2*s-1;s-=1;var o=mg.map(new Array(a),(function(){return 0})),l=0;return mg.forEach(i.forEach((function(e){var t=e.pos+s;o[t]+=e.weight;for(var r=0;t>0;)t%2&&(r+=o[t+1]),o[t=t-1>>1]+=e.weight;l+=e.weight*r}))),l}var xg=Qp;var Eg=Qp;var wg=Qp,Ag=g_;function Cg(e,t,r){for(var n;t.length&&(n=wg.last(t)).i<=r;)t.pop(),e.push(n.vs),r++;return r}var Rg=Qp,kg=function(e,t){return xg.map(t,(function(t){var r=e.inEdges(t);if(r.length){var n=xg.reduce(r,(function(t,r){var n=e.edge(r),i=e.node(r.v);return{sum:t.sum+n.weight*i.order,weight:t.weight+n.weight}}),{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}return{v:t}}))},Sg=function(e,t){var r={};return Eg.forEach(e,(function(e,t){var n=r[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};Eg.isUndefined(e.barycenter)||(n.barycenter=e.barycenter,n.weight=e.weight)})),Eg.forEach(t.edges(),(function(e){var t=r[e.v],n=r[e.w];Eg.isUndefined(t)||Eg.isUndefined(n)||(n.indegree++,t.out.push(r[e.w]))})),function(e){var t=[];function r(e){return function(t){t.merged||(Eg.isUndefined(t.barycenter)||Eg.isUndefined(e.barycenter)||t.barycenter>=e.barycenter)&&function(e,t){var r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight);t.weight&&(r+=t.barycenter*t.weight,n+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function n(t){return function(r){r.in.push(t),0==--r.indegree&&e.push(r)}}for(;e.length;){var i=e.pop();t.push(i),Eg.forEach(i.in.reverse(),r(i)),Eg.forEach(i.out,n(i))}return Eg.map(Eg.filter(t,(function(e){return!e.merged})),(function(e){return Eg.pick(e,["vs","i","barycenter","weight"])}))}(Eg.filter(r,(function(e){return!e.indegree})))},Tg=function(e,t){var r=Ag.partition(e,(function(e){return wg.has(e,"barycenter")})),n=r.lhs,i=wg.sortBy(r.rhs,(function(e){return-e.i})),s=[],a=0,o=0,l=0;n.sort((u=!!t,function(e,t){return e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:u?t.i-e.i:e.i-t.i})),l=Cg(s,i,l),wg.forEach(n,(function(e){l+=e.vs.length,s.push(e.vs),a+=e.barycenter*e.weight,o+=e.weight,l=Cg(s,i,l)}));var u;var c={vs:wg.flatten(s,!0)};o&&(c.barycenter=a/o,c.weight=o);return c},Og=function e(t,r,n,i){var s=t.children(r),a=t.node(r),o=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};o&&(s=Rg.filter(s,(function(e){return e!==o&&e!==l})));var c=kg(t,s);Rg.forEach(c,(function(r){if(t.children(r.v).length){var s=e(t,r.v,n,i);u[r.v]=s,Rg.has(s,"barycenter")&&(a=r,o=s,Rg.isUndefined(a.barycenter)?(a.barycenter=o.barycenter,a.weight=o.weight):(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight))}var a,o}));var h=Sg(c,n);!function(e,t){Rg.forEach(e,(function(e){e.vs=Rg.flatten(e.vs.map((function(e){return t[e]?t[e].vs:e})),!0)}))}(h,u);var d=Tg(h,i);if(o&&(d.vs=Rg.flatten([o,d.vs,l],!0),t.predecessors(o).length)){var f=t.node(t.predecessors(o)[0]),p=t.node(t.predecessors(l)[0]);Rg.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var Ig=Qp,Ng=Mp.Graph,Lg=function(e,t,r){var n=function(e){var t;for(;e.hasNode(t=Ig.uniqueId("_root")););return t}(e),i=new Ng({compound:!0}).setGraph({root:n}).setDefaultNodeLabel((function(t){return e.node(t)}));return Ig.forEach(e.nodes(),(function(s){var a=e.node(s),o=e.parent(s);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(i.setNode(s),i.setParent(s,o||n),Ig.forEach(e[r](s),(function(t){var r=t.v===s?t.w:t.v,n=i.edge(r,s),a=Ig.isUndefined(n)?0:n.weight;i.setEdge(r,s,{weight:e.edge(t).weight+a})})),Ig.has(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))})),i};var Vg=Qp;var Pg=Qp,Dg=yg,Bg=bg,Mg=Og,Gg=Lg,jg=function(e,t,r){var n,i={};Vg.forEach(r,(function(r){for(var s,a,o=e.parent(r);o;){if((s=e.parent(o))?(a=i[s],i[s]=o):(a=n,n=o),a&&a!==o)return void t.setEdge(a,o);o=s}}))},zg=Mp.Graph,Fg=g_,Ug=function(e){var t=Fg.maxRank(e),r=Hg(e,Pg.range(1,t+1),"inEdges"),n=Hg(e,Pg.range(t-1,-1,-1),"outEdges"),i=Dg(e);Yg(e,i);for(var s,a=Number.POSITIVE_INFINITY,o=0,l=0;l<4;++o,++l){Wg(o%2?r:n,o%4>=2),i=Fg.buildLayerMatrix(e);var u=Bg(e,i);u<a&&(l=0,s=Pg.cloneDeep(i),a=u)}Yg(e,s)};function Hg(e,t,r){return Pg.map(t,(function(t){return Gg(e,t,r)}))}function Wg(e,t){var r=new zg;Pg.forEach(e,(function(e){var n=e.graph().root,i=Mg(e,n,r,t);Pg.forEach(i.vs,(function(t,r){e.node(t).order=r})),jg(e,r,i.vs)}))}function Yg(e,t){Pg.forEach(t,(function(t){Pg.forEach(t,(function(t,r){e.node(t).order=r}))}))}var Xg=Qp,qg=Mp.Graph,Kg=g_,Zg=function(e){var t,r=Kg.buildLayerMatrix(e),n=Xg.merge($g(e,r),Jg(e,r)),i={};Xg.forEach(["u","d"],(function(s){t="u"===s?r:Xg.values(r).reverse(),Xg.forEach(["l","r"],(function(r){"r"===r&&(t=Xg.map(t,(function(e){return Xg.values(e).reverse()})));var a=("u"===s?e.predecessors:e.successors).bind(e),o=ty(e,t,n,a),l=ry(e,t,o.root,o.align,"r"===r);"r"===r&&(l=Xg.mapValues(l,(function(e){return-e}))),i[s+r]=l}))}));var s=ny(e,i);return iy(i,s),sy(i,e.graph().align)};function $g(e,t){var r={};return Xg.reduce(t,(function(t,n){var i=0,s=0,a=t.length,o=Xg.last(n);return Xg.forEach(n,(function(t,l){var u=function(e,t){if(e.node(t).dummy)return Xg.find(e.predecessors(t),(function(t){return e.node(t).dummy}))}(e,t),c=u?e.node(u).order:a;(u||t===o)&&(Xg.forEach(n.slice(s,l+1),(function(t){Xg.forEach(e.predecessors(t),(function(n){var s=e.node(n),a=s.order;!(a<i||c<a)||s.dummy&&e.node(t).dummy||Qg(r,n,t)}))})),s=l+1,i=c)})),n})),r}function Jg(e,t){var r={};function n(t,n,i,s,a){var o;Xg.forEach(Xg.range(n,i),(function(n){o=t[n],e.node(o).dummy&&Xg.forEach(e.predecessors(o),(function(t){var n=e.node(t);n.dummy&&(n.order<s||n.order>a)&&Qg(r,t,o)}))}))}return Xg.reduce(t,(function(t,r){var i,s=-1,a=0;return Xg.forEach(r,(function(o,l){if("border"===e.node(o).dummy){var u=e.predecessors(o);u.length&&(i=e.node(u[0]).order,n(r,a,l,s,i),a=l,s=i)}n(r,a,r.length,i,t.length)})),r})),r}function Qg(e,t,r){if(t>r){var n=t;t=r,r=n}var i=e[t];i||(e[t]=i={}),i[r]=!0}function ey(e,t,r){if(t>r){var n=t;t=r,r=n}return Xg.has(e[t],r)}function ty(e,t,r,n){var i={},s={},a={};return Xg.forEach(t,(function(e){Xg.forEach(e,(function(e,t){i[e]=e,s[e]=e,a[e]=t}))})),Xg.forEach(t,(function(e){var t=-1;Xg.forEach(e,(function(e){var o=n(e);if(o.length){o=Xg.sortBy(o,(function(e){return a[e]}));for(var l=(o.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=o[u];s[e]===e&&t<a[h]&&!ey(r,e,h)&&(s[h]=e,s[e]=i[e]=i[h],t=a[h])}}}))})),{root:i,align:s}}function ry(e,t,r,n,i){var s={},a=function(e,t,r,n){var i=new qg,s=e.graph(),a=function(e,t,r){return function(n,i,s){var a,o=n.node(i),l=n.node(s),u=0;if(u+=o.width/2,Xg.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(u+=r?a:-a),a=0,u+=(o.dummy?t:e)/2,u+=(l.dummy?t:e)/2,u+=l.width/2,Xg.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=r?a:-a),a=0,u}}(s.nodesep,s.edgesep,n);return Xg.forEach(t,(function(t){var n;Xg.forEach(t,(function(t){var s=r[t];if(i.setNode(s),n){var o=r[n],l=i.edge(o,s);i.setEdge(o,s,Math.max(a(e,t,n),l||0))}n=t}))})),i}(e,t,r,i),o=i?"borderLeft":"borderRight";function l(e,t){for(var r=a.nodes(),n=r.pop(),i={};n;)i[n]?e(n):(i[n]=!0,r.push(n),r=r.concat(t(n))),n=r.pop()}return l((function(e){s[e]=a.inEdges(e).reduce((function(e,t){return Math.max(e,s[t.v]+a.edge(t))}),0)}),a.predecessors.bind(a)),l((function(t){var r=a.outEdges(t).reduce((function(e,t){return Math.min(e,s[t.w]-a.edge(t))}),Number.POSITIVE_INFINITY),n=e.node(t);r!==Number.POSITIVE_INFINITY&&n.borderType!==o&&(s[t]=Math.max(s[t],r))}),a.successors.bind(a)),Xg.forEach(n,(function(e){s[e]=s[r[e]]})),s}function ny(e,t){return Xg.minBy(Xg.values(t),(function(t){var r=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY;return Xg.forIn(t,(function(t,i){var s=function(e,t){return e.node(t).width}(e,i)/2;r=Math.max(t+s,r),n=Math.min(t-s,n)})),r-n}))}function iy(e,t){var r=Xg.values(t),n=Xg.min(r),i=Xg.max(r);Xg.forEach(["u","d"],(function(r){Xg.forEach(["l","r"],(function(s){var a,o=r+s,l=e[o];if(l!==t){var u=Xg.values(l);(a="l"===s?n-Xg.min(u):i-Xg.max(u))&&(e[o]=Xg.mapValues(l,(function(e){return e+a})))}}))}))}function sy(e,t){return Xg.mapValues(e.ul,(function(r,n){if(t)return e[t.toLowerCase()][n];var i=Xg.sortBy(Xg.map(e,n));return(i[1]+i[2])/2}))}var ay=Qp,oy=g_,ly=Zg;var uy=Qp,cy=f_,hy=x_,dy=$_,fy=g_.normalizeRanks,py=tg,_y=g_.removeEmptyRanks,gy=ig,yy=lg,my=hg,by=Ug,vy=function(e){(function(e){var t=oy.buildLayerMatrix(e),r=e.graph().ranksep,n=0;ay.forEach(t,(function(t){var i=ay.max(ay.map(t,(function(t){return e.node(t).height})));ay.forEach(t,(function(t){e.node(t).y=n+i/2})),n+=i+r}))})(e=oy.asNonCompoundGraph(e)),ay.forEach(ly(e),(function(t,r){e.node(r).x=t}))},xy=g_,Ey=Mp.Graph,wy=function(e,t){var r=t&&t.debugTiming?xy.time:xy.notime;r("layout",(function(){var t=r(" buildLayoutGraph",(function(){return function(e){var t=new Ey({multigraph:!0,compound:!0}),r=Ly(e.graph());return t.setGraph(uy.merge({},Cy,Ny(r,Ay),uy.pick(r,Ry))),uy.forEach(e.nodes(),(function(r){var n=Ly(e.node(r));t.setNode(r,uy.defaults(Ny(n,ky),Sy)),t.setParent(r,e.parent(r))})),uy.forEach(e.edges(),(function(r){var n=Ly(e.edge(r));t.setEdge(r,uy.merge({},Oy,Ny(n,Ty),uy.pick(n,Iy)))})),t}(e)}));r(" runLayout",(function(){!function(e,t){t(" makeSpaceForEdgeLabels",(function(){!function(e){var t=e.graph();t.ranksep/=2,uy.forEach(e.edges(),(function(r){var n=e.edge(r);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}(e)})),t(" removeSelfEdges",(function(){!function(e){uy.forEach(e.edges(),(function(t){if(t.v===t.w){var r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e)})),t(" acyclic",(function(){cy.run(e)})),t(" nestingGraph.run",(function(){gy.run(e)})),t(" rank",(function(){dy(xy.asNonCompoundGraph(e))})),t(" injectEdgeLabelProxies",(function(){!function(e){uy.forEach(e.edges(),(function(t){var r=e.edge(t);if(r.width&&r.height){var n=e.node(t.v),i={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};xy.addDummyNode(e,"edge-proxy",i,"_ep")}}))}(e)})),t(" removeEmptyRanks",(function(){_y(e)})),t(" nestingGraph.cleanup",(function(){gy.cleanup(e)})),t(" normalizeRanks",(function(){fy(e)})),t(" assignRankMinMax",(function(){!function(e){var t=0;uy.forEach(e.nodes(),(function(r){var n=e.node(r);n.borderTop&&(n.minRank=e.node(n.borderTop).rank,n.maxRank=e.node(n.borderBottom).rank,t=uy.max(t,n.maxRank))})),e.graph().maxRank=t}(e)})),t(" removeEdgeLabelProxies",(function(){!function(e){uy.forEach(e.nodes(),(function(t){var r=e.node(t);"edge-proxy"===r.dummy&&(e.edge(r.e).labelRank=r.rank,e.removeNode(t))}))}(e)})),t(" normalize.run",(function(){hy.run(e)})),t(" parentDummyChains",(function(){py(e)})),t(" addBorderSegments",(function(){yy(e)})),t(" order",(function(){by(e)})),t(" insertSelfEdges",(function(){!function(e){var t=xy.buildLayerMatrix(e);uy.forEach(t,(function(t){var r=0;uy.forEach(t,(function(t,n){var i=e.node(t);i.order=n+r,uy.forEach(i.selfEdges,(function(t){xy.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:i.rank,order:n+ ++r,e:t.e,label:t.label},"_se")})),delete i.selfEdges}))}))}(e)})),t(" adjustCoordinateSystem",(function(){my.adjust(e)})),t(" position",(function(){vy(e)})),t(" positionSelfEdges",(function(){!function(e){uy.forEach(e.nodes(),(function(t){var r=e.node(t);if("selfedge"===r.dummy){var n=e.node(r.e.v),i=n.x+n.width/2,s=n.y,a=r.x-i,o=n.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*a/3,y:s-o},{x:i+5*a/6,y:s-o},{x:i+a,y:s},{x:i+5*a/6,y:s+o},{x:i+2*a/3,y:s+o}],r.label.x=r.x,r.label.y=r.y}}))}(e)})),t(" removeBorderNodes",(function(){!function(e){uy.forEach(e.nodes(),(function(t){if(e.children(t).length){var r=e.node(t),n=e.node(r.borderTop),i=e.node(r.borderBottom),s=e.node(uy.last(r.borderLeft)),a=e.node(uy.last(r.borderRight));r.width=Math.abs(a.x-s.x),r.height=Math.abs(i.y-n.y),r.x=s.x+r.width/2,r.y=n.y+r.height/2}})),uy.forEach(e.nodes(),(function(t){"border"===e.node(t).dummy&&e.removeNode(t)}))}(e)})),t(" normalize.undo",(function(){hy.undo(e)})),t(" fixupEdgeLabelCoords",(function(){!function(e){uy.forEach(e.edges(),(function(t){var r=e.edge(t);if(uy.has(r,"x"))switch("l"!==r.labelpos&&"r"!==r.labelpos||(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}}))}(e)})),t(" undoCoordinateSystem",(function(){my.undo(e)})),t(" translateGraph",(function(){!function(e){var t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,i=0,s=e.graph(),a=s.marginx||0,o=s.marginy||0;function l(e){var s=e.x,a=e.y,o=e.width,l=e.height;t=Math.min(t,s-o/2),r=Math.max(r,s+o/2),n=Math.min(n,a-l/2),i=Math.max(i,a+l/2)}uy.forEach(e.nodes(),(function(t){l(e.node(t))})),uy.forEach(e.edges(),(function(t){var r=e.edge(t);uy.has(r,"x")&&l(r)})),t-=a,n-=o,uy.forEach(e.nodes(),(function(r){var i=e.node(r);i.x-=t,i.y-=n})),uy.forEach(e.edges(),(function(r){var i=e.edge(r);uy.forEach(i.points,(function(e){e.x-=t,e.y-=n})),uy.has(i,"x")&&(i.x-=t),uy.has(i,"y")&&(i.y-=n)})),s.width=r-t+a,s.height=i-n+o}(e)})),t(" assignNodeIntersects",(function(){!function(e){uy.forEach(e.edges(),(function(t){var r,n,i=e.edge(t),s=e.node(t.v),a=e.node(t.w);i.points?(r=i.points[0],n=i.points[i.points.length-1]):(i.points=[],r=a,n=s),i.points.unshift(xy.intersectRect(s,r)),i.points.push(xy.intersectRect(a,n))}))}(e)})),t(" reversePoints",(function(){!function(e){uy.forEach(e.edges(),(function(t){var r=e.edge(t);r.reversed&&r.points.reverse()}))}(e)})),t(" acyclic.undo",(function(){cy.undo(e)}))}(t,r)})),r(" updateInputGraph",(function(){!function(e,t){uy.forEach(e.nodes(),(function(r){var n=e.node(r),i=t.node(r);n&&(n.x=i.x,n.y=i.y,t.children(r).length&&(n.width=i.width,n.height=i.height))})),uy.forEach(e.edges(),(function(r){var n=e.edge(r),i=t.edge(r);n.points=i.points,uy.has(i,"x")&&(n.x=i.x,n.y=i.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,t)}))}))};var Ay=["nodesep","edgesep","ranksep","marginx","marginy"],Cy={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Ry=["acyclicer","ranker","rankdir","align"],ky=["width","height"],Sy={width:0,height:0},Ty=["minlen","weight","width","height","labeloffset"],Oy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Iy=["labelpos"];function Ny(e,t){return uy.mapValues(uy.pick(e,t),Number)}function Ly(e){var t={};return uy.forEach(e,(function(e,r){t[r.toLowerCase()]=e})),t}var Vy=Qp,Py=g_,Dy=Mp.Graph;var By={graphlib:Mp,layout:wy,debug:{debugOrdering:function(e){var t=Py.buildLayerMatrix(e),r=new Dy({compound:!0,multigraph:!0}).setGraph({});return Vy.forEach(e.nodes(),(function(t){r.setNode(t,{label:t}),r.setParent(t,"layer"+e.node(t).rank)})),Vy.forEach(e.edges(),(function(e){r.setEdge(e.v,e.w,{},e.name)})),Vy.forEach(t,(function(e,t){var n="layer"+t;r.setNode(n,{rank:"same"}),Vy.reduce(e,(function(e,t){return r.setEdge(e,t,{style:"invis"}),t}))})),r}},util:{time:g_.time,notime:g_.notime},version:"0.8.5"};class My extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let n=Ee(e.children[0]);if(!n)continue;var r=new By.graphlib.Graph;r.setGraph({edgesep:t._edgeSep}),r.setDefaultEdgeLabel((function(){return{}})),r.graph().rankdir=this._getDagreDirection(t.direction);let i=new Map;for(let t of e.children){let e=t.dataScope.getAttributeValue(Ae);i.set(e,e+""),r.setNode(e,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let e of n.linkList)r.setEdge(e.source,e.target);By.layout(r);const s={};let a=Math.min(...r.nodes().map((e=>r.node(e).y))),o=Math.min(...r.nodes().map((e=>r.node(e).x))),l=t.left-o,u=t.top-a;for(const e of r.nodes())s[e]={x:r.node(e).x+l,y:r.node(e).y+u};for(let t of e.children){let e=t.dataScope.getAttributeValue(Ae);Ue(t,s[i.get(e)].x-t.x,s[i.get(e)].y-t.y)}}let n=F(e,!0);for(let e of n)g(e)}_getDagreDirection(e){switch(e){case te.Left2Right:return"LR";case te.Right2Left:return"RL";case te.Top2Bottom:return"TB";case te.Bottom2Top:return"BT"}}}class Gy extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=ve(e.children[0]);if(!r)continue;let i=n.hierarchy(r._data),s=Math.max(...e.children.map((e=>e.bounds.width))),a=Math.max(...e.children.map((e=>e.bounds.height))),o=t.orientation==ee.HORIZONTAL?[t.height,t.width]:[t.width,t.height],l=n.tree().nodeSize([s,a]).size(o)(i);this._apply(l,t,e)}g(e)}_apply(e,t,r){let n,i,s=r.children.filter((t=>t.dataScope.getAttributeValue(Ae)==e.data[Ae]))[0];switch(t.orientation){case ee.HORIZONTAL:n=e.y+t.left,i=e.x+t.top;break;case ee.VERTICAL:n=e.x+t.left,i=t.top+e.y}if(Ue(s,n-s.x,i-s.y),e.children&&e.children.length>0)for(let n of e.children)this._apply(n,t,r)}}class jy extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=this._inputVars.filter((e=>e.type===Z.ORDER))[0].element,r=t.layout,i=r.width?r.width:t.bounds.width,s=r.height?r.height:t.bounds.height,a=void 0===r.top?t.bounds.top:r.top,o=void 0===r.left?t.bounds.left:r.left,l=n.hierarchy(t).sum((e=>e.type===Nt.Rect?e.width*e.height:0));n.treemap().size([i,s])(l),this._apply(l,o,a);let u=F(e,!0);for(let e of u)g(e)}_apply(e,t,r){if(e.data.type==Nt.Collection&&e.children)for(let n of e.children)this._apply(n,t,r);else e.data.type==Nt.Rect&&(e.data.resize(e.x1-e.x0,e.y1-e.y0),Ue(e.data,e.x0+t-e.data.left,e.y0+r-e.data.top))}}class zy extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){if(!e.layout)continue;if(0===e.children.length)continue;let t=ve(e.children[0]);if(!t)continue;let r={};for(let t of e.children)r[t.dataScope.getAttributeValue(Ae)]=t;e.children[0].type===Nt.Rect?this._layoutRects(t.getRoot(),t,r):this._layoutArcs(t.getRoot(),t,r)}g(e)}_layoutArcs(e,t,r){let n=t.getChildren(e);if(0===n.length)return;let i=r[e[Ae]],s=!i||i.type!=Nt.Arc&&i.type!=Nt.Pie?60:i.startAngle;for(let e=0;e<n.length;e++){let i=n[e],a=r[i[Ae]];if(a.type===Nt.Arc){let e=pe(s+a.angle);a.setAngles(s,e),s=e}this._layoutArcs(i,t,r)}}_layoutRects(e,t,r){let n=t.getChildren(e);if(0===n.length)return;let i,s,a=r[e[Ae]];this._direction,te.Top2Bottom,i=a.left,s=a.bottom;for(let e=0;e<n.length;e++){let a=n[e],o=r[a[Ae]];Ue(o,i-o.left,s-o.top),i+=o.width,this._layoutRects(a,t,r)}}}class Fy extends K{constructor(e,t){super(e),this._trigger=t}get trigger(){return this._trigger}}class Uy extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar.condEncoding,t=e.trigger,r=I(e.target),n={};if(t.type===Qe.ELEMENT){let i=t.elements.length>0?t.elements:[void 0];r.forEach((t=>n[t.id]=i.map((r=>e._targetEval(r,t))).some((e=>e))))}t.type===Qe.MOUSE&&r.forEach((r=>n[r.id]=e._targetEval(t.mouseEvent,r))),e.evalResult=n}}class Hy extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=360/e.children.length;for(let[n,i]of e.children.entries())Ue(i,t.x+t.radius-i.bounds.x,t.y-i.bounds.y),i._rotate=[n*r,t.x,t.y]}let r=F(e,!0);for(let e of r)g(e)}}class Wy extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let r of t){let t=r.layout;if(!t)continue;let i=t._tree?t._tree._data:ve(r.children[0])._data,s=n.hierarchy(i);if(t.isRadial()){s=n.cluster().size([de(t.angleExtent),t.radius])(s),t._d3Root=s;const e=new Map(s.descendants().map((e=>[e.data[Ae],[e.x,e.y]])));for(let n of r.children){let r=n.dataScope.getAttributeValue(Ae);Ue(n,t.x-n.bounds.x,t.y-e.get(r)[1]-n.bounds.y),n._rotate=[fe(e.get(r)[0]),t.x,t.y]}}else if(t.orientation===ee.VERTICAL){!t.width||t.width;let i=t.height?t.height:600;s=n.cluster().nodeSize([e.bounds.width+1,i/(s.height+1)])(s),t._d3Root=s;const a=new Map(s.descendants().map((e=>[e.data[Ae],[e.x,e.y]])));let o=1/0,l=-o;s.each((e=>{e.x>l&&(l=e.x),e.x<o&&(o=e.x)})),t._x0=o;for(let e of r.children){let r=e.dataScope.getAttributeValue(Ae);Ue(e,a.get(r)[0]-o+t.left-e.bounds.x,a.get(r)[1]+t.top-e.bounds.y)}}else if(t.orientation===ee.HORIZONTAL){!t.width||t.width;let i=t.height?t.height:600;s=n.cluster().nodeSize([e.bounds.height,i/(s.height+1)])(s),t._d3Root=s;const a=new Map(s.descendants().map((e=>[e.data[Ae],[e.x,e.y]])));let o=1/0,l=-o;s.each((e=>{e.x>l&&(l=e.x),e.x<o&&(o=e.x)})),t._x0=o;for(let e of r.children){let r=e.dataScope.getAttributeValue(Ae);Ue(e,a.get(r)[1]+t.left-e.bounds.x,a.get(r)[0]-o+t.top-e.bounds.y)}}}let r=F(e,!0);for(let e of r)g(e)}}class Yy{constructor(){this._variables={},this._operators={},this._edges=[]}toJSON(){const e=this._edges.map((e=>({from:e.fromNode.id,to:e.toNode.id,isDirected:e.isDirected}))),t={};for(const e in this._variables)t[e]=Object.values(this._variables[e]).map((e=>{let t={id:e.id,type:e.type,incoming:e.incomingEdges.map((e=>e.id)),outgoing:e.outgoingEdges.map((e=>e.id)),undirected:e.undirectedEdges.map((e=>e.id))};return"ChannelVar"===e.type?(t.channel=e.channel,t.element=e.element):"BoundsVar"===e.type||"DataScopeVar"===e.type?t.element=e.element:"DomainVar"===e.type?(t.scale=e.scale,t.attrValues=e.attrValues):"FieldVar"===e.type?(t.field=e.field,t.dataset=e.dataset):"PropertyVar"===e.type?(t.property=e.property,t.element=e.element):t.scale=e.scale,t}));const r={};for(const e in this._operators)r[e]=Object.values(this._operators[e]).map((e=>{let t={id:e.id,type:e.type,inputVars:e.inputVars.map((e=>e.id)),outputVar:e.outputVar?e.outputVar.id:null};return e.type===q.DOMAIN_BUILDER?t.aggregator=e.aggregator:e.type===q.SCALE_BUILDER&&(t.channel=e.channel),t}));return{edges:e,variables:t,operators:r}}getVariable(e,...t){if(Object.values(Z).indexOf(e)<0)throw new Error("Variable Type Not Known");let r=this.findVariable(e,t);if(r)return r;switch(e){case Z.CHANNEL:r=new Ne(e,t[0],t[1]),"vertex"!=t[1].type&&"segment"!=t[1].type||this._connectPathElement2Size(t[1],r);break;case Z.PROPERTY:r=new tt(e,t[0],t[1]);break;case Z.ATTRIBUTE:r=new Ut(e,t[0],t[1]);break;case Z.ITEMS:r=new pr(e,t[0],t[1]);break;case Z.DOMAIN:r=new Ht(e,t[0]);break;case Z.DATASCOPE:r=new jt(e,t[0]);break;case Z.BOUNDS:r=new Gt(e,t[0]);break;case Z.ORDER:r=new _r(e,t[0]);break;case Z.SCALE:r=new $e(e,t[0]);break;case Z.COND_ENCODING:r=new $(e,t[0]);break;case Z.AFFIXATION:r=new yr(e,t[0]);break;case Z.ALIGNMENT:r=new Ar(e,t[0]);break;case Z.TRIGGER:r=new Fy(e,t[0])}return e in this._variables||(this._variables[e]={}),this._variables[e][r.id]=r,r}_connectPathElement2Size(e,t){let r=e.parent,n=t.channel,i=this.findVariable(Z.CHANNEL,["x"===n?"width":"height",r]);if(i){let e=i.incomingDataflow;e||(e=this.createOneWayDependency(q.CONDUIT)),this.connect(t,e),this.connect(e,i)}}findIncomingDataflowOperator(e,t){return t.incomingDataflow&&t.incomingDataflow.type===e?t.incomingDataflow:void 0}getIncomingDataflowOperator(e,t){let r=this.findIncomingDataflowOperator(e,t);return r||this.createOneWayDependency(e)}getOutgoingDataflowOperator(e,t){for(let r of t.outgoingEdges)if(r.toNode instanceof X&&r.toNode.type===e)return r.toNode;return this.createOneWayDependency(e)}createOneWayDependency(e,...t){if(Object.values(q).indexOf(e)<0)throw new Error("Dependency Type Not Known");let r;switch(e){case q.EVAL_BBOX:r=new Zt(e);break;case q.AFFIXER:r=new gr(e);break;case q.DOMAIN_BUILDER:r=new Wt(e,t[0]);break;case q.SCALE_BUILDER:r=new Kt(e,t[0]);break;case q.ENCODER:r=new et(e,t[0]);break;case q.AXIS_PATH_PLACER:r=new sr(e);break;case q.AXIS_TICKS_PLACER:r=new ar(e);break;case q.AXIS_LABELS_PLACER:r=new or(e);break;case q.AXIS_TITLE_PLACER:r=new Er(e);break;case q.LINK_PLACER:r=new Rr(e);break;case q.GRID_LAYOUT:r=new lr(e);break;case q.STACK_LAYOUT:r=new cr(e);break;case q.PACK_LAYOUT:r=new xr(e);break;case q.FORCE_LAYOUT:r=new Cr(e);break;case q.DIRECTED_LAYOUT:r=new My(e);break;case q.TIDY_TREE_LAYOUT:r=new Gy(e);break;case q.TREEMAP_LAYOUT:r=new jy(e);break;case q.STRATA_LAYOUT:r=new zy(e);break;case q.CIRCULAR_LAYOUT:r=new Hy(e);break;case q.CLUSTER_LAYOUT:r=new Wy(e);break;case q.GRIDLINES_PLACER:r=new ur(e);break;case q.BIN_TRANSFORMER:r=new dr(e);break;case q.FILTER_TRANSFORMER:r=new fr(e);break;case q.KDE_TRANSFORMER:r=new mr(e);break;case q.TARGET_EVALUATOR:r=new Uy(e);break;case q.CONDUIT:default:r=new hr(e)}return e in this._operators||(this._operators[e]={}),this._operators[e][r.id]=r,r}createMultiWayDependency(e){if(Object.values(q).indexOf(e)<0)throw new Error("Dependency Type Not Known");let t;return q.ALIGNER,t=new wr(e),e in this._operators||(this._operators[e]={}),this._operators[e][t.id]=t,t}connect(e,t,r=!0){if(e instanceof K&&t instanceof X){if(!t.inputVars.includes(e)){const n=new Ft(e,t,r);this._edges.push(n),e.outgoingEdges.push(n),t.inputVars.push(e)}}else if(e instanceof X&&t instanceof K){if(!e.outputVars.includes(t)){const n=new Ft(e,t,r);this._edges.push(n),e.outputVars.push(t),t.incomingEdges.push(n)}}else if(e instanceof K&&t instanceof zt){if(!t.vars.includes(e)){const r=new Ft(e,t,!1);this._edges.push(r),t.vars.push(e),t.edges.push(e),e.undirectedEdges.push(r)}}else{if(!(e instanceof zt&&t instanceof K))throw new Error("An edge must connect a variable and an operator.");if(!e.vars.includes(t)){const r=new Ft(t,e,!1);this._edges.push(r),e.vars.push(t),e.edges.push(t),t.undirectedEdges.push(r)}}}disconnectChannelVarFromBBoxOperator(e){let t=this.getOutgoingDataflowOperator(q.EVAL_BBOX,e),r=e.outgoingEdges.find((r=>r.fromNode===e&&r.toNode===t));r&&this.disconnect(e,t,r)}disconnect(e,t,r){if(e instanceof K&&t instanceof X){let n=e.outgoingEdges.findIndex((e=>e===r));n>=0&&(this._edges.splice(this._edges.indexOf(r),1),e.outgoingEdges.splice(n,1));let i=t.inputVars.findIndex((t=>t==e));i>=0&&t.inputVars.splice(i,1)}else if(e instanceof X&&t instanceof K){let n=t.incomingEdges.findIndex((e=>e===r));n>=0&&(this._edges.splice(this._edges.indexOf(r),1),t.incomingEdges.splice(n,1));let i=e.outputVars.findIndex((e=>e===t));i>=0&&e.outputVars.splice(i,1)}}deleteVariable(e){for(let t=e.incomingEdges.length-1;t>=0;t--){let r=e.incomingEdges[t],n=r.fromNode;this.disconnect(n,e,r),n.isIsolated()&&delete this._operators[n.type][n.id]}for(let t=e.outgoingEdges.length-1;t>=0;t--){let r=e.outgoingEdges[t],n=r.toNode;this.disconnect(e,n,r),n.isIsolated()&&delete this._operators[n.type][n.id]}delete this._variables[e.type][e.id]}deleteOperator(e){for(let t=e.outputVars.length-1;t>=0;t--){let r=e.outputVars[t],n=r.incomingEdges.find((t=>t.fromNode===e&&t.toNode===r));this.disconnect(e,r,n),r.isIsolated()&&delete this._variables[r.type][r.id]}for(let t=e.inputVars.length-1;t>=0;t--){let r=e.inputVars[t],n=r.outgoingEdges.find((t=>t.fromNode===r&&t.toNode===e));this.disconnect(r,e,n),r.isIsolated()&&delete this._variables[r.type][r.id]}delete this._operators[e.type][e.id]}addInteraction(e){}_dfs(e,t,r){if(e&&0!==e.outgoingEdges.length)for(let n of e.outgoingEdges)n.isDirected&&(t.push(n.toNode),this._dfs(n.toNode.outputVars[0],t.slice(),r));else r.push(t)}processChange(e,t,...r){let n=this.findVariable(e,r);if(n){for(let e of n.outgoingEdges)if(e.isDirected){let r=e.toNode;r.run();let n=r.outputVars;if(n.length>0){let e=n[0];switch(e.type){case Z.ITEMS:this.processChange(e.type,t,e.predicate,e.dataset);break;case Z.ATTRIBUTE:this.processChange(e.type,t,e.attribute,e.dataset);break;case Z.BOUNDS:case Z.ORDER:this.processChange(e.type,t,e.element);break;case Z.CHANNEL:this.processChange(e.type,t,e.channel,e.element);break;case Z.PROPERTY:this.processChange(e.type,t,e.property,e.element);break;case Z.SCALE:case Z.DOMAIN:this.processChange(e.type,t,e.encodings[0]);break;case Z.COND_ENCODING:this.processChange(e.type,t,e.condEncoding)}}}for(let e of n.undirectedEdges)t.push(e.operator)}else console.warn("Unable to find variables matching the described change: ",e,r)}findVariable(e,t){if(!(e in this._variables))return null;let r=Object.values(this._variables[e]);switch(e){case Z.CHANNEL:return r.find((e=>e.channel==t[0]&&Me(e.element)==Me(t[1])));case Z.PROPERTY:return r.find((e=>e.property==t[0]&&e.element==t[1]));case Z.COND_ENCODING:return r.find((e=>e.condEncoding==t[0]));case Z.AFFIXATION:return r.find((e=>e.affixation==t[0]));case Z.ATTRIBUTE:return r.find((e=>e.attribute==t[0]&&e.dataset==t[1]));case Z.ITEMS:return r.find((e=>e.dataset==t[1]));case Z.DOMAIN:case Z.SCALE:return r.find((e=>e.encodings.includes(t[0])));case Z.TRIGGER:return r.find((e=>e.trigger===t[0]));case Z.DATASCOPE:default:return t[0].classId?r.find((e=>Me(e.element)==Me(t[0]))):r.find((e=>e.element.id==t[0].id))}}findVariablesByElement(e){let t={};for(let r in this._variables){let n=Object.values(this._variables[r]).filter((t=>t.element&&Me(t.element)==Me(e)));n.length>0&&(t[r]=n)}return t}}function Xy(e){return!(!A(e)&&e.type!=Nt.Glyph||e.dataScope)||e.type===Nt.Collection&&e.firstChild.dataScope.numTuples>1}function qy(e,t,r,n){let i=n.getAttributeType(r);if(i!=Re.String&&i!=Re.Date&&i!=Re.Integer)throw new Error("Repeat only works on a string or date attribute: "+r+" is "+i);if(!function(e){if(Array.isArray(e)){if(1===e.length)return Xy(e[0]);for(let t of e)if(!A(t)||t.dataScope)return!1;return!0}return Xy(e)}(t))throw new Error("The "+t.type+" is not repeatable");return function(e,t,r,n){let i=n.getAttributeSummary(r).unique.map((e=>t.dataScope?t.dataScope.cross(r,e):new ge(n).cross(r,e)));i=i.filter((e=>!e.isEmpty()));let s=St(e);s.dataScope=t.dataScope?t.dataScope.clone():new ge(n),s.addChild(t);for(let e=1;e<i.length;e++){let e=Ot(t);s.addChild(e)}return s.children.forEach(((e,t)=>e.dataScope=i[t])),s}(e,t,r,n)}class Ky{constructor(e,t,r,n,i){this._elem=e,this._channel=t,this._attribute=r,this._aggregator=n,this._includeZero=i.includeZero,this._flipScale=i.flipScale,this._mapping=i.mapping,this._preferredRangeExtent=i.rangeExtent,this._preferredDomain=void 0,this._scaleType=i.scaleType,this._colorScheme=i.scheme,this._forLegend=i.forLegend,this._scales=[],this._elemGroups=[],this._elem2scale={},this._refElements=[],["width","height","radius","angle","thickness","radialDistance","strokeWidth","area"].indexOf(this._channel)>=0&&(this._includeZero=!0),this.initialize()}initialize(){this._scales=[];let e=I(this._elem);if(this._elemGroups=[],"x"===this._channel||"y"===this._channel){let t=this._elem,r=G(t);if(r.layout&&r.layout.type==W.GRID){let e="x"===this._channel?r.layout.getElementsByCol(!0,t):r.layout.getElementsByRow(!0,t);for(let t of e)this._createScaleForElems(t)}else if("vertex"===this._elem.type&&(ze(this._elem.parent)||je(this._elem.parent))){let e=I(this._elem.parent).map((e=>N(this._elem,[e])));for(let t of e)this._createScaleForElems(t)}else this._createScaleForElems(e)}else if("angle"===this._channel){let t=e.reduce(((e,t)=>{const r=t.parent.id;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),r=Object.values(t);for(let e of r)this._createScaleForElems(e)}else this._createScaleForElems(e)}_createScaleForElems(e){this._elemGroups.push(e);var t=function(e){if(e.scaleType)return new Yt(e.scaleType);if("text"===e.channel)return new Yt("ordinal");switch(Dt(e.element).getAttributeType(e.attribute)){case Re.Boolean:break;case Re.Date:return new Yt("time");case Re.String:if("count"==e.aggregator)return new Yt("linear");if(e.channel.indexOf("Color")>=0){let t={};return t.scheme=e.colorScheme?e.colorScheme:"schemeCategory10",new Yt("ordinalColor",t)}return new Yt("point");default:return["strokeColor","fillColor","fillGradient"].indexOf(e.channel)>=0?e.mapping?new Yt("linear"):new Yt("sequentialColor",{scheme:e.colorScheme}):new Yt("linear")}}(this);this._scales.push(t);for(let r of e)this._elem2scale[r.id]=t}getScale(e){return this._elem2scale[e.id]}getElements(e){let t=this._scales.indexOf(e);return this._elemGroups[t]}get element(){return this._elem}get channel(){return this._channel}get attribute(){return this._attribute}get dataTable(){return Dt(this._elem)}get aggregator(){return this._aggregator}hasMultipleScales(){return this._scales.length>0}get scales(){return this._scales}getRangeStart(e){let t=this.getScale(e);return Math.min(...t.range)}getRangeExtent(e){return this.getScale(e).rangeExtent}get scaleType(){return this._scaleType}set scaleType(e){this._scaleType=e}set domain(e){this._preferredDomain=e;for(let t of this._scales)t._scale.domain(e);for(let e of this._refElements)e instanceof nr&&e.createTicksLabels({});this._elem.scene.onChange(Z.DOMAIN,this)}set rangeExtent(e){for(let t of this._scales)t.rangeExtent=e;for(let e of this._refElements)e instanceof nr&&e.createTicksLabels({});this._elem.scene.onChange(Z.PROPERTY,rt.RANGE_EXTENT,this)}set includeZero(e){this._includeZero=e;for(let e of this._refElements)e instanceof nr&&e.createTicksLabels({});this._elem.scene.onChange(Z.PROPERTY,rt.INCLUDE_ZERO,this)}get includeZero(){return this._includeZero}set flipScale(e){this._flipScale=e,this._elem.scene.onChange(Z.PROPERTY,rt.FLIP_SCALE,this)}get flipScale(){return this._flipScale}set mapping(e){this._mapping=e}get mapping(){return this._mapping}set colorScheme(e){this._colorScheme=e}get colorScheme(){return this._colorScheme}addRefElement(e){this._refElements.indexOf(e)<0&&this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}class Zy{constructor(e,t,r,n){this._trigger=e,this._target=t.target,this._targetEval=r,this._efxFn=n,this._evalResult={}}get trigger(){return this._trigger}get target(){return this._target}get channels(){return Object.keys(this._rules)}get evalResult(){return this._evalResult}set evalResult(e){this._evalResult=e}}class $y extends ae{constructor(e,t,r,n,i){super(i),this._type=Nt.Gridlines,this._id=this._type+Vt(),this._attribute=t,this._channel=e,this._scale=r,this._elems=n,"strokeColor"in i||(this.styles.strokeColor="#ddd"),"opacity"in i||(this.styles.opacity=.5),"values"in i?this._values=i.values:this._scale?this._values=tr(this._scale,this._channel,this._elems):this._values=this._elems.map((e=>e.dataScope.getAttributeValue(this._attribute))),this._lines=[]}get type(){return this._type}get id(){return this._id}getSVGPathData(){let e="";if("radialDistance"===this._channel)for(let t of this._lines)e+="M "+t.x+" "+t.y+" m -"+t.r+" 0 a "+t.r+" "+t.r+" 0 1 0 "+2*t.r+" 0 a "+t.r+" "+t.r+" 0 1 0 -"+2*t.r+" 0 ";else for(let t of this._lines)e+=["M",t.x1,t.y1].join(" ")+[" L",t.x2,t.y2].join(" ")+" ";return e}_updateBounds(){if("radialDistance"===this._channel){let e=this._lines.map((e=>new d(e.x-e.r,e.y-e.y,2*e.r,2*e.r)));this._bounds=f(e)}else{let e=this._lines.map((e=>e.x1)).concat(this._lines.map((e=>e.x2))),t=this._lines.map((e=>e.y1)).concat(this._lines.map((e=>e.y2))),r=Math.min(...e),n=Math.max(...e),i=Math.min(...t),s=Math.max(...t);this._bounds=new d(r,i,n-r,s-i)}}get elements(){return this._elems}get values(){return this._values}get channel(){return this._channel}get attribute(){return this._attribute}get scale(){return this._scale}get lines(){return this._lines}set lines(e){this._lines=e}}class Jy extends H{constructor(e){super(),this.type=W.STACK,this._orientation=e.orientation,this._direction=e.direction,this._left=e.left,this._top=e.top,this._horzCellAlignment="horzCellAlignment"in e&&e.horzCellAlignment?e.horzCellAlignment:y.LEFT,this._vertCellAlignment="vertCellAlignment"in e&&e.vertCellAlignment?e.vertCellAlignment:y.BOTTOM,this._gap="gap"in e?e.gap:0}clone(){let e=new Jy({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return e._horzCellAlignment=this._horzCellAlignment,e._vertCellAlignment=this._vertCellAlignment,e}get horzCellAlignment(){return this._horzCellAlignment}get vertCellAlignment(){return this._vertCellAlignment}get orientation(){return this._orientation}set horzCellAlignment(e){this._horzCellAlignment=e}set vertCellAlignment(e){this._vertCellAlignment=e}set orientation(e){this._orientation=e}}function Qy(e,t,r,n,i){let s=i.getAttributeType(r);if(s!=Re.String&&s!=Re.Date&&s!=Re.Integer)throw new Error("Divide only works on a string or date attribute: "+r+" is "+s);if(!function(e){if([Nt.Line,Nt.Circle,Nt.Rect,Nt.Area,Nt.Ring,Nt.Pie,Nt.Path].indexOf(e.type)<0)return!1;if(e.type===Nt.Path&&(e.closed||!e.firstVertex.dataScope))return!1;if(e.dataScope){let t=I(e);for(let e of t)if(e.dataScope.numTuples>1)return!0;return!1}return!0}(t))throw new Error("The "+t.type+" is not dividable");switch(t.type){case Nt.Line:case Nt.Path:return;case Nt.Circle:return function(e,t,r,n,i){let s,a,o,l=I(t),u=r||ee.ANGULAR;if(u!=ee.ANGULAR&&u!=ee.RADIAL)throw new Error("Unknown orientation: "+u);u===ee.ANGULAR&&l.forEach((r=>{let l=r.dataScope?r.dataScope:new ge(i),u=i.getUniqueAttributeValues(n).map((e=>l.cross(n,e)));u=u.filter((e=>!e.isEmpty()));let c=St(e);null==a&&(a=c.id),c._classId=a,c.dataScope=r.dataScope?r.dataScope:new ge(i);let h=r.parent;h.removeChild(r),delete e._itemMap[r.id];let d=360/u.length,f=90;for(let e=0;e<u.length;e++){let n=kt({type:"arc",innerRadius:0,outerRadius:r.radius,x:r.x,y:r.y,startAngle:pe(f-d*(e+1)),endAngle:pe(f-d*e),strokeColor:r.strokeColor,fillColor:r.fillColor,strokeWidth:r.strokeWidth,opacity:r.opacity});o||(o=n.id),n.classId=o,n.dataScope=u[e],n._updateBounds(),n._refBounds=n.bounds.clone(),c.addChild(n),c._layout=new Jy({orientation:ee.ANGULAR,direction:re.CLOCKWISE}),c._layout.group=c,h.removeChild(r),h.addChild(c),r===t&&(s=c)}}));return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Nt.Rect:return function(e,t,r,n,i){let s,a=I(t),o=r||ee.HORIZONTAL;if(o!=ee.HORIZONTAL&&o!=ee.VERTICAL)throw new Error("Unknown orientation: "+o);let l=i.getUniqueAttributeValues(n).map((e=>new ge(i).cross(n,e))),u={},c=0;for(let e of a){let t=l;e.dataScope&&(t=l.map((t=>t.merge(e.dataScope))),t=t.filter((e=>!e.isEmpty()))),t.length>c&&(c=t.length),u[e.id]=t}let h,d=kt({type:"rect",left:t.bounds.left,top:t.bounds.top,width:t.bounds.width,height:t.bounds.height,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});d._classId=d.id;for(let r of a){let n=St(e);null==h&&(h=n.id),n._classId=h,n.dataScope=r.dataScope?r.dataScope:new ge(i);let a=r.parent;a.removeChild(r),delete e._itemMap[r.id];let l=u[r.id],c=r.bounds,f=c.left,p=c.top,_=o==ee.HORIZONTAL?c.width/l.length:c.width,g=o==ee.HORIZONTAL?c.height:c.height/l.length;for(let e=0;e<l.length;e++){let t=Ot(d);t.dataScope=l[e],t.resize(_,g),t._updateBounds(),t._refBounds=t.bounds.clone(),n.addChild(t)}a.addChild(n),n._layout=new Jy({orientation:o,left:f,top:p}),n._layout.group=n,r==t&&(s=n)}return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Nt.Area:return function(e,t,r,n,i){let s,a=I(t),o=r||ee.HORIZONTAL;if(o!=ee.HORIZONTAL&&o!=ee.VERTICAL)throw new Error("Unknown orientation: "+o);let l,u=i.getUniqueAttributeValues(n).map((e=>new ge(i).cross(n,e))),c={},h=0;for(let e of a){let t=u;e.dataScope&&(t=u.map((t=>t.merge(e.dataScope))),t=t.filter((e=>!e.isEmpty()))),t.length>h&&(h=t.length),c[e.id]=t}let d=Object.assign({},t.styles);d.vertices=t.vertices.map((e=>[e.x,e.y])),d.type="area",d.orientation=t.orientation,d.baseline=t.baseline;let f=kt(d);if(f._classId=f.id,t.vertices)for(let e=0;e<t.vertices.length;e++)t.vertices[e].dataScope&&(f.vertices[e]._dataScope=t.vertices[e].dataScope.clone());for(let r of a){let n=St(e);null==l&&(l=n.id),n._classId=l,n.dataScope=r.dataScope?r.dataScope:new ge(i);let a=r.parent;a.removeChild(r),delete e._itemMap[r.id];let u=c[r.id],h=r.bounds,d=h.left,p=h.top,_=o==ee.HORIZONTAL?h.width/u.length:h.width,g=o==ee.HORIZONTAL?h.height:h.height/u.length;for(let e=0;e<u.length;e++){let t=Ot(f);t.dataScope=u[e],console.log(t.dataScope),t.resize(_,g),t._updateBounds(),t._refBounds=t.bounds.clone(),n.addChild(t);for(let e of t.vertices)e.dataScope?e.dataScope=t.dataScope.merge(e.dataScope):e.dataScope=t.dataScope}a.addChild(n),n._layout=new Jy({orientation:o,left:d,top:p}),n._layout.group=n,r==t&&(s=n)}return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Nt.Ring:return function(e,t,r,n,i){let s,a,o,l=I(t),u=r||ee.ANGULAR;if(u!=ee.ANGULAR&&u!=ee.RADIAL)throw new Error("Unknown orientation: "+u);u===ee.ANGULAR&&l.forEach((r=>{let l=r.dataScope?r.dataScope:new ge(i),u=i.getUniqueAttributeValues(n).map((e=>l.cross(n,e)));u=u.filter((e=>!e.isEmpty()));let c=St(e);null==a&&(a=c.id),c._classId=a,c.dataScope=r.dataScope?r.dataScope:new ge(i);let h=r.parent;h.removeChild(r),delete e._itemMap[r.id];let d=360/u.length,f=90;for(let e=0;e<u.length;e++){let n=kt({type:"arc",innerRadius:r.innerRadius,outerRadius:r.outerRadius,x:r.x,y:r.y,startAngle:pe(f-d*(e+1)),endAngle:pe(f-d*e),strokeColor:r.strokeColor,fillColor:r.fillColor,strokeWidth:r.strokeWidth,opacity:r.opacity});o||(o=n.id),n.classId=o,n.dataScope=u[e],n._updateBounds(),n._refBounds=n.bounds.clone(),c.addChild(n),c._layout=new Jy({orientation:ee.ANGULAR,direction:re.CLOCKWISE}),c._layout.group=c,h.removeChild(r),h.addChild(c),r===t&&(s=c)}}));return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Nt.Pie:case Nt.Arc:return function(e,t,r,n,i){let s,a,o,l=I(t),u=r||ee.ANGULAR;if(u!=ee.ANGULAR&&u!=ee.RADIAL)throw new Error("Unknown orientation: "+u);u===ee.ANGULAR||l.forEach((r=>{let l=r.dataScope?r.dataScope:new ge(i),u=i.getUniqueAttributeValues(n).map((e=>l.cross(n,e)));u=u.filter((e=>!e.isEmpty()));let c=St(e);null==a&&(a=c.id),c._classId=a,c.dataScope=r.dataScope?r.dataScope:new ge(i);let h=r.parent;h.removeChild(r),delete e._itemMap[r.id];for(let e=0;e<u.length;e++){let n=kt({type:"arc",innerRadius:r.innerRadius+e*(r.outerRadius-r.innerRadius)/u.length,outerRadius:r.innerRadius+(e+1)*(r.outerRadius-r.innerRadius)/u.length,x:r.x,y:r.y,startAngle:r.startAngle,endAngle:r.endAngle,strokeColor:r.strokeColor,fillColor:r.fillColor,strokeWidth:r.strokeWidth,opacity:r.opacity});o||(o=n.id),n.classId=o,n.dataScope=u[e],n._updateBounds(),n._refBounds=n.bounds.clone(),c.addChild(n),c._layout=new Jy({orientation:ee.RADIAL}),c._layout.group=c,h.removeChild(r),h.addChild(c),r===t&&(s=c)}}));return{newMark:s.children[0],collection:s}}(e,t,n,r,i)}}function em(e,t,r,n){let i=n.getAttributeType(r);if(i!=Re.String&&i!=Re.Date&&i!=Re.Integer)throw new Error("Repopulate only works on a string or date attribute: "+r+" is "+i);let s=I(t);for(let e of s){let t=n.getAttributeSummary(r).unique.map((t=>e.dataScope?e.dataScope.cross(r,t):new ge(n).cross(r,t)));t=t.filter((e=>!e.isEmpty()));let i=e.children.length-t.length,s=t.length-e.children.length;for(let t=0;t<i;t++)e.removeChildAt(e.children.length-1);let a=e._children.length;for(let t=0;t<s;t++){let r=Ot(e._children[t%a]);e.addChild(r)}e.children.forEach(((e,r)=>e.dataScope=t[r]))}}class tm{constructor(e,t){this._elem=e,this._base=t,this._id=rm(e,t),this._channels={},this._attribute=void 0}get id(){return this._id}get element(){return this._elem}get base(){return this._base}get channels(){return Object.keys(this._channels)}addChannel(e,t){let r={};r.elemAnchor="elementAnchor"in t?t.elementAnchor:"x"==e||"angle"==e?y.CENTER:y.MIDDLE,r.baseAnchor="baseAnchor"in t?t.baseAnchor:"x"==e||"angle"==e?y.CENTER:y.MIDDLE,r.offset="offset"in t?t.offset:0,"attribute"in t&&(this._attribute=t.attribute),this._channels[e]=r}hasChannel(e){return e in this._channels}getElementAnchor(e){return this._channels[e].elemAnchor}getBaseAnchor(e){return this._channels[e].baseAnchor}getOffset(e){return this._channels[e].offset}get attribute(){return this._attribute?this._attribute:Bt}}function rm(e,t){return(e.classId?e.classId:e.id)+":"+(t.classId?t.classId:t.id)}function nm(e,t,r,n){e.dataScope&&e.dataScope.dataTable.hasAttribute(t)?function(e,t,r,n){if(!e.dataScope.dataTable.hasAttribute(t))return void console.warn("Cannot order collection children by an non-existent attribute",t);let i;if(t===Bt)i=(e,r)=>parseInt(e.dataScope.getAttributeValue(t).substring(1))-parseInt(r.dataScope.getAttributeValue(t).substring(1));else{switch(e.children[0].dataScope.getAttributeType(t)){case Re.Date:break;case Re.Number:case Re.Integer:i=(e,r)=>e.dataScope.aggregateNumericalAttribute(t)-r.dataScope.aggregateNumericalAttribute(t);break;case Re.String:i=n?(e,r)=>n.indexOf(e.dataScope.getAttributeValue(t))-n.indexOf(r.dataScope.getAttributeValue(t)):(e,r)=>e.dataScope.getAttributeValue(t)<r.dataScope.getAttributeValue(t)?-1:1}}e.children.sort(i),r&&e.children.reverse()}(e,t,r,n):function(e,t,r){let n;switch(t){case"x":case"y":case"width":case"height":n=(e,r)=>e.bounds[t]-r.bounds[t];break;default:n=(e,r)=>e[t]-r[t]}e._children.sort(n),r&&e.children.reverse()}(e,t,r),e._sortBy={property:t,descending:r,vals:n}}function im(e,t,r,n){e.vertices[0].dataScope&&e.vertices[0].dataScope.dataTable.hasAttribute(t)?function(e,t,r,n){let i;if(t===Bt)i=(e,r)=>parseInt(e.dataScope.getAttributeValue(t).substring(1))-parseInt(r.dataScope.getAttributeValue(t).substring(1));else{switch(e.vertices[0].dataScope.getAttributeType(t)){case Re.Date:break;case Re.Number:case Re.Integer:i=(e,r)=>e.dataScope.aggregateNumericalAttribute(t)-r.dataScope.aggregateNumericalAttribute(t);break;case Re.String:i=n?(e,r)=>n.indexOf(e.dataScope.getAttributeValue(t))-n.indexOf(r.dataScope.getAttributeValue(t)):(e,r)=>e.dataScope.getAttributeValue(t)<r.dataScope.getAttributeValue(t)?-1:1}}e.vertices.sort(i),r&&e.vertices.reverse()}(e,t,r,n):function(e,t,r){let n=(e,r)=>e[t]-r[t];e.vertices.sort(n),r&&e.vertices.reverse()}(e,t,r),e._sortBy={property:t,descending:r,vals:n}}class sm extends H{constructor(e){super(),this.type=W.GRID,this._numCols=e.numCols,this._numRows=e.numRows,this._start="start"in e?e.start:Q.TopLeft,this._direction="direction"in e?e.direction:J.RowFirst,this._rowGap="rowGap"in e&&void 0!==e.rowGap?e.rowGap:5,this._colGap="colGap"in e&&void 0!==e.colGap?e.colGap:5,this._cellHorzAlignment="horzCellAlignment"in e&&Y("h",e.horzCellAlignment)?e.horzCellAlignment:y.LEFT,this._cellVertAlignment="vertCellAlignment"in e&&Y("v",e.vertCellAlignment)?e.vertCellAlignment:y.BOTTOM,this._numCols||this._numRows||(this._numRows=1),this._left=void 0,this._top=void 0,this._cellBounds=void 0,this._grid=void 0}get cellBounds(){return this._cellBounds}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}clone(){let e=new sm({numCols:this._numCols,numRows:this._numRows,start:this._start,direction:this._direction,colGap:this._colGap,rowGap:this._rowGap,horzCellAlignment:this._cellHorzAlignment,vertCellAlignment:this._cellVertAlignment});return e._left=this._left,e._top=this._top,this._cellBounds&&(e._cellBounds=this._cellBounds.map((e=>e.clone()))),e}getElementsByRow(e,t){let r=[],n=this.group.children;for(let t=0;t<this.numRows;t++){let i=this._grid[t].filter((e=>null!=e)).map((e=>n[e]));if(e){let e=[];for(let t of i)e=e.concat(F(t));r.push(e)}else r.push(i)}return t&&(r=this._filterElementsByExample(r,t)),r}getElementsByCol(e,t){let r=[],n=this.group.children,i=this._grid;for(let t=0;t<this.numCols;t++){let s=i.map((e=>e[t])).filter((e=>null!=e)).map((e=>n[e]));if(e){let e=[];for(let t of s)e=e.concat(F(t));r.push(e)}else r.push(s)}return t&&(r=this._filterElementsByExample(r,t)),r}getElementsByCell(e,t){let r=[],n=this.group.children;for(let t=0;t<n.length;t++)if(e){let e=F(n[t]);r.push(e)}else r.push(n[t]);return t&&(r=this._filterElementsByExample(r,t)),r}_filterElementsByExample(e,t){let r;return"vertex"===t.type?(r=e.map((e=>e.filter((e=>e.classId===t.parent.classId)))),r=r.map((e=>N(t,e)))):"segment"===t.type?(r=e.map((e=>e.filter((e=>e.classId===t.parent.classId)))),r=r.map((e=>L(t,e)))):r=e.map((e=>e.filter((e=>e.classId===t.classId)))),r}getIndex(e){let t=e;for(;t&&t.parent!==this.group;)t=t.parent;return this.group.children.indexOf(t)}getRowCol(e){let t,r;switch(this._direction){case J.RowFirst:t=Math.floor(e/this.numCols),r=e%this.numCols;break;case J.ColumnFirst:t=e%this.numRows,r=Math.floor(e/this.numRows);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}return this._start.toLowerCase().includes("bottom")&&(t=this.numRows-1-t),this._start.toLowerCase().includes("right")&&(r=this.numCols-1-r),{row:t,col:r}}}class am extends yt{constructor(e,t){super(),this._type=Nt.Axis,this._id=this._type+Vt(),this._enc=e,this._textColor="textColor"in t?t.textColor:"#555",this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._showTitle=!("showTitle"in t)||t.showTitle,this._orientation="orientation"in t?t.orientation:ee.VERTICAL,this._numberFormat=t.numberFormat?t.numberFormat:""}get attribute(){return this._enc.attribute}get channel(){return this._enc.channel}get attributeType(){return Dt(this._enc.element).getFieldType(this.attribute)}get orientation(){return this._orientation}get textColor(){return this._textColor}}class om extends am{constructor(e,t){super(e,t),"numCols"in t||"numRows"in t?(this._numCols=t.numCols,this._numRows=t.numRows):this._orientation===ee.VERTICAL?this._numCols=1:this._numRows=1,this._initialize()}_initialize(){let e=this._enc.element.scene,t=this._enc.attribute,r=this._enc.scales[0],n=new Pt(r.domain.map((e=>({category:e,value:r.map(e)})))),i=n.getUniqueAttributeValues("category").sort(((e,t)=>t.length-e.length))[0],s=this._enc.element,a=s instanceof ae&&s.closed?s.strokeWidth:0;if(this._orientation===ee.VERTICAL){let r=0;this._showTitle&&(this.addChild(new At({fillColor:this._textColor,fontSize:this._fontSize,text:t,x:this._x,y:this._y,anchor:["left","top"]})),r=parseFloat(this._fontSize)+5);let o=e.mark("rect",{top:this._y+2+r,left:this._x,width:10,height:10,strokeWidth:a,strokeColor:s.strokeColor,opacity:s.opacity}),l=e.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+r+12+a,anchor:["left","bottom"]}),u=e.glyph(o,l),c=e.repeat(u,n);e.encode(l,{channel:"text",attribute:"category",forLegend:!0}),e.encode(o,{channel:"fillColor",attribute:"category",shareScale:this._enc,forLegend:!0}),c.layout=new sm({numCols:this._numCols,numRows:this._numRows}),this.addChild(c)}else{let t=e.mark("rect",{top:this._y,left:this._x,width:10,height:10,strokeWidth:a,strokeColor:s.strokeColor,opacity:s.opacity}),r=e.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+15,y:this._y,anchor:["left","top"]}),o=e.glyph(t,r),l=e.repeat(o,n);e.encode(r,{channel:"text",attribute:"category",forLegend:!0}),e.encode(t,{channel:"fillColor",attribute:"category",shareScale:this._enc,forLegend:!0}),l.layout=new sm({numCols:this._numCols,numRows:this._numRows,colGap:15}),this.addChild(l)}}}class lm extends am{constructor(e,t){super(e,t),this._initialize()}_initialize(){let e,t,r,i=this._enc.element.scene,s=this._enc.attribute;if(this._orientation==ee.VERTICAL?(e=15,t=300):(e=300,t=15),this._showTitle){let t=i.mark("text",{fillColor:this._textColor,text:s,x:this._x+e/2,y:this._y,anchor:["center","middle"]});this.addChild(t),r=20}else r=0;let a,o=i.mark("rect",{top:this._y+r,left:this._x,width:e,height:t,strokeWidth:0,opacity:this._enc.element.opacity}),l=Object.values(this._enc.attrValues),u=[Math.min(...l),Math.max(...l)],c=this._enc.mapping,h=[],d=[],f=n.format(this._numberFormat);if(c){let n=Object.keys(c).map((e=>parseFloat(e))).sort(((e,t)=>e-t));this._orientation==ee.VERTICAL?(a=new E({x1:0,y1:100,x2:0,y2:0}),n.forEach((n=>{let s=(n-u[0])/(u[1]-u[0]);a.addStop(100*s,c[n],1);let o=i.mark("line",{x1:this._x+e,x2:this._x+e+5,y1:this._y+t-s*t+r,y2:this._y+t-s*t+r,strokeColor:this._strokeColor});d.push(o);let l=i.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(n):n.toFixed(0),x:this._x+e+5+5,y:this._y+t-s*t+r,anchor:["left","middle"]});h.push(l)}))):(a=new E({x1:0,y1:0,x2:100,y2:0}),n.forEach((n=>{let s=(n-u[0])/(u[1]-u[0]);a.addStop(100*s,c[n],1);let o=i.mark("line",{x1:this._x+s*e,x2:this._x+s*e,y1:this._y+20-5+r,y2:this._y+t+5+r,strokeColor:this._strokeColor});d.push(o);let l=i.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(n):n.toFixed(0),x:this._x+s*e,y:this._y+t+5+r,anchor:["center","top"]});h.push(l)})))}else{let n=this._enc.scales[0].domain,o=Dt(this._enc.element),l=o.getAttributeType(s),u=[],c=l===Re.Date?o.getUniqueFieldValues(s):[...new Set(Object.values(this._enc.attrValues))];if(c.length<=10)u=c,u.sort(((e,t)=>e-t));else if(l===Re.Date){c.sort(((e,t)=>e-t));for(let e=0;e<c.length;e+=Math.ceil(c.length/10))u.push(c[e])}else{let e=(n[1]-n[0])/9;for(let t=0;t<10;t++)u.push(n[0]+t*e)}let p=0,_=(u[u.length-1]-u[0])/u.length;for(;_<1;)_*=10,p++;u=u.map((e=>e.toFixed(p))),this._orientation==ee.VERTICAL?(a=new E({x1:0,y1:100,x2:0,y2:0}),u.forEach((u=>{let c=(u-n[0])/(n[1]-n[0]);a.addStop(100*c,this._enc.scales[0].map(u),1);let p=i.mark("line",{x1:this._x+e,x2:this._x+e+5,y1:this._y+t-c*t+r,y2:this._y+t-c*t+r,strokeColor:this._strokeColor});d.push(p);let _=i.mark("text",{fillColor:this._textColor,text:l===Re.Date?o.getRawValue(s,u):this._numberFormat?f(u):u,x:this._x+e+5+5,y:this._y+t-c*t+r,anchor:["left","middle"]});h.push(_)}))):(a=new E({x1:0,y1:0,x2:100,y2:0}),u.forEach((u=>{let c=(u-n[0])/(n[1]-n[0]);a.addStop(100*c,this._enc.scale.map(u),1);let f=i.mark("line",{x1:this._x+c*e,x2:this._x+c*e,y1:this._y+t+r,y2:this._y+t+5+r,strokeColor:this._strokeColor});d.push(f);let p=i.mark("text",{fillColor:this._textColor,text:l===Re.Date?o.getRawValue(s,u):u,x:this._x+c*e,y:this._y+t+5+r,anchor:["center","top"]});h.push(p)})))}o.styles.fillColor=a,this.addChild(o);for(let e of h)this.addChild(e);for(let e of d)this.addChild(e)}}class um extends yt{constructor(e){super(),this._type=Nt.Composite,this._id=e&&e.id?e.id:this._type+Vt()}addChild(e){let t=e.parent;super.addChild(e);let r=M(e)._depGraph;t&<(t,e,r),ut(this,e,r)}}class cm{constructor(e,t,r){this._elems=e,this._channel=t,this._anchor=r}get elements(){return this._elems}get channel(){return this._channel}get anchor(){return this._anchor}}class hm extends H{constructor(e){super(),this.type=W.STRATA,this._direction=e.direction,this._gap="gap"in e?e.gap:0}clone(){return new hm({direction:this._direction,gap:this._gap})}}function dm(e,t,r,n,i,s){switch(t.type){case Nt.Circle:case Nt.Ring:return function(e,t,r,n,i,s){let a,o=r||ne.OUTWARD,l=i||50;if(o!==ne.INWARD&&o!==ne.OUTWARD)throw"Unknown direction to stratify";let u,c=I(t,e),h=Array.isArray(s)?s:[s];if(n){let r=St(e);r.dataScope=void 0,null==u&&(u=r.id),r._classId=u;let n=c.map((e=>h[0].getNode(e.dataScope.getAttributeValue(Ae))));fm(c,n,h[0],r,t.classId?t.classId:t.id,400,350,o,l),a=r}else c.forEach(((r,n)=>{let i=St(e);i.dataScope=void 0,null==u&&(u=i.id),i._classId=u;let s=r.parent;pm(r,t.id,o,l,h[n],h[n].getRoot(),i,e,!0),i._layout=new hm({direction:o}),i._layout.group=i,s.addChild(i),r===t&&(a=i)}));return a}(e,t,r,n,i,s);case Nt.Rect:return function(e,t,r,n,i,s){let a,o,l=r||te.Top2Bottom,u=i||50;if(!Object.values(te).includes(l))throw"Unknown direction to stratify";return I(t).forEach((r=>{let n=St(e);n.dataScope=void 0,null==o&&(o=n.id),n._classId=o;let i=r.parent;_m(r,t.id,l,u,s,s.getRoot(),n,e,!0),n._layout=new hm({direction:l}),n._layout.group=n,i.addChild(n),r===t&&(a=n)})),a}(e,t,r,0,i,s)}}function fm(e,t,r,n,i,s,a,o,l){let u=t.map((e=>r.getParent(e))).filter(((e,t,r)=>r.findIndex((t=>t[Ae]===e[Ae]))===t));if(u=u.filter((e=>e!==r.getRoot())),0===u.length)return;let c=[];for(let t of u){let u,h,d,f=e.filter((e=>r.getParent(r.getNode(e.dataScope.getAttributeValue(Ae)))===t));if(f[0].type===Nt.Circle){let e=f.map((e=>k(s,a,e.bounds.x,e.bounds.y)-e.radius)),t=f.map((e=>k(s,a,e.bounds.x,e.bounds.y)+e.radius));d=o===ne.OUTWARD?Math.max(...t):Math.min(...e)-l;let r=f.map((e=>_e(e.bounds.x,e.bounds.y,s,a))),n=f.map((e=>_e(s+k(s,a,e.bounds.x,e.bounds.y),a-e.radius,s,a))),i=r.map(((e,t)=>e-n[t])),c=r.map(((e,t)=>e+n[t])),p=i.concat(c);u=Math.min(...p),h=Math.max(...p)}else f[0].type===Nt.Arc&&(u=360,h=-360,f.forEach((e=>{let t=e.startAngle,r=e.endAngle;r<t&&(r+=360),u=Math.min(u,t),h=Math.max(h,r)})),u=pe(u),h=pe(h),d=o===ne.OUTWARD?Math.max(...f.map((e=>e.outerRadius))):Math.min(...f.map((e=>e.innerRadius)))-l);let p=kt({type:"arc",innerRadius:d,outerRadius:d+l,x:s,y:a,startAngle:pe(u),endAngle:pe(h),strokeColor:e[0].strokeColor,fillColor:e[0].fillColor,strokeWidth:e[0].strokeWidth,opacity:e[0].opacity});p._updateBounds(),p.dataScope=r.getNodeDataScope(t),p._classId=i,n.addChild(p),c.push(p)}fm(c,u,r,n,i,s,a,o,l)}function pm(e,t,r,n,i,s,a,o,l){l&&(e.dataScope=i.getNodeDataScope(s),e._classId=t);let u=i.getChildren(s);if(0===u.length)return;let c=e.type===Nt.Circle||e.type===Nt.Ring?60:e.startAngle,h=(e.type===Nt.Circle||e.type===Nt.Ring?360:e.angle)/u.length;for(let s=0;s<u.length;s++){let o,l;l=r===ne.OUTWARD?e.type===Nt.Circle?e.radius:e.outerRadius:e.type===Nt.Circle?e.radius-n:e.innerRadius-n,o=kt(360===h?{type:"ring",innerRadius:l,outerRadius:l+n,x:e.x,y:e.y,strokeColor:e.strokeColor,fillColor:e.fillColor,strokeWidth:e.strokeWidth,opacity:e.opacity}:{type:"arc",innerRadius:l,outerRadius:l+n,x:e.x,y:e.y,startAngle:pe(c+h*s),endAngle:pe(c+h*(s+1)),strokeColor:e.strokeColor,fillColor:e.fillColor,strokeWidth:e.strokeWidth,opacity:e.opacity}),o._updateBounds(),o.dataScope=i.getNodeDataScope(u[s]),o._classId=t+"_strata",a.addChild(o),pm(o,t,r,n,i,u[s],a)}}function _m(e,t,r,n,i,s,a,o,l){l&&(e.dataScope=i.getNodeDataScope(s),e._classId=t,a.addChild(e));let u,c,h,d=i.getChildren(s);if(0!==d.length){switch(r){case te.Top2Bottom:case te.Bottom2Top:case te.Left2Right:case te.Right2Left:}u=e.left,c=e.bottom,h=e.width/d.length;for(let s=0;s<d.length;s++){let o=Ot(e);Ue(o,u-o.left,c-o.top),o.resize(h,n),o._updateBounds(),u+=h,o.dataScope=i.getNodeDataScope(d[s]),o._classId=t,a.addChild(o),_m(o,t,r,n,i,d[s],a)}}}class gm extends Je{constructor(e,t,r,n){super(e,t),this._elem=r,this._cumulative=n,this._elements=[]}get element(){return this._elem}isCumulative(){return this._cumulative}get elements(){return this._elements}set elements(e){this._elements=e}}class ym extends Je{constructor(e,t,r){super(e,t),this._key=r}get key(){return this._key}}class mm extends Je{constructor(e,t,r){super(e,t),this._listener=r,this._elements=[]}get mouseEvent(){return this._mouseEvent}set mouseEvent(e){this._mouseEvent=e}get listener(){return this._listener}get elements(){return this._elements}set elements(e){this._elements=e}}class bm extends Je{constructor(e,t,r){super(e,t),this._ctrlId=r}get id(){return this._ctrlId}}class vm extends yt{constructor(e){super(),this._itemMap={},this._type=Nt.Scene,this._id=e&&e.id?e.id:this._type+Vt(),e&&e.fillColor&&(this.fillColor=e.fillColor),this._encodings={},this._relations=[],this._triggers={},this._depGraph=new Yy}get depGraph(){return this._depGraph}get interactionTriggers(){return this._triggers}mark(e,t){if(Object.values(It).indexOf(e)<0)throw new Error("Mascot does not allow directly creating a "+e);let r=void 0===t?{}:t;r.type=e;let n=kt(r);return null!==n&&(n._classId=n.id,this.addChild(n),this._itemMap[n.id]=n,nt(n,this._depGraph),ut(this,n,this._depGraph)),n}glyph(...e){let t=[];for(let r of e)t.push([r.parent,r]);let r=Tt(e);if(null!==r){r._classId=r.id,this.addChild(r),this._itemMap[r.id]=r;for(let e of t)lt(e[0],e[1],this._depGraph);!function(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.getIncomingDataflowOperator(q.EVAL_BBOX,r);for(let r of e.children)t.connect(t.getVariable(Z.BOUNDS,r),n);t.connect(n,r),n.run()}(r,this._depGraph),ut(this,r,this._depGraph)}return r}composite(){let e=new um;return null!==e&&(e._classId=e.id,this.addChild(e),this._itemMap[e.id]=e,function(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e),o=t.createOneWayDependency(q.EVAL_BBOX);t.connect(n,o),t.connect(i,o),t.connect(s,o),t.connect(a,o),t.connect(o,r),o.run()}(e,this._depGraph),ut(this,e,this._depGraph)),e}attach(e,t){if(e.type==Nt.Glyph)for(let t of e.children)t._refBounds||(t._refBounds=t.bounds.clone());e.dataScope=new ge(t)}repeat(e,t,r){let n=r||{};if(n.attribute=n.attribute||Bt,console.log("------ repeat by",n.attribute," ----"),function(e,t,r){if(!e||void 0===t)throw new Error("Incomplete information to do repeat. You must specify an element, a categorical data attribute and a data table");if(t instanceof be||t instanceof xe){if(!Array.isArray(e)||2!==e.length)throw new Error("To repeat with a tree or a network, you need to provide two marks, one for node and one for link")}else t instanceof Pt&&Ce(r.attribute,t);if(r.layout&&!(r.layout instanceof H))throw new Error("Invalid layout: "+r.layout)}(e,t,n),t instanceof be||t instanceof xe){let r=e[0].parent,n=e[1].parent,[i,s]=function(e,t,r,n){let i=n.nodeTable.getAttributeSummary(Ae).unique.map((e=>t.dataScope?t.dataScope.cross(Ae,e):new ge(n.nodeTable).cross(Ae,e))),s=St(e),a=St(e),o={};a.dataScope=t.dataScope?t.dataScope.clone():new ge(n.nodeTable),a.addChild(t);for(let e=1;e<i.length;e++){let e=Ot(t);a.addChild(e)}a.children.forEach(((e,t)=>{e.dataScope=i[t],e.links=[],o[e.dataScope.getAttributeValue(Ae)]=e}));let l=n.linkTable.getAttributeSummary(Bt).unique.map((e=>r.dataScope?r.dataScope.cross(Bt,e):new ge(n.linkTable).cross(Bt,e)));s.dataScope=r.dataScope?r.dataScope.clone():new ge(n.linkTable),s.addChild(r);for(let e=1;e<l.length;e++){let e=Ot(r);s.addChild(e)}s.children.forEach(((e,t)=>e.dataScope=l[t]));let u=n instanceof be?"parent":"source",c=n instanceof be?"child":"target";for(let e of s.children){let t=e.dataScope.getAttributeValue(u),r=e.dataScope.getAttributeValue(c),n=o[t],i=o[r];e.source=n,e.target=i,n.links.push(e),i.links.push(e)}return[a,s]}(this,e[0],e[1],t);return lt(r,e[0],this._depGraph),lt(n,e[1],this._depGraph),ot(i,this._depGraph),ot(s,this._depGraph),ut(i,e[0],this._depGraph),ut(i.parent,i,this._depGraph),ut(s,e[1],this._depGraph),ut(s.parent,s,this._depGraph),[i,s]}if(t instanceof Pt){let r=e.parent,i=qy(this,e,n.attribute,t);return lt(r,e,this._depGraph),ot(i,this._depGraph),ut(i,e,this._depGraph),ut(i.parent,i,this._depGraph),n.layout&&(i.layout=n.layout),i}}divide(e,t,r){let n=r||{};if(n.attribute=n.attribute||Bt,console.log("------ divide by",n.attribute," ----"),function(e,t,r){if(!e||void 0===t)throw new Error("Incomplete information to do divide. You must specify an element, a categorical data attribute and a data table");if(t instanceof Pt&&Ce(r.attribute,t),r.layout&&!(r.layout instanceof H))throw new Error("Invalid layout: "+r.layout)}(e,t,n),t instanceof be||t instanceof xe)throw"Not implemented";if(t instanceof Pt){let{newMark:r,collection:i}=Qy(this,e,n.attribute,n.orientation,t);return it(e,this._depGraph),nt(r,this._depGraph),ot(i,this._depGraph),ut(i,r,this._depGraph),i.parent.type!==Nt.Scene&&ut(i.parent,i,this._depGraph),this.onChange(Z.CHANNEL,"width",r),{newMark:r,collection:i}}}densify(e,t,r){let n=r||{};if(n.attribute=n.attribute||Bt,console.log("------ densify by",n.attribute," ----"),function(e,t,r){if(!e||void 0===t)throw new Error("Incomplete information to do densification. You must specify an element, a categorical data attribute and a data table");t instanceof Pt&&Ce(r.attribute,t)}(e,t,n),t instanceof be||t instanceof xe)throw"Not implemented";if(t instanceof Pt){let r=Oe(0,e,n.attribute,n.orientation,t);return it(e,this._depGraph),nt(r,this._depGraph),r.parent.type!==Nt.Scene&&ut(r.parent,r,this._depGraph),this.onChange(Z.CHANNEL,"width",r),r}}stratify(e,t,r){if(!(t instanceof be||Array.isArray(t)&&t.every((e=>e instanceof be))))throw"Cannot stratify on a non-tree dataset";if(![Nt.Circle,Nt.Rect,Nt.Ring].includes(e.type))throw"Cannot stratify elements that are not rects, circles, or rings";let n=r||{},i=n.direction,s=n.size,a=e.parent,o=dm(this,e,i,n.startFromLeaf,s,t);return lt(a,e,this._depGraph),ot(o,this._depGraph),o.children.length>0&&ut(o,o.firstChild,this._depGraph),ut(o.parent,o,this._depGraph),o}repopulate(e,t,r){e.dataScope=void 0;let n=e;for(let e in r){em(0,n,r[e],t);let i=Pe(n.children[0],!0);for(let e of i){Ve(e,this),st(e,this._depGraph);for(let t of e.refElements)rr(t,this),at(t,this._depGraph);e.clearRefElements()}let s=I(n);for(let e of s)if(e.layout){for(let t of e.layout.refElements)rr(t,this),at(t,this._depGraph);e.layout.clearRefElements()}n=n.children[0]}e.dataScope=new ge(t),this.onChange(Z.CHANNEL,"width",e.children[0])}classify(e,t){let r=t||{};console.log("------ classify by",r.attribute," ----"),function(e,t,r,n){let i=I(t);for(let t of i){let i,s={},a=t.children;for(let e of a){let t=e.dataScope.getAttributeValue(r);t in s||(s[t]=[]),s[t].push(e)}let o=Dt(a[0]);for(let a in s){let l=St(e);t.addChild(l),void 0===i&&(i=l.id),l._classId=i,l.dataScope=t.dataScope?t.dataScope.cross(r,a):new ge(o).cross(r,a);for(let e of s[a])l.addChild(e);n&&(l._layout=n.clone(),l._layout.group=l)}}}(this,e,r.attribute,r.layout),lt(e,e.firstChild.firstChild,this._depGraph),ot(e.firstChild,this._depGraph),ut(e.firstChild,e.firstChild.firstChild,this._depGraph),ut(e,e.firstChild,this._depGraph),this.onChange(Z.CHANNEL,"width",e.firstChild.firstChild)}affix(e,t,r,n){e.dataScope.dataTable!==e.dataScope.dataTable&&console.warn("Affix: elements and base elements are not created from the same table");let i=rm(e,t),s=this._relations.find((e=>e.id===i));s||(s=new tm(e,t),this._relations.push(s)),s.addChannel(r,n||{}),function(e,t){let r=t.getVariable(Z.AFFIXATION,e),n=t.getOutgoingDataflowOperator(q.AFFIXER,r);t.connect(r,n);for(let r of e.channels){let i=t.getVariable(Z.CHANNEL,r,e.element),s=t.getVariable(Z.CHANNEL,r,e.base);t.connect(s,n),t.connect(n,i)}n.run()}(s,this._depGraph)}align(e,t,r){let n=new cm(e,t,r);!function(e,t){let r=t.createMultiWayDependency(q.ALIGNER),n=t.getVariable(Z.ALIGNMENT,e);t.connect(n,r);for(let n of e.elements){let i=t.getVariable(Z.CHANNEL,e.channel,n);t.connect(i,r)}r.run()}(n,this._depGraph),this._relations.push(n)}encode(e,t){if("rowId"===t.attribute&&(t.attribute=Bt),function(e,t){if(!e||!("channel"in t)||!("attribute"in t))throw new Error("Incomplete information to do encoding. You must specify an item, a categorical data attribute and a data table");let r=Dt(e);if(r.tree){let e=t.attribute;if(e.indexOf(".")>0&&!r.tree.nodeTable.hasAttribute(e.split(".")[1]))throw new Error("Data attribute does not exist in the data table")}else if(!r||!r.hasAttribute(t.attribute))throw new Error("Data attribute does not exist in the data table");if(!Object.values(Le).includes(t.channel))throw new Error("Channel Not Supported")}(e,t),t.shareScale){let e=t.shareScale;if(e.channel!=t.channel&&e.channel.indexOf("Color")<0&&t.channel.indexOf("Color")<0)throw new Error("Cannot share scales between "+e.channel+" and "+t.channel+" encodings");t.scheme=t.shareScale.colorScheme}!function(e){let t;"vertex"===e.type&&e.parent.type===Nt.Area?t=e.parent:e.type===Nt.Area&&(t=e),t&&!t._refBounds&&I(t).forEach((e=>e._refBounds=e.bounds.clone()))}(e);let r=t.aggregator?t.aggregator:"sum";console.log("------ encode",t.channel,t.attribute," --");let n=Be(e,t.channel);if(n&&t.attribute!==n.attribute){Ve(n,this),st(n,this._depGraph);for(let e of n.refElements)rr(e,this),at(e,this._depGraph);n.clearRefElements()}let i=new Ky(e,t.channel,t.attribute,r,t);return this._addAttributeEncoding(i),function(e,t,r){let n=e.attribute,i=e.channel,s=e.element,a=t.createOneWayDependency(q.ENCODER);if(["width","height"].includes(e.channel)&&s.type===Nt.Area){let e=t.getVariable(Z.PROPERTY,rt.BASE_LINE,s);t.connect(e,a)}if(r){let n=t.getVariable(Z.DOMAIN,r),o=t.getVariable(Z.SCALE,r),l=t.getVariable(Z.CHANNEL,i,s);t.connect(o,a),t.connect(a,l),n.addLinkedEncoding(e),o.addLinkedEncoding(e),n.incomingDataflow.run()}else{let r=t.getVariable(Z.ATTRIBUTE,n,Dt(s)),o=t.getVariable(Z.PROPERTY,rt.INCLUDE_ZERO,e),l=t.getVariable(Z.DOMAIN,e),u=t.getVariable(Z.DATASCOPE,s),c=t.createOneWayDependency(q.DOMAIN_BUILDER);t.connect(r,c),t.connect(o,c),t.connect(u,c),t.connect(c,l),c.run();let h=t.getVariable(Z.PROPERTY,rt.RANGE_START,e),d=t.getVariable(Z.PROPERTY,rt.RANGE_EXTENT,e),f=t.getVariable(Z.PROPERTY,rt.FLIP_SCALE,e),p=t.getVariable(Z.SCALE,e),_=t.createOneWayDependency(q.SCALE_BUILDER);t.connect(h,_),t.connect(d,_),t.connect(f,_),t.connect(l,_),t.connect(_,p),_.run();let g=t.getVariable(Z.CHANNEL,i,s);t.connect(p,a),t.connect(a,g),a.run()}}(i,this._depGraph,t.shareScale),t.shareScale?this.onChange(Z.DOMAIN,i):this.onChange(Z.CHANNEL,t.channel,e),i}connect(e,t){let r={};e.forEach((e=>r[e.dataScope.getAttributeValue(Ae)]=e));let n=t[0].dataScope.dataTable,i=n.tree?"parent":"source",s=n.tree?"child":"target";for(let t of e)t.links=[];for(let e of t){let t=e.dataScope.getAttributeValue(i),n=e.dataScope.getAttributeValue(s),a=r[t],o=r[n];e.source=a,e.target=o,a.links.push(e),o.links.push(e)}ft(e.find((e=>e.links.length>0)),this._depGraph),this.onChange(Z.CHANNEL,"x",e[0])}_addAttributeEncoding(e){let t=Me(e.element);t in this._encodings||(this._encodings[t]={}),this._encodings[t][e.channel]=e}activate(e,t,r,n,i){!function(e,t,r,n,i){if(!("event"in e)||!("type"in e))throw"Event and trigger must be specified";if(![Qe.WIDGET,Qe.KEYBOARD].includes(e.type)){if(!("target"in t)||!("targetChannels"in t))throw"Target must be specified";if("function"!=typeof r)throw"Target evaluator must be a function"}if(e.type===Qe.ELEMENT&&!("element"in e))throw"Element must be specified for trigger";if(Array.isArray(n)){if(!n.every((e=>"function"==typeof e)))throw"Effect setter must be a function";if(i&&!Array.isArray(i))throw"An array of effect setters must be accompanied by an array of animation effects";if(i&&Array.isArray(i)&&i.length!==n.length)throw"the length of effect setters is not equal to the length of animation effects"}else if("function"!=typeof n)throw"Effect setter must be a function"}(e,t,r,n,i);let s=e.event,a=function(e){switch(e.type){case Qe.ELEMENT:return[e.type,e.element.classId?e.element.classId:e.element.id].join("-");case Qe.ATTRIBUTE:return[e.type].join("-");case Qe.WIDGET:return[e.type,e.event,e.listener?e.listener.id:"scene",e.id?e.id:""].join("-");case Qe.MOUSE:return[e.type,e.event,e.listener?e.listener.id:"scene"].join("-");case Qe.KEYBOARD:return[e.type,e.event,e.key].join("-");default:return[e.type,e.event].join("-")}}(e);if(s=0===s.indexOf("brush")?"brush":s,s in this._triggers||(this._triggers[s]={}),a in this._triggers[s]||(this._triggers[s][a]=function(e){switch(e.type){case Qe.ELEMENT:return new gm(e.type,e.event,e.element,"cumulative"in e&&e.cumulative);case Qe.MOUSE:return new mm(e.type,e.event,e.listener);case Qe.KEYBOARD:return new ym(e.type,e.event,e.key);case Qe.WIDGET:return new bm(e.type,e.event,e.id)}}(e)),this._triggers[s][a].animation=i,![Qe.WIDGET,Qe.KEYBOARD].includes(e.type)){let e=this._triggers[s][a],i=new Zy(e,t,r,n);return function(e,t,r){let n=e.target,i=r.getVariable(Z.COND_ENCODING,e);for(let s of t){let t=r.getVariable(Z.TRIGGER,e.trigger),a=r.findIncomingDataflowOperator(q.TARGET_EVALUATOR,i);a||(a=r.createOneWayDependency(q.TARGET_EVALUATOR,e._targetEval)),r.connect(t,a),r.connect(a,i);let o=r.getVariable(Z.CHANNEL,s,n),l=o.incomingDataflow;if(l&&l instanceof et&&l.outputVar.channel===s)r.connect(i,l);else if(!l){let e=r.createOneWayDependency(q.ENCODER);r.connect(i,e),r.connect(e,o),e.storeValues(n,s)}}}(i,t.targetChannels,this._depGraph),i}this._triggers[s][a].callback=n}onChange(e,...t){if(Object.values(Z).indexOf(e)<0)throw new Error("Unknown Variable Type: "+e);let r=[];this._depGraph.processChange(e,r,...t);for(let e of r)e.run()}gridlines(e,t,r){let n=r||{},i=n.element?Be(n.element,e):De(t,e,this);if(i){i.attribute!==t&&console.warn("Cannot create a "+e+" axis for "+t);let r=[];if("x"==e)for(let e of i.scales)r.push({scale:e,elems:i.getElements(e)});else if("width"==e){let e=G(i.element),t=i.scales[0];if(e.layout&&e.layout.type==W.GRID&&e.layout.numCols>1){let n=e.layout.getElementsByCol(!0);for(let e of n)r.push({scale:t,elems:e})}else r.push({scale:i.scales[0],elems:i.getElements(i.scales[0])})}else if("y"==e){let e=G(i.element);if(e.layout&&e.layout.type==W.GRID&&e.layout.numRows>1){let t=e.layout.getElementsByRow(!0,i.element);for(let e of t)r.push({scale:i.getScale(e[0]),elems:e})}else r.push({scale:i.scales[0],elems:i.getElements(i.scales[0])})}else if("height"==e){let e=G(i.element),t=i.scales[0];if(e.layout&&e.layout.type==W.GRID&&e.layout.numRows>1){let n=e.layout.getElementsByRow(!0,i.element);for(let e of n)r.push({scale:t,elems:e})}else r.push({scale:t,elems:i.getElements(t)})}else"radialDistance"==e&&r.push({scale:i.scales[0],elems:I(i.element)});for(let e of r){let t=new $y(i.channel,i.attribute,e.scale,e.elems,n);this.addChild(t),i.addRefElement(t),gt(t,this._depGraph),ut(this,t,this._depGraph)}}else{let r=n.element?n.element:P(this,t);if(!r)return void console.warn("Cannot create "+e+" gridlines for "+t);let i=D(r.parent);if(!i.layout)return void console.warn("Cannot create "+e+" gridlines for "+t);let s=I(i);for(let r of s){let i=[];r.layout.type==W.GRID&&r.layout.numRows>1&&"x"==e?i=r.layout.getElementsByRow():r.layout.type==W.GRID&&r.layout.numCols>1&&"y"==e?i=r.layout.getElementsByCol():i.push(r.children);for(let s of i){let i=new $y(e,t,null,s,n);this.addChild(i),r.layout.addRefElement(i),gt(i,this._depGraph),ut(this,i,this._depGraph)}}}}axis(e,t,r){let n=r||{},i="rowId"==t?Bt:t,s=[],a=n.element?Be(n.element,e):De(i,e,this);if(a){a.attribute!==i&&console.warn("Cannot create a "+e+" axis for "+i);let t=[];if("x"==e||"width"==e){let e=G(a.element);if(e.layout&&e.layout.type==W.GRID&&e.layout.numCols>1){let r=e.layout.getElementsByCell(!0,a.element);for(let e of r)t.push({scale:a.getScale(e[0]),elems:e})}else t.push({scale:a.scales[0],elems:a.getElements(a.scales[0])})}else if("y"==e||"height"==e){let e=G(a.element);if(e.layout&&e.layout.type==W.GRID&&e.layout.numRows>1){let r=e.layout.getElementsByCell(!0,a.element);for(let e of r)t.push({scale:a.getScale(e[0]),elems:e})}else t.push({scale:a.scales[0],elems:a.getElements(a.scales[0])})}else"radialDistance"==e&&t.push({scale:a.scales[0],elems:I(a.element)});for(let e of t){let t=new nr(a,e.scale,e.elems,n);this.addChild(t),s.push(t),a.addRefElement(t),_t(t,this._depGraph),ut(this,t,this._depGraph),this.onChange(Z.PROPERTY,rt.AXIS_PATH_POSITION,t)}}else{let t=n.element?n.element:P(this,i);if(!t)return void console.warn("Cannot create a "+e+" axis for "+i);let r=D(t.parent);if(!r.layout)return void console.warn("Cannot create a "+e+" axis for "+i);let a=I(r);for(let t of a){let r=[];t.layout.type==W.GRID&&t.layout.numRows>1&&"x"==e?r=t.layout.getElementsByRow():t.layout.type==W.GRID&&t.layout.numCols>1&&"y"==e?r=t.layout.getElementsByCol():r.push(t.children);for(let a of r){let r=new ir(a,e,i,n);this.addChild(r),s.push(r),t.layout.addRefElement(r),pt(r,this._depGraph),ut(this,r,this._depGraph),this.onChange(Z.PROPERTY,rt.AXIS_PATH_POSITION,r)}}}return s}legend(e,t,r){let n=r||{},i="rowId"==t?Bt:t,s=n.element?Be(n.element,e):De(i,e,this);if(s){s.attribute!==t&&console.warn("Cannot create a "+e+" legend for "+t);let r="string"===Dt(s.element).getAttributeType(t)?new om(s,n):new lm(s,n);this.addChild(r),function(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.getVariable(Z.PROPERTY,rt.LEGEND_POSITION,e),i=t.getIncomingDataflowOperator(q.EVAL_BBOX,r);t.connect(n,i),t.connect(i,r)}(r,this._depGraph),ut(this,r,this._depGraph),g(r),this.onChange(Z.PROPERTY,rt.LEGEND_POSITION,r)}else console.warn("Cannot create a "+e+" legend for "+i)}setLayout(e,t){if(e.layout&&(ht(e,e.layout,this._depGraph),t.type===W.TREEMAP)){let t=e.firstChild;for(;t&&t.type===Nt.Collection&&t.layout;)ht(t,t.layout,this._depGraph),t=t.firstChild}if(I(e).forEach((e=>{let r=t?t.clone():t;e._layout=r,r&&(r.group=e)})),dt(e,t,this._depGraph),e.children&&e.children.length>0){let t=F(e,!0);for(let e of t)this.onChange(Z.CHANNEL,"x",e)}}setProperties(e,t,r){let n=r?[e]:I(e);n.forEach((e=>{for(const[r,n]of Object.entries(t))We(e,r,n)})),"width"in t&&n.forEach((e=>e._refBounds.setWidth(t.width))),"height"in t&&n.forEach((e=>e._refBounds.setHeight(t.height)));for(let r in t)["vertex","segment"].includes(e.type)&&!["x","y"].includes(r)||(Object.values(Le).includes(r)?this.onChange(Z.CHANNEL,r,e):this.onChange(Z.PROPERTY,r,e))}setLayoutParameters(e,t){let r=I(e);for(let e of r)for(let r in t)e.layout[r]=t[r];this.onChange(Z.CHANNEL,"width",e.firstChild)}sortChildren(e,t,r,n){if(e instanceof yt)nm(e,t,r,n),this.onChange(Z.ORDER,e);else if(e instanceof ae){let i=I(e);for(let e of i)im(e,t,r,n)}}findElements(e){return V(this,e)}translate(e,t,r){Ue(e,t,r);let n=F(e,!0);for(let e of n)g(e);for(let e of n)this.onChange(Z.CHANNEL,"x",e)}transform(e,t,r){let n=t.clone();switch(e){case"bin":!function(e,t,r,n,i){let s=i.getVariable(Z.ATTRIBUTE,e,r),a=i.getVariable(Z.ATTRIBUTE,t,n),o=i.createOneWayDependency(q.BIN_TRANSFORMER);i.connect(s,o),i.connect(o,a),o.run()}(r.attribute,r.newAttribute,t,n,this._depGraph);break;case"filter":!function(e,t,r,n){let i=n.getVariable(Z.ITEMS,void 0,t),s=n.getVariable(Z.ITEMS,e,r),a=n.createOneWayDependency(q.FILTER_TRANSFORMER);n.connect(i,a),n.connect(a,s),a.run()}(c(r),t,n,this._depGraph);break;case"kde":!function(e,t,r,n,i,s){let a=s.getVariable(Z.ATTRIBUTE,e,r),o=s.getVariable(Z.ATTRIBUTE,t,n),l=s.createOneWayDependency(q.KDE_TRANSFORMER);l.args=i,s.connect(a,l),s.connect(l,o),l.run()}(r.attribute,r.newAttribute,t,n,r,this._depGraph)}return n}}function xm(e,t){let r=new ge(t.tables[e.dt]);for(let t in e.attr2value)r._attr2value[t]=e.attr2value[t],r._updateTuples(t,e.attr2value[t]);return r}class Em extends H{constructor(e){super(),this.type=W.DIRECTED,this._width="width"in e?e.width:500,this._height="height"in e?e.height:300,this._top="top"in e?e.top:0,this._left="left"in e?e.left:0,this._edgeSep="edgeSep"in e?e.edgeSep:50,this._spreadLinks=!("spreadLinks"in e)||e.spreadLinks,this._direction="direction"in e?e.direction:te.Top2Bottom}clone(){return new Em({width:this._width,height:this._height,top:this._top,left:this._left,edgeSep:this._edgeSep,spreadLinks:this._spreadLinks,direction:this._direction})}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get edgeSep(){return this._edgeSep}get spreadLinks(){return this._spreadLinks}get direction(){return this._direction}}class wm extends H{constructor(e){super(),this.type=W.FORCE,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._iterations="iterations"in e?e.iterations:1,this._repulsion="repulsion"in e?e.repulsion:30,this._attraction="attraction"in e?e.attraction:1,this._linkDistance="linkDistance"in e?e.linkDistance:30}clone(){return new wm({x:this._x,y:this._y,iterations:this._iterations,repulsion:this._repulsion,attraction:this._attraction,linkDistance:this._linkDistance})}}class Am extends H{constructor(e){super(),this.type=W.PACKING,this._x="x"in e?e.x:400,this._y="y"in e?e.y:400,this._width=e.width,this._height=e.height}clone(){return new Am({x:this._x,y:this._y,width:this._width,height:this._height})}}class Cm extends H{constructor(e){super(),this.type=W.TIDYTREE,this._width="width"in e?e.width:500,this._height="height"in e?e.height:500,this._left="left"in e?e.left:100,this._top="top"in e?e.top:100,this._orientation="orientation"in e?e.orientation:ee.HORIZONTAL}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get orientation(){return this._orientation}clone(){return new Cm({width:this._width,height:this._height,top:this._top,left:this._left,orientation:this._orientation})}}class Rm extends H{constructor(e){super(),this.type=W.TREEMAP,this._width=e.width,this._height=e.height,this._left=e.left,this._top=e.top}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}clone(){return new Rm({width:this._width,height:this._height,top:this._top,left:this._left})}}function km(e){switch(e.type){case W.GRID:return function(e){let t=new sm(e.args);return t._left=e.left,t._top=e.top,t._cellBounds=e.cellBounds.map((e=>Sm(e))),t._grid=e.grid,t}(e);case W.STACK:return function(e){let t=new Jy(e.args);return t}(e);case W.PACKING:return function(e){let t=new Am(e.args);return t}(e);case W.FORCE:return function(e){return new wm(e.args)}(e);case W.DIRECTED:return function(e){return new Em(e.args)}(e);case W.TIDYTREE:return function(e){return new Cm(e.args)}(e);case W.TREEMAP:return function(e){return new Rm(e.args)}(e);case W.STRATA:return function(e){return new hm(e.args)}(e);default:return void console.warn("unsupported layout type for deserialization:",e.type)}}function Sm(e){return new d(e.x-e.width/2,e.y-e.height/2,e.width,e.height)}function Tm(e,t){e.type===Nt.Pie&&(e.type=Nt.Arc),e.args.type=e.type;let r=kt(e.args);return e.id&&(r._id=e.id),e.classId&&(r._classId=e.classId),e.dataScope&&(r._dataScope=xm(e.dataScope,t)),e.bounds&&(r._bounds=Sm(e.bounds)),e.refBounds&&(r._refBounds=Sm(e.refBounds)),function(e,t,r){if(e.vertices){const n=[];for(let i of e.vertices){const e=Om(i,t,r);n.push(e)}t.vertices=n,t.segments=[];let i=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new se(t.vertices[e-1],t.vertices[e],t,i++));t.type===Nt.Rect&&t.segments.push(new se(t.vertices[t.vertices.length-1],t.vertices[0],t,i++))}t.vertexCounter=e.vertexCounter,t.segmentCounter=e.segmentCounter,t.curveMode=e.curveMode}(e,r,t),r}function Om(e,t,r){let n=new ie(e.x,e.y,t,e.id);return e.dataScope&&(n._dataScope=xm(e.dataScope,r)),"polarAngle"in e&&(n._polarAngle=e.polarAngle),n.shape=e.shape,n.width=e.width,n.height=e.height,n.radius=e.radius,n.fillColor=e.fillColor,n.opacity=e.opacity,n.strokeWidth=e.strokeWidth,n.strokeColor=e.strokeColor,n}function Im(e){let t={};t.fillColor=e.fillColor;let r=new vm(t),n={};if(e.tables)for(let t in e.tables){let r=e.tables[t];n[t]=new Pt(r.data,r.url,r.attributeTypes),n[t]._id=r.id}r.tables=n;let i={};if(e.scales)for(let t in e.scales)i[t]=Pm(e.scales[t]);if(r.scales=i,Vm(e,r,r),Lm(e,r),e.encodings)for(let t of e.encodings)r._addAttributeEncoding(Dm(t,r));return delete r.tables,delete r.scales,r._bounds=Sm(e.bounds),r}function Nm(e,t,r){if(e.type===Nt.Collection){let n=St(r);t.addChild(n),Vm(e,n,r),r._itemMap[n.id]=n}else if(e.type===Nt.Glyph){let n=Tt();t.addChild(n),Vm(e,n,r),r._itemMap[n.id]=n}else if(e.type===Nt.Composite){let n=new um;t.addChild(n),Vm(e,n,r),r._itemMap[n.id]=n,n._bounds=Sm(e.bounds)}else if(Object.values(C).includes(e.type)){let n=Tm(e,r);r._itemMap[n.id]=n,t.addChild(n)}}function Lm(e,t){if(e.children)for(let r of e.children)Lm(r,t);else if(Object.values(C).includes(e.type)){let r=t._itemMap[e.id];e.links&&(r.links=e.links.map((e=>t._itemMap[e]))),e.source&&(r.source=t._itemMap[e.source]),e.target&&(r.target=t._itemMap[e.target])}}function Vm(e,t,r){if(e.id&&(t._id=e.id),e.classId&&(t._classId=e.classId),e.dataScope&&(t._dataScope=xm(e.dataScope,r)),t._bounds=Sm(e.bounds),e.layout&&(t._layout=km(e.layout),t._layout.group=t),t._sortBy=e.sortBy,e.children)for(let n of e.children)Nm(n,t,r)}function Pm(e){let t=new Yt(e.type,e.args);return t._id=e.id,t.domain=e.domain,t.range=e.range,t}function Dm(e,t){let r=function(e,t,r){if("vertex"===t){let t=e.split("_v_");return r._itemMap[t[0]].vertices.find((e=>e._id===parseInt(t[1])))}if("segment"===t){let t=e.split("_s_");return r._itemMap[t[0]].segments.find((e=>e._id===parseInt(t[1])))}return r._itemMap[e]}(e.element,e.elementType,t);r||console.warn("element not created:",e.element,e.elementType);let n=new Ky(r,e.channel,e.attr,e.aggregator,e.args);if(e.scales&&(n._scales=e.scales.map((e=>t.scales[e]))),e.elemGroups&&(n._elemGroups=e.elemGroups.map((e=>e.map((e=>t._itemMap[e]))))),e.elem2scale){n._elem2scale={};for(let r in e.elem2scale)n._elem2scale[r]=t.scales[e.elem2scale[r]]}return e.args.startAngle&&(n.startAngle=e.args.startAngle),n}function Bm(e){let t={};return t.id=e._id,t.data=e._rawData,t.attributeTypes=e._attrTypes,t.url=e.url,t}function Mm(e){let t={};return t.dt=e._dt.id,t.attr2value=Object.assign({},e._attr2value),t}function Gm(e,t){t.vertices=[];for(let r of e.vertices)t.vertices.push(jm(r));t.vertexCounter=e.vertexCounter,t.segmentCounter=e.segmentCounter,t.curveMode=e.curveMode}function jm(e){let t={};return t.type=e.type,t.id=e._id,t.x=e.x,t.y=e.y,e._dataScope&&(t.dataScope=Mm(e._dataScope)),void 0!==e._polarAngle&&(t.polarAngle=e._polarAngle),t.shape=e.shape,t.width=e.width,t.height=e.height,t.radius=e.radius,t.fillColor=e.fillColor,t.opacity=e.opacity,t.strokeWidth=e.strokeWidth,t.strokeColor=e.strokeColor,t}function zm(e){return e.type===Nt.Scene?function(e){let t=Hm(e,{});t.fillColor=e.fillColor,t.scales={},t.encodings=[];for(let r in e._encodings)for(let n in e._encodings[r]){let i=e._encodings[r][n];i._forLegend||t.encodings.push(Um(i));for(let e of i._scales)e.id in t.scales||(t.scales[e.id]=Fm(e))}t.tables={};let r=function(e){let t={};for(let r in e._encodings)for(let n in e._encodings[r]){let i=e._encodings[r][n];i.dataTable.id in t||i._forLegend||(t[i.dataTable.id]=i.dataTable)}for(let r of e.children)if(![Nt.Axis,Nt.Legend,Nt.Gridlines].includes(r.type)){if(r.dataScope){t[r.dataScope.dataTable.id]=r.dataScope.dataTable;break}if(r.children&&r.children.length>0){let e=r.firstChild;for(;e;){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}e=e.children&&e.children.length>0?e.firstChild:void 0}}}return t}(e);for(let e in r)t.tables[e]=Bm(r[e]);return console.log(t.tables),t}(e):e instanceof yt?Hm(e,{}):e instanceof w?function(e){let t={args:{}};t.type=e.type,t.id=e.id,e.classId&&(t.classId=e.classId),e._dataScope&&(t.dataScope=Mm(e._dataScope)),e.bounds&&(t.bounds=e.bounds.toJSON()),e.refBounds&&(t.refBounds=e.refBounds.toJSON()),e.links&&(t.links=e.links.map((e=>e.id))),e.source&&(t.source=e.source.id),e.target&&(t.target=e.target.id);for(let r in e.styles)r.indexOf("Color")>0&&e.styles[r]instanceof E?t.args[r]=e.styles[r].toJSON():t.args[r]=e.styles[r];switch(e.type){case Nt.Arc:case Nt.Pie:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.innerRadius=e._innerRadius,t.args.outerRadius=e._outerRadius,t.args.startAngle=e._startAngle,t.args.endAngle=e._endAngle,t.args.direction=e._direction,t.args.thickness=e._thickness}(e,t),Gm(e,t);break;case Nt.Area:!function(e,t){t.args.baseline=e._baseline,t.args.orientation=e._orientation}(e,t),Gm(e,t);break;case Nt.Circle:!function(e,t){t.args.x=e.x,t.args.y=e.y,t.args.radius=e.radius}(e,t);break;case Nt.Image:break;case Nt.Line:case Nt.Path:case Nt.BezierCurve:Gm(e,t);break;case Nt.PointText:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.text=e._text,t.args.anchor=e._anchor}(e,t);break;case Nt.Polygon:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.radius=e._radius}(e,t),Gm(e,t);break;case Nt.Rect:!function(e,t){t.args.width=e.width,t.args.height=e.height,t.args.top=e.top,t.args.left=e.left}(e,t),Gm(e,t);case Nt.Ring:}return t}(e):(console.warn("unsupported serialization",e.type),{type:e.type})}function Fm(e){let t={};return t.type=e.type,t.id=e.id,e._args&&(t.args=e._args),t.domain=e.domain,t.range=e.range,t}function Um(e){let t={};t.element=e._elem.id,t.elementType=e._elem.type,e.attrValues&&(t.attrValues=e.attrValues),t.channel=e._channel,t.attr=e._attribute,t.aggregator=e._aggregator,t.args={},t.args.includeZero=e._includeZero,t.args.flipScale=e._flipScale,t.args.mapping=e._mapping,t.args.rangeExtent=e._preferredRangeExtent,t.args.domain=e._preferredDomain,t.args.scaleType=e._scaleType,t.args.scheme=e._colorScheme,t.scales=e._scales.map((e=>e.id)),t.elemGroups=e._elemGroups.map((e=>e.map((e=>e.id)))),t.elem2scale={};for(let r in e._elem2scale)t.elem2scale[r]=e._elem2scale[r].id;return t.refElements=e._refElements.map((e=>e.id)),"angle"==e.channel&&(t.args.startAngle=e.startAngle),t}function Hm(e,t){if(t.id=e.id,t.type=e.type,e.classId&&(t.classId=e.classId),e._dataScope&&(t.dataScope=Mm(e._dataScope)),t.bounds=e.bounds.toJSON(),e._layout&&(t.layout=function(e){switch(e.type){case W.GRID:return function(e){let t={args:{}};return t.type=e.type,t.args.numCols=e._numCols,t.args.numRows=e._numRows,t.args.start=e._start,t.args.direction=e._direction,t.args.colGap=e._colGap,t.args.rowGap=e._rowGap,t.args.horzCellAlignment=e._cellHorzAlignment,t.args.vertCellAlignment=e._cellVertAlignment,t.left=e._left,t.top=e._top,t.cellBounds=e._cellBounds.map((e=>e.toJSON())),t.group=e.group.id,t.grid=e._grid,t}(e);case W.STACK:return function(e){let t={args:{}};return t.type=e.type,t.args.orientation=e._orientation,t.args.direction=e._direction,t.args.left=e._left,t.args.top=e._top,t.args.horzCellAlignment=e._horzCellAlignment,t.args.vertCellAlignment=e._vertCellAlignment,t.args.gap=e._gap,t.group=e.group.id,t}(e);case W.PACKING:return function(e){let t={args:{}};return t.type=e.type,t.args.x=e._x,t.args.y=e._y,t.args.width=e._width,t.args.height=e._height,t.group=e.group.id,t}(e);case W.FORCE:return function(e){let t={args:{}};return t.type=e.type,t.args.x=e._x,t.args.y=e._y,t.args.iterations=e._iterations,t.args.repulsion=e._repulsion,t.args.attraction=e._attraction,t.args.linkDistance=e._linkDistance,t.group=e.group.id,t}(e);case W.CLUSTER:return function(e){let t={args:{}};return t.type=e.type,t.args.size=e._size,t.args.rootX=e._rootX,t.args.rootY=e._rootY,t}(e);case W.DIRECTED:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t.args.edgeSep=e._edgeSep,t.args.spreadLinks=e._spreadLinks,t.args.direction=e._direction,t}(e);case W.TIDYTREE:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t.args.orientation=e._orientation,t}(e);case W.TREEMAP:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t}(e);case W.STRATA:return function(e){let t={args:{}};return t.type=e.type,t.args.direction=e._direction,t.args.gap=e._gap,t}(e);default:throw new Error("unknow layout type "+e.type)}}(e._layout)),t.children=[],e.children.length>0)for(let r of e.children)t.children.push(zm(r));return t.sortBy=e._sortBy,t}function Wm(e,t,r,i,s){for(let a of e){let e=a.listener?a.listener:r,o=e.type===Nt.Axis?e.boundsWithoutTitle:e.bounds,l=[[o.left,o.top],[o.right,o.bottom]],u="brushX"===a.event?n.brushX():"brushY"===a.event?n.brushY():n.brush();u.extent(l).on("brush end",(e=>{let t,n;if(e&&e.selection)switch(a.event){case"brushX":t=[e.selection[0],e.selection[1]],n=void 0;break;case"brushY":t=void 0,n=[e.selection[0],e.selection[1]];break;default:t=[e.selection[0][0],e.selection[1][0]],n=[e.selection[0][1],e.selection[1][1]]}else t=void 0,n=void 0;a.mouseEvent={xInterval:t,yInterval:n},r.onChange(Z.TRIGGER,a),i._render(r,s)})),t.append("g").attr("class","brush").call(u)}}function Ym(e,t,r,n,i){t.on("mousemove",(s=>{for(let n of e){let[e,i]=R(t.attr("id"),s.clientX,s.clientY),a=j(r,n.element.type,e,i);a?n.isCumulative&&!n.elements.includes(a)?n.elements.push(a):n.elements=[a]:n.elements=[],n.mouseEvent={x:e,y:i},r.onChange(Z.TRIGGER,n)}n._render(r,i)}))}function Xm(e,t,r,i,s){for(let t of e)if(t.type===Qe.WIDGET){console.log(t.id),document.getElementById(t.id).addEventListener("input",(function(){qm(t,r,i,s)}))}else t.type===Qe.KEYBOARD&&n.select("body").on("keydown",(e=>{e.key===t.key&&qm(t,r,i,s)}))}function qm(e,t,r,n){if(Array.isArray(e.callback))for(let i=0;i<e.callback.length;i++)e.callback[i](),r._render(t,n,e.animation[i]);else e.callback(),r._render(t,n,e.animation)}function Km(e,t,r,n,i){t.on("click",(s=>{for(let n of e){let[e,i]=R(t.attr("id"),s.clientX,s.clientY),a=j(r,n.element.type,e,i);a?n.isCumulative&&!n.elements.includes(a)?n.elements.push(a):n.elements=[a]:n.elements=[],n.mouseEvent={x:e,y:i},r.onChange(Z.TRIGGER,n)}n._render(r,i)}))}class Zm{constructor(e){this._svgId=e,this._compMap={},this._decoMap={},this._brushCreated=0}render(e,t){let r=t||{};n.select("#"+this._svgId).select("defs").empty()&&n.select("#"+this._svgId).append("defs"),this._render(e,r),this._registerEvents(e,r)}_render(e,t,r){for(let e in this._decoMap)this._decoMap[e].remove(),delete this._decoMap[e];this._removed={};for(let e in this._compMap)this._removed[e]=1;this._renderItem(e,t,r);for(let e in this._removed)this._compMap[e].remove(),delete this._compMap[e]}_registerEvents(e,t){let r=n.select("#"+this._svgId);for(let n in e.interactionTriggers){let i=Object.values(e.interactionTriggers[n]);switch(n){case"click":r.on("click",null),Km(i,r,e,this,t);break;case"brush":case"brushX":case"brushY":Wm(i,r,e,this,t);break;case"hover":Ym(i,r,e,this,t);break;case"input":Xm(i,0,e,this,t)}}}clear(){let e=document.getElementById(this._svgId);for(;e.firstChild;)e.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(e,t,r){this._configSVG(e);let i=this._compMap[e.id];switch(e.type){case Nt.Scene:!function(e,t){t.style("background",e.fillColor?e.fillColor:"#fff")}(e,n.select("#"+this._svgId));break;case Nt.Circle:!function(e,t){t.attr("cx",e.x),t.attr("cy",e.y),t.attr("r",e.radius)}(e,i);break;case Nt.Rect:!function(e,t){let r=e.bounds;t.attr("x",r.left).attr("y",r.top).attr("width",r.width).attr("height",r.height)}(e,i);break;case Nt.Path:case Nt.BezierCurve:case Nt.BundledPath:case Nt.Chord:case Nt.Polygon:case Nt.Link:case Nt.Pie:case Nt.Line:case Nt.Area:case Nt.Ring:case Nt.Arc:case Nt.Gridlines:!function(e,t){t.attr("d",e.getSVGPathData()),e.closed||t.style("fill","none"),(e.id.includes("axis")||e.id.includes("gridlines"))&&t.style("shape-rendering","crispEdges"),e.type===Nt.BundledPath&&t.style("mix-blend-mode","multiply")}(e,i);break;case Nt.PointText:!function(e,t){if(t.attr("text-anchor",v(e.anchor[0])).attr("alignment-baseline",v(e.anchor[1])).attr("dominant-baseline",v(e.anchor[1])).attr("x",e.x).attr("y",e.y),e.hasBackground()){let t=n.select("#"+m(e)),r=e.bounds;t.attr("x",r.left-5).attr("y",r.top-5).attr("width",r.width+10).attr("height",r.height+10).attr("rx",5).attr("ry",5).style("fill",e.backgroundColor).style("stroke",e.borderColor).style("strokeWidth",e.borderWidth)}e.textPath?(t.select("textPath").empty()&&t.append("textPath"),t.select("textPath").attr("href","#"+b(e)).attr("startOffset",e.textPathOffset).text(e.text)):t.text(e.text)}(e,i);break;case Nt.Image:!function(e,t){t.attr("href",e.src).attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height)}(e,i)}if(function(e,t,r){for(let i in e.styles)if(void 0!==e.styles[i])if(i.indexOf("Color")>0&&e.styles[i].type==Nt.LinearGradient){let n=r.select("defs"),s=e.styles[i];if(n.select("#"+s.id).empty()){let e=n.append("linearGradient").attr("id",s.id);e.attr("x1",s.x1+"%").attr("x2",s.x2+"%").attr("y1",s.y1+"%").attr("y2",s.y2+"%");for(let t of s.stops)e.append("stop").attr("offset",t.offset+"%").style("stop-color",t.color).style("stop-opacity",t.opacity)}t.style(x[i],"url(#"+s.id+")")}else t.style(x[i],e.styles[i]),"visibility"===i&&e.type===Nt.PointText&&e.hasBackground()&&n.select("#"+m(e)).style(x[i],e.styles[i])}(e,i,n.select("#"+this._svgId)),e._rotate&&i.attr("transform","rotate("+e._rotate.join(" ")+")"),r&&(i=i.transition().delay(r.delay?r.delay:0).duration(r.duration?r.duration:0)),e.vertices&&this._renderVertices(e),[Nt.Circle].includes(e.type)&&t&&t.bounds?this._renderBounds(e):A(e)&&t&&t.refBounds&&this._renderRefBounds(e),e.children)for(let n of e.children)this._renderItem(n,t,r)}_configSVG(e){let t,r=e.parent;if(t=r&&r.id&&r.id in this._compMap?n.select("#"+this._svgId).select("#"+r.id):n.select("#"+this._svgId),e.id in this._compMap)delete this._removed[e.id],e.type===Nt.PointText&&(e.hasBackground()&&delete this._removed[m(e)],e.textPath&&delete this._removed[b(e)]);else{if(e.type===Nt.PointText&&(e.hasBackground()&&(this._compMap[m(e)]=t.append("rect").attr("id",m(e))),e.textPath)){let t=n.select("#"+this._svgId).select("defs"),r=b(e);t.select("#"+r).empty()&&(this._compMap[r]=t.append("path").attr("id",r)),this._compMap[r].attr("d",e.textPath).style("fill","none")}this._compMap[e.id]=t.append(this._getSVGElementType(e))}e.type==Nt.Gridlines&&this._compMap[e.id].lower(),this._compMap[e.id].attr("id",e.id),e.classId&&this._compMap[e.id].attr("class",e.classId)}_renderBounds(e){let t=e.bounds;e.layout&&"grid"==e.layout.type&&this._renderLayout(e),e.id in this._decoMap||(this._decoMap[e.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[e.id].attr("x",t.left).attr("y",t.top).attr("width",t.width).attr("height",t.height).attr("fill","none").attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5")}_renderRefBounds(e){let t=e.refBounds;t&&(e.id in this._decoMap||(this._decoMap[e.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[e.id].attr("x",t.left).attr("y",t.top).attr("width",t.width).attr("height",t.height).attr("fill","none").attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5"))}_renderVertices(e){let t=e.id+"-vertices";if(t in this._compMap)delete this._removed[t];else{let r=e.parent,i=r?r.id:this._svgId;this._compMap[t]=n.select("#"+i).append("g").attr("id",t)}if(0===e.vertices.map((e=>e.shape)).filter((e=>void 0!==e)).length)return void this._compMap[t].style("visible","hidden");this._compMap[t].style("visible","visible");let r=e.vertices.filter((e=>void 0!==e.shape));for(let e of r){let r=t+"-"+e.id;r in this._compMap?e.shape!==this._compMap[r].node().tagName?(this._compMap[r].remove(),this._compMap[r]=n.select("#"+t).append(e.shape).attr("id",r),delete this._removed[r]):delete this._removed[r]:this._compMap[r]=n.select("#"+t).append(e.shape).attr("id",r),"rect"==e.shape?n.select("#"+r).attr("x",e.x-e.width/2).attr("y",e.y-e.height/2).attr("width",e.width).attr("height",e.height):"circle"==e.shape&&n.select("#"+r).attr("cx",e.x).attr("cy",e.y).attr("r",e.radius),n.select("#"+r).style("fill",e.fillColor).style("opacity",e.opacity).style("stroke-width",e.strokeWidth).style("stroke",e.strokeColor)}}_renderLayout(e){let t=e.id+"-grid";t in this._decoMap||(this._decoMap[t]=n.select("#"+this._svgId).append("g").attr("id",t).attr("class","deco"));let r=e.layout.cellBounds;e.layout.rowGap,this._decoMap[t].selectAll("rect").remove();for(let e of r)this._decoMap[t].append("rect").attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getSVGElementType(e){switch(e.type){case Nt.Rect:return"rect";case Nt.Collection:case Nt.Group:case Nt.Glyph:case Nt.Scene:case Nt.Axis:case Nt.Legend:case Nt.Composite:return"g";case Nt.Area:case Nt.Path:case Nt.Polygon:case Nt.Ring:case Nt.Pie:case Nt.Arc:case Nt.BezierCurve:case Nt.BundledPath:case Nt.Chord:case Nt.Line:case Nt.Gridlines:return"path";case Nt.Circle:return"circle";case Nt.PointText:return"text";case"vertex":if("circle"==e.shape)return"circle";if("rect"==e.shape)return"rect";throw"argument exception";case"image":return"image"}}}function $m(e,t){return void 0===e&&void 0===t||void 0!==e&&void 0!==t}function Jm(e,t){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&(0===r.length||r.every((e=>n.includes(e))))}function Qm(e,t){if(!$m(e.layout,t.layout))return console.log("Not both defined or undefined:",e.bounds,t.bounds),!1;let r=e.layout,n=t.layout;if(!r&&!n)return!0;if(r.type!==n.type)return console.log("layout types are different:",r,n),!1;switch(r.type){case W.GRID:return function(e,t){e._cellBounds.length!==t._cellBounds.length&&console.log("cell bounds length different:",e,t);for(let r=0;r<e._cellBounds;r++)if(!tb(e._cellBounds[r],t._cellBounds[r]))return console.log("cell bounds not equal:",e,t),!1;for(let r=0;r<e._grid.length;r++)for(let n=0;n<e._grid[r].length;n++)if(e._grid[r][n]!==t._grid[r][n])return console.log("grid not equal",e,t),!1;return e._numCols===t._numCols&&e._numRows===t._numRows&&e._start===t._start&&e._direction===t._direction&&e._rowGap===t._rowGap&&e._colGap===t._colGap&&e._cellHorzAlignment===t._cellHorzAlignment&&e._cellVertAlignment===t._cellVertAlignment&&e._left===t._left&&e._top===t._top}(r,n);case W.STACK:return function(e,t){return e._orientation===t._orientation&&e._direction===t._direction&&e._left===t._left&&e._top===t._top&&e._horzCellAlignment===t._horzCellAlignment&&e._vertCellAlignment===t._vertCellAlignment&&e._gap===t._gap}(r,n);case W.PACKING:return function(e,t){return e._x===t._x&&e._y===t._y&&e._width===t._width&&e._height===t._height}(r,n);case W.FORCE:return function(e,t){return e._x===t._x&&e._y===t._y&&e._iterations===t._iterations&&e._repulsion===t._repulsion&&e._attraction===t._attraction&&e._linkDistance===t._linkDistance}(r,n);case W.DIRECTED:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left&&e._edgeSep===t._edgeSep&&e._spreadLinks===t._spreadLinks&&e._direction===t._direction}(r,n);case W.TIDYTREE:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left&&e._orientation===t._orientation}(r,n);case W.STRATA:return function(e,t){return e._direction===t._direction&&e._gap===t._gap}(r,n);case W.TREEMAP:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left}(r,n);default:return!1}}function eb(e,t){if(!$m(e.bounds,t.bounds))return console.log("Not both defined or undefined:",e.bounds,t.bounds),!1;let r=e.bounds,n=t.bounds;return!r&&!n||tb(r,n)}function tb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rb(e,t){if(!$m(e,t))return console.log("Not both defined or undefined:",e,t),!1;if(e.type!==t.type)return console.log("Different mark types:",e,t),!1;if(e.id!==t.id)return console.log("id not equal:",e,t),!1;if(e.classId!==t.classId)return console.log("class id not equal:",e,t),!1;if(!ib(e,t))return console.log("DataScopes not equal",e,t),!1;if(!eb(e,t))return console.log("Bounds not equal",e,t),!1;if(!$m(e.links,t.links))return console.log("Not both defined or undefined: links ",e.links,t.links),!1;if(!$m(e.source,t.source))return console.log("Not both defined or undefined: source ",e.source,t.source),!1;if(!$m(e.target,t.target))return console.log("Not both defined or undefined: links ",e.target,t.target),!1;if(e.links&&t.links&&e.links.length!==t.links.length)return console.log("unequal number of links",e,t),!1;if(e.source&&t.source&&!rb(e.source,t.source))return console.log("different sources",e.source,t.source),!1;if(e.target&&t.target&&!rb(e.target,t.target))return console.log("different targets",e.target,t.target),!1;switch(e.type){case Nt.Arc:case Nt.Pie:return nb(e,t)?e.x===t.x&&e.y===t.y&&e.innerRadius===t.innerRadius&&e.outerRadius===t.outerRadius&&e.startAngle===t.startAngle&&e.endAngle===t.endAngle&&e.direction===t.direction&&e.thickness===t.thickness:(console.log("vertices not equal:",e,t),!1);case Nt.Area:return nb(e,t)?e.baseline===t.baseline&&e.orientation===t.orientation:(console.log("vertices not equal:",e,t),!1);case Nt.Circle:return e.x===t.x&&e.y===t.y&&e.radius===t.radius;case Nt.Image:return console.warn("not implemented"),!0;case Nt.Line:case Nt.Path:case Nt.BezierCurve:return!!nb(e,t)||(console.log("vertices not equal:",e,t),!1);case Nt.PointText:return e.x===t.x&&e.y===t.y&&e.text===t.text&&e.anchor[0]===t.anchor[0]&&e.anchor[1]===t.anchor[1];case Nt.Polygon:return nb(e,t)?e.x===t.x&&e.y===t.y&&e.radius===t.radius:(console.log("vertices not equal:",e,t),!1);case Nt.Rect:return nb(e,t)?e.width===t.width&&e.height===t.height&&e.top===t.top&&e.left===t.left:(console.log("vertices not equal:",e,t),!1);case Nt.Ring:default:return console.warn("not implemented"),!0}}function nb(e,t){if(e.vertices.length!==t.vertices.length)return console.log("unequal number of vertices:",e,t),!1;for(let r=0;r<e.vertices.length;r++){let n=e.vertices[r],i=t.vertices[r];return n.id!==i.id?(console.log("vertex id not equal:",n,i),!1):n.x!==i.x||n.y!==i.y?(console.log("vertex position not equal:",n,i),!1):ib(n,i)?n._polarAngle===i._polarAngle&&n.shape===i.shape&&n.width===i.width&&n.height==i.height&&n.radius==i.radius&&n.fillColor==i.fillColor&&n.opacity==i.opacity&&n.strokeWidth==i.strokeWidth&&n.strokeColor==i.strokeColor:(console.log("vertex data scopes not equal:",n.dataScope,i.dataScope),!1)}}function ib(e,t){if(!$m(e.dataScope,t.dataScope))return console.log("Not both defined or undefined:",e.dataScope,t.dataScope),!1;if(!e.dataScope&&!t.dataScope)return!0;let r=e.dataScope,n=t.dataScope;if(!Jm(r._attr2value,n._attr2value))return!1;for(let e in r._attr2value)if(r._attr2value[e]!==n._attr2value[e])return!1;return r._dt.id===n._dt.id&&r._tuples.length===n._tuples.length}function sb(e,t){return e.type!==t.type&&console.log("Different types:",e.type,t.type),[Nt.Collection,Nt.Glyph,Nt.Composite].includes(e.type)?ab(e,t):e instanceof w?rb(e,t):void 0}function ab(e,t){let r=e.children.filter((e=>!Object.values(Lt).includes(e.type))),n=t.children.filter((e=>!Object.values(Lt).includes(e.type)));if(r.length!==n.length)return console.log("children length not equal:",r,n),!1;if(e.id!==t.id)return console.log("id not equal:",e,t),!1;if(e.classId!==t.classId)return console.log("class id not equal:",e,t),!1;if(!ib(e,t))return console.log("DataScopes not equal",e.dataScope,t.dataScope),!1;if(!eb(e,t))return console.log("Bounds not equal",e,t),!1;if(!Qm(e,t))return console.log("Layouts not equal",e,t),!1;if(!function(e,t){if(!Jm(e,t))return console.log("different keys",e,t),!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}(e._sortBy,t._sortBy))return console.log("SortBy not equal",e,t),!1;for(let e=0;e<r.length;e++)if(!sb(r[e],n[e]))return console.log("Not equal",r[e],n[e]),!1;return!0}class ob extends H{constructor(e){super(),this.type=W.CIRCULAR,this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._radius="radius"in e?e.radius:100}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}clone(){return new ob({x:this._x,y:this._y,radius:this._radius})}}class lb extends H{constructor(e){super(),this.type=W.CLUSTER,this._isRadial="radial"in e&&e.radial,this._angleExtent="angleExtent"in e?e.angleExtent:360,this._radius="radius"in e?e.radius:300,this._rootX="x"in e?e.x:300,this._rootY="y"in e?e.y:300,this._orientation="orientation"in e?e.orientation:ee.HORIZONTAL,this._width="width"in e?e.width:800,this._height="height"in e?e.height:600,this._left="left"in e?e.left:60,this._top="top"in e?e.top:100,this._tree="tree"in e?e.tree:void 0}get radius(){return this._radius}get angleExtent(){return this._angleExtent}get x(){return this._rootX}get y(){return this._rootY}get width(){return this._width}get height(){return this._height}get left(){return this._left}get top(){return this._top}isRadial(){return this._isRadial}get orientation(){return this._orientation}clone(){return new lb({radius:this._radius,angleExtent:this._angleExtent,x:this._rootX,y:this._rootY,radial:this._isRadial,orientation:this._orientation,left:this._left,top:this._top,width:this._width,height:this._height,tree:this._tree})}}e.csv=async function(e){return async function(e){let t=await Mt("GET",e),r=n.csvParse(t.trim(),n.autoType);return new Pt(r,e)}(e)},e.deserialize=function(e){return Im(e)},e.graphJSON=async function(e){return async function(e){let t=await Mt("GET",e);return new xe(JSON.parse(t),e)}(e)},e.isEqual=function(e,t){return function(e,t){return e.fillColor!==t.fillColor?(console.log("fillColor not equal:",e,t),!1):ab(e,t)}(e,t)},e.layout=function(e,t){let r=t||{};switch(e.toLowerCase()){case W.STACK:return new Jy(r);case W.PACKING:return new Am(r);case W.FORCE:return new wm(r);case W.DIRECTED:return new Em(r);case W.TIDYTREE:return new Cm(r);case W.TREEMAP:return new Rm(r);case W.CIRCULAR:return new ob(r);case W.CLUSTER:return new lb(r);case W.GRID:default:return new sm(r)}},e.renderer=function(e,t){return new Zm(t)},e.scene=function(e){return new vm(e)},e.serialize=function(e){return zm(e)},e.treeJSON=async function(e){return async function(e){let t=await Mt("GET",e);return new be(JSON.parse(t),e)}(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
/* version: 3.1.6 */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3")):"function"==typeof define&&define.amd?define(["exports","d3"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).msc={},e.d3)}(this,(function(e,t){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var r=i(t);const s={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var e=this.getCanvas();return e?e.getContext("2d"):null}};class n{constructor(e,t,i){this._id="predicate_"+Gt(),this._type=e||a.POINT,this._variableType=t,this._variableName=i,this._value=void 0}get type(){return this._type}get value(){return this._value}set value(e){this._value=e}get id(){return this._id}get variableType(){return this._variableType}get variableName(){return this._variableName}}const a=Object.freeze({POINT:"point",INTERVAL:"interval",LIST:"list"});class o extends n{constructor(e,t,i){super(e,t,i)}testElement(e){let t;if("attribute"==this._variableType){if(!e.dataScope)return!1;t=e.dataScope.getAttrVal(this._variableName)}else t=e[this._variableName];return this._value[0]<=t&&this._value[1]>=t}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value[0]<=t&&this._value[1]>=t}return!1}}class l extends n{constructor(e,t,i){super(e,t,i)}addValue(e){this._value||(this._value=[]),this._value.push(e)}resetValue(){this._value=void 0}testElement(e){if("attribute"==this._variableType){if(!e.dataScope)return!1;let t=e.dataScope.getAttributeValues(this._variableName);return 1===t.length&&this._value.indexOf(t[0])>=0}return this._value.indexOf(e[this._variableName])>=0}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value.indexOf(t)>=0}return!1}}class h extends n{constructor(e,t,i){super(e,t,i)}testElement(e){if("attribute"==this._variableType){if(!e.dataScope)return!1;return e.dataScope.getAttrVal(this._variableName)==this._value}return e[this._variableName]==this._value}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value===t}return!1}equals(e){return this.type===e.type&&this.variableName===e.variableName&&this.value===e.value}}function c(e){let t,i="attribute"in e?"attribute":"property",r=e[i];switch(e.type){case a.LIST:t=new l(e.type,i,r);break;case a.INTERVAL:t=new o(e.type,i,r);break;case a.POINT:default:t=new h(e.type,i,r)}return t.value=e.value,t}function d(e,t){for(let i of t)if(!i.testElement(e))return!1;return!0}class u{constructor(e,t,i,r){this._x=e+i/2,this._y=t+r/2,this._width=i,this._height=r}translate(e,t){this._x+=e,this._y+=t}toJSON(){let e={};return e.x=this._x,e.y=this._y,e.width=this._width,e.height=this._height,e}union(e){let t=Math.min(this.left,e.left),i=Math.min(this.top,e.top),r=Math.max(this.right,e.right),s=Math.max(this.bottom,e.bottom);return new u(t,i,r-t,s-i)}clone(){return new u(this.left,this.top,this._width,this._height)}get left(){return this._x-this._width/2}set left(e){this._x=e+this._width/2}get right(){return this._x+this._width/2}set right(e){this._x=e-this._width/2}get top(){return this._y-this._height/2}set top(e){this._y=e+this._height/2}get bottom(){return this._y+this._height/2}set bottom(e){this._y=e-this._height/2}get x(){return this._x}get y(){return this._y}get center(){return this.x}get middle(){return this.y}get width(){return this._width}setWidth(e,t){switch(t){case y.RIGHT:this._x=this.right-e/2;break;case y.CENTER:this._width=2*e;break;default:this._x=this.left+e/2}this._width=e}get height(){return this._height}setHeight(e,t){switch(t){case y.TOP:this._y=this.top+e/2;break;case y.MIDDLE:this._height=2*e;break;default:this._y=this.bottom-e/2}this._height=e}contains(e,t){return this.left<=e&&this.right>=e&&this.top<=t&&this.bottom>=t}overlap(e){return!(this.right<e.left||this.bottom<e.top||this.left>e.right||this.top>e.bottom)}}function _(e){let t=e[0].clone();for(let i=1;i<e.length;i++)t=t.union(e[i]);return t}function p(e){return _(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.refBounds?e.refBounds:e.bounds)))}function g(e){return _(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.bounds)))}function f(e){let t=O(e);for(let e of t)e._updateBounds();let i=[];for(let e of t)e.parent&&!i.includes(e.parent)&&i.push(e.parent);for(let e of i)f(e)}const y=Object.freeze({TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",CENTER:"center",MIDDLE:"middle"});function m(e){return e.id+"-bg"}function b(e){return e.id+"-path"}function x(e){switch(e){case y.TOP:return"text-before-edge";case y.BOTTOM:return"auto";case y.LEFT:return"start";case y.RIGHT:return"end";case y.CENTER:case y.MIDDLE:return"middle";default:return e}}const v=Object.freeze({fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",strokeDash:"stroke-dasharray",opacity:"opacity",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",visibility:"visibility",cursor:"cursor"});class w{constructor(e){if(this._dataScope=void 0,this._type="type"in e?e.type:Dt.Mark,this._id=e.id?e.id:this._type+"_"+Gt(),this._classId=void 0,this._bounds=void 0,this._rotate=void 0,this._refBounds=void 0,this._dirty=!0,this._clipMask=void 0,this._cursor=void 0,this._styles={},void 0!==e)for(let t in v)t in e&&(this.styles[t]=e[t])}get scene(){return D(this)}set strokeColor(e){this.styles.strokeColor=e,this._dirty=!0}get strokeColor(){return this.styles.strokeColor}set strokeWidth(e){this.styles.strokeWidth=e,this._dirty=!0}get strokeWidth(){return this.styles.strokeWidth}set strokeDash(e){this.styles.strokeDash=e,this._dirty=!0}get strokeDash(){return this.styles.strokeDash}set fillColor(e){this.styles.fillColor=e,this._dirty=!0}get fillColor(){return this.styles.fillColor}get rotation(){return this._rotate}get cursor(){return this._cursor}get id(){return this._id}set id(e){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=e,this.getScene()._itemMap[e]=this):this._id=e}get classId(){return this._classId?this._classId:this._id}set classId(e){this._classId=e}get type(){return this._type}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this._refBounds?this._refBounds:this.bounds}contains(e,t){if(!this.bounds)return!1;if(!this.bounds.contains(e,t))return!1;switch(this.type){case Dt.Rect:case Dt.SimpleText:return!0;case Dt.Circle:return Math.sqrt(Math.pow(e-this.x,2)+Math.pow(t-this.y,2))<=this.radius+this.strokeWidth;case Dt.Path:{let i=s.getContext(),r=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(r),this.closed?i.isPointInPath(r,e,t):i.isPointInStroke(r,e,t)}case Dt.Line:{let i=s.getContext(),r=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(r),i.isPointInStroke(r,e,t)}default:{let i=s.getContext(),r=new Path2D(this.getSVGPathData());return i.isPointInPath(r,e,t)}}}set dataScope(e){this._dataScope=e}get dataScope(){return this._dataScope}get styles(){return this._styles}set styles(e){this._styles=e,this._dirty=!0}set visibility(e){this.styles.visibility=e,this._dirty=!0}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(e){this.styles.opacity=e,this._dirty=!0}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone())}createClipMask(){let e=this._bounds;this._clipMask=new u(e.left,e.top,e.width,e.height)}get clipMask(){return this._clipMask}}function E(e){return e instanceof w&&e.type!==Dt.Gridlines}const A=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",SimpleText:"text",RichText:"richText",Polygon:"polygon",BezierCurve:"bezierCurve"});function C(e,t,i){const r=document.getElementById(e),s=r.createSVGPoint();s.x=t,s.y=i;const n=s.matrixTransform(r.getScreenCTM().inverse());return[n.x,n.y]}function T(e,t,i,r){return Math.sqrt(Math.pow(e-i,2)+Math.pow(t-r,2))}function R(e,t,i,r,s){const n=s*Math.PI/180,a=e-i,o=t-r;return{x:a*Math.cos(n)-o*Math.sin(n)+i,y:a*Math.sin(n)+o*Math.cos(n)+r}}const k={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}},S={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var e=this.getCanvas();return e?e.getContext("2d"):null}};function O(e,t){let i=D(e);if("vertex"===e.type||"segment"===e.type)return function(e,t){let i=D(e),r=t||i;if("vertex"===e.type){return I(e,L(r,[{property:"classId",value:e.parent.classId}]))}if("segment"===e.type){return N(e,L(r,[{property:"classId",value:e.parent.classId}]))}return e.classId?L(r,[{property:"classId",value:e.classId}]):[e]}(e,t);if(!e.classId)return[e];if(e.classId&&i._peerIndex.has(e.classId)){let r=i._peerIndex.get(e.classId);return t?r.filter((e=>function(e,t){let i=e.parent;for(;i;){if(i===t)return!0;i=i.parent}return!1}(e,t))):r}return[e]}function I(e,t){if(!e.classId){if(e.dataScope){let i=e.parent;if(!i)throw new Error("vertex has no parent mark");let r=[];if(i.type===Dt.Area){let s=i.vertices.indexOf(e)<i.vertices.length/2;for(let e of t){let t=s?e.vertices.slice(0,e.vertices.length/2):e.vertices.slice(e.vertices.length/2);r=r.concat(t.filter((e=>e.dataScope)))}}else for(let e of t)r=r.concat(e.vertices.filter((e=>e.dataScope)));return r}{let i=e.parent;if(!i)throw new Error("vertex has no parent mark");let r=i.vertices.indexOf(e),s=[];for(let e of t)s.push(e.vertices[r]);return s}}}function N(e,t){if(e.dataScope){if(!e.parent)throw new Error("segment has no parent mark");let i=[];for(let e of t)i=i.concat(e.segments);return i}{let i=e.parent;if(!i)throw new Error("segment has no parent mark");let r=i.segments.indexOf(e),s=[];for(let e of t)s.push(e.segments[r]);return s}}function L(e,t){let i=[];return M(e,t.map((e=>c(e))),i),i}function V(e,t){let i=e.children.filter((e=>e.type==Dt.Collection));if(0!==i.length)for(let e of i){let i=e;for(;i&&i.dataScope;){if(i.dataScope.hasAttribute(t))return i;i=i.children?i.children[0]:void 0}}}function P(e){return e.type==Dt.Collection?e:e.parent?P(e.parent):void 0}function M(e,t,i){if(e)if(d(e,t)&&i.push(e),e.vertices)for(let r of e.vertices.concat(e.segments))d(r,t)&&i.push(r);else if(e.children&&e.children.length>0)for(let r of e.children)M(r,t,i)}function D(e){let t=e;for(;t;){if(t.type==Dt.Scene)return t;t=t.parent}}function B(e){let t=e;for("vertex"!=t.type&&"segment"!=t.type||(t=t.parent);t.parent&&[Dt.Collection,Dt.Glyph].includes(t.parent.type);)t=t.parent;return t}function G(e,t,i,r){let s=L(e,r);for(let e of s)if(F(e,t,i))return e}function F(e,t,i){switch(e.type){case Dt.Path:case Dt.Arc:case Dt.BezierCurve:case Dt.Line:{let r=s.getContext(),n=new Path2D(e.getSVGPathData());return r.lineWidth=Math.max(e.strokeWidth,2.5),r.stroke(n),e.closed?r.isPointInPath(n,t,i):r.isPointInStroke(n,t,i)}case Dt.Circle:{let r=e.x,s=e.y;if(e.rotation){let t=R(r,s,e.rotation[1],e.rotation[2],e.rotation[0]);r=t.x,s=t.y}return Math.sqrt(Math.pow(t-r,2)+Math.pow(i-s,2))<=e.radius+e.strokeWidth}default:return e.bounds.contains(t,i)}}function z(e,t){let i=[];if(H(e,i),t){let e={};for(let t of i)e[t.classId]=t;return Object.values(e)}return i}function H(e,t){if(E(e))t.push(e);else if(e.children&&!Object.values(Bt).includes(e.type))for(let i of e.children)H(i,t)}function j(e,t){if(e){if(t(e),e.vertices)for(let i of e.vertices)t(i);if(e.segments)for(let i of e.segments)t(i);if(e.children&&e.children.length>0)for(let i of e.children)j(i,t)}}class U{constructor(){this._refElements=[]}addRefElement(e){this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}const W=Object.freeze({GRID:"grid",STACK:"stack",PACKING:"packing",FORCE:"force",DIRECTED:"directedgraph",TIDYTREE:"tidytree",TREEMAP:"treemap",STRATA:"strata",CIRCULAR:"circular",CLUSTER:"cluster"});function Y(e,t){return!!(e.startsWith("h")&&[y.LEFT,y.CENTER,y.RIGHT].indexOf(t)>=0)||(!!(e.startsWith("v")&&[y.TOP,y.MIDDLE,y.BOTTOM].indexOf(t)>=0)||(console.warn("Invalid alignment:",t),!1))}class X{constructor(e){this._id=e+"_"+Gt(),this._type=e,this._inputVars=[],this._outputVars=[]}run(){}get id(){return this._id}get type(){return this._type}get inputVars(){return this._inputVars}get outputVars(){return this._outputVars}get outputVar(){return this._outputVars[0]}isIsolated(){return 0==this._inputVars.length&&0==this._outputVars.length}}const q=Object.freeze({CONDUIT:"conduit",ENCODER:"encoder",LAYOUT:"layout",LINK_PLACER:"linkRouter",CONSTRAINT:"constraint",EVAL_BBOX:"evalBBox",EVAL_REFBOUNDS:"evalRefBounds",AFFIXER:"affixer",ALIGNER:"aligner",DATA_EXTRACTOR:"dataExtractor",SCALE_BUILDER:"scaleBuilder",AXIS_PATH_PLACER:"axisPathPlacer",AXIS_TICKS_PLACER:"axisTicksPlacer",AXIS_LABELS_PLACER:"axisLabelsPlacer",AXIS_TITLE_PLACER:"axisTitlePlacer",GRIDLINES_PLACER:"gridlinesPlacer",GRID_LAYOUT:"gridLayout",STACK_LAYOUT:"stackLayout",PACK_LAYOUT:"packLayout",FORCE_LAYOUT:"forceLayout",DIRECTED_LAYOUT:"directedLayout",TIDY_TREE_LAYOUT:"tidyTreeLayout",TREEMAP_LAYOUT:"treemapLayout",STRATA_LAYOUT:"strataLayout",CIRCULAR_LAYOUT:"circularLayout",CLUSTER_LAYOUT:"clusterLayout",BIN_TRANSFORMER:"binTransformer",FILTER_TRANSFORMER:"filterTransformer",KDE_TRANSFORMER:"kdeTransformer",TARGET_EVALUATOR:"targetEvaluator",TARGET_UPDATER:"targetUpdater"});class K{constructor(e){let t=e||{};this._stops=[],this.type=Dt.LinearGradient,this.id=this.type+Gt(),this.x1="x1"in t?t.x1:0,this.x2="x2"in t?t.x2:100,this.y1="y1"in t?t.y1:0,this.y2="y2"in t?t.y2:0}toJSON(){let e={};return e.type=this.type,e.id=this.id,e.x1=this.x1,e.x2=this.x2,e.y1=this.y1,e.y2=this.y2,e.stops=this._stops,e}addStop(e,t,i){this._stops.push({offset:e,color:t,opacity:i})}get stops(){return this._stops}}const Z=Object.freeze({RowFirst:"rowFirst",ColumnFirst:"columnFirst"}),$=Object.freeze({TopLeft:"topLeft",TopRight:"topRight",BottomLeft:"bottomLeft",BottomRight:"bottomRight"}),J={HORIZONTAL:"horizontal",VERTICAL:"vertical",ANGULAR:"angular",RADIAL:"radial"},Q={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"},ee=Object.freeze({CLOCKWISE:"clockwise",ANTI_CLOCKWISE:"anti-clockwise"}),te=Object.freeze({INWARD:"inward",OUTWARD:"outward"});class ie{constructor(e,t,i,r){this.type="vertex",this._id=r,this._x=e,this._y=t,this._dataScope=void 0,this.parent=i,this.shape=void 0,this.width=0,this.height=0,this.radius=0,this.fillColor="#555",this.opacity=1,this.strokeWidth=0,this.strokeColor="#aaa",this._polarAngle=void 0}get dataScope(){return this._dataScope}set dataScope(e){this._dataScope=e}get bounds(){switch(this.shape){case"rect":return new u(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new u(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new u(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}_clone(e){let t=new ie(this.x,this.y,e,this._id);return this._dataScope&&(t._dataScope=this._dataScope.clone()),t.shape=this.shape,t.width=this.width,t.height=this.height,t.radius=this.radius,t.fillColor=this.fillColor,t.opacity=this.opacity,t.strokeWidth=this.strokeWidth,t.strokeColor=this.strokeColor,t}get polarAngle(){return this._polarAngle}get scene(){return this.parent.scene}get x(){return this._x}get y(){return this._y}}ie.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class re{constructor(e,t,i,r){this.type="segment",this._id=r,this.vertex1=e,this.vertex2=t,this.dataScope=void 0,this.parent=i}get id(){return this.parent.id+"_s_"+this._id}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}get scene(){return this.parent.scene}}class se extends w{constructor(e){super(e),this._type="type"in e?e.type:Dt.Path,this.vertices=[],this.vertexCounter=0,this._sortBy={},this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed=!1,this.curveMode="linear",this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1;for(let t of ie.styles)t in e&&(this["_"+t]=e[t]);"vertices"in e&&this._setVertices(e.vertices),this._sourceAnchor="sourceAnchor"in e?e.sourceAnchor:["center","middle"],this._targetAnchor="targetAnchor"in e?e.targetAnchor:["center","middle"],this._sourceOffset="sourceOffset"in e?e.sourceOffset:[0,0],this._targetOffset="targetOffset"in e?e.targetOffset:[0,0],this._strength="strength"in e?e.strength:.85,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}_setVertices(e){let t;this.vertices=[],this.segments=[],this.vertexCounter=0,this.segmentCounter=0;for(let i=0;i<e.length;i++)if(i!=e.length-1||e[i][0]!==e[0][0]||e[i][1]!==e[0][1]||this.type!==Dt.Path){t=new ie(e[i][0],e[i][1],this,this.vertexCounter++);for(let e of ie.styles)if(this[e]){let i=e.replace("vx","");t[i[0].toLowerCase()+i.slice(1)]=this[e]}this.vertices.push(t),i>0&&this.segments.push(new re(this.vertices[i-1],this.vertices[i],this,this.segmentCounter++))}let i=e[0],r=e[e.length-1];(i[0]===r[0]&&i[1]===r[1]||this.type===Dt.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new re(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))),this._dirty=!0}copyPropertiesTo(e){e.attrs=Object.assign({},this.attrs),e.styles=Object.assign({},this.styles);for(let t of ie.styles)this["_"+t]&&(e["_"+t]=this["_"+t]);this._dataScope&&(e._dataScope=this._dataScope.clone()),e.closed=this.closed,e.curveMode=this.curveMode,e.vertices=[],e.segments=[];for(let t of this.vertices)e.vertices.push(t._clone(e));e.segmentCounter=0;for(let t=1;t<e.vertices.length;t++)e.segments.push(new re(e.vertices[t-1],e.vertices[t],e,e.segmentCounter++));e.closed&&e.segments.push(new re(e.vertices[e.vertices.length-1],e.vertices[0],e,e.segmentCounter++)),e._sourceAnchor=this._sourceAnchor.slice(),e._targetAnchor=this._targetAnchor.slice(),e._sourceOffset=this._sourceOffset.slice(),e._targetOffset=this._targetOffset.slice(),e._beta=this._beta}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}get strokeColor(){return this.styles.strokeColor}get strokeWidth(){return this.styles.strokeWidth}get strokeDash(){return this.styles.strokeDash}set strokeDash(e){this.styles.strokeDash=e,this._dirty=!0}resize(e,t,i,r){let s=this.bounds,n=0===s.width?1:s.width,a=0===s.height?1:s.height;if("right"===i)for(let t of this.vertices)t._x=s.right-e/n*(s.right-t.x);else for(let t of this.vertices)t._x=s.left+e/n*(t.x-s.left);if("top"===r)for(let e of this.vertices)e._y=s.top+t/a*(e.y-s.top);else for(let e of this.vertices)e._y=s.bottom-t/a*(s.bottom-e.y);this._updateBounds(),this._dirty=!0}_updateBounds(){let e=[],t=[];if(this._d){const i=this._d.match(/[a-zA-Z][^a-zA-Z]*/g),r=" ";i.forEach((i=>{let s=i.slice(1).trim().split(r).map(Number);for(let[i,r]of s.entries())i%2==0?e.push(r):t.push(r)}))}else e=this.vertices.map((e=>e.x)),t=this.vertices.map((e=>e.y));let i=Math.min(...e),r=Math.min(...t),s=Math.max(...e),n=Math.max(...t),a=s-i,o=n-r;if(this._bounds=new u(i,r,a,o),this.type===Dt.Line||this.type===Dt.Path){let e=this.styles.strokeWidth?this.styles.strokeWidth:1;i===s?this._bounds=new u(i-e/2,r,s-i+e,n-r):r===n&&(this._bounds=new u(i,r-e/2,s-i,n-r+e))}}addVertex(e,t,i){let r=new ie(e,t,this,this.vertexCounter++);this.vertices.splice(i,0,r)}sortVertices(e,t){this.vertices.sort(((t,i)=>t[e]-i[e])),t&&this.vertices.reverse();for(let e=0;e<this.segments.length;e++){let t=this.segments[e];t.vertex1=this.vertices[e],t.vertex2=this.vertices[(e+1)%this.vertices.length]}this._dirty=!0}sortVerticesByData(e,t,i){let r;r=i?(t,r)=>i.indexOf(t.dataScope.getValue(e))-i.indexOf(r.dataScope.getAttrVal(e)):(t,i)=>t.dataScope.getAttrVal(e)<i.dataScope.getAttrVal(e)?-1:1,this.vertices.sort(r),t&&this.vertices.reverse();for(let e=0;e<this.segments.length;e++){let t=this.segments[e];t.vertex1=this.vertices[e],t.vertex2=this.vertices[(e+1)%this.vertices.length]}this._dirty=!0}getSVGPathData(){if(this._d)return this._d;let e=r.path(),t=this._getD3CurveFunction(this.curveMode)(e);t.lineStart();for(let e of this.vertices)t.point(e.x,e.y);return this.closed&&t.point(this.vertices[0].x,this.vertices[0].y),t.lineEnd(),e._}get firstVertex(){return this.vertices[0]}get firstSegment(){return this.segments[0]}get lastVertex(){return this.vertices[this.vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_getD3CurveFunction(e){switch(e){case oe.Natural:return r.curveNatural;case oe.Basis:return r.curveBasis;case oe.BumpX:return r.curveBumpX;case oe.BumpY:return r.curveBumpY;case oe.Linear:return r.curveLinear;case oe.Step:return r.curveStep;case oe.CatmullRom:return r.curveCatmullRom;case oe.Cardinal:return r.curveCardinal;case oe.Bundle:return r.curveBundle.beta(.5);default:return r.curveLinear}}get vxShape(){return this._vxShape}get vxWidth(){return this._vxWidth}get vxHeight(){return this._vxHeight}get vxRadius(){return this._vxRadius}get vxFillColor(){return this._vxFillColor}get vxStrokeColor(){return this._vxStrokeColor}get vxStrokeWidth(){return this._vxStrokeWidth}get vxOpacity(){return this._vxOpacity}get sourceAnchor(){return this._sourceAnchor}get targetAnchor(){return this._targetAnchor}get sourceOffset(){return this._sourceOffset}get targetOffset(){return this._targetOffset}}function ne(e,t){const i=k.getSVG();let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",e.getSVGPathData()),i.appendChild(r);let s=r.getTotalLength();return r.getPointAtLength(s*t)}function ae(e){return e instanceof se&&e.source&&e.target}const oe={Natural:"natural",Basis:"basis",BumpX:"bumpX",BumpY:"bumpY",Bundle:"bundle",Linear:"linear",Step:"step",CatmullRom:"CatmullRom",Cardinal:"cardinal"};function le(e,t,i){const r=e.match(/[a-zA-Z][^a-zA-Z]*/g),s=",";return r.map((e=>{const r=e[0],n=e.slice(1).trim();if("M"===r||"L"===r||"T"===r){const[e,a]=n.split(s).map(Number);return`${r}${e+t} ${a+i}`}if("C"===r){const e=n.split(s).map(Number);return`${r}${e[0]+t} ${e[1]+i} ${e[2]+t} ${e[3]+i} ${e[4]+t} ${e[5]+i}`}if("Q"===r){const e=n.split(s).map(Number);return`${r}${e[0]+t} ${e[1]+i} ${e[2]+t} ${e[3]+i}`}if("A"===r){const e=n.split(s).map(Number);return`${r}${e[0]} ${e[1]} ${e[2]} ${e[3]} ${e[4]} ${e[5]+t} ${e[6]+i}`}return"Z"===r||"z"===r?r:e})).join(" ")}class he extends se{constructor(e){super(e),this._type=Dt.Arc,this.closed=!0,this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._innerRadius="innerRadius"in e?e.innerRadius:100,this._outerRadius="outerRadius"in e?e.outerRadius:200,this._thickness="thickness"in e?e.thickness:this._outerRadius-this._innerRadius,this._startAngle="startAngle"in e?e.startAngle:0,this._endAngle="endAngle"in e?e.endAngle:90,this._sr=ce(this._startAngle),this._er=ce(this._endAngle),this._direction="direction"in e?e.direction:ee.ANTI_CLOCKWISE;let t=this._x+this._innerRadius*Math.cos(this._sr),i=this._y-this._innerRadius*Math.sin(this._sr),r=this._x+this._innerRadius*Math.cos(this._er),s=this._y-this._innerRadius*Math.sin(this._er),n=this._x+this._outerRadius*Math.cos(this._sr),a=this._y-this._outerRadius*Math.sin(this._sr),o=this._x+this._outerRadius*Math.cos(this._er),l=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[t,i],[n,a],[o,l],[r,s]])}get type(){return 0===this._innerRadius?Dt.Pie:Dt.Arc}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}get direction(){return this._direction}get x(){return this._x}get y(){return this._y}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}setAngles(e,t){this._startAngle=e,this._endAngle=t,this._sr=ce(this._startAngle),this._er=ce(this._endAngle),this.vertices[0]._x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0]._y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1]._x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1]._y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2]._x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2]._y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3]._x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3]._y=this._y-this._innerRadius*Math.sin(this._er),this._dirty=!0}_updateBounds(){let e=this.vertices.map((e=>e.x)),t=this.vertices.map((e=>e.y)),i=Math.min(...e),r=Math.min(...t),s=Math.max(...e)-i,n=Math.max(...t)-r;this._bounds=new u(i,r,s,n)}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._innerRadius=this._innerRadius,e._outerRadius=this._outerRadius,e._startAngle=this._startAngle,e._endAngle=this._endAngle,e._thickness=this._thickness,e._direction=this._direction,e._sr=this._sr,e._er=this._er}getSVGPathData(){let e=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,t=e>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,e,t,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,e,t,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}}function ce(e){return e*Math.PI/180}function de(e){return 180*e/Math.PI}function ue(e){return(e%360+360)%360}function _e(e,t,i,r){let s=e-i,n=r-t;return Math.atan2(n,s)*(180/Math.PI)}class pe{constructor(e){this._attr2value={},this._dt=e,this._tuples=this._dt.data}isFullTable(){return 0===Object.keys(this._attr2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get attributes(){return Object.keys(this._attr2value)}get dataTable(){return this._dt}get filters(){return this._attr2value}merge(e){let t=new pe(this._dt);for(let e in this._attr2value)t=t.cross(e,this._attr2value[e]);for(let i in e._attr2value)t=t.cross(i,e._attr2value[i]);return t}cross(e,t){if(e in this._attr2value&&this._attr2value[e]!==t)return console.warn("Conflict in attribute values when merging dataScope:",e,this._attr2value[e],t),this;let i=this.clone();return i._attr2value[e]=t,i._updateTuples(e,t),i}derive(e){let t=Object.assign({},this._attr2value);for(let i in e)t[i]=e[i];let i=new pe(this._dt);for(let e in t)i._attr2value[e]=t[e],i._updateTuples(e,t[e]);return i}clone(){let e=new pe(this._dt);return e._attr2value=Object.assign({},this._attr2value),e._tuples=this._tuples.map((e=>e)),e}getAttrVal(e){let t=this.getAttributeValues(e);return t.length,t[0]}getAttributeValues(e){let t=this._tuples.map((t=>t[e]));return t=[...new Set(t)],t}getUniqueAttributeValues(e){let t=this._tuples.map((t=>t[e]));return[...new Set(t)]}hasAttribute(e){return e in this._attr2value}getAttributeType(e){return this._dt.getAttributeType(e)}aggregateNumericalAttribute(e,t){let i=this._tuples.map((t=>t[e]));switch(t){case fe.Max:return Math.max(...i);case fe.Min:return Math.min(...i);case fe.Avg:case fe.Mean:return r.mean(i);case fe.Median:return r.median(i);case fe.Count:return i.length;case fe.Percentile25:return r.quantile(i,.25);case fe.Percentile75:return r.quantile(i,.75);case fe.Sum:default:return r.sum(i)}}_updateTuples(e,t){this._tuples=this._tuples.filter((i=>i[e]==t))}get tuples(){return this._tuples}}function ge(e){return"vertex"==e.type||"segment"==e.type?e.dataScope?e.dataScope:e.parent.dataScope:e.dataScope}const fe={Max:"max",Min:"min",Avg:"avg",Median:"median",Sum:"sum",Count:"count",Mean:"mean",Percentile25:"percentile 25",Percentile75:"percentile 75"};class ye{constructor(e,t){this._id=Dt.TreeData+Gt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._data=e,this._nodeList=[],this._linkList=[],this._nodeHash={},this._traverse(e,this._nodeList,this._linkList),this._nodeTable=new Ft(this._nodeList,"nodes"),this._linkTable=new Ft(this._linkList,"links"),this._nodeTable.tree=this,this._linkTable.tree=this}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}_traverse(e,t,i,r=0){let s={};we in e||(e[we]="n"+t.length),t.push(s),e._depth=r;for(let n in e)if("children"==n&&e[n]&&e[n].length>0)for(let s of e[n]){let n=this._traverse(s,t,i,r+1);i.push({parent:e[we],child:n})}else s[n]=e[n];return this._nodeHash[s[we]]=s,s[we]}getNodeDataScope(e){return new pe(this._nodeTable).cross(Ht,e[Ht])}getNode(e){return this._nodeHash[e]}getRoot(){return this._nodeTable.data[0]}getChildren(e){let t=e[we],i=[],r=this._linkTable.data,s=this._nodeTable.data;for(let e in r)if(r[e].parent==t){let t=r[e].child,n=s.findIndex((e=>e[we]==t));i.push(s[n])}return i}getParent(e){let t=e[we],i=this._linkTable.data,r=this._nodeTable.data;for(let e in i)if(i[e].child==t){let t=i[e].parent,s=r.findIndex((e=>e[we]==t));return r[s]}}}function me(e){return e.dataScope._dt.tree}class be{constructor(e,t){this._id=Dt.NetworkData+Gt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._nodeTable=new Ft(e.nodes,this._id+"_nodes"),this._linkTable=new Ft(e.links,this._id+"_links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._rawNodes=e.nodes,this._rawLinks=e.links,this._nodeHash={};for(let t of e.nodes)this._nodeHash[t[we]]=t}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodeList(){return this._rawNodes}get linkList(){return this._rawLinks}getNode(e){return this._nodeHash[e]}getLinks(e){let t=e[we],i=this._rawLinks,r=[];for(let e in i)i[e].target!==t&&i[e].source!==t||r.push(i[e]);return r}buildNodeHierarchy(e){let t={};return t[we]="root",ve(t,this._rawNodes,e),new ye(t,this.url)}}function xe(e){return e.dataScope._dt.graph}function ve(e,t,i){if(0===t.length||0===i.length)return;"children"in e||(e.children=[]);let r={};for(let e of t){let t=e[i[0]];t in r||(r[t]=[]),r[t].push(e)}if(1===i.length)for(let t in r){let i={children:r[t]};i[we]=t,e.children.push(i)}else for(let t in r){let s={};s[we]=t,e.children.push(s),ve(s,r[t],i.slice(1))}}const we="id";function Ee(e,t){if(t.hasAttribute(e))return!0;if(t.tree&&t.tree.nodeTable.hasAttribute(e.split(".")[1]))return!0;throw new Error(["Attribute",e,"does not exist in the table",t.name].join(" "))}const Ae=Object.freeze({Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"});function Ce(e){var t=Object.values(Ae);for(let i=0;i<e.length;i++){let r=e[i];if(null!=r){for(let e=0;e<t.length;e++)Te[t[e]](r)||(t.splice(e,1),e-=1);if(1==t.length)return t[0]}}return t[0]}const Te={boolean:function(e){return"true"===e||"false"===e||!0===e||!1===e||"[object Boolean]"==toString.call(e)},integer:function(e){return Te.number(e)&&(e=+e)==~~e},number:function(e){return!isNaN(+e)&&"[object Date]"!=toString.call(e)},date:function(e){let t=new Date(e);return null!=t&&!isNaN(t)},string:function(e){return!0}};function Re(e,t){let i={};switch(t){case Ae.Boolean:i.trueCount=e.filter((e=>e)).length,i.falseCount=e.filter((e=>!e)).length;break;case Ae.Date:i.min=r.min(e),i.max=r.max(e),i.extent=[i.min,i.max],i.unique=[...new Set(e)];break;case Ae.String:i.unique=[...new Set(e)];break;default:i.min=r.min(e),i.max=r.max(e),i.extent=[i.min,i.max],i.mean=r.mean(e),i.median=r.median(e),i.unique=[...new Set(e)]}return i}function ke(e,t,i,r,s){let n=s.getAttributeType(i);if(n!=Ae.String&&n!=Ae.Date&&n!=Ae.Number&&n!=Ae.Integer)throw new Error("Densify only works on a string or date attribute: "+i+" is "+n);if(!function(e){if([Dt.Line,Dt.Circle,Dt.Rect,Dt.Area].indexOf(e.type)<0)return!1;if(e.dataScope){let t=O(e,e.scene);for(let e of t)if(e.dataScope.numTuples>1)return!0;return!1}return!0}(t))throw new Error("The "+t.type+" is not dividable");switch(t.type){case Dt.Line:return function(e,t,i){let r,s,n=O(e);for(let a of n){let n=a.dataScope?a.dataScope:new pe(i),o=i.getUniqueAttributeValues(t).map((e=>n.cross(t,e)));o=o.filter((e=>!e.isEmpty())),1===o.length&&o.push(o[0].clone());let l=Object.assign({},a.styles);for(let e of ie.styles)a[e]&&(l[e]=a[e]);let h=a.vertices[0].x,c=a.vertices[0].y,d=[],u=a.vertices[1].x-h,_=a.vertices[1].y-c;for(let e=0;e<o.length;e++)d.push([h+e*u/(o.length-1),c+e*_/(o.length-1)]);l.vertices=d,l.type="path";let p=Nt(l);s||(s=p.id),p._classId=s,p.dataScope=n,p._updateBounds(),p._refBounds=p.bounds.clone();let g=a.parent;g.addChild(p),g.removeChild(a);for(let[e,t]of p.vertices.entries())t.dataScope?t.dataScope=t.dataScope.merge(o[e]):t.dataScope=o[e];a==e&&(r=p)}return r}(t,i,s);case Dt.Circle:return function(e,t,i,r,s){let n,a,o=O(e),l=i.getAttributeType(t);for(let h of o){let o=h.dataScope?h.dataScope:new pe(i),c=i.getUniqueAttributeValues(t).map((e=>o.cross(t,e)));c=l==Ae.Number?c:c.filter((e=>!e.isEmpty()));let d=c.length;if(d<3)throw new Error("INSUFFICIENT_DATA_SCOPES");let u=r||90,_=360/d,p=[],g=[],f="clockwise"==(s||"clockwise")?-1:1;for(let e=0;e<c.length;e++){let t=u+f*e*_;g[e]=t;let i=Se(h.x,h.y,h.radius,g[e]);p.push(i)}let y=Object.assign({},h.styles);y.vertices=p,y.type="polygon",y.x=h.x,y.y=h.y,y.radius=h.radius;let m=Nt(y);a||(a=m.id),m._classId=a,m.dataScope=o;let b=h.parent;b.addChild(m),b.removeChild(h);for(let[e,t]of m.vertices.entries())t._polarAngle=g[e],e>=c.length?t.dataScope=o.merge(c[2*c.length-1-e]):t.dataScope=o.merge(c[e]);h===e&&(n=m)}return n}(t,i,s);case Dt.Rect:return function(e,t,i,r){let s,n,a=O(e),o=t||J.HORIZONTAL;if(o!=J.HORIZONTAL&&o!=J.VERTICAL)throw new Error("Unknown orientation: "+o);for(let t of a){let a=r.getAttributeType(i),l=t.dataScope?t.dataScope:new pe(r),h=r.getUniqueAttributeValues(i).map((e=>l.cross(i,e)));h=a==Ae.Number?h:h.filter((e=>!e.isEmpty())),1===h.length&&h.push(h[0].clone()),a!=Ae.Number&&a!=Ae.Date||h.sort(((e,t)=>e._attr2value[i]>t._attr2value[i]?1:-1));let c=Object.assign({},t.styles),d=t.vertices[0].x,u=t.vertices[0].y,_=t.vertices[t.vertices.length-2].x,p=t.vertices[t.vertices.length-2].y,g=[],f=_-d,m=p-u;for(let e=0;e<h.length;e++)g.push(o==J.VERTICAL?[_,u+e*m/(h.length-1)]:[d+e*f/(h.length-1),u]);for(let e=0;e<h.length;e++)g.push(o==J.VERTICAL?[d,u+(h.length-1-e)*m/(h.length-1)]:[d+(h.length-1-e)*f/(h.length-1),p]);c.vertices=g,c.type="area";let b=Nt(c);n||(n=b.id),b._classId=n,b.dataScope=l,b.orientation=o,b.baseline=o===J.HORIZONTAL?y.BOTTOM:y.LEFT;let x=t.parent;x.addChild(b),x.removeChild(t);for(let[e,t]of b.vertices.entries())e>=h.length?t.dataScope=l.merge(h[2*h.length-1-e]):t.dataScope=l.merge(h[e]);t===e&&(s=b)}return s}(t,r,i,s)}}function Se(e,t,i,r){return[i*Math.cos(ce(r))+e,t-i*Math.sin(ce(r))]}class Oe{constructor(e){this._id="v_"+Gt(),this._type=e,this._incomings=[],this._outgoings=[],this._undirected=[]}get id(){return this._id}get incomingEdges(){return this._incomings}get outgoingEdges(){return this._outgoings}get undirectedEdges(){return this._undirected}get type(){return this._type}get incomingDataflow(){for(let e of this._incomings)if(e.fromNode&&e.fromNode instanceof X)return e.fromNode;return null}isIsolated(){return 0==this._incomings.length&&0==this._outgoings.length}}const Ie=Object.freeze({CHANNEL:"channel",PROPERTY:"property",ATTRIBUTE:"attribute",ITEMS:"items",DATASCOPE:"datascope",ATTR_VALUE:"dataValue",BOUNDS:"bounds",SCALE:"scale",CONDITION_RESULT:"conditionResult",AFFIXATION:"affixation",ALIGNMENT:"alignment",EVT_CTX:"evtContext"});class Ne extends Oe{constructor(e,t,i){super(e),this._channel=t,this._elem=i}get channel(){return this._channel}get element(){return this._elem}}const Le=Object.freeze({X:"x",Y:"y",WIDTH:"width",HEIGHT:"height",RADIUS:"radius",FILLCOLOR:"fillColor",STROKECOLOR:"strokeColor",FILLGRADIENT:"fillGradient",TEXT:"text",ANGLE:"angle",THICKNESS:"thickness",AREA:"area",FONTSIZE:"fontSize",RADIALDISTANCE:"radialDistance",STROKEWIDTH:"strokeWidth",OPACITY:"opacity",VISIBILITY:"visibility",STRENGTH:"strength",SRC:"src"});function Ve(e,t){delete t._encodings[Be(e.element)][e.channel]}function Pe(e,t){let i=e.scene._encodings[Be(e)],r=[];if(i&&(r=r.concat(Object.values(i))),t){let t=e.scene;for(let i in t._encodings){let s=i.split("_");s.pop(),s.join("_")===e.classId&&(r=r.concat(Object.values(t._encodings[i])))}}return r}function Me(e,t,i){for(let r in i._encodings){let s=i._encodings[r];if(s[t]&&s[t].attribute==e)return s[t]}return null}function De(e,t){let i=e.scene._encodings[Be(e)];return i&&i[t]?i[t]:null}function Be(e){if(Array.isArray(e))return e.map((e=>Be(e))).join("_");if(e.classId)return e.classId;if("vertex"==e.type&&e.dataScope){if(e.parent.type===Dt.Area){let t=e.parent.vertices.indexOf(e)<e.parent.vertices.length/2;return e.parent.classId+"_v"+(t?0:e.parent.vertices.length-1)}return e.parent.classId+"_v"}return"vertex"==e.type?e.parent.classId+"_v"+e.parent.vertices.indexOf(e):"segment"==e.type&&e.dataScope?e.parent.classId+"_s":"segment"==e.type?e.parent.classId+"_s"+e.parent.segments.indexOf(e):null}function Ge(e,t){if(0==e.children.length)return[];let i=D(e),r=e.type===Dt.Composite?e.children:[e.children[0]],s=Object.keys(i._encodings),n=[];for(let e of r){let t=e;for(;t;){if(t.classId&&n.indexOf(t.classId)<0&&n.push(t.classId),t.type===Dt.Glyph){t.children.forEach((e=>n.push(e.classId)));break}if(!t.children)break;t=t.children[0]}}let a=[];for(let e of s)for(let r of n)0===e.indexOf(r)&&i._encodings[e][t]&&a.push(i._encodings[e][t]);return a}function Fe(e){let t=De(e,"y"),i=De(e,"height");return t||i&&i.scales[0].domain[0]<0}function ze(e){let t=De(e,"x"),i=De(e,"width");return t||i&&i.scales[0].domain[0]<0}function He(e,t){let i=function(e){let t=e.parent,i=[];for(;t.type!==Dt.Scene;)i.push(t),t=t.parent;return i}(e);for(let e of i)if(De(e,t))return!1;return i.length>=2?i[i.length-2]:e}function je(e,t,i){switch(e.type){case Dt.Rect:case Dt.Path:case Dt.Line:case Dt.Area:!function(e,t,i){for(let r of e.vertices)Ue(r,t,i);e._updateBounds(),e._refBounds&&e._refBounds.translate(t,i)}(e,t,i),0===t&&0===i||(e._dirty=!0);break;case Dt.Group:case Dt.Collection:case Dt.Glyph:!function(e,t,i){for(let r of e.children)je(r,t,i);e._layout&&(void 0!==e._layout._left&&(e._layout._left+=t),void 0!==e._layout._top&&(e._layout._top+=i),e._layout._cellBounds&&e._layout._cellBounds.forEach((e=>e.translate(t,i))));e._updateBounds(),e._refBounds&&e._refBounds.translate(t,i)}(e,t,i);break;case"segment":!function(e,t,i){Ue(e.vertex1,t,i),Ue(e.vertex2,t,i)}(e,t,i),0===t&&0===i||(e.parent._dirty=!0);break;case"vertex":Ue(e,t,i),0===t&&0===i||(e.parent._dirty=!0);break;default:!function(e,t,i){e._x+=t,e._y+=i,e._updateBounds(),e._refBounds&&e._refBounds.translate(t,i)}(e,t,i),0===t&&0===i||(e._dirty=!0)}}function Ue(e,t,i){e._x+=t,e._y+=i}function We(e,t,i){switch(t){case"x":Xe(e,i);break;case"y":qe(e,i);break;case"width":!function(e,t){e.resize(t,e.height)}(e,i);break;case"height":!function(e,t){e.resize(e.width,t)}(e,i);break;case"radius":e.radius=i;break;case"strength":e._strength=i;break;case"area":e.type===Dt.Circle?e.radius=Math.sqrt(i/Math.PI):e.type===Dt.Rect&&e.resize(Math.sqrt(i),Math.sqrt(i)),e._updateBounds();break;case"text":e._text=i;break;case"curveMode":e.curveMode=i;break;case"baseline":e.baseline=i;break;case"angle":[Dt.Arc,Dt.Pie].includes(e.type)&&function(e,t){e._endAngle=ue(e._startAngle+t),e._sr=ce(e._startAngle),e._er=ce(e._endAngle),e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,i);break;case"startAngle":!function(e,t){let i=e.angle;e._startAngle=t,e._endAngle=ue(e._startAngle+i),e._sr=ce(e._startAngle),e._er=ce(e._endAngle),e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,i);break;case"thickness":!function(e,t){Ye(e,e._innerRadius+t)}(e,i);break;case"innerRadius":!function(e,t){e._innerRadius=t,e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,i);break;case"outerRadius":Ye(e,i);break;case"radialDistance":{let t=Se(e.parent.x,e.parent.y,i,e.polarAngle);Xe(e,t[0]),qe(e,t[1]);break}case"visibility":e.visibility=i;break;case"src":e.src=i;break;default:if("vertex"===e.type)e[t]=i;else if(e instanceof vt)for(let r of e.children)We(r,t,i);else e.styles[t]=i}"vertex"===e.type?e.parent._dirty=!0:e._dirty=!0}function Ye(e,t){e._outerRadius=t,e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er)}function Xe(e,t){"vertex"==e.type?e._x=t:je(e,t-e.x,0)}function qe(e,t){"vertex"==e.type?e._y=t:je(e,0,t-e.y)}class Ke extends se{constructor(e){super(e)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}resize(e,t,i,r){e!==this.width&&("right"===i?(this.vertices[1]._x=this.refBounds.right,this.vertices[2]._x=this.refBounds.right,this.vertices[0]._x=this.vertices[1]._x-e,this.vertices[3]._x=this.vertices[0]._x):(this.vertices[0]._x=this.refBounds.left,this.vertices[3]._x=this.refBounds.left,this.vertices[1]._x=this.vertices[0]._x+e,this.vertices[2]._x=this.vertices[1]._x)),t!==this.height&&("top"===r?(this.vertices[0]._y=this.refBounds.top,this.vertices[1]._y=this.refBounds.top,this.vertices[3]._y=this.vertices[0]._y+t,this.vertices[2]._y=this.vertices[3]._y):(this.vertices[2]._y=this.refBounds.bottom,this.vertices[3]._y=this.refBounds.bottom,this.vertices[0]._y=this.vertices[3]._y-t,this.vertices[1]._y=this.vertices[0]._y)),this._dirty=!0}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class Ze extends se{constructor(e){super(e),this._type=Dt.Area,this.closed=!0,this._orientation="orientation"in e?e.orientation:void 0,this._baseline="baseline"in e?e.baseline:void 0,e&&"vertices"in e&&this.segments.push(new re(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get topLeftVertex(){return this._orientation===J.HORIZONTAL?this.vertices[0]:this.vertices[this.vertices.length-1]}get bottomLeftVertex(){return this._orientation===J.HORIZONTAL?this.vertices[this.vertices.length-1]:this.vertices[this.vertices.length/2]}get topRightVertex(){return this._orientation===J.HORIZONTAL?this.vertices[this.vertices.length/2-1]:this.vertices[0]}get bottomRightVertex(){return this._orientation===J.HORIZONTAL?this.vertices[this.vertices.length/2]:this.vertices[this.vertices.length/2-1]}get baseline(){return this._baseline}set baseline(e){this._baseline=e,this._dirty=!0}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this._dirty=!0}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(e){super.copyPropertiesTo(e),e._baseline=this._baseline,e._orientation=this._orientation}getSVGPathData(){return super.getSVGPathData()+" z"}}class $e extends Oe{constructor(e,t){super(e),this._encs={},this._encs[t.channel+"_"+Be(t.element)]=t,this._initialized=!1}addLinkedEncoding(e){this._encs[e.channel+"_"+Be(e.element)]=e}getEncoding(e,t){let i=e+"_"+Be(t);return this._encs[i]}get encodings(){return Object.values(this._encs)}get initialized(){return this._initialized}set initialized(e){this._initialized=e}}class Je extends Oe{constructor(e,t,i){super(e),this._result=t,this._condEnc=i}get result(){return this._result}get conditionalEncoding(){return this._condEnc}}class Qe extends X{constructor(e){super(e)}storeValues(e,t){this._storedValues={};let i=O(e);for(let e of i)this._storedValues[e.id]=e[t]}_restoreValues(e){let t=this.outputVar.channel;e.forEach((e=>{e.styles[t]!==this._storedValues[e.id]&&(e._dirty=!0,e.styles[t]=this._storedValues[e.id])}))}run(){super.run();let e=this.inputVars.find((e=>e instanceof $e)),t=this.outputVar,i=O(t.element),r=["x","y","width","height","radius"].includes(t.channel);if(e){let i=e.getEncoding(t.channel,t.element);for(let e of i.scales){let t=i.getElements(e);this._doMapping(t,e,i.attrValues,i),r&&this._updateRefBounds(t,e,i)}}else this._restoreValues(i);let s=this._getUsableCondEncodings();if(s.length>0&&this._doCondEncoding(i,s.map((e=>e.conditionalEncoding))),r){f(["vertex","segment"].includes(t.element.type)?t.element.parent:t.element)}}_updateRefBounds(e,t,i){switch(this.outputVar.channel){case"width":e.forEach((e=>{e._refBounds.setWidth(t.rangeExtent)}));break;case"height":e.forEach((e=>{e._refBounds.setHeight(t.rangeExtent)}));break;case"radius":e.forEach((e=>{e._refBounds.setWidth(2*t.rangeExtent,y.CENTER),e._refBounds.setHeight(2*t.rangeExtent,y.MIDDLE)}));break;case"x":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let r=e.parent._refBounds;e.parent._refBounds=new u(i.flipScale?t.range[1]:t.range[0],r.top,t.rangeExtent,r.height)}));break;case"y":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let r=e.parent._refBounds;e.parent._refBounds=new u(r.left,i.flipScale?t.range[0]:t.range[1],r.width,t.rangeExtent)}))}}_doMapping(e,t,i,r){switch(this.outputVar.channel){case"width":t.domain[0]<0&&e[0]instanceof Ke?function(e,t,i){for(let r=0;r<e.length;r++){let s=e[r],n=s.refBounds.left+t.map(0),a=s.refBounds.left+t.map(i[s.id]);je(s.leftSegment,n-s.leftSegment.x,0),je(s.rightSegment,a-s.rightSegment.x,0)}}(e,t,i):t.domain[0]<0&&e[0]instanceof Ze||(e[0].type===Dt.Area?function(e,t,i){let r=e[0].baseline;if(e[0].orientation===J.VERTICAL)switch(r){case"left":for(let r of e)O(r.topLeftVertex,r).forEach((e=>We(e,"x",r.refBounds.left))),O(r.topRightVertex,r).forEach((e=>We(e,"x",r.refBounds.left+t.map(i[e.id]))));break;case"right":for(let r of e)O(r.topLeftVertex,r).forEach((e=>We(e,"x",r.refBounds.right-t.map(i[e.id])))),O(r.topRightVertex,r).forEach((e=>We(e,"x",r.refBounds.right)));break;case"center":console.log("center");for(let r of e)O(r.topLeftVertex,r).forEach((e=>We(e,"x",r.refBounds.center-t.map(i[e.id])/2))),O(r.topRightVertex,r).forEach((e=>We(e,"x",r.refBounds.center+t.map(i[e.id])/2)))}}(e,t,i):this._doStandardMapping(e,t,i));break;case"height":t.domain[0]<0&&e[0]instanceof Ke?function(e,t,i){for(let r=0;r<e.length;r++){let s=e[r],n=s.refBounds.bottom-t.map(0),a=s.refBounds.bottom-t.map(i[s.id]);je(s.bottomSegment,0,n-s.bottomSegment.y),je(s.topSegment,0,a-s.topSegment.y)}}(e,t,i):t.domain[0]<0&&e[0]instanceof Ze?function(e,t,i){for(let r of e){let e=I(r.topLeftVertex,[r]);for(let s of e)We(s,"y",r.refBounds.bottom-t.map(i[s.id]));I(r.bottomLeftVertex,[r]).forEach((e=>We(e,"y",r.refBounds.bottom-t.map(0))))}}(e,t,i):e[0].type===Dt.Area?function(e,t,i){let r=e[0].baseline;if(e[0].orientation===J.HORIZONTAL)switch(r){case"top":for(let r of e)O(r.bottomLeftVertex,r).forEach((e=>We(e,"y",r.refBounds.top+t.map(i[e.id])))),O(r.topLeftVertex,r).forEach((e=>We(e,"y",r.refBounds.top)));break;case"middle":for(let r of e)O(r.topLeftVertex,r).forEach((e=>We(e,"y",r.refBounds.middle-t.map(i[e.id])/2))),O(r.bottomLeftVertex,r).forEach((e=>We(e,"y",r.refBounds.middle+t.map(i[e.id])/2)));break;default:for(let r of e)O(r.topLeftVertex,r).forEach((e=>We(e,"y",r.refBounds.bottom-t.map(i[e.id])))),O(r.bottomLeftVertex,r).forEach((e=>We(e,"y",r.refBounds.bottom)))}}(e,t,i):this._doStandardMapping(e,t,i);break;case"text":this._doTextMapping(e,i);break;case"fillGradient":!function(e,t,i,r){for(let s of e){let e=s.vertices.map((e=>i[e.id])),n=Math.min(...e),a=Math.max(...e),o="horizontal"===s.orientation?new K({x1:0,y1:100,x2:0,y2:0}):new K({x1:0,y1:0,x2:100,y2:0});if(o.addStop(0,t.map(n),1),r._mapping){let e=Object.keys(r._mapping).map((e=>parseFloat(e))).sort();for(let i of e)i>n&&i<a&&o.addStop(100*(i-n)/(a-n),t.map(i),1)}else"divergingColor"===t.type&&o.addStop(100*-n/(a-n),t.map(0),1);"sequentialColor"===t.type&&o.addStop(100*-n/(a-n),t.map(0),1),o.addStop(100,t.map(a),1),s.fillColor=o}}(e,t,i,r);break;default:this._doStandardMapping(e,t,i)}}_doTextMapping(e,t){let i=this.outputVar.channel;e.forEach((e=>{We(e,i,t[e.id])}))}_doStandardMapping(e,t,i){let r=this.outputVar.channel;e.forEach((e=>{let s=t.map(i[e.id]);We(e,r,s),e instanceof se&&e.firstVertex&&e.firstVertex.shape&&"strokeColor"===r&&e.vertices.forEach((e=>e.fillColor=s))}))}_doCondEncoding(e,t){let i=e[0].scene;for(let r of e){let e=t.map((e=>e.evalResult.getValue(r.id))).every((e=>e||void 0===e)),s=t[0].eventContext;t[0].stylingFunction(e,s,r,i)}}_updateElement(e,t,i,r){let s;"object"==typeof r&&e.triggerElement?"property"in r?s=e.triggerElement[r.property]:"attribute"in r&&(s=e.triggerElement.dataScope.getAttrVal(r.attribute)):s=r,["x","y"].includes(i)&&"offset"in r&&(s+=r.offset),We(t,i,s)}_getUsableCondEncodings(){return this.inputVars.filter((e=>e instanceof Je))}}class et extends Oe{constructor(e,t,i){super(e),this._property=t,this._elem=i}get property(){return this._property}get element(){return this._elem}}function tt(e){return e in it?it[e]:e}const it=Object.freeze({numCols:"layoutParameter",numRows:"layoutParameter",startCorner:"layoutParameter",direction:"layoutParameter"}),rt=Object.freeze({AXIS_ORIENTATION:"axisOrientation",AXIS_PATH_POSITION:"axisPathPosition",AXIS_TICK_SIZE:"axisTickSize",AXIS_TICK_OFFSET:"axisTickOffset",AXIS_TICKS_POSITION:"axisTicksPosition",AXIS_LABELS_POSITION:"axisLabelsPosition",AXIS_TITLE_POSITION:"axisTitlePosition",AXIS_LABEL_OFFSET:"axisLabelOffset",AXIS_LABEL_FORMAT:"axisLabelFormat",AXIS_FONT_SIZE:"axisFontSize",LEGEND_POSITION:"legendPosition",GRIDLINES_POSITION:"gridlinesPosition",INCLUDE_ZERO:"includeZero",FLIP_SCALE:"flipScale",RANGE_START:"rangeStart",RANGE_EXTENT:"rangeExtent",BASE_LINE:"baseline",LAYOUT_PARAMETER:"layoutParameter",CHILDREN_ORDER:"childrenOrder",TRANSFORM:"transform"});function st(e,t){if(t.findVariable(Ie.BOUNDS,[e]))return;let i=t.getVariable(Ie.BOUNDS,e),r=t.createOneWayDependency(q.EVAL_BBOX);switch(t.connect(r,i),e.type){case Dt.Circle:case Dt.Polygon:{let i=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"radius",e),a=t.getVariable(Ie.CHANNEL,"area",e);t.connect(n,r),t.connect(i,r),t.connect(s,r),t.connect(a,r);break}case Dt.Area:case Dt.Line:case Dt.BezierCurve:case Dt.Path:case Dt.Image:{let i=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"width",e),a=t.getVariable(Ie.CHANNEL,"height",e);t.connect(i,r),t.connect(s,r),t.connect(n,r),t.connect(a,r);break}case Dt.Rect:{let i=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"width",e),a=t.getVariable(Ie.CHANNEL,"height",e),o=t.getVariable(Ie.CHANNEL,"area",e);t.connect(i,r),t.connect(s,r),t.connect(n,r),t.connect(a,r),t.connect(o,r);break}case Dt.SimpleText:case Dt.RichText:{let i=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"text",e);t.connect(i,r),t.connect(s,r),t.connect(n,r);break}case Dt.Ring:{let i=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"innerRadius",e),a=t.getVariable(Ie.CHANNEL,"outerRadius",e);t.connect(i,r),t.connect(s,r),t.connect(n,r),t.connect(a,r);break}case Dt.Pie:case Dt.Arc:{let i=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"innerRadius",e),a=t.getVariable(Ie.CHANNEL,"outerRadius",e),o=t.getVariable(Ie.CHANNEL,"startAngle",e),l=t.getVariable(Ie.CHANNEL,"endAngle",e),h=t.getVariable(Ie.CHANNEL,"angle",e),c=t.getVariable(Ie.CHANNEL,"thickness",e);t.connect(i,r),t.connect(s,r),t.connect(n,r),t.connect(a,r),t.connect(o,r),t.connect(l,r),t.connect(h,r),t.connect(c,r);break}}r.run()}function nt(e,t){let i=t.findVariablesByElement(e);for(let e in i){let r=i[e];for(let e of r)t.deleteVariable(e)}}function at(e,t){let i=t.findVariable(Ie.CHANNEL,[e.channel,e.element]);i||console.warn("cannot find encoding to remove from the dep graph");let r=i.incomingDataflow;t.deleteOperator(r)}function ot(e,t){if(e.type===Dt.Axis){let i=t.findVariable(Ie.PROPERTY,[rt.AXIS_PATH_POSITION,e]).incomingDataflow;t.deleteOperator(i),i=t.findVariable(Ie.PROPERTY,[rt.AXIS_TICKS_POSITION,e]).incomingDataflow,t.deleteOperator(i),i=t.findVariable(Ie.PROPERTY,[rt.AXIS_LABELS_POSITION,e]).incomingDataflow,t.deleteOperator(i)}else if(e.type===Dt.Gridlines){let i=t.findVariable(Ie.PROPERTY,[rt.GRIDLINES_POSITION,e]).incomingDataflow;t.deleteOperator(i)}}function lt(e,t){if(t.findVariable(Ie.BOUNDS,[e]))return;let i=t.getVariable(Ie.BOUNDS,e),r=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"width",e),a=t.getVariable(Ie.CHANNEL,"height",e),o=t.createOneWayDependency(q.EVAL_BBOX);t.connect(r,o),t.connect(s,o),t.connect(n,o),t.connect(a,o),t.connect(o,i),o.run()}function ht(e,t){let i=t.getVariable(Ie.BOUNDS,e),r=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getVariable(Ie.CHANNEL,"width",e),a=t.getVariable(Ie.CHANNEL,"height",e),o=t.createOneWayDependency(q.EVAL_BBOX);t.connect(r,o),t.connect(s,o),t.connect(n,o),t.connect(a,o),t.connect(o,i),o.run()}function ct(e,t,i){let r=i.getVariable(Ie.BOUNDS,e),s=i.getVariable(Ie.BOUNDS,t),n=i.getIncomingDataflowOperator(q.EVAL_BBOX,r),a=s.outgoingEdges.find((e=>e.fromNode===s&&e.toNode===n));if(a&&i.disconnect(s,n,a),e.layout){let r=i.getVariable(Ie.CHANNEL,"x",t),s=i.getIncomingDataflowOperator(_t(e.layout.type),r);s&&i.deleteOperator(s)}}function dt(e,t,i){let r=i.getVariable(Ie.BOUNDS,e),s=i.getVariable(Ie.BOUNDS,t),n=i.getIncomingDataflowOperator(q.EVAL_BBOX,r);i.connect(s,n),i.connect(n,r),e.layout&>(e,e.layout,i)}function ut(e,t){let i=t.getVariable(Ie.BOUNDS,e),r=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"y",e),n=t.getIncomingDataflowOperator(q.EVAL_BBOX,i);t.connect(r,n),t.connect(s,n);for(let i of e.children)t.connect(t.getVariable(Ie.BOUNDS,i),n);t.connect(n,i),n.run()}function _t(e){switch(e){case W.GRID:return q.GRID_LAYOUT;case W.STACK:return q.STACK_LAYOUT;case W.PACKING:return q.PACK_LAYOUT;case W.FORCE:return q.FORCE_LAYOUT;case W.DIRECTED:return q.DIRECTED_LAYOUT;case W.TIDYTREE:return q.TIDY_TREE_LAYOUT;case W.TREEMAP:return q.TREEMAP_LAYOUT;case W.STRATA:return q.STRATA_LAYOUT;case W.CIRCULAR:return q.CIRCULAR_LAYOUT;case W.CLUSTER:return q.CLUSTER_LAYOUT}}function pt(e,t,i){let r=i.getVariable(Ie.PROPERTY,rt.CHILDREN_ORDER,e),s=i.getOutgoingDataflowOperator(_t(t.type),r);i.deleteOperator(s)}function gt(e,t,i){let r=t?t.type:"none",s=r===W.TREEMAP?z(e)[0]:e.children[0];if(!s)return;let n=i.getVariable(Ie.CHANNEL,"width",s),a=i.getVariable(Ie.CHANNEL,"height",s),o=i.getVariable(Ie.PROPERTY,rt.CHILDREN_ORDER,e),l=i.getVariable(Ie.CHANNEL,"x",s),h=i.getVariable(Ie.CHANNEL,"y",s),c=i.getVariable(Ie.CHANNEL,"visibility",s),d=i.getVariable(Ie.PROPERTY,rt.LAYOUT_PARAMETER,t),u=i.getOutgoingDataflowOperator(_t(r),o);if(i.connect(n,u),i.connect(a,u),i.connect(o,u),i.connect(d,u),i.connect(c,u),i.connect(u,l),i.connect(u,h),i.disconnectChannelVarFromBBoxOperator(n),i.disconnectChannelVarFromBBoxOperator(a),s.type===Dt.Arc||s.type===Dt.Pie){let e=i.getVariable(Ie.CHANNEL,"angle",s),t=i.getVariable(Ie.CHANNEL,"thickness",s);i.connect(e,u),i.connect(t,u)}else if(s.type===Dt.Circle){let e=i.getVariable(Ie.CHANNEL,"area",s),t=i.getVariable(Ie.CHANNEL,"radius",s);i.connect(e,u),i.connect(t,u),i.disconnectChannelVarFromBBoxOperator(e),i.disconnectChannelVarFromBBoxOperator(t)}else if(s.type===Dt.Rect){let e=i.getVariable(Ie.CHANNEL,"area",s);i.connect(e,u),i.disconnectChannelVarFromBBoxOperator(e)}if(u.run(),s.links&&ft(s,i),s.children&&s.children[0]){let e=i.getVariable(Ie.BOUNDS,s.children[0]),t=i.getVariable(Ie.CHANNEL,"x",s).incomingDataflow;t&&i.connect(e,t),i.disconnectChannelVarFromBBoxOperator(e)}}function ft(e,t){let i=e.links[0],r=t.getVariable(Ie.CHANNEL,"x",e),s=t.getVariable(Ie.CHANNEL,"x",i),n=t.getVariable(Ie.CHANNEL,"strokeWidth",i),a=t.getVariable(Ie.CHANNEL,"strength",i),o=t.createOneWayDependency(q.LINK_PLACER);t.connect(r,o),t.connect(n,o),t.connect(a,o),t.connect(o,s)}function yt(e,t,i){let r=e.attribute,s=e.channel,n=e.element,a=t.createOneWayDependency(q.ENCODER);if(["width","height"].includes(e.channel)&&n.type===Dt.Area){let e=t.getVariable(Ie.PROPERTY,rt.BASE_LINE,n);t.connect(e,a)}if(i){let r=t.getVariable(Ie.ATTR_VALUE,i),o=t.getVariable(Ie.SCALE,i),l=t.getVariable(Ie.CHANNEL,s,n);t.connect(o,a),t.connect(a,l),r.addLinkedEncoding(e),o.addLinkedEncoding(e),r.incomingDataflow.run()}else{let i=t.getVariable(Ie.ATTRIBUTE,r,zt(n)),o=t.getVariable(Ie.PROPERTY,rt.INCLUDE_ZERO,e),l=t.getVariable(Ie.ATTR_VALUE,e),h=t.getVariable(Ie.DATASCOPE,n),c=t.getVariable(Ie.PROPERTY,rt.TRANSFORM,e),d=t.createOneWayDependency(q.DATA_EXTRACTOR);t.connect(i,d),t.connect(o,d),t.connect(h,d),t.connect(c,d),t.connect(d,l),d.run();let u=t.getVariable(Ie.PROPERTY,rt.RANGE_START,e),_=t.getVariable(Ie.PROPERTY,rt.RANGE_EXTENT,e),p=t.getVariable(Ie.PROPERTY,rt.FLIP_SCALE,e),g=t.getVariable(Ie.SCALE,e),f=t.createOneWayDependency(q.SCALE_BUILDER);t.connect(u,f),t.connect(_,f),t.connect(p,f),t.connect(l,f),t.connect(f,g),f.run();let y=t.getVariable(Ie.CHANNEL,s,n);t.connect(g,a),t.connect(a,y),a.run()}}function mt(e,t){let i=t.getVariable(Ie.PROPERTY,rt.AXIS_ORIENTATION,e),r=t.getVariable(Ie.BOUNDS,e.elements[0].parent),s=t.getVariable(Ie.PROPERTY,rt.AXIS_PATH_POSITION,e),n=t.createOneWayDependency(q.AXIS_PATH_PLACER);t.connect(i,n),t.connect(r,n),t.connect(n,s),n.run();let a=t.getVariable(Ie.PROPERTY,rt.AXIS_TICK_OFFSET,e),o=t.getVariable(Ie.PROPERTY,rt.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(q.AXIS_TICKS_PLACER),h=t.getVariable(Ie.PROPERTY,rt.AXIS_TICKS_POSITION,e);t.connect(s,l),t.connect(a,l),t.connect(o,l),t.connect(l,h),l.run();let c=t.getVariable(Ie.PROPERTY,rt.AXIS_LABEL_OFFSET,e),d=t.getVariable(Ie.PROPERTY,rt.AXIS_LABEL_FORMAT,e),u=t.getVariable(Ie.PROPERTY,rt.AXIS_FONT_SIZE,e),_=t.createOneWayDependency(q.AXIS_LABELS_PLACER),p=t.getVariable(Ie.PROPERTY,rt.AXIS_LABELS_POSITION,e);t.connect(s,_),t.connect(c,_),t.connect(d,_),t.connect(u,_),t.connect(_,p),_.run();let g=t.getVariable(Ie.PROPERTY,rt.AXIS_TITLE_POSITION,e),f=t.createOneWayDependency(q.AXIS_TITLE_PLACER);t.connect(s,f),t.connect(f,g),f.run();let y=t.getVariable(Ie.BOUNDS,e),m=t.getIncomingDataflowOperator(q.EVAL_BBOX,y);t.connect(h,m),t.connect(p,m),t.connect(m,y)}function bt(e,t){let i=t.getVariable(Ie.PROPERTY,rt.AXIS_ORIENTATION,e),r=t.getVariable(Ie.BOUNDS,B(e.elements[0])),s=t.getVariable(Ie.PROPERTY,rt.AXIS_PATH_POSITION,e),n=t.createOneWayDependency(q.AXIS_PATH_PLACER);t.connect(i,n),t.connect(r,n),t.connect(n,s),n.run();let a=t.getVariable(Ie.PROPERTY,rt.AXIS_TICK_OFFSET,e),o=t.getVariable(Ie.PROPERTY,rt.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(q.AXIS_TICKS_PLACER),h=t.getVariable(Ie.PROPERTY,rt.AXIS_TICKS_POSITION,e);t.connect(s,l),t.connect(a,l),t.connect(o,l),t.connect(l,h),l.run();let c=t.getVariable(Ie.PROPERTY,rt.AXIS_LABEL_OFFSET,e),d=t.getVariable(Ie.PROPERTY,rt.AXIS_LABEL_FORMAT,e),u=t.getVariable(Ie.PROPERTY,rt.AXIS_FONT_SIZE,e),_=t.createOneWayDependency(q.AXIS_LABELS_PLACER),p=t.getVariable(Ie.PROPERTY,rt.AXIS_LABELS_POSITION,e);t.connect(s,_),t.connect(c,_),t.connect(d,_),t.connect(u,_),t.connect(_,p),_.run();let g=t.getVariable(Ie.PROPERTY,rt.AXIS_TITLE_POSITION,e),f=t.createOneWayDependency(q.AXIS_TITLE_PLACER);t.connect(s,f),t.connect(f,g),f.run();let y=t.getVariable(Ie.BOUNDS,e),m=t.getIncomingDataflowOperator(q.EVAL_BBOX,y);t.connect(h,m),t.connect(p,m),t.connect(m,y)}function xt(e,t){let i=t.getVariable(Ie.BOUNDS,B(e.elements[0])),r=t.getVariable(Ie.PROPERTY,rt.GRIDLINES_POSITION,e),s=t.createOneWayDependency(q.GRIDLINES_PLACER);t.connect(i,s),t.connect(s,r),s.run();let n=t.getVariable(Ie.BOUNDS,e),a=t.getIncomingDataflowOperator(q.EVAL_BBOX,n);t.connect(r,a),t.connect(a,n)}class vt{constructor(){this._id=this.type+Gt(),this._type=Dt.Group,this._dataScope=void 0,this._bounds=void 0,this._layout=void 0,this._children=[],this._sortBy={property:Ht,descending:!1}}get id(){return this._id}get type(){return this._type}contains(e,t){return this.bounds.contains(e,t)}get children(){return this._children}addChild(e){this.children.indexOf(e)>=0||(e.parent&&e.parent.removeChild(e),this.children.push(e),e.parent=this)}addChildAt(e,t){e.parent&&e.parent.removeChild(e),this.children.splice(t,0,e),e.parent=this}removeChild(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=null)}removeChildAt(e){this.children[e].parent=null,this.children.splice(e,1)}removeAll(){for(let e of this.children)e.parent=null;this._children=[]}get dataScope(){return this._dataScope}set dataScope(e){if(this._dataScope=e,void 0===e)for(let t of this.children)t.dataScope=e;else for(let t of this.children)t.dataScope?t.dataScope=t.dataScope.merge(e):t.dataScope=e}getInternalEncodings(e){if(0==this.children.length)return[];let t=this.children[0],i=this.getScene(),r=Object.keys(i.encodings),s=[];for(;t;){if(t.classId&&s.indexOf(t.classId)<0&&s.push(t.classId),t.type===Dt.Glyph){t.children.forEach((e=>s.push(e.classId)));break}if(!t.children)break;t=t.children[0]}let n=[];for(let t of r){let r=t.split("_");for(let a of s)r[0]==a&&i.encodings[t][e]&&n.push(i.encodings[t][e])}return n}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(e){if(this._layout=e,e&&(e.group=this),gt(this,e,this.scene._depGraph),this.children&&this.children.length>0){let e=z(this,!0);for(let t of e)this.scene.onChange(Ie.CHANNEL,"x",t)}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let e=this.children.map((e=>e.refBounds)),t=Math.min(...e.map((e=>e.left))),i=Math.min(...e.map((e=>e.top))),r=Math.max(...e.map((e=>e.right))),s=Math.max(...e.map((e=>e.bottom)));return new u(t,i,r-t,s-i)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){let e=this.children;if(e.length>0){this._bounds=e[0].bounds.clone();for(let t=1;t<e.length;t++)"hidden"!=e[t].visibility&&(this._bounds=this._bounds.union(e[t].bounds))}else this._bounds=new u(0,0,0,0)}set visibility(e){this._visibility="hidden"==e?e:"visible";for(let t of this.children)t.visibility=e}get visibility(){return this._visibility?this._visibility:"visible"}get scene(){return D(this)}get sortBy(){return this._sortBy}}class wt extends vt{constructor(){super(),this._type=Dt.Collection,this._id=this.type+"_"+Gt(),this._classId=this.id,this._childrenOrder=void 0,this._clipMask=void 0}get classId(){return this._classId}contains(e,t){if([Dt.Arc,Dt.Pie,Dt.Polygon,Dt.Area].indexOf(this.firstChild.type)>=0){let i=this.getSVGPathData();if(""!==i){let r=s.getContext(),n=new Path2D(i);return r.lineWidth=Math.max(this.strokeWidth,2.5),r.stroke(n),r.isPointInPath(n,e,t)}}return this._bounds.contains(e,t)}getSVGPathData(){let e="";for(let t of this.children)if(t.getSVGPathData)e+=t.getSVGPathData();else if(t.bounds){let i=t.bounds;e+=["M",i.left,i.top].join(" "),e+=["L",i.right,i.top].join(" "),e+=["L",i.right,i.bottom].join(" "),e+=["L",i.left,i.bottom,"Z"].join(" ")}return e}createClipMask(){let e=p(this._children);this._clipMask=new u(e.left,e.top,e.width,e.height)}get clipMask(){return this._clipMask}}class Et extends vt{constructor(e){if(super(),this._type=Dt.Glyph,this._id=this.type+"_"+Gt(),this._classId=this._id,e)for(let t of e)this.addChild(t)}get classId(){return this._classId}}class At extends se{constructor(e){super(e),this._type=Dt.BezierCurve,this._orientation="orientation"in e?e.orientation:J.HORIZONTAL}get type(){return this._type}get orientation(){return this._orientation}copyPropertiesTo(e){super.copyPropertiesTo(e),e._orientation=this._orientation}getSVGPathData(){if(this._d)return this._d;let e="M ";return e+=this.vertices[0].x+" "+this.vertices[0].y+" ",e+="C "+this.vertices[1].x+" "+this.vertices[1].y+" ",e+=this.vertices[2].x+" "+this.vertices[2].y+" ",e+=this.vertices[3].x+" "+this.vertices[3].y,e}}class Ct extends w{constructor(e){super(e),this._type=Dt.Circle,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._radius="radius"in e?e.radius:100,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}set radius(e){this._radius=e,this._dirty=!0}get area(){return Math.PI*Math.pow(this._radius,2)}_updateBounds(){if(this._rotate){let e=R(this._x,this._y,this._rotate[1],this._rotate[2],this._rotate[0]);this._bounds=new u(e.x-this._radius,e.y-this._radius,2*this._radius,2*this._radius)}else this._bounds=new u(this._x-this._radius,this._y-this._radius,2*this._radius,2*this._radius)}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._radius=this._radius}getSVGPathData(){return["M",this._x,this._y,"m",-this._radius,", 0 a",this._radius,",",this._radius,"0 1,0",2*this._radius,",0 a",this._radius,",",this._radius,"0 1,0",-2*this._radius,",0"].join(" ")}}class Tt extends w{constructor(e){super(e),this._type=Dt.Image,this._src=e.src,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._width="width"in e?e.width:100,this._height="height"in e?e.height:100}get src(){return this._src}set src(e){this._src=e,this._dirty=!0}get width(){return this._width}set width(e){this._width=e,this._updateBounds(),this._dirty=!0}get height(){return this._height}set height(e){this._height=e,this._updateBounds(),this._dirty=!0}resize(e,t){this._width=e,this._height=t,this._dirty=!0,this._updateBounds()}get x(){return this._x}set x(e){this._x=e,this._dirty=!0,this._updateBounds()}get y(){return this._y}set y(e){this._y=e,this._dirty=!0,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new u(this._x,this._y,this._width,this._height)}copyPropertiesTo(e){e.attrs=Object.assign({},this.attrs),e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e.x=this._x,e.y=this._y,e.width=this._width,e.height=this._height,e.src=this._src}}class Rt extends se{constructor(e){super(e)}get x1(){return this.vertices[0].x}get y1(){return this.vertices[0].y}get x2(){return this.vertices[1].x}get y2(){return this.vertices[1].y}get x(){return(this.vertices[0].x+this.vertices[1].x)/2}get y(){return(this.vertices[0].y+this.vertices[1].y)/2}set x(e){let t=e-this.x;this.vertices[0]._x+=t,this.vertices[1]._x+=t,this._dirty=!0}set y(e){let t=e-this.y;this.vertices[0]._y+=t,this.vertices[1]._y+=t,this._dirty=!0}set x1(e){this.vertices[0]._x=e,this._dirty=!0}set x2(e){this.vertices[1]._x=e,this._dirty=!0}set y1(e){this.vertices[0]._y=e,this._dirty=!0}set y2(e){this.vertices[1]._y=e,this._dirty=!0}}class kt extends w{constructor(e){super(e),this._type=Dt.SimpleText,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._text="text"in e?e.text:"",this._anchor="anchor"in e?e.anchor:[y.CENTER,y.MIDDLE],this._textPath=void 0,this._textPathOffset="50%","fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in e&&(this._backgroundColor=e.backgroundColor),"borderWidth"in e&&(this._borderWidth=e.borderWidth),"borderColor"in e&&(this._borderColor=e.borderColor),this._rotate="rotate"in e?e.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let e,t,i=function(e,t,i){let r=S.getContext();r.font=t;let s=r.measureText(e);return s.fontBoundingBoxAscent?{width:s.width,height:s.fontBoundingBoxAscent+s.fontBoundingBoxDescent}:s.actualBoundingBoxAscent?{width:s.width,height:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent}:{width:s.width,height:i}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),r=i.width,s=i.height;switch(this._anchor[0]){case y.LEFT:e=this._x;break;case y.RIGHT:e=this._x-r;break;case y.CENTER:e=this._x-r/2;break;default:e=this._x}switch(this._anchor[1]){case y.TOP:t=this._y;break;case y.BOTTOM:t=this._y-s;break;case y.MIDDLE:default:t=this._y-s/2}if(this._rotate&&3===this._rotate.length){let i=[{x:e,y:t},{x:e+r,y:t},{x:e,y:t+s},{x:e+r,y:t+s}].map((e=>R(e.x,e.y,this._rotate[1],this._rotate[2],this._rotate[0]))),n=Math.min(...i.map((e=>e.x))),a=Math.max(...i.map((e=>e.x))),o=Math.min(...i.map((e=>e.y))),l=Math.max(...i.map((e=>e.y)));this._bounds=new u(n,o,a-n,l-o)}else this._bounds=new u(e,t,r,s)}get x(){return this._x}set x(e){this._x=e,this._dirty=!0}get y(){return this._y}set y(e){this._y=e,this._dirty=!0}get text(){return this._text}set text(e){this._text=e,this._dirty=!0}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}get textPath(){return this._textPath}set textPath(e){this._textPath=e,this._dirty=!0}get textPathOffset(){return this._textPathOffset}set textPathOffset(e){this._textPathOffset=e,this._dirty=!0}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e._x=this._x,e._y=this._y,e._text=this._text,e._anchor=[this._anchor[0],this._anchor[1]],e._backgroundColor=this._backgroundColor,e._borderColor=this._borderColor,e._borderStroke=this._borderStroke}}class St extends se{constructor(e){super(e),this._type=Dt.Polygon,this.closed=!0,"x"in e&&(this._x=e.x),"y"in e&&(this._y=e.y),"radius"in e&&(this._radius=e.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}set x(e){this._x=e,this._dirty=!0}set y(e){this._y=e,this._dirty=!0}set radius(e){this._radius=e,this._dirty=!0}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._radius=this._radius}}class Ot extends se{constructor(e){super(e),this._type=Dt.Ring,this.closed=!0,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._innerRadius="innerRadius"in e?e.innerRadius:100,this._outerRadius="outerRadius"in e?e.outerRadius:200}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get x(){return this._x}get y(){return this._y}get thickness(){return this._outerRadius-this._innerRadius}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._innerRadius=this._innerRadius,e._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}class It extends w{constructor(e){super(e),this._type=Dt.RichText,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._text="text"in e?e.text:"",this._width="width"in e?e.width:200,this._anchor="anchor"in e?e.anchor:[y.CENTER,y.MIDDLE],"fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in e&&(this._backgroundColor=e.backgroundColor),"borderWidth"in e&&(this._borderWidth=e.borderWidth),"borderColor"in e&&(this._borderColor=e.borderColor),this._rotate="rotate"in e?e.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let e,t,i=function(e,t,i){let r=S.getContext();r.font=t;let s=r.measureText(e);return s.fontBoundingBoxAscent?{width:s.width,height:s.fontBoundingBoxAscent+s.fontBoundingBoxDescent}:s.actualBoundingBoxAscent?{width:s.width,height:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent}:{width:s.width,height:i}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),r=i.width,s=i.height;switch(this._anchor[0]){case y.LEFT:e=this._x;break;case y.RIGHT:e=this._x-r;break;case y.CENTER:e=this._x-r/2;break;default:e=this._x}switch(this._anchor[1]){case y.TOP:t=this._y;break;case y.BOTTOM:t=this._y-s;break;case y.MIDDLE:default:t=this._y-s/2}if(this._rotate&&3===this._rotate.length){let i=[{x:e,y:t},{x:e+r,y:t},{x:e,y:t+s},{x:e+r,y:t+s}].map((e=>R(e.x,e.y,this._rotate[1],this._rotate[2],this._rotate[0]))),n=Math.min(...i.map((e=>e.x))),a=Math.max(...i.map((e=>e.x))),o=Math.min(...i.map((e=>e.y))),l=Math.max(...i.map((e=>e.y)));this._bounds=new u(n,o,a-n,l-o)}else this._bounds=new u(e,t,r,s)}get x(){return this._x}get y(){return this._y}get text(){return this._text}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}get textPath(){return this._textPath}set textPath(e){this._textPath=e,this._dirty=!0}get textPathOffset(){return this._textPathOffset}set textPathOffset(e){this._textPathOffset=e,this._dirty=!0}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}get width(){return this._width}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e._x=this._x,e._y=this._y,e._text=this._text,e._anchor=[this._anchor[0],this._anchor[1]],e._backgroundColor=this._backgroundColor,e._borderColor=this._borderColor,e._borderStroke=this._borderStroke}}function Nt(e){let t=null;switch(e.type){case Dt.Circle:t=new Ct(e);break;case Dt.Line:var i="x1"in e?e.x1:0,r="y1"in e?e.y1:0,s="x2"in e?e.x2:100,n="y2"in e?e.y2:100;e.vertices=[[i,r],[s,n]],t=new Rt(e);break;case Dt.Rect:var a="top"in e?e.top:0,o="left"in e?e.left:0,l="width"in e?e.width:50,h="height"in e?e.height:30;e.vertices=[[o,a],[o+l,a],[o+l,a+h],[o,a+h]],t=new Ke(e);break;case Dt.SimpleText:t=new kt(e);break;case Dt.RichText:t=new It(e);break;case Dt.Image:t=new Tt(e);break;case Dt.BundledPath:case Dt.Chord:case Dt.Path:t=new se(e);break;case Dt.Area:t=new Ze(e);break;case Dt.Ring:t=new Ot(e);break;case Dt.Arc:t=new he(e);break;case Dt.BezierCurve:"vertices"in e||(e.vertices=[[0,100],[20,120],[80,180],[100,200]]),t=new At(e);break;case Dt.Polygon:t=new St(e)}return t&&t._updateBounds(),t}function Lt(e){let t=new wt;return e.addChild(t),e._itemMap[t.id]=t,t}function Vt(e){return new Et(e)}function Pt(e){switch(e.type){case Dt.Collection:return function(e){let t=Lt(e.scene);for(let i=0;i<e.children.length;i++){let r=e.children[i];t.addChild(Pt(r))}if(t._classId=e.classId,e._layout){let i=e._layout.clone();t._layout=i,i.group=t}return t._updateBounds(),t}(e);case Dt.Glyph:return function(e){let t=new Et;for(let i of e.children)t.addChild(Pt(i));t._classId=e.classId,e._dataScope&&(t.dataScope=e._dataScope.clone());return t}(e);default:return function(e){let t=Nt({type:e.type});e.copyPropertiesTo(t),t._classId=e.classId,t._bounds=e.bounds.clone(),e._refBounds||(e._refBounds=e.bounds.clone());t._refBounds=e._refBounds.clone(),e.dataScope&&(t._dataScope=e.dataScope.clone());if(e.vertices)for(let i=0;i<e.vertices.length;i++)e.vertices[i].dataScope&&(t.vertices[i]._dataScope=e.vertices[i].dataScope.clone());return t}(e)}}const Mt=Object.freeze({Rect:"rect",Circle:"circle",Line:"line",Ring:"ring",Path:"path",Image:"image",SimpleText:"text",RichText:"richText",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord"}),Dt=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Line:"line",Path:"path",Image:"image",SimpleText:"text",RichText:"richText",Collection:"collection",Group:"group",Composite:"composite",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable",Layout:"layout",NetworkData:"networkdata",TreeData:"treedata"}),Bt=Object.freeze({Axis:"axis",Legend:"legend",Gridlines:"gridlines"});function Gt(){return Date.now().toString(36)+"_"+Math.random().toString(36).slice(2)}class Ft{constructor(e,t,i){this._id=Dt.DataTable+Gt(),this.initialize(e,t,i)}initialize(e,t,i){if(this.url=t,this._rawData=JSON.parse(JSON.stringify(e)),this._data=e,this._dateMap=new Map,this._attributes=0===this._data.length?[]:Object.keys(this._data[0]),this._newAttribute=0,i)this._attrTypes=i;else{this._attrTypes={};for(let e of this._attributes)this._attrTypes[e]=Ce(this.data.map((t=>t[e]))),"year"==e.toLowerCase()&&this._attrTypes[e]==Ae.Integer&&(this._attrTypes[e]=Ae.Date)}this._validate(this.data,this._attrTypes),this._attrSummaries={};for(let e of this._attributes)this._attrSummaries[e]=Re(this.data.map((t=>t[e])),this._attrTypes[e]);this._attributes.indexOf(Ht)<0&&this._addAttribute(Ht,Ae.String,this.data.map(((e,t)=>"r"+t)))}clone(){let e=[];for(let t of this._data)e.push(Object.assign({},t));let t=new Ft(e,this.url,Object.assign({},this._attrTypes));return t.sourceDataTable=this,t}get id(){return this._id}get name(){return this.url?function(e){var t=e.indexOf("\\")>=0?e.lastIndexOf("\\"):e.lastIndexOf("/"),i=e.substring(t);0!==i.indexOf("\\")&&0!==i.indexOf("/")||(i=i.substring(1));return i}(this.url):this.id}get data(){return this._data}getEncodableAttributes(e){switch(e){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.numericAttributes.concat(this.nonNumericAttributes);default:return this.numericAttributes}}_addAttribute(e,t,i){this._data.forEach(((t,r)=>t[e]=i[r])),e!==Ht&&this._rawData.forEach(((t,r)=>t[e]=i[r])),this._attrTypes[e]=t,this._attributes.push(e),this._attrSummaries[e]=Re(i,t)}getAttributeType(e){return this._attrTypes[e]}get attributes(){return this._attributes}getAttributeSummary(e){return this._attrSummaries[e]}getAttributeValues(e){return this.data.map((t=>t[e]))}getUniqueAttributeValues(e){return this._attrSummaries[e].unique}orderAttributeValues(e,t){this._attrSummaries[e].unique=t}getRowCount(){return this.data.length}hasAttribute(e){return this._attributes.indexOf(e)>=0}parseAttributeAsDate(e,t){let i=r.timeParse(t);for(let t of this.data){let r=t[e];null==r||null==r?(r="",t[e]=new Date(1899,11,31).getTime()):t[e]=i(r).getTime(),this._dateMap.set(t[e],r)}this._attrTypes[e]=Ae.Date,this._attrSummaries[e]=Re(this.data.map((t=>t[e])),Ae.Date)}getRawValue(e,t){return this.getAttributeType(e)===Ae.Date?this._dateMap.get(t).toString():t}get nonNumericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!=Ae.Number&&this._attrTypes[t]!=Ae.Integer&&t!=Ft.RowID&&e.push(t);return e.sort(((e,t)=>this.getUniqueAttributeValues(e).length-this.getUniqueAttributeValues(t).length)),e}get numericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!==Ae.Number&&this._attrTypes[t]!==Ae.Integer||t==Ft.RowID||e.push(t);return e}getAttributesByType(e){let t=[];for(let i in this._attrTypes)this._attrTypes[i]===e&&i!=Ft.RowID&&t.push(i);return t}summarize(){for(let e of this._attributes)this._attrSummaries[e]=Re(this.data.map((t=>t[e])),this._attrTypes[e])}_validate(e,t){for(let i of e)for(let e in t){let r,s=t[e],n=i[e];if(null==i[e]||null==i[e])switch(s){case Ae.Boolean:r=!1;break;case Ae.Date:r=new Date(1899,11,31).getTime();break;case Ae.String:r="";break;default:r=0}else switch(s){case Ae.Boolean:r=n;break;case Ae.Date:r=Number.isInteger(n)?new Date(n,0).getTime():new Date(n+"").getTime(),this._dateMap.set(r,n);break;case Ae.String:r=n.toString();break;default:r=n}i[e]=r}}}function zt(e){let t=ge(e);if(t)return t.dataTable}const Ht="mascot_rowId";function jt(e,t){return fetch(t,{method:e}).then((e=>e.ok?e.text():(console.log(e.status),Promise.reject({status:e.status,statusText:e.statusText})))).catch((e=>(console.log(e),Promise.reject({status:e.status,statusText:e.statusText}))))}class Ut extends Oe{constructor(e,t){super(e),this._elem=t}get element(){return this._elem}}class Wt extends Oe{constructor(e,t){super(e),this._item=t}get element(){return this._item}}class Yt{constructor(e){this._id=e+"_"+Gt(),this._type=e,this._vars=[],this._edges=[]}get vars(){return this._vars}get edges(){return this._edges}run(){console.log("-",this._type)}}class Xt{constructor(e,t,i=!0){this._id="e_"+Gt(),this._fromNode=e,this._toNode=t,this._isDirected=i}get id(){return this._id}get fromNode(){return this._fromNode}get toNode(){return this._toNode}get isDirected(){return this._isDirected}get operator(){return this._fromNode instanceof X||this._fromNode instanceof Yt?this._fromNode:this._toNode}}class qt extends Oe{constructor(e,t,i){super(e),this._attribute=t,this._dataset=i}get attribute(){return this._attribute}get dataset(){return this._dataset}}class Kt{constructor(e,t){switch(this._id="scale_"+Gt(),this._type=e,t&&(this._args=t),e){case"linear":this._scale=r.scaleLinear();break;case"point":this._scale=r.scalePoint();break;case"ordinal":this._scale=r.scaleOrdinal();break;case"ordinalColor":this._scale=r.scaleOrdinal(r[t.scheme]);break;case"power":this._scale=r.scalePow().exponent(2);break;case"sqrt":this._scale=r.scalePow().exponent(.5);break;case"log":this._scale=r.scaleLog();break;case"identity":case"time":this._scale=r.scaleTime();break;case"sequentialColor":t.scheme?this._scale=r.scaleSequential(r[t.scheme]):this._scale=r.scaleSequential()}}get id(){return this._id}get domain(){return this._scale.domain()}set domain(e){this._scale.domain(e)}get range(){return this._scale.range()}set range(e){this._scale.range(e)}get rangeExtent(){let e=this._scale.range();return Math.abs(e[1]-e[0])}set rangeExtent(e){let t=this._scale.range();t[0]<t[1]?this._scale.range([t[0],t[0]+e]):this._scale.range([t[1]+e,t[1]])}get type(){return this._type}map(e){return this._scale(e)}invert(e,t){let i=Math.min(...this._scale.range()),r=Math.max(...this._scale.range()),s=e;return t||(s=Math.max(i,Math.min(e,r))),"time"===this._type?this._scale.invert(s).getTime():this._scale.invert(s)}}const Zt=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],$t=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class Jt{constructor(){this._map={}}clear(){this._map={}}setValue(e,t){this._map[e]=t}getValue(e){return this._map[e]}}class Qt extends Oe{constructor(e,t){super(e),this._encs=[t],this._valueMap=new Jt}addLinkedEncoding(e){this._encs.push(e)}get encodings(){return this._encs}get attrValues(){return this._valueMap}set attrValues(e){this._valueMap=e}}class ei extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e instanceof Qt)),t=this.outputVar,i=t.encodings,r=i[0],s=r.channel,n=r.attribute,a=e.encodings[0].dataTable.getAttributeType(e.encodings[0].attribute),o=Object.values(e.attrValues);if("angle"===r.channel&&[Dt.Arc,Dt.Pie].indexOf(r.element.type)>=0)for(let t of e.encodings)for(let e of t.scales){let i=t.getElements(e).map((e=>t.attrValues[e.id]));e.domain=r._preferredDomain?r._preferredDomain:t.dataTable.tree?[0,t.dataTable.tree.getRoot()[n]]:this._getDomainForNumbers(i),console.log("domain for",n,e.domain)}else{let t;t=r._preferredDomain?r._preferredDomain:a==Ae.String||"text"===e.encodings[0].channel?this._getDomainForStrings(o):this._getDomainForNumbers(o);for(let i of e.encodings)for(let e of i.scales)e.domain=t.slice()}for(let e=0;e<r.scales.length;e++){let n=r.scales[e],a=r.getElements(n),o=this._buildRange(s,a,r,t);if(o)for(let t of i)t.scales[e].range=o}t.initialized=!0}_getDomainForNumbers(e){let t=this.outputVar.encodings[0],i=[Math.min(...e),Math.max(...e)];if(t.includeZero&&i[0]>0&&(i=[0,Math.max(...e)]),t.mapping)i=Object.keys(t.mapping),i=i.map((e=>parseFloat(e))),i.sort(((e,t)=>e-t));else if("sequentialColor"===t.scales[0].type){if(i[0]<0&&i[1]>0){let e=Math.max(Math.abs(i[0]),Math.abs(i[1]));i=[-e,e]}}else if("angle"===t.channel){i=[0,Object.values(e).reduce(((e,t)=>e+t),0)]}return i}_getDomainForStrings(e){let t,i=this.outputVar,r=i.encodings[0];return t="count"==i.encodings[0].aggregator?[0,Math.max(...e)]:Array.from(new Set(e)),r.mapping&&(t=Object.keys(r.mapping)),t}_buildRange(e,t,i,r){return"x"===e?this._buildXRange(t,i,r):"y"===e?this._buildYRange(t,i,r):["width","height","radius","area","fontSize","radialDistance","strokeWidth"].includes(e)?this._buildSizeRange(t,i,r):e.indexOf("Color")>0||"fillGradient"===e?this._buildColorRange(t,i):"angle"===e?this._buildAngleRange(t,i):"thickness"===e?this._buildThicknessRange(t,i,r):"src"===e?i.scales[0].domain.slice():void 0}_buildThicknessRange(e,t,i){let r=e.map((e=>e.outerRadius-e.innerRadius));return[0,i.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(...r)]}_buildAngleRange(e,t){return[0,360]}_buildColorRange(e,t){if(t.mapping){return t.scales[0].domain.map((e=>t.mapping[e+""]))}if("sequentialColor"===t.scales[0].type){let e=this.outputVar,i=t.scales[0].domain;for(let s of e.encodings)if(!t.colorScheme)for(let e of s.scales){let t=e.domain;e._scale=r.scaleSequential(i[0]<0&&i[1]>0?r.interpolatePuOr:r.interpolateTurbo),e._scale.domain(t)}}if((Zt.indexOf(t.colorScheme)>=0||$t.indexOf(t.colorScheme)>=0)&&"ordinalColor"===t.scales[0].type){let e=this.outputVar,i=t.scales[0].domain;for(let s of e.encodings)for(let e of s.scales){let s=e.domain;e._scale=r.scaleOrdinal(r[t.colorScheme][i.length]),e._scale.domain(s)}}}_buildSizeRange(e,t,i){let r,s;return r=0,s=i.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(...e.map((e=>"radius"===t.channel?e.refBounds.width/2:"strokeWidth"===t.channel?e.strokeWidth:"radialDistance"===t.channel?e.parent.radius:"area"===t.channel?e.type===Dt.Circle?Math.PI*Math.pow(e.radius,2):e.width*e.height:"fontSize"===t.channel?parseFloat(e.fontSize):e.refBounds[t.channel]))),[0,0+s]}_buildXRange(e,t,i){let r,s;switch(t.scales[0].type,e[0].type){case"vertex":case"segment":var n=e[0].parent.refBounds?e[0].parent.refBounds:e[0].parent.bounds;r=i.initialized?t.getRangeStart(e[0]):n.left,s=i.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:n.width;break;default:r=i.initialized?t.getRangeStart(e[0]):t._preferredRangeStart?t._preferredRangeStart:B(e[0]).bounds.left+e[0].bounds.width/2,s=i.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(450,Math.max(...e.map((e=>e.bounds.x)))-Math.min(...e.map((e=>e.bounds.x))))}return t.flipScale?[r+s,r]:[r,r+s]}_buildYRange(e,t,i){let r,s;switch(t.scales[0].type,e[0].type){case"vertex":case"segment":var n=e[0].parent.refBounds?e[0].parent.refBounds:e[0].parent.bounds;r=i.initialized?t.getRangeStart(e[0]):n.top,s=i.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:n.height;break;default:r=i.initialized?t.getRangeStart(e[0]):B(e[0]).bounds.top+e[0].bounds.height/2,s=i.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:450}return t.flipScale?[r,r+s]:[r+s,r]}}class ti extends X{constructor(e){super(e)}run(){super.run()}}class ii extends vt{constructor(e){super(),this._type=Dt.Axis,this._id=e.id?e.id:this._type+Gt(),this._attribute=void 0,this._channel=void 0,this._orientation=void 0,this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._textColor="textColor"in e?e.textColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._tickOffset="tickOffset"in e?e.tickOffset:0,this._tickSize="tickSize"in e?e.tickSize:5,this._tickAnchor=e.tickAnchor,this._tickVisible=!("tickVisible"in e)||e.tickVisible,this._pathVisible=!("pathVisible"in e)||e.pathVisible,this._labelVisible=!("labelVisible"in e)||e.labelVisible,this._labelOffset="labelOffset"in e?e.labelOffset:this._tickSize+this._tickOffset+3,this._labelFormat="labelFormat"in e?e.labelFormat:"",this._titleOffset="titleOffset"in e?e.titleOffset:40,this._rotateYTitle=!("rotateTitle"in e&&!e.rotateTitle),this._showTitle=!("titleVisible"in e)||e.titleVisible,this._labelRotation="labelRotation"in e?e.labelRotation:0,this._ticks=new vt,this._ticks._id=this._id+"_ticks",this.addChild(this._ticks),this._labels=new vt,this._labels._id=this._id+"_labels",this.addChild(this._labels),this._title=new kt({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title._id=this.id+"_title",this.addChild(this._title),this._showTitle||(this._title.visibility="hidden"),this._pathPos=void 0,this._args=e}get id(){return this._id}get pathPos(){return this._pathPos}get attribute(){return this._attribute}get channel(){return this._channel}get orientation(){return this._orientation}get tickSize(){return this._tickSize}get tickOffset(){return this._tickOffset}get tickAnchor(){return this._tickAnchor?this._tickAnchor:"x"===this._channel||"width"===this._channel?"center":"middle"}get labelOffset(){return this._labelOffset}get tickValues(){return this._tickValues}get labelValues(){return this._labelValues}get titleOffset(){return this._titleOffset}get boundsWithoutTitle(){let e=this.children.filter((e=>e.type!==Dt.SimpleText)),t=e[0].bounds.clone();for(let i=1;i<e.length;i++)"hidden"!=e[i].visibility&&(t=t.union(e[i].bounds));return t}}const ri="top",si="bottom",ni="left";function ai(e,t,i,s){let n,a=e.domain,o=e.range;switch(e.type){case"linear":case"log":{let l=Math.abs(o[0]-o[1]);n="width"==t||"x"==t?45:30;let h,c=Math.max(2,Math.floor(l/n));if("width"==t||"height"==t){let r=!!s&&(s.elements[0].parent.layout&&s.elements[0].parent.layout.type==W.STACK);a[1]=e._scale.invert(r?g(i)[t]:p(i)[t])}if("log"===e.type){h=[];let t=e._scale.ticks();for(let e of t){let i=Math.log(e)/Math.log(10)+1e-6;Math.abs(i-Math.floor(i))<c/t.length&&h.push(e)}}else h=r.ticks(a[0],a[1],c);return h}case"point":{n="width"==t||"x"==t?80:30;let i=Math.floor(e.rangeExtent/a.length),r=Math.ceil(n/i);return"x"==t?a.filter(((e,t)=>t%r==0)):a}case"time":{n="width"==t||"x"==t?80:30;let e,i,s=Math.floor((o[1]-o[0])/n),l=Math.ceil((a[1]-a[0])/s)/1e3,h=[1,60,3600,86400,2628003,31536e3],c=[r.timeSeconds,r.timeMinutes,r.timeHours,r.timeDays,r.timeMonths,r.timeYears];for(let t=0;t<h.length-1;t++)if(l>=h[t]&&l<h[t+1])return e=Math.floor(l/h[t]),i=c[t],i(a[0],a[1],e);return l>h[h.length-1]?(e=Math.floor(l/h[h.length-1]),i=c[h.length-1],i(a[0],a[1],e)):[]}default:return[]}}function oi(e,t){t.removeChild(e)}class li extends ii{constructor(e,t,i,r){super(r),this._encoding=e,this._attribute=this._encoding.attribute,this._channel=this._encoding.channel,this._scale=t,this._elems=i,this._flip="flip"in r&&r.flip,this._posArg="x"==this._channel||"width"==this._channel?r.pathY:r.pathX,this._orientation="orientation"in r?r.orientation:"x"===this._channel||"width"==this._channel?si:ni,this._titleText="title"in r?r.title:this._encoding.attribute,this._path="angle"===this._channel?new Ct({strokeColor:this._strokeColor,id:this._id+"_path"}):new se({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(r),e.dataTable.getAttributeType(this._attribute)!==Ae.Date||"labelFormat"in r||(this._labelFormat="%m/%d/%y"),"radialDistance"===this._channel&&"rotation"in r&&(this._rotate=[-r.rotation,this._elems[0].parent.x,this._elems[0].parent.y])}isFlipped(){return this._flip}get elements(){return this._elems}get scale(){return this._scale}get encoding(){return this._encoding}createTicksLabels(e){"tickValues"in e?(this._tickValues=e.tickValues,this._labelValues=e.tickValues):(this._tickValues=ai(this._scale,this._channel,this._elems,this),this._labelValues=this._tickValues),this._ticks.removeAll();for(let e=0;e<this._tickValues.length;e++){let t=new se({strokeColor:this._strokeColor,id:this._id+"_tick"+e});this._tickVisible||(t.visibility="hidden"),this._ticks.addChild(t)}let t;switch(this._labels.removeAll(),this._encoding.dataTable.getAttributeType(this._attribute)){case Ae.Date:t=r.utcFormat(this._labelFormat);break;case Ae.String:t=function(e){return e};break;default:t=r.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let r=new kt({text:t(i),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labelVisible||(r.visibility="hidden"),this._labels.addChild(r)}this._title._text=this._titleText}}class hi extends ii{constructor(e,t,i,r){super(r),this._elems=e,this._attribute=i,this._channel=t,this._posArg="x"==this._channel||"width"==this._channel?r.pathY:r.pathX,this._labelAttribute=r.labelAttribute,this._orientation="orientation"in r?r.orientation:"x"===this._channel||"width"==this._channel?si:ni,this._titleText="title"in r?r.title:this._attribute,this._path="angle"===this._channel?new Ct({strokeColor:this._strokeColor,id:this._id+"_path"}):new se({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(r),this._elems[0].dataScope.dataTable.getAttributeType(this._attribute)!==Ae.Date||"labelFormat"in r||(this._labelFormat="%m/%d/%y")}get elements(){if(this.layout.type===W.CLUSTER){const e=new Map(this._elems.map((e=>[e.dataScope.getAttrVal(we),e])));return this.layout._d3Root.leaves().map((t=>e.get(t.data[we])))}return this._elems}get layout(){return this._elems[0].parent.layout}createTicksLabels(e){"tickValues"in e?(this._tickValues=e.tickValues,this._labelValues=e.tickValues):(this._tickValues=this.elements.map((e=>e.dataScope.getAttrVal(this._labelAttribute?this._labelAttribute:this._attribute))),this._labelValues=this._tickValues),this._ticks.removeAll();for(let e=0;e<this._tickValues.length;e++){let t=new se({strokeColor:this._strokeColor,id:this._id+"_tick"+e});this._tickVisible||(t.visibility="hidden"),this._ticks.addChild(t)}let t;switch(this._labels.removeAll(),this._elems[0].dataScope.dataTable.getAttributeType(this._labelAttribute?this._labelAttribute:this._attribute)){case Ae.Date:t=r.timeFormat(this._labelFormat);break;case Ae.String:t=function(e){return e};break;default:t=r.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let r=new kt({text:t(i),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labels.addChild(r)}this._title._text=this._titleText}}class ci extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e instanceof et&&e.property==rt.AXIS_ORIENTATION)).element;e.createTicksLabels(e._args),e instanceof li?this._runForEncoding(e):e instanceof hi&&this._runForLayout(e),f(e._path)}_runForLayout(e){let t=e.channel,i=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?g(e.elements):p(e.elements),r=[];if("x"===t){let t=e.orientation===ri?i.top-2:i.bottom+2;e._pathPos=e._posArg?e._posArg:t,r.push([i.left,e._pathPos]),r.push([i.right,e._pathPos]),e._path._setVertices(r)}else if("y"===t){let t=e.orientation===ni?i.left-2:i.right+2;e._pathPos=e._posArg?e._posArg:t,r.push([e._pathPos,i.top]),r.push([e._pathPos,i.bottom]),e._path._setVertices(r)}else if("angle"===t){let t=e.elements[0].parent.layout;t.type===W.CLUSTER&&(e._path._x=t.x,e._path._y=t.y,e._path._radius=t.radius)}}_runForEncoding(e){let t=e.channel,i=e.elements,r=i[0].parent.layout&&i[0].parent.layout.type==W.STACK?g(i):p(i),s=[],n=B(i[0]);if(n&&n.clipMask&&(r=n.clipMask),"x"===t){let t,n,a=De(i[0],"y");a?(t=Math.min(...a.getScale(i[0]).range,r.top),n=Math.max(...a.getScale(i[0]).range,r.bottom)):(t=r.top,n=r.bottom);let o=e.orientation===ri?t-2:n+2;e._pathPos=e._posArg?e._posArg:o,s.push([e.scale.range[0],e._pathPos]),s.push([e.scale.range[1],e._pathPos])}else if("width"===t){let t=e.orientation===ri?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,s.push([r.left,e._pathPos]),s.push([r.right,e._pathPos])}else if("radialDistance"===t){let t=e.elements[0].parent,i=t.y;e._pathPos=e._posArg?e._posArg:i,s.push([e.scale.range[0]+t.x,e._pathPos]),s.push([e.scale.range[1]+t.x,e._pathPos])}else if("y"===t){let t,n,a=De(i[0],"x");a?(t=Math.min(...a.getScale(i[0]).range,r.left),n=Math.max(...a.getScale(i[0]).range,r.right)):(t=r.left,n=r.right);let o=e.orientation===ni?t-2:n+2;e._pathPos=e._posArg?e._posArg:o,s.push([e._pathPos,e.scale.range[0]]),s.push([e._pathPos,e.scale.range[1]])}else if("height"===t){let t=e.orientation===ni?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,s.push([e._pathPos,r.bottom]),s.push([e._pathPos,r.top])}e._path._setVertices(s)}}class di extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e instanceof et&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof li?this._runForEncoding(e):e instanceof hi&&this._runForLayout(e);let t=[];if("width"===e.channel||"x"===e.channel){let i=e._ticks.children.map((e=>e.vertices[0].x)),r=[e._path.vertices[0].x,e._path.vertices[1].x];t.push([Math.min(...i.concat(r)),e._path.vertices[0].y]),t.push([Math.max(...i.concat(r)),e._path.vertices[0].y]),e._path._setVertices(t)}else if("height"===e.channel||"y"===e.channel){let i=e._ticks.children.map((e=>e.vertices[0].y)),r=[e._path.vertices[0].y,e._path.vertices[1].y];t.push([e._pathPos,Math.min(...i.concat(r))]),t.push([e._pathPos,Math.max(...i.concat(r))]),e._path._setVertices(t)}for(let t of e._ticks.children)t._updateBounds();f(e._ticks)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==si?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,i=e.orientation==si?e.tickSize:-e.tickSize;for(let[r,s]of e._ticks.children.entries()){let n=e.elements[r].bounds[e.tickAnchor];s._setVertices([[n,t],[n,t+i]])}}else if("y"===t){let t=e.orientation==ni?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,i=e.orientation==ni?-e.tickSize:e.tickSize;for(let[r,s]of e._ticks.children.entries()){let n=e.elements[r].bounds[e.tickAnchor];s._setVertices([[t,n],[t+i,n]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===W.CLUSTER){let i=t._d3Root.leaves();const r=new Map(i.map((e=>[e.data[we],[e.x,e.y]])));for(let[i,s]of e._ticks.children.entries()){let n=e.elements[i].dataScope.getAttrVal(we),a=de(r.get(n)[0])-90;s._setVertices([[t.x+r.get(n)[1]+e.elements[i].bounds.width/2,t.y],[t.x+r.get(n)[1]+e.elements[i].bounds.width/2+e.tickSize,t.y]]),s._rotate=[a,t.x,t.y]}}}}_runForEncoding(e){let t=e.channel,i=p(e.elements);if("x"==t){let t=e.orientation==si?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,i=e.orientation==si?e.tickSize:-e.tickSize;for(let[r,s]of e._ticks.children.entries())s._setVertices([[e.scale.map(e._tickValues[r]),t],[e.scale.map(e._tickValues[r]),t+i]])}else if("width"==t){let t=e.orientation==si?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==si?e.tickSize:-e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Dt.Area&&"right"===e.elements[0].baseline))for(let[s,n]of e._ticks.children.entries())n._setVertices([[i.left+e.scale.rangeExtent-e.scale.map(e._tickValues[s]),t],[i.left+e.scale.rangeExtent-e.scale.map(e._tickValues[s]),t+r]]);else for(let[s,n]of e._ticks.children.entries())n._setVertices([[e.scale.map(e._tickValues[s])+i.left,t],[e.scale.map(e._tickValues[s])+i.left,t+r]])}else if("y"===t){let t=e.orientation==ni?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,i=e.orientation==ni?-e.tickSize:e.tickSize;for(let[r,s]of e._ticks.children.entries())s._setVertices([[t,e.scale.map(e._tickValues[r])],[t+i,e.scale.map(e._tickValues[r])]])}else if("height"===t){let t=e.orientation==ni?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==ni?-e.tickSize:e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Dt.Area&&"top"===e.elements[0].baseline))for(let[s,n]of e._ticks.children.entries())n._setVertices([[t,i.top+e.scale.map(e._tickValues[s])],[t+r,i.top+e.scale.map(e._tickValues[s])]]);else for(let[s,n]of e._ticks.children.entries()){let a=i.bottom-e.scale.map(e._tickValues[s]);n._setVertices([[t,a],[t+r,a]])}}else if("radialDistance"===t){let t=e.orientation==si?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,i=e.orientation==si?e.tickSize:-e.tickSize,r=e.elements[0].parent;for(let[s,n]of e._ticks.children.entries())n._setVertices([[r.x+e.scale.map(e._tickValues[s]),t],[r.x+e.scale.map(e._tickValues[s]),t+i]])}}}class ui extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e instanceof et&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof li?this._runForEncoding(e):e instanceof hi&&this._runForLayout(e);for(let t of e._labels.children)t._updateBounds();f(e._labels)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==si?e.labelOffset:-e.labelOffset,i=e.orientation==si?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM];for(let[r,s]of e._labels.children.entries()){let n=e.elements[r].bounds;s.x=n[e.tickAnchor],s._y=e.pathPos+t,s._anchor=i,e._labelRotation&&(s._rotate=[e._labelRotation,s.x,s.y],s._anchor=[y.RIGHT,y.MIDDLE])}}else if("y"===t){let t=e.orientation==ni?-e.labelOffset:e.labelOffset,i=e.orientation==ni?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE];for(let[r,s]of e._labels.children.entries()){let n=e.elements[r].bounds;s.x=e.pathPos+t,s._y=e.tickAnchor==y.MIDDLE?n.y:n[e.tickAnchor],s._anchor=i,e._labelRotation&&(s._rotate=[e._labelRotation,s.x,s.y],s._anchor=[y.RIGHT,i[1]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===W.CLUSTER){let i=t._d3Root.leaves();const r=new Map(i.map((e=>[e.data[we],[e.x,e.y]])));let s=5;for(let[i,n]of e._labels.children.entries()){let a=e.elements[i].dataScope.getAttrVal(we);if(r.get(a)[0]<Math.PI){let o=de(r.get(a)[0])-90;n._anchor=[y.LEFT,y.MIDDLE],n.x=t.x+r.get(a)[1]+e.elements[i].bounds.width/2+s,n._y=t.y,n._rotate=[o,t.x,t.y]}else{let o=de(r.get(a)[0])+90;n._anchor=[y.RIGHT,y.MIDDLE],n.x=t.x-r.get(a)[1]-e.elements[i].bounds.width/2-s,n._y=t.y,n._rotate=[o,t.x,t.y]}}}}}_runForEncoding(e){let t=e.channel,i=p(e.elements);if("x"==t){let t=e.orientation==si?e.labelOffset:-e.labelOffset,i=e.orientation==si?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM];for(let[r,s]of e._labels.children.entries())s.x=e.scale.map(e.labelValues[r]),s._y=e.pathPos+t,s._anchor=i,e._labelRotation&&(s._rotate=[e._labelRotation,s.x,s.y],s._anchor=[y.RIGHT,i[1]])}else if("width"===t){let t=e.orientation==si?e.labelOffset:-e.labelOffset,r=e.orientation==si?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM],s=!!(e.isFlipped()||e.elements[0].type===Dt.Area&&"right"===e.elements[0].baseline);for(let[n,a]of e._labels.children.entries())a.x=s?i.left+e.scale.rangeExtent-e.scale.map(e.labelValues[n]):e.scale.map(e.labelValues[n])+i.left,a._y=e.pathPos+t,a._anchor=r,e._labelRotation&&(a._rotate=[e._labelRotation,a.x,a.y],a._anchor=[y.RIGHT,r[1]])}else if("y"===t){let t=e.orientation==ni?-e.labelOffset:e.labelOffset,i=e.orientation==ni?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE];for(let[r,s]of e._labels.children.entries())s.x=e.pathPos+t,s._y=e.scale.map(e.labelValues[r]),s._anchor=i,e._labelRotation&&(s._rotate=[e._labelRotation,s.x,s.y],s._anchor=[y.RIGHT,i[1]])}else if("height"===t){let t=e.orientation==ni?-e.labelOffset:e.labelOffset,r=e.orientation==ni?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE],s=e.elements[0].type===Dt.Area&&"top"===e.elements[0].baseline;for(let[n,a]of e._labels.children.entries())a.x=e.pathPos+t,a._y=s?i.top+e.scale.map(e.labelValues[n]):i.bottom-e.scale.map(e.labelValues[n]),a._anchor=r,e._labelRotation&&(a._rotate=[e._labelRotation,a.x,a.y],a._anchor=[y.RIGHT,r[1]])}else if("radialDistance"==t){let t=e.orientation==si?e.labelOffset:-e.labelOffset,i=e.orientation==si?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM],r=e.elements[0].parent;for(let[s,n]of e._labels.children.entries())n.x=r.x+e.scale.map(e.labelValues[s]),n._y=e.pathPos+t,n._anchor=i,e._labelRotation&&(n._rotate=[e._labelRotation,n.x,n.y],n._anchor=[y.RIGHT,i[1]])}}}class _i extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){let t=e.layout;if(!t)return;this.fillGrid(e,t),this.computeCellBounds(e,t),this.placeElements(e,t)}let i=z(e,!0);for(let e of i)f(e)}placeElements(e,t){let i=Ge(e,"x"),r=Ge(e,"y");for(let i=0;i<e.children.length;i++){let r=e.children[i],s=t.cellBounds[i],n=0,a=0;switch(t._cellHorzAlignment){case y.LEFT:n=s.left-r.refBounds.left;break;case y.CENTER:n=s.x-r.refBounds.x;break;case y.RIGHT:n=s.right-r.refBounds.right}switch(t._cellVertAlignment){case y.TOP:a=s.top-r.refBounds.top;break;case y.MIDDLE:a=s.y-r.refBounds.y;break;case y.BOTTOM:a=s.bottom-r.refBounds.bottom}je(r,n,a)}if(i.length>0)for(let e of i)for(let i of e.scales){let r=e.getElements(i)[0],s=t.getIndex(r);if(s<0)continue;let n="point"===i.type?t.cellBounds[s].left+r.bounds.width/2:t.cellBounds[s].left,a=n+i.rangeExtent;i.range=i.range[0]<i.range[1]?[n,a]:[a,n]}if(r.length>0)for(let e of r)for(let i of e.scales){let r=e.getElements(i)[0],s=t.getIndex(r);if(s<0)continue;let n="point"===i.type?t.cellBounds[s].top+e.getElements(i)[0].bounds.height/2:t.cellBounds[s].top,a=n+i.rangeExtent;i.range=i.range[0]<i.range[1]?[n,a]:[a,n]}}fillGrid(e,t){t._grid=new Array(t.numRows).fill(null).map((()=>new Array(t.numCols).fill(null)));for(let i=0;i<e.children.length;i++){let e=t.getRowCol(i);t._grid[e.row][e.col]=i}}computeCellBounds(e,t){let i=e.children.map((e=>e.refBounds?e.refBounds:e.bounds)),r=t._colGap,s=t._rowGap;if(void 0===t._left){let e=i.map((e=>e.left)),r=i.map((e=>e.top));t._left=Math.min(...e),t._top=Math.min(...r)}let n=i.map((e=>e.width)),a=i.map((e=>e.height)),o=Math.max(...n),l=Math.max(...a);t._cellBounds=new Array(e.children.length).fill(null);for(let i=0;i<t.numRows;i++)for(let n=0;n<t.numCols;n++){let a=t._grid[i][n];a>=e.children.length||(t._cellBounds[a]=new u(t._left+(o+r)*n+0,t._top+(l+s)*i,o,l))}}}class pi extends X{constructor(e){super(e)}run(){let e=this.outputVar.element;e.updateValues(),e.scale?this._runForEncoding(e):this._runForLayout(e),f(e)}_runForLayout(e){let t=e.channel,i=p(e.elements),r=[];if("x"===t)for(let t=0;t<e.values.length;t++){let s=e.elements[t].refBounds;r.push({x1:s.x,y1:i.bottom,x2:s.x,y2:i.top})}else if("y"===t)for(let t=0;t<e.values.length;t++){let s=e.elements[t].refBounds;r.push({x1:i.left,y1:s.y,x2:i.right,y2:s.y})}e.lines=r,e._dirty=!0}_runForEncoding(e){let t=e.channel,i=p(e.elements),r=[];if("x"===t){let t,s,n=De(e.elements[0],"y");n?(t=Math.min(...n.getScale(e.elements[0]).range,i.top),s=Math.max(...n.getScale(e.elements[0]).range,i.bottom)):(t=i.top,s=i.bottom);for(let i of e.values)r.push({x1:e.scale.map(i),y1:s,x2:e.scale.map(i),y2:t})}else if("width"===t)for(let t of e.values)r.push({x1:e.scale.map(t)+i.left,y1:i.bottom,x2:e.scale.map(t)+i.left,y2:i.top});else if("y"===t){let t,s,n=De(e.elements[0],"x");n?(t=Math.min(...n.getScale(e.elements[0]).range,i.left),s=Math.max(...n.getScale(e.elements[0]).range,i.right)):(t=i.top,s=i.bottom);for(let i of e.values)r.push({x1:t,y1:e.scale.map(i),x2:s,y2:e.scale.map(i)})}else if("height"===t)for(let t of e.values)r.push({x1:i.left,y1:i.bottom-e.scale.map(t),x2:i.right,y2:i.bottom-e.scale.map(t)});else if("radialDistance"===t){let t=e.elements[0].parent;for(let i=0;i<e.values.length;i++)r.push({x:t.x,y:t.y,r:e.scale.map(e.values[i])})}e.lines=r,e._dirty=!0}}class gi extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=z(e)[0],i=O(e.parent);for(let e of i){let i=e.layout;if(!i)return;switch(t.type){case Dt.Rect:case Dt.Circle:case Dt.Image:this._stackRects(e,i);break;case Dt.Area:e.children[0].orientation===J.HORIZONTAL?this._stackAreasVert(e,i):this._stackAreasHorz(e,i);break;case Dt.Arc:case Dt.Pie:t.parent.classId===e.classId&&this._stackArcs(e,i)}}f(t)}_stackArcs(e,t){if(t.orientation===J.ANGULAR){let t=90;if((this._direction?this._direction:ee.Clockwise)===ee.Clockwise)for(let i of e.children){let e=ue(t-i.angle);We(i,"startAngle",e),t=e}else for(let i of e.children){let e=ue(t+i.angle);We(i,"startAngle",e),t=e}}else if(t.orientation===J.RADIAL){let t=Math.min(...e.children.map((e=>e.innerRadius)));for(let i of e.children){let e=i.outerRadius-i.innerRadius;We(i,"innerRadius",t),We(i,"outerRadius",t+e),t=i._outerRadius}}}_stackAreasVert(e,t){let i=e.children.filter((e=>"visible"===e.visibility)),r=e.bounds,s=t.vertCellAlignment===y.TOP?r.top:r.bottom,n=t.vertCellAlignment===y.TOP?1:-1;if(0===i.length)return;t.vertCellAlignment===y.BOTTOM&&i.reverse();let a=i[0].vertices.length/2,o=new Array(a).fill(0);for(let e of i){for(let t=0;t<a;t++){let i=e.vertices[t],r=e.vertices[2*a-t-1],l=Math.abs(i.y-r.y),h=s+o[t]*n,c=s+(o[t]+l)*n;je(i,0,h-i.y),je(r,0,c-r.y),o[t]+=l}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}if(t.vertCellAlignment===y.MIDDLE)for(let e of i){for(let t=0;t<a;t++){let i=e.vertices[t],s=e.vertices[2*a-t-1],n=r.middle+o[t]/2;je(i,0,n-r.bottom),je(s,0,n-r.bottom)}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}}_stackAreasHorz(e,t){}_stackRects(e,t){e.scene;let i=t._orientation,r=e.children.map((e=>e.bounds)),s=r.map((e=>e.left)),n=r.map((e=>e.top)),a=r.map((e=>e.width)),o=r.map((e=>e.height)),l=null==t._left?Math.min(...s):t._left,h=null==t._top?Math.min(...n):t._top,c=Math.max(...a),d=Math.max(...o);if(i==J.VERTICAL)for(let i=0;i<e.children.length;i++){let r=e.children[i],s=0,n=h+r.bounds.height/2-r.bounds.y;h+=r.bounds.height+t._gap,je(r,s,n),r._updateBounds();let a=0,o=0;if(!ze(r))switch(t._horzCellAlignment){case y.LEFT:a=l-r.bounds.left;break;case y.CENTER:a=l+c/2-r.bounds.x;break;case y.RIGHT:a=l+c-r.bounds.right}je(r,a,o)}else for(let i=0;i<e.children.length;i++){let r=e.children[i],s=l+r.bounds.width/2-r.bounds.x,n=0;l+=r.bounds.width+t._gap,je(r,s,n),r._updateBounds();let a=0,o=0;if(!Fe(r))switch(t._vertCellAlignment){case y.TOP:o=h-r.bounds.top;break;case y.MIDDLE:o=h+d/2-r.bounds.y;break;case y.BOTTOM:o=h+d-r.bounds.bottom}je(r,a,o)}}}class fi extends X{constructor(e){super(e)}run(){super.run()}}class yi extends X{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,i=e.attribute,s=t.attribute,n=e.dataset,a=t.dataset,o=n.getAttributeValues(i),l=r.bin()(o),h=this._findBin,c=o.map((e=>{let t=h(e,l);return(t.x0+t.x1)/2+""})),d=l.map((e=>(e.x0+e.x1)/2+""));a._addAttribute(s,Ae.String,c),a.orderAttributeValues(s,d)}_findBin(e,t){for(let i of t)if(i.indexOf(e)>=0)return i}}class mi extends X{constructor(e){super(e)}run(){let e=this.outputVar,t=e.dataset,i=e.predicate,r=[];for(let[e,s]of t.data.entries())i.testTuple(s)||r.push(e);r.sort(((e,t)=>t-e)),r.forEach((e=>{e>=0&&e<t.data.length&&(t._data.splice(e,1),t._rawData.splice(e,1))}));for(let e of t._attributes)t._attrSummaries[e]=Re(t.data.map((t=>t[e])),t._attrTypes[e])}}class bi extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e.type===Ie.AFFIXATION)).affixation,t=e.base,i=e.element,r=O(t),s=O(i),n=e.channels,a=e.attribute;if(E(i)&&E(t)){let e=r.map((e=>e.dataScope.getAttrVal(a)));s=s.filter((t=>e.includes(t.dataScope.getAttrVal(a))));let t=(e,t)=>e.dataScope.getAttrVal(a)<t.dataScope.getAttrVal(a)?-1:e.dataScope.getAttrVal(a)>t.dataScope.getAttrVal(a)?1:0;s.sort(t),r.sort(t)}if(n.includes("x")||n.includes("y"))for(let t of n)this._handleXY(t,s,r,e.getElementAnchor(t),e.getBaseAnchor(t),e.getOffset(t));(n.includes("radialDistance")||n.includes("angle"))&&this._handlePolar(s,r,e);let o=z(i,!0);for(let e of o)f(e)}_handlePolar(e,t,i){let r=i.hasChannel("radialDistance")?i.getBaseAnchor("radialDistance"):y.MIDDLE,s=i.hasChannel("radialDistance")?i.getElementAnchor("radialDistance"):y.MIDDLE,n=i.hasChannel("angle")?i.getBaseAnchor("angle"):y.CENTER;i.hasChannel("angle")?i.getElementAnchor("angle"):y.CENTER;let a=i.hasChannel("radialDistance")?i.getOffset("radialDistance"):0,o=i.hasChannel("angle")?i.getOffset("angle"):0;if([Dt.Arc,Dt.Ring].indexOf(t[0].type)>=0&&e[0].type==Dt.SimpleText)for(let i=0;i<e.length;i++){let s=t[i],o=e[i],l=r===y.MIDDLE?(s.outerRadius+s.innerRadius)/2:r===y.TOP?s.outerRadius-5:s.innerRadius+5;if(l+=a,s.type===Dt.Arc){let e=Se(s.x,s.y,l,s.startAngle),t=Se(s.x,s.y,l,s.endAngle);s.endAngle>=180&&s.endAngle<=360?o._textPath=["M",e[0],e[1],"A",l,l,s.angle,s.angle>=180?1:0,0,t[0],t[1]].join(" "):o._textPath=["M",t[0],t[1],"A",l,l,s.angle,s.angle>=180?1:0,1,e[0],e[1]].join(" ")}else if(s.type===Dt.Ring){let e=275,t=265,i=350,r=Se(s.x,s.y,l,e),n=Se(s.x,s.y,l,t);o._textPath=["M",n[0],n[1],"A",l,l,i,1,1,r[0],r[1]].join(" ")}o.textPathOffset=n===y.LEFT?"0%":"50%"}else for(let i=0;i<e.length;i++){let l,h,c=t[i],d=e[i];c.type==Dt.Arc||c.type==Dt.Ring?(h="left"==n?c.endAngle+o:"center"==n?c.startAngle+c.angle/2+o:c.startAngle+o,l="top"==r?c.outerRadius+a:"bottom"==r?c.innerRadius+a:(c.outerRadius+c.innerRadius)/2+a):c.type==Dt.Circle&&(h=90,l="top"==r?c.radius+a:"bottom"==r?a:c.radius/2+a),je(d,c.x-d.x,c.y-l-d.bounds[s]),d._rotate=[90-h,c.x,c.y]}}_handleXY(e,t,i,r,s,n){for(let a=0;a<t.length;a++){let o,l=i[a],h=t[a];if(ae(l)){o=ne(l,[y.LEFT,y.TOP].includes(s)?0:[y.CENTER,y.MIDDLE].includes(s)?.5:1)[e]}else o=l.bounds[s]+n;t[0].type===Dt.SimpleText?(h.anchor["x"==e?0:1]=r,We(h,e,o)):"x"==e?je(h,o-h.bounds[r],0):je(h,0,o-h.bounds[r])}}}class xi extends Oe{constructor(e,t){super(e),this._affx=t}get affixation(){return this._affx}}class vi extends X{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,i=e.attribute,r=t.attribute,s=e.dataset,n=t.dataset,a=this.args,o="min"in a?a.min:s.getAttributeSummary(i).min,l="max"in a?a.max:s.getAttributeSummary(i).max,h=o,c=[];for(;h<l;)c.push(h),h+=a.interval;c.push(h);let d={},u={};if(a.groupBy)for(let e of s.data){let t=a.groupBy.map((t=>e[t])).join("-");t in d||(d[t]=[],u[t]=a.groupBy.map((t=>e[t]))),d[t].push(e[i])}else d[""]=s.data.map((e=>e[i])),u[""]="";let _=[];for(let e in u){let t=wi(Ei(a.bandwidth),c,d[e]);for(let s of t){let t={};""!==e&&a.groupBy.forEach(((i,r)=>t[i]=u[e][r])),t[i]=s[0],t[r]=s[1],_.push(t)}}let p={};if(p[i]=s.getAttributeType(i),p[r]=Ae.Number,a.groupBy)for(let e of a.groupBy)p[e]=s.getAttributeType(e);n.initialize(_,n.url,p)}}function wi(e,t,i){return t.map((t=>[t,r.mean(i,(i=>e(t-i)))]))}function Ei(e){return t=>Math.abs(t/=e)<=1?.75*(1-t*t)/e:0}class Ai extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){let t=e.layout;if(!t)return;let i=e.children.map((e=>({name:e.id,radius:e.radius,itm:e}))),s=i.reduce(((e,t)=>e+Math.pow(t.radius,2)),0),n=Math.sqrt(s);void 0===t._width&&(t._width=n),void 0===t._height&&(t._height=n);let a=r.hierarchy({name:"root",children:i}).sum((e=>e.radius?e.radius:0)).sort(((e,t)=>t.value-e.value));r.pack().size([t._width,t._height]).radius((e=>e.value))(a);for(let e of a.children){let i=e.data.itm;je(i,t._x-a.x+e.x-i.x,t._y-a.y+e.y-i.y)}}let i=z(e,!0);for(let e of i)f(e)}}class Ci extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e instanceof et&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof li?this._runForEncoding(e):e instanceof hi&&this._runForLayout(e),f(e._title)}_runForEncoding(e){let t=e.channel,i=p(e.elements);if("x"==t)e._title.x=(e.scale.range[0]+e.scale.range[1])/2,e._title._y=e.orientation==si?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("width"==t)e._title.x=i.left+e.scale.rangeExtent/2,e._title._y=e.orientation==si?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._rotateYTitle?(e._title.x=e.orientation==ni?e.pathPos-e.titleOffset:e.pathPos+e.titleOffset,e._title._y=(e.scale.range[0]+e.scale.range[1])/2,e._title._rotate=e.orientation==ni?[-90,e._title._x,e._title._y]:[90,e._title._x,e._title._y]):(e._title.x=e.orientation==ni?e.pathPos-e.titleOffset:e.pathPos+e.titleOffset,e._title._y=Math.min(e.scale.range[0],e.scale.range[1])-25,e._title._rotate=void 0);else if("height"===t)e._title.x=i.center,e._title._y=(i.top+i.bottom)/2-i.width/2-e.titleOffset,e._title._rotate=e.orientation==ni?[-90,i.center,i.middle]:[90,i.center,i.middle];else if("radialDistance"===t){let t=e.elements[0].parent;e._title.x=t.x+e.scale.rangeExtent/2,e._title._y=e.orientation==si?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset,e._rotate&&(e._title._rotate=e._rotate.slice())}}_runForLayout(e){let t=e.channel,i=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?g(e.elements):p(e.elements);if("x"==t)e._title.x=i.center,e._title._y=e.orientation==si?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._title.x=i.center,e._title._y=i.middle-i.width/2-e.titleOffset,e._title._rotate=e.orientation==ni?[-90,i.center,i.middle]:[90,i.center,i.middle];else if("angle"===t){let t=e.elements[0].parent.layout;t.type===W.CLUSTER&&(e._title.x=t.x,e._title._y=t.y)}}}class Ti extends Yt{constructor(e){super(e)}run(){super.run();let e,t=this.vars.find((e=>e.type===Ie.ALIGNMENT)).alignment,i=t.anchor,s=t.elements;i==y.Top||i==y.LEFT?e=Math.min(...s.map((e=>e.bounds[i]))):i==y.BOTTOM||i==y.RIGHT?e=Math.max(...s.map((e=>e.bounds[i]))):i!=y.CENTER&&i!=y.MIDDLE||(e=r.mean(s.map((e=>e.bounds[i]))));for(let r of s){let s=He(r,t.channel);if(s){let n=e-r.bounds[i];je(s,"x"===t.channel?n:0,"x"===t.channel?0:n)}}for(let e of s)f(e)}}class Ri extends Oe{constructor(e,t){super(e),this._aln=t}get alignment(){return this._aln}}class ki extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let i=xe(e.children[0]);if(!i)continue;let s=i.linkList.map((e=>({source:i.getNode(e.source),target:i.getNode(e.target)}))),n=r.forceSimulation(i.nodeList).force("charge",r.forceManyBody().strength(-t._repulsion)).force("link",r.forceLink(s).id((e=>e.id)).distance(t._linkDistance)).force("x",r.forceX()).force("y",r.forceY()).force("center",r.forceCenter(t._x,t._y).strength(t._attraction));n.stop(),n.tick(t._iterations);for(let t=0;t<e.children.length;t++){let r=e.children[t],s=i.nodeList[t];je(r,s.x-r.x,s.y-r.y)}}let i=z(e,!0);for(let e of i)f(e)}}class Si extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e);switch(e.type){case Dt.Arc:this._updateArcLinks(t);break;case Dt.BezierCurve:this._updateBezierLinks(t);break;case Dt.BundledPath:this._updateBundledLinks(t);break;case Dt.Chord:this._updateChordLinks(t);break;case Dt.Line:default:this._updateLineLinks(t)}f(e)}_updateArcLinks(e){for(let t of e){let e=t.source.x<t.target.x?t.source:t.target,i=t.source.x<t.target.x?t.target:t.source;t._x=(e.x+i.x)/2,t._y=(e.y+i.y)/2,t._innerRadius=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))/2,t._outerRadius=t._innerRadius+t._thickness;let r=_e(e.x,e.y,t._x,t._y),s=_e(i.x,i.y,t._x,t._y);t.direction===ee.CLOCKWISE&&([r,s]=[s,r]),We(t,"startAngle",r),We(t,"angle",Math.abs(s-r))}}_updateBezierLinks(e){let t=this._inputVars[0].element,i=O(t),r=t.parent.layout;r.type===W.DIRECTED||r.type===W.TIDYTREE?this._updateBezierLinksForDirectedGraph(i,e,r):r.type===W.CLUSTER&&this._updateBezierLinksForClusteredGraph(i,e,r)}_updateBezierLinksForClusteredGraph(e,t,i){const s=i._d3Root.descendants(),n=new Map(s.map((e=>[Oi(e),e]))),a=new Map(s.map((e=>[e.data[we],Oi(e)])));if(i.isRadial()){const e=r.linkRadial().angle((e=>e.x)).radius((e=>e.y));for(let r of t){let t=r.source,s=r.target,o=t.dataScope.getAttrVal(we),l=s.dataScope.getAttrVal(we),h=n.get(a.get(o)),c=n.get(a.get(l));r._d=le(e({source:h,target:c}),i.x,i.y)}}else if(i.orientation===J.VERTICAL){const e=r.linkVertical().x((e=>e.x)).y((e=>e.y));for(let r of t){let t=r.source,s=r.target,o=t.dataScope.getAttrVal(we),l=s.dataScope.getAttrVal(we),h=n.get(a.get(o)),c=n.get(a.get(l));r._d=le(e({source:h,target:c}),i.left-i._x0,i.top)}}else if(i.orientation===J.HORIZONTAL){const e=r.linkHorizontal().x((e=>e.y)).y((e=>e.x));for(let r of t){let t=r.source,s=r.target,o=t.dataScope.getAttrVal(we),l=s.dataScope.getAttrVal(we),h=n.get(a.get(o)),c=n.get(a.get(l));r._d=le(e({source:h,target:c}),i.left,i.top-i._x0)}}}_updateBezierLinksForDirectedGraph(e,t,i){let r={},s={},n={},a={};for(let t of e){s[t.id]=0,r[t.id]=0;let e=t.links.filter((e=>e.source===t)),i=t.links.filter((e=>e.target===t));a[t.id]=i.map((e=>e.strokeWidth)).reduce(((e,t)=>e+t),0),n[t.id]=e.map((e=>e.strokeWidth)).reduce(((e,t)=>e+t),0)}i.spreadLinks&&("LR"===i.direction||"RL"===i.direction?t.sort(((e,t)=>_e(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y)-_e(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y))):t.sort(((e,t)=>_e(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y)-_e(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y))));for(let e of t){let t,o,l,h,c=e.source,d=e.target;i.spreadLinks?"LR"===i.direction||"RL"===i.direction?(t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0],l=d.bounds[e.targetAnchor[0]]+e.targetOffset[0],o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1]-n[c.id]/2+r[c.id]+e.strokeWidth/2,h=d.bounds[e.targetAnchor[1]]+e.targetOffset[1]-a[d.id]/2+s[d.id]+e.strokeWidth/2,r[c.id]+=e.strokeWidth,s[d.id]+=e.strokeWidth):(o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1],h=d.bounds[e.targetAnchor[1]]+e.targetOffset[1],t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0]-n[c.id]/2+r[c.id]+e.strokeWidth/2,l=d.bounds[e.targetAnchor[0]]+e.targetOffset[0]-a[d.id]/2+s[d.id]+e.strokeWidth/2,r[c.id]+=e.strokeWidth,s[d.id]+=e.strokeWidth):(t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0],o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1],l=d.bounds[e.targetAnchor[0]]+e.targetOffset[0],h=d.bounds[e.targetAnchor[1]]+e.targetOffset[1]),e.orientation===J.HORIZONTAL?e._setVertices([[t,o],[(t+l)/2,o],[t,h],[l,h]]):e.orientation===J.VERTICAL&&e._setVertices([[t,o],[t,(o+h)/2],[l,o],[l,h]])}}_updateBundledLinks(e){let t=this._inputVars[0].element.parent.layout;if(t.type!==W.CLUSTER)throw"Bundled links must work on a cluster layout";let i=t._d3Root.leaves();const s=new Map(i.map((e=>[Oi(e),e]))),n=new Map(i.map((e=>[e.data[we],Oi(e)]))),a=r.lineRadial().curve(r.curveBundle.beta(e[0]._strength)).radius((e=>e.y)).angle((e=>e.x));for(let i of e){let e=i.source.dataScope.getAttrVal(we),r=i.target.dataScope.getAttrVal(we),o=s.get(n.get(e)),l=s.get(n.get(r));(o.outgoing??=[]).push([o,l]),l.incoming??=[];let h=o.path(l);i._d=le(a(h),t.x,t.y)}}_updateChordLinks(e){for(let t of e){let e=t.source,i=t.target,r=Se(e.x,e.y,e.innerRadius,e.startAngle),s=Se(e.x,e.y,e.innerRadius,e.endAngle),n=Se(i.x,i.y,i.innerRadius,i.startAngle),a=Se(i.x,i.y,i.innerRadius,i.endAngle);t._d=["M",r[0],r[1],"Q",e.x,e.y,a[0],a[1],"A",e.x,e.y,i.angle,i.angle>180?1:0,1,n[0],n[1],"Q",e.x,e.y,s[0],s[1],"A",e.x,e.y,e.angle,e.angle>180?1:0,1,r[0],r[1]].join(" "),t._dirty=!0}}_updateLineLinks(e){for(let t of e){let e=t.source,i=t.target;t.vertices[0]._x=e.bounds.x,t.vertices[0]._y=e.bounds.y,t.vertices[1]._x=i.bounds.x,t.vertices[1]._y=i.bounds.y,t._dirty=!0}}}function Oi(e){return`${e.parent?Oi(e.parent)+".":""}${e.data[we]}`}var Ii="\0",Ni="\0",Li="";function Vi(e,t){e[t]?e[t]++:e[t]=1}function Pi(e,t){--e[t]||delete e[t]}function Mi(e,t,i,r){var s=""+t,n=""+i;if(!e&&s>n){var a=s;s=n,n=a}return s+Li+n+Li+(void 0===r?Ii:r)}function Di(e,t){return Mi(e,t.v,t.w,t.name)}var Bi=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=!e.hasOwnProperty("directed")||e.directed,this._isMultigraph=!!e.hasOwnProperty("multigraph")&&e.multigraph,this._isCompound=!!e.hasOwnProperty("compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[Ni]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._in[t]).length))}sinks(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._out[t]).length))}setNodes(e,t){var i=arguments,r=this;return e.forEach((function(e){i.length>1?r.setNode(e,t):r.setNode(e)})),this}setNode(e,t){return this._nodes.hasOwnProperty(e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=Ni,this._children[e]={},this._children[Ni][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return this._nodes.hasOwnProperty(e)}removeNode(e){var t=this;if(this._nodes.hasOwnProperty(e)){var i=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach((function(e){t.setParent(e)})),delete this._children[e]),Object.keys(this._in[e]).forEach(i),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(i),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===t)t=Ni;else{for(var i=t+="";void 0!==i;i=this.parent(i))if(i===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==Ni)return t}}children(e=Ni){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===Ni)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){const r=new Set(t);for(var i of this.successors(e))r.add(i);return Array.from(r.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var i=this;Object.entries(this._nodes).forEach((function([i,r]){e(i)&&t.setNode(i,r)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,i.edge(e))}));var r={};function s(e){var n=i.parent(e);return void 0===n||t.hasNode(n)?(r[e]=n,n):n in r?r[n]:s(n)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,s(e)))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var i=this,r=arguments;return e.reduce((function(e,s){return r.length>1?i.setEdge(e,s,t):i.setEdge(e,s),s})),this}setEdge(){var e,t,i,r,s=!1,n=arguments[0];"object"==typeof n&&null!==n&&"v"in n?(e=n.v,t=n.w,i=n.name,2===arguments.length&&(r=arguments[1],s=!0)):(e=n,t=arguments[1],i=arguments[3],arguments.length>2&&(r=arguments[2],s=!0)),e=""+e,t=""+t,void 0!==i&&(i=""+i);var a=Mi(this._isDirected,e,t,i);if(this._edgeLabels.hasOwnProperty(a))return s&&(this._edgeLabels[a]=r),this;if(void 0!==i&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[a]=s?r:this._defaultEdgeLabelFn(e,t,i);var o=function(e,t,i,r){var s=""+t,n=""+i;if(!e&&s>n){var a=s;s=n,n=a}var o={v:s,w:n};r&&(o.name=r);return o}(this._isDirected,e,t,i);return e=o.v,t=o.w,Object.freeze(o),this._edgeObjs[a]=o,Vi(this._preds[t],e),Vi(this._sucs[e],t),this._in[t][a]=o,this._out[e][a]=o,this._edgeCount++,this}edge(e,t,i){var r=1===arguments.length?Di(this._isDirected,arguments[0]):Mi(this._isDirected,e,t,i);return this._edgeLabels[r]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,i){var r=1===arguments.length?Di(this._isDirected,arguments[0]):Mi(this._isDirected,e,t,i);return this._edgeLabels.hasOwnProperty(r)}removeEdge(e,t,i){var r=1===arguments.length?Di(this._isDirected,arguments[0]):Mi(this._isDirected,e,t,i),s=this._edgeObjs[r];return s&&(e=s.v,t=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],Pi(this._preds[t],e),Pi(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var i=this._in[e];if(i){var r=Object.values(i);return t?r.filter((e=>e.v===t)):r}}outEdges(e,t){var i=this._out[e];if(i){var r=Object.values(i);return t?r.filter((e=>e.w===t)):r}}nodeEdges(e,t){var i=this.inEdges(e,t);if(i)return i.concat(this.outEdges(e,t))}},Gi={Graph:Bi,version:"2.2.2"},Fi=Bi,zi={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Hi(e),edges:ji(e)};void 0!==e.graph()&&(t.value=structuredClone(e.graph()));return t},read:function(e){var t=new Fi(e.options).setGraph(e.value);return e.nodes.forEach((function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),e.edges.forEach((function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function Hi(e){return e.nodes().map((function(t){var i=e.node(t),r=e.parent(t),s={v:t};return void 0!==i&&(s.value=i),void 0!==r&&(s.parent=r),s}))}function ji(e){return e.edges().map((function(t){var i=e.edge(t),r={v:t.v,w:t.w};return void 0!==t.name&&(r.name=t.name),void 0!==i&&(r.value=i),r}))}var Ui=function(e){var t,i={},r=[];function s(r){i.hasOwnProperty(r)||(i[r]=!0,t.push(r),e.successors(r).forEach(s),e.predecessors(r).forEach(s))}return e.nodes().forEach((function(e){t=[],s(e),t.length&&r.push(t)})),r};var Wi=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map((function(e){return e.key}))}has(e){return this._keyIndices.hasOwnProperty(e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var i=this._keyIndices;if(e=String(e),!i.hasOwnProperty(e)){var r=this._arr,s=r.length;return i[e]=s,r.push({key:e,priority:t}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var i=this._keyIndices[e];if(t>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[i].priority+" New: "+t);this._arr[i].priority=t,this._decrease(i)}_heapify(e){var t=this._arr,i=2*e,r=i+1,s=e;i<t.length&&(s=t[i].priority<t[s].priority?i:s,r<t.length&&(s=t[r].priority<t[s].priority?r:s),s!==e&&(this._swap(e,s),this._heapify(s)))}_decrease(e){for(var t,i=this._arr,r=i[e].priority;0!==e&&!(i[t=e>>1].priority<r);)this._swap(e,t),e=t}_swap(e,t){var i=this._arr,r=this._keyIndices,s=i[e],n=i[t];i[e]=n,i[t]=s,r[n.key]=e,r[s.key]=t}},Yi=Wi,Xi=function(e,t,i,r){return function(e,t,i,r){var s,n,a={},o=new Yi,l=function(e){var t=e.v!==s?e.v:e.w,r=a[t],l=i(e),h=n.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);h<r.distance&&(r.distance=h,r.predecessor=s,o.decrease(t,h))};e.nodes().forEach((function(e){var i=e===t?0:Number.POSITIVE_INFINITY;a[e]={distance:i},o.add(e,i)}));for(;o.size()>0&&(s=o.removeMin(),(n=a[s]).distance!==Number.POSITIVE_INFINITY);)r(s).forEach(l);return a}(e,String(t),i||qi,r||function(t){return e.outEdges(t)})},qi=()=>1;var Ki=Xi,Zi=function(e,t,i){return e.nodes().reduce((function(r,s){return r[s]=Ki(e,s,t,i),r}),{})};var $i=function(e){var t=0,i=[],r={},s=[];function n(a){var o=r[a]={onStack:!0,lowlink:t,index:t++};if(i.push(a),e.successors(a).forEach((function(e){r.hasOwnProperty(e)?r[e].onStack&&(o.lowlink=Math.min(o.lowlink,r[e].index)):(n(e),o.lowlink=Math.min(o.lowlink,r[e].lowlink))})),o.lowlink===o.index){var l,h=[];do{l=i.pop(),r[l].onStack=!1,h.push(l)}while(a!==l);s.push(h)}}return e.nodes().forEach((function(e){r.hasOwnProperty(e)||n(e)})),s};var Ji=$i,Qi=function(e){return Ji(e).filter((function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var er=function(e,t,i){return function(e,t,i){var r={},s=e.nodes();return s.forEach((function(e){r[e]={},r[e][e]={distance:0},s.forEach((function(t){e!==t&&(r[e][t]={distance:Number.POSITIVE_INFINITY})})),i(e).forEach((function(i){var s=i.v===e?i.w:i.v,n=t(i);r[e][s]={distance:n,predecessor:e}}))})),s.forEach((function(e){var t=r[e];s.forEach((function(i){var n=r[i];s.forEach((function(i){var r=n[e],s=t[i],a=n[i],o=r.distance+s.distance;o<a.distance&&(a.distance=o,a.predecessor=s.predecessor)}))}))})),r}(e,t||tr,i||function(t){return e.outEdges(t)})},tr=()=>1;function ir(e){var t={},i={},r=[];if(e.sinks().forEach((function s(n){if(i.hasOwnProperty(n))throw new rr;t.hasOwnProperty(n)||(i[n]=!0,t[n]=!0,e.predecessors(n).forEach(s),delete i[n],r.push(n))})),Object.keys(t).length!==e.nodeCount())throw new rr;return r}class rr extends Error{constructor(){super(...arguments)}}var sr=ir;ir.CycleException=rr;var nr=sr;var ar=function(e,t,i){Array.isArray(t)||(t=[t]);var r=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),s="post"===i?or:lr,n=[],a={};return t.forEach((t=>{if(!e.hasNode(t))throw new Error("Graph does not have node: "+t);s(t,r,a,n)})),n};function or(e,t,i,r){for(var s=[[e,!1]];s.length>0;){var n=s.pop();n[1]?r.push(n[0]):i.hasOwnProperty(n[0])||(i[n[0]]=!0,s.push([n[0],!0]),hr(t(n[0]),(e=>s.push([e,!1]))))}}function lr(e,t,i,r){for(var s=[e];s.length>0;){var n=s.pop();i.hasOwnProperty(n)||(i[n]=!0,r.push(n),hr(t(n),(e=>s.push(e))))}}function hr(e,t){for(var i=e.length;i--;)t(e[i],i,e);return e}var cr=ar;var dr=ar;var ur=Bi,_r=Wi;var pr={Graph:Gi.Graph,json:zi,alg:{components:Ui,dijkstra:Xi,dijkstraAll:Zi,findCycles:Qi,floydWarshall:er,isAcyclic:function(e){try{nr(e)}catch(e){if(e instanceof nr.CycleException)return!1;throw e}return!0},postorder:function(e,t){return cr(e,t,"post")},preorder:function(e,t){return dr(e,t,"pre")},prim:function(e,t){var i,r=new ur,s={},n=new _r;function a(e){var r=e.v===i?e.w:e.v,a=n.priority(r);if(void 0!==a){var o=t(e);o<a&&(s[r]=i,n.decrease(r,o))}}if(0===e.nodeCount())return r;e.nodes().forEach((function(e){n.add(e,Number.POSITIVE_INFINITY),r.setNode(e)})),n.decrease(e.nodes()[0],0);var o=!1;for(;n.size()>0;){if(i=n.removeMin(),s.hasOwnProperty(i))r.setEdge(i,s[i]);else{if(o)throw new Error("Input graph is not connected: "+e);o=!0}e.nodeEdges(i).forEach(a)}return r},tarjan:$i,topsort:sr},version:Gi.version};function gr(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function fr(e,t){if("_next"!==e&&"_prev"!==e)return t}let yr=pr.Graph,mr=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return gr(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&gr(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,i=t._prev;for(;i!==t;)e.push(JSON.stringify(i,fr)),i=i._prev;return"["+e.join(", ")+"]"}};var br=function(e,t){if(e.nodeCount()<=1)return[];let i=function(e,t){let i=new yr,r=0,s=0;e.nodes().forEach((e=>{i.setNode(e,{v:e,in:0,out:0})})),e.edges().forEach((e=>{let n=i.edge(e.v,e.w)||0,a=t(e),o=n+a;i.setEdge(e.v,e.w,o),s=Math.max(s,i.node(e.v).out+=a),r=Math.max(r,i.node(e.w).in+=a)}));let n=function(e){const t=[];for(let i=0;i<e;i++)t.push(i);return t}(s+r+3).map((()=>new mr)),a=r+1;return i.nodes().forEach((e=>{wr(n,a,i.node(e))})),{graph:i,buckets:n,zeroIdx:a}}(e,t||xr);return function(e,t,i){let r,s=[],n=t[t.length-1],a=t[0];for(;e.nodeCount();){for(;r=a.dequeue();)vr(e,t,i,r);for(;r=n.dequeue();)vr(e,t,i,r);if(e.nodeCount())for(let n=t.length-2;n>0;--n)if(r=t[n].dequeue(),r){s=s.concat(vr(e,t,i,r,!0));break}}return s}(i.graph,i.buckets,i.zeroIdx).flatMap((t=>e.outEdges(t.v,t.w)))};let xr=()=>1;function vr(e,t,i,r,s){let n=s?[]:void 0;return e.inEdges(r.v).forEach((r=>{let a=e.edge(r),o=e.node(r.v);s&&n.push({v:r.v,w:r.w}),o.out-=a,wr(t,i,o)})),e.outEdges(r.v).forEach((r=>{let s=e.edge(r),n=r.w,a=e.node(n);a.in-=s,wr(t,i,a)})),e.removeNode(r.v),n}function wr(e,t,i){i.out?i.in?e[i.out-i.in+t].enqueue(i):e[e.length-1].enqueue(i):e[0].enqueue(i)}let Er=pr.Graph;var Ar={addBorderNode:function(e,t,i,r){let s={width:0,height:0};arguments.length>=4&&(s.rank=i,s.order=r);return Cr(e,"border",s,t)},addDummyNode:Cr,asNonCompoundGraph:function(e){let t=new Er({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach((i=>{e.children(i).length||t.setNode(i,e.node(i))})),e.edges().forEach((i=>{t.setEdge(i,e.edge(i))})),t},buildLayerMatrix:function(e){let t=Sr(Tr(e)+1).map((()=>[]));return e.nodes().forEach((i=>{let r=e.node(i),s=r.rank;void 0!==s&&(t[s][r.order]=i)})),t},intersectRect:function(e,t){let i,r,s=e.x,n=e.y,a=t.x-s,o=t.y-n,l=e.width/2,h=e.height/2;if(!a&&!o)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(o)*l>Math.abs(a)*h?(o<0&&(h=-h),i=h*a/o,r=h):(a<0&&(l=-l),i=l,r=l*o/a);return{x:s+i,y:n+r}},mapValues:function(e,t){let i=t;"string"==typeof t&&(i=e=>e[t]);return Object.entries(e).reduce(((e,[t,r])=>(e[t]=i(r,t),e)),{})},maxRank:Tr,normalizeRanks:function(e){let t=Math.min(...e.nodes().map((t=>{let i=e.node(t).rank;return void 0===i?Number.MAX_VALUE:i})));e.nodes().forEach((i=>{let r=e.node(i);r.hasOwnProperty("rank")&&(r.rank-=t)}))},notime:function(e,t){return t()},partition:function(e,t){let i={lhs:[],rhs:[]};return e.forEach((e=>{t(e)?i.lhs.push(e):i.rhs.push(e)})),i},pick:function(e,t){const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},predecessorWeights:function(e){let t=e.nodes().map((t=>{let i={};return e.inEdges(t).forEach((t=>{i[t.v]=(i[t.v]||0)+e.edge(t).weight})),i}));return Or(e.nodes(),t)},range:Sr,removeEmptyRanks:function(e){let t=Math.min(...e.nodes().map((t=>e.node(t).rank))),i=[];e.nodes().forEach((r=>{let s=e.node(r).rank-t;i[s]||(i[s]=[]),i[s].push(r)}));let r=0,s=e.graph().nodeRankFactor;Array.from(i).forEach(((t,i)=>{void 0===t&&i%s!=0?--r:void 0!==t&&r&&t.forEach((t=>e.node(t).rank+=r))}))},simplify:function(e){let t=(new Er).setGraph(e.graph());return e.nodes().forEach((i=>t.setNode(i,e.node(i)))),e.edges().forEach((i=>{let r=t.edge(i.v,i.w)||{weight:0,minlen:1},s=e.edge(i);t.setEdge(i.v,i.w,{weight:r.weight+s.weight,minlen:Math.max(r.minlen,s.minlen)})})),t},successorWeights:function(e){let t=e.nodes().map((t=>{let i={};return e.outEdges(t).forEach((t=>{i[t.w]=(i[t.w]||0)+e.edge(t).weight})),i}));return Or(e.nodes(),t)},time:function(e,t){let i=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-i)+"ms")}},uniqueId:kr,zipObject:Or};function Cr(e,t,i,r){let s;do{s=kr(r)}while(e.hasNode(s));return i.dummy=t,e.setNode(s,i),s}function Tr(e){return Math.max(...e.nodes().map((t=>{let i=e.node(t).rank;return void 0===i?Number.MIN_VALUE:i})))}let Rr=0;function kr(e){var t=++Rr;return toString(e)+t}function Sr(e,t,i=1){null==t&&(t=e,e=0);let r=e=>e<t;i<0&&(r=e=>t<e);const s=[];for(let t=e;r(t);t+=i)s.push(t);return s}function Or(e,t){return e.reduce(((e,i,r)=>(e[i]=t[r],e)),{})}let Ir=br,Nr=Ar.uniqueId;var Lr={run:function(e){("greedy"===e.graph().acyclicer?Ir(e,function(e){return t=>e.edge(t).weight}(e)):function(e){let t=[],i={},r={};function s(n){r.hasOwnProperty(n)||(r[n]=!0,i[n]=!0,e.outEdges(n).forEach((e=>{i.hasOwnProperty(e.w)?t.push(e):s(e.w)})),delete i[n])}return e.nodes().forEach(s),t}(e)).forEach((t=>{let i=e.edge(t);e.removeEdge(t),i.forwardName=t.name,i.reversed=!0,e.setEdge(t.w,t.v,i,Nr("rev"))}))},undo:function(e){e.edges().forEach((t=>{let i=e.edge(t);if(i.reversed){e.removeEdge(t);let r=i.forwardName;delete i.reversed,delete i.forwardName,e.setEdge(t.w,t.v,i,r)}}))}};let Vr=Ar;var Pr={run:function(e){e.graph().dummyChains=[],e.edges().forEach((t=>function(e,t){let i,r,s,n=t.v,a=e.node(n).rank,o=t.w,l=e.node(o).rank,h=t.name,c=e.edge(t),d=c.labelRank;if(l===a+1)return;for(e.removeEdge(t),s=0,++a;a<l;++s,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:t,rank:a},i=Vr.addDummyNode(e,"edge",r,"_d"),a===d&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),e.setEdge(n,i,{weight:c.weight},h),0===s&&e.graph().dummyChains.push(i),n=i;e.setEdge(n,o,{weight:c.weight},h)}(e,t)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let i,r=e.node(t),s=r.edgeLabel;for(e.setEdge(r.edgeObj,s);r.dummy;)i=e.successors(t)[0],e.removeNode(t),s.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(s.x=r.x,s.y=r.y,s.width=r.width,s.height=r.height),t=i,r=e.node(t)}))}};var Mr={longestPath:function(e){var t={};e.sources().forEach((function i(r){var s=e.node(r);if(t.hasOwnProperty(r))return s.rank;t[r]=!0;var n=Math.min(...e.outEdges(r).map((t=>null==t?Number.POSITIVE_INFINITY:i(t.w)-e.edge(t).minlen)));return n===Number.POSITIVE_INFINITY&&(n=0),s.rank=n}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var Dr=pr.Graph,Br=Mr.slack,Gr=function(e){var t,i,r=new Dr({directed:!1}),s=e.nodes()[0],n=e.nodeCount();r.setNode(s,{});for(;Fr(r,e)<n;)t=zr(r,e),i=r.hasNode(t.v)?Br(e,t):-Br(e,t),Hr(r,e,i);return r};function Fr(e,t){return e.nodes().forEach((function i(r){t.nodeEdges(r).forEach((s=>{var n=s.v,a=r===n?s.w:n;e.hasNode(a)||Br(t,s)||(e.setNode(a,{}),e.setEdge(r,a,{}),i(a))}))})),e.nodeCount()}function zr(e,t){return t.edges().reduce(((i,r)=>{let s=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(s=Br(t,r)),s<i[0]?[s,r]:i}),[Number.POSITIVE_INFINITY,null])[1]}function Hr(e,t,i){e.nodes().forEach((e=>t.node(e).rank+=i))}var jr=Gr,Ur=Mr.slack,Wr=Mr.longestPath,Yr=pr.alg.preorder,Xr=pr.alg.postorder,qr=Ar.simplify,Kr=Zr;function Zr(e){e=qr(e),Wr(e);var t,i=jr(e);for(Qr(i),$r(i,e);t=ts(i);)rs(i,e,t,is(i,e,t))}function $r(e,t){var i=Xr(e,e.nodes());(i=i.slice(0,i.length-1)).forEach((i=>function(e,t,i){var r=e.node(i),s=r.parent;e.edge(i,s).cutvalue=Jr(e,t,i)}(e,t,i)))}function Jr(e,t,i){var r=e.node(i).parent,s=!0,n=t.edge(i,r),a=0;return n||(s=!1,n=t.edge(r,i)),a=n.weight,t.nodeEdges(i).forEach((n=>{var o,l,h=n.v===i,c=h?n.w:n.v;if(c!==r){var d=h===s,u=t.edge(n).weight;if(a+=d?u:-u,o=i,l=c,e.hasEdge(o,l)){var _=e.edge(i,c).cutvalue;a+=d?-_:_}}})),a}function Qr(e,t){arguments.length<2&&(t=e.nodes()[0]),es(e,{},1,t)}function es(e,t,i,r,s){var n=i,a=e.node(r);return t[r]=!0,e.neighbors(r).forEach((s=>{t.hasOwnProperty(s)||(i=es(e,t,i,s,r))})),a.low=n,a.lim=i++,s?a.parent=s:delete a.parent,i}function ts(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function is(e,t,i){var r=i.v,s=i.w;t.hasEdge(r,s)||(r=i.w,s=i.v);var n=e.node(r),a=e.node(s),o=n,l=!1;n.lim>a.lim&&(o=a,l=!0);var h=t.edges().filter((t=>l===ss(e,e.node(t.v),o)&&l!==ss(e,e.node(t.w),o)));return h.reduce(((e,i)=>Ur(t,i)<Ur(t,e)?i:e))}function rs(e,t,i,r){var s=i.v,n=i.w;e.removeEdge(s,n),e.setEdge(r.v,r.w,{}),Qr(e),$r(e,t),function(e,t){var i=e.nodes().find((e=>!t.node(e).parent)),r=Yr(e,i);(r=r.slice(1)).forEach((i=>{var r=e.node(i).parent,s=t.edge(i,r),n=!1;s||(s=t.edge(r,i),n=!0),t.node(i).rank=t.node(r).rank+(n?s.minlen:-s.minlen)}))}(e,t)}function ss(e,t,i){return i.low<=t.lim&&t.lim<=i.lim}Zr.initLowLimValues=Qr,Zr.initCutValues=$r,Zr.calcCutValue=Jr,Zr.leaveEdge=ts,Zr.enterEdge=is,Zr.exchangeEdges=rs;var ns=Mr.longestPath,as=Gr,os=Kr,ls=function(e){switch(e.graph().ranker){case"network-simplex":default:cs(e);break;case"tight-tree":!function(e){ns(e),as(e)}(e);break;case"longest-path":hs(e)}};var hs=ns;function cs(e){os(e)}var ds=function(e){let t=function(e){let t={},i=0;function r(s){let n=i;e.children(s).forEach(r),t[s]={low:n,lim:i++}}return e.children().forEach(r),t}(e);e.graph().dummyChains.forEach((i=>{let r=e.node(i),s=r.edgeObj,n=function(e,t,i,r){let s,n,a=[],o=[],l=Math.min(t[i].low,t[r].low),h=Math.max(t[i].lim,t[r].lim);s=i;do{s=e.parent(s),a.push(s)}while(s&&(t[s].low>l||h>t[s].lim));n=s,s=r;for(;(s=e.parent(s))!==n;)o.push(s);return{path:a.concat(o.reverse()),lca:n}}(e,t,s.v,s.w),a=n.path,o=n.lca,l=0,h=a[l],c=!0;for(;i!==s.w;){if(r=e.node(i),c){for(;(h=a[l])!==o&&e.node(h).maxRank<r.rank;)l++;h===o&&(c=!1)}if(!c){for(;l<a.length-1&&e.node(h=a[l+1]).minRank<=r.rank;)l++;h=a[l]}e.setParent(i,h),i=e.successors(i)[0]}}))};let us=Ar;var _s={run:function(e){let t=us.addDummyNode(e,"root",{},"_root"),i=function(e){var t={};function i(r,s){var n=e.children(r);n&&n.length&&n.forEach((e=>i(e,s+1))),t[r]=s}return e.children().forEach((e=>i(e,1))),t}(e),r=Math.max(...Object.values(i))-1,s=2*r+1;e.graph().nestingRoot=t,e.edges().forEach((t=>e.edge(t).minlen*=s));let n=function(e){return e.edges().reduce(((t,i)=>t+e.edge(i).weight),0)}(e)+1;e.children().forEach((a=>ps(e,t,s,n,r,i,a))),e.graph().nodeRankFactor=s},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach((t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}};function ps(e,t,i,r,s,n,a){let o=e.children(a);if(!o.length)return void(a!==t&&e.setEdge(t,a,{weight:0,minlen:i}));let l=us.addBorderNode(e,"_bt"),h=us.addBorderNode(e,"_bb"),c=e.node(a);e.setParent(l,a),c.borderTop=l,e.setParent(h,a),c.borderBottom=h,o.forEach((o=>{ps(e,t,i,r,s,n,o);let c=e.node(o),d=c.borderTop?c.borderTop:o,u=c.borderBottom?c.borderBottom:o,_=c.borderTop?r:2*r,p=d!==u?1:s-n[a]+1;e.setEdge(l,d,{weight:_,minlen:p,nestingEdge:!0}),e.setEdge(u,h,{weight:_,minlen:p,nestingEdge:!0})})),e.parent(a)||e.setEdge(t,l,{weight:0,minlen:s+n[a]})}let gs=Ar;var fs=function(e){e.children().forEach((function t(i){let r=e.children(i),s=e.node(i);if(r.length&&r.forEach(t),s.hasOwnProperty("minRank")){s.borderLeft=[],s.borderRight=[];for(let t=s.minRank,r=s.maxRank+1;t<r;++t)ys(e,"borderLeft","_bl",i,s,t),ys(e,"borderRight","_br",i,s,t)}}))};function ys(e,t,i,r,s,n){let a={width:0,height:0,rank:n,borderType:t},o=s[t][n-1],l=gs.addDummyNode(e,"border",a,i);s[t][n]=l,e.setParent(l,r),o&&e.setEdge(o,l,{weight:1})}function ms(e){e.nodes().forEach((t=>bs(e.node(t)))),e.edges().forEach((t=>bs(e.edge(t))))}function bs(e){let t=e.width;e.width=e.height,e.height=t}function xs(e){e.y=-e.y}function vs(e){let t=e.x;e.x=e.y,e.y=t}let ws=Ar;var Es=function(e){let t={},i=e.nodes().filter((t=>!e.children(t).length)),r=Math.max(...i.map((t=>e.node(t).rank))),s=ws.range(r+1).map((()=>[]));function n(i){if(t[i])return;t[i]=!0;let r=e.node(i);s[r.rank].push(i),e.successors(i).forEach(n)}return i.sort(((t,i)=>e.node(t).rank-e.node(i).rank)).forEach(n),s};let As=Ar.zipObject;function Cs(e,t,i){let r=As(i,i.map(((e,t)=>t))),s=t.flatMap((t=>e.outEdges(t).map((t=>({pos:r[t.w],weight:e.edge(t).weight}))).sort(((e,t)=>e.pos-t.pos)))),n=1;for(;n<i.length;)n<<=1;let a=2*n-1;n-=1;let o=new Array(a).fill(0),l=0;return s.forEach((e=>{let t=e.pos+n;o[t]+=e.weight;let i=0;for(;t>0;)t%2&&(i+=o[t+1]),t=t-1>>1,o[t]+=e.weight;l+=e.weight*i})),l}let Ts=Ar;let Rs=Ar;function ks(e,t,i){let r;for(;t.length&&(r=t[t.length-1]).i<=i;)t.pop(),e.push(r.vs),i++;return i}let Ss=function(e,t=[]){return t.map((t=>{let i=e.inEdges(t);if(i.length){let r=i.reduce(((t,i)=>{let r=e.edge(i),s=e.node(i.v);return{sum:t.sum+r.weight*s.order,weight:t.weight+r.weight}}),{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}return{v:t}}))},Os=function(e,t){let i={};return e.forEach(((e,t)=>{let r=i[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(r.barycenter=e.barycenter,r.weight=e.weight)})),t.edges().forEach((e=>{let t=i[e.v],r=i[e.w];void 0!==t&&void 0!==r&&(r.indegree++,t.out.push(i[e.w]))})),function(e){let t=[];function i(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let i=0,r=0;e.weight&&(i+=e.barycenter*e.weight,r+=e.weight);t.weight&&(i+=t.barycenter*t.weight,r+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=i/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function r(t){return i=>{i.in.push(t),0==--i.indegree&&e.push(i)}}for(;e.length;){let s=e.pop();t.push(s),s.in.reverse().forEach(i(s)),s.out.forEach(r(s))}return t.filter((e=>!e.merged)).map((e=>Ts.pick(e,["vs","i","barycenter","weight"])))}(Object.values(i).filter((e=>!e.indegree)))},Is=function(e,t){let i=Rs.partition(e,(e=>e.hasOwnProperty("barycenter"))),r=i.lhs,s=i.rhs.sort(((e,t)=>t.i-e.i)),n=[],a=0,o=0,l=0;r.sort((h=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:h?t.i-e.i:e.i-t.i)),l=ks(n,s,l),r.forEach((e=>{l+=e.vs.length,n.push(e.vs),a+=e.barycenter*e.weight,o+=e.weight,l=ks(n,s,l)}));var h;let c={vs:n.flat(!0)};o&&(c.barycenter=a/o,c.weight=o);return c};var Ns=function e(t,i,r,s){let n=t.children(i),a=t.node(i),o=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,h={};o&&(n=n.filter((e=>e!==o&&e!==l)));let c=Ss(t,n);c.forEach((i=>{if(t.children(i.v).length){let o=e(t,i.v,r,s);h[i.v]=o,o.hasOwnProperty("barycenter")&&(a=o,void 0!==(n=i).barycenter?(n.barycenter=(n.barycenter*n.weight+a.barycenter*a.weight)/(n.weight+a.weight),n.weight+=a.weight):(n.barycenter=a.barycenter,n.weight=a.weight))}var n,a}));let d=Os(c,r);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(d,h);let u=Is(d,s);if(o&&(u.vs=[o,u.vs,l].flat(!0),t.predecessors(o).length)){let e=t.node(t.predecessors(o)[0]),i=t.node(t.predecessors(l)[0]);u.hasOwnProperty("barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+e.order+i.order)/(u.weight+2),u.weight+=2}return u};let Ls=pr.Graph,Vs=Ar;var Ps=function(e,t,i){let r=function(e){var t;for(;e.hasNode(t=Vs.uniqueId("_root")););return t}(e),s=new Ls({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((t=>e.node(t)));return e.nodes().forEach((n=>{let a=e.node(n),o=e.parent(n);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(s.setNode(n),s.setParent(n,o||r),e[i](n).forEach((t=>{let i=t.v===n?t.w:t.v,r=s.edge(i,n),a=void 0!==r?r.weight:0;s.setEdge(i,n,{weight:e.edge(t).weight+a})})),a.hasOwnProperty("minRank")&&s.setNode(n,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))})),s};let Ms=Es,Ds=function(e,t){let i=0;for(let r=1;r<t.length;++r)i+=Cs(e,t[r-1],t[r]);return i},Bs=Ns,Gs=Ps,Fs=function(e,t,i){let r,s={};i.forEach((i=>{let n,a,o=e.parent(i);for(;o;){if(n=e.parent(o),n?(a=s[n],s[n]=o):(a=r,r=o),a&&a!==o)return void t.setEdge(a,o);o=n}}))},zs=pr.Graph,Hs=Ar;var js=function e(t,i){if(i&&"function"==typeof i.customOrder)return void i.customOrder(t,e);let r=Hs.maxRank(t),s=Us(t,Hs.range(1,r+1),"inEdges"),n=Us(t,Hs.range(r-1,-1,-1),"outEdges"),a=Ms(t);if(Ys(t,a),i&&i.disableOptimalOrderHeuristic)return;let o,l=Number.POSITIVE_INFINITY;for(let e=0,i=0;i<4;++e,++i){Ws(e%2?s:n,e%4>=2),a=Hs.buildLayerMatrix(t);let r=Ds(t,a);r<l&&(i=0,o=Object.assign({},a),l=r)}Ys(t,o)};function Us(e,t,i){return t.map((function(t){return Gs(e,t,i)}))}function Ws(e,t){let i=new zs;e.forEach((function(e){let r=e.graph().root,s=Bs(e,r,i,t);s.vs.forEach(((t,i)=>e.node(t).order=i)),Fs(e,i,s.vs)}))}function Ys(e,t){Object.values(t).forEach((t=>t.forEach(((t,i)=>e.node(t).order=i))))}let Xs=pr.Graph,qs=Ar;var Ks=function(e){let t,i=qs.buildLayerMatrix(e),r=Object.assign(Zs(e,i),$s(e,i)),s={};["u","d"].forEach((n=>{t="u"===n?i:Object.values(i).reverse(),["l","r"].forEach((i=>{"r"===i&&(t=t.map((e=>Object.values(e).reverse())));let a=("u"===n?e.predecessors:e.successors).bind(e),o=en(e,t,r,a),l=tn(e,t,o.root,o.align,"r"===i);"r"===i&&(l=qs.mapValues(l,(e=>-e))),s[n+i]=l}))}));let n=rn(e,s);return sn(s,n),nn(s,e.graph().align)};function Zs(e,t){let i={};return t.length&&t.reduce((function(t,r){let s=0,n=0,a=t.length,o=r[r.length-1];return r.forEach(((t,l)=>{let h=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),c=h?e.node(h).order:a;(h||t===o)&&(r.slice(n,l+1).forEach((t=>{e.predecessors(t).forEach((r=>{let n=e.node(r),a=n.order;!(a<s||c<a)||n.dummy&&e.node(t).dummy||Js(i,r,t)}))})),n=l+1,s=c)})),r})),i}function $s(e,t){let i={};function r(t,r,s,n,a){let o;qs.range(r,s).forEach((r=>{o=t[r],e.node(o).dummy&&e.predecessors(o).forEach((t=>{let r=e.node(t);r.dummy&&(r.order<n||r.order>a)&&Js(i,t,o)}))}))}return t.length&&t.reduce((function(t,i){let s,n=-1,a=0;return i.forEach(((o,l)=>{if("border"===e.node(o).dummy){let t=e.predecessors(o);t.length&&(s=e.node(t[0]).order,r(i,a,l,n,s),a=l,n=s)}r(i,a,i.length,s,t.length)})),i})),i}function Js(e,t,i){if(t>i){let e=t;t=i,i=e}let r=e[t];r||(e[t]=r={}),r[i]=!0}function Qs(e,t,i){if(t>i){let e=t;t=i,i=e}return!!e[t]&&e[t].hasOwnProperty(i)}function en(e,t,i,r){let s={},n={},a={};return t.forEach((e=>{e.forEach(((e,t)=>{s[e]=e,n[e]=e,a[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let o=r(e);if(o.length){o=o.sort(((e,t)=>a[e]-a[t]));let r=(o.length-1)/2;for(let l=Math.floor(r),h=Math.ceil(r);l<=h;++l){let r=o[l];n[e]===e&&t<a[r]&&!Qs(i,e,r)&&(n[r]=e,n[e]=s[e]=s[r],t=a[r])}}}))})),{root:s,align:n}}function tn(e,t,i,r,s){let n={},a=function(e,t,i,r){let s=new Xs,n=e.graph(),a=function(e,t,i){return(r,s,n)=>{let a,o=r.node(s),l=r.node(n),h=0;if(h+=o.width/2,o.hasOwnProperty("labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(h+=i?a:-a),a=0,h+=(o.dummy?t:e)/2,h+=(l.dummy?t:e)/2,h+=l.width/2,l.hasOwnProperty("labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(h+=i?a:-a),a=0,h}}(n.nodesep,n.edgesep,r);return t.forEach((t=>{let r;t.forEach((t=>{let n=i[t];if(s.setNode(n),r){var o=i[r],l=s.edge(o,n);s.setEdge(o,n,Math.max(a(e,t,r),l||0))}r=t}))})),s}(e,t,i,s),o=s?"borderLeft":"borderRight";function l(e,t){let i=a.nodes(),r=i.pop(),s={};for(;r;)s[r]?e(r):(s[r]=!0,i.push(r),i=i.concat(t(r))),r=i.pop()}return l((function(e){n[e]=a.inEdges(e).reduce(((e,t)=>Math.max(e,n[t.v]+a.edge(t))),0)}),a.predecessors.bind(a)),l((function(t){let i=a.outEdges(t).reduce(((e,t)=>Math.min(e,n[t.w]-a.edge(t))),Number.POSITIVE_INFINITY),r=e.node(t);i!==Number.POSITIVE_INFINITY&&r.borderType!==o&&(n[t]=Math.max(n[t],i))}),a.successors.bind(a)),Object.keys(r).forEach((e=>n[e]=n[i[e]])),n}function rn(e,t){return Object.values(t).reduce(((t,i)=>{let r=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;Object.entries(i).forEach((([t,i])=>{let n=function(e,t){return e.node(t).width}(e,t)/2;r=Math.max(i+n,r),s=Math.min(i-n,s)}));const n=r-s;return n<t[0]&&(t=[n,i]),t}),[Number.POSITIVE_INFINITY,null])[1]}function sn(e,t){let i=Object.values(t),r=Math.min(...i),s=Math.max(...i);["u","d"].forEach((i=>{["l","r"].forEach((n=>{let a=i+n,o=e[a];if(o===t)return;let l=Object.values(o),h=r-Math.min(...l);"l"!==n&&(h=s-Math.max(...l)),h&&(e[a]=qs.mapValues(o,(e=>e+h)))}))}))}function nn(e,t){return qs.mapValues(e.ul,((i,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map((e=>e[r])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}let an=Ar,on=Ks;let ln=Lr,hn=Pr,cn=ls,dn=Ar.normalizeRanks,un=ds,_n=Ar.removeEmptyRanks,pn=_s,gn=fs,fn={adjust:function(e){let t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||ms(e)},undo:function(e){let t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){e.nodes().forEach((t=>xs(e.node(t)))),e.edges().forEach((t=>{let i=e.edge(t);i.points.forEach(xs),i.hasOwnProperty("y")&&xs(i)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){e.nodes().forEach((t=>vs(e.node(t)))),e.edges().forEach((t=>{let i=e.edge(t);i.points.forEach(vs),i.hasOwnProperty("x")&&vs(i)}))}(e),ms(e))}},yn=js,mn=function(e){(function(e){let t=an.buildLayerMatrix(e),i=e.graph().ranksep,r=0;t.forEach((t=>{const s=t.reduce(((t,i)=>{const r=e.node(i).height;return t>r?t:r}),0);t.forEach((t=>e.node(t).y=r+s/2)),r+=s+i}))})(e=an.asNonCompoundGraph(e)),Object.entries(on(e)).forEach((([t,i])=>e.node(t).x=i))},bn=Ar,xn=pr.Graph;var vn=function(e,t){let i=t&&t.debugTiming?bn.time:bn.notime;i("layout",(()=>{let r=i(" buildLayoutGraph",(()=>function(e){let t=new xn({multigraph:!0,compound:!0}),i=In(e.graph());return t.setGraph(Object.assign({},En,On(i,wn),bn.pick(i,An))),e.nodes().forEach((i=>{const r=On(In(e.node(i)),Cn);Object.keys(Tn).forEach((e=>{void 0===r[e]&&(r[e]=Tn[e])})),t.setNode(i,r),t.setParent(i,e.parent(i))})),e.edges().forEach((i=>{let r=In(e.edge(i));t.setEdge(i,Object.assign({},kn,On(r,Rn),bn.pick(r,Sn)))})),t}(e)));i(" runLayout",(()=>function(e,t,i){t(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((i=>{let r=e.edge(i);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(e))),t(" removeSelfEdges",(()=>function(e){e.edges().forEach((t=>{if(t.v===t.w){var i=e.node(t.v);i.selfEdges||(i.selfEdges=[]),i.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e))),t(" acyclic",(()=>ln.run(e))),t(" nestingGraph.run",(()=>pn.run(e))),t(" rank",(()=>cn(bn.asNonCompoundGraph(e)))),t(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let i=e.edge(t);if(i.width&&i.height){let i=e.node(t.v),r={rank:(e.node(t.w).rank-i.rank)/2+i.rank,e:t};bn.addDummyNode(e,"edge-proxy",r,"_ep")}}))}(e))),t(" removeEmptyRanks",(()=>_n(e))),t(" nestingGraph.cleanup",(()=>pn.cleanup(e))),t(" normalizeRanks",(()=>dn(e))),t(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((i=>{let r=e.node(i);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))})),e.graph().maxRank=t}(e))),t(" removeEdgeLabelProxies",(()=>function(e){e.nodes().forEach((t=>{let i=e.node(t);"edge-proxy"===i.dummy&&(e.edge(i.e).labelRank=i.rank,e.removeNode(t))}))}(e))),t(" normalize.run",(()=>hn.run(e))),t(" parentDummyChains",(()=>un(e))),t(" addBorderSegments",(()=>gn(e))),t(" order",(()=>yn(e,i))),t(" insertSelfEdges",(()=>function(e){var t=bn.buildLayerMatrix(e);t.forEach((t=>{var i=0;t.forEach(((t,r)=>{var s=e.node(t);s.order=r+i,(s.selfEdges||[]).forEach((t=>{bn.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:s.rank,order:r+ ++i,e:t.e,label:t.label},"_se")})),delete s.selfEdges}))}))}(e))),t(" adjustCoordinateSystem",(()=>fn.adjust(e))),t(" position",(()=>mn(e))),t(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var i=e.node(t);if("selfedge"===i.dummy){var r=e.node(i.e.v),s=r.x+r.width/2,n=r.y,a=i.x-s,o=r.height/2;e.setEdge(i.e,i.label),e.removeNode(t),i.label.points=[{x:s+2*a/3,y:n-o},{x:s+5*a/6,y:n-o},{x:s+a,y:n},{x:s+5*a/6,y:n+o},{x:s+2*a/3,y:n+o}],i.label.x=i.x,i.label.y=i.y}}))}(e))),t(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let i=e.node(t),r=e.node(i.borderTop),s=e.node(i.borderBottom),n=e.node(i.borderLeft[i.borderLeft.length-1]),a=e.node(i.borderRight[i.borderRight.length-1]);i.width=Math.abs(a.x-n.x),i.height=Math.abs(s.y-r.y),i.x=n.x+i.width/2,i.y=r.y+i.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(e))),t(" normalize.undo",(()=>hn.undo(e))),t(" fixupEdgeLabelCoords",(()=>function(e){e.edges().forEach((t=>{let i=e.edge(t);if(i.hasOwnProperty("x"))switch("l"!==i.labelpos&&"r"!==i.labelpos||(i.width-=i.labeloffset),i.labelpos){case"l":i.x-=i.width/2+i.labeloffset;break;case"r":i.x+=i.width/2+i.labeloffset}}))}(e))),t(" undoCoordinateSystem",(()=>fn.undo(e))),t(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,i=0,r=Number.POSITIVE_INFINITY,s=0,n=e.graph(),a=n.marginx||0,o=n.marginy||0;function l(e){let n=e.x,a=e.y,o=e.width,l=e.height;t=Math.min(t,n-o/2),i=Math.max(i,n+o/2),r=Math.min(r,a-l/2),s=Math.max(s,a+l/2)}e.nodes().forEach((t=>l(e.node(t)))),e.edges().forEach((t=>{let i=e.edge(t);i.hasOwnProperty("x")&&l(i)})),t-=a,r-=o,e.nodes().forEach((i=>{let s=e.node(i);s.x-=t,s.y-=r})),e.edges().forEach((i=>{let s=e.edge(i);s.points.forEach((e=>{e.x-=t,e.y-=r})),s.hasOwnProperty("x")&&(s.x-=t),s.hasOwnProperty("y")&&(s.y-=r)})),n.width=i-t+a,n.height=s-r+o}(e))),t(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let i,r,s=e.edge(t),n=e.node(t.v),a=e.node(t.w);s.points?(i=s.points[0],r=s.points[s.points.length-1]):(s.points=[],i=a,r=n),s.points.unshift(bn.intersectRect(n,i)),s.points.push(bn.intersectRect(a,r))}))}(e))),t(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let i=e.edge(t);i.reversed&&i.points.reverse()}))}(e))),t(" acyclic.undo",(()=>ln.undo(e)))}(r,i,t))),i(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((i=>{let r=e.node(i),s=t.node(i);r&&(r.x=s.x,r.y=s.y,r.rank=s.rank,t.children(i).length&&(r.width=s.width,r.height=s.height))})),e.edges().forEach((i=>{let r=e.edge(i),s=t.edge(i);r.points=s.points,s.hasOwnProperty("x")&&(r.x=s.x,r.y=s.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,r)))}))};let wn=["nodesep","edgesep","ranksep","marginx","marginy"],En={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},An=["acyclicer","ranker","rankdir","align"],Cn=["width","height"],Tn={width:0,height:0},Rn=["minlen","weight","width","height","labeloffset"],kn={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Sn=["labelpos"];function On(e,t){return bn.mapValues(bn.pick(e,t),Number)}function In(e){var t={};return e&&Object.entries(e).forEach((([e,i])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=i})),t}let Nn=Ar,Ln=pr.Graph;var Vn={graphlib:pr,layout:vn,debug:{debugOrdering:function(e){let t=Nn.buildLayerMatrix(e),i=new Ln({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach((t=>{i.setNode(t,{label:t}),i.setParent(t,"layer"+e.node(t).rank)})),e.edges().forEach((e=>i.setEdge(e.v,e.w,{},e.name))),t.forEach(((e,t)=>{let r="layer"+t;i.setNode(r,{rank:"same"}),e.reduce(((e,t)=>(i.setEdge(e,t,{style:"invis"}),t)))})),i}},util:{time:Ar.time,notime:Ar.notime},version:"1.1.3"};class Pn extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=xe(e.children[0]);if(!r)continue;var i=new Vn.graphlib.Graph;i.setGraph({edgesep:t._edgeSep}),i.setDefaultEdgeLabel((function(){return{}})),i.graph().rankdir=this._getDagreDirection(t.direction);let s=new Map;for(let t of e.children){let e=t.dataScope.getAttrVal(we);s.set(e,e+""),i.setNode(e,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let e of r.linkList)i.setEdge(e.source,e.target);Vn.layout(i);const n={};let a=Math.min(...i.nodes().map((e=>i.node(e).y))),o=Math.min(...i.nodes().map((e=>i.node(e).x))),l=t.left-o,h=t.top-a;for(const e of i.nodes())n[e]={x:i.node(e).x+l,y:i.node(e).y+h};for(let t of e.children){let e=t.dataScope.getAttrVal(we);je(t,n[s.get(e)].x-t.x,n[s.get(e)].y-t.y)}}let r=z(e,!0);for(let e of r)f(e)}_getDagreDirection(e){switch(e){case Q.Left2Right:return"LR";case Q.Right2Left:return"RL";case Q.Top2Bottom:return"TB";case Q.Bottom2Top:return"BT"}}}class Mn extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let i=me(e.children[0]);if(!i)continue;let s=r.hierarchy(i._data),n=Math.max(...e.children.map((e=>e.bounds.width))),a=Math.max(...e.children.map((e=>e.bounds.height))),o=t.orientation==J.HORIZONTAL?[t.height,t.width]:[t.width,t.height],l=r.tree().nodeSize([n,a]).size(o)(s);this._apply(l,t,e)}f(e)}_apply(e,t,i){let r,s,n=i.children.filter((t=>t.dataScope.getAttrVal(we)==e.data[we]))[0];switch(t.orientation){case J.HORIZONTAL:r=e.y+t.left,s=e.x+t.top;break;case J.VERTICAL:r=e.x+t.left,s=t.top+e.y}if(je(n,r-n.x,s-n.y),e.children&&e.children.length>0)for(let r of e.children)this._apply(r,t,i)}}class Dn extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=this._inputVars.filter((e=>e.type===Ie.PROPERTY&&e.property===rt.CHILDREN_ORDER))[0].element,i=t.layout,s=i.width?i.width:t.bounds.width,n=i.height?i.height:t.bounds.height,a=void 0===i.top?t.bounds.top:i.top,o=void 0===i.left?t.bounds.left:i.left,l=r.hierarchy(t).sum((e=>e.type===Dt.Rect?e.width*e.height:0));r.treemap().size([s,n])(l),this._apply(l,o,a);let h=z(e,!0);for(let e of h)f(e)}_apply(e,t,i){if(e.data.type==Dt.Collection&&e.children)for(let r of e.children)this._apply(r,t,i);else e.data.type==Dt.Rect&&(e.data.resize(e.x1-e.x0,e.y1-e.y0),je(e.data,e.x0+t-e.data.left,e.y0+i-e.data.top))}}class Bn extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){if(!e.layout)continue;if(0===e.children.length)continue;let t=me(e.children[0]);if(!t)continue;let i={};for(let t of e.children)i[t.dataScope.getAttrVal(we)]=t;e.children[0].type===Dt.Rect?this._layoutRects(t.getRoot(),t,i):this._layoutArcs(t.getRoot(),t,i)}f(e)}_layoutArcs(e,t,i){let r=t.getChildren(e);if(0===r.length)return;let s=i[e[we]],n=!s||s.type!=Dt.Arc&&s.type!=Dt.Pie?60:s.startAngle;for(let e=0;e<r.length;e++){let s=r[e],a=i[s[we]];if(a.type===Dt.Arc){let e=ue(n+a.angle);a.setAngles(n,e),n=e}this._layoutArcs(s,t,i)}}_layoutRects(e,t,i){let r=t.getChildren(e);if(0===r.length)return;let s,n,a=i[e[we]];this._direction,Q.Top2Bottom,s=a.left,n=a.bottom;for(let e=0;e<r.length;e++){let a=r[e],o=i[a[we]];je(o,s-o.left,n-o.top),s+=o.width,this._layoutRects(a,t,i)}}}class Gn extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=this.inputVars[0],i=e.conditionalEncoding,r=t.context,s=e.result,n=i.responderComponent;s.clear();let a=Array.isArray(n)?n:[n];if(i.evalFunction)for(let e of a){O(e).forEach((e=>s.setValue(e.id,i.evalFunction(r,e))))}}}class Fn extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let i=360/e.children.length;for(let[r,s]of e.children.entries())je(s,t.x+t.radius-s.bounds.x,t.y-s.bounds.y),s._rotate=[r*i,t.x,t.y]}let i=z(e,!0);for(let e of i)f(e)}}class zn extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=O(e.parent);for(let i of t){let t=i.layout;if(!t)continue;let s=t._tree?t._tree._data:me(i.children[0])._data,n=r.hierarchy(s);if(t.isRadial()){n=r.cluster().size([ce(t.angleExtent),t.radius])(n),t._d3Root=n;const e=new Map(n.descendants().map((e=>[e.data[we],[e.x,e.y]])));for(let r of i.children){let i=r.dataScope.getAttrVal(we);je(r,t.x-r.bounds.x,t.y-e.get(i)[1]-r.bounds.y),r._rotate=[de(e.get(i)[0]),t.x,t.y]}}else if(t.orientation===J.VERTICAL){!t.width||t.width;let s=t.height?t.height:600;n=r.cluster().nodeSize([e.bounds.width+1,s/(n.height+1)])(n),t._d3Root=n;const a=new Map(n.descendants().map((e=>[e.data[we],[e.x,e.y]])));let o=1/0,l=-o;n.each((e=>{e.x>l&&(l=e.x),e.x<o&&(o=e.x)})),t._x0=o;for(let e of i.children){let i=e.dataScope.getAttrVal(we);je(e,a.get(i)[0]-o+t.left-e.bounds.x,a.get(i)[1]+t.top-e.bounds.y)}}else if(t.orientation===J.HORIZONTAL){!t.width||t.width;let s=t.height?t.height:600;n=r.cluster().nodeSize([e.bounds.height,s/(n.height+1)])(n),t._d3Root=n;const a=new Map(n.descendants().map((e=>[e.data[we],[e.x,e.y]])));let o=1/0,l=-o;n.each((e=>{e.x>l&&(l=e.x),e.x<o&&(o=e.x)})),t._x0=o;for(let e of i.children){let i=e.dataScope.getAttrVal(we);je(e,a.get(i)[1]+t.left-e.bounds.x,a.get(i)[0]-o+t.top-e.bounds.y)}}}let i=z(e,!0);for(let e of i)f(e)}}class Hn extends Oe{constructor(e,t){super(e),this._cond=t}get context(){return this._cond}}class jn extends X{constructor(e,t,i){super(e),this._fn=t,this._compnt=i}run(){super.run();let e=this.inputVars.find((e=>e instanceof Hn));this.outputVar,this._fn(void 0,e.context,this._compnt)}}class Un extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=this.inputVars.find((e=>e instanceof qt)),i=e.encodings[0].dataTable.getAttributeType(t.attribute),r={};for(let t of e.encodings){let e=this._computeAttrValues(t,i);Object.assign(r,e)}e.attrValues=r}_computeAttrValues(e,t){let i=O(e.element),r={};if(e.element.type===Dt.Area&&["width","height","fillGradient"].indexOf(e.channel)>=0)for(let t of i)for(let i of t.vertices)r[i.id]=ge(i).aggregateNumericalAttribute(e.attribute,e.aggregator);else switch(t){case Ae.Boolean:break;case Ae.Date:for(let t of i)r[t.id]=ge(t).getAttrVal(e.attribute);break;case Ae.String:try{if("count"==e.aggregator)for(let t of i)r[t.id]=ge(t).getAttributeValues(e.attribute).length;else for(let t of i)r[t.id]=ge(t).getAttrVal(e.attribute)}catch(t){throw new Error("Cannot bind "+this.channel+" to "+e.attribute+" : "+t)}break;default:if(e.attribute.startsWith("parent.")||e.attribute.startsWith("child.")){let t=e.dataTable.tree.nodeTable,s=e.attribute.split(".")[0],n=e.attribute.split(".")[1];for(let e of i){let i=ge(e).getAttrVal(s);r[e.id]=new pe(t).cross(we,i).getAttrVal(n)}}else for(let t of i)r[t.id]=ge(t).aggregateNumericalAttribute(e.attribute,e.aggregator)}if(e.transform)for(let t of i)r[t.id]=e.transform(r[t.id],t);return e.attrValues=r,r}}class Wn extends Oe{constructor(e,t,i){super(e),this._dataset=i,this._predicate=t}get dataset(){return this._dataset}get predicate(){return this._predicate}}class Yn{constructor(){this._variables={},this._operators={},this._edges=[]}toJSON(){const e=this._edges.map((e=>({from:e.fromNode.id,to:e.toNode.id,isDirected:e.isDirected}))),t={};for(const e in this._variables)t[e]=Object.values(this._variables[e]).map((e=>{let t={id:e.id,type:e.type,incoming:e.incomingEdges.map((e=>e.id)),outgoing:e.outgoingEdges.map((e=>e.id)),undirected:e.undirectedEdges.map((e=>e.id))};return"ChannelVar"===e.type?(t.channel=e.channel,t.element=e.element):"BoundsVar"===e.type||"DataScopeVar"===e.type?t.element=e.element:"dataValue"===e.type?(t.scale=e.scale,t.attrValues=e.attrValues):"FieldVar"===e.type?(t.field=e.field,t.dataset=e.dataset):"PropertyVar"===e.type?(t.property=e.property,t.element=e.element):t.scale=e.scale,t}));const i={};for(const e in this._operators)i[e]=Object.values(this._operators[e]).map((e=>{let t={id:e.id,type:e.type,inputVars:e.inputVars.map((e=>e.id)),outputVar:e.outputVar?e.outputVar.id:null};return e.type===q.DOMAIN_BUILDER?t.aggregator=e.aggregator:e.type===q.SCALE_BUILDER&&(t.channel=e.channel),t}));return{edges:e,variables:t,operators:i}}getVariable(e,...t){if(Object.values(Ie).indexOf(e)<0)throw console.log(e),new Error("Variable Type Not Known");let i=this.findVariable(e,t);if(i)return i;switch(e){case Ie.CHANNEL:i=new Ne(e,t[0],t[1]),"vertex"!=t[1].type&&"segment"!=t[1].type||this._connectPathElement2Size(t[1],i);break;case Ie.PROPERTY:i=new et(e,t[0],t[1]);break;case Ie.ATTRIBUTE:i=new qt(e,t[0],t[1]);break;case Ie.ITEMS:i=new Wn(e,t[0],t[1]);break;case Ie.ATTR_VALUE:i=new Qt(e,t[0]);break;case Ie.DATASCOPE:i=new Wt(e,t[0]);break;case Ie.BOUNDS:i=new Ut(e,t[0]);break;case Ie.SCALE:i=new $e(e,t[0]);break;case Ie.AFFIXATION:i=new xi(e,t[0]);break;case Ie.ALIGNMENT:i=new Ri(e,t[0]);break;case Ie.EVT_CTX:i=new Hn(e,t[0],t[1]);break;case Ie.CONDITION_RESULT:i=new Je(e,t[0],t[1])}return e in this._variables||(this._variables[e]={}),this._variables[e][i.id]=i,i}_connectPathElement2Size(e,t){let i=e.parent,r=t.channel,s=this.findVariable(Ie.CHANNEL,["x"===r?"width":"height",i]);if(s){let e=s.incomingDataflow;e||(e=this.createOneWayDependency(q.CONDUIT)),this.connect(t,e),this.connect(e,s)}}findIncomingDataflowOperator(e,t){return t.incomingDataflow&&t.incomingDataflow.type===e?t.incomingDataflow:void 0}getIncomingDataflowOperator(e,t){let i=this.findIncomingDataflowOperator(e,t);return i||this.createOneWayDependency(e)}getOutgoingDataflowOperator(e,t){for(let i of t.outgoingEdges)if(i.toNode instanceof X&&i.toNode.type===e)return i.toNode;return this.createOneWayDependency(e)}createOneWayDependency(e,...t){if(Object.values(q).indexOf(e)<0)throw new Error("Dependency Type Not Known");let i;switch(e){case q.EVAL_BBOX:i=new ti(e);break;case q.AFFIXER:i=new bi(e);break;case q.DATA_EXTRACTOR:i=new Un(e,t[0]);break;case q.SCALE_BUILDER:i=new ei(e,t[0]);break;case q.ENCODER:i=new Qe(e,t[0]);break;case q.AXIS_PATH_PLACER:i=new ci(e);break;case q.AXIS_TICKS_PLACER:i=new di(e);break;case q.AXIS_LABELS_PLACER:i=new ui(e);break;case q.AXIS_TITLE_PLACER:i=new Ci(e);break;case q.LINK_PLACER:i=new Si(e);break;case q.GRID_LAYOUT:i=new _i(e);break;case q.STACK_LAYOUT:i=new gi(e);break;case q.PACK_LAYOUT:i=new Ai(e);break;case q.FORCE_LAYOUT:i=new ki(e);break;case q.DIRECTED_LAYOUT:i=new Pn(e);break;case q.TIDY_TREE_LAYOUT:i=new Mn(e);break;case q.TREEMAP_LAYOUT:i=new Dn(e);break;case q.STRATA_LAYOUT:i=new Bn(e);break;case q.CIRCULAR_LAYOUT:i=new Fn(e);break;case q.CLUSTER_LAYOUT:i=new zn(e);break;case q.GRIDLINES_PLACER:i=new pi(e);break;case q.BIN_TRANSFORMER:i=new yi(e);break;case q.FILTER_TRANSFORMER:i=new mi(e);break;case q.KDE_TRANSFORMER:i=new vi(e);break;case q.TARGET_EVALUATOR:i=new Gn(e);break;case q.TARGET_UPDATER:i=new jn(e,t[0],t[1]);break;case q.CONDUIT:default:i=new fi(e)}return e in this._operators||(this._operators[e]={}),this._operators[e][i.id]=i,i}createMultiWayDependency(e){if(Object.values(q).indexOf(e)<0)throw new Error("Dependency Type Not Known");let t;return q.ALIGNER,t=new Ti(e),e in this._operators||(this._operators[e]={}),this._operators[e][t.id]=t,t}connect(e,t,i=!0){if(e instanceof Oe&&t instanceof X){if(!t.inputVars.includes(e)){const r=new Xt(e,t,i);this._edges.push(r),e.outgoingEdges.push(r),t.inputVars.push(e)}}else if(e instanceof X&&t instanceof Oe){if(!e.outputVars.includes(t)){const r=new Xt(e,t,i);this._edges.push(r),e.outputVars.push(t),t.incomingEdges.push(r)}}else if(e instanceof Oe&&t instanceof Yt){if(!t.vars.includes(e)){const i=new Xt(e,t,!1);this._edges.push(i),t.vars.push(e),t.edges.push(e),e.undirectedEdges.push(i)}}else{if(!(e instanceof Yt&&t instanceof Oe))throw new Error("An edge must connect a variable and an operator.");if(!e.vars.includes(t)){const i=new Xt(t,e,!1);this._edges.push(i),e.vars.push(t),e.edges.push(t),t.undirectedEdges.push(i)}}}disconnectChannelVarFromBBoxOperator(e){let t=this.getOutgoingDataflowOperator(q.EVAL_BBOX,e),i=e.outgoingEdges.find((i=>i.fromNode===e&&i.toNode===t));i&&this.disconnect(e,t,i)}disconnect(e,t,i){if(e instanceof Oe&&t instanceof X){let r=e.outgoingEdges.findIndex((e=>e===i));r>=0&&(this._edges.splice(this._edges.indexOf(i),1),e.outgoingEdges.splice(r,1));let s=t.inputVars.findIndex((t=>t==e));s>=0&&t.inputVars.splice(s,1)}else if(e instanceof X&&t instanceof Oe){let r=t.incomingEdges.findIndex((e=>e===i));r>=0&&(this._edges.splice(this._edges.indexOf(i),1),t.incomingEdges.splice(r,1));let s=e.outputVars.findIndex((e=>e===t));s>=0&&e.outputVars.splice(s,1)}}deleteVariable(e){for(let t=e.incomingEdges.length-1;t>=0;t--){let i=e.incomingEdges[t],r=i.fromNode;this.disconnect(r,e,i),r.isIsolated()&&delete this._operators[r.type][r.id]}for(let t=e.outgoingEdges.length-1;t>=0;t--){let i=e.outgoingEdges[t],r=i.toNode;this.disconnect(e,r,i),r.isIsolated()&&delete this._operators[r.type][r.id]}delete this._variables[e.type][e.id]}deleteOperator(e){for(let t=e.outputVars.length-1;t>=0;t--){let i=e.outputVars[t],r=i.incomingEdges.find((t=>t.fromNode===e&&t.toNode===i));this.disconnect(e,i,r),i.isIsolated()&&delete this._variables[i.type][i.id]}for(let t=e.inputVars.length-1;t>=0;t--){let i=e.inputVars[t],r=i.outgoingEdges.find((t=>t.fromNode===i&&t.toNode===e));this.disconnect(i,e,r),i.isIsolated()&&delete this._variables[i.type][i.id]}delete this._operators[e.type][e.id]}addInteraction(e){}_dfs(e,t,i){if(e&&0!==e.outgoingEdges.length)for(let r of e.outgoingEdges)r.isDirected&&(t.push(r.toNode),this._dfs(r.toNode.outputVars[0],t.slice(),i));else i.push(t)}processChange(e,t,...i){let r=this.findVariable(e,i);if(r){for(let e of r.outgoingEdges)if(e.isDirected){let i=e.toNode;i.run();let r=i.outputVars;if(r.length>0){let e=r[0];switch(e.type){case Ie.ITEMS:this.processChange(e.type,t,e.predicate,e.dataset);break;case Ie.ATTRIBUTE:this.processChange(e.type,t,e.attribute,e.dataset);break;case Ie.BOUNDS:this.processChange(e.type,t,e.element);break;case Ie.CHANNEL:this.processChange(e.type,t,e.channel,e.element);break;case Ie.PROPERTY:this.processChange(e.type,t,e.property,e.element);break;case Ie.SCALE:case Ie.ATTR_VALUE:this.processChange(e.type,t,e.encodings[0]);break;case Ie.CONDITION_RESULT:this.processChange(e.type,t,e.result)}}}for(let e of r.undirectedEdges)t.push(e.operator)}else console.warn("Unable to find variables matching the described change: ",e,i)}findVariable(e,t){if(!(e in this._variables))return null;let i=Object.values(this._variables[e]);switch(e){case Ie.CHANNEL:return i.find((e=>e.channel==t[0]&&Be(e.element)==Be(t[1])));case Ie.PROPERTY:return i.find((e=>e.property==t[0]&&e.element==t[1]));case Ie.AFFIXATION:return i.find((e=>e.affixation==t[0]));case Ie.ATTRIBUTE:return i.find((e=>e.attribute==t[0]&&e.dataset==t[1]));case Ie.ITEMS:return i.find((e=>e.dataset==t[1]));case Ie.ATTR_VALUE:case Ie.SCALE:return i.find((e=>e.encodings.includes(t[0])));case Ie.EVT_CTX:return i.find((e=>e.context===t[0]));case Ie.CONDITION_RESULT:return i.find((e=>e.result==t[0]));case Ie.DATASCOPE:default:return t[0].classId?i.find((e=>Be(e.element)==Be(t[0]))):i.find((e=>e.element.id==t[0].id))}}findVariablesByElement(e){let t={};for(let i in this._variables){let r=Object.values(this._variables[i]).filter((t=>t.element&&Be(t.element)==Be(e)));r.length>0&&(t[i]=r)}return t}}function Xn(e){return!(!E(e)&&e.type!=Dt.Glyph||e.dataScope)||e.type===Dt.Collection&&e.firstChild.dataScope.numTuples>1}function qn(e,t,i,r){let s=r.getAttributeType(i);if(s!=Ae.String&&s!=Ae.Date&&s!=Ae.Integer)throw new Error("Repeat only works on a string or date attribute: "+i+" is "+s);if(!function(e){if(Array.isArray(e)){if(1===e.length)return Xn(e[0]);for(let t of e)if(!E(t)||t.dataScope)return!1;return!0}return Xn(e)}(t))throw new Error("The "+t.type+" is not repeatable");return function(e,t,i,r){let s=r.getAttributeSummary(i).unique.map((e=>t.dataScope?t.dataScope.cross(i,e):new pe(r).cross(i,e)));s=s.filter((e=>!e.isEmpty()));let n=Lt(e);n.dataScope=t.dataScope?t.dataScope.clone():new pe(r),n.addChild(t),t._refBounds||(t._refBounds=t.bounds.clone());for(let e=1;e<s.length;e++){let e=Pt(t);n.addChild(e)}return n.children.forEach(((e,t)=>e.dataScope=s[t])),n}(e,t,i,r)}class Kn{constructor(e,t,i,r,s){this._id="encoding_"+Gt(),this._elem=e,this._channel=t,this._attribute=i,this._table=s.table,this._aggregator=r,this._includeZero=s.includeZero,this._flipScale=s.flipScale,this._mapping=s.mapping,this._preferredRangeExtent=s.rangeExtent,this._preferredRangeStart=s.rangeStart,this._preferredDomain=s.domain,this._scaleType=s.scaleType,this._colorScheme=s.scheme,this._forLegend=s.forLegend,this._transform=s.transform,s.shareScale&&(this._baseEnc=s.shareScale),this._scales=[],this._elemGroups=[],this._elem2scale={},this._refElements=[],["width","height","radius","angle","thickness","radialDistance","strokeWidth","area"].indexOf(this._channel)>=0&&(this._includeZero=!0),this.initialize()}get id(){return this._id}initialize(){this._scales=[];let e=O(this._elem);if(this._elemGroups=[],"x"===this._channel||"y"===this._channel){let t=this._elem,i=B(t);if(i.layout&&i.layout.type==W.GRID){let e="x"===this._channel?i.layout.getElementsByCol(!0,t):i.layout.getElementsByRow(!0,t);for(let t of e)this._createScaleForElems(t)}else if("vertex"===this._elem.type&&(ze(this._elem.parent)||Fe(this._elem.parent))){let e=O(this._elem.parent).map((e=>I(this._elem,[e])));for(let t of e)this._createScaleForElems(t)}else this._createScaleForElems(e)}else if("angle"===this._channel){let t=e.reduce(((e,t)=>{const i=t.parent.id;return e[i]||(e[i]=[]),e[i].push(t),e}),{}),i=Object.values(t);for(let e of i)this._createScaleForElems(e)}else this._createScaleForElems(e)}_createScaleForElems(e){this._elemGroups.push(e);var t=function(e){if(e.scaleType)return new Kt(e.scaleType);if("text"===e.channel)return new Kt("ordinal");switch(e.dataTable.getAttributeType(e.attribute)){case Ae.Boolean:break;case Ae.Date:return new Kt("time");case Ae.String:if("count"==e.aggregator)return new Kt("linear");if(e.channel.indexOf("Color")>=0){let t={};return t.scheme=e.colorScheme?e.colorScheme:"schemeCategory10",new Kt("ordinalColor",t)}return"src"===e.channel?new Kt("ordinal"):new Kt("point");default:return["strokeColor","fillColor","fillGradient"].indexOf(e.channel)>=0?e.mapping?new Kt("linear"):new Kt("sequentialColor",{scheme:e.colorScheme}):new Kt("linear")}}(this);this._scales.push(t);for(let i of e)this._elem2scale[i.id]=t}getScale(e){return this._elem2scale[e.id]}getAttrValue(e,t,i){let s=this.getScale(t).invert(e,i),n=this._attribute;if(this.dataTable.getAttributeType(n)===Ae.Date){let e=O(t).map((e=>e.dataScope.getAttrVal(n)));return e.sort(((e,t)=>e-t)),e[r.bisectLeft(e,s)]}return s}getChannelValue(e,t){return this.getScale(t).map(e)}getElements(e){let t=this._scales.indexOf(e);return this._elemGroups[t]}get element(){return this._elem}get channel(){return this._channel}get attribute(){return this._attribute}get dataTable(){return this._table}get aggregator(){return this._aggregator}hasMultipleScales(){return this._scales.length>0}get scales(){return this._scales}getRangeStart(e){let t=this.getScale(e);return Math.min(...t.range)}getRangeExtent(e){return this.getScale(e).rangeExtent}get domain(){if(1===this._scales.length)return this._scales[0].domain;throw new Error("AttributeEncoding: multiple scales exist, specify element to get domain.")}get rangeExtent(){if(1===this._scales.length)return this._scales[0].rangeExtent;throw new Error("AttributeEncoding: multiple scales exist, specify element to get rangeExtent.")}get scaleType(){return this._scaleType}set scaleType(e){this._scaleType=e}getDomain(e){return this.getScale(e).domain}set domain(e){this._preferredDomain=e;for(let t of this._scales)t._scale.domain(e);for(let e of this._refElements)e instanceof li&&e.createTicksLabels({});this._elem.scene.onChange(Ie.ATTR_VALUE,this)}set rangeExtent(e){for(let t of this._scales)t.rangeExtent=e;for(let e of this._refElements)e instanceof li&&e.createTicksLabels({});this._elem.scene.onChange(Ie.PROPERTY,rt.RANGE_EXTENT,this)}get transform(){return this._transform}set transform(e){this._transform=e,this._elem.scene.onChange(Ie.PROPERTY,rt.TRANSFORM,this)}set includeZero(e){this._includeZero=e;for(let e of this._refElements)e instanceof li&&e.createTicksLabels({});this._elem.scene.onChange(Ie.PROPERTY,rt.INCLUDE_ZERO,this)}get includeZero(){return this._includeZero}set flipScale(e){this._flipScale=e,this._elem.scene.onChange(Ie.PROPERTY,rt.FLIP_SCALE,this)}get flipScale(){return this._flipScale}set mapping(e){this._mapping=e}get mapping(){return this._mapping}set colorScheme(e){this._colorScheme=e}get colorScheme(){return this._colorScheme}addRefElement(e){this._refElements.indexOf(e)<0&&this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}pan(e,t,i){let r=i||this._elem;r.scene.createMask(r);let s=this.getDomain(r),n=Math.min(...s),a=Math.max(...s),o="log"!==this._scales[0].type,l=this.getAttrValue(e,r,o)-this.getAttrValue(e+t,r,o);(o||n+l>0)&&(this.domain=[n+l,a+l])}zoom(e,t,i,r){let s=r||this._elem;s.scene.createMask(s);let n=this.getDomain(s),a=Math.min(...n),o=Math.max(...n),l="log"!==this._scales[0].type,h=this.getAttrValue(t,s,l),c=a-(h-a)*e*i,d=o+(o-h)*e*i;c!==d&&(!l&&c<=0||(this.domain=[c,d]))}}class Zn{constructor(){this._vals={},this._vals.elements=[]}set(e,t){this._vals[e]=t}get(e){return this._vals[e]}clear(){this._vals={},this._vals.elements=[]}}Object.freeze({X_INT:"xInterval",Y_INT:"yInterval"});class $n{constructor(e,t,i,r){this._respCompnt=t,this._responderEval=i,this._efxFn=r,this._evtCtx=e,this._evalResult=new Jt}get responderComponent(){return this._respCompnt}get eventContext(){return this._evtCtx}get evalResult(){return this._evalResult}get evalFunction(){return this._responderEval}get stylingFunction(){return this._efxFn}}class Jn extends se{constructor(e,t,i,r,s){super(s),this._type=Dt.Gridlines,this._id=this._type+Gt(),this._attribute=t,this._channel=e,this._scale=i,this._elems=r,this._args=s,"strokeColor"in s||(this.styles.strokeColor="#ddd"),"opacity"in s||(this.styles.opacity=.5),this.updateValues(),this._lines=[]}updateValues(){"values"in this._args?this._values=this._args.values:this._scale?this._values=ai(this._scale,this._channel,this._elems):this._values=this._elems.map((e=>e.dataScope.getAttrVal(this._attribute)))}get type(){return this._type}get id(){return this._id}getSVGPathData(){let e="";if("radialDistance"===this._channel)for(let t of this._lines)e+="M "+t.x+" "+t.y+" m -"+t.r+" 0 a "+t.r+" "+t.r+" 0 1 0 "+2*t.r+" 0 a "+t.r+" "+t.r+" 0 1 0 -"+2*t.r+" 0 ";else for(let t of this._lines)e+=["M",t.x1,t.y1].join(" ")+[" L",t.x2,t.y2].join(" ")+" ";return e}_updateBounds(){if("radialDistance"===this._channel){let e=this._lines.map((e=>new u(e.x-e.r,e.y-e.y,2*e.r,2*e.r)));this._bounds=_(e)}else{let e=this._lines.map((e=>e.x1)).concat(this._lines.map((e=>e.x2))),t=this._lines.map((e=>e.y1)).concat(this._lines.map((e=>e.y2))),i=Math.min(...e),r=Math.max(...e),s=Math.min(...t),n=Math.max(...t);this._bounds=new u(i,s,r-i,n-s)}}get elements(){return this._elems}get values(){return this._values}get channel(){return this._channel}get attribute(){return this._attribute}get scale(){return this._scale}get lines(){return this._lines}set lines(e){this._lines=e}}class Qn extends U{constructor(e){super(),this.type=W.STACK,this._orientation=e.orientation,this._direction=e.direction,this._left=e.left,this._top=e.top,this._horzCellAlignment="horzCellAlignment"in e&&e.horzCellAlignment?e.horzCellAlignment:y.LEFT,this._vertCellAlignment="vertCellAlignment"in e&&e.vertCellAlignment?e.vertCellAlignment:y.BOTTOM,this._gap="gap"in e?e.gap:0}clone(){let e=new Qn({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return e._horzCellAlignment=this._horzCellAlignment,e._vertCellAlignment=this._vertCellAlignment,e}get horzCellAlignment(){return this._horzCellAlignment}get vertCellAlignment(){return this._vertCellAlignment}get orientation(){return this._orientation}set horzCellAlignment(e){this._horzCellAlignment=e}set vertCellAlignment(e){this._vertCellAlignment=e}set orientation(e){this._orientation=e}}function ea(e,t,i,r,s){let n=s.getAttributeType(i);if(n!=Ae.String&&n!=Ae.Date&&n!=Ae.Integer)throw new Error("Divide only works on a string or date attribute: "+i+" is "+n);if(!function(e){if([Dt.Line,Dt.Circle,Dt.Rect,Dt.Area,Dt.Ring,Dt.Pie,Dt.Path].indexOf(e.type)<0)return!1;if(e.type===Dt.Path&&(e.closed||!e.firstVertex.dataScope))return!1;if(e.dataScope){let t=O(e);for(let e of t)if(e.dataScope.numTuples>1)return!0;return!1}return!0}(t))throw new Error("The "+t.type+" is not dividable");switch(t.type){case Dt.Line:case Dt.Path:return;case Dt.Circle:return function(e,t,i,r,s){let n,a,o,l=O(t),h=i||J.ANGULAR;if(h!=J.ANGULAR&&h!=J.RADIAL)throw new Error("Unknown orientation: "+h);h===J.ANGULAR&&l.forEach((i=>{let l=i.dataScope?i.dataScope:new pe(s),h=s.getUniqueAttributeValues(r).map((e=>l.cross(r,e)));h=h.filter((e=>!e.isEmpty()));let c=Lt(e);null==a&&(a=c.id),c._classId=a,c.dataScope=i.dataScope?i.dataScope:new pe(s);let d=i.parent;d.removeChild(i),delete e._itemMap[i.id];let u=360/h.length,_=90;for(let e=0;e<h.length;e++){let r=Nt({type:"arc",innerRadius:0,outerRadius:i.radius,x:i.x,y:i.y,startAngle:ue(_-u*(e+1)),endAngle:ue(_-u*e),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});o||(o=r.id),r.classId=o,r.dataScope=h[e],r._updateBounds(),r._refBounds=r.bounds.clone(),c.addChild(r),c._layout=new Qn({orientation:J.ANGULAR,direction:ee.CLOCKWISE}),c._layout.group=c,d.removeChild(i),d.addChild(c),i===t&&(n=c)}}));return{newMark:n.children[0],collection:n}}(e,t,r,i,s);case Dt.Rect:return function(e,t,i,r,s){let n,a=O(t),o=i||J.HORIZONTAL;if(o!=J.HORIZONTAL&&o!=J.VERTICAL)throw new Error("Unknown orientation: "+o);let l=s.getUniqueAttributeValues(r).map((e=>new pe(s).cross(r,e))),h={},c=0;for(let e of a){let t=l;e.dataScope&&(t=l.map((t=>t.merge(e.dataScope))),t=t.filter((e=>!e.isEmpty()))),t.length>c&&(c=t.length),h[e.id]=t}let d,u=Nt({type:"rect",left:t.bounds.left,top:t.bounds.top,width:t.bounds.width,height:t.bounds.height,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});u._classId=u.id;for(let i of a){let r=Lt(e);null==d&&(d=r.id),r._classId=d,r.dataScope=i.dataScope?i.dataScope:new pe(s);let a=i.parent;a.removeChild(i),delete e._itemMap[i.id];let l=h[i.id],c=i.bounds,_=c.left,p=c.top,g=o==J.HORIZONTAL?c.width/l.length:c.width,f=o==J.HORIZONTAL?c.height:c.height/l.length;for(let e=0;e<l.length;e++){let t=Pt(u);t.dataScope=l[e],t.resize(g,f),t._updateBounds(),t._refBounds=t.bounds.clone(),r.addChild(t)}a.addChild(r),r._layout=new Qn({orientation:o,left:_,top:p}),r._layout.group=r,i==t&&(n=r)}return{newMark:n.children[0],collection:n}}(e,t,r,i,s);case Dt.Area:return function(e,t,i,r,s){let n,a=O(t),o=i||J.HORIZONTAL;if(o!=J.HORIZONTAL&&o!=J.VERTICAL)throw new Error("Unknown orientation: "+o);let l,h=s.getUniqueAttributeValues(r).map((e=>new pe(s).cross(r,e))),c={},d=0;for(let e of a){let t=h;e.dataScope&&(t=h.map((t=>t.merge(e.dataScope))),t=t.filter((e=>!e.isEmpty()))),t.length>d&&(d=t.length),c[e.id]=t}let u=Object.assign({},t.styles);u.vertices=t.vertices.map((e=>[e.x,e.y])),u.type="area",u.orientation=t.orientation,u.baseline=t.baseline;let _=Nt(u);if(_._classId=_.id,t.vertices)for(let e=0;e<t.vertices.length;e++)t.vertices[e].dataScope&&(_.vertices[e]._dataScope=t.vertices[e].dataScope.clone());for(let i of a){let r=Lt(e);null==l&&(l=r.id),r._classId=l,r.dataScope=i.dataScope?i.dataScope:new pe(s);let a=i.parent;a.removeChild(i),delete e._itemMap[i.id];let h=c[i.id],d=i.bounds,u=d.left,p=d.top,g=o==J.HORIZONTAL?d.width/h.length:d.width,f=o==J.HORIZONTAL?d.height:d.height/h.length;for(let e=0;e<h.length;e++){let t=Pt(_);t.dataScope=h[e],console.log(t.dataScope),t.resize(g,f),t._updateBounds(),t._refBounds=t.bounds.clone(),r.addChild(t);for(let e of t.vertices)e.dataScope?e.dataScope=t.dataScope.merge(e.dataScope):e.dataScope=t.dataScope}a.addChild(r),r._layout=new Qn({orientation:o,left:u,top:p}),r._layout.group=r,i==t&&(n=r)}return{newMark:n.children[0],collection:n}}(e,t,r,i,s);case Dt.Ring:return function(e,t,i,r,s){let n,a,o,l=O(t),h=i||J.ANGULAR;if(h!=J.ANGULAR&&h!=J.RADIAL)throw new Error("Unknown orientation: "+h);h===J.ANGULAR&&l.forEach((i=>{let l=i.dataScope?i.dataScope:new pe(s),h=s.getUniqueAttributeValues(r).map((e=>l.cross(r,e)));h=h.filter((e=>!e.isEmpty()));let c=Lt(e);null==a&&(a=c.id),c._classId=a,c.dataScope=i.dataScope?i.dataScope:new pe(s);let d=i.parent;d.removeChild(i),delete e._itemMap[i.id];let u=360/h.length,_=90;for(let e=0;e<h.length;e++){let r=Nt({type:"arc",innerRadius:i.innerRadius,outerRadius:i.outerRadius,x:i.x,y:i.y,startAngle:ue(_-u*(e+1)),endAngle:ue(_-u*e),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});o||(o=r.id),r.classId=o,r.dataScope=h[e],r._updateBounds(),r._refBounds=r.bounds.clone(),c.addChild(r),c._layout=new Qn({orientation:J.ANGULAR,direction:ee.CLOCKWISE}),c._layout.group=c,d.removeChild(i),d.addChild(c),i===t&&(n=c)}}));return{newMark:n.children[0],collection:n}}(e,t,r,i,s);case Dt.Pie:case Dt.Arc:return function(e,t,i,r,s){let n,a,o,l=O(t),h=i||J.ANGULAR;if(h!=J.ANGULAR&&h!=J.RADIAL)throw new Error("Unknown orientation: "+h);h===J.ANGULAR||l.forEach((i=>{let l=i.dataScope?i.dataScope:new pe(s),h=s.getUniqueAttributeValues(r).map((e=>l.cross(r,e)));h=h.filter((e=>!e.isEmpty()));let c=Lt(e);null==a&&(a=c.id),c._classId=a,c.dataScope=i.dataScope?i.dataScope:new pe(s);let d=i.parent;d.removeChild(i),delete e._itemMap[i.id];for(let e=0;e<h.length;e++){let r=Nt({type:"arc",innerRadius:i.innerRadius+e*(i.outerRadius-i.innerRadius)/h.length,outerRadius:i.innerRadius+(e+1)*(i.outerRadius-i.innerRadius)/h.length,x:i.x,y:i.y,startAngle:i.startAngle,endAngle:i.endAngle,strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});o||(o=r.id),r.classId=o,r.dataScope=h[e],r._updateBounds(),r._refBounds=r.bounds.clone(),c.addChild(r),c._layout=new Qn({orientation:J.RADIAL}),c._layout.group=c,d.removeChild(i),d.addChild(c),i===t&&(n=c)}}));return{newMark:n.children[0],collection:n}}(e,t,r,i,s)}}function ta(e,t,i,r){let s=r.getAttributeType(i);if(s!=Ae.String&&s!=Ae.Date&&s!=Ae.Integer)throw new Error("Repopulate only works on a string or date attribute: "+i+" is "+s);let n=O(t);for(let e of n){let t=r.getAttributeSummary(i).unique.map((t=>e.dataScope?e.dataScope.cross(i,t):new pe(r).cross(i,t)));t=t.filter((e=>!e.isEmpty()));let s=e.children.length-t.length,n=t.length-e.children.length;for(let t=0;t<s;t++)e.removeChildAt(e.children.length-1);let a=e._children.length;for(let t=0;t<n;t++){let i=Pt(e._children[t%a]);e.addChild(i)}e.children.forEach(((e,i)=>e.dataScope=t[i]))}}class ia{constructor(e,t){this._elem=e,this._base=t,this._id=ra(e,t),this._channels={},this._attribute=void 0}get id(){return this._id}get element(){return this._elem}get base(){return this._base}get channels(){return Object.keys(this._channels)}addChannel(e,t){let i={};i.elemAnchor="elementAnchor"in t?t.elementAnchor:"x"==e||"angle"==e?y.CENTER:y.MIDDLE,i.baseAnchor="baseAnchor"in t?t.baseAnchor:"x"==e||"angle"==e?y.CENTER:y.MIDDLE,i.offset="offset"in t?t.offset:0,"attribute"in t&&(this._attribute=t.attribute),this._channels[e]=i}hasChannel(e){return e in this._channels}getElementAnchor(e){return this._channels[e].elemAnchor}getBaseAnchor(e){return this._channels[e].baseAnchor}getOffset(e){return this._channels[e].offset}get attribute(){return this._attribute?this._attribute:Ht}}function ra(e,t){return(e.classId?e.classId:e.id)+":"+(t.classId?t.classId:t.id)}function sa(e,t,i,r){e.dataScope&&e.dataScope.dataTable.hasAttribute(t)?function(e,t,i,r){if(!e.dataScope.dataTable.hasAttribute(t))return void console.warn("Cannot order collection children by an non-existent attribute",t);let s;if(t===Ht)s=(e,i)=>parseInt(e.dataScope.getAttrVal(t).substring(1))-parseInt(i.dataScope.getAttrVal(t).substring(1));else{switch(e.children[0].dataScope.getAttributeType(t)){case Ae.Date:break;case Ae.Number:case Ae.Integer:s=(e,i)=>e.dataScope.aggregateNumericalAttribute(t)-i.dataScope.aggregateNumericalAttribute(t);break;case Ae.String:s=r?(e,i)=>r.indexOf(e.dataScope.getAttrVal(t))-r.indexOf(i.dataScope.getAttrVal(t)):(e,i)=>e.dataScope.getAttrVal(t)<i.dataScope.getAttrVal(t)?-1:1}}e.children.sort(s),i&&e.children.reverse()}(e,t,i,r):function(e,t,i){let r;switch(t){case"x":case"y":case"width":case"height":r=(e,i)=>e.bounds[t]-i.bounds[t];break;default:r=(e,i)=>e[t]-i[t]}e._children.sort(r),i&&e.children.reverse()}(e,t,i),e._sortBy={property:t,descending:i,vals:r}}function na(e,t,i,r){e.vertices[0].dataScope&&e.vertices[0].dataScope.dataTable.hasAttribute(t)?function(e,t,i,r){let s;if(t===Ht)s=(e,i)=>parseInt(e.dataScope.getAttrVal(t).substring(1))-parseInt(i.dataScope.getAttrVal(t).substring(1));else{switch(e.vertices[0].dataScope.getAttributeType(t)){case Ae.Date:break;case Ae.Number:case Ae.Integer:s=(e,i)=>e.dataScope.aggregateNumericalAttribute(t)-i.dataScope.aggregateNumericalAttribute(t);break;case Ae.String:s=r?(e,i)=>r.indexOf(e.dataScope.getAttrVal(t))-r.indexOf(i.dataScope.getAttrVal(t)):(e,i)=>e.dataScope.getAttrVal(t)<i.dataScope.getAttrVal(t)?-1:1}}e.vertices.sort(s),i&&e.vertices.reverse()}(e,t,i,r):function(e,t,i){let r=(e,i)=>e[t]-i[t];e.vertices.sort(r),i&&e.vertices.reverse()}(e,t,i),e._sortBy={property:t,descending:i,vals:r}}class aa extends U{constructor(e){super(),this.type=W.GRID,this._numCols=e.numCols,this._numRows=e.numRows,this._start="start"in e?e.start:$.TopLeft,this._direction="direction"in e?e.direction:Z.RowFirst,this._rowGap="rowGap"in e&&void 0!==e.rowGap?e.rowGap:5,this._colGap="colGap"in e&&void 0!==e.colGap?e.colGap:5,this._cellHorzAlignment="horzCellAlignment"in e&&Y("h",e.horzCellAlignment)?e.horzCellAlignment:y.LEFT,this._cellVertAlignment="vertCellAlignment"in e&&Y("v",e.vertCellAlignment)?e.vertCellAlignment:y.BOTTOM,this._numCols||this._numRows||(this._numRows=1),this._left=void 0,this._top=void 0,this._cellBounds=void 0,this._grid=void 0}get cellBounds(){return this._cellBounds}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numCols(e){this._numCols=e}set numRows(e){this._numRows=e}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}clone(){let e=new aa({numCols:this._numCols,numRows:this._numRows,start:this._start,direction:this._direction,colGap:this._colGap,rowGap:this._rowGap,horzCellAlignment:this._cellHorzAlignment,vertCellAlignment:this._cellVertAlignment});return e._left=this._left,e._top=this._top,this._cellBounds&&(e._cellBounds=this._cellBounds.map((e=>e.clone()))),e}getElementsByRow(e,t){let i=[],r=this.group.children;for(let t=0;t<this.numRows;t++){let s=this._grid[t].filter((e=>null!=e)).map((e=>r[e]));if(e){let e=[];for(let t of s)e=e.concat(z(t));i.push(e)}else i.push(s)}return t&&(i=this._filterElementsByExample(i,t)),i}getElementsByCol(e,t){let i=[],r=this.group.children,s=this._grid;for(let t=0;t<this.numCols;t++){let n=s.map((e=>e[t])).filter((e=>null!=e)).map((e=>r[e]));if(e){let e=[];for(let t of n)e=e.concat(z(t));i.push(e)}else i.push(n)}return t&&(i=this._filterElementsByExample(i,t)),i}getElementsByCell(e,t){let i=[],r=this.group.children;for(let t=0;t<r.length;t++)if(e){let e=z(r[t]);i.push(e)}else i.push(r[t]);return t&&(i=this._filterElementsByExample(i,t)),i}_filterElementsByExample(e,t){let i;return"vertex"===t.type?(i=e.map((e=>e.filter((e=>e.classId===t.parent.classId)))),i=i.map((e=>I(t,e)))):"segment"===t.type?(i=e.map((e=>e.filter((e=>e.classId===t.parent.classId)))),i=i.map((e=>N(t,e)))):i=e.map((e=>e.filter((e=>e.classId===t.classId)))),i}getIndex(e){let t=e;for(;t&&t.parent!==this.group;)t=t.parent;return this.group.children.indexOf(t)}getRowCol(e){let t,i;switch(this._direction){case Z.RowFirst:t=Math.floor(e/this.numCols),i=e%this.numCols;break;case Z.ColumnFirst:t=e%this.numRows,i=Math.floor(e/this.numRows);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}return this._start.toLowerCase().includes("bottom")&&(t=this.numRows-1-t),this._start.toLowerCase().includes("right")&&(i=this.numCols-1-i),{row:t,col:i}}get startCorner(){return this._start}set startCorner(e){this._start=e}get direction(){return this._direction}set direction(e){this._direction=e}}class oa extends vt{constructor(e,t){super(),this._type=Dt.Axis,this._id=this._type+Gt(),this._enc=e,this._textColor="textColor"in t?t.textColor:"#555",this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._showTitle=!("showTitle"in t)||t.showTitle,this._orientation="orientation"in t?t.orientation:J.VERTICAL,this._numberFormat=t.numberFormat?t.numberFormat:""}get attribute(){return this._enc.attribute}get channel(){return this._enc.channel}get attributeType(){return zt(this._enc.element).getFieldType(this.attribute)}get orientation(){return this._orientation}get textColor(){return this._textColor}}class la extends oa{constructor(e,t){super(e,t),"numCols"in t||"numRows"in t?(this._numCols=t.numCols,this._numRows=t.numRows):this._orientation===J.VERTICAL?this._numCols=1:this._numRows=1,this._initialize()}_initialize(){let e=this._enc.element.scene,t=this._enc.attribute,i=this._enc.scales[0],r=new Ft(i.domain.map((e=>({category:e,value:i.map(e)})))),s=r.getUniqueAttributeValues("category").sort(((e,t)=>t.length-e.length))[0],n=this._enc.element,a=n instanceof se&&n.closed&&"strokeColor"!==this._enc.channel?n.strokeWidth:0;if(this._orientation===J.VERTICAL){let i=0;this._showTitle&&(this.addChild(new kt({fillColor:this._textColor,fontSize:this._fontSize,text:t,x:this._x,y:this._y,anchor:["left","top"]})),i=parseFloat(this._fontSize)+5);let o=e.mark("rect",{top:this._y+2+i,left:this._x,width:10,height:10,strokeWidth:a,strokeColor:n.strokeColor,opacity:n.opacity}),l=e.mark("text",{text:s,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+i+12+a,anchor:["left","bottom"]}),h=e.glyph(o,l),c=e.repeat(h,r);e.encode(l,{channel:"text",attribute:"category",forLegend:!0}),e.encode(o,{channel:"fillColor",attribute:"category",shareScale:this._enc,forLegend:!0}),c.layout=new aa({numCols:this._numCols,numRows:this._numRows}),this.addChild(c)}else{let t=e.mark("rect",{top:this._y,left:this._x,width:10,height:10,strokeWidth:a,strokeColor:n.strokeColor,opacity:n.opacity}),i=e.mark("text",{text:s,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+15,y:this._y,anchor:["left","top"]}),o=e.glyph(t,i),l=e.repeat(o,r);e.encode(i,{channel:"text",attribute:"category",forLegend:!0}),e.encode(t,{channel:"fillColor",attribute:"category",shareScale:this._enc,forLegend:!0}),l.layout=new aa({numCols:this._numCols,numRows:this._numRows,colGap:15}),this.addChild(l)}}}class ha extends oa{constructor(e,t){super(e,t),this._initialize()}_initialize(){let e,t,i,s=this._enc.element.scene,n=this._enc.attribute;if(this._orientation==J.VERTICAL?(e=15,t=300):(e=300,t=15),this._showTitle){let t=s.mark("text",{fillColor:this._textColor,text:n,x:this._x+e/2,y:this._y,anchor:["center","middle"]});this.addChild(t),i=20}else i=0;let a,o=s.mark("rect",{top:this._y+i,left:this._x,width:e,height:t,strokeWidth:0,opacity:this._enc.element.opacity}),l=Object.values(this._enc.attrValues),h=[Math.min(...l),Math.max(...l)],c=this._enc.mapping,d=[],u=[],_=r.format(this._numberFormat);if(c){let r=Object.keys(c).map((e=>parseFloat(e))).sort(((e,t)=>e-t));this._orientation==J.VERTICAL?(a=new K({x1:0,y1:100,x2:0,y2:0}),r.forEach((r=>{let n=(r-h[0])/(h[1]-h[0]);a.addStop(100*n,c[r],1);let o=s.mark("line",{x1:this._x+e,x2:this._x+e+5,y1:this._y+t-n*t+i,y2:this._y+t-n*t+i,strokeColor:this._strokeColor});u.push(o);let l=s.mark("text",{fillColor:this._textColor,text:this._numberFormat?_(r):r.toFixed(0),x:this._x+e+5+5,y:this._y+t-n*t+i,anchor:["left","middle"]});d.push(l)}))):(a=new K({x1:0,y1:0,x2:100,y2:0}),r.forEach((r=>{let n=(r-h[0])/(h[1]-h[0]);a.addStop(100*n,c[r],1);let o=s.mark("line",{x1:this._x+n*e,x2:this._x+n*e,y1:this._y+20-5+i,y2:this._y+t+5+i,strokeColor:this._strokeColor});u.push(o);let l=s.mark("text",{fillColor:this._textColor,text:this._numberFormat?_(r):r.toFixed(0),x:this._x+n*e,y:this._y+t+5+i,anchor:["center","top"]});d.push(l)})))}else{let r=this._enc.scales[0].domain,o=zt(this._enc.element),l=o.getAttributeType(n),h=[],c=l===Ae.Date?o.getUniqueFieldValues(n):[...new Set(Object.values(this._enc.attrValues))];if(c.length<=10)h=c,h.sort(((e,t)=>e-t));else if(l===Ae.Date){c.sort(((e,t)=>e-t));for(let e=0;e<c.length;e+=Math.ceil(c.length/10))h.push(c[e])}else{let e=(r[1]-r[0])/9;for(let t=0;t<10;t++)h.push(r[0]+t*e)}let p=0,g=(h[h.length-1]-h[0])/h.length;for(;g<1;)g*=10,p++;h=h.map((e=>e.toFixed(p))),this._orientation==J.VERTICAL?(a=new K({x1:0,y1:100,x2:0,y2:0}),h.forEach((h=>{let c=(h-r[0])/(r[1]-r[0]);a.addStop(100*c,this._enc.scales[0].map(h),1);let p=s.mark("line",{x1:this._x+e,x2:this._x+e+5,y1:this._y+t-c*t+i,y2:this._y+t-c*t+i,strokeColor:this._strokeColor});u.push(p);let g=s.mark("text",{fillColor:this._textColor,text:l===Ae.Date?o.getRawValue(n,h):this._numberFormat?_(h):h,x:this._x+e+5+5,y:this._y+t-c*t+i,anchor:["left","middle"]});d.push(g)}))):(a=new K({x1:0,y1:0,x2:100,y2:0}),h.forEach((h=>{let c=(h-r[0])/(r[1]-r[0]);a.addStop(100*c,this._enc.scale.map(h),1);let _=s.mark("line",{x1:this._x+c*e,x2:this._x+c*e,y1:this._y+t+i,y2:this._y+t+5+i,strokeColor:this._strokeColor});u.push(_);let p=s.mark("text",{fillColor:this._textColor,text:l===Ae.Date?o.getRawValue(n,h):h,x:this._x+c*e,y:this._y+t+5+i,anchor:["center","top"]});d.push(p)})))}o.styles.fillColor=a,this.addChild(o);for(let e of d)this.addChild(e);for(let e of u)this.addChild(e)}}class ca extends vt{constructor(e){super(),this._type=Dt.Composite,this._id=e&&e.id?e.id:this._type+Gt()}addChild(e){let t=e.parent;super.addChild(e);let i=D(e)._depGraph;t&&ct(t,e,i),dt(this,e,i)}}class da{constructor(e,t,i){this._elems=e,this._channel=t,this._anchor=i}get elements(){return this._elems}get channel(){return this._channel}get anchor(){return this._anchor}}class ua extends U{constructor(e){super(),this.type=W.STRATA,this._direction=e.direction,this._gap="gap"in e?e.gap:0}clone(){return new ua({direction:this._direction,gap:this._gap})}}function _a(e,t,i,r,s,n){switch(t.type){case Dt.Circle:case Dt.Ring:return function(e,t,i,r,s,n){let a,o=i||te.OUTWARD,l=s||50;if(o!==te.INWARD&&o!==te.OUTWARD)throw"Unknown direction to stratify";let h,c=O(t,e),d=Array.isArray(n)?n:[n];if(r){let i=Lt(e);i.dataScope=void 0,null==h&&(h=i.id),i._classId=h;let r=c.map((e=>d[0].getNode(e.dataScope.getAttrVal(we))));pa(c,r,d[0],i,t.classId?t.classId:t.id,400,350,o,l),a=i}else c.forEach(((i,r)=>{let s=Lt(e);s.dataScope=void 0,null==h&&(h=s.id),s._classId=h;let n=i.parent;ga(i,t.id,o,l,d[r],d[r].getRoot(),s,e,!0),s._layout=new ua({direction:o}),s._layout.group=s,n.addChild(s),i===t&&(a=s)}));return a}(e,t,i,r,s,n);case Dt.Rect:return function(e,t,i,r,s,n){let a,o,l=i||Q.Top2Bottom,h=s||50;if(!Object.values(Q).includes(l))throw"Unknown direction to stratify";return O(t).forEach((i=>{let r=Lt(e);r.dataScope=void 0,null==o&&(o=r.id),r._classId=o;let s=i.parent;fa(i,t.id,l,h,n,n.getRoot(),r,e,!0),r._layout=new ua({direction:l}),r._layout.group=r,s.addChild(r),i===t&&(a=r)})),a}(e,t,i,0,s,n)}}function pa(e,t,i,r,s,n,a,o,l){let h=t.map((e=>i.getParent(e))).filter(((e,t,i)=>i.findIndex((t=>t[we]===e[we]))===t));if(h=h.filter((e=>e!==i.getRoot())),0===h.length)return;let c=[];for(let t of h){let h,d,u,_=e.filter((e=>i.getParent(i.getNode(e.dataScope.getAttrVal(we)))===t));if(_[0].type===Dt.Circle){let e=_.map((e=>T(n,a,e.bounds.x,e.bounds.y)-e.radius)),t=_.map((e=>T(n,a,e.bounds.x,e.bounds.y)+e.radius));u=o===te.OUTWARD?Math.max(...t):Math.min(...e)-l;let i=_.map((e=>_e(e.bounds.x,e.bounds.y,n,a))),r=_.map((e=>_e(n+T(n,a,e.bounds.x,e.bounds.y),a-e.radius,n,a))),s=i.map(((e,t)=>e-r[t])),c=i.map(((e,t)=>e+r[t])),p=s.concat(c);h=Math.min(...p),d=Math.max(...p)}else _[0].type===Dt.Arc&&(h=360,d=-360,_.forEach((e=>{let t=e.startAngle,i=e.endAngle;i<t&&(i+=360),h=Math.min(h,t),d=Math.max(d,i)})),h=ue(h),d=ue(d),u=o===te.OUTWARD?Math.max(..._.map((e=>e.outerRadius))):Math.min(..._.map((e=>e.innerRadius)))-l);let p=Nt({type:"arc",innerRadius:u,outerRadius:u+l,x:n,y:a,startAngle:ue(h),endAngle:ue(d),strokeColor:e[0].strokeColor,fillColor:e[0].fillColor,strokeWidth:e[0].strokeWidth,opacity:e[0].opacity});p._updateBounds(),p.dataScope=i.getNodeDataScope(t),p._classId=s,r.addChild(p),c.push(p)}pa(c,h,i,r,s,n,a,o,l)}function ga(e,t,i,r,s,n,a,o,l){l&&(e.dataScope=s.getNodeDataScope(n),e._classId=t);let h=s.getChildren(n);if(0===h.length)return;let c=e.type===Dt.Circle||e.type===Dt.Ring?60:e.startAngle,d=(e.type===Dt.Circle||e.type===Dt.Ring?360:e.angle)/h.length;for(let n=0;n<h.length;n++){let o,l;l=i===te.OUTWARD?e.type===Dt.Circle?e.radius:e.outerRadius:e.type===Dt.Circle?e.radius-r:e.innerRadius-r,o=Nt(360===d?{type:"ring",innerRadius:l,outerRadius:l+r,x:e.x,y:e.y,strokeColor:e.strokeColor,fillColor:e.fillColor,strokeWidth:e.strokeWidth,opacity:e.opacity}:{type:"arc",innerRadius:l,outerRadius:l+r,x:e.x,y:e.y,startAngle:ue(c+d*n),endAngle:ue(c+d*(n+1)),strokeColor:e.strokeColor,fillColor:e.fillColor,strokeWidth:e.strokeWidth,opacity:e.opacity}),o._updateBounds(),o.dataScope=s.getNodeDataScope(h[n]),o._classId=t+"_strata",a.addChild(o),ga(o,t,i,r,s,h[n],a)}}function fa(e,t,i,r,s,n,a,o,l){l&&(e.dataScope=s.getNodeDataScope(n),e._classId=t,a.addChild(e));let h,c,d,u=s.getChildren(n);if(0!==u.length){switch(i){case Q.Top2Bottom:case Q.Bottom2Top:case Q.Left2Right:case Q.Right2Left:}h=e.left,c=e.bottom,d=e.width/u.length;for(let n=0;n<u.length;n++){let o=Pt(e);je(o,h-o.left,c-o.top),o.resize(d,r),o._updateBounds(),h+=d,o.dataScope=s.getNodeDataScope(u[n]),o._classId=t,a.addChild(o),fa(o,t,i,r,s,u[n],a)}}}class ya{constructor(e,t,i,r){this._id=e,this._event=i,this._target=t,this._evtCtx=new Zn,this._cumulative=r}get id(){return this._id}get event(){return this._event}get eventContext(){return this._evtCtx}get target(){return this._target}isCumulative(){return this._cumulative}isMouseDriven(){return["brush","brushX","brushY","click","hover"].includes(this._event)}isKeyboardDriven(){return["keydown","keyup"].includes(this._event)}isWidgetDriven(){return["change","input"].includes(this._event)}}class ma extends vt{constructor(e){super(),this._itemMap={},this._peerIndex=new Map,this._type=Dt.Scene,this._id=e&&e.id?e.id:this._type+Gt(),e&&e.fillColor&&(this.fillColor=e.fillColor),this._encodings={},this._relations=[],this._triggers={},this._condEncodings={},this._depGraph=new Yn}get depGraph(){return this._depGraph}get interactionTriggers(){return this._triggers}buildPeerIndex(){this._peerIndex=new Map;let e=this._peerIndex;j(this,(t=>{t.classId&&(e.has(t.classId)||e.set(t.classId,[]),e.get(t.classId).push(t))}))}mark(e,t){if(Object.values(Mt).indexOf(e)<0)throw new Error("Mascot does not allow directly creating a "+e);let i=void 0===t?{}:t;i.type=e;let r=Nt(i);return null!==r&&(r._classId=r.id,this.addChild(r),this._itemMap[r.id]=r,st(r,this._depGraph),dt(this,r,this._depGraph)),r}glyph(...e){let t=[];for(let i of e)t.push([i.parent,i]);let i=Vt(e);if(null!==i){i._classId=i.id,this.addChild(i),this._itemMap[i.id]=i;for(let e of t)ct(e[0],e[1],this._depGraph);ut(i,this._depGraph),dt(this,i,this._depGraph)}return i}composite(){let e=new ca;return null!==e&&(e._classId=e.id,this.addChild(e),this._itemMap[e.id]=e,ht(e,this._depGraph),dt(this,e,this._depGraph)),e}attach(e,t){if(e.type==Dt.Glyph)for(let t of e.children)t._refBounds||(t._refBounds=t.bounds.clone());e.dataScope=new pe(t)}repeat(e,t,i){let r=i||{};if(r.attribute=r.attribute||Ht,console.log("------ repeat by",r.attribute," ----"),function(e,t,i){if(!e||void 0===t)throw new Error("Incomplete information to do repeat. You must specify an element, a categorical data attribute and a data table");if(t instanceof ye||t instanceof be){if(!Array.isArray(e)||2!==e.length)throw new Error("To repeat with a tree or a network, you need to provide two marks, one for node and one for link")}else t instanceof Ft&&Ee(i.attribute,t);if(i.layout&&!(i.layout instanceof U))throw new Error("Invalid layout: "+i.layout)}(e,t,r),t instanceof ye||t instanceof be){let i=e[0].parent,r=e[1].parent,[s,n]=function(e,t,i,r){let s=r.nodeTable.getAttributeSummary(we).unique.map((e=>t.dataScope?t.dataScope.cross(we,e):new pe(r.nodeTable).cross(we,e))),n=Lt(e),a=Lt(e),o={};a.dataScope=t.dataScope?t.dataScope.clone():new pe(r.nodeTable),a.addChild(t);for(let e=1;e<s.length;e++){let e=Pt(t);a.addChild(e)}a.children.forEach(((e,t)=>{e.dataScope=s[t],e.links=[],o[e.dataScope.getAttrVal(we)]=e}));let l=r.linkTable.getAttributeSummary(Ht).unique.map((e=>i.dataScope?i.dataScope.cross(Ht,e):new pe(r.linkTable).cross(Ht,e)));n.dataScope=i.dataScope?i.dataScope.clone():new pe(r.linkTable),n.addChild(i);for(let e=1;e<l.length;e++){let e=Pt(i);n.addChild(e)}n.children.forEach(((e,t)=>e.dataScope=l[t]));let h=r instanceof ye?"parent":"source",c=r instanceof ye?"child":"target";for(let e of n.children){let t=e.dataScope.getAttrVal(h),i=e.dataScope.getAttrVal(c),r=o[t],s=o[i];e.source=r,e.target=s,r.links.push(e),s.links.push(e)}return[a,n]}(this,e[0],e[1],t);return this.buildPeerIndex(),ct(i,e[0],this._depGraph),ct(r,e[1],this._depGraph),lt(s,this._depGraph),lt(n,this._depGraph),dt(s,e[0],this._depGraph),dt(s.parent,s,this._depGraph),dt(n,e[1],this._depGraph),dt(n.parent,n,this._depGraph),[s,n]}if(t instanceof Ft){let i=e.parent,s=qn(this,e,r.attribute,t);return this.buildPeerIndex(),ct(i,e,this._depGraph),lt(s,this._depGraph),dt(s,e,this._depGraph),dt(s.parent,s,this._depGraph),r.layout&&(s.layout=r.layout),s}}divide(e,t,i){let r=i||{};if(r.attribute=r.attribute||Ht,console.log("------ divide by",r.attribute," ----"),function(e,t,i){if(!e||void 0===t)throw new Error("Incomplete information to do divide. You must specify an element, a categorical data attribute and a data table");if(t instanceof Ft&&Ee(i.attribute,t),i.layout&&!(i.layout instanceof U))throw new Error("Invalid layout: "+i.layout)}(e,t,r),t instanceof ye||t instanceof be)throw"Not implemented";if(t instanceof Ft){let{newMark:i,collection:s}=ea(this,e,r.attribute,r.orientation,t);return this.buildPeerIndex(),nt(e,this._depGraph),st(i,this._depGraph),lt(s,this._depGraph),dt(s,i,this._depGraph),s.parent.type!==Dt.Scene&&dt(s.parent,s,this._depGraph),this.onChange(Ie.CHANNEL,"width",i),{newMark:i,collection:s}}}densify(e,t,i){let r=i||{};if(r.attribute=r.attribute||Ht,console.log("------ densify by",r.attribute," ----"),function(e,t,i){if(!e||void 0===t)throw new Error("Incomplete information to do densification. You must specify an element, a categorical data attribute and a data table");t instanceof Ft&&Ee(i.attribute,t)}(e,t,r),t instanceof ye||t instanceof be)throw"Not implemented";if(t instanceof Ft){let i=ke(0,e,r.attribute,r.orientation,t);return this.buildPeerIndex(),nt(e,this._depGraph),st(i,this._depGraph),i.parent.type!==Dt.Scene&&dt(i.parent,i,this._depGraph),this.onChange(Ie.CHANNEL,"width",i),i}}stratify(e,t,i){if(!(t instanceof ye||Array.isArray(t)&&t.every((e=>e instanceof ye))))throw"Cannot stratify on a non-tree dataset";if(![Dt.Circle,Dt.Rect,Dt.Ring].includes(e.type))throw"Cannot stratify elements that are not rects, circles, or rings";let r=i||{},s=r.direction,n=r.size,a=e.parent,o=_a(this,e,s,r.startFromLeaf,n,t);return this.buildPeerIndex(),ct(a,e,this._depGraph),lt(o,this._depGraph),o.children.length>0&&dt(o,o.firstChild,this._depGraph),dt(o.parent,o,this._depGraph),o}repopulate(e,t,i){e.dataScope=void 0;let r=e;for(let e in i){ta(0,r,i[e],t);let s=Pe(r.children[0],!0);for(let e of s){Ve(e,this),at(e,this._depGraph);for(let t of e.refElements)oi(t,this),ot(t,this._depGraph);e.clearRefElements()}let n=O(r);for(let e of n)if(e.layout){for(let t of e.layout.refElements)oi(t,this),ot(t,this._depGraph);e.layout.clearRefElements()}r=r.children[0]}e.dataScope=new pe(t),this.buildPeerIndex(),this.onChange(Ie.CHANNEL,"width",e.children[0])}classify(e,t){let i=t||{};console.log("------ classify by",i.attribute," ----"),function(e,t,i,r){let s=O(t);for(let t of s){let s,n={},a=t.children;for(let e of a){let t=e.dataScope.getAttrVal(i);t in n||(n[t]=[]),n[t].push(e)}let o=zt(a[0]);for(let a in n){let l=Lt(e);t.addChild(l),void 0===s&&(s=l.id),l._classId=s,l.dataScope=t.dataScope?t.dataScope.cross(i,a):new pe(o).cross(i,a);for(let e of n[a])l.addChild(e);r&&(l._layout=r.clone(),l._layout.group=l)}}}(this,e,i.attribute,i.layout),this.buildPeerIndex(),ct(e,e.firstChild.firstChild,this._depGraph),lt(e.firstChild,this._depGraph),dt(e.firstChild,e.firstChild.firstChild,this._depGraph),dt(e,e.firstChild,this._depGraph),this.onChange(Ie.CHANNEL,"width",e.firstChild.firstChild)}affix(e,t,i,r){e.dataScope.dataTable!==e.dataScope.dataTable&&console.warn("Affix: elements and base elements are not created from the same table");let s=ra(e,t),n=this._relations.find((e=>e.id===s));n||(n=new ia(e,t),this._relations.push(n)),n.addChannel(i,r||{}),function(e,t){let i=t.getVariable(Ie.AFFIXATION,e),r=t.getOutgoingDataflowOperator(q.AFFIXER,i);t.connect(i,r);for(let i of e.channels){let s=t.getVariable(Ie.CHANNEL,i,e.element),n=t.getVariable(Ie.CHANNEL,i,e.base);t.connect(n,r),t.connect(r,s)}r.run()}(n,this._depGraph)}align(e,t,i){let r=new da(e,t,i);!function(e,t){let i=t.createMultiWayDependency(q.ALIGNER),r=t.getVariable(Ie.ALIGNMENT,e);t.connect(r,i);for(let r of e.elements){let s=t.getVariable(Ie.CHANNEL,e.channel,r);t.connect(s,i)}i.run()}(r,this._depGraph),this._relations.push(r)}encode(e,t){if("rowId"===t.attribute&&(t.attribute=Ht),function(e,t){if(!e||!("channel"in t)||!("attribute"in t))throw new Error("Incomplete information to do encoding. You must specify an item, a categorical data attribute and a data table");let i=zt(e);if(i.tree){let e=t.attribute;if(e.indexOf(".")>0&&!i.tree.nodeTable.hasAttribute(e.split(".")[1]))throw new Error("Data attribute does not exist in the data table")}else if(!i||!i.hasAttribute(t.attribute))throw new Error("Data attribute does not exist in the data table");if(!Object.values(Le).includes(t.channel))throw new Error("Channel Not Supported")}(e,t),t.shareScale){let e=t.shareScale;if(e.channel!=t.channel&&e.channel.indexOf("Color")<0&&t.channel.indexOf("Color")<0)throw new Error("Cannot share scales between "+e.channel+" and "+t.channel+" encodings");t.scheme=t.shareScale.colorScheme}!function(e){let t;"vertex"===e.type&&e.parent.type===Dt.Area?t=e.parent:e.type===Dt.Area&&(t=e),t&&!t._refBounds&&O(t).forEach((e=>e._refBounds=e.bounds.clone()))}(e);let i=t.aggregator?t.aggregator:"sum";console.log("------ encode",t.channel,t.attribute," --");let r=De(e,t.channel);if(r&&t.attribute!==r.attribute){Ve(r,this),at(r,this._depGraph);for(let e of r.refElements)oi(e,this),ot(e,this._depGraph);r.clearRefElements()}t.table=zt(e);let s=new Kn(e,t.channel,t.attribute,i,t);return this._addAttributeEncoding(s),yt(s,this._depGraph,t.shareScale),t.shareScale?this.onChange(Ie.ATTR_VALUE,s):this.onChange(Ie.CHANNEL,t.channel,e),s}connect(e,t){let i={};e.forEach((e=>i[e.dataScope.getAttrVal(we)]=e));let r=t[0].dataScope.dataTable,s=r.tree?"parent":"source",n=r.tree?"child":"target";for(let t of e)t.links=[];for(let e of t){let t=e.dataScope.getAttrVal(s),r=e.dataScope.getAttrVal(n),a=i[t],o=i[r];e.source=a,e.target=o,a.links.push(e),o.links.push(e)}ft(e.find((e=>e.links.length>0)),this._depGraph),this.onChange(Ie.CHANNEL,"x",e[0])}_addAttributeEncoding(e){let t=Be(e.element);t in this._encodings||(this._encodings[t]={}),this._encodings[t][e.channel]=e}activate(e,t,i,r,s){!function(e,t,i,r,s){if(!("event"in e)||!("target"in e))throw"Target and event must be specified in the trigger";if(!("component"in i))throw"Responder component must be specified";if(Array.isArray(r)){if(!r.every((e=>"function"==typeof e)))throw"Styling rules must be a function";if(s&&!Array.isArray(s))throw"An array of effect setters must be accompanied by an array of animation effects";if(s&&Array.isArray(s)&&s.length!==r.length)throw"the length of effect setters is not equal to the length of animation effects"}else if("function"!=typeof r)throw"Styling rules must be a function"}(e,0,t,r,s);let n=e.event,a=function(e){return["string"==typeof e.target?e.target:e.target.classId?e.target.classId:e.target.id,e.event].join("-")}(e);n=0===n.indexOf("brush")?"brush":0===n.indexOf("drag")?"drag":n,n in this._triggers||(this._triggers[n]={}),a in this._triggers[n]||(this._triggers[n][a]=new ya(a,e.target,e.event,e.cumulative));let o=this._triggers[n][a].eventContext,l=new $n(o,t.component,i,r);return a in this._condEncodings||(this._condEncodings[a]=[]),this._condEncodings[a].push(l),function(e,t,i,r){let s=t.responderComponent,n=r.getVariable(Ie.EVT_CTX,e),a=i.properties?i.properties:i.channels;if(t.evalFunction){let e=r.getVariable(Ie.CONDITION_RESULT,t.evalResult,t),i=r.findIncomingDataflowOperator(q.TARGET_EVALUATOR,e);i||(i=r.createOneWayDependency(q.TARGET_EVALUATOR,t.evalFunction)),r.connect(n,i),r.connect(i,e);for(let t of a){let i=Array.isArray(s)?s:[s];for(let s of i){let i=r.getVariable(Ie.CHANNEL,t,s),n=i.incomingDataflow;if(n&&n instanceof Qe&&n.outputVar.channel===t)r.connect(e,n);else if(!n){let n=r.createOneWayDependency(q.ENCODER);r.connect(e,n),r.connect(n,i),n.storeValues(s,t)}}}}else for(let e of a){Object.values(Le).includes(e)?r.getVariable(Ie.CHANNEL,e,s):r.getVariable(Ie.PROPERTY,tt(e),s);let i=r.createOneWayDependency(q.TARGET_UPDATER,t.stylingFunction,s);r.connect(n,i)}}(o,l,t,this._depGraph),this._triggers[n][a]}onChange(e,...t){if(Object.values(Ie).indexOf(e)<0)throw new Error("Unknown Variable Type: "+e);let i=[];this._depGraph.processChange(e,i,...t);for(let e of i)e.run()}gridlines(e,t,i){let r=i||{},s=r.element?De(r.element,e):Me(t,e,this);if(s){s.attribute!==t&&console.warn("Cannot create a "+e+" axis for "+t);let i=[];if("x"==e)for(let e of s.scales)i.push({scale:e,elems:s.getElements(e)});else if("width"==e){let e=B(s.element),t=s.scales[0];if(e.layout&&e.layout.type==W.GRID&&e.layout.numCols>1){let r=e.layout.getElementsByCol(!0);for(let e of r)i.push({scale:t,elems:e})}else i.push({scale:s.scales[0],elems:s.getElements(s.scales[0])})}else if("y"==e){let e=B(s.element);if(e.layout&&e.layout.type==W.GRID&&e.layout.numRows>1){let t=e.layout.getElementsByRow(!0,s.element);for(let e of t)i.push({scale:s.getScale(e[0]),elems:e})}else i.push({scale:s.scales[0],elems:s.getElements(s.scales[0])})}else if("height"==e){let e=B(s.element),t=s.scales[0];if(e.layout&&e.layout.type==W.GRID&&e.layout.numRows>1){let r=e.layout.getElementsByRow(!0,s.element);for(let e of r)i.push({scale:t,elems:e})}else i.push({scale:t,elems:s.getElements(t)})}else if("radialDistance"==e){let e=r.element?r.element:s.element;i.push({scale:s.scales[0],elems:O(e,e.parent)})}for(let e of i){let t=new Jn(s.channel,s.attribute,e.scale,e.elems,r);this.addChild(t),s.addRefElement(t),xt(t,this._depGraph),dt(this,t,this._depGraph)}}else{let i=r.element?r.element:V(this,t);if(!i)return void console.warn("Cannot create "+e+" gridlines for "+t);let s=P(i.parent);if(!s.layout)return void console.warn("Cannot create "+e+" gridlines for "+t);let n=O(s);for(let i of n){let s=[];i.layout.type==W.GRID&&i.layout.numRows>1&&"x"==e?s=i.layout.getElementsByRow():i.layout.type==W.GRID&&i.layout.numCols>1&&"y"==e?s=i.layout.getElementsByCol():s.push(i.children);for(let n of s){let s=new Jn(e,t,null,n,r);this.addChild(s),i.layout.addRefElement(s),xt(s,this._depGraph),dt(this,s,this._depGraph)}}}}axis(e,t,i){let r=i||{},s="rowId"==t?Ht:t,n=[],a=r.element?De(r.element,e):Me(s,e,this);if(a){a.attribute!==s&&console.warn("Cannot create a "+e+" axis for "+s);let t=[];if("x"==e||"width"==e){let e=B(r.element?r.element:a.element);if(e.layout&&e.layout.type==W.GRID&&e.layout.numCols>1){let i=e.layout.getElementsByCell(!0,a.element);for(let e of i)t.push({scale:a.getScale(e[0]),elems:e})}else t.push({scale:a.scales[0],elems:a.getElements(a.scales[0])})}else if("y"==e||"height"==e){let e=B(r.element?r.element:a.element);if(e.layout&&e.layout.type==W.GRID&&e.layout.numRows>1){let i=e.layout.getElementsByCell(!0,a.element);for(let e of i)t.push({scale:a.getScale(e[0]),elems:e})}else t.push({scale:a.scales[0],elems:a.getElements(a.scales[0])})}else if("radialDistance"==e){let e=r.element?r.element:a.element;t.push({scale:a.scales[0],elems:O(e,e.parent)})}for(let e of t){let t=new li(a,e.scale,e.elems,r);this.addChild(t),n.push(t),a.addRefElement(t),bt(t,this._depGraph),dt(this,t,this._depGraph),this.onChange(Ie.PROPERTY,rt.AXIS_PATH_POSITION,t)}}else{let t=r.element?r.element:V(this,s);if(!t)return void console.warn("Cannot create a "+e+" axis for "+s);let i=P(t.parent);if(!i.layout)return void console.warn("Cannot create a "+e+" axis for "+s);let a=O(i);for(let t of a){let i=[];t.layout.type==W.GRID&&t.layout.numRows>1&&"x"==e?i=t.layout.getElementsByRow():t.layout.type==W.GRID&&t.layout.numCols>1&&"y"==e?i=t.layout.getElementsByCol():i.push(t.children);for(let a of i){let i=new hi(a.slice(),e,s,r);this.addChild(i),n.push(i),t.layout.addRefElement(i),mt(i,this._depGraph),dt(this,i,this._depGraph),this.onChange(Ie.PROPERTY,rt.AXIS_PATH_POSITION,i)}}}return n.length>1?n:n[0]}legend(e,t,i){let r=i||{},s="rowId"==t?Ht:t,n=r.element?De(r.element,e):Me(s,e,this);if(n){n.attribute!==t&&console.warn("Cannot create a "+e+" legend for "+t);let i="string"===zt(n.element).getAttributeType(t)?new la(n,r):new ha(n,r);this.addChild(i),function(e,t){let i=t.getVariable(Ie.BOUNDS,e),r=t.getVariable(Ie.PROPERTY,rt.LEGEND_POSITION,e),s=t.getIncomingDataflowOperator(q.EVAL_BBOX,i);t.connect(r,s),t.connect(s,i)}(i,this._depGraph),dt(this,i,this._depGraph),f(i),this.onChange(Ie.PROPERTY,rt.LEGEND_POSITION,i)}else console.warn("Cannot create a "+e+" legend for "+s)}createMask(e){let t=B(e),i=t||e;i.clipMask||i.createClipMask()}setLayout(e,t){if(e.layout&&(pt(e,e.layout,this._depGraph),t.type===W.TREEMAP)){let t=e.firstChild;for(;t&&t.type===Dt.Collection&&t.layout;)pt(t,t.layout,this._depGraph),t=t.firstChild}if(O(e).forEach((e=>{let i=t?t.clone():t;e._layout=i,i&&(i.group=e)})),gt(e,t,this._depGraph),e.children&&e.children.length>0){let t=z(e,!0);for(let e of t)this.onChange(Ie.CHANNEL,"x",e)}}setProperties(e,t,i){let r=i?[e]:O(e);r.forEach((e=>{for(const[i,r]of Object.entries(t))We(e,i,r)})),"width"in t&&r.forEach((e=>{e._refBounds&&e._refBounds.setWidth(t.width)})),"height"in t&&r.forEach((e=>{e._refBounds&&e._refBounds.setHeight(t.height)}));for(let i in t)["vertex","segment"].includes(e.type)&&!["x","y"].includes(i)||(Object.values(Le).includes(i)?this.onChange(Ie.CHANNEL,i,e):this.onChange(Ie.PROPERTY,i,e))}setLayoutParameters(e,t){let i=O(e);for(let e of i)for(let i in t)e.layout[i]=t[i];this.onChange(Ie.CHANNEL,"width",e.firstChild)}sortChildren(e,t,i,r){if(e instanceof vt)sa(e,t,i,r),this.onChange(Ie.PROPERTY,rt.CHILDREN_ORDER,e);else if(e instanceof se){let s=O(e);for(let e of s)na(e,t,i,r)}}findElements(e){return L(this,e)}translate(e,t,i){je(e,t,i);let r=z(e,!0);for(let e of r)f(e);for(let e of r)this.onChange(Ie.CHANNEL,"x",e)}transform(e,t,i){let r=t.clone();switch(e){case"bin":!function(e,t,i,r,s){let n=s.getVariable(Ie.ATTRIBUTE,e,i),a=s.getVariable(Ie.ATTRIBUTE,t,r),o=s.createOneWayDependency(q.BIN_TRANSFORMER);s.connect(n,o),s.connect(o,a),o.run()}(i.attribute,i.newAttribute,t,r,this._depGraph);break;case"filter":!function(e,t,i,r){let s=r.getVariable(Ie.ITEMS,void 0,t),n=r.getVariable(Ie.ITEMS,e,i),a=r.createOneWayDependency(q.FILTER_TRANSFORMER);r.connect(s,a),r.connect(a,n),a.run()}(c(i),t,r,this._depGraph);break;case"kde":!function(e,t,i,r,s,n){let a=n.getVariable(Ie.ATTRIBUTE,e,i),o=n.getVariable(Ie.ATTRIBUTE,t,r),l=n.createOneWayDependency(q.KDE_TRANSFORMER);l.args=s,n.connect(a,l),n.connect(l,o),l.run()}(i.attribute,i.newAttribute,t,r,i,this._depGraph)}return r}getEncodingByAttribute(e,t){return Me(e,t,this)}getEncodingByElement(e,t){return De(e,t)}getAxis(e,t){return Me(e,t,this).refElements[0]}}function ba(e,t){let i=new pe(t.tables[e.dt]);for(let t in e.attr2value)i._attr2value[t]=e.attr2value[t],i._updateTuples(t,e.attr2value[t]);return i}class xa extends U{constructor(e){super(),this.type=W.DIRECTED,this._width="width"in e?e.width:500,this._height="height"in e?e.height:300,this._top="top"in e?e.top:0,this._left="left"in e?e.left:0,this._edgeSep="edgeSep"in e?e.edgeSep:50,this._spreadLinks=!("spreadLinks"in e)||e.spreadLinks,this._direction="direction"in e?e.direction:Q.Top2Bottom}clone(){return new xa({width:this._width,height:this._height,top:this._top,left:this._left,edgeSep:this._edgeSep,spreadLinks:this._spreadLinks,direction:this._direction})}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get edgeSep(){return this._edgeSep}get spreadLinks(){return this._spreadLinks}get direction(){return this._direction}}class va extends U{constructor(e){super(),this.type=W.FORCE,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._iterations="iterations"in e?e.iterations:1,this._repulsion="repulsion"in e?e.repulsion:30,this._attraction="attraction"in e?e.attraction:1,this._linkDistance="linkDistance"in e?e.linkDistance:30}clone(){return new va({x:this._x,y:this._y,iterations:this._iterations,repulsion:this._repulsion,attraction:this._attraction,linkDistance:this._linkDistance})}}class wa extends U{constructor(e){super(),this.type=W.PACKING,this._x="x"in e?e.x:400,this._y="y"in e?e.y:400,this._width=e.width,this._height=e.height}clone(){return new wa({x:this._x,y:this._y,width:this._width,height:this._height})}}class Ea extends U{constructor(e){super(),this.type=W.TIDYTREE,this._width="width"in e?e.width:500,this._height="height"in e?e.height:500,this._left="left"in e?e.left:100,this._top="top"in e?e.top:100,this._orientation="orientation"in e?e.orientation:J.HORIZONTAL}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get orientation(){return this._orientation}clone(){return new Ea({width:this._width,height:this._height,top:this._top,left:this._left,orientation:this._orientation})}}class Aa extends U{constructor(e){super(),this.type=W.TREEMAP,this._width=e.width,this._height=e.height,this._left=e.left,this._top=e.top}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}clone(){return new Aa({width:this._width,height:this._height,top:this._top,left:this._left})}}function Ca(e){switch(e.type){case W.GRID:return function(e){let t=new aa(e.args);"left"in e&&(t._left=e.left);"top"in e&&(t._top=e.top);"cellBounds"in e&&(t._cellBounds=e.cellBounds.map((e=>Ta(e))));"grid"in e&&(t._grid=e.grid);return t}(e);case W.STACK:return function(e){let t=new Qn(e.args);return t}(e);case W.PACKING:return function(e){let t=new wa(e.args);return t}(e);case W.FORCE:return function(e){return new va(e.args)}(e);case W.DIRECTED:return function(e){return new xa(e.args)}(e);case W.TIDYTREE:return function(e){return new Ea(e.args)}(e);case W.TREEMAP:return function(e){return new Aa(e.args)}(e);case W.STRATA:return function(e){return new ua(e.args)}(e);default:return void console.warn("unsupported layout type for deserialization:",e.type)}}function Ta(e){return new u(e.x-e.width/2,e.y-e.height/2,e.width,e.height)}function Ra(e,t){e.type===Dt.Pie&&(e.type=Dt.Arc),e.args.type=e.type;let i=Nt(e.args);return e.id&&(i._id=e.id),e.classId&&(i._classId=e.classId),e.dataScope&&(i._dataScope=ba(e.dataScope,t)),e.bounds&&(i._bounds=Ta(e.bounds)),e.refBounds&&(i._refBounds=Ta(e.refBounds)),function(e,t,i){if(e.vertices){const r=[];for(let s of e.vertices){const e=ka(s,t,i);r.push(e)}t.vertices=r,t.segments=[];let s=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new re(t.vertices[e-1],t.vertices[e],t,s++));t.type===Dt.Rect&&t.segments.push(new re(t.vertices[t.vertices.length-1],t.vertices[0],t,s++))}t.vertexCounter=e.vertexCounter,t.segmentCounter=e.segmentCounter,t.curveMode=e.curveMode}(e,i,t),i}function ka(e,t,i){let r=new ie(e.x,e.y,t,e.id);return e.dataScope&&(r._dataScope=ba(e.dataScope,i)),"polarAngle"in e&&(r._polarAngle=e.polarAngle),r.shape=e.shape,r.width=e.width,r.height=e.height,r.radius=e.radius,r.fillColor=e.fillColor,r.opacity=e.opacity,r.strokeWidth=e.strokeWidth,r.strokeColor=e.strokeColor,r}function Sa(e){let t={};t.fillColor=e.fillColor;let i=new ma(t);console.log("======== deserialization =========");let r={};if(e.tables)for(let t in e.tables){let i=e.tables[t];r[t]=new Ft(i.data,i.url,i.attributeTypes),r[t]._id=i.id}i.tables=r;let s={};if(e.scales)for(let t in e.scales)s[t]=La(e.scales[t]);if(i.scales=s,Na(e,i,i),Ia(e,i),i.buildPeerIndex(),e.encodings){let t={};for(let r of e.encodings){let e=Va(r,i);t[e.id]=e}for(let e in t){i._addAttributeEncoding(t[e]);let r=t[e]._baseEnc?t[t[e]._baseEnc]:void 0;yt(t[e],i._depGraph,r),r?i.onChange(Ie.ATTR_VALUE,t[e]):i.onChange(Ie.CHANNEL,t[e].channel,t[e].element)}}if(e.axes)for(let t of e.axes){let e=t.args?t.args:{};e.tickValues&&Object.values(i.tables)[0].getAttributeType(t.attr)===Ae.Date&&(e.tickValues=e.tickValues.map((e=>new Date(new Date(e).toISOString())))),t.id&&(e.id=t.id),i.axis(t.channel,t.attr,e)}if(e.gridlines)for(let t of e.gridlines)i.gridlines(t.channel,t.attr,t.args);return e.bounds&&(i._bounds=Ta(e.bounds)),delete i.tables,delete i.scales,i}function Oa(e,t,i){if(e.type===Dt.Collection){let r=Lt(i);e.classId&&(r._classId=e.classId),t.addChild(r),i._itemMap[r.id]=r,lt(r,i._depGraph),dt(t,r,i._depGraph),Na(e,r,i)}else if(e.type===Dt.Glyph){let r=Vt();e.classId&&(r._classId=e.classId),t.addChild(r),i._itemMap[r.id]=r,ut(r,i._depGraph),dt(t,r,i._depGraph),Na(e,r,i)}else if(e.type===Dt.Composite){let r=new ca;t.addChild(r),i._itemMap[r.id]=r,ht(r,i._depGraph),dt(t,r,i._depGraph),Na(e,r,i),r._bounds=Ta(e.bounds)}else if(e.type===Dt.Axis){let r=new ii({});t.addChild(r),function(e,t,i){e.id&&(t._id=e.id);if(t._children=[],e.labels){let r=new vt;Na(e.labels,r,i),t._labels=r,t._children.push(r)}e.path&&(t._path=Oa(e.path,t,i));if(e.ticks){let r=new vt;Na(e.ticks,r,i),t._ticks=r,t._children.push(r)}e.title&&(t._title=Oa(e.title,t,i))}(e,r,i),i._itemMap[r.id]=r}else if(Object.values(A).includes(e.type)){let r=Ra(e,i);return i._itemMap[r.id]=r,t.addChild(r),st(r,i._depGraph),dt(t,r,i._depGraph),r}}function Ia(e,t){if(e.children)for(let i of e.children)Ia(i,t);else if(Object.values(A).includes(e.type)){let i=t._itemMap[e.id];e.links&&(i.links=e.links.map((e=>t._itemMap[e]))),e.source&&(i.source=t._itemMap[e.source]),e.target&&(i.target=t._itemMap[e.target])}}function Na(e,t,i){if(e.id&&(t._id=e.id),e.classId&&(t._classId=e.classId),e.dataScope&&(t._dataScope=ba(e.dataScope,i)),e.bounds&&(t._bounds=Ta(e.bounds)),t._sortBy=e.sortBy,e.children)for(let r of e.children)Oa(r,t,i);e.layout&&(t._layout=Ca(e.layout),t._layout.group=t,gt(t,t._layout,i._depGraph))}function La(e){let t=new Kt(e.type,e.args);return t._id=e.id,t.domain=e.domain,t.range=e.range,t}function Va(e,t){let i=Pa(e.element,e.elementType,t);i||console.warn("element not created:",e.element,e.elementType);let r=e.args?e.args:{};e.table&&(r.table=t.tables[e.table]);let s=new Kn(i,e.channel,e.attr,e.aggregator?e.aggregator:"sum",r);if(s._id=e.id,e.scales&&(s._scales=e.scales.map((e=>t.scales[e]))),r.baseEnc&&(s._baseEnc=e.args.baseEnc),e.elemGroups&&(s._elemGroups=e.elemGroups.map((e=>e.map((e=>Pa(e,i.type,t)))))),e.elem2scale){s._elem2scale={};for(let i in e.elem2scale)s._elem2scale[i]=t.scales[e.elem2scale[i]]}return r.startAngle&&(s.startAngle=r.startAngle),s}function Pa(e,t,i){if("vertex"===t){let t=e.split("_v_");return i._itemMap[t[0]].vertices.find((e=>e._id===parseInt(t[1])))}if("segment"===t){let t=e.split("_s_");return i._itemMap[t[0]].segments.find((e=>e._id===parseInt(t[1])))}return i._itemMap[e]}function Ma(e){let t={};return t.id=e._id,t.data=e._rawData,t.attributeTypes=e._attrTypes,t.url=e.url,t}function Da(e){let t={};return t.dt=e._dt.id,t.attr2value=Object.assign({},e._attr2value),t}function Ba(e,t){t.vertices=[];for(let i of e.vertices)t.vertices.push(Ga(i));t.vertexCounter=e.vertexCounter,t.segmentCounter=e.segmentCounter,t.curveMode=e.curveMode}function Ga(e){let t={};return t.type=e.type,t.id=e._id,t.x=e.x,t.y=e.y,e._dataScope&&(t.dataScope=Da(e._dataScope)),void 0!==e._polarAngle&&(t.polarAngle=e._polarAngle),t.shape=e.shape,t.width=e.width,t.height=e.height,t.radius=e.radius,t.fillColor=e.fillColor,t.opacity=e.opacity,t.strokeWidth=e.strokeWidth,t.strokeColor=e.strokeColor,t}function Fa(e){return e.type===Dt.Scene?function(e){let t=ja(e,{});t.fillColor=e.fillColor,t.scales={},t.encodings=[];for(let i in e._encodings)for(let r in e._encodings[i]){let s=e._encodings[i][r];s._forLegend||t.encodings.push(Ha(s));for(let e of s._scales)e.id in t.scales||(t.scales[e.id]=za(e))}t.tables={};let i=function(e){let t={};for(let i in e._encodings)for(let r in e._encodings[i]){let s=e._encodings[i][r];s.dataTable.id in t||s._forLegend||(t[s.dataTable.id]=s.dataTable)}for(let i of e.children)if(![Dt.Axis,Dt.Legend,Dt.Gridlines].includes(i.type)){if(i.dataScope){t[i.dataScope.dataTable.id]=i.dataScope.dataTable;break}if(i.children&&i.children.length>0){let e=i.firstChild;for(;e;){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}e=e.children&&e.children.length>0?e.firstChild:void 0}}}return t}(e);for(let e in i)t.tables[e]=Ma(i[e]);return console.log("======== serialization ========="),console.log(t),t}(e):[Dt.Collection,Dt.Glyph,Dt.Composite].includes(e.type)?ja(e,{}):e instanceof w?function(e){let t={args:{}};t.type=e.type,t.id=e.id,e.classId&&(t.classId=e.classId),e._dataScope&&(t.dataScope=Da(e._dataScope)),e.bounds&&(t.bounds=e.bounds.toJSON()),e.refBounds&&(t.refBounds=e.refBounds.toJSON()),e.links&&(t.links=e.links.map((e=>e.id))),e.source&&(t.source=e.source.id),e.target&&(t.target=e.target.id);for(let i in e.styles)i.indexOf("Color")>0&&e.styles[i]instanceof K?t.args[i]=e.styles[i].toJSON():t.args[i]=e.styles[i];switch(e.type){case Dt.Arc:case Dt.Pie:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.innerRadius=e._innerRadius,t.args.outerRadius=e._outerRadius,t.args.startAngle=e._startAngle,t.args.endAngle=e._endAngle,t.args.direction=e._direction,t.args.thickness=e._thickness}(e,t),Ba(e,t);break;case Dt.Area:!function(e,t){t.args.baseline=e._baseline,t.args.orientation=e._orientation}(e,t),Ba(e,t);break;case Dt.Circle:!function(e,t){t.args.x=e.x,t.args.y=e.y,t.args.radius=e.radius}(e,t);break;case Dt.Image:break;case Dt.Line:case Dt.Path:case Dt.BezierCurve:Ba(e,t);break;case Dt.SimpleText:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.text=e._text,t.args.anchor=e._anchor,e._backgroundColor&&(t.args.backgroundColor=e._backgroundColor),e._borderWidth&&(t.args.borderWidth=e._borderWidth),e._borderColor&&(t.args.borderColor=e._borderColor)}(e,t);break;case Dt.Polygon:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.radius=e._radius}(e,t),Ba(e,t);break;case Dt.Rect:!function(e,t){t.args.width=e.width,t.args.height=e.height,t.args.top=e.top,t.args.left=e.left}(e,t),Ba(e,t);case Dt.Ring:}return t}(e):(console.warn("unsupported serialization",e.type),{type:e.type})}function za(e){let t={};return t.type=e.type,t.id=e.id,e._args&&(t.args=e._args),t.domain=e.domain,t.range=e.range,t}function Ha(e){let t={};t.id=e._id,t.element=e._elem.id,t.elementType=e._elem.type,t.channel=e._channel,t.attr=e._attribute,t.aggregator=e._aggregator,t.table=e._table.id,t.args={},t.args.includeZero=e._includeZero,t.args.flipScale=e._flipScale,t.args.mapping=e._mapping,t.args.rangeExtent=e._preferredRangeExtent,t.args.domain=e._preferredDomain,t.args.scaleType=e._scaleType,t.args.scheme=e._colorScheme,e._baseEnc&&(t.args.baseEnc=e._baseEnc.id),t.scales=e._scales.map((e=>e.id)),t.elemGroups=e._elemGroups.map((e=>e.map((e=>e.id)))),t.elem2scale={};for(let i in e._elem2scale)t.elem2scale[i]=e._elem2scale[i].id;return"angle"==e.channel&&(t.args.startAngle=e.startAngle),t}function ja(e,t){if(t.id=e.id,t.type=e.type,e.classId&&(t.classId=e.classId),e._dataScope&&(t.dataScope=Da(e._dataScope)),t.bounds=e.bounds.toJSON(),e._layout&&(t.layout=function(e){switch(e.type){case W.GRID:return function(e){let t={args:{}};return t.type=e.type,t.args.numCols=e._numCols,t.args.numRows=e._numRows,t.args.start=e._start,t.args.direction=e._direction,t.args.colGap=e._colGap,t.args.rowGap=e._rowGap,t.args.horzCellAlignment=e._cellHorzAlignment,t.args.vertCellAlignment=e._cellVertAlignment,t.left=e._left,t.top=e._top,t.group=e.group.id,t}(e);case W.STACK:return function(e){let t={args:{}};return t.type=e.type,t.args.orientation=e._orientation,t.args.direction=e._direction,t.args.left=e._left,t.args.top=e._top,t.args.horzCellAlignment=e._horzCellAlignment,t.args.vertCellAlignment=e._vertCellAlignment,t.args.gap=e._gap,t.group=e.group.id,t}(e);case W.PACKING:return function(e){let t={args:{}};return t.type=e.type,t.args.x=e._x,t.args.y=e._y,t.args.width=e._width,t.args.height=e._height,t.group=e.group.id,t}(e);case W.FORCE:return function(e){let t={args:{}};return t.type=e.type,t.args.x=e._x,t.args.y=e._y,t.args.iterations=e._iterations,t.args.repulsion=e._repulsion,t.args.attraction=e._attraction,t.args.linkDistance=e._linkDistance,t.group=e.group.id,t}(e);case W.CLUSTER:return function(e){let t={args:{}};return t.type=e.type,t.args.size=e._size,t.args.rootX=e._rootX,t.args.rootY=e._rootY,t}(e);case W.DIRECTED:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t.args.edgeSep=e._edgeSep,t.args.spreadLinks=e._spreadLinks,t.args.direction=e._direction,t}(e);case W.TIDYTREE:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t.args.orientation=e._orientation,t}(e);case W.TREEMAP:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t}(e);case W.STRATA:return function(e){let t={args:{}};return t.type=e.type,t.args.direction=e._direction,t.args.gap=e._gap,t}(e);default:throw new Error("unknow layout type "+e.type)}}(e._layout)),t.children=[],e.children.length>0)for(let i of e.children)i instanceof ii?Ua(i,t):i instanceof Jn?Wa(i,t):t.children.push(Fa(i));return t.sortBy=e._sortBy,t}function Ua(e,t){t.axes??=[];let i={};i.type=e._type,i.id=e._id,i.attr=e._attribute,i.channel=e._channel,i.args={},i.args.orientation=e._orientation,i.args.strokeColor=e._strokeColor,i.args.textColor=e._textColor,i.args.fontSize=e._fontSize,i.args.tickOffset=e._tickOffset,i.args.tickSize=e._tickSize,i.args.tickAnchor=e._tickAnchor,i.args.tickVisible=e._tickVisible,i.args.pathVisible=e._pathVisible,i.args.labelOffset=e._labelOffset,i.args.labelFormat=e._labelFormat,i.args.titleOffset=e._titleOffset,i.args.title=e._titleText,i.args.rotateTitle=e._rotateTitle,i.args.titleVisible=e._showTitle,i.args.labelRotation=e._labelRotation,t.axes.push(i)}function Wa(e,t){t.gridlines??=[];let i={};i.type=e._type,i.id=e._id,i.attr=e._attribute,i.channel=e._channel,i.args=e._args,t.gridlines.push(i)}function Ya(e,t,i,s,n){for(let o of e){let e="background"===o.target?i:o.target;e=Array.isArray(e)?e:[e];let l="brushX"===o.event?r.brushX():"brushY"===o.event?r.brushY():r.brush();var a;l.on("start",(function(t){a&&e.length>1&&r.select(a).call(l.move,null),a=this})),l.on("brush end",(function(e){let t,a;if(e&&e.selection)switch(o.event){case"brushX":t=[e.selection[0],e.selection[1]],a=void 0;break;case"brushY":t=void 0,a=[e.selection[0],e.selection[1]];break;default:t=[e.selection[0][0],e.selection[1][0]],a=[e.selection[0][1],e.selection[1][1]]}else t=void 0,a=void 0;let l=o.eventContext;l.clear(),l.set("xInterval",t),l.set("yInterval",a),l.set("target",r.select(this).attr("id").replace("brush-","")),i.onChange(Ie.EVT_CTX,l),s._render(i,n)}));for(let i of e){let e=i.type===Dt.Axis?i.boundsWithoutTitle:i.bounds,r=[[e.left,e.top],[e.right,e.bottom]];t.append("g").attr("class","brush").attr("id","brush-"+i.id).call(l.extent(r))}}}function Xa(e,t,i,s,n){for(let a of e){let e="background"===a.target?t:t.select("#"+a.target.id),o=r.drag();o.on("drag",(e=>{let[r,o]=C(t.attr("id"),e.sourceEvent.clientX,e.sourceEvent.clientY),l=a.eventContext;l.set("x",r),l.set("y",o),l.set("dx",e.dx),l.set("dy",e.dy),i.onChange(Ie.EVT_CTX,l),s._render(i,n)})),e.call(o)}}function qa(e,t,i,r,s){for(let n of e){let e="background"===n.target?t:n.target.classId?t.selectAll("."+n.target.classId):t.select("#"+n.target.id);e.on("mouseover",(e=>{let[a,o]=C(t.attr("id"),e.clientX,e.clientY),l=n.eventContext;l.set("x",a),l.set("y",o);let h=e.target.__data__;l.set("elements",[h]),l.set("element",h),i.onChange(Ie.EVT_CTX,l),r._render(i,s)})),e.on("mouseout",(e=>{let t=n.eventContext;t.set("elements",[]),t.set("element",void 0),i.onChange(Ie.EVT_CTX,t),r._render(i,s)}))}}function Ka(e,t,i,s,n){for(let t of e)if(t.isWidgetDriven()){let e=(Array.isArray(t.target)?t.target:[t.target]).map((e=>document.getElementById(e))),r=t.eventContext;for(let a of e)a.addEventListener(t.event,(function(){r.set("inputValue",a.value),"checkbox"===a.type&&r.set("checked",a.checked),i.onChange(Ie.EVT_CTX,r),s._render(i,n)}))}else t.isKeyboardDriven()&&r.select("body").on("keydown",(e=>{e.key===t.key&&$a(t,i,s,n)}))}function Za(e,t,i,r,s){t.on("wheel",(n=>{for(let r of e){n.preventDefault(),n.stopPropagation();let[e,s]=C(t.attr("id"),n.clientX,n.clientY),a=r.eventContext;a.set("deltaX",n.deltaX),a.set("deltaY",n.deltaY),a.set("x",e),a.set("y",s),i.onChange(Ie.EVT_CTX,a)}r._render(i,s)}))}function $a(e,t,i,r){if(Array.isArray(e.callback))for(let s=0;s<e.callback.length;s++)e.callback[s](),i._render(t,r,e.animation[s]);else e.callback(),i._render(t,r,e.animation)}function Ja(e,t,i,r,s){t.on("click",(n=>{for(let r of e){let[e,s]=C(t.attr("id"),n.clientX,n.clientY),a=r.eventContext,o=[];r.target.type&&o.push({property:"type",value:r.target.type}),r.target.classId&&o.push({property:"classId",value:r.target.classId});let l=G(i,e,s,o),h=a.get("elements").slice();l?r.isCumulative&&!a.get("elements").includes(l)?h.push(l):h=[l]:h=[],h.length===a.get("elements").length&&h.every(((e,t)=>e===a.get("elements")[t]))||(a.clear(),a.set("x",e),a.set("y",s),a.set("elements",h),a.set("element",h.length>0?h[h.length-1]:void 0),i.onChange(Ie.EVT_CTX,a))}r._render(i,s)}))}class Qa{constructor(e){this._svgId=e,this._svg=document.getElementById(this._svgId),this._compMap={},this._decoMap={},this._brushCreated=0,this._lastTriggerEvt=void 0}render(e,t){this._compMap={},this._decoMap={},this._brushCreated=0;let i=t||{};if(!this._svg.querySelector("defs")){const e=document.createElementNS("http://www.w3.org/2000/svg","defs");this._svg.appendChild(e)}this._render(e,i),this._registerEvents(e,i)}_render(e,t,i){for(let e in this._decoMap)this._decoMap[e].remove(),delete this._decoMap[e];this._removed={};for(let e in this._compMap)this._removed[e]=1;this._renderItem(e,t,i);for(let e in this._removed)this._compMap[e].remove(),delete this._compMap[e]}_registerEvents(e,t){let i=r.select("#"+this._svgId);for(let r in e.interactionTriggers){let s=Object.values(e.interactionTriggers[r]);switch(r){case"click":i.on("click",null),Ja(s,i,e,this,t);break;case"brush":case"brushX":case"brushY":Ya(s,i,e,this,t);break;case"drag":case"dragX":case"dragY":Xa(s,i,e,this,t);break;case"hover":qa(s,i,e,this,t);break;case"change":case"input":Ka(s,0,e,this,t);break;case"scroll":Za(s,i,e,this,t)}}}clear(){for(;this._svg.firstChild;)this._svg.firstChild.remove();const e=this._svg.cloneNode(!0);this._svg.parentNode.replaceChild(e,this._svg),this._svg=e,this._compMap={},this._decoMap={}}_renderItem(e,t,i){if(this._configSVG(e),!e.children&&!1===e._dirty)return;let r=this._compMap[e.id];if(i){const e=i.delay||0,t=i.duration||0;r.style.transition=`all ${t}ms ease ${e}ms`}switch(e.type){case Dt.Scene:!function(e,t){t.style.background=e.fillColor?e.fillColor:"#fff"}(e,this._svg);break;case Dt.Circle:!function(e,t){t.setAttribute("cx",e.x),t.setAttribute("cy",e.y),t.setAttribute("r",e.radius)}(e,r);break;case Dt.Rect:!function(e,t){let i=e.bounds;t.setAttribute("x",i.left),t.setAttribute("y",i.top),t.setAttribute("width",i.width),t.setAttribute("height",i.height)}(e,r);break;case Dt.Path:case Dt.BezierCurve:case Dt.BundledPath:case Dt.Chord:case Dt.Polygon:case Dt.Link:case Dt.Pie:case Dt.Line:case Dt.Area:case Dt.Ring:case Dt.Arc:case Dt.Gridlines:!function(e,t){t.setAttribute("d",e.getSVGPathData()),e.closed||(t.style.fill="none"),(e.id.includes("axis")||e.id.includes("gridlines"))&&(t.style.shapeRendering="crispEdges"),e.type===Dt.BundledPath&&(t.style.mixBlendMode="multiply")}(e,r);break;case Dt.SimpleText:!function(e,t,i){if(t.setAttribute("text-anchor",x(e.anchor[0])),t.setAttribute("alignment-baseline",x(e.anchor[1])),t.setAttribute("dominant-baseline",x(e.anchor[1])),t.setAttribute("x",e.x),t.setAttribute("y",e.y),i){e._updateBounds();let t=e.bounds;i.setAttribute("x",t.left-5),i.setAttribute("y",t.top-5),i.setAttribute("width",t.width+10),i.setAttribute("height",t.height+10),i.setAttribute("rx",5),i.setAttribute("ry",5),i.style.fill=e.backgroundColor,i.style.stroke=e.borderColor,i.style.strokeWidth=e.borderWidth}if(e.textPath){let i=t.querySelector("textPath");i||(i=document.createElementNS("http://www.w3.org/2000/svg","textPath"),t.appendChild(i)),i.setAttribute("href","#"+b(e)),i.setAttribute("startOffset",e.textPathOffset),i.textContent=e.text}else t.textContent=e.text}(e,r,this._compMap[m(e)]);break;case Dt.RichText:!function(e,t){for(;t.firstChild;)t.firstChild.remove();t.setAttribute("width",e.width),t.setAttribute("x",e.x),t.setAttribute("y",e.y),t.style.border="1px solid #ddd";let i=document.createElementNS("http://www.w3.org/1999/xhtml","div");i.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),i.style.width="100%",i.style.padding="10px",i.style.backgroundColor="rgba(255, 255, 255, 0.85)",i.style.color="black",i.style.visibility="visible",i.style.boxSizing="border-box",i.style.opacity="1",i.innerHTML=e.text,t.appendChild(i),t.setAttribute("height",i.offsetHeight)}(e,r);break;case Dt.Image:!function(e,t){t.setAttribute("href",e.src),t.setAttribute("x",e.x),t.setAttribute("y",e.y),t.setAttribute("width",e.width),t.setAttribute("height",e.height)}(e,r)}if(e._rotate&&r.setAttribute("transform","rotate("+e._rotate.join(" ")+")"),function(e,t,i){if(!e.styles)return;let r=Object.keys(e.styles);e.type===Dt.RichText&&(r=r.filter((e=>["textAnchor","fillColor"].indexOf(e)<0)));for(let s of r)if(void 0!==e.styles[s])if(s.indexOf("Color")>0&&e.styles[s].type==Dt.LinearGradient){const r=i.querySelector("defs"),n=e.styles[s];if(!r.querySelector("#"+n.id)){const e=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");e.setAttribute("id",n.id),e.setAttribute("x1",n.x1+"%"),e.setAttribute("x2",n.x2+"%"),e.setAttribute("y1",n.y1+"%"),e.setAttribute("y2",n.y2+"%");for(let t of n.stops){const i=document.createElementNS("http://www.w3.org/2000/svg","stop");i.setAttribute("offset",t.offset+"%"),i.style.stopColor=t.color,i.style.stopOpacity=t.opacity,e.appendChild(i)}r.appendChild(e)}t.style[v[s]]="url(#"+n.id+")"}else if(t.style[v[s]]=e.styles[s],"visibility"===s)if(e.type===Dt.SimpleText){if(e.hasBackground()){const t=i.querySelector("#"+m(e));t&&(t.style[v[s]]=e.styles[s])}}else if(e.type===Dt.RichText){const i=t.querySelector("div");i&&(i.style.visibility=e.styles[s])}}(e,r,this._svg),e.vertices&&e.vertices.length>0&&e.vertices.map((e=>e.shape)).filter((e=>void 0!==e)).length>0&&this._renderVertices(e),t&&t.bounds?this._renderBounds(e):E(e)&&t&&t.refBounds&&this._renderRefBounds(e),e.clipMask){const t=this._svg.querySelector("defs");let i=t.querySelector("#"+e.id+"-clipPath");i||(i=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),i.setAttribute("id",e.id+"-clipPath"),t.appendChild(i));let s=i.querySelector("rect");s||(s=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.appendChild(s)),s.setAttribute("x",e.clipMask.left),s.setAttribute("y",e.clipMask.top),s.setAttribute("width",e.clipMask.width),s.setAttribute("height",e.clipMask.height),r.setAttribute("clip-path","url(#"+e.id+"-clipPath)")}if(e.children)for(let r of e.children)this._renderItem(r,t,i);else e._dirty=!1}_configSVG(e){if(e.id in this._compMap)delete this._removed[e.id],e.type===Dt.SimpleText&&(e.hasBackground()&&delete this._removed[m(e)],e.textPath&&delete this._removed[b(e)]);else{let t,i=e.parent;if(t=i&&i.id&&i.id in this._compMap?this._svg.querySelector("#"+i.id):this._svg,e.type===Dt.SimpleText){if(e.hasBackground()){const i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("id",m(e)),t.appendChild(i),this._compMap[m(e)]=i}if(e.textPath){const t=this._svg.querySelector("defs"),i=b(e);let r=t.querySelector("#"+i);r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("id",i),t.appendChild(r),this._compMap[i]=r),r.setAttribute("d",e.textPath),r.style.fill="none"}}const r=document.createElementNS("http://www.w3.org/2000/svg",this._getSVGElementType(e));t?t.appendChild(r):console.warn("Parent element not found for ",e),this._compMap[e.id]=r}if(e.type==Dt.Gridlines){const t=this._compMap[e.id].parentNode;t.insertBefore(this._compMap[e.id],t.firstChild)}this._compMap[e.id].setAttribute("id",e.id),this._compMap[e.id].__data__=e;let t=e.type;e.classId&&(t+=" "+e.classId),e.parent&&e.parent.type===Dt.Axis&&(t+=e.id.endsWith("_ticks")?" axis_ticks":e.id.endsWith("_labels")?" axis_labels":""),this._compMap[e.id].setAttribute("class",t)}_renderBounds(e){let t=e.bounds;if(e.layout&&"grid"==e.layout.type&&this._renderLayout(e),!(e.id in this._decoMap)){const t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("class","deco"),this._svg.appendChild(t),this._decoMap[e.id]=t}const i=this._decoMap[e.id];i.setAttribute("x",t.left),i.setAttribute("y",t.top),i.setAttribute("width",t.width),i.setAttribute("height",t.height),i.setAttribute("fill","none"),i.setAttribute("stroke","blue"),i.setAttribute("stroke-width","1px"),i.setAttribute("stroke-dasharray","5,5")}_renderRefBounds(e){let t=e.refBounds;if(t){if(!(e.id in this._decoMap)){const t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("class","deco"),this._svg.appendChild(t),this._decoMap[e.id]=t}const i=this._decoMap[e.id];i.setAttribute("x",t.left),i.setAttribute("y",t.top),i.setAttribute("width",t.width),i.setAttribute("height",t.height),i.setAttribute("fill","none"),i.setAttribute("stroke","blue"),i.setAttribute("stroke-width","1px"),i.setAttribute("stroke-dasharray","5,5")}}_renderVertices(e){let t=e.id+"-vertices";if(t in this._compMap)delete this._removed[t];else{let i=e.parent,r=i?i.id:this._svgId;const s=this._svg.querySelector("#"+r),n=document.createElementNS("http://www.w3.org/2000/svg","g");n.setAttribute("id",t),s.appendChild(n),this._compMap[t]=n}if(0===e.vertices.map((e=>e.shape)).filter((e=>void 0!==e)).length)return void(this._compMap[t].style.visibility="hidden");this._compMap[t].style.visibility="visible";let i=e.vertices.filter((e=>void 0!==e.shape));for(let e of i){let i=t+"-"+e.id;if(i in this._compMap)if(e.shape!==this._compMap[i].tagName){this._compMap[i].remove();const r=document.createElementNS("http://www.w3.org/2000/svg",e.shape);r.setAttribute("id",i),this._compMap[t].appendChild(r),this._compMap[i]=r,delete this._removed[i]}else delete this._removed[i];else{const r=document.createElementNS("http://www.w3.org/2000/svg",e.shape);r.setAttribute("id",i),this._compMap[t].appendChild(r),this._compMap[i]=r}const r=this._compMap[i];"rect"==e.shape?(r.setAttribute("x",e.x-e.width/2),r.setAttribute("y",e.y-e.height/2),r.setAttribute("width",e.width),r.setAttribute("height",e.height)):"circle"==e.shape&&(r.setAttribute("cx",e.x),r.setAttribute("cy",e.y),r.setAttribute("r",e.radius)),r.style.fill=e.fillColor,r.style.opacity=e.opacity,r.style.strokeWidth=e.strokeWidth,r.style.stroke=e.strokeColor}}_renderLayout(e){let t=e.id+"-grid";if(!(t in this._decoMap)){const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttribute("id",t),e.setAttribute("class","deco"),this._svg.appendChild(e),this._decoMap[t]=e}let i=e.layout.cellBounds;e.layout.rowGap;this._decoMap[t].querySelectorAll("rect").forEach((e=>e.remove()));for(let e of i){const i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x",e.left),i.setAttribute("y",e.top),i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.setAttribute("stroke","blue"),i.setAttribute("stroke-width","1px"),i.setAttribute("stroke-dasharray","5,5"),i.setAttribute("fill","none"),this._decoMap[t].appendChild(i)}}_getSVGElementType(e){switch(e.type){case Dt.Rect:return"rect";case Dt.Collection:case Dt.Group:case Dt.Glyph:case Dt.Scene:case Dt.Axis:case Dt.Legend:case Dt.Composite:return"g";case Dt.Area:case Dt.Path:case Dt.Polygon:case Dt.Ring:case Dt.Pie:case Dt.Arc:case Dt.BezierCurve:case Dt.BundledPath:case Dt.Chord:case Dt.Line:case Dt.Gridlines:return"path";case Dt.Circle:return"circle";case Dt.SimpleText:return"text";case Dt.RichText:return"foreignObject";case"vertex":if("circle"==e.shape)return"circle";if("rect"==e.shape)return"rect";throw"argument exception";case"image":return"image"}}}function eo(e,t){return void 0===e&&void 0===t||void 0!==e&&void 0!==t}function to(e,t){const i=Object.keys(e),r=Object.keys(t);return i.length===r.length&&(0===i.length||i.every((e=>r.includes(e))))}function io(e,t){if(!eo(e.layout,t.layout))return console.log("Not both defined or undefined:",e.bounds,t.bounds),!1;let i=e.layout,r=t.layout;if(!i&&!r)return!0;if(i.type!==r.type)return console.log("layout types are different:",i,r),!1;switch(i.type){case W.GRID:return function(e,t){e._cellBounds.length!==t._cellBounds.length&&console.log("cell bounds length different:",e,t);for(let i=0;i<e._cellBounds;i++)if(!so(e._cellBounds[i],t._cellBounds[i]))return console.log("cell bounds not equal:",e,t),!1;for(let i=0;i<e._grid.length;i++)for(let r=0;r<e._grid[i].length;r++)if(e._grid[i][r]!==t._grid[i][r])return console.log("grid not equal",e,t),!1;return e._numCols===t._numCols&&e._numRows===t._numRows&&e._start===t._start&&e._direction===t._direction&&e._rowGap===t._rowGap&&e._colGap===t._colGap&&e._cellHorzAlignment===t._cellHorzAlignment&&e._cellVertAlignment===t._cellVertAlignment&&e._left===t._left&&e._top===t._top}(i,r);case W.STACK:return function(e,t){return e._orientation===t._orientation&&e._direction===t._direction&&e._left===t._left&&e._top===t._top&&e._horzCellAlignment===t._horzCellAlignment&&e._vertCellAlignment===t._vertCellAlignment&&e._gap===t._gap}(i,r);case W.PACKING:return function(e,t){return e._x===t._x&&e._y===t._y&&e._width===t._width&&e._height===t._height}(i,r);case W.FORCE:return function(e,t){return e._x===t._x&&e._y===t._y&&e._iterations===t._iterations&&e._repulsion===t._repulsion&&e._attraction===t._attraction&&e._linkDistance===t._linkDistance}(i,r);case W.DIRECTED:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left&&e._edgeSep===t._edgeSep&&e._spreadLinks===t._spreadLinks&&e._direction===t._direction}(i,r);case W.TIDYTREE:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left&&e._orientation===t._orientation}(i,r);case W.STRATA:return function(e,t){return e._direction===t._direction&&e._gap===t._gap}(i,r);case W.TREEMAP:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left}(i,r);default:return!1}}function ro(e,t){if(!eo(e.bounds,t.bounds))return console.log("Not both defined or undefined:",e.bounds,t.bounds),!1;let i=e.bounds,r=t.bounds;return!i&&!r||so(i,r)}function so(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function no(e,t){if(!eo(e,t))return console.log("Not both defined or undefined:",e,t),!1;if(e.type!==t.type)return console.log("Different mark types:",e,t),!1;if(e.id!==t.id)return console.log("id not equal:",e,t),!1;if(e.classId!==t.classId)return console.log("class id not equal:",e,t),!1;if(!oo(e,t))return console.log("DataScopes not equal",e,t),!1;if(!ro(e,t))return console.log("Bounds not equal",e,t),!1;if(!eo(e.links,t.links))return console.log("Not both defined or undefined: links ",e.links,t.links),!1;if(!eo(e.source,t.source))return console.log("Not both defined or undefined: source ",e.source,t.source),!1;if(!eo(e.target,t.target))return console.log("Not both defined or undefined: links ",e.target,t.target),!1;if(e.links&&t.links&&e.links.length!==t.links.length)return console.log("unequal number of links",e,t),!1;if(e.source&&t.source&&!no(e.source,t.source))return console.log("different sources",e.source,t.source),!1;if(e.target&&t.target&&!no(e.target,t.target))return console.log("different targets",e.target,t.target),!1;switch(e.type){case Dt.Arc:case Dt.Pie:return ao(e,t)?e.x===t.x&&e.y===t.y&&e.innerRadius===t.innerRadius&&e.outerRadius===t.outerRadius&&e.startAngle===t.startAngle&&e.endAngle===t.endAngle&&e.direction===t.direction&&e.thickness===t.thickness:(console.log("vertices not equal:",e,t),!1);case Dt.Area:return ao(e,t)?e.baseline===t.baseline&&e.orientation===t.orientation:(console.log("vertices not equal:",e,t),!1);case Dt.Circle:return e.x===t.x&&e.y===t.y&&e.radius===t.radius;case Dt.Image:return console.warn("not implemented"),!0;case Dt.Line:case Dt.Path:case Dt.BezierCurve:return!!ao(e,t)||(console.log("vertices not equal:",e,t),!1);case Dt.SimpleText:return e.x===t.x&&e.y===t.y&&e.text===t.text&&e.anchor[0]===t.anchor[0]&&e.anchor[1]===t.anchor[1];case Dt.Polygon:return ao(e,t)?e.x===t.x&&e.y===t.y&&e.radius===t.radius:(console.log("vertices not equal:",e,t),!1);case Dt.Rect:return ao(e,t)?e.width===t.width&&e.height===t.height&&e.top===t.top&&e.left===t.left:(console.log("vertices not equal:",e,t),!1);case Dt.Ring:default:return console.warn("not implemented"),!0}}function ao(e,t){if(e.vertices.length!==t.vertices.length)return console.log("unequal number of vertices:",e,t),!1;for(let i=0;i<e.vertices.length;i++){let r=e.vertices[i],s=t.vertices[i];return r.id!==s.id?(console.log("vertex id not equal:",r,s),!1):r.x!==s.x||r.y!==s.y?(console.log("vertex position not equal:",r,s),!1):oo(r,s)?r._polarAngle===s._polarAngle&&r.shape===s.shape&&r.width===s.width&&r.height==s.height&&r.radius==s.radius&&r.fillColor==s.fillColor&&r.opacity==s.opacity&&r.strokeWidth==s.strokeWidth&&r.strokeColor==s.strokeColor:(console.log("vertex data scopes not equal:",r.dataScope,s.dataScope),!1)}}function oo(e,t){if(!eo(e.dataScope,t.dataScope))return console.log("Not both defined or undefined:",e.dataScope,t.dataScope),!1;if(!e.dataScope&&!t.dataScope)return!0;let i=e.dataScope,r=t.dataScope;if(!to(i._attr2value,r._attr2value))return!1;for(let e in i._attr2value)if(i._attr2value[e]!==r._attr2value[e])return!1;return i._dt.id===r._dt.id&&i._tuples.length===r._tuples.length}function lo(e,t){return e.type!==t.type&&console.log("Different types:",e.type,t.type),[Dt.Collection,Dt.Glyph,Dt.Composite].includes(e.type)?ho(e,t):e instanceof w?no(e,t):void 0}function ho(e,t){let i=e.children.filter((e=>!Object.values(Bt).includes(e.type))),r=t.children.filter((e=>!Object.values(Bt).includes(e.type)));if(i.length!==r.length)return console.log("children length not equal:",i,r),!1;if(e.id!==t.id)return console.log("id not equal:",e,t),!1;if(e.classId!==t.classId)return console.log("class id not equal:",e,t),!1;if(!oo(e,t))return console.log("DataScopes not equal",e.dataScope,t.dataScope),!1;if(!ro(e,t))return console.log("Bounds not equal",e,t),!1;if(!io(e,t))return console.log("Layouts not equal",e,t),!1;if(!function(e,t){if(!to(e,t))return console.log("different keys",e,t),!1;for(let i in e)if(e[i]!==t[i])return!1;return!0}(e._sortBy,t._sortBy))return console.log("SortBy not equal",e,t),!1;for(let e=0;e<i.length;e++)if(!lo(i[e],r[e]))return console.log("Not equal",i[e],r[e]),!1;return!0}class co extends U{constructor(e){super(),this.type=W.CIRCULAR,this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._radius="radius"in e?e.radius:100}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}clone(){return new co({x:this._x,y:this._y,radius:this._radius})}}class uo extends U{constructor(e){super(),this.type=W.CLUSTER,this._isRadial="radial"in e&&e.radial,this._angleExtent="angleExtent"in e?e.angleExtent:360,this._radius="radius"in e?e.radius:300,this._rootX="x"in e?e.x:300,this._rootY="y"in e?e.y:300,this._orientation="orientation"in e?e.orientation:J.HORIZONTAL,this._width="width"in e?e.width:800,this._height="height"in e?e.height:600,this._left="left"in e?e.left:60,this._top="top"in e?e.top:100,this._tree="tree"in e?e.tree:void 0}get radius(){return this._radius}get angleExtent(){return this._angleExtent}get x(){return this._rootX}get y(){return this._rootY}get width(){return this._width}get height(){return this._height}get left(){return this._left}get top(){return this._top}isRadial(){return this._isRadial}get orientation(){return this._orientation}clone(){return new uo({radius:this._radius,angleExtent:this._angleExtent,x:this._rootX,y:this._rootY,radial:this._isRadial,orientation:this._orientation,left:this._left,top:this._top,width:this._width,height:this._height,tree:this._tree})}}e.csv=async function(e){return async function(e){let t=await jt("GET",e),i=r.csvParse(t.trim(),r.autoType);return new Ft(i,e)}(e)},e.csvString=function(e){return function(e){let t=r.csvParse(e.trim(),r.autoType);return new Ft(t,"fromString")}(e)},e.deserialize=function(e){return Sa(e)},e.graphJSON=async function(e){return async function(e){let t=await jt("GET",e);return new be(JSON.parse(t),e)}(e)},e.isEqual=function(e,t){return function(e,t){return e.fillColor!==t.fillColor?(console.log("fillColor not equal:",e,t),!1):ho(e,t)}(e,t)},e.layout=function(e,t){let i=t||{};switch(e.toLowerCase()){case W.STACK:return new Qn(i);case W.PACKING:return new wa(i);case W.FORCE:return new va(i);case W.DIRECTED:return new xa(i);case W.TIDYTREE:return new Ea(i);case W.TREEMAP:return new Aa(i);case W.CIRCULAR:return new co(i);case W.CLUSTER:return new uo(i);case W.GRID:default:return new aa(i)}},e.locateElement=function(e,t,i,r,s){return G(e,t,i,r)},e.renderer=function(e,t){return new Qa(t)},e.scene=function(e){return new ma(e)},e.serialize=function(e){return Fa(e)},e.table=function(e){return new Ft(e,"")},e.treeJSON=async function(e){return async function(e){let t=await jt("GET",e);return new ye(JSON.parse(t),e)}(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
|