mascot-vis 1.7.4 → 1.7.5
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/dist/mascot-min.js +21 -21
- package/dist/mascot.js +1254 -28
- package/package.json +1 -1
package/dist/mascot-min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* version: 1.7.
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","d3","pixi.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msc={},t.d3,t.PIXI)}(this,(function(t,e,i){"use strict";function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var n=s(e),r=s(i);class a{constructor(t,e,i,s){this.left=t,this.top=e,this.width=i,this.height=s}toJSON(){let t={};return t.left=this.left,t.top=this.top,t.width=this.width,t.height=this.height,t}union(t){let e=Math.min(this.left,t.left),i=Math.min(this.top,t.top),s=Math.max(this.right,t.right),n=Math.max(this.bottom,t.bottom);return new a(e,i,s-e,n-i)}clone(){return new a(this.left,this.top,this.width,this.height)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get x(){return(this.left+this.right)/2}get y(){return(this.top+this.bottom)/2}get center(){return(this.left+this.right)/2}get middle(){return(this.top+this.bottom)/2}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}overlap(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}const o="id",h="atlas_rowId",l=["linear","power","log","sqrt","symlog","identity","time","ordinal","band","point","ordinalColor","sequentialColor","divergingColor"],c="natural",d="basis",u="bumpX",f="bumpY",p="linear",g="step",_="CatmullRom",m="cardinal",y={Grid:"grid",Circular:"circular",Stack:"stack",Treemap:"treemap",Packing:"packing",Force:"force",TidyTree:"tidytree",Sugiyama:"sugiyama",Strata:"strata"},v="vertical",b="horizontal",x="angular",w="radial",k={Up:"up",Down:"down",Left:"left",Right:"right",Inward:"inward",Outward:"outward",Clockwise:"clockwise",Anticlockwise:"anticlockwise"},C={Top:"top",Left:"left",Bottom:"bottom",Right:"right",Center:"center",Middle:"middle"},S="alignment",E="affixation",T={Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"pointText",Collection:"collection",Group:"group",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable"},A={Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"},I="max",O="min",R="avg",M="median",N="sum",F="count",P="mean",B="percentile 25",L="percentile 75",j={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"},D="Cannot find relevant information to create an axis for ",V="Cannot change scale type to ",z={FIELD_NONEXISTENT:"Data field does not exist in the data table",INCOMPLETE_REPEAT_INFO:"Incomplete information to do repeat. You must specify an item, a categorical data field and a data table",REPEAT_BY_NONCAT:"Repeat only works on a string or date field",PARTITION_BY_NONCAT:"Divide only works on a string or date field",DENSIFY_BY_NONCAT:"Densify only works on a string or date field",INCOMPLETE_REPOPULATE_INFO:"Incomplete information to re-populate. You must specify an item, a categorical data field and a data table",REPOPULATE_BY_NONCAT:"Repopulate only works on a string or date field",REPOPULATE_DT_MISMATCH:"Cannot repopulate with a data table that is different from the item's parent's data table",COMPNT_NON_REPEATABLE:"Item not repeatable",REPEAT_NODE_LINK:"To repeat with a tree or a network, you need to provide two marks, one for node and one for link",INCOMPLETE_PARTITION_INFO:"Incomplete information to divide. You must specify an item, a categorical data field and a data table",COMPNT_NON_PARTITIONABLE:"Item cannot be divided",INCOMPLETE_DENSIFY_INFO:"Incomplete information to densify. You must specify an item, a categorical data field and a data table",COMPNT_NON_DENSIFIABLE:"Item cannot be densified",STRATIFY_WITHOUT_TREE:"Stratify only works on a tree dataset",STRATIFY_WRONG_ITEM:"Stratify only works on a circle or a rectangle",BIND_WITHOUT_DATASCOPE:"Item must be repeated or divided by data first before applyng binding",UNKNOWN_ALIGNMENT:"Unkown alignment",UNKNOWN_Orientation:"Unkown orientation",UNKNOWN_DIRECTION:"Unkown direction",UNKOWNN_SCALE_TYPE:"Unknown scale type",UNKNOWN_ANCHOR:"Unknown anchor",INCOMPLETE_BINDING_INFO:"Incomplete binding information. You must specify an item, a data field and a visual channel",MULTIPLE_VALUES_PER_FIELD:"Multiple distinct field values exist",DIFFERENT_SCALE_TYPE:"Cannot merge different types of scale",INSUFFICIENT_DATA_SCOPES:"Insufficient data to divide or densify a mark",INCORRECT_CONSTRAINT_INFO:"Constrain information is incorreclty passed",FEATURE_NOT_IMPLEMENTED:"This feature has not been implemented yet",LAYOUT_WITHOUT_TREE:"The layout can only be applied to a tree"};class G{constructor(t){this.group=void 0}run(){}clone(){}}class W extends G{constructor(t){super(),this.type="grid",this._numCols=t.numCols,this._numRows=t.numRows,this._dir="dir"in t?t.dir:[W.direction.Left2Right,W.direction.Top2Bottom],this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&this._validateCellAlignment("h",t.horzCellAlignment)?t.horzCellAlignment:C.Left,this._cellVertAlignment="vertCellAlignment"in t&&this._validateCellAlignment("v",t.vertCellAlignment)?t.vertCellAlignment:C.Bottom}_validateCellAlignment(t,e){return"h"===t&&[C.Left,C.Center,C.Right].indexOf(e)>=0||("v"===t&&[C.Top,C.Middle,C.Bottom].indexOf(e)>=0||(console.warn("Invalid alignment:",e),!1))}toJSON(){let t={args:{}};return t.type=this.type,t.args.numCols=this._numCols,t.args.numRows=this._numRows,t.args.colGap=this._colGap,t.args.rowGap=this._rowGap,t.args.horzCellAlignment=this._cellHorzAlignment,t.args.vertCellAlignment=this._cellVertAlignment,t.left=this._left,t.top=this._top,t.args.dir=this._dir,t}clone(){return new W({numCols:this._numCols,numRows:this._numRows,dir:this._dir,colGap:this._colGap,rowGap:this._rowGap})}get cellBounds(){let t,e,i=this.group,s=this._colGap,n=this._rowGap;this._numRows?(e=this._numRows,t=Math.ceil(this.group.children.length/this._numRows)):this._numCols&&(t=this._numCols,e=Math.ceil(this.group.children.length/this._numCols));let r=i.children.map((t=>t.bounds));if(void 0===this._left){let t=r.map((t=>t.left)),e=r.map((t=>t.top));this._left=Math.min(...t),this._top=Math.min(...e)}let o=r.map((t=>t.width)),h=r.map((t=>t.height)),l=Math.max(...o),c=Math.max(...h),d=i.getInternalEncodings("x"),u=i.getInternalEncodings("y"),f=i.getInternalEncodings("width"),p=i.getInternalEncodings("height"),g=0;if(d.length>0){let t=d[d.length-1];l=t.scale.rangeExtent,g=t.scale.range[0],"point"===t.scale.type&&(l+=t.anyItem.bounds.width)}else f.length>0&&f[f.length-1]._rectNegativeValues&&(l=f[f.length-1].scale.rangeExtent,g=f[f.length-1].scale.range[0]);if(u.length>0){let t=u[u.length-1];c=t.scale.rangeExtent,"point"===t.scale.type&&(c+=t.anyItem.bounds.height)}else p.length>0&&p[p.length-1]._rectNegativeValues&&(c=p[p.length-1].scale.rangeExtent);let _=[],m=e*t;switch(this._dir[0]){case W.direction.Left2Right:switch(this._dir[1]){case W.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(this._left+(l+s)*(e%t)+g,this._top+(c+n)*Math.floor(e/t),l,c));break;case W.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(this._left+(l+s)*(e%t)+g,this._top+(this.numRows-1-Math.floor(e/t))*(c+n),l,c))}break;case W.direction.Right2Left:switch(this._dir[1]){case W.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(g+this._left+(t-1)*(l+s)-(l+s)*(e%t),this._top+(c+n)*Math.floor(e/t),l,c));break;case W.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(g+this._left+(t-1-e%t)*(l+s),this._top+(this.numRows-1-Math.floor(e/t))*(c+n),l,c))}break;case W.direction.Top2Bottom:switch(this._dir[1]){case W.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),l,c));break;case W.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*(this.numCols-1)-(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),l,c))}break;case W.direction.Bottom2Top:switch(this._dir[1]){case W.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),l,c));break;case W.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*(this.numCols-1)-(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),l,c))}}return _}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.cellBounds,e=this.group.getInternalEncodings("x"),i=this.group.getInternalEncodings("y"),s=this.group.getInternalEncodings("width"),n=this.group.getInternalEncodings("height");for(let s=0;s<this.group.children.length;s++){let n=this.group.children[s],r=t[s],a=r.x-n.bounds.x,o=r.y-n.bounds.y;n._doTranslate(a,o);let h=0,l=0;if(0==e.length)switch(this._cellHorzAlignment){case C.Left:h=r.left-n.bounds.left;break;case C.Center:h=r.x-n.bounds.x;break;case C.Right:h=r.right-n.bounds.right}if(0==i.length)switch(this._cellVertAlignment){case C.Top:l=r.top-n.bounds.top;break;case C.Middle:l=r.y-n.bounds.y;break;case C.Bottom:l=r.bottom-n.bounds.bottom}n._doTranslate(h,l)}if(e.length>0)for(let t of e)t._apply();else if(s.length>0){let t=s[s.length-1];t._rectNegativeValues&&t._apply()}if(i.length>0)for(let t of i)t._apply();else if(n.length>0){let t=n[n.length-1];t._rectNegativeValues&&t._apply()}this.group._updateBounds()}set rowGap(t){this._rowGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get rowGap(){return this._rowGap}set colGap(t){this._colGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get colGap(){return this._colGap}set numCols(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"columns for",this.group.children.length,"items in grid"):(this._numCols=t,this._numRows=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numRows(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"rows for",this.group.children.length,"items in grid"):(this._numRows=t,this._numCols=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}set vertCellAlignment(t){if(t!=C.Top&&t!=C.Bottom&&t!=C.Middle)throw z.UNKOWN_ALIGNMENT;this._cellVertAlignment=t,this.run()}get vertCellAlignment(){return this._cellVertAlignment}set horzCellAlignment(t){if(t!=C.Left&&t!=C.Center&&t!=C.Right)throw z.UNKOWN_ALIGNMENT;this._cellHorzAlignment=t,this.run()}get horzCellAlignment(){return this._cellHorzAlignment}}W.direction={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"};class U{constructor(t){this._stops=[],this.type=T.LinearGradient,this.id=this.type+pt[this.type]++,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 t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,i){this._stops.push({offset:t,color:e,opacity:i})}get stops(){return this._stops}}class q{constructor(t){if(this._dataScope=void 0,this._id=void 0,this.attrs={},this.styles={},this.staticProperties={},void 0!==t)for(let e in j)e in t&&(this.styles[e]=t[e])}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){if(!this._bounds)return!1;if(!this._bounds.contains(t,e))return!1;switch(this.type){case T.Rect:case T.PointText:return!0;case T.Circle:return Math.sqrt(Math.pow(t-this.x,2)+Math.pow(e-this.y,2))<=this.radius+this.strokeWidth;case T.Path:{let i=mt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),this.closed?i.isPointInPath(s,t,e):i.isPointInStroke(s,t,e)}case T.Line:{let i=mt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),i.isPointInStroke(s,t,e)}default:{let i=mt.getContext(),s=new Path2D(this.getSVGPathData());return i.isPointInPath(s,t,e)}}}toJSON(){let t={};t.type=this.type,t.id=this.id,this.classId&&(t.classId=this.classId),this._dataScope&&(t.dataScope=this._dataScope.toJSON()),t.args={};for(let e in this.attrs)t.args[e]=this.attrs[e];for(let e in this.styles)e.indexOf("Color")>0&&this.styles[e]instanceof U?t.args[e]=this.styles[e].toJSON():t.args[e]=this.styles[e];return t}getScene(){let t=this;for(;t;){if(t.type==T.Scene)return t;t=t.parent}}set dataScope(t){this._dataScope=t}get dataScope(){return this._dataScope}duplicate(){let t=this.getScene().mark(this.type);return this.copyPropertiesTo(t),t.classId=this.classId,this._dataScope&&(t._dataScope=this._dataScope.clone()),t}_doTranslate(t,e){}set visibility(t){this.styles.visibility=t}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity=t}}function J(t){return t>=-1e-12&&t<=1e-12}class Y{constructor(t,e){this.x=t,this.y=e}transform(t){return t?t._transformPoint(this):this}negate(){return new Y(-this.x,-this.y)}subtract(t){return new Y(this.x-t.x,this.y-t.y)}isZero(){return J(this.x)&&J(this.y)}isCollinear(t){let e=this.x,i=this.y,s=t.x,n=t.y;return Math.abs(e*n-i*s)<=1e-8*Math.sqrt((e*e+i*i)*(s*s+n*n))}}class H{constructor(t,e,i){this.type="vertex",this._id=i,this.x=t.x,this.y=t.y,this.dataScope=void 0,this.parent=e,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 bounds(){switch(this.shape){case"rect":return new a(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new a(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new a(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}toJSON(){let t={};return t.type=this.type,t.id=this._id,t.x=this.x,t.y=this.y,this.dataScope&&(t.dataScope=this.dataScope.toJSON()),void 0!==this._polarAngle&&(t.polarAngle=this._polarAngle),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}static fromJSON(t,e){let i=new H(t,e,t.id);return t.dataScope&&(i.dataScope=t.dataScope),"polarAngle"in t&&(i.polarAngle=t.polarAngle),i.shape=t.shape,i.width=t.width,i.height=t.height,i.radius=t.radius,i.fillColor=t.fillColor,i.opacity=t.opacity,i.strokeWidth=t.strokeWidth,i.strokeColor=t.strokeColor,i}_doTranslate(t,e){this.x+=t,this.y+=e}_clone(t){let e=new H(new Y(this.x,this.y),t,this._id);return this.dataScope&&(e.dataScope=this.dataScope.clone()),e.shape=this.shape,e.width=this.width,e.height=this.height,e.radius=this.radius,e.fillColor=this.fillColor,e.opacity=this.opacity,e.strokeWidth=this.strokeWidth,e.strokeColor=this.strokeColor,e}set polarAngle(t){this._polarAngle=t}get polarAngle(){return this._polarAngle}}H.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class ${constructor(t,e,i,s){this.type="segment",this._id=s,this.vertex1=t,this.vertex2=e,this.dataScope=void 0,this.parent=i}get id(){return this.parent.id+"_s_"+this._id}_doTranslate(t,e){this.vertex1._doTranslate(t,e),this.vertex2._doTranslate(t,e)}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}}class Z extends q{constructor(t){if(super(t),this.type="type"in t?t.type:T.Path,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none"),this.vertices=[],this.vertexCounter=0,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,void 0!==t){for(let e of H.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&this._setVertices(t.vertices)}}toJSON(){let t=super.toJSON();if(t.type=this.type,t.id=this.id,this.type===T.Rect)t.args.width=this.width,t.args.height=this.height,t.args.top=this.top,t.args.left=this.left;else if(this.type===T.Circle)t.args.x=this.x,t.args.y=this.y,t.args.radius=this.radius;else if(this.type===T.Arc)t.args.x=this._x,t.args.y=this._y,t.args.innerRadius=this._innerRadius,t.args.outerRadius=this._outerRadius,t.args.startAngle=this._startAngle,t.args.endAngle=this._endAngle;else if(this.type===T.Pie)t.args.x=this._x,t.args.y=this._y,t.args.radius=this.radius,t.args.startAngle=this.startAngleDeg,t.args.endAngle=this.endAngleDeg;else{t.vertices=[];for(let e of this.vertices)t.vertices.push(e.toJSON());this.type===T.Polygon?(t.args.x=this._x,t.args.y=this._y,t.args.radius=this._radius):this.type===T.Area&&(t.args.baseline=this._baseline,t.args.orientation=this._orientation)}t.vertexCounter=this.vertexCounter,t.segmentCounter=this.segmentCounter,t.curveMode=this.curveMode,this._bounds&&(t.bounds=this._bounds.toJSON());for(let e of H.styles)t.args[e]=this[e];return t}_setVertices(t){let e,i;this.vertices=[],this.segments=[];for(let s=0;s<t.length;s++)if(s!=t.length-1||t[s][0]!==t[0][0]||t[s][1]!==t[0][1]||this.type!==T.Path){i=new Y(t[s][0],t[s][1]),e=new H(i,this,this.vertexCounter++);for(let t of H.styles)if(this[t]){let i=t.replace("vx","");e[i[0].toLowerCase()+i.slice(1)]=this[t]}this.vertices.push(e),s>0&&this.segments.push(new $(this.vertices[s-1],this.vertices[s],this,this.segmentCounter++))}let s=t[0],n=t[t.length-1];(s[0]===n[0]&&s[1]===n[1]||this.type===T.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new $(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of H.styles)this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScope&&(t._dataScope=this._dataScope.clone()),t.closed=this.closed,t.curveMode=this.curveMode,t.vertices=[],t.segments=[];for(let e of this.vertices)t.vertices.push(e._clone(t));t.segmentCounter=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new $(t.vertices[e-1],t.vertices[e],t,t.segmentCounter++));t.closed&&t.segments.push(new $(t.vertices[t.vertices.length-1],t.vertices[0],t,t.segmentCounter++))}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}set strokeColor(t){this.styles.strokeColor=t}get strokeWidth(){return this.styles.strokeWidth}set strokeWidth(t){this.styles.strokeWidth=t}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash=t}_doTranslate(t,e){for(let i of this.vertices)i._doTranslate(t,e);this._updateBounds()}resize(t,e,i,s){let n=this.bounds,r=0===n.width?1:n.width,a=0===n.height?1:n.height;if("right"===i)for(let e of this.vertices)e.x=n.right-t/r*(n.right-e.x);else for(let e of this.vertices)e.x=n.left+t/r*(e.x-n.left);if("top"===s)for(let t of this.vertices)t.y=n.top+e/a*(t.y-n.top);else for(let t of this.vertices)t.y=n.bottom-e/a*(n.bottom-t.y);this._updateBounds()}_updateBounds(){let t=this.vertices.map((t=>t.x)),e=this.vertices.map((t=>t.y)),i=Math.min(...t),s=Math.min(...e),n=Math.max(...t),r=Math.max(...e);this._bounds=new a(i,s,n-i,r-s)}addVertex(t,e,i){let s=new H(new Y(t,e),this,this.vertexCounter++);this.vertices.splice(i,0,s)}sortVertices(t,e){this.vertices.sort(((e,i)=>e[t]-i[t])),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}sortVerticesByData(t,e,i){let s;s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1,this.vertices.sort(s),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}getSVGPathData(){let t=n.path(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t of this.vertices)e.point(t.x,t.y);return this.closed&&e.point(this.vertices[0].x,this.vertices[0].y),e.lineEnd(),t._}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(t){switch(t){case c:return n.curveNatural;case d:return n.curveBasis;case u:return n.curveBumpX;case f:return n.curveBumpY;case p:return n.curveLinear;case g:return n.curveStep;case _:return n.curveCatmullRom;case m:return n.curveCardinal;default:return n.curveLinear}}get vxShape(){return this._vxShape}set vxShape(t){this._vxShape=t;for(let e of this.vertices)e.shape=t}get vxWidth(){return this._vxWidth}set vxWidth(t){this._vxWidth=t;for(let e of this.vertices)e.width=t}get vxHeight(){return this._vxHeight}set vxHeight(t){this._vxHeight=t;for(let e of this.vertices)e.height=t}get vxRadius(){return this._vxRadius}set vxRadius(t){this._vxRadius=t;for(let e of this.vertices)e.radius=t}get vxFillColor(){return this._vxFillColor}set vxFillColor(t){this._vxFillColor=t;for(let e of this.vertices)e.fillColor=t}get vxStrokeColor(){return this._vxStrokeColor}set vxStrokeColor(t){this._vxStrokeColor=t;for(let e of this.vertices)e.strokeColor=t}get vxStrokeWidth(){return this._vxStrokeWidth}set vxStrokeWidth(t){this._vxStrokeWidth=t;for(let e of this.vertices)e.strokeWidth=t}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}}function K(t,e){if("field"in e){if(!t.dataScope)return!1;let i=e.field;if("value"in e)return t.dataScope.getFieldValue(i)===e.value;if("interval"in e){let s=t.dataScope.getFieldValue(i);return s>=e.interval[0]&&s<=e.interval[1]}return"values"in e?e.values.indexOf(t.dataScope.getFieldValue(i))>=0:t.dataScope.hasField(i)}if("channel"in e){let i=e.channel;if("value"in e)return t[i]===e.value;if("interval"in e)return t[i]>=e.interval[0]&&t[i]<=e.interval[1];if("values"in e)return e.values.indexOf(t[i])>=0}else{if("type"in e)return t.type===e.type;if("id"in e)return t.id===e.id;if("classId"in e)return t.classId===e.classId;if("fields"in e){if(!t.dataScope)return!1;let i=e.fields[0],s=e.fields[1],n=t.dataScope.getFieldValue(i),r=t.dataScope.getFieldValue(s);switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}}}return!1}function X(t,e){let i=[];return Q(t,e,i),i}function Q(t,e,i){if(t&&"axis"!=t.type&&"legend"!=t.type&&"gridlines"!=t.type)if(tt(t,e)&&i.push(t),t.vertices)for(let s of t.vertices.concat(t.segments))tt(s,e)&&i.push(s);else if(t.children&&t.children.length>0)for(let s of t.children)Q(s,e,i)}function tt(t,e){for(let i of e)if(!K(t,i))return!1;return!0}function et(t,e){return"vertex"==t.type?function(t,e){if(!t.classId){if(t.dataScope){let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=X(e,[{classId:i.classId}]),n=[];if(i.type===T.Area){let e=i.vertices.indexOf(t)<i.vertices.length/2;for(let t of s){let i=e?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);n=n.concat(i.filter((t=>t.dataScope)))}}else for(let t of s)n=n.concat(t.vertices.filter((t=>t.dataScope)));return n}{let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=i.vertices.indexOf(t),n=X(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.vertices[s]);return r}}}(t,e):"segment"==t.type?function(t,e){if(t.dataScope){let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=X(e,[{classId:i.classId}]),n=[];for(let t of s)n=n.concat(t.segments);return n}{let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=i.segments.indexOf(t),n=X(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.segments[s]);return r}}(t,e):t.classId?X(e,[{classId:t.classId}]):[]}function it(t,e){let i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout&&(!e||e&&i.layout.type===e))return i.layout;i=i.parent}}function st(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function nt(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout&&i.layout.type==y.Grid){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function rt(t,e){let i,s=t.parent;for(;s&&s.type!==T.Scene;)s.layout&&(!e||e&&s.layout.type===e)&&(i=s.layout),s=s.parent;return i}function at(t){if(t.classId)return t.classId;if("vertex"==t.type&&t.dataScope){if(t.parent.type===T.Area){let e=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;return t.parent.classId+"_v_"+(e?0:t.parent.vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v_"+t.parent.vertices.indexOf(t):"segment"==t.type&&t.dataScope?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s_"+t.parent.segments.indexOf(t):null}function ot(t){let e=[];for(let i of t)i.parent&&e.indexOf(i.parent)<0&&e.push(i.parent);return e}function ht(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e.push(i),e=e.concat(ht(i));return e}function lt(t){let e=[];if(ut(t))e.push(t);else if(t.children&&t.children.length>0&&!dt(t))for(let i of t.children)e=e.concat(lt(i));return e}function ct(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e=e.concat(ct(i));else e.push(t);return e}function dt(t){return t.type===T.Axis||t.type===T.Legend||t.type===T.Gridlines}function ut(t){return t instanceof q}function ft(t){return t instanceof Z}const pt={area:0,rect:0,circle:0,pie:0,line:0,path:0,ring:0,arc:0,image:0,pointText:0,collection:0,group:0,scene:0,axis:0,glyph:0,legend:0,polygon:0,gridlines:0,LinearGradient:0,link:0,scale:0,datatable:0};function gt(t,e){if(e.getEncodingByItem(t,"x"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==y.Grid&&e.numCols>1)return!1}return!t.parent||t.parent.type==T.Scene||gt(t.parent,e)}function _t(t,e){if(e.getEncodingByItem(t,"y"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==y.Grid&&e.numRows>1)return!1}return!t.parent||t.parent.type==T.Scene||_t(t.parent,e)}var mt={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var t=this.getCanvas();return t?t.getContext("2d"):null}},yt={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}};function vt(t){let e=t.parent;return e.type==T.Scene?t:vt(e)}function bt(t){let e=t.parent;return t.type==T.Collection?e.type==T.Collection?bt(e):t:e.type!=T.Scene?bt(e):void 0}function xt(t,e,i,s){return[i*Math.cos(kt(s))+t,e-i*Math.sin(kt(s))]}function wt(t,e,i,s){let n=function(t){return 180*t/Math.PI}(Math.atan2(s-e,t-i));n=Math.round(10*n+Number.EPSILON)/10,n<0&&(n+=360);let r=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-s,2));return r=Math.round(10*r+Number.EPSILON)/10,[n,r]}function kt(t){return t*Math.PI/180}function Ct(t){let e=t.vertices.length;for(let i=0;i<t.vertices.length/2;i++){let s=i,n=e-i-1,r=t.vertices[s],a=t.vertices[n];if(r.x!=a.x||r.y!=a.y)return r.x==a.x?"horizontal":"vertical"}}class St{constructor(){this.children=[],this._dataScope=void 0,this._layout=void 0,this.type=T.Group,this._id=this.type+pt[this.type]++}get id(){return this._id}set id(t){this.type!==T.Scene&&this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}toJSON(){let t={};if(t.type=this.type,t.id=this.id,this._dataScope&&(t.dataScope=this._dataScope.toJSON()),this.classId&&(t.classId=this.classId),this._layout&&(t.layout=this._layout.toJSON()),this._bounds&&(t.bounds=this._bounds.toJSON()),t.children=[],this.children.length>0&&this.type!=T.Axis)for(let e of this.children)t.children.push(e.toJSON());return this.childrenOrder&&(t.childrenOrder=this.childrenOrder),t}addChild(t){this.children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this.children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this.children=[]}getScene(){let t=this;for(;t;){if(t.type==T.Scene)return t;t=t.parent}}get dataScope(){return this._dataScope}set dataScope(t){if(this._dataScope=t,void 0===t)for(let e of this.children)e.dataScope=t;else for(let e of this.children)e.dataScope?e.dataScope=e.dataScope.merge(t):e.dataScope=t}_doTranslate(t,e){for(let i of this.children)i._doTranslate(t,e);this._updateBounds(),this._layout&&(void 0!==this._layout._left&&(this._layout._left+=t),void 0!==this._layout._top&&(this._layout._top+=e),void 0!==this._layout.x&&(this._layout.x+=t),void 0!==this._layout.y&&(this._layout.y+=e)),this._updateBounds()}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],i=this.getScene(),s=Object.keys(i.encodings),n=[];for(;e&&(e.classId&&n.indexOf(e.classId)<0&&n.push(e.classId),e.children);)e=e.children[0];let r=[];for(let e of s){let s=e.split("_");for(let a of n)s[0]==a&&i.encodings[e][t]&&r.push(i.encodings[e][t])}return r}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t)t.group=this,this._layout.run();else{let t=this.getInternalEncodings("x"),e=this.getInternalEncodings("y");for(let e of t)e._map(),e._apply();for(let t of e)t._map(),t._apply()}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){if(this.children.length>0){this._bounds=this.children[0].bounds.clone();for(let t=1;t<this.children.length;t++)"hidden"!=this.children[t].visibility&&(this._bounds=this._bounds.union(this.children[t].bounds));if(this._layout&&"grid"==this._layout.type){let t=this._layout.cellBounds;for(let e=0;e<t.length;e++)this._bounds=this._bounds.union(t[e])}}else this._bounds=new a(0,0,0,0)}sortChildrenByData(t,e,i){let s;switch(this.children[0].dataScope.getFieldType(t)){case A.Date:break;case A.Number:case A.Integer:s=(e,i)=>e.dataScope.aggregateNumericalField(t)-i.dataScope.aggregateNumericalField(t);break;case A.String:s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1}this.children.sort(s),e&&this.children.reverse(),this.layout&&this.layout.run(),this._childrenOrder={field:t,direction:e?"desc":"asc",ranking:i}}sortChildren(t,e){let i;switch(t){case"x":case"y":case"width":case"height":i=(e,i)=>e.bounds[t]-i.bounds[t];break;default:i=(e,i)=>e[t]-i[t]}this.children.sort(i),e&&this.children.reverse(),this.layout&&this.layout.run(),this.childrenOrder={channel:t,reverse:e}}set visibility(t){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}get visibility(){return this._visibility?this._visibility:"visible"}}function Et(t){return[...new Set(t)]}function Tt(t,e){if(e.hasField(t))return!0;if(e.tree&&e.tree.nodeTable.hasField(t.split(".")[1]))return!0;throw new Error(z.FIELD_NONEXISTENT+", field: "+t+", data table: "+e.name)}function At(t){return t<0?t+360:t>360?t-360:t}class It{constructor(t){this._field2value={},this._dt=t,this._tuples=this._dt.data}toJSON(){let t={};return t.dt=this._dt.id,t.f2v=Object.assign({},this._field2value),t}isFullTable(){return 0===Object.keys(this._field2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get fields(){return Object.keys(this._field2value)}get dataTable(){return this._dt}get filters(){return this._field2value}merge(t){let e=new It(this._dt);for(let i in t._field2value)e=e.cross(i,t._field2value[i]);for(let t in this._field2value)e=e.cross(t,this._field2value[t]);return e}cross(t,e){let i=this.clone();return i._field2value[t]=e,i._updateTuples(t,e),i}clone(){let t=new It(this._dt);return t._field2value=Object.assign({},this._field2value),t._tuples=this._tuples.map((t=>t)),t}getFieldValue(t){let e=this._tuples.map((e=>e[t]));return e=[...new Set(e)],e.length,e[0]}getUniqueFieldValues(t){let e=this._tuples.map((e=>e[t]));return[...new Set(e)]}hasField(t){return t in this._field2value}getFieldType(t){return this._dt.getFieldType(t)}aggregateNumericalField(t,e){let i=this._tuples.map((e=>e[t]));switch(e){case I:return Math.max(...i);case O:return Math.min(...i);case R:case P:return n.mean(i);case M:return n.median(i);case F:return i.length;case B:return n.quantile(i,.25);case L:return n.quantile(i,.75);case N:default:return n.sum(i)}}_updateTuples(t,e){this._tuples=this._tuples.filter((i=>i[t]==e))}}function Ot(t,e,i,s,n){let r=n?s.transformField(i,n):i,a=s.getFieldType(r);if(a!=A.String&&a!=A.Date&&a!=A.Integer)throw new Error(z.REPEAT_BY_NONCAT+": "+r+" is "+a);if(!Kc(e))throw new Error(z.COMPNT_NON_REPEATABLE);return function(t,e,i,s){let n=s.getFieldSummary(i).unique.map((t=>e.dataScope?e.dataScope.cross(i,t):new It(s).cross(i,t)));n=n.filter((t=>!t.isEmpty()));let r=t.collection();r.dataScope=e.dataScope?e.dataScope.clone():new It(s),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}return r.children.forEach(((t,e)=>t.dataScope=n[e])),t._reapplySizeBindings(e),r}(t,e,r,s)}class Rt extends G{constructor(t){super(t),this.type=y.Stack,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:C.Left,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:C.Bottom,this._gap="gap"in t?t.gap:0}toJSON(){let t={args:{}};return t.type=this.type,t.args.orientation=this._orientation,t.args.direction=this._direction,t.args.left=this._left,t.args.top=this._top,t.args.gap=this._gap,t.args.horzCellAlignment=this._horzCellAlignment,t.args.vertCellAlignment=this._vertCellAlignment,t}clone(){let t=new Rt({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}_stackAreasVert(){let t=this.group.children,e=this.group.bounds,i=this._vertCellAlignment===C.Top?e.top:e.bottom,s=this._vertCellAlignment===C.Top?1:-1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],h=Math.abs(a.y-o.y),l=i+r[t]*s,c=i+(r[t]+h)*s;a._doTranslate(0,l-a.y),o._doTranslate(0,c-o.y),r[t]+=h}e._updateBounds()}if(this.vertCellAlignment===C.Middle)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.middle+r[t]/2;s._doTranslate(0,o-e.bottom),a._doTranslate(0,o-e.bottom)}i._updateBounds()}this.group._updateBounds()}_stackAreasHorz(){let t=this.group.children,e=this.group.bounds,i=this._horzCellAlignment===C.Right?e.right:e.left,s=this._horzCellAlignment===C.Right?-1:1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],h=Math.abs(a.x-o.x),l=i+r[t]*s,c=i+(r[t]+h)*s;a._doTranslate(0,l-a.y),o._doTranslate(0,c-o.y),r[t]+=h}e._updateBounds()}if(this._horzCellAlignment===C.Center)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.center-r[t]/2;s._doTranslate(0,o-e.left),a._doTranslate(0,o-e.left)}i._updateBounds()}this.group._updateBounds()}_stackAreas(){this.group.children[0].orientation===b?this._stackAreasVert():this._stackAreasHorz()}_stackArcs(){let t=this.group,e=this.startAngle?this.startAngle:90;if((this._direction?this._direction:k.Clockwise)===k.Clockwise)for(let i of t.children){let t=At(e-i.angle);i.adjustAngle(t,e),e=t}else for(let i of t.children){let t=At(e+i.angle);i.adjustAngle(e,t),e=t}}_stackRects(){let t=this.group.getScene(),e=this.group,i=this._orientation,s=e.children.map((t=>t.bounds)),n=s.map((t=>t.left)),r=s.map((t=>t.top)),a=s.map((t=>t.width)),o=s.map((t=>t.height)),h=null==this._left?Math.min(...n):this._left,l=null==this._top?Math.min(...r):this._top,c=Math.max(...a),d=Math.max(...o);if(i==v){let i=h+c/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=i-n.bounds.x,a=l+n.bounds.height/2-n.bounds.y;l+=n.bounds.height+this._gap,n._doTranslate(r,a);let o=0,d=0;if(!t.getEncodingByItem(n,"x"))switch(this._horzCellAlignment){case C.Left:o=h-n.bounds.left;break;case C.Center:o=h+c/2-n.bounds.x;break;case C.Right:o=h+c-n.bounds.right}n._doTranslate(o,d)}}else{let i=l+d/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=h+n.bounds.width/2-n.bounds.x,a=i-n.bounds.y;h+=n.bounds.width+this._gap,n._doTranslate(r,a);let o=0,c=0;if(!t.getEncodingByItem(n,"y"))switch(this._vertCellAlignment){case C.Top:c=l-n.bounds.top;break;case C.Middle:c=l+d/2-n.bounds.y;break;case C.Bottom:c=l+d-n.bounds.bottom}n._doTranslate(o,c)}}this.group._updateBounds()}run(){null!=this.group&&this.group.children&&0!==this.group.children.length&&("area"==this.group.children[0].type?this._stackAreas():this.group.children[0].type==T.Arc||this.group.children[0].type==T.Pie?this._stackArcs():this._stackRects())}set vertCellAlignment(t){if(t!=C.Top&&t!=C.Bottom&&t!=C.Middle)throw z.UNKOWN_ALIGNMENT;this._vertCellAlignment=t,this.run()}get vertCellAlignment(){return this._vertCellAlignment}set horzCellAlignment(t){if(t!=C.Left&&t!=C.Center&&t!=C.Right)throw z.UNKOWN_ALIGNMENT;this._horzCellAlignment=t,this.run()}get horzCellAlignment(){return this._horzCellAlignment}get cellBounds(){return this.group.children.map((t=>t.bounds))}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}}function Mt(t,e,i,s,n,r){let a=r?n.transformField(s,r):s,o=n.getFieldType(a);if(o!=A.String&&o!=A.Date)throw new Error(z.PARTITION_BY_NONCAT+": "+a+" is "+o);if(!Xc(e))throw new Error(z.COMPNT_NON_PARTITIONABLE);switch(e.type){case T.Line:return function(t,e,i,s){let n,r,a=et(e,t),o=s.getFieldSummary(i).unique.map((t=>new It(s).cross(i,t))),h={},l=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>l&&(l=e.length),h[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope,i.parent.addChild(s);let a=h[i.id],o=i.vertices[0].x,c=i.vertices[0].y,d=i.vertices[1].x,u=i.vertices[1].y;i.classId=e.id,i.vertices[0].x=o,i.vertices[0].y=c,i.vertices[1].x=o+(d-o)/l,i.vertices[1].y=c+(u-c)/l,i.dataScope=a[0],s.addChild(i);for(let t=1;t<a.length;t++){let e=i.duplicate();e.vertices[0].x=o+(d-o)*t/l,e.vertices[0].y=c+(u-c)*t/l,e.vertices[1].x=o+(d-o)*(t+1)/l,e.vertices[1].y=c+(u-c)*(t+1)/l,e.dataScope=a[t],s.addChild(e)}i==e&&(n=s)}return n}(t,e,a,n);case T.Circle:return function(t,e,i,s,n){let r,a,o=i||x,h=et(e,t);if(o==x)h.forEach((i=>{let o=i.dataScope?i.dataScope:new It(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/l,f=90;for(let s=0;s<l;s++){let n=t.mark("pie",{radius:i.radius,x:i.x,y:i.y,startAngle:At(f-u*(s+1)),endAngle:At(f-u*s),strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}c.layout=Yc("stack",{direction:k.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)}));else{if(o!=w)throw z.UNKNOWN_Orientation+": "+o;h.forEach((i=>{let o=i.dataScope?i.dataScope:new It(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=i.radius/l;for(let s=0;s<l;s++){let n=t.mark("ring",{x:i.x,y:i.y,innerRadius:s*u,outerRadius:(s+1)*u,strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)}))}return r}(t,e,i,a,n);case T.Rect:return function(t,e,i,s,n){let r,a=et(e,t),o=i||b;if(o!=b&&o!=v)throw z.UNKNOWN_Orientation+": "+o;let h,l=n.getFieldSummary(s).unique.map((t=>new It(n).cross(s,t))),c={},d=0;for(let t of a){let e=l;t.dataScope&&(e=l.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>d&&(d=e.length),c[t.id]=e}for(let i of a){let s=t.collection();null==h&&(h=s.id),s.classId=h,s.dataScope=i.dataScope?i.dataScope:new It(n),i.parent.addChild(s);let a=c[i.id],l=i.bounds,u=l.left,f=l.top,p=o==b?l.width/d:l.width,g=o==b?l.height:l.height/d;i.classId=e.id,i.resize(p,g),i.dataScope=a[0],s.addChild(i);for(let t=1;t<a.length;t++){let e=i.duplicate();e.resize(p,g),e.dataScope=a[t],s.addChild(e)}s.layout=new Rt({orientation:o,left:u,top:f}),i==e&&(r=s)}t._reapplySizeBindings(r);let u=t.getRelatedAxes(e);for(let i of u)i._item.classId===e.classId&&(i._item=r,i._items=et(r,t));return r}(t,e,i,a,n);case T.Area:return function(t,e,i,s,n){let r,a=et(e,t),o=a[0];if(4==o.vertices.length&&i==b&&o.vertices[0].x!==o.vertices[1].x)for(let t of a){let e=t.vertices[1];t.vertices[1]=t.vertices[3],t.vertices[3]=e}let h,l=n.getFieldSummary(s).unique.map((t=>new It(n).cross(s,t)));for(let s of a){let a=t.collection();null==h&&(h=a.id),a.classId=h,a.dataScope=s.dataScope?s.dataScope:new It(n),s.parent.addChild(a);let o=s.left,c=s.top,d=i==b?s.width/l.length:s.width,u=i==b?s.height:s.height/l.length;s.classId=e.id,s.resizeArea(d,u),a.addChild(s);for(let t=1;t<l.length;t++){let t=s.duplicate();t.resizeArea(d,u),a.addChild(t)}for(let t=0;t<a.children.length;t++){let e=a.children[t];e.dataScope?e.dataScope=e.dataScope.merge(l[t]):e.dataScope=l[t];for(let t of e.vertices)t.dataScope?t.dataScope=e.dataScope.merge(t.dataScope):t.dataScope=e.dataScope}a.layout=new Rt({orientation:i,left:o,top:c}),s==e&&(r=a)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case T.Ring:return function(t,e,i,s,n){let r,a,o=i||x,h=et(e,t);if(o==x)return h.forEach((i=>{let o=i.dataScope?i.dataScope:new It(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/l,f=90;for(let s=0;s<l;s++){let n=t.mark("arc",{innerRadius:i.innerRadius,outerRadius:i.outerRadius,x:i.x,y:i.y,startAngle:At(f-u*(s+1)),endAngle:At(f-u*s),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}c.layout=Yc("stack",{direction:k.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw z.UNKNOWN_Orientation+": "+o}(t,e,i,a,n);case T.Pie:return function(t,e,i,s,n){let r,a,o=i||w,h=et(e,t);if(o==w)return h.forEach((i=>{let o=i.dataScope?i.dataScope:new It(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent;for(let s=0;s<l;s++){let n=t.mark("arc",{innerRadius:s*i.outerRadius/l,outerRadius:(s+1)*i.outerRadius/l,x:i.x,y:i.y,startAngle:i.startAngle,endAngle:i.endAngle,strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw z.UNKNOWN_Orientation+": "+o}(t,e,i,a,n)}}function Nt(t,e,i,s,n,r,a,o){let h=r?n.transformField(s,r):s,l=n.getFieldType(h);if(l!=A.String&&l!=A.Date&&l!=A.Number)throw new Error(z.DENSIFY_BY_NONCAT+": "+h+" is "+l);if(!Qc(e))throw new Error(z.COMPNT_NON_DENSIFIABLE);switch(e.type){case T.Line:return function(t,e,i,s){let n,r=et(e,t);for(let a of r){let r=a.dataScope?a.dataScope:new It(s),o=s.getFieldSummary(i).unique.map((t=>r.cross(i,t)));o=o.filter((t=>!t.isEmpty()));let h=Object.assign({},a.styles);for(let t of H.styles)a[t]&&(h[t]=a[t]);let l=a.vertices[0].x,c=a.vertices[0].y,d=[],u=a.vertices[1].x-l,f=a.vertices[1].y-c;for(let t=0;t<o.length;t++)d.push([l+t*u/(o.length-1),c+t*f/(o.length-1)]);h.vertices=d;let p=t.mark("path",h);p.classId=e.id,p.dataScope=r;let g=a.parent;g.addChild(p),g.removeChild(a);for(let[t,e]of p.vertices.entries())e.dataScope?e.dataScope=e.dataScope.merge(o[t]):e.dataScope=o[t];a==e&&(n=p)}return n}(t,e,h,n);case T.Circle:return function(t,e,i,s,n,r){let a;return et(e,t).forEach((o=>{let h=o.dataScope?o.dataScope:new It(s),l=s.getFieldSummary(i).unique.map((t=>h.cross(i,t)));l=l.filter((t=>!t.isEmpty()));let c=l.length;if(c<3)throw Error(z.INSUFFICIENT_DATA_SCOPES);let d=360/c,u=[],f=[],p="clockwise"==r?-1:1;for(let t=0;t<l.length;t++){let e=n+p*t*d;f[t]=e;let i=xt(o.x,o.y,o.radius,f[t]);u.push(i)}let g=t.mark("polygon",{x:o.x,y:o.y,radius:o.radius,vertices:u});g.dataScope=h,g.styles=Object.assign({},o.styles);for(let t of H.styles)o[t]&&(g[t]=o[t]);let _=o.parent;_.addChild(g),_.removeChild(o);for(let[t,e]of g.vertices.entries())e.polarAngle=f[t],e.dataScope?e.dataScope=e.dataScope.merge(l[t]):e.dataScope=l[t];o==e&&(a=g)})),a}(t,e,h,n,a,o);case T.Rect:case T.Area:return function(t,e,i,s,n){let r,a=et(e,t);for(let o of a){let a=n.getFieldType(s),h=o.dataScope?o.dataScope:new It(n),l=n.getFieldSummary(s).unique.map((t=>h.cross(s,t)));l=a==A.Number?l:l.filter((t=>!t.isEmpty())),a!=A.Number&&a!=A.Date||l.sort(((t,e)=>t._field2value[s]>e._field2value[s]?1:-1));let c=Object.assign({},o.styles),d=o.vertices[0].x,u=o.vertices[0].y,f=o.vertices[o.vertices.length-2].x,p=o.vertices[o.vertices.length-2].y,g=[],_=f-d,m=p-u;for(let t=0;t<l.length;t++)g.push(i==v?[f,u+(l.length-1-t)*m/(l.length-1)]:[d+t*_/(l.length-1),u]);for(let t=0;t<l.length;t++)g.push(i==v?[d,u+t*m/(l.length-1)]:[d+(l.length-1-t)*_/(l.length-1),p]);c.vertices=g;let y=t.mark("area",c);y.classId="area"==o.type?o.classId:"area"+o.classId.substring(9),y.dataScope=h,y.orientation=i,y.baseline=i===b?C.Bottom:C.Left;let x=o.parent;x.addChild(y),x.removeChild(o);for(let[t,e]of y.vertices.entries())t>=l.length?e.dataScope=h.merge(l[2*l.length-1-t]):e.dataScope=h.merge(l[t]);o==e&&(r=y)}return r}(t,e,i,h,n)}}class Ft extends Z{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}set height(t){this.resize(this.width,t)}set width(t){this.resize(t,this.height)}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(t,e,i,s){"right"===i?(this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x),"top"===s?(this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y),this._updateBounds()}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 Pt extends Z{constructor(t){super(t),this.attrs.x="x"in t?t.x:0,this.attrs.y="y"in t?t.y:0,this.attrs.radius="radius"in t?t.radius:100}get radius(){return this.attrs.radius}get x(){return this.attrs.x}get y(){return this.attrs.y}get area(){return Math.PI*Math.pow(this.radius,2)}set x(t){this.attrs.x=t,this._updateBounds()}set y(t){this.attrs.y=t,this._updateBounds()}set radius(t){this.attrs.radius=t,this._updateBounds()}resize(t,e,i,s){let n=Math.min(t,e)/2,r=n-this.attrs.radius;this.attrs.radius=n,"right"==i?this.attrs.x-=r:this.attrs.x+=r,"top"==s?this.attrs.y+=r:this.attrs.y-=r,this._updateBounds()}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this.attrs.x-this.attrs.radius,this.attrs.y-this.attrs.radius,2*this.attrs.radius,2*this.attrs.radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t.attrs.x=this.attrs.x,t.attrs.y=this.attrs.y,t.attrs.radius=this.attrs.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(" ")}}function Bt(t){return t._query=function(){this.data=[];let t=this.field,e=this.items,i=this.aggregator;switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case A.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,i)))}},t._map=function(){let t,e=this.items,i=this.data,s=this.channel;if(t=Jc(this.scaleType),null==this.data.find((t=>t<0))||"width"!=s&&"height"!=s||0!=e[0].type.indexOf("rect")){let n,r;t.domain=[0,Math.max(...i)],"radius"==s||"outerRadius"==s||"innerRadius"==s?(n=0,r=Math.max(...e.map((t=>t[s]))),r<20&&(r=20)):"area"==s?(n=0,r=Math.max(...e.map((t=>t.bounds.width*t.bounds.height))),r<400&&(r=400)):"fontSize"==s?(n=2,r=Math.max(...e.map((t=>parseFloat(t.styles.fontSize))))):"strokeWidth"==s?(n=1,r=Math.max(...e.map((t=>parseFloat(t.styles.strokeWidth)))),r==n&&(r=n+5)):(n=0,r=Math.max(...e.map((t=>t.bounds[s])))),this.rangeExtent&&(r=n+this.rangeExtent),this.range&&(n=this.range[0],r=this.range[1]),t._setRange([n,r])}else this._rectNegativeValues=!0,t.domain=[Math.min(...i),Math.max(...i)],"width"==s?t._setRange([0,Math.max(...e.map((t=>t.width)))]):t._setRange([0,Math.max(...e.map((t=>t.height)))]);this.scale||(this.scale=t),this.scale._addEncoding(this)},t._apply=function(){if("radius"==this.channel||"outerRadius"==this.channel||"innerRadius"==this.channel){for(let t=0;t<this.items.length;t++){this.items[t][this.channel]=this.scale.map(this.data[t])}this.scene._relayoutAncestors(this.anyItem,this.items)}else if(this._rectNegativeValues){if("width"==this.channel){let t=Math.min(...this.items.map((t=>t.bounds.left)));for(let e=0;e<this.items.length;e++){let i,s=this.items[e],n=s.leftSegment.vertex1.x,r=s.rightSegment.vertex1.x;i=s.parent&&s.parent.type==T.Collection?s.parent.bounds.left:t,s.rightSegment._doTranslate(i+this.scale.map(this.data[e])-r,0),s.leftSegment._doTranslate(i+this.scale.map(0)-n,0),s._updateBounds()}}else if("height"==this.channel){let t=Math.min(...this.items.map((t=>t.bounds.top)))+this.scale.rangeExtent;for(let e=0;e<this.items.length;e++){let i,s=this.items[e],n=s.topSegment.vertex1.y,r=s.bottomSegment.vertex1.y;if(s.parent&&s.parent.type===T.Collection){let t=s.parent.parent;if(t.type===T.Collection&&t.layout&&t.layout.type===y.Grid){let e=t.children.indexOf(s.parent);i=t.layout.cellBounds[e].bottom}else i=s.parent.bounds.bottom}else i=t;s.topSegment._doTranslate(0,i-this.scale.map(this.data[e])-n),s.bottomSegment._doTranslate(0,i-this.scale.map(0)-r),s._updateBounds()}}}else if("area"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=Math.sqrt(this.scale.map(this.data[t]));e.resize(i,i)}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("fontSize"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.fontSize=i+"px"}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("strokeWidth"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.strokeWidth=i}this.scene._relayoutAncestors(this.anyItem,this.items)}else{let t="left",e="bottom";if(this.anyItem.parent&&this.anyItem.parent.type==T.Glyph){let i=this.anyItem.parent.children;1==Et(i.map((t=>t.bounds.right))).length&&(t="right"),1==Et(i.map((t=>t.bounds.top))).length&&(e="top")}if(this.anyItem.type===T.Collection&&this.anyItem.layout&&this.anyItem.layout[this.channel])for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.layout[this.channel]=i}else for(let i=0;i<this.items.length;i++){let s=this.items[i],n=this.scale.map(this.data[i]),r="width"==this.channel?n:s.bounds.width,a="height"==this.channel?n:s.bounds.height;s.resize(r,a,t,e)}this.scene._relayoutAncestors(this.anyItem,this.items)}},t.run(),t}function Lt(t){return t._query=function(){this.data=[],this.areas=et(this.items[0],this.scene);let t=this.areas.length;this.areaNum=t,this._vertices=[],this.indicator=[];for(let t of this.areas)for(let e=0;e<t.vertices.length;e++)this._vertices.push(t.vertices[e]),e<t.vertices.length/2?this.indicator.push(1):this.indicator.push(0);let e=this.field,i=this._vertices,s="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?i.map((t=>t.dataScope)):i.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(e)){case A.Boolean:break;case A.Date:this.data=s.map((t=>t.getFieldValue(e)));break;case A.String:this.data=s.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)));break;default:"x"==this.channel||"y"==this.channel?this.data=s.map((t=>t._field2value[e])):this.data=s.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)))}},t._map=function(){let t,e,i;switch(this.datatable.getFieldType(this.field)){case A.Boolean:break;case A.Date:t=Jc("time"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=[e,i];break;case A.String:t=Jc("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=this._includeZero||e<0?[0,i]:[e,i];break;default:t=Jc("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=e<0?[0,i]:[e,i]}let s,n=Ct(this.areas[0]),r=it(this.anyItem);if(r){let t=r.cellBounds;s="width"==this.channel||"height"==this.channel?n==v?t[0].width:t[0].height:n==v?t[0].height:t[0].width}else if("width"==this.channel||"x"==this.channel){let t=this._vertices.map((t=>t.x));s=Math.max(...t)-Math.min(...t)}else{let t=this._vertices.map((t=>t.y));s=Math.max(...t)-Math.min(...t)}e<0?(t._scale.domain([e,i]),t._setRange([0,s])):t._setRange([0,s]),this.scale?this.scale._merge(t):this.scale=t,this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);let i=this.areas[0].orientation;if("width"===e||"height"===e){if(it(this.areas[0])){let t=0;for(let e of this.areas){let s=st(e),n=it(e);for(let r=0;r<e.vertices.length;r++){let a,o,h=this._vertices[r+t];if(i===b)if(a=0,n.type===y.Stack)o=s.bottom-this.scale.map(this.data[r+t])-h.y;else if(n.type===y.Grid){switch(e.baseline){case"top":o=s.top+this.scale.map(this.data[r+t])-h.y;break;case"bottom":o=s.bottom-this.scale.map(this.data[r+t])-h.y;break;case"middle":{let i=e.vertices.length-1-r,n=Math.abs(this.scale.map(this.data[r+t])-this.scale.map(this.data[i+t]));o=this.indicator[r+t]?s.middle-n/2-h.y:s.middle+n/2-h.y;break}}}else o=0;else if(o=0,n.type===y.Stack)a=s.left+this.scale.map(this.data[r+t])-h.x;else if(n.type===y.Grid){switch(e.baseline){case"left":a=s.left+this.scale.map(this.data[r+t])-h.x;break;case"right":a=s.right-this.scale.map(this.data[r+t])-h.x;break;case"center":{let i=e.vertices.length-1-r,n=Math.abs(this.scale.map(this.data[r+t])-this.scale.map(this.data[i+t]));a=this.indicator[r+t]?s.center-n/2-h.x:s.center+n/2-h.x;break}}}else a=0;h._doTranslate(a,o)}t+=e.vertices.length}}else{let t="center"==this.areas[0].baseline||"middle"==this.areas[0].baseline,e=ot(this._vertices),s=i==v?this.areas[0].baseline!==C.Right?Math.min(...e.map((t=>t.bounds.left))):Math.max(...e.map((t=>t.bounds.right))):this.areas[0].baseline!=C.Top?Math.max(...e.map((t=>t.bounds.bottom))):Math.min(...e.map((t=>t.bounds.top)));for(let t=0;t<this._vertices.length;t++){let e=this._vertices[t],n=i==v?this.areas[0].baseline!==C.Right?s+this.scale.map(this.data[t])-e.x:s-this.scale.map(this.data[t])-e.x:0,r=i==v?0:this.areas[0].baseline!=C.Top?s-this.scale.map(this.data[t])-e.y:s+this.scale.map(this.data[t])-e.y;e._doTranslate(n,r)}if(1==t){let t=this._vertices.length/this.areaNum,e=ot(this._vertices),s=i==v?Math.min(...e.map((t=>t.bounds.x))):Math.max(...e.map((t=>t.bounds.y)));for(let e=0;e<this.areaNum;e++)for(let n=0;n<t/2;n++){let r=e*t+n,a=(e+1)*t-n-1,o=this._vertices[r],h=this._vertices[a],l=i==v?o.x-h.x:h.y-o.y,c=i==v?s+l/2-o.x:0,d=i==v?0:s+l/2-o.y,u=i==v?s-l/2-h.x:0,f=i==v?0:s-l/2-h.y;o._doTranslate(c,d),h._doTranslate(u,f)}}}}else{if(it(this.anyItem)){let t=ot(this._vertices);void 0===this.scale.offset&&(this.scale.offset=i==b?Math.min(...t.map((t=>t.bounds.left))):Math.max(...t.map((t=>t.bounds.top))));for(let t=0;t<this._vertices.length;t++){let e=this._vertices[t],s=st(e),n=i==v?0:s.left+this.scale.map(this.data[t])-e.x,r=i==v?s.bottom-this.scale.map(this.data[t])-e.y:0;e._doTranslate(n,r)}}else{let t=ot(this._vertices);void 0===this.scale.offset&&(this.scale.offset=i==b?Math.min(...t.map((t=>t.bounds.left))):Math.max(...t.map((t=>t.bounds.top))));for(let t=0;t<this._vertices.length;t++){let e=this._vertices[t],s=i==b?this.scale.offset+this.scale.map(this.data[t])-e.x:0,n=i==b?0:this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-e.y;e._doTranslate(s,n)}}}for(let t of this.areas)t._updateBounds();"width"!=e&&"height"!=e||this.scene._relayoutAncestors(this.areas[0],this.areas)},t.run(),t}class jt{constructor(t,e,i,s,n){this.items=t,this.anyItem=this.items[0],this.scene=e,this.channel=i,this.field=s,this._aggregator=n.aggregator,this.datatable=n.datatable,this.scale=n.scale,this.scale?(this._flipScale=this.scale.isFlipped,this.scaleType=this.scale.type,this._includeZero=this.scale.includeZero):(this._flipScale=n.flipScale,this.scaleType=n.scaleType,this._includeZero=n.includeZero),this._mapping=n.mapping,this.rangeExtent=n.rangeExtent,this._scheme=n.scheme,this.range=n.range,"angle"==this.channel&&(this.startAngle="startAngle"in n?n.startAngle:90),this._query=void 0,this._map=void 0,this._apply=void 0}get id(){return["enc",at(this.anyItem),this.channel,this.field].join("-")}set aggregator(t){this._aggregator=t,this.scale=void 0,this.run()}get aggregator(){return this._aggregator}toJSON(){let t={};return t.anyItem=this.anyItem.id,t.items=this.items.map((t=>t.id)),this.data&&(t.data=this.data),this._rectNegativeValues&&(t._rectNegativeValues=!0),t.args={},t.args.channel=this.channel,t.args.field=this.field,t.args.aggregator=this.aggregator,t.args.datatable=this.datatable.id,t.args.scale=this.scale.id,t.args.rangeExtent=this.rangeExtent,t.args.scaleType=this.scaleType,t.args.range=this.range,"angle"==this.channel&&(t.args.startAngle=this.startAngle),t}run(){this._query(),this._map(),this._apply()}get dataTable(){return this.datatable}_inferTickValues(){let t,e=this,i=e.scale.domain,s=e.scale.range;switch(e.scale.type){case"linear":case"log":{let r=Math.abs(s[0]-s[1]);if("width"==e.channel||"height"==e.channel){let t=rt(e.anyItem,"stack");if(t){let s=et(t.group,e.scene);r=Math.max(...s.map((t=>t.bounds[e.channel]))),i[1]=e.scale.invert(r)}}t="width"==e.channel||"x"==e.channel?45:30;let a=Math.floor(r/t);return"log"===e.scale.type?e.scale._scale.ticks(a):n.ticks(i[0],i[1],a)}case"point":{t="width"==e.channel||"x"==e.channel?80:30;let s=Math.floor(e.scale.rangeExtent/i.length),n=Math.ceil(t/s);return"x"==e.channel?i.filter(((t,e)=>e%n==0)):i}case"time":{t="width"==e.channel||"x"==e.channel?80:30;let r,a,o=Math.floor((s[1]-s[0])/t),h=Math.ceil((i[1]-i[0])/o)/1e3,l=[1,60,3600,86400,2628003,31536e3],c=[n.timeSeconds,n.timeMinutes,n.timeHours,n.timeDays,n.timeMonths,n.timeYears];for(let t=0;t<l.length-1;t++)if(h>=l[t]&&h<l[t+1])return r=Math.floor(h/l[t]),a=c[t],a(i[0],i[1],r);return h>l[l.length-1]?(r=Math.floor(h/l[l.length-1]),a=c[l.length-1],a(i[0],i[1],r)):[]}default:return[]}}getScaleRange(t){let e=t||this.anyItem;if(e.type!=T.Area){if("x"==this.channel){let t=it(e);if(t&&t.type==y.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].left+this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}{let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}}if("y"==this.channel){let t=it(e);if(t&&t.type==y.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].bottom,i[s].bottom-this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}{let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}}if("width"==this.channel){let t=rt(e);if("grid"===t.type){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].right]}if("stack"===t.type&&"horizontal"==t.orientation)return[t.group.bounds.left,t.group.bounds.right];{let t=et(e,this.scene),i=Math.min(...t.map((t=>t.bounds.left)));return[i,i+this.scale.rangeExtent]}}if("height"==this.channel){let t=rt(e,"grid");if(t){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent===t||e.parent.parent===t));return[i[s].bottom,i[s].bottom-i[s].height]}{let t=et(e,this.scene),i=Math.max(...t.map((t=>t.bounds.bottom)));return[i,i-this.scale.rangeExtent]}}if("radialDistance"==this.channel){let t=e.parent;return[t.x,t.x+this.scale.rangeExtent]}return this.scale.range}{let t,i=Ct(e),s=it(e);t=s?i==v?s.horzCellAlignment===C.Left:s.vertCellAlignment===C.Bottom:i==v?e.baseline==C.Left:e.baseline==C.Bottom;let n=nt(e);if(n)switch(this.channel){case"x":return[n.left,n.left+this.scale.rangeExtent];case"width":return t?[n.left,n.left+this.scale.rangeExtent]:[n.right,n.right-this.scale.rangeExtent];case"y":return[n.bottom,n.bottom-this.scale.rangeExtent];case"height":return t?[n.bottom,n.bottom-this.scale.rangeExtent]:[n.top+this.scale.rangeExtent,n.top]}else if(s&&"stack"===s.type)switch(n=s.group.bounds,this.channel){case"x":return[n.left,n.left+this.scale.rangeExtent];case"width":return t?[n.left,n.left+this.scale.rangeExtent]:[n.right,n.right-this.scale.rangeExtent];case"y":return[n.bottom,n.bottom-this.scale.rangeExtent];case"height":return t?[n.bottom,n.bottom-this.scale.rangeExtent]:[n.top+this.scale.rangeExtent,n.top]}if(i==b)switch(this.channel){case"width":case"height":{let i=et(e.firstVertex,this.scene),s=t?Math.max(...i.map((t=>t.y))):Math.min(...i.map((t=>t.y)));return t?[s,s-this.scale.rangeExtent]:[s+this.scale.rangeExtent,s]}case"x":case"y":{let t=et(e.firstVertex,this.scene),i=Math.min(...t.map((t=>t.x)));return[i,i+this.scale.rangeExtent]}}else if(i==v)switch(this.channel){case"x":case"y":{let t=et(e.firstVertex,this.scene),i=Math.max(...t.map((t=>t.y)));return[i,i-this.scale.rangeExtent]}case"height":case"width":{let i=et(e.firstVertex,this.scene),s=t?Math.min(...i.map((t=>t.x))):Math.max(...i.map((t=>t.x)));return t?[s,s+this.scale.rangeExtent]:[s-this.scale.rangeExtent,s]}}}}}function Dt(t,e,i){return e.map((e=>[e,n.mean(i,(i=>t(e-i)))]))}function Vt(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}function zt(t,e){if("field"in e){let i=e.field;if("value"in e)return t[i]==e.value;if("range"in e)return t[i]>=e.range[0]&&t[i]<=e.range[1];if("values"in e)return e.values.indexOf(t[i])>=0}else if("fields"in e){let i=e.fields[0],s=e.fields[1],n=t[i],r=t[s];switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}return!1}}class Gt{constructor(t,e,i){if(this.url=e,this.id=T.DataTable+pt[T.DataTable]++,this.data=t,this.rawData=JSON.parse(JSON.stringify(t)),this._dateMap=new Map,this._fields=Object.keys(this.data[0]),this._newField=0,i)this._fieldTypes=i;else{this._fieldTypes={};for(let t of this._fields)this._fieldTypes[t]=qt(this.data.map((e=>e[t]))),"year"==t.toLowerCase()&&this._fieldTypes[t]==A.Integer&&(this._fieldTypes[t]=A.Date)}this._validate(this.data,this._fieldTypes),this._fieldSummaries={};for(let t of this._fields)this._fieldSummaries[t]=Wt(this.data.map((e=>e[t])),this._fieldTypes[t]);this._fields.indexOf(h)<0&&this._addField(h,A.String,this.data.map(((t,e)=>"r"+e)))}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),i=t.substring(e);0!==i.indexOf("\\")&&0!==i.indexOf("/")||(i=i.substring(1));return i}(this.url):this.id}set sourceDataTable(t){this._sourceDataTable=t}get sourceDataTable(){return this._sourceDataTable}getEncodableFields(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":return this.numericFields.concat(this.nonNumericFields);case"area":case"strokeWidth":default:return this.numericFields}}toJSON(){let t={};return t.data=this.rawData,t.fieldTypes=this._fieldTypes,t.url=this.url,t.id=this.id,t.sourceDataTable=this._sourceDataTable,t.transform=this._transform,t.dateMap={},t}transformField(t,e,i){let s=this.data.map((i=>e(i[t]))),n=qt(s),r=i||Date.now()+"_field"+this._newField++;return this._addField(r,n,s),r}setValueOrder(t,e){this._fieldSummaries[t].unique=e}_addField(t,e,i){this.data.forEach(((e,s)=>e[t]=i[s])),this._fieldTypes[t]=e,this._fields.push(t),this._fieldSummaries[t]=Wt(i,e)}getFieldType(t){return this._fieldTypes[t]}get fields(){return this._fields}getFieldSummary(t){return this._fieldSummaries[t]}getFieldValues(t){return this.data.map((e=>e[t]))}getUniqueFieldValues(t){return this._fieldSummaries[t].unique}getRowCount(){return this.data.length}hasField(t){return this._fields.indexOf(t)>=0}parseFieldAsDate(t,e){let i=n.timeParse(e);for(let e of this.data){let s=e[t];null==s||null==s?(s="",e[t]=new Date(1899,11,31).getTime()):e[t]=i(s).getTime(),this._dateMap.set(e[t],s)}this._fieldTypes[t]=A.Date,this._fieldSummaries[t]=Wt(this.data.map((e=>e[t])),A.Date)}getRawValue(t,e){return this.getFieldType(t)===A.Date?this._dateMap.get(e).toString():e}static get RowID(){return h}get nonNumericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!=A.Number&&this._fieldTypes[e]!=A.Integer&&e!=Gt.RowID&&t.push(e);return t}get numericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!==A.Number&&this._fieldTypes[e]!==A.Integer||e==Gt.RowID||t.push(e);return t}getFieldsByType(t){let e=[];for(let i in this._fieldTypes)this._fieldTypes[i]===t&&i!=Gt.RowID&&e.push(i);return e}transform(t,e,i){let s=i||{};switch(t){case"kde":return function(t,e,i){let s=e[0],n=t.nonNumericFields,r={};for(let e of t.data){let t=n.map((t=>String(e[t]))).join("_");t in r||(r[t]=n.map((t=>e[t])),r[t].push([])),r[t][r[t].length-1].push(e[s])}let a="min"in i?i.min:t.getFieldSummary(s).min,o="max"in i?i.max:t.getFieldSummary(s).max,h=a,l=[];for(;h<o;)l.push(h),h+=i.interval;l.push(h);let c=[];for(let t in r){let e=r[t].pop(),a=Dt(Vt(i.bandwidth),l,e);for(let e of a){let i={};r[t].forEach(((t,e)=>i[n[e]]=t)),i[s]=e[0],i[s+"_density"]=e[1],c.push(i)}}let d={};return n.forEach((e=>d[e]=t.getFieldType(e))),d[s]=A.Number,d[s+"_density"]=A.Number,new Gt(c,t.url,d)}(this,e,s);case"bin":return function(t,e,i){let s=e[0],r=t.nonNumericFields,a={};for(let e of t.data){let t=r.map((t=>String(e[t]))).join("_");a.hasOwnProperty(t)||(a[t]=r.map((t=>e[t])),a[t].push([])),a[t][a[t].length-1].push(e[s])}let o=[];for(let t in a){let e=a[t].pop(),i=n.bin()(e);for(let e of i){let i={};a[t].forEach(((t,e)=>i[r[e]]=t)),i.x0=e.x0,i.x1=e.x1,i[s+"_count"]=e.length,o.push(i)}}let h={};r.forEach((e=>h[e]=t.getFieldType(e))),h.x0=A.Number,h.x1=A.Number,h[s+"_count"]=A.Number;let l=new Gt(o,t.url,h);return l.sourceDataTable=t,l.transform={type:"bin",args:e},l}(this,e);case"sort":return function(t,e,i){t.data.sort(((t,i)=>function(t,e,i,s){for(let s of i){if(t[s]<e[s])return-1;if(t[s]>e[s])return 1}return 0}(t,i,e))),t.summarize()}(this,e);case"filter":return function(t,e){let i=[];for(let s of t.data){let t=!0;for(let i of e)if(!zt(s,i)){t=!1;break}t&&i.push(s)}let s=new Gt(i,t.url);return s.sourceDataTable=t,s.transform={type:"filter",args:e},s}(this,e)}}summarize(){for(let t of this._fields)this._fieldSummaries[t]=Wt(this.data.map((e=>e[t])),this._fieldTypes[t])}_validate(t,e){for(let i of t)for(let t in e){let s,n=e[t],r=i[t];if(null==i[t]||null==i[t])switch(n){case A.Boolean:s=!1;break;case A.Date:s=new Date(1899,11,31).getTime();break;case A.String:s="";break;default:s=0}else switch(n){case A.Boolean:s=r;break;case A.Date:s=Number.isInteger(r)?new Date(r,0).getTime():new Date(r+"").getTime(),this._dateMap.set(s,r);break;case A.String:s=r.toString();break;default:s=r}i[t]=s}}}function Wt(t,e){var i={};switch(e){case A.Boolean:i.trueCount=t.filter((t=>t)).length,i.falseCount=t.filter((t=>!t)).length;break;case A.Date:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.unique=[...new Set(t)];break;case A.String:i.unique=[...new Set(t)];break;default:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.mean=n.mean(t),i.median=n.median(t),i.unique=[...new Set(t)]}return i}var Ut={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return Ut.number(t)&&(t=+t)==~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function qt(t){var e=Object.values(A);for(let i=0;i<t.length;i++){let s=t[i];if(null!=s){for(let t=0;t<e.length;t++)Ut[e[t]](s)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}class Jt extends q{constructor(t){super(t),this.type=T.PointText,this.attrs.x=0,this.attrs.y=0,"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"),void 0!==t&&("x"in t&&(this.attrs.x=t.x),"y"in t&&(this.attrs.y=t.y),this.attrs.text="text"in t?t.text:"",this.attrs.anchor="anchor"in t?t.anchor:["center","middle"]),this._updateBounds()}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this.attrs.x,t.y=this.attrs.y,t.text=this.text,t.anchor=[this.anchor[0],this.anchor[1]]}get bounds(){return this._bounds||this._updateBounds(),this._bounds}set text(t){this.attrs.text=t,this._updateBounds()}get text(){return this.attrs.text}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){let t,e,i=function(t,e,i){let s=mt.getContext();s.font=e;let n=s.measureText(t);return n.fontBoundingBoxAscent?{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}:n.actualBoundingBoxAscent?{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}:{width:n.width,height:i}}(this.attrs.text,[this.fontWeight,this.styles.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),s=i.width,n=i.height;switch(this.attrs.anchor[0]){case"left":t=this.attrs.x;break;case"right":t=this.attrs.x-s;break;case"center":t=this.attrs.x-s/2;break;default:t=this.attrs.x}switch(this.attrs.anchor[1]){case"top":e=this.attrs.y;break;case"bottom":e=this.attrs.y-n;break;case"middle":e=this.attrs.y-n/2}this._bounds=new a(t,e,s,n)}get center(){return{x:this.bounds.left+this.bounds.width/2,y:this.bounds.top+this.bounds.height/2}}get x(){return this.attrs.x}set x(t){this.attrs.x=t,this._updateBounds()}get y(){return this.attrs.y}set y(t){this.attrs.y=t,this._updateBounds()}get anchor(){return this.attrs.anchor}set anchor(t){this.attrs.anchor=t,this._updateBounds()}get fontSize(){return parseFloat(this.styles.fontSize)}set fontSize(t){this.styles.fontSize="number"==typeof t?t+"px":t,this._updateBounds()}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._updateBounds()}get fontFamily(){return this.styles.fontFamily}set fontFamily(t){this.styles.fontFamily=t,this._updateBounds()}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}}class Yt extends St{constructor(t){super(),this.type=T.Axis,this.id=this.type+pt[this.type]++,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor?t.tickAnchor:"middle",this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelOffset="labelOffset"in t?t.labelOffset:15,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,"titleAnchor"in t?this._titleAnchor=t.titleAnchor:"x"==this.channel||"width"==this.channel?this._titleAnchor="top"==this._orientation?["center","bottom"]:["center","top"]:this._titleAnchor="left"==this._orientation?["right","middle"]:["left","middle"],this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._titlePosition=t.titlePosition,this._labelRotation="labelRotation"in t?t.labelRotation:0}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.field=this._field,t.channel=this._channel,"args"in t||(t.args={}),t.args.orientation=this._orientation,t.args.strokeColor=this._strokeColor,t.args.textColor=this._textColor,t.args.tickOffset=this._tickOffset,t.args.tickSize=this._tickSize,t.args.tickAnchor=this._tickAnchor,t.args.tickVisible=this._tickVisible,t.args.pathVisible=this._pathVisible,t.args.labelOffset=this._labelOffset,t.args.labelFormat=this._labelFormat,this._labelRotation&&(t.args.labelRotation=this._labelRotation),t.args.showTitle=this._showTitle,t.args.tickValues=this._tickValues,t.args.titleAnchor=this._titleAnchor,t.args.titleOffset=this._titleOffset,t.args.titlePosition=this._titlePosition,t.args.rotateTitle=this._rotateYTitle,t}get field(){return this._field}get channel(){return this._channel}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.reposition()}get pathX(){if("y"==this.channel||"height"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].x;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].x}}set pathX(t){"y"!=this.channel&&"height"!=this.channel||(this._posArg=t),this.reposition()}get pathPosition(){return"x"==this.channel||"width"==this.channel?this.pathY:this.pathX}set pathPosition(t){"x"==this.channel||"width"==this.channel?this.pathY=t:"y"!=this.channel&&"height"!=this.channel||(this.pathX=t)}get pathY(){if("x"==this.channel||"width"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].y;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].y}}set pathY(t){"x"!=this.channel&&"width"!=this.channel||(this._posArg=t),this.reposition()}get tickOffset(){return this._tickOffset}set tickOffset(t){this._tickOffset=t,this._positionTicks()}get titleOffset(){return this._titleOffset}set titleOffset(t){this._titleOffset=t}get tickSize(){return this._tickSize}set tickSize(t){this._tickSize=t,this._positionTicks()}set tickValues(t){this._tickValues=t,this._generateTicks(),this._positionTicks()}get tickValues(){return this._tickValues}set labelValues(t){this._labelValues=t,this._generateLabels(),this._positionLabels()}get labelValues(){return this._labelValues}get tickAnchor(){return this._tickAnchor}set tickAnchor(t){this._tickAnchor=t}get tickVisible(){return this._tickVisible}set tickVisible(t){this._tickVisible=t;for(let e of this._ticks.children)e.visibility=t?"visible":"hidden"}get pathVisible(){return this._pathVisible}set pathVisible(t){this._pathVisible=t;let e=[];this._path&&e.push(this._path),this._rules&&this._rules.children.forEach((t=>e.push(t)));for(let i of e)i.visibility=t?"visible":"hidden"}get labelOffset(){return this._labelOffset}set labelOffset(t){this._labelOffset=t,this._positionLabels()}get labelFormat(){return this._labelFormat}set labelFormat(t){this._labelFormat=t,this._generateLabels(),this._positionLabels()}get labelRotation(){return this._labelRotation}set labelRotation(t){if(this._labelRotation=t,this._labels&&this._labels.children){let e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(t)for(let t of this._labels.children)t._rotate=[this._labelRotation,t.x,t.y],t.anchor=["right",e[1]];else for(let t of this._labels.children)t._rotate=void 0}}get showTitle(){return this._showTitle}set showTitle(t){this._showTitle=t,this._title||(this._generateTitle(),this._positionTitle()),this._title.visibility=t?"visible":"hidden"}get titleAnchor(){return this._titleAnchor}set titleAnchor(t){this._titleAnchor=t}get titlePosition(){return this._titlePosition}set titlePosition(t){this._titlePosition=t}get rotateTitle(){return this._rotateYTitle}set rotateTitle(t){this._rotateYTitle=t}get title(){return this._titleText}set title(t){this._titleText=t}get includeZero(){return!!this.encoding&&this.encoding.scale.includeZero}set includeZero(t){this.encoding&&(this.encoding.scale.includeZero=t)}_generatePath(){}_generateTicks(){}_generateLabels(){}_generateTitle(){this._title=new Jt({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title.id=this.id+"-title",this.addChild(this._title)}_positionPath(){}_positionTicks(){}_positionLabels(){}_positionTitle(){}matches(t){}reposition(){this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle(),"radialDistance"===this._channel&&this._rotate&&(this._rotate=[this._rotate[0],this._item.parent.x,this._item.parent.y]),this._updateBounds()}}class Ht extends Yt{constructor(t,e,i){super(i),this.encoding=t,this._field=this.encoding.field,this._channel=this.encoding.channel,this._orientation="orientation"in i?i.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?i.pathY:i.pathX,this._position=this._posArg,this._titleText="title"in i?i.title:this.encoding.field,this._item=e,this._ticks=new St,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new St,this._labels.id=this.id+"labels",this.addChild(this._labels),"radialDistance"===this._channel&&"rotation"in i&&(this._rotate=[-i.rotation,this._item.parent.x,this._item.parent.y]),this._showTitle=!("showTitle"in i)||i.showTitle,this._determineAxisFlip(),this._generatePath(),this._positionPath(),this._showTitle&&this._generateTitle(),this._showTitle&&this._positionTitle()}autoUpdateTicks(){let t=this.encoding._inferTickValues();this.tickValues=t,this.labelValues=t}_updateBounds(){this._bounds=this._path.bounds,this._ticks.children.length>0&&(this._bounds=this._bounds.union(this._ticks.bounds)),this._labels.children.length>0&&(this._bounds=this._bounds.union(this._labels.bounds)),this._title&&(this._bounds=this._bounds.union(this._title.bounds))}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"time"===this.encoding.scale.type&&(t.args.isDate=!0),this._rotate&&(t.args.rotation=this._rotate[0]),"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,t}get ticks(){return this._ticks}get labels(){return this._labels}get path(){return this._path}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;this._path.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_generatePath(){this._path=new Z({strokeColor:this._strokeColor}),this._pathVisible||(this._path.visibility="hidden"),this._path.type=T.Line,this._path.id=this.id+"path",this.addChild(this._path)}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new Z({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=T.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this.encoding.datatable.getFieldType(this.encoding.field)){case A.Date:t=n.timeFormat(this._labelFormat);break;case A.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let s=new Jt({text:t(i),fontSize:this._fontSize,fillColor:this._textColor});s.id=this.id+"label"+e,this._labels.addChild(s)}}_positionPath(){this._range=this.encoding.getScaleRange(this._item),void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg;let t=[];if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].x));t.push([Math.min(...e.concat(this._range)),this._position]),t.push([Math.max(...e.concat(this._range)),this._position])}else if("y"==this._channel||"height"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].y));t.push([this._position,Math.min(...e.concat(this._range))]),t.push([this._position,Math.max(...e.concat(this._range))])}this._path._setVertices(t),this._path._updateBounds(),this._showTitle&&this._title&&this._positionTitle(),this._updateBounds()}_isAlignedLeft(t){switch(t.type){case y.Stack:case y.Grid:return t.horzCellAlignment===C.Left;default:return!0}}_isAlignedBottom(t){switch(t.type){case y.Stack:case y.Grid:return t.vertCellAlignment===C.Bottom;default:return!0}}_determineAxisFlip(){if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){if("width"==this._channel){let t=bt(this._item)?bt(this._item).layout:it(this._item);if(t)this._flip=!this._isAlignedLeft(t);else if("area"==this._item.type){let t=this._item.baseline==C.Left||this._item.baseline==C.Center||this._item.baseline==C.Middle||null==this._item.baseline;this._flip=!t}}}else if(("y"==this._channel||"height"==this._channel)&&"height"==this._channel){let t=bt(this._item)?bt(this._item).layout:it(this._item);if(t)this._flip=!this._isAlignedBottom(t);else if("area"==this._item.type){let t=this._item.baseline==C.Bottom||this._item.baseline==C.Center||this._item.baseline==C.Middle||null==this._item.baseline;this._flip=!t}}}_positionLabels(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize,e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._range[1]-this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i])-this.encoding.scale.range[0],s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]])}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize,e="left"==this._orientation?["right","middle"]:["left","middle"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]+this.encoding.scale.map(this._labelValues[i]),s.anchor=e;else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[1],s.anchor=e;else for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[0]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[0],s.anchor=e}this._labels._updateBounds(),this._updateBounds()}_computePosition(){let t;if("vertex"===this._item.type&&!this._item.parent.closed){let t=et(this._item,this._item.parent.getScene());if("x"===this._channel&&1==Et(t.map((t=>t.bounds.middle))).length)return this._item.bounds.middle;if("y"===this._channel&&1==Et(t.map((t=>t.bounds.center))).length)return this._item.bounds.center;if("radialDistance"===this._channel)return this._item.parent.y}if(this._item.type==T.Area&&(t=nt(this._item)),void 0===t){let e=bt(this._item);void 0===e&&(e=vt(this._item)),t=e.bounds}return"x"===this._channel||"width"===this._channel?"top"==this._orientation?t.top-this._tickSize:t.bottom+this._tickSize:"y"===this._channel||"height"===this._channel?"left"==this._orientation?t.left-this._tickSize:t.right+this._tickSize:"radialDistance"===this._channel?this._item.parent.y:void 0}_positionTicks(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,this._range=this.encoding.getScaleRange(this._item),"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position+t]]),i._updateBounds()}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[1]+this.encoding.scale.map(this._tickValues[e])],[this._position,this._range[1]+this.encoding.scale.map(this._tickValues[e])]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries()){let s=this._range[1]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[1];i._setVertices([[this._position+t,s],[this._position,s]]),i._updateBounds()}else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]],[this._position,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]]]),i._updateBounds()}this._positionPath(),this._ticks._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._path.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel||"width"==this._channel?(this._title.x=t.x,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){let e=at(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(at(t.anyItem).split("_")[0]===e)return!0}return!1}get isFlipped(){return!!this._flip||!!this.encoding.scale.isFlipped}}class $t extends Yt{constructor(t,e,i,s,n){super(n),this._channel=i,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._item=t[0],this._items=t,this._mlayout=e,this._field=s,this._titleText="title"in n?n.title:this._field,this._showTitle="showTitle"in n&&n.showTitle,this._ticks=new St,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new St,this._labels.id=this.id+"labels",this.addChild(this._labels),this._rules=new St,this._rules.id=this.id+"paths",this.addChild(this._rules),this._generatePath(),this._generateTicks(),this._generateLabels(),this._showTitle&&this._generateTitle(),this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle()}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,this.classId&&(t.classId=this.classId),t}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;for(let e of this._rules.children)e.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_updateBounds(){this._bounds=this._rules.bounds.clone(),this._bounds=this._bounds.union(this._ticks.bounds),this._bounds=this._bounds.union(this._labels.bounds),this._showTitle&&(this._bounds=this._bounds.union(this._title.bounds))}_generatePath(){if(this._rules.removeAll(),this._mlayout.type==y.Grid){let t="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;for(let e=0;e<t;e++){let t=new Z({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=T.Line,t.id=this.id+"rule"+e,this._rules.addChild(t)}}else if(this._mlayout.type===y.Stack){let t=new Z({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=T.Line,t.id=this.id+"rule",this._rules.addChild(t)}}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._mlayout.group.children.length;t++){let e=new Z({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=T.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this._item.dataScope.getFieldType(this._field)){case A.Date:t=n.timeFormat(this._labelFormat);break;case A.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}let e=this._mlayout.cellBounds;for(let i=0;i<e.length&&!(i>=this._mlayout.group.children.length);i++){let e=this._mlayout.group.children[i],s=new Jt({fillColor:this._textColor,fontSize:this._fontSize,text:t(e.dataScope.getFieldValue(this._field))});s.id=this.id+"label"+i,this._labels.addChild(s)}}_positionPath(){if(this._mlayout.type==y.Grid){let t=this._mlayout.cellBounds,e="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;if("x"==this._channel){let i=t[0].left,s=this._mlayout.numCols;for(let n=0;n<e;n++)this._rules.children[n]._setVertices([[i,this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:t[n*s][this._orientation]],[i+t[0].width*s+this._mlayout.colGap*(s-1),this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:t[n*s][this._orientation]]])}else{let i=t[0].top,s=this._mlayout.numRows;for(let n=0;n<e;n++)this._rules.children[n]._setVertices([[this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation],i],[this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation],i+t[0].height*s+this._mlayout.rowGap*(s-1)]])}}else if(this._mlayout.type===y.Stack){let t=this._mlayout.group.bounds;"x"==this._channel?this._rules.children[0]._setVertices([[t.left,this._posArg?this._posArg:t[this._orientation]],[t.right,this._posArg?this._posArg:t[this._orientation]]]):this._rules.children[0]._setVertices([[this._posArg?this._posArg:t[this._orientation],t.top],[this._posArg?this._posArg:t[this._orientation],t.bottom]])}this._rules.children.forEach((t=>t._updateBounds())),this._rules._updateBounds(),this._updateBounds()}_positionTicks(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?1:-1;for(let[i,s]of this._ticks.children.entries()){let n=this._posArg?t[i][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:t[i][this._orientation]+this._tickOffset*e;s._setVertices([[t[i].x,n],[t[i].x,n+e*this._tickSize]]),s._updateBounds()}}else if("y"==this._channel){let e="left"==this._orientation?-1:1;for(let[i,s]of this._ticks.children.entries()){let n=this._posArg?t[i][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:this._mlayout.group.bounds[this._orientation]+this._tickOffset*e,r="middle"==this._tickAnchor?t[i].y:t[i][this._tickAnchor];s._setVertices([[n,r],[n+e*this._tickSize,r]]),s._updateBounds()}}this._ticks._updateBounds(),this._updateBounds()}_positionLabels(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?["center","top"]:["center","bottom"],i="bottom"==this._orientation?this._labelOffset:-this._labelOffset;for(let[s,n]of this._labels.children.entries())n.x=t[s].x,n.y=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+i:t[s][this._orientation]+i,n.anchor=e,this._labelRotation&&(n._rotate=[this._labelRotation,n.x,n.y],n.anchor=["right",e[1]])}else if("y"==this._channel){let e="left"==this._orientation?["right","middle"]:["left","middle"],i="left"==this._orientation?-this._labelOffset:this._labelOffset;for(let[s,n]of this._labels.children.entries())n.x=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+i:this._mlayout.group.bounds[this._orientation]+i,n.y="middle"==this._tickAnchor?t[s].y:t[s][this._tickAnchor],n.anchor=e,this._labelRotation&&(n._rotate=[this._labelRotation,n.x,n.y])}this._labels._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._rules.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel?(this._title.x=t.x,this._titleOffset=this._labels.bounds.height+this._labelOffset+15,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._titleOffset=this._labels.bounds.width+this._labelOffset+15,this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){return at(this._item).split("_")[0]===at(t).split("_")[0]}}class Zt extends St{constructor(t,e){super(),this.type=T.Legend,this.id=this.type+pt[this.type]++,this.encoding=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._showTitle=!("showTitle"in e)||e.showTitle,"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._numCols=1,this._orientation="orientation"in e?e.orientation:v,this._initialize()}toJSON(){let t=super.toJSON();return"args"in t||(t.args={}),t.args.textColor=this._textColor,t.channel=this.encoding.channel,t.field=this.encoding.field,t.args.strokeColor=this._strokeColor,t.args.x=this._x,t.args.y=this._y,t.args.orientation=this._orientation,t}get field(){return this.encoding.field}get channel(){return this.encoding.channel}get fieldType(){return this.encoding.datatable.getFieldType(this.field)}_initialize(){let t=this.encoding.scene,e=this.encoding.field;switch(this.encoding.datatable.getFieldType(e)){case A.String:this._createCategoricalColorLegend(t,e);break;case A.Number:case A.Integer:this._createNumericalColorLegend(t,e)}this._updateBounds()}_createNumericalColorLegend(t,e){let i,s,n;if(this._orientation==v?(i=15,s=300):(i=300,s=15),this._showTitle){let s=t.mark("text",{fillColor:this._textColor,text:e,x:this._x+i/2,y:this._y,anchor:["center","middle"]});this.addChild(s),n=20}else n=0;let r,a=t.mark("rect",{top:this._y+n,left:this._x,width:i,height:s,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),o=[Math.min(...this.encoding.data),Math.max(...this.encoding.data)],h=this.encoding.scale.mapping,l=[],c=[];if(h){let e=Object.keys(h).map((t=>parseFloat(t))).sort(((t,e)=>t-e));this._orientation==v?(r=new U({x1:0,y1:100,x2:0,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,h[e],1);let d=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-a*s+n,y2:this._y+s-a*s+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+i+5+5,y:this._y+s-a*s+n,anchor:["left","middle"]});l.push(u)}))):(r=new U({x1:0,y1:0,x2:100,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,h[e],1);let d=t.mark("line",{x1:this._x+a*i,x2:this._x+a*i,y1:this._y+20-5+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+a*i,y:this._y+s+5+n,anchor:["center","top"]});l.push(u)})))}else{let e=this.encoding.scale.domain,a=[],o=Et(this.encoding.data);if(o.length<=10)a=o,a.sort(((t,e)=>t-e));else{let t=(e[1]-e[0])/9;for(let i=0;i<10;i++)a.push(e[0]+i*t);let i=0;for(;t<1;)t*=10,i++;a=a.map((t=>t.toFixed(i)))}this._orientation==v?(r=new U({x1:0,y1:100,x2:0,y2:0}),a.forEach((a=>{let o=(a-e[0])/(e[1]-e[0]);r.addStop(100*o,this.encoding.scale.map(a),1);let h=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-o*s+n,y2:this._y+s-o*s+n,strokeColor:this._strokeColor});c.push(h);let d=t.mark("text",{fillColor:this._textColor,text:a,x:this._x+i+5+5,y:this._y+s-o*s+n,anchor:["left","middle"]});l.push(d)}))):(r=new U({x1:0,y1:0,x2:100,y2:0}),a.forEach((a=>{let o=(a-e[0])/(e[1]-e[0]);r.addStop(100*o,this.encoding.scale.map(a),1);let h=t.mark("line",{x1:this._x+o*i,x2:this._x+o*i,y1:this._y+s+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(h);let d=t.mark("text",{fillColor:this._textColor,text:a,x:this._x+o*i,y:this._y+s+5+n,anchor:["center","top"]});l.push(d)})))}a.styles.fillColor=r,this.addChild(a);for(let t of l)this.addChild(t);for(let t of c)this.addChild(t)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.setTextColor(this)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.removeAll(),this._initialize()}setTextColor(t){if(t.children&&0!==t.children.length)for(let e of t.children)e.type===T.PointText?e.fillColor=this._textColor:e.children&&e.children.length>0&&this.setTextColor(e)}_createCategoricalColorLegend(t,e){let i=0;this._showTitle&&(this.addChild(new Jt({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),i=parseFloat(this._fontSize)+5);let s=t.mark("rect",{top:this._y+2+i,left:this._x,width:10,height:10,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),n=t.mark("text",{fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+i,anchor:["left","top"]}),r=t.glyph(s,n),a=this.encoding.scale,o=new Gt(a.domain.map((t=>({category:t,value:a.map(t)})))),h=t.repeat(r,o);t.encode(n,{channel:"text",field:"category",_remember:!1}),t.encode(s,{channel:"fillColor",field:"category",_remember:!1,scale:a}),h.layout=Yc("grid",{numCols:this._numCols,numRows:this._numRows}),this.addChild(h)}pathHitTest(t,e){let i=ct(this);for(let s=i.length-1;s>=0;s--){let n=i[s];if(ft(n)&&n.contains(t,e))return n}return null}matches(t){let e=at(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(at(t.anyItem).split("_")[0]===e)return!0}return!1}}class Kt extends St{constructor(t){if(super(),this.type=T.Glyph,this._id=this.type+pt[this.type]++,t)for(let e of t)this.addChild(e)}duplicate(){let t=this.getScene().glyph();for(let e of this.children)t.addChild(e.duplicate());return t.classId=this.classId,this._dataScope&&(t.dataScope=this._dataScope.clone()),t}}class Xt extends Z{constructor(t){super(t),this.type=T.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new $(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get baseline(){return this._baseline}set baseline(t){this._baseline=t}get orientation(){return this._orientation}set orientation(t){this._orientation=t}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(t){super.copyPropertiesTo(t),t._baseline=this._baseline}resizeArea(t,e){let i=this.vertices[this.vertices.length/2].x,s=this.vertices[this.vertices.length/2].y,n=this.width,r=this.height;for(let a of this.vertices)a.x=i+t/n*(a.x-i),a.y=s+e/r*(a.y-s);this._updateBounds()}getSVGPathData(){return super.getSVGPathData()+" z"}}class Qt extends Z{constructor(t){super(t),this.type=T.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t}get outerRadius(){return this._outerRadius}set outerRadius(t){this._outerRadius=t,this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new Y(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}get thickness(){return this._outerRadius-this._innerRadius}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._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 te extends Z{constructor(t){super(t),this.type=T.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}get center(){return new Y(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}set radius(t){this._radius=t,this._updateBounds()}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}_doTranslate(t,e){this._x+=t,this._y+=e,super._doTranslate(t,e)}}class ee{constructor(t,e){this.direction=e,this.items=t,this.type=S,this.id=this.type+"_"+[...new Set(this.items.map((t=>t.classId)))].join("_")}apply(){let t,e=this.direction;this.direction==C.Top||this.direction==C.Left?t=Math.min(...this.items.map((t=>t.bounds[e]))):this.direction==C.Bottom||this.direction==C.Right?t=Math.max(...this.items.map((t=>t.bounds[e]))):this.direction!=C.Center&&this.direction!=C.Middle||(t=n.mean(this.items.map((t=>t.bounds[e]))));let i=this.items.map((i=>t-i.bounds[e])),s=e==C.TOP||e==C.Middle||e==C.Bottom?"y":"x";this.items.forEach(((t,e)=>{if(t.parent&&t.parent.layout&&t.parent.layout.type==y.Stack){let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t.parent._doTranslate(n,r)}else{let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t._doTranslate(n,r)}}));let r={};this.items.forEach((t=>r[t.classId]=t)),Object.values(r).forEach((t=>t.getScene()._updateAncestorBounds(t)))}toJSON(){let t={};return t.items=this.items.map((t=>t.id)),t.direction=this.direction,t.type=this.type,t.id=this.id,t}}class ie{constructor(t,e,i,s,n,r,a){this.item=t,this.baseItem=e,this.scene=i,this.channel=s,this.itemAnchor=n,this.baseAnchor=r,this.offset=a,this.type=E,this.id=this.type+"_"+this.item.classId+"_"+this.baseItem.classId+"_"+s}apply(){let t=et(this.item,this.scene),e=et(this.baseItem,this.scene),i=this.itemAnchor,s=this.baseAnchor,n=this.item.type==T.PointText;if("radialDistance"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];a.type==T.Arc||a.type==T.Ring?r="top"==s?a.outerRadius+this.offset:"bottom"==s?a.innerRadius+this.offset:(a.outerRadius+a.innerRadius)/2+this.offset:a.type==T.Circle&&(r="top"==s?a.radius+this.offset:"bottom"==s?this.offset:a.radius/2+this.offset),o._doTranslate(a.x-o.x,a.y-r-o.bounds[i]),o._rotate?o._rotate=[o._rotate[0],a.x,a.y]:o._rotate=[0,a.x,a.y]}else if("angle"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];r=a.type==T.Arc?"left"==s?a.endAngle+this.offset:"center"==s?a.startAngle+a.angle/2+this.offset:a.startAngle+this.offset:90,o._rotate?o._rotate[0]=90-r:(o._doTranslate(a.x-o.bounds[i],a.y-t[n].y),o._rotate=[90-r,e[n].x,e[n].y])}else{let r;if(this.baseItem.type==T.Link)switch(s){case"left":case"top":r=0;break;case"center":case"middle":r=.5;break;case"right":case"bottom":r=1}for(let a=0;a<t.length;a++){let o=this.baseItem.type==T.Link?e[a].getPointAt(r)[this.channel]:e[a].bounds[s]+this.offset;n?(t[a].anchor["x"==this.channel?0:1]=this.itemAnchor,t[a][this.channel]=o):"x"==this.channel?t[a]._doTranslate(o-t[a].bounds[i],0):t[a]._doTranslate(0,o-t[a].bounds[i])}}this.item.getScene()._updateAncestorBounds(this.item),this.baseItem.getScene()._updateAncestorBounds(this.baseItem)}toJSON(){let t={};return t.item=this.item.id,t.baseItem=this.baseItem.id,t.channel=this.channel,t.itemAnchor=this.itemAnchor,t.baseAnchor=this.baseAnchor,t.offset=this.offset,t.type="affixation",t.id=this.id,t}}class se extends St{constructor(t,e,i){super(),this.type=T.Gridlines,this.id=this.type+pt[this.type]++,this.encoding=t,this.channel=this.encoding.channel,this._item=e,this._strokeColor="strokeColor"in i?i.strokeColor:"#ddd",this._strokeWidth="strokeWidth"in i?i.strokeWidth:1,"radialDistance"==this.channel&&"angle"in i&&(this._rotate=[-i.angle,this.encoding.x,this.encoding.y])}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.args.strokeColor=this._strokeColor,t.args.strokeWidth=this._strokeWidth,t.args.values=this._values,"time"===this.encoding.scale.type&&(t.args.isDate=!0),t.channel=this.encoding.channel,t.field=this.encoding.field,this._rotate&&(t.args.angle=this._rotate[0]),t}get values(){return this._values}set values(t){this._values=t,this.updateLines(),this.updateLinePositions()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t;for(let e of this.children)e.strokeColor=t}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t;for(let e of this.children)e.strokeWidth=t}matches(t){let e=at(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(at(t.anyItem).split("_")[0]===e)return!0}return!1}updateLinePositions(){let t=bt(this._item)?bt(this._item):vt(this._item);if("x"==this.channel||"width"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);for(let[t,s]of this.children.entries()){let n=i[0]+this.encoding.scale.map(this._values[t])-this.encoding.scale.range[0];s._setVertices([[n,e.top],[n,e.bottom]])}}else if("y"==this.channel||"height"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);if(this.encoding.flip)for(let[t,s]of this.children.entries()){let n=i[1]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}else for(let[t,s]of this.children.entries()){let n=i[0]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}}else if("radialDistance"==this.channel)for(let[t,e]of this.children.entries())e.x=this._item.parent.x,e.y=this._item.parent.y,e.radius=this.encoding.scale.map(this._values[t]);for(let t of this.children)t._updateBounds();this._updateBounds()}updateLines(){if(this.children=[],"x"==this.channel||"y"==this.channel||"width"==this.channel||"height"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Z({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=T.Line,e.id=this.id+"line"+t,this.addChild(e)}else if("radialDistance"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Pt({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=T.Circle,e.id=this.id+"line"+t,this.addChild(e)}}}class ne extends St{constructor(){super(),this.type=T.Collection,this._id=this.type+pt[this.type]++,this.classId=this.id,this._childrenOrder=void 0}get childrenOrder(){return this._childrenOrder?this._childrenOrder:{field:"atlas_rowId",direction:"asc"}}set childrenOrder(t){if(!("field"in t)&&!("direction"in t))return;let e,i=t.field;if(this.dataScope.dataTable.hasField(i)){if(this._childrenOrder=t,i===h)e=(t,e)=>parseInt(t.dataScope.getFieldValue(i).substring(1))-parseInt(e.dataScope.getFieldValue(i).substring(1));else{switch(this.children[0].dataScope.getFieldType(i)){case A.Date:break;case A.Number:case A.Integer:e=(t,e)=>t.dataScope.aggregateNumericalField(i)-e.dataScope.aggregateNumericalField(i);break;case A.String:e=t.ranking?(e,s)=>t.ranking.indexOf(e.dataScope.getFieldValue(i))-t.ranking.indexOf(s.dataScope.getFieldValue(i)):(t,e)=>t.dataScope.getFieldValue(i)<e.dataScope.getFieldValue(i)?-1:1}}this.children.sort(e),"desc"==t.direction&&this.children.reverse(),this.layout&&this.layout.run()}else console.warn("Cannot order collection children by an non-existent field",t.field)}duplicate(){let t=this.getScene().collection();for(let e=0;e<this.children.length;e++){let i=this.children[e];t.addChild(i.duplicate())}if(t.classId=this.classId,this.parent.addChild(t),this._layout){let e=this._layout.clone();t.layout=e}return t}}class re extends Z{constructor(t){super(t),this._type=T.Arc,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=kt(this._startAngle),this._er=kt(this._endAngle);let e=this._x+this._innerRadius*Math.cos(this._sr),i=this._y-this._innerRadius*Math.sin(this._sr),s=this._x+this._innerRadius*Math.cos(this._er),n=this._y-this._innerRadius*Math.sin(this._er),r=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),h=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[e,i],[r,a],[o,h],[s,n]])}get type(){return 0===this._innerRadius?T.Pie:T.Arc}set type(t){this._type=t}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t,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[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}set outerRadius(t){this._outerRadius=t,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._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new Y(this._x,this._y)}set x(t){this._x=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this._updateBounds()}set y(t){this._y=t,this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}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}sweepOver(t){let e=this.startAngle,i=this.endAngle;i<e&&(i+=360);let s=t.startAngle,n=t.endAngle;return n<s&&(n+=360),s>=e&&s<=i&&n>=e&&n<=i}_doTranslate(t,e){this._x+=t,this._y+=e,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._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>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,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}adjustAngle(t,e){this._startAngle=t,this._endAngle=e,this._sr=kt(this._startAngle),this._er=kt(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)}}class ae extends q{constructor(t){super(t),this.type=T.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}toJSON(){let t=super.toJSON();return t.src=this._src,t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}get src(){return this._src}set src(t){this._src=t}get width(){return this._width}set width(t){this._width=t,this._updateBounds()}get height(){return this._height}set height(t){this._height=t,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new a(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}}class oe extends Z{constructor(t){super(t),this.type=T.Link,this.mode="mode"in t?t.mode:"linear",this.source=void 0,this.target=void 0,this.sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this.targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this.sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this.targetOffset="targetOffset"in t?t.targetOffset:[0,0]}radialvalue(t,e){let i=t-Math.PI/2;return[t=e*Math.cos(i),e*=Math.sin(t)]}bezierCurveHorizontal(t,e,i,s){return`M ${t} ${e} C ${(t+i)/2} ${e} ${t} ${s} ${i} ${s}`}bezierCurveVertical(t,e,i,s){return`M ${t} ${e} C ${t} ${(e+s)/2} ${i} ${e} ${i} ${s}`}bezierCurveRadial(t,e,i,s){let n=this.radialvalue(t,e),r=this.radialvalue(t,(e+s)/2),a=this.radialvalue(i,e),o=this.radialvalue(i,s);return`M ${n[0]} ${n[1]} C ${r[0]} ${r[1]} ${a[0]} ${a[1]} ${o[0]} ${o[1]}`}_updateBounds(){if(null!=this.source&&null!=this.target){let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];this._bounds=new a(Math.min(t,i),Math.min(e,s),Math.abs(t-i),Math.abs(e-s))}else this._bounds=new a(0,0,0,0)}getSVGPathData(){if(void 0===this.source||void 0===this.target)return"";let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];switch(this.mode){case"curveHorizontal":return this.bezierCurveHorizontal(t,e,i,s);case"curveVertical":return this.bezierCurveVertical(t,e,i,s);case"linear":default:return`M ${t} ${e} L ${i} ${s}`}}copyPropertiesTo(t){super.copyPropertiesTo(t),t.sourceAnchor=this.sourceAnchor.slice(),t.targetAnchor=this.targetAnchor.slice(),t.sourceOffset=this.sourceOffset.slice(),t.targetOffset=this.targetOffset.slice(),t.mode=this.mode}getPointAt(t){const e=yt.getSVG();let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",this.getSVGPathData()),e.appendChild(i);let s=i.getTotalLength();return i.getPointAtLength(s*t)}}const he=function(t,e,i){let s=t.getScene();dt(t)||s._reapplyConstraints(t),s.getRelatedAxes(t).forEach((t=>{t.encoding&&void 0!==t.encoding.scale.offset&&(t.encoding.scale.offset+="x"===t.channel||"width"===t.channel?e:i),0===i||"x"!==t.channel&&"width"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+i),0===e||"y"!==t.channel&&"height"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+e),t.reposition()})),s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},le=function(t,e,i){let s=t.getScene();s._relayoutAncestors(t,e);let n=[t],r=t.firstChild;for(;r;)n.push(r),r=r.firstChild;for(let t of n)t.getScene()._reapplyConstraints(t);if(i)s.reCreateRelatedAxes(t);else{s.getRelatedAxes(t).forEach((t=>t.reposition()))}s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},ce=function(t){for(let e of t.encodings)e._map(),e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let i=e.anyItem,s=e.scene.getRelatedAxes(i);for(let i of s)i.encoding&&i.encoding.scale===t&&(i.tickValues=e.scene._inferTickValues(e),i.labelValues=e.scene._inferTickValues(e),i._positionPath(),i._showTitle&&i._positionTitle(),"radialDistance"===i._channel&&i._rotate&&(i._rotate=[i._rotate[0],i._item.parent.x,i._item.parent.y]),i._updateBounds());e.scene.getRelatedGridlines(i).forEach((t=>t.updateLinePositions()))}},de=function(t){for(let e of t.encodings)e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let t=e.anyItem;e.scene.getRelatedAxes(t).forEach((t=>t.reposition())),e.scene.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))}},ue=function(t,e){let i=t.getScene();i._relayoutAncestors(t,e),i._reapplyConstraints(t),i.getRelatedAxes(t).forEach((t=>t.reposition())),i.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},fe=function(t,e){let i=e.getScene(),s=i.encodings[at(t)];if(s){i.encodings[at(e)]={};for(let n of["x","y"]){const r=s[n];r&&(r.anyItem=e,r.items=et(e,i),i.encodings[at(e)][n]=r,delete i.encodings[at(t)][n])}0===Object.keys(s)&&delete i.encodings[at(t)]}},pe=function(t){let e=t.getScene(),i=e.encodings[at(t)];for(let t in i)i[t]._apply();e.getRelatedAxes(t).forEach((t=>t.reposition())),e.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))};function ge(t,e,i,s){let n=s.getFieldType(i);if(n!=A.String&&n!=A.Date&&n!=A.Integer)throw new Error(z.REPOPULATE_BY_NONCAT+": "+i+" is "+n);if(e.parent&&e.parent.dataScope&&!e.parent.dataScope.isFullTable()&&e.parent.dataScope.dataTable!=s)throw new Error(z.REPOPULATE_DT_MISMATCH);return function(t,e,i,s){let n=et(e.parent,t);1===n.length&&(e.parent.dataScope=void 0);for(let t of n){let e=s.getFieldSummary(i).unique.map((e=>t.dataScope?t.dataScope.cross(i,e):new It(s).cross(i,e)));e=e.filter((t=>!t.isEmpty()));const n=e.length-t.children.length,r=t.children.length-e.length;for(let e=0;e<r;e++)t.removeChildAt(t.children.length-1);const a=t.children.length;for(let e=0;e<n;e++){let e=t.children[Math.floor(Math.random()*a)].duplicate();t.addChild(e)}t.children.forEach(((t,i)=>t.dataScope=e[i]))}t._relayoutAncestors(e)}(t,e,i,s)}function _e(t,e){let i=t.item;if(e.innerRadius===i.outerRadius&&i.sweepOver(e))t.children.push({item:e,children:[]});else if(t.children&&t.children.length>0&&e.innerRadius>i.outerRadius&&i.sweepOver(e))for(let i of t.children)_e(i,e)}function me(t,e,i,s){let n=t.item;if(n.innerRadius=e,n.outerRadius=e+s.map(i[n.id]),t.children&&t.children.length>0)for(let e of t.children)me(e,n.outerRadius,i,s)}class ye{constructor(t,e){this._type="tree";let i=[],s=[];this._nodeHash={},this._traverse(t,i,s),this._nodeTable=new Gt(i,"nodes"),this._linkTable=new Gt(s,"links"),this._nodeTable.tree=this,this._linkTable.tree=this,this._data=t,this.aggregateFromLeaves("value","average")}get type(){return this._type}_traverse(t,e,i,s=0){let n={};o in t||(t.id="n"+e.length),e.push(n),t._depth=s;for(let r in t)if("children"==r&&t[r]&&t[r].length>0)for(let n of t[r]){let r=this._traverse(n,e,i,s+1);i.push({parent:t.id,child:r})}else n[r]=t[r];return this._nodeHash[n.id]=n,n.id}getParent(t){let e,i=t.id,s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].child==i){e=s[t].parent;let i=n.findIndex((t=>t.id==e));return n[i]}}getChildren(t){let e=t.id,i=[],s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].parent==e){let e=s[t].child,r=n.findIndex((t=>t.id==e));i.push(n[r])}return i}getNodeDataScope(t){return new It(this._nodeTable).cross(h,t.atlas_rowId)}getMaxDepth(){return this._nodeTable._fieldSummaries._depth.max}getRoot(){return this._nodeTable.data[0]}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}getNode(t){return this._nodeTable.data.filter((e=>e.id==t))[0]}sumLeaves(t,e){if(!t)return 0;let i=t.id,s=[];if(s=this.getChildren(t),s&&s.length>0){let t=0;for(let i of s)t+=this.sumLeaves(i,e);this.getNode(i)["sum"+e]=t}else this.getNode(i)["sum"+e]=t[e];return t["sum"+e]}countLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0)for(let t of s)n+=this.countLeaves(t,e);else n=1;return this.getNode(i)["count"+e]=n,t["count"+e]}averageLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0){for(let t of s)n+=this.averageLeaves(t,e);n/=s.length,this.getNode(i)["average"+e]=n}else this.getNode(i)["average"+e]=t[e];return t["average"+e]}medianLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.medianLeaves(t,e));n.sort((function(t,e){return t-e}));let t=Math.floor(n.length/2);n.length%2?this.getNode(i)["median"+e]=n[t]:this.getNode(i)["median"+e]=(n[t-1]+n[t])/2}else this.getNode(i)["median"+e]=t[e];return t["median"+e]}maxLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.maxLeaves(t,e));this.getNode(i)["max"+e]=Math.max(...n)}else this.getNode(i)["max"+e]=t[e];return t["max"+e]}minLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.minLeaves(t,e));this.getNode(i)["min"+e]=Math.min(...n)}else this.getNode(i)["min"+e]=t[e];return t["min"+e]}aggregateFromLeaves(t,e){let i=this.getRoot();switch(e){case"sum":this.sumLeaves(i,t);break;case"count":this.countLeaves(i,t);break;case"average":this.averageLeaves(i,t);break;case"median":this.medianLeaves(i,t);break;case"max":this.maxLeaves(i,t);break;case"min":this.minLeaves(i,t)}}}function ve(t,e,i,s,n){switch(e.type){case T.Circle:return function(t,e,i,s,n){let r,a,o=i||k.Outward,h=s||50;if(o!==k.Inward&&o!==k.Outward)throw z.UNKNOWN_DIRECTION+" "+o;return et(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let l=i.parent;be(i,e.id,o,h,n,n.getRoot(),s,t,!0),s.layout=Yc("strata",{direction:o,rootMark:i}),l.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n);case T.Rect:return function(t,e,i,s,n){let r,a,o=i||k.Down,h=s||50;if([k.Up,k.Down,k.Left,k.Right].indexOf(o)<0)throw z.UNKNOWN_DIRECTION+" "+o;return et(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let l=i.parent;xe(i,e.id,o,h,n,n.getRoot(),s,t,!0),s.layout=Yc("strata",{direction:o,rootMark:i}),l.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n)}}function be(t,e,i,s,n,r,a,o,h){h&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let l=n.getChildren(r);if(0===l.length)return;let c=t.type===T.Circle||t.type===T.Ring?90:t.startAngle,d=(t.type===T.Circle||t.type===T.Ring?360:t.angle)/l.length;for(let r=0;r<l.length;r++){let h,u=t.type===T.Circle?t.radius:t.outerRadius;h=360===d?o.mark("ring",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}):o.mark("arc",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,startAngle:At(c+d*r),endAngle:At(c+d*(r+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),h.dataScope=n.getNodeDataScope(l[r]),h.classId=e,a.addChild(h),be(h,e,i,s,n,l[r],a,o)}}function xe(t,e,i,s,n,r,a,o,h){h&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let l,c,d,u=n.getChildren(r);if(0!==u.length){switch(i){case k.Up:case k.Down:case k.Left:case k.Right:default:l=t.left,c=t.bottom,d=t.width/u.length}for(let r=0;r<u.length;r++){let h=o.mark("rect",{left:l,top:c,width:d,height:s,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});l+=d,h.dataScope=n.getNodeDataScope(u[r]),h.classId=e,a.addChild(h),xe(h,e,i,s,n,u[r],a,o)}}}class we{constructor(t,e,i,s){this._listener=t,this._eventType=e,this._selDef=i,this._targetDef=s}getCallbackFunction(t,e){let i=this;return function(s){s.stopPropagation();let r,a=e._getSelection(s,i.selectionDef,i._listener,t.getItem(n.select(this).attr("id"))),o=et(i.targetDef.item,t);i.selectionDef.remember?(e.addGlobalPredicate(t,a.predicate),r=e.getGlobalPredicates(t)):r=e.getGlobalPredicates(t).concat([a.predicate]);for(let t of o){let e=!0;for(let i of r)if(!K(t,i)){e=!1;break}for(let s in i.targetDef.effect)s in t.staticProperties||(t.staticProperties[s]=t[s]),e?t[s]=i.targetDef.effect[s].selected:"unselected"in i.targetDef.effect[s]?t[s]=i.targetDef.effect[s].unselected:s in t.staticProperties&&(t[s]=t.staticProperties[s])}e._renderer.render(t,{visualOnly:!0})}}getRestoreFunction(t,e,i){let s=this;return function(){let n=et(s.targetDef.item,t);if(s.targetDef.effect)for(let t of n)for(let e in s.targetDef.effect)t[e]=t.staticProperties[e];else for(let t of n)for(let e in t.staticProperties)t[e]=t.staticProperties[e];i&&(e._globalPredicates={}),e._renderer.render(t,{visualOnly:!0})}}get listener(){return this._listener}get selectionDef(){return this._selDef}get targetDef(){return this._targetDef}get eventType(){return this._eventType}}class ke extends St{constructor(t){super(),t&&t.fillColor&&(this.fillColor=t.fillColor),this.type=T.Scene,this._id=this.type+pt[this.type]++,this.encodings={},this.constraints={},this._itemMap={},this._interactions=[]}clear(){this.removeAll(),this.encodings={},this.constraints={},this._itemMap={}}group(t){let e=new St;if(e.classId=e.id,this.addChild(e),t&&t.length>0)for(let i of t)e.addChild(i);return this._itemMap[e.id]=e,e}mark(t,e){let i=void 0===e?{}:e,s=null;switch(i.type=t,t){case T.Rect:{"top"in i||(i.top=0),"left"in i||(i.left=0),"width"in i||(i.width=100),"height"in i||(i.height=100);let t=i.top,e=i.left,n=i.width,r=i.height;i.vertices=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]],delete i.top,delete i.left,delete i.width,delete i.height,"fillColor"in i||(i.fillColor="none"),s=new Ft(i);break}case T.Area:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,e],[s,n],[t,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new Xt(i);break;case T.Line:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new Z(i),s.type=T.Line;break;case T.Path:s=new Z(i);break;case T.Circle:s=new Pt(i);break;case T.Ring:s=new Qt(i);break;case T.Arc:s=new re(i);break;case T.Polygon:s=new te(i);break;case T.Pie:i.innerRadius=0,"radius"in i&&(i.outerRadius=i.radius),s=new re(i);break;case"text":case T.PointText:"anchor"in i||(i.anchor=["center","middle"]),s=new Jt(i);break;case T.Image:s=new ae(i);break;case T.Link:s=new oe(i)}return null!==s&&(s.id="id"in i?i.id:s.type+pt[s.type]++,s.classId=s.id,this.addChild(s),this._itemMap[s.id]=s),s}glyph(...t){let e=new Kt(t);return e.classId=e.id,this.addChild(e),this._itemMap[e.id]=e,e}collection(){let t=new ne;return this.addChild(t),this._itemMap[t.id]=t,t}attach(t,e){t.dataScope=new It(e)}repeat(t,e,i){if(!t||void 0===e)throw z.INCOMPLETE_REPEAT_INFO;if(e.nodeTable&&e.linkTable){if(!Array.isArray(t)||2!==t.length)throw z.REPEAT_NODE_LINK;return function(t,e,i,s){let n=s.nodeTable.getFieldSummary(o).unique.map((t=>e.dataScope?e.dataScope.cross(o,t):new It(s.nodeTable).cross(o,t))),r=t.collection(),a={};r.dataScope=e.dataScope?e.dataScope.clone():new It(s.nodeTable),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}r.children.forEach(((t,e)=>{t.dataScope=n[e],a[t.dataScope.getFieldValue(o)]=t}));let l=s.linkTable.getFieldSummary(h).unique.map((t=>i.dataScope?i.dataScope.cross(h,t):new It(s.linkTable).cross(h,t))),c=t.collection();c.dataScope=i.dataScope?i.dataScope.clone():new It(s.linkTable),c.addChild(i);for(let t=1;t<l.length;t++){let t=i.duplicate();c.addChild(t)}c.children.forEach(((t,e)=>t.dataScope=l[e]));let d="tree"===s.type?"parent":"source",u="tree"===s.type?"child":"target";for(let t of c.children){let e=t.dataScope.getFieldValue(d),i=t.dataScope.getFieldValue(u);t.source=a[e],t.target=a[i],t._updateBounds()}return t.addChild(c),t.addChild(r),[r,c]}(this,t[0],t[1],e)}{let s=i||{},n=s.field?s.field:Gt.RowID,r=s.callback;Tt(n,e);let a=Ot(this,t,n,e,r);return s.layout&&(a.layout=s.layout),a}}repopulate(t,e,i){if(!t||void 0===e)throw z.INCOMPLETE_REPEAT_INFO;let s=i||{},n=s.field?s.field:Gt.RowID;Tt(n,e),ge(this,t,n,e)}densify(t,e,i){if(!t||void 0===e)throw z.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:Gt.RowID,a="startAngle"in s?s.startAngle:90,o="direction"in s?s.direction:"clockwise",h=s.callback;return Tt(r,e),Nt(this,t,n,r,e,h,a,o)}stratify(t,e,i){if(!(e instanceof ye))throw z.STRATIFY_WITHOUT_TREE;if(t.type!==T.Circle&&t.type!==T.Rect)throw z.STRATIFY_WRONG_ITEM;let s=i||{};return ve(this,t,s.direction,s.size,e)}divide(t,e,i){if(!t||null==e)throw z.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:Gt.RowID,a=s.callback;Tt(r,e);let o=Mt(this,t,n,r,e,a);return s.layout&&(o.layout=s.layout),fe(t,o),o}_validateEncodeArgs(t,e){if(!t||!("channel"in e)||!("field"in e))throw z.INCOMPLETE_BINDING_INFO;let i=e.field;if("vertex"==t.type||"segment"==t.type){if(!t.parent.dataScope&&!t.dataScope)throw z.BIND_WITHOUT_DATASCOPE}else if(!t.dataScope)throw z.BIND_WITHOUT_DATASCOPE;Tt(i,e.table?e.table:t.dataScope?t.dataScope._dt:t.parent.dataScope._dt)}encode(t,e){let i;if(this._validateEncodeArgs(t,e),"vertex"==t.type&&t.parent.type==T.Area){let e=et(t.parent,this);i=[];let s=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;for(let t of e)i=s?i.concat(t.vertices.slice(0,t.vertices.length/2)):i.concat(t.vertices.slice(t.vertices.length/2))}else i=et(t,this);return this._doEncode(i,e)}_doEncode(t,e){let i=t[0],s=e.channel,n=e.field;"datatable"in e||(e.datatable=i.dataScope?i.dataScope.dataTable:i.parent.dataScope.dataTable),"aggregator"in e||(e.aggregator="sum"),"flipScale"in e||(e.flipScale=!1),"includeZero"in e||(e.includeZero=!1),"scaleType"in e||(e.scaleType="linear");let r=new jt(t,this,s,n,e);switch(s){case"width":case"height":case"radius":case"outerRadius":case"innerRadius":case"area":case"fontSize":i.type==T.Area?Lt(r):Bt(r);break;case"strokeWidth":i.type==T.Link?function(t){t._query=function(){let t=this.field,e=this.channel,i=this.items.map((t=>t.dataScope));if("strokeWidth"==e)if(this.datatable.hasField(t))this.data=i.map((e=>e.getFieldValue(t)));else if(t.startsWith("parent.")||t.startsWith("child.")){let e=this.datatable.tree.nodeTable,s=t.split(".")[0],n=t.split(".")[1],r=i.map((t=>t.getFieldValue(s)));this.data=r.map((t=>new It(e).cross(o,t).getFieldValue(n)))}},t._map=function(){let t,e=this.channel,i=this.items;if("strokeWidth"==e){let e,s;t=Jc(this.scaleType),t.domain=[0,Math.max(...this.data)],e=1,s=Math.max(...i.map((t=>parseFloat(t.styles.strokeWidth)))),s==e&&(s=e+5),this.rangeExtent&&(s=e+this.rangeExtent),this.range&&(e=this.range[0],s=this.range[1]),t._setRange([e,s]),this.scale||(this.scale=t),this.scale._addEncoding(this)}},t._apply=function(){if("strokeWidth"==this.channel)for(let t=0;t<this.data.length;t++)this.items[t].styles.strokeWidth=this.scale.map(this.data[t])},t.run()}(r):Bt(r);break;case"x":case"y":i.type==T.Area?Lt(r):function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t,e,i,s,n,r=this.channel,a=this.datatable.getFieldType(this.field),o=it(this.anyItem);if(o&&o.type==y.Grid){let e=o.cellBounds;t="x"==r?e[0].width:e[0].height}else{let e=this.items.map((t=>t[r]));t=Math.max(...e)-Math.min(...e),t<100?t=100:t>500&&(t=500)}switch(this.rangeExtent&&(t=this.rangeExtent),a){case A.Boolean:break;case A.Date:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=s.concat(this.scale.domain);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=Jc("time"),this.scale.isFlipped=this._flipScale,n=[0,t];break;case A.String:if(s=Array.from(new Set(this.data)),n=[0,t],this.scale){let t=this.scale.domain;for(let e of s)t.indexOf(e)<0&&t.push(e);s=t,n=this.scale.range}else this.scale=Jc("point"),this.scale.isFlipped=this._flipScale,n=[0,t];break;default:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=s.concat(this.scale._scale.domain());s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=Jc(this.scaleType),this.scale.isFlipped=this._flipScale,this.scale.includeZero=this._includeZero,n=[0,t];s[0]==s[1]&&(s[1]=1.1*s[0])}this.scale._scale.domain(s),this.scale._setRange(n),this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);if("x"==e){let i=it(this.anyItem);if(i&&i.type==y.Grid)for(let t=0;t<this.items.length;t++){let i=this.items[t],s=st(i).left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){let t=ot(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t[e]))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n)}}}else{let i=it(this.anyItem);if(i&&i.type==y.Grid){let t=this.items.map((t=>st(t)));for(let i=0;i<this.items.length;i++){let s=this.items[i],n=0,r=t[i].bottom-this.scale.map(this.data[i])-s[e];s._doTranslate(n,r),"vertex"!=s.type&&"segment"!=s.type||s.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n)}}}},t.run()}(r);break;case"fillColor":case"strokeColor":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:this.data=[!0,!1];break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){switch(this.datatable.getFieldType(this.field)){case A.Date:break;case A.Boolean:if(!this.scale&&(this.scale=Jc("ordinalColor"),this.scale.domain=this.data,this._mapping)){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;case A.String:if(this.scale)this.scale.domain=Array.from(new Set(this.scale.domain.concat(this.data)));else if(this.scale=Jc("ordinalColor",this._scheme?this._scheme:"schemeCategory10"),this.scale.domain=this.data,this._mapping){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;default:if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=Jc("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=Jc("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=Jc("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}}this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);"vertex"==e.type||"segment"==e.type?e[this.channel]=i:e.styles[this.channel]=i,e.vertices&&"strokeColor"==this.channel&&e.vertices.forEach((t=>t.fillColor=i))}},t.run()}(r);break;case"angle":!function(t){t._query=function(){this.data=[],this.id2data={};let t=this.field,e=this.items;switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case A.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator)))}for(let t=0;t<this.data.length;t++)this.id2data[e[t].id]=this.data[t]},t._map=function(){this.scale||(this.scale=Jc("linear"),this.scale.domain=this.datatable.tree?[0,Math.max(...this.data)]:[0,this.data.reduce(((t,e)=>t+e),0)],this.scale._setRange([0,360]),this.scale._addEncoding(this))},t._apply=function(){let t;for(let e=0;e<this.items.length;e++)t=this.items[e],t.type!==T.Arc&&t.type!==T.Pie||t.adjustAngle(t.startAngle,At(t.startAngle+this.scale.map(this.data[e])));this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"text":!function(t){t._query=function(){this.data=[];let t,e,i=this.items;if(this.field.startsWith("parent.")||this.field.startsWith("child.")){e=this.datatable.tree.nodeTable,t=this.field.split(".")[1];let s=this.field.split(".")[0],n=i.map((t=>t.dataScope)).map((t=>t.getFieldValue(s)));e.getFieldType(t)==A.Integer||e.getFieldType(t)==A.Number?this.data=n.map((i=>new It(e).cross(o,i).aggregateNumericalField(t))):this.data=n.map((i=>new It(e).cross(o,i).getFieldValue(t)))}else e=this.datatable,t=this.field,e.getFieldType(t)==A.Integer||e.getFieldType(t)==A.Number?this.data=i.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator))):this.data=i.map((e=>e.dataScope.getFieldValue(t)))},t._map=function(){if(this.scale);else switch(this.datatable.getFieldType(this.field)){case A.Boolean:case A.Date:break;case A.String:default:this.scale=Jc("ordinal"),this.scale.domain=[...new Set(this.data)],this.scale._scale.range(this.scale.domain.map((t=>t+"")))}},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.text=i}},t.run()}(r);break;case"radialDistance":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t=this.data;this.scale||(this.scale=Jc("linear"),this.scale.domain=[0,Math.max(...t)],this.scale._setRange([0,this.anyItem.parent.radius])),this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]),s=xt(this.anyItem.parent.x,this.anyItem.parent.y,i,e.polarAngle);e.x=s[0],e.y=s[1]}this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"thickness":!function(t){t._query=function(){this.data={};let t=this.field,e=this.items,i=e.map((t=>t.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t);break;case A.String:try{for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].aggregateNumericalField(t,this.aggregator)}},t._map=function(){let t=this.data;if(!this.scale){this.scale=Jc(this.scaleType),this.scale.domain=[0,Math.max(...Object.values(t))];let e=1,i=this.rangeExtent?e+this.rangeExtent:Math.max(...this.items.map((t=>t.outerRadius)));this.scale._setRange([e,i])}this.scale._addEncoding(this)},t._apply=function(){this.items.sort(((t,e)=>(t.innerRadius+t.outerRadius)/2-(e.innerRadius+e.outerRadius)/2));let t={item:new re({outerRadius:0,startAngle:0,endAngle:360}),children:[]};for(let e of this.items)_e(t,e);for(let e of t.children)me(e,e.item.innerRadius,this.data,this.scale)},t.run()}(r)}return"_remember"in e&&1!=e._remember||this._registerBinding(r),s.indexOf("Color")<0&&this._updateAncestorBounds(i,r.items),r}encodeWithinCollection(t,e){this._validateEncodeArgs(t,e);let i=function(t,e){let i={},s=et(t,e);for(let t of s){let e=t.parent.id;e in i||(i[e]=[]),i[e].push(t)}return Object.keys(i).map((t=>i[t]))}(t,this),s=[];for(let t of i){let i=this._doEncode(t,e);s.push(i)}return s}getPeers(t){return et(t,this)}find(t){return X(this,t)}align(t,e){if(!function(t,e,i){if(e==C.Top||e==C.Bottom||e==C.Middle){for(let e of t)if(!_t(e,i))return!1;return!0}if(e==C.Left||e==C.Right||e==C.Center){for(let e of t)if(!gt(e,i))return!1;return!0}}(t,e,this))return!1;let i=new ee(t,e);if(i.id in this.constraints)return console.warn("constraint has been added"),!1;this.constraints[i.id]=i,i.apply(),this._updateAncestorBounds(t[0])}removeAllConstraints(){this.constraints={}}affix(t,e,i,s){let n=s||{},r="offset"in n?n.offset:0,a="itemAnchor"in n?n.itemAnchor:"x"==i||"angle"==i?"center":"middle",o="baseAnchor"in n?n.baseAnchor:"x"==i||"angle"==i?"center":"middle",h=new ie(t,e,this,i,a,o,r);h.id,this.constraints,this.constraints[h.id]=h,h.apply()}axis(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(s){s.datatable.getFieldType(e)!==A.Date||"labelFormat"in n||(n.labelFormat="%m/%d/%y");let t=new Ht(s,n.item?n.item:s.anyItem,n);return"tickValues"in n?(t.tickValues=n.tickValues,t.labelValues=n.tickValues):(t.tickValues=s._inferTickValues(),t.labelValues=s._inferTickValues()),this.addChildAt(t,0),this._itemMap[t.id]=t,this._updateBounds(),t}let r=n.item?n.item:X(this,[{field:e}])[0];void 0===r&&console.warn(D+e);let a=it(r);if(a&&("x"==t||"y"==t)){let i,s,r=et(a.group,this);for(let a of r){let r=X(a,[{field:e}])[0],o=et(r,a);r.dataScope.dataTable.getFieldType(e)!==A.Date||"labelFormat"in n||(n.labelFormat="%m/%d/%y"),i=new $t(o,a.layout,t,e,n),null==s&&(s=i.id),i.classId=s,this.addChildAt(i,0),this._itemMap[i.id]=i}return this._updateBounds(),i}console.warn(D+e)}getRelatedAxes(t){let e=[];if(dt(t))return e;for(let i of this.children){if(i.type!==T.Axis)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ht(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}removeItem(t){if(!dt(t)){let e=this.getRelatedEncodings(t);for(let t of e)this.removeEncoding(t);let i=this.getRelatedAxes(t);for(let t of i)this.removeItem(t);for(let e of this.getRelatedGridlines(t))this.removeItem(e)}delete this._itemMap[t.id],this.removeChild(t),this._updateBounds()}getRelatedEncodings(t){let e=[],i=t;for(;i;)if(e.push(at(i)),i.type==T.Collection)i=i.firstChild;else if(i.type==T.Glyph){for(let t of i.children)e.push(at(t));i=void 0}else i=void 0;let s=Object.keys(this.encodings),n=[];for(let t of s){let i=t.split("_")[0];if(e.indexOf(i)>=0)for(let e in this.encodings[t])n.push(this.encodings[t][e])}return n}removeAllEncodings(){this.encodings={},this.removeAllItemsByType(T.Axis),this.removeAllItemsByType(T.Legend),this.removeAllItemsByType(T.Gridlines)}removeEncoding(t){let e=at(t.anyItem);delete this.encodings[e][t.channel];let i=[];for(let e of this.children)dt(e)&&e.encoding&&e.encoding===t&&i.push(e);for(let t of i)this.removeItem(t);this._updateBounds()}removeAllItemsByType(t){let e=[];for(let i of this.children)i.type===t&&e.push(i);for(let t of e)this.removeItem(t);this._updateBounds()}reCreateRelatedAxes(t){this.getRelatedAxes(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),delete e.tickValues,delete e.labelValues,this.removeItem(t),this.axis(t.channel,t.field,e)})),this._updateBounds()}reCreateRelatedLegends(t){this.getRelatedLegends(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),this.removeItem(t),this.legend(t.channel,t.field,e)})),this._updateBounds()}legend(t,e,i){let s=i||{},n=this.getEncodingByField(e,t);if(!n)throw z.INCORRECT_LEGEND_INFO+e;"x"in s||(s.x=100),"y"in s||(s.y=100);let r=new Zt(n,s);return this.addChild(r),this._itemMap[r.id]=r,this._updateBounds(),r}gridlines(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(!s)return!1;let r=new se(s,n.item?n.item:s.anyItem,n);return r.values="values"in n?n.values:s._inferTickValues(),this.addChildAt(r,0),this._itemMap[r.id]=r,this._updateBounds(),r}getRelatedLegends(t){let e=[];if(dt(t))return e;for(let i of this.children)i.type===T.Legend&&i.matches(t)&&e.push(i);return e}getRelatedGridlines(t){let e=[];if(dt(t))return e;for(let i of this.children){if(i.type!==T.Gridlines)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ht(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}propagate(t,e,...i){let s=et(t,this);for(let t of s)t[e](...i)}classify(t,e,i){let s,n={},r=t[0].parent;for(let i of t){let t=i.dataScope.getFieldValue(e);t in n||(n[t]=[]),n[t].push(i)}let a=[],o=t[0].dataScope._dt;for(let t in n){let r=this.collection();i.addChild(r),void 0===s&&(s=r.id),r.classId=s,r.dataScope=new It(o).cross(e,t);for(let e of n[t])r.addChild(e);a.push(r)}return 0===r.children.length&&r.parent.removeChild(r),a}getEncodingByItem(t,e){let i=this.encodings[at(t)];return i&&i[e]?i[e]:null}getEncodingByField(t,e){for(let i in this.encodings){let s=this.encodings[i];if(s[e]&&s[e].field==t)return s[e]}return null}positionBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(!ft(t))return null;for(let i in this.encodings){if(i.split("_")[0]===t.classId&&e in this.encodings[i])return this.encodings[i][e]}}sizeBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(ft(t)){let i="width"===e||"height"===e||"radius"===e?["area"]:["width","height"],s="width"===e?["x"]:"height"===e?["y"]:["x","y"];for(let e in this.encodings){let n=e.split("_")[0];if(e.indexOf("_")<0){for(let s of i)if(n===t.classId&&s in this.encodings[e])return this.encodings[e][s]}else for(let i of s)if(n===t.classId&&i in this.encodings[e])return this.encodings[e][i]}}return null}setProperties(t,e){let i,s={};for(let t in e)s[t]=!0;if(Object.values(y).indexOf(t.type)>-1&&t.group){i=et(t.group,this);for(let t of i)for(let i in e)t.layout[i]=e[i]}else if(i=et(t,this),"vertex"===t.type)for(let t of i)for(let i in e)t[i]=e[i];else if(t instanceof q)for(let n in e)if("x"!==n&&"y"!==n||!this.positionBound(t,n))if("width"!==n&&"height"!==n&&"radius"!==n||!this.sizeBound(t,n))t.type!==T.Rect&&t.type!==T.Line||"width"!==n&&"height"!==n?t.type==T.Circle&&"radius"==n?i.forEach((t=>t.resize(2*e[n],2*e[n],e.xRef,e.yRef))):i.forEach((t=>t[n]=e[n])):"width"===n?i.forEach((t=>t.resize(e[n],t.bounds.height,e.xRef))):i.forEach((t=>t.resize(t.bounds.width,e[n],void 0,e.yRef)));else{let i=this.getEncodingByItem(t,n);i||"radius"!=n||(i=this.getEncodingByItem(t,"area"));let s=i.scale.rangeExtent*e[n]/t[n];i.scale.rangeExtent=s}else s[n]=!1;else if("collection"==t.type||"group"==t.type)for(let t of i)for(let i in e)t[i]="layout"===i&&void 0!==e[i]?e[i].clone():e[i];let n=Object.keys(s).filter((t=>s[t])),r=["width","height","fontSize","area","radius"];for(let e of r)if(n.indexOf(e)>=0&&ut(t)){ue(t,i);break}n.indexOf("baseline")>=0&&t.type===T.Area&&pe(t,i);let a=["layout","rowGap","colGap","numRows","numCols","vertCellAlignment","horzCellAlignment"];for(let t of a)if(n.indexOf(t)>=0){let t=n.indexOf("numRows")>=0||n.indexOf("numCols")>=0||n.indexOf("layout")>=0;le(i[0],i,t);break}return s}_canTranslate(t){let e={x:!0,y:!0};return t.type==T.Axis?("x"===t.channel||"width"===t.channel?e.x=!1:"y"!==t.channel&&"height"!==t.channel||(e.y=!1),e):(t.parent.type===T.Collection&&t.parent.layout&&(e.x=!1,e.y=!1),this.positionBound(t,"x")&&(e.x=!1),this.positionBound(t,"y")&&(e.y=!1),e)}translate(t,e,i){let s=this._canTranslate(t);if(!s.x&&!s.y)return s;const n=s.x?e:0,r=s.y?i:0;return t._doTranslate(n,r),this._updateAncestorBounds(t),he(t,n,r),s}_updateAncestorBounds(t,e){let i=ot(e||et(t,this));for(;i.length>0;){for(let t of i)(t.children&&t.children.length>0||t.vertices)&&t._updateBounds();i=ot(i)}}_reapplyConstraints(t){let e=t,i=[t];for(;e.children;)e.type==T.Collection?i.push(e.firstChild):i=i.concat(e.children),e=e.firstChild;for(e=t.parent;e&&e.type!==T.Scene;)i.push(e),e=e.parent;const s=i.map((t=>t.classId));for(let t in this.constraints){const e=this.constraints[t];switch(e.type){case E:(s.indexOf(e.item.classId)>=0||s.indexOf(e.baseItem.classId)>=0)&&e.apply();break;case S:for(let t of e.items)if(s.indexOf(t.classId)>=0){e.apply();break}}}}_relayoutAncestors(t,e){let i=ot(e||et(t,this));for(;i.length>0;){for(let t of i)t.layout&&t.layout.run(),t.children&&t.children.length>0&&t._updateBounds(),t.vertices&&t._updateBounds();i=ot(i)}}_reapplySizeBindings(t){let e=["width","height"];for(let i in this.encodings){if(t.classId!=i)continue;let s=this.encodings[i],n=X(this,[{classId:i}]);for(let t of e){let e=s[t];e&&e.run()}this._relayoutAncestors(n[0],n)}}_registerBinding(t){let e=this.encodings,i=at(t.anyItem);return i in e||(e[i]={}),e[i][t.channel]=t,!0}toJSON(){let t=super.toJSON();this.fillColor&&(t.fillColor=this.fillColor);let e={};t.encodings=[],t.itemCounter=pt;for(let i in this.encodings)for(let s in this.encodings[i]){let n=this.encodings[i][s];t.encodings.push(n.toJSON()),n.scale&&!(n.scale.id in e)&&(e[n.scale.id]=n.scale.toJSON())}t.scales=e,t.constraints={};for(let e in this.constraints)t.constraints[e]=this.constraints[e].toJSON();t.tables={};let i=this.getDataTables();for(let e in i)t.tables[e]=i[e].toJSON();return t}getDataTables(){let t={};for(let e in this.encodings)for(let i in this.encodings[e]){let s=this.encodings[e][i];s.datatable.id in t||(t[s.datatable.id]=s.datatable)}for(let e of this.children)if(!dt(e)){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}if(e.children&&e.children.length>0){let i=e.firstChild;for(;i;){if(i.dataScope){t[i.dataScope.dataTable.id]=i.dataScope.dataTable;break}i=i.children&&i.children.length>0?i.firstChild:void 0}}}return t}getItem(t){let e=t.split("_")[0];if(t.indexOf("_v_")>0){let i=parseInt(t.split("_v_")[1]);return this._itemMap[e].vertices.find((t=>t._id===i))}if(t.indexOf("_s_")>0){let i=parseInt(t.split("_s_")[1]);return this._itemMap[e].segments.find((t=>t._id===i))}return this._itemMap[t]}addInteraction(t,e,i,s){let n=new we(t,e,i,s);this._interactions.push(n)}}class Ce{constructor(t){this._renderer=t,this._globalPredicates={}}processInteraction(t,e){let i=t.listener;if(ut(i)){let s=i.classId?"."+i.classId:"#"+i.id;switch(t.eventType){case"hover":n.selectAll(s).on("mouseover",t.getCallbackFunction(e,this)),n.selectAll(s).on("mouseleave",t.getRestoreFunction(e,this));break;case"click":n.selectAll(s).on("mousedown",t.getCallbackFunction(e,this))}}else if(i.type==T.Scene){if(!t.targetDef||!t.targetDef.item)return;t.selectionDef.item||n.select("#"+this._renderer._svgId).on("mousedown",t.getRestoreFunction(e,this,!0))}}_getSelection(t,e,i,s){let n={};s?n.item=s:e.item;let r=e.field?e.field:h;return n.item&&(n.predicate={field:r,value:n.item.dataScope.getFieldValue(r)}),n}addGlobalPredicate(t,e){t.id in this._globalPredicates||(this._globalPredicates[t.id]={}),this._globalPredicates[t.id][e.field]=e}getGlobalPredicates(t){return t.id in this._globalPredicates?Object.values(this._globalPredicates[t.id]):[]}}class Se{constructor(t){this._svgId=t,this._compMap={},this._decoMap={},this._interactionHandler=new Ce(this)}render(t,e){let i=e||{};for(let t in this._decoMap)this._decoMap[t].remove(),delete this._decoMap[t];this._removed={};for(let t in this._compMap)this._removed[t]=1;this._renderItem(t,i);for(let t in this._removed)this._compMap[t].remove(),delete this._compMap[t];if(!("visualOnly"in i))for(let e of t._interactions)this._interactionHandler.processInteraction(e,t)}clear(){let t=document.getElementById(this._svgId);for(;t.firstChild;)t.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(t,e){let i,s=t.id,r=t.parent;i=r&&r.id&&r.id in this._compMap?n.select("#"+this._svgId).select("#"+r.id):n.select("#"+this._svgId),s in this._compMap?delete this._removed[s]:this._compMap[s]=i.append(this._getSVGElementType(t)),t.type==T.Gridlines&&this._compMap[s].lower();let a=this._compMap[s];if(a.attr("id",s),t.classId&&a.attr("class",t.classId),t.type==T.Scene&&n.select("#"+this._svgId).style("background",t.fillColor?t.fillColor:"#fff"),"vertex"!=t.type){if(t.type==T.Path||t.type==T.Polygon||t.type==T.Link)a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==T.Line)a.attr("x1",t.vertices[0].x),a.attr("y1",t.vertices[0].y),a.attr("x2",t.vertices[1].x),a.attr("y2",t.vertices[1].y),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==T.Circle)a.attr("cx",t.x),a.attr("cy",t.y),a.attr("r",t.radius);else if(t.type==T.Rect){let e=t.bounds;a.attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height)}else t.type==T.PointText?a.attr("text-anchor",this._getTextAnchor(t.anchor[0])).attr("alignment-baseline",this._getTextAnchor(t.anchor[1])).attr("dominant-baseline",this._getTextAnchor(t.anchor[1])).text(t.text).attr("x",t.x).attr("y",t.y):t.type==T.Pie||t.type==T.Area?(a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges")):t.type==T.Ring||t.type==T.Arc?a.attr("d",t.getSVGPathData()):t.type==T.Image&&a.attr("href",t.src).attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height);for(let e in t.styles)if(void 0!==t.styles[e])if(e.indexOf("Color")>0&&t.styles[e].type==T.LinearGradient){n.select("#"+this._svgId).select("defs").empty()&&n.select("#"+this._svgId).append("defs");let i=n.select("defs"),s=t.styles[e];if(i.select("#"+s.id).empty()){let t=i.append("linearGradient").attr("id",s.id);t.attr("x1",s.x1+"%").attr("x2",s.x2+"%").attr("y1",s.y1+"%").attr("y2",s.y2+"%");for(let e of s.stops)t.append("stop").attr("offset",e.offset+"%").style("stop-color",e.color).style("stop-opacity",e.opacity)}a.style(j[e],"url(#"+s.id+")")}else a.style(j[e],t.styles[e]);if(t._rotate&&a.attr("transform","rotate("+t._rotate.join(" ")+")"),t.vertices&&this._renderVertices(t),t.type==T.Collection&&e&&e.collectionBounds){let e=t.bounds;t.layout&&"grid"==t.layout.type?this._renderLayout(t):(t.id in this._decoMap||(this._decoMap[t.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[t.id].attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("fill","none").attr("stroke","#1ecb40").attr("stroke-width","2px").attr("stroke-dasharray","5,5"))}if(t.children)for(let i of t.children)this._renderItem(i,e)}}_renderVertices(t){let e=t.id+"-vertices";if(e in this._compMap)delete this._removed[e];else{let i=t.parent,s=i?i.id:this._svgId;this._compMap[e]=n.select("#"+s).append("g").attr("id",e)}if(0===t.vertices.map((t=>t.shape)).filter((t=>void 0!==t)).length)return void this._compMap[e].style("visible","hidden");this._compMap[e].style("visible","visible");let i=t.vertices.filter((t=>void 0!==t.shape));for(let t of i){let i=e+"-"+t.id;i in this._compMap?t.shape!==this._compMap[i].node().tagName?(this._compMap[i].remove(),this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),delete this._removed[i]):delete this._removed[i]:this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),"rect"==t.shape?n.select("#"+i).attr("x",t.x-t.width/2).attr("y",t.y-t.height/2).attr("width",t.width).attr("height",t.height):"circle"==t.shape&&n.select("#"+i).attr("cx",t.x).attr("cy",t.y).attr("r",t.radius),n.select("#"+i).style("fill",t.fillColor).style("opacity",t.opacity).style("stroke-width",t.strokeWidth).style("stroke",t.strokeColor)}}_renderLayout(t){let e=t.id+"-grid";e in this._decoMap||(this._decoMap[e]=n.select("#"+this._svgId).append("g").attr("id",e).attr("class","deco"));let i=t.layout.cellBounds,s=t.layout.rowGap;this._decoMap[e].selectAll("rect").remove(),this._decoMap[e].selectAll("rect").data(i.slice(0,i.length-1)).enter().append("rect").attr("x",(t=>t.left)).attr("y",(t=>t.bottom)).attr("width",(t=>t.width)).attr("height",s).style("fill","pink").style("opacity",.5);let r=Math.min(...i.map((t=>t.left))),a=Math.min(...i.map((t=>t.top)));this._decoMap[e].append("rect").attr("x",r).attr("y",a).attr("width",t.bounds.width).attr("height",t.bounds.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getTextAnchor(t){switch(t){case"top":return"text-before-edge";case"bottom":return"text-after-edge";case"left":return"start";case"right":return"end";case"center":case"middle":return"middle";default:return t}}_getSVGElementType(t){switch(t.type){case T.Rect:return"rect";case T.Collection:case T.Group:case T.Glyph:case T.Scene:case T.Axis:case T.Legend:case T.Gridlines:return"g";case T.Area:case T.Path:case T.Polygon:case T.Ring:case T.Pie:case T.Arc:case T.Link:return"path";case T.Circle:return"circle";case T.Line:return"line";case T.PointText:return"text";case"vertex":if("circle"==t.shape)return"circle";if("rect"==t.shape)return"rect";throw"argument exception";case"image":return"image"}}}class Ee{constructor(t,e){switch(this._type=t,this._offset=void 0,this.id="scale"+pt.scale++,this._flipped=!1,this._includeZero=!1,t){case"linear":if(e){let t=Object.keys(e).map((t=>parseFloat(t))).sort(((t,e)=>t-e)),i=t.map((t=>e[t]));this._scale=n.scaleLinear(t,i),"clamp"in e&&this._scale.clamp(e.clamp),this._mapping=e}else 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(e&&"string"==typeof e?n[e]:n.schemeCategory10);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":case"divergingColor":e&&"string"==typeof e?(this._scale=n.scaleSequential(n[e]),this._scheme=e):this._scale=n.scaleSequential()}this.encodings=[]}set scheme(t){if(this._type.indexOf("Color")<0&&"linear"!==this._type)return;let e=n.scaleSequential(n[t]),i=this._scale.domain();if(Math.min(...i)*Math.max(...i)<0){let t=Math.max(Math.abs(Math.min(...i)),Math.abs(Math.max(...i)));i=[-t,t]}e.domain(i),this._scheme=t,this._scale=e,"linear"===this._type&&(this._type=this._scale.domain()[0]*this._scale.domain()[1]<0?"divergingColor":"sequentialColor",this._mapping&&(this._mapping=void 0));for(let e of this.encodings)e._mapping&&(e._mapping=void 0),e._scheme=t,e._apply()}get scheme(){return this._scheme}get type(){return this._type}set type(t){let e;switch(t){case"linear":e=n.scaleLinear();break;case"power":e=n.scalePow().exponent(2);break;case"sqrt":e=n.scalePow().exponent(.5);break;case"log":e=n.scaleLog()}if(e){this._type=t,e.domain(this._scale.domain()).range(this._scale.range()),this._scale=e;for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}else console.warn(V+t)}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.offset=this._offset,t.domain=this._scale.domain(),t.range=this.range,t.clamp=this.clamp,t.isFlipped=this.isFlipped,t.includeZero=this.includeZero,this._scheme&&(t.scheme=this._scheme),t}_merge(t){if(this.type!=t.type)throw z.DIFFERENT_SCALE_TYPE;let e,i;switch(this.type){case"linear":case"time":e=[Math.min(this.domain[0],t.domain[0]),Math.max(this.domain[1],t.domain[1])],i=[0,this.map(e[1])-this.map(e[0])];break;case"point":case"ordinalColor":e=[...new Set(this.domain.concat(t.domain))],i=[];break;default:console.log("TODO: merge scale type",this.type)}this._scale.domain(e),this._scale.range(i)}get domain(){if(this._includeZero){return[0,this._scale.domain()[1]]}return this._scale.domain()}set domain(t){this._scale.domain(t);for(let t of this.encodings)t._apply()}get range(){return this._scale.range()}
|
|
1
|
+
/* version: 1.7.5 */
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3"),require("three"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","d3","three","pixi.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msc={},t.d3,t.THREE,t.PIXI)}(this,(function(t,e,i,s){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var r=n(e),a=n(i),o=n(s);class l{constructor(t,e,i,s){this.left=t,this.top=e,this.width=i,this.height=s}toJSON(){let t={};return t.left=this.left,t.top=this.top,t.width=this.width,t.height=this.height,t}union(t){let e=Math.min(this.left,t.left),i=Math.min(this.top,t.top),s=Math.max(this.right,t.right),n=Math.max(this.bottom,t.bottom);return new l(e,i,s-e,n-i)}clone(){return new l(this.left,this.top,this.width,this.height)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get x(){return(this.left+this.right)/2}get y(){return(this.top+this.bottom)/2}get center(){return(this.left+this.right)/2}get middle(){return(this.top+this.bottom)/2}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}overlap(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}const h="id",c="atlas_rowId",d=["linear","power","log","sqrt","symlog","identity","time","ordinal","band","point","ordinalColor","sequentialColor","divergingColor"],u="natural",f="basis",p="bumpX",g="bumpY",_="linear",m="step",y="CatmullRom",v="cardinal",b={Grid:"grid",Circular:"circular",Stack:"stack",Treemap:"treemap",Packing:"packing",Force:"force",TidyTree:"tidytree",Sugiyama:"sugiyama",Strata:"strata"},x="vertical",w="horizontal",k="angular",S="radial",C={Up:"up",Down:"down",Left:"left",Right:"right",Inward:"inward",Outward:"outward",Clockwise:"clockwise",Anticlockwise:"anticlockwise"},E={Top:"top",Left:"left",Bottom:"bottom",Right:"right",Center:"center",Middle:"middle"},A="alignment",T="affixation",I={Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"pointText",Collection:"collection",Group:"group",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable"},O={Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"},M="max",R="min",N="avg",B="median",P="sum",F="count",L="mean",D="percentile 25",j="percentile 75",V={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"},z="Cannot find relevant information to create an axis for ",G="Cannot change scale type to ",W={FIELD_NONEXISTENT:"Data field does not exist in the data table",INCOMPLETE_REPEAT_INFO:"Incomplete information to do repeat. You must specify an item, a categorical data field and a data table",REPEAT_BY_NONCAT:"Repeat only works on a string or date field",PARTITION_BY_NONCAT:"Divide only works on a string or date field",DENSIFY_BY_NONCAT:"Densify only works on a string or date field",INCOMPLETE_REPOPULATE_INFO:"Incomplete information to re-populate. You must specify an item, a categorical data field and a data table",REPOPULATE_BY_NONCAT:"Repopulate only works on a string or date field",REPOPULATE_DT_MISMATCH:"Cannot repopulate with a data table that is different from the item's parent's data table",COMPNT_NON_REPEATABLE:"Item not repeatable",REPEAT_NODE_LINK:"To repeat with a tree or a network, you need to provide two marks, one for node and one for link",INCOMPLETE_PARTITION_INFO:"Incomplete information to divide. You must specify an item, a categorical data field and a data table",COMPNT_NON_PARTITIONABLE:"Item cannot be divided",INCOMPLETE_DENSIFY_INFO:"Incomplete information to densify. You must specify an item, a categorical data field and a data table",COMPNT_NON_DENSIFIABLE:"Item cannot be densified",STRATIFY_WITHOUT_TREE:"Stratify only works on a tree dataset",STRATIFY_WRONG_ITEM:"Stratify only works on a circle or a rectangle",BIND_WITHOUT_DATASCOPE:"Item must be repeated or divided by data first before applyng binding",UNKNOWN_ALIGNMENT:"Unkown alignment",UNKNOWN_Orientation:"Unkown orientation",UNKNOWN_DIRECTION:"Unkown direction",UNKOWNN_SCALE_TYPE:"Unknown scale type",UNKNOWN_ANCHOR:"Unknown anchor",INCOMPLETE_BINDING_INFO:"Incomplete binding information. You must specify an item, a data field and a visual channel",MULTIPLE_VALUES_PER_FIELD:"Multiple distinct field values exist",DIFFERENT_SCALE_TYPE:"Cannot merge different types of scale",INSUFFICIENT_DATA_SCOPES:"Insufficient data to divide or densify a mark",INCORRECT_CONSTRAINT_INFO:"Constrain information is incorreclty passed",FEATURE_NOT_IMPLEMENTED:"This feature has not been implemented yet",LAYOUT_WITHOUT_TREE:"The layout can only be applied to a tree"};class U{constructor(t){this.group=void 0}run(){}clone(){}}class q extends U{constructor(t){super(),this.type="grid",this._numCols=t.numCols,this._numRows=t.numRows,this._dir="dir"in t?t.dir:[q.direction.Left2Right,q.direction.Top2Bottom],this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&this._validateCellAlignment("h",t.horzCellAlignment)?t.horzCellAlignment:E.Left,this._cellVertAlignment="vertCellAlignment"in t&&this._validateCellAlignment("v",t.vertCellAlignment)?t.vertCellAlignment:E.Bottom}_validateCellAlignment(t,e){return"h"===t&&[E.Left,E.Center,E.Right].indexOf(e)>=0||("v"===t&&[E.Top,E.Middle,E.Bottom].indexOf(e)>=0||(console.warn("Invalid alignment:",e),!1))}toJSON(){let t={args:{}};return t.type=this.type,t.args.numCols=this._numCols,t.args.numRows=this._numRows,t.args.colGap=this._colGap,t.args.rowGap=this._rowGap,t.args.horzCellAlignment=this._cellHorzAlignment,t.args.vertCellAlignment=this._cellVertAlignment,t.left=this._left,t.top=this._top,t.args.dir=this._dir,t}clone(){return new q({numCols:this._numCols,numRows:this._numRows,dir:this._dir,colGap:this._colGap,rowGap:this._rowGap})}get cellBounds(){let t,e,i=this.group,s=this._colGap,n=this._rowGap;this._numRows?(e=this._numRows,t=Math.ceil(this.group.children.length/this._numRows)):this._numCols&&(t=this._numCols,e=Math.ceil(this.group.children.length/this._numCols));let r=i.children.map((t=>t.bounds));if(void 0===this._left){let t=r.map((t=>t.left)),e=r.map((t=>t.top));this._left=Math.min(...t),this._top=Math.min(...e)}let a=r.map((t=>t.width)),o=r.map((t=>t.height)),h=Math.max(...a),c=Math.max(...o),d=i.getInternalEncodings("x"),u=i.getInternalEncodings("y"),f=i.getInternalEncodings("width"),p=i.getInternalEncodings("height"),g=0;if(d.length>0){let t=d[d.length-1];h=t.scale.rangeExtent,g=t.scale.range[0],"point"===t.scale.type&&(h+=t.anyItem.bounds.width)}else f.length>0&&f[f.length-1]._rectNegativeValues&&(h=f[f.length-1].scale.rangeExtent,g=f[f.length-1].scale.range[0]);if(u.length>0){let t=u[u.length-1];c=t.scale.rangeExtent,"point"===t.scale.type&&(c+=t.anyItem.bounds.height)}else p.length>0&&p[p.length-1]._rectNegativeValues&&(c=p[p.length-1].scale.rangeExtent);let _=[],m=e*t;switch(this._dir[0]){case q.direction.Left2Right:switch(this._dir[1]){case q.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new l(this._left+(h+s)*(e%t)+g,this._top+(c+n)*Math.floor(e/t),h,c));break;case q.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new l(this._left+(h+s)*(e%t)+g,this._top+(this.numRows-1-Math.floor(e/t))*(c+n),h,c))}break;case q.direction.Right2Left:switch(this._dir[1]){case q.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new l(g+this._left+(t-1)*(h+s)-(h+s)*(e%t),this._top+(c+n)*Math.floor(e/t),h,c));break;case q.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new l(g+this._left+(t-1-e%t)*(h+s),this._top+(this.numRows-1-Math.floor(e/t))*(c+n),h,c))}break;case q.direction.Top2Bottom:switch(this._dir[1]){case q.direction.Left2Right:for(let t=0;t<m;t++)_.push(new l(g+this._left+(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),h,c));break;case q.direction.Right2Left:for(let t=0;t<m;t++)_.push(new l(g+this._left+(h+s)*(this.numCols-1)-(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),h,c))}break;case q.direction.Bottom2Top:switch(this._dir[1]){case q.direction.Left2Right:for(let t=0;t<m;t++)_.push(new l(g+this._left+(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),h,c));break;case q.direction.Right2Left:for(let t=0;t<m;t++)_.push(new l(g+this._left+(h+s)*(this.numCols-1)-(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),h,c))}}return _}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.cellBounds,e=this.group.getInternalEncodings("x"),i=this.group.getInternalEncodings("y"),s=this.group.getInternalEncodings("width"),n=this.group.getInternalEncodings("height");for(let s=0;s<this.group.children.length;s++){let n=this.group.children[s],r=t[s],a=r.x-n.bounds.x,o=r.y-n.bounds.y;n._doTranslate(a,o);let l=0,h=0;if(0==e.length)switch(this._cellHorzAlignment){case E.Left:l=r.left-n.bounds.left;break;case E.Center:l=r.x-n.bounds.x;break;case E.Right:l=r.right-n.bounds.right}if(0==i.length)switch(this._cellVertAlignment){case E.Top:h=r.top-n.bounds.top;break;case E.Middle:h=r.y-n.bounds.y;break;case E.Bottom:h=r.bottom-n.bounds.bottom}n._doTranslate(l,h)}if(e.length>0)for(let t of e)t._apply();else if(s.length>0){let t=s[s.length-1];t._rectNegativeValues&&t._apply()}if(i.length>0)for(let t of i)t._apply();else if(n.length>0){let t=n[n.length-1];t._rectNegativeValues&&t._apply()}this.group._updateBounds()}set rowGap(t){this._rowGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get rowGap(){return this._rowGap}set colGap(t){this._colGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get colGap(){return this._colGap}set numCols(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"columns for",this.group.children.length,"items in grid"):(this._numCols=t,this._numRows=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numRows(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"rows for",this.group.children.length,"items in grid"):(this._numRows=t,this._numCols=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}set vertCellAlignment(t){if(t!=E.Top&&t!=E.Bottom&&t!=E.Middle)throw W.UNKOWN_ALIGNMENT;this._cellVertAlignment=t,this.run()}get vertCellAlignment(){return this._cellVertAlignment}set horzCellAlignment(t){if(t!=E.Left&&t!=E.Center&&t!=E.Right)throw W.UNKOWN_ALIGNMENT;this._cellHorzAlignment=t,this.run()}get horzCellAlignment(){return this._cellHorzAlignment}}q.direction={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"};class H{constructor(t){this._stops=[],this.type=I.LinearGradient,this.id=this.type+_t[this.type]++,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 t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,i){this._stops.push({offset:t,color:e,opacity:i})}get stops(){return this._stops}}class J{constructor(t){if(this._dataScope=void 0,this._id=void 0,this.attrs={},this.styles={},this.staticProperties={},void 0!==t)for(let e in V)e in t&&(this.styles[e]=t[e])}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){if(!this._bounds)return!1;if(!this._bounds.contains(t,e))return!1;switch(this.type){case I.Rect:case I.PointText:return!0;case I.Circle:return Math.sqrt(Math.pow(t-this.x,2)+Math.pow(e-this.y,2))<=this.radius+this.strokeWidth;case I.Path:{let i=vt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),this.closed?i.isPointInPath(s,t,e):i.isPointInStroke(s,t,e)}case I.Line:{let i=vt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),i.isPointInStroke(s,t,e)}default:{let i=vt.getContext(),s=new Path2D(this.getSVGPathData());return i.isPointInPath(s,t,e)}}}toJSON(){let t={};t.type=this.type,t.id=this.id,this.classId&&(t.classId=this.classId),this._dataScope&&(t.dataScope=this._dataScope.toJSON()),t.args={};for(let e in this.attrs)t.args[e]=this.attrs[e];for(let e in this.styles)e.indexOf("Color")>0&&this.styles[e]instanceof H?t.args[e]=this.styles[e].toJSON():t.args[e]=this.styles[e];return t}getScene(){let t=this;for(;t;){if(t.type==I.Scene)return t;t=t.parent}}set dataScope(t){this._dataScope=t}get dataScope(){return this._dataScope}duplicate(){let t=this.getScene().mark(this.type);return this.copyPropertiesTo(t),t.classId=this.classId,this._dataScope&&(t._dataScope=this._dataScope.clone()),t}_doTranslate(t,e){}set visibility(t){this.styles.visibility=t}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity=t}}function Y(t){return t>=-1e-12&&t<=1e-12}class ${constructor(t,e){this.x=t,this.y=e}transform(t){return t?t._transformPoint(this):this}negate(){return new $(-this.x,-this.y)}subtract(t){return new $(this.x-t.x,this.y-t.y)}isZero(){return Y(this.x)&&Y(this.y)}isCollinear(t){let e=this.x,i=this.y,s=t.x,n=t.y;return Math.abs(e*n-i*s)<=1e-8*Math.sqrt((e*e+i*i)*(s*s+n*n))}}class Z{constructor(t,e,i){this.type="vertex",this._id=i,this.x=t.x,this.y=t.y,this.dataScope=void 0,this.parent=e,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 bounds(){switch(this.shape){case"rect":return new l(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new l(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new l(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}toJSON(){let t={};return t.type=this.type,t.id=this._id,t.x=this.x,t.y=this.y,this.dataScope&&(t.dataScope=this.dataScope.toJSON()),void 0!==this._polarAngle&&(t.polarAngle=this._polarAngle),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}static fromJSON(t,e){let i=new Z(t,e,t.id);return t.dataScope&&(i.dataScope=t.dataScope),"polarAngle"in t&&(i.polarAngle=t.polarAngle),i.shape=t.shape,i.width=t.width,i.height=t.height,i.radius=t.radius,i.fillColor=t.fillColor,i.opacity=t.opacity,i.strokeWidth=t.strokeWidth,i.strokeColor=t.strokeColor,i}_doTranslate(t,e){this.x+=t,this.y+=e}_clone(t){let e=new Z(new $(this.x,this.y),t,this._id);return this.dataScope&&(e.dataScope=this.dataScope.clone()),e.shape=this.shape,e.width=this.width,e.height=this.height,e.radius=this.radius,e.fillColor=this.fillColor,e.opacity=this.opacity,e.strokeWidth=this.strokeWidth,e.strokeColor=this.strokeColor,e}set polarAngle(t){this._polarAngle=t}get polarAngle(){return this._polarAngle}}Z.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class K{constructor(t,e,i,s){this.type="segment",this._id=s,this.vertex1=t,this.vertex2=e,this.dataScope=void 0,this.parent=i}get id(){return this.parent.id+"_s_"+this._id}_doTranslate(t,e){this.vertex1._doTranslate(t,e),this.vertex2._doTranslate(t,e)}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}}class X extends J{constructor(t){if(super(t),this.type="type"in t?t.type:I.Path,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none"),this.vertices=[],this.vertexCounter=0,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,void 0!==t){for(let e of Z.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&this._setVertices(t.vertices)}}toJSON(){let t=super.toJSON();if(t.type=this.type,t.id=this.id,this.type===I.Rect)t.args.width=this.width,t.args.height=this.height,t.args.top=this.top,t.args.left=this.left;else if(this.type===I.Circle)t.args.x=this.x,t.args.y=this.y,t.args.radius=this.radius;else if(this.type===I.Arc)t.args.x=this._x,t.args.y=this._y,t.args.innerRadius=this._innerRadius,t.args.outerRadius=this._outerRadius,t.args.startAngle=this._startAngle,t.args.endAngle=this._endAngle;else if(this.type===I.Pie)t.args.x=this._x,t.args.y=this._y,t.args.radius=this.radius,t.args.startAngle=this.startAngleDeg,t.args.endAngle=this.endAngleDeg;else{t.vertices=[];for(let e of this.vertices)t.vertices.push(e.toJSON());this.type===I.Polygon?(t.args.x=this._x,t.args.y=this._y,t.args.radius=this._radius):this.type===I.Area&&(t.args.baseline=this._baseline,t.args.orientation=this._orientation)}t.vertexCounter=this.vertexCounter,t.segmentCounter=this.segmentCounter,t.curveMode=this.curveMode,this._bounds&&(t.bounds=this._bounds.toJSON());for(let e of Z.styles)t.args[e]=this[e];return t}_setVertices(t){let e,i;this.vertices=[],this.segments=[];for(let s=0;s<t.length;s++)if(s!=t.length-1||t[s][0]!==t[0][0]||t[s][1]!==t[0][1]||this.type!==I.Path){i=new $(t[s][0],t[s][1]),e=new Z(i,this,this.vertexCounter++);for(let t of Z.styles)if(this[t]){let i=t.replace("vx","");e[i[0].toLowerCase()+i.slice(1)]=this[t]}this.vertices.push(e),s>0&&this.segments.push(new K(this.vertices[s-1],this.vertices[s],this,this.segmentCounter++))}let s=t[0],n=t[t.length-1];(s[0]===n[0]&&s[1]===n[1]||this.type===I.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new K(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of Z.styles)this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScope&&(t._dataScope=this._dataScope.clone()),t.closed=this.closed,t.curveMode=this.curveMode,t.vertices=[],t.segments=[];for(let e of this.vertices)t.vertices.push(e._clone(t));t.segmentCounter=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new K(t.vertices[e-1],t.vertices[e],t,t.segmentCounter++));t.closed&&t.segments.push(new K(t.vertices[t.vertices.length-1],t.vertices[0],t,t.segmentCounter++))}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}set strokeColor(t){this.styles.strokeColor=t}get strokeWidth(){return this.styles.strokeWidth}set strokeWidth(t){this.styles.strokeWidth=t}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash=t}_doTranslate(t,e){for(let i of this.vertices)i._doTranslate(t,e);this._updateBounds()}resize(t,e,i,s){let n=this.bounds,r=0===n.width?1:n.width,a=0===n.height?1:n.height;if("right"===i)for(let e of this.vertices)e.x=n.right-t/r*(n.right-e.x);else for(let e of this.vertices)e.x=n.left+t/r*(e.x-n.left);if("top"===s)for(let t of this.vertices)t.y=n.top+e/a*(t.y-n.top);else for(let t of this.vertices)t.y=n.bottom-e/a*(n.bottom-t.y);this._updateBounds()}_updateBounds(){let t=this.vertices.map((t=>t.x)),e=this.vertices.map((t=>t.y)),i=Math.min(...t),s=Math.min(...e),n=Math.max(...t),r=Math.max(...e);this._bounds=new l(i,s,n-i,r-s)}addVertex(t,e,i){let s=new Z(new $(t,e),this,this.vertexCounter++);this.vertices.splice(i,0,s)}sortVertices(t,e){this.vertices.sort(((e,i)=>e[t]-i[t])),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}sortVerticesByData(t,e,i){let s;s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1,this.vertices.sort(s),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}getSVGPathData(){let t=r.path(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t of this.vertices)e.point(t.x,t.y);return this.closed&&e.point(this.vertices[0].x,this.vertices[0].y),e.lineEnd(),t._}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(t){switch(t){case u:return r.curveNatural;case f:return r.curveBasis;case p:return r.curveBumpX;case g:return r.curveBumpY;case _:return r.curveLinear;case m:return r.curveStep;case y:return r.curveCatmullRom;case v:return r.curveCardinal;default:return r.curveLinear}}get vxShape(){return this._vxShape}set vxShape(t){this._vxShape=t;for(let e of this.vertices)e.shape=t}get vxWidth(){return this._vxWidth}set vxWidth(t){this._vxWidth=t;for(let e of this.vertices)e.width=t}get vxHeight(){return this._vxHeight}set vxHeight(t){this._vxHeight=t;for(let e of this.vertices)e.height=t}get vxRadius(){return this._vxRadius}set vxRadius(t){this._vxRadius=t;for(let e of this.vertices)e.radius=t}get vxFillColor(){return this._vxFillColor}set vxFillColor(t){this._vxFillColor=t;for(let e of this.vertices)e.fillColor=t}get vxStrokeColor(){return this._vxStrokeColor}set vxStrokeColor(t){this._vxStrokeColor=t;for(let e of this.vertices)e.strokeColor=t}get vxStrokeWidth(){return this._vxStrokeWidth}set vxStrokeWidth(t){this._vxStrokeWidth=t;for(let e of this.vertices)e.strokeWidth=t}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}}function Q(t,e){if("field"in e){if(!t.dataScope)return!1;let i=e.field;if("value"in e)return t.dataScope.getFieldValue(i)===e.value;if("interval"in e){let s=t.dataScope.getFieldValue(i);return s>=e.interval[0]&&s<=e.interval[1]}return"values"in e?e.values.indexOf(t.dataScope.getFieldValue(i))>=0:t.dataScope.hasField(i)}if("channel"in e){let i=e.channel;if("value"in e)return t[i]===e.value;if("interval"in e)return t[i]>=e.interval[0]&&t[i]<=e.interval[1];if("values"in e)return e.values.indexOf(t[i])>=0}else{if("type"in e)return t.type===e.type;if("id"in e)return t.id===e.id;if("classId"in e)return t.classId===e.classId;if("fields"in e){if(!t.dataScope)return!1;let i=e.fields[0],s=e.fields[1],n=t.dataScope.getFieldValue(i),r=t.dataScope.getFieldValue(s);switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}}}return!1}function tt(t,e){let i=[];return et(t,e,i),i}function et(t,e,i){if(t&&"axis"!=t.type&&"legend"!=t.type&&"gridlines"!=t.type)if(it(t,e)&&i.push(t),t.vertices)for(let s of t.vertices.concat(t.segments))it(s,e)&&i.push(s);else if(t.children&&t.children.length>0)for(let s of t.children)et(s,e,i)}function it(t,e){for(let i of e)if(!Q(t,i))return!1;return!0}function st(t,e){return"vertex"==t.type?function(t,e){if(!t.classId){if(t.dataScope){let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=tt(e,[{classId:i.classId}]),n=[];if(i.type===I.Area){let e=i.vertices.indexOf(t)<i.vertices.length/2;for(let t of s){let i=e?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);n=n.concat(i.filter((t=>t.dataScope)))}}else for(let t of s)n=n.concat(t.vertices.filter((t=>t.dataScope)));return n}{let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=i.vertices.indexOf(t),n=tt(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.vertices[s]);return r}}}(t,e):"segment"==t.type?function(t,e){if(t.dataScope){let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=tt(e,[{classId:i.classId}]),n=[];for(let t of s)n=n.concat(t.segments);return n}{let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=i.segments.indexOf(t),n=tt(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.segments[s]);return r}}(t,e):t.classId?tt(e,[{classId:t.classId}]):[]}function nt(t,e){let i=t.parent;for(;i&&i.type!=I.Scene;){if(i.layout&&(!e||e&&i.layout.type===e))return i.layout;i=i.parent}}function rt(t){let e=t,i=t.parent;for(;i&&i.type!=I.Scene;){if(i.layout){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function at(t){let e=t,i=t.parent;for(;i&&i.type!=I.Scene;){if(i.layout&&i.layout.type==b.Grid){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function ot(t,e){let i,s=t.parent;for(;s&&s.type!==I.Scene;)s.layout&&(!e||e&&s.layout.type===e)&&(i=s.layout),s=s.parent;return i}function lt(t){if(t.classId)return t.classId;if("vertex"==t.type&&t.dataScope){if(t.parent.type===I.Area){let e=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;return t.parent.classId+"_v_"+(e?0:t.parent.vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v_"+t.parent.vertices.indexOf(t):"segment"==t.type&&t.dataScope?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s_"+t.parent.segments.indexOf(t):null}function ht(t){let e=[];for(let i of t)i.parent&&e.indexOf(i.parent)<0&&e.push(i.parent);return e}function ct(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e.push(i),e=e.concat(ct(i));return e}function dt(t){let e=[];if(pt(t))e.push(t);else if(t.children&&t.children.length>0&&!ft(t))for(let i of t.children)e=e.concat(dt(i));return e}function ut(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e=e.concat(ut(i));else e.push(t);return e}function ft(t){return t.type===I.Axis||t.type===I.Legend||t.type===I.Gridlines}function pt(t){return t instanceof J}function gt(t){return t instanceof X}const _t={area:0,rect:0,circle:0,pie:0,line:0,path:0,ring:0,arc:0,image:0,pointText:0,collection:0,group:0,scene:0,axis:0,glyph:0,legend:0,polygon:0,gridlines:0,LinearGradient:0,link:0,scale:0,datatable:0};function mt(t,e){if(e.getEncodingByItem(t,"x"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==b.Grid&&e.numCols>1)return!1}return!t.parent||t.parent.type==I.Scene||mt(t.parent,e)}function yt(t,e){if(e.getEncodingByItem(t,"y"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==b.Grid&&e.numRows>1)return!1}return!t.parent||t.parent.type==I.Scene||yt(t.parent,e)}var vt={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var t=this.getCanvas();return t?t.getContext("2d"):null}},bt={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}};function xt(t){let e=t.parent;return e.type==I.Scene?t:xt(e)}function wt(t){let e=t.parent;return t.type==I.Collection?e.type==I.Collection?wt(e):t:e.type!=I.Scene?wt(e):void 0}function kt(t,e,i,s){return[i*Math.cos(Ct(s))+t,e-i*Math.sin(Ct(s))]}function St(t,e,i,s){let n=function(t){return 180*t/Math.PI}(Math.atan2(s-e,t-i));n=Math.round(10*n+Number.EPSILON)/10,n<0&&(n+=360);let r=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-s,2));return r=Math.round(10*r+Number.EPSILON)/10,[n,r]}function Ct(t){return t*Math.PI/180}function Et(t){let e=t.vertices.length;for(let i=0;i<t.vertices.length/2;i++){let s=i,n=e-i-1,r=t.vertices[s],a=t.vertices[n];if(r.x!=a.x||r.y!=a.y)return r.x==a.x?"horizontal":"vertical"}}class At{constructor(){this.children=[],this._dataScope=void 0,this._layout=void 0,this.type=I.Group,this._id=this.type+_t[this.type]++}get id(){return this._id}set id(t){this.type!==I.Scene&&this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){let i=this.getSVGPathData();if(""!==i){let s=vt.getContext(),n=new Path2D(i);return s.lineWidth=Math.max(this.strokeWidth,2.5),s.stroke(n),s.isPointInPath(n,t,e)}return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}getSVGPathData(){let t="";for(let e of this.children)if(e.getSVGPathData)t+=e.getSVGPathData();else if(e.bounds){let i=e.bounds;t+=["M",i.left,i.top].join(" "),t+=["L",i.right,i.top].join(" "),t+=["L",i.right,i.bottom].join(" "),t+=["L",i.left,i.bottom,"Z"].join(" ")}return t}toJSON(){let t={};if(t.type=this.type,t.id=this.id,this._dataScope&&(t.dataScope=this._dataScope.toJSON()),this.classId&&(t.classId=this.classId),this._layout&&(t.layout=this._layout.toJSON()),this._bounds&&(t.bounds=this._bounds.toJSON()),t.children=[],this.children.length>0&&this.type!=I.Axis)for(let e of this.children)t.children.push(e.toJSON());return this.childrenOrder&&(t.childrenOrder=this.childrenOrder),t}addChild(t){this.children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this.children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this.children=[]}getScene(){let t=this;for(;t;){if(t.type==I.Scene)return t;t=t.parent}}get dataScope(){return this._dataScope}set dataScope(t){if(this._dataScope=t,void 0===t)for(let e of this.children)e.dataScope=t;else for(let e of this.children)e.dataScope?e.dataScope=e.dataScope.merge(t):e.dataScope=t}_doTranslate(t,e){for(let i of this.children)i._doTranslate(t,e);this._updateBounds(),this._layout&&(void 0!==this._layout._left&&(this._layout._left+=t),void 0!==this._layout._top&&(this._layout._top+=e),void 0!==this._layout.x&&(this._layout.x+=t),void 0!==this._layout.y&&(this._layout.y+=e)),this._updateBounds()}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],i=this.getScene(),s=Object.keys(i.encodings),n=[];for(;e&&(e.classId&&n.indexOf(e.classId)<0&&n.push(e.classId),e.children);)e=e.children[0];let r=[];for(let e of s){let s=e.split("_");for(let a of n)s[0]==a&&i.encodings[e][t]&&r.push(i.encodings[e][t])}return r}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t)t.group=this,this._layout.run();else{let t=this.getInternalEncodings("x"),e=this.getInternalEncodings("y");for(let e of t)e._map(),e._apply();for(let t of e)t._map(),t._apply()}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){if(this.children.length>0){this._bounds=this.children[0].bounds.clone();for(let t=1;t<this.children.length;t++)"hidden"!=this.children[t].visibility&&(this._bounds=this._bounds.union(this.children[t].bounds));if(this._layout&&"grid"==this._layout.type){let t=this._layout.cellBounds;for(let e=0;e<t.length;e++)this._bounds=this._bounds.union(t[e])}}else this._bounds=new l(0,0,0,0)}sortChildrenByData(t,e,i){let s;switch(this.children[0].dataScope.getFieldType(t)){case O.Date:break;case O.Number:case O.Integer:s=(e,i)=>e.dataScope.aggregateNumericalField(t)-i.dataScope.aggregateNumericalField(t);break;case O.String:s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1}this.children.sort(s),e&&this.children.reverse(),this.layout&&this.layout.run(),this._childrenOrder={field:t,direction:e?"desc":"asc",ranking:i}}sortChildren(t,e){let i;switch(t){case"x":case"y":case"width":case"height":i=(e,i)=>e.bounds[t]-i.bounds[t];break;default:i=(e,i)=>e[t]-i[t]}this.children.sort(i),e&&this.children.reverse(),this.layout&&this.layout.run(),this.childrenOrder={channel:t,reverse:e}}set visibility(t){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}get visibility(){return this._visibility?this._visibility:"visible"}}function Tt(t){return[...new Set(t)]}function It(t,e){if(e.hasField(t))return!0;if(e.tree&&e.tree.nodeTable.hasField(t.split(".")[1]))return!0;throw new Error(W.FIELD_NONEXISTENT+", field: "+t+", data table: "+e.name)}function Ot(t){return t<0?t+360:t>360?t-360:t}class Mt{constructor(t){this._field2value={},this._dt=t,this._tuples=this._dt.data}toJSON(){let t={};return t.dt=this._dt.id,t.f2v=Object.assign({},this._field2value),t}isFullTable(){return 0===Object.keys(this._field2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get fields(){return Object.keys(this._field2value)}get dataTable(){return this._dt}get filters(){return this._field2value}merge(t){let e=new Mt(this._dt);for(let i in t._field2value)e=e.cross(i,t._field2value[i]);for(let t in this._field2value)e=e.cross(t,this._field2value[t]);return e}cross(t,e){let i=this.clone();return i._field2value[t]=e,i._updateTuples(t,e),i}clone(){let t=new Mt(this._dt);return t._field2value=Object.assign({},this._field2value),t._tuples=this._tuples.map((t=>t)),t}getFieldValue(t){let e=this._tuples.map((e=>e[t]));return e=[...new Set(e)],e.length,e[0]}getUniqueFieldValues(t){let e=this._tuples.map((e=>e[t]));return[...new Set(e)]}hasField(t){return t in this._field2value}getFieldType(t){return this._dt.getFieldType(t)}aggregateNumericalField(t,e){let i=this._tuples.map((e=>e[t]));switch(e){case M:return Math.max(...i);case R:return Math.min(...i);case N:case L:return r.mean(i);case B:return r.median(i);case F:return i.length;case D:return r.quantile(i,.25);case j:return r.quantile(i,.75);case P:default:return r.sum(i)}}_updateTuples(t,e){this._tuples=this._tuples.filter((i=>i[t]==e))}}function Rt(t,e,i,s,n){let r=n?s.transformField(i,n):i,a=s.getFieldType(r);if(a!=O.String&&a!=O.Date&&a!=O.Integer)throw new Error(W.REPEAT_BY_NONCAT+": "+r+" is "+a);if(!_d(e))throw new Error(W.COMPNT_NON_REPEATABLE);return function(t,e,i,s){let n=s.getFieldSummary(i).unique.map((t=>e.dataScope?e.dataScope.cross(i,t):new Mt(s).cross(i,t)));n=n.filter((t=>!t.isEmpty()));let r=t.collection();r.dataScope=e.dataScope?e.dataScope.clone():new Mt(s),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}return r.children.forEach(((t,e)=>t.dataScope=n[e])),t._reapplySizeBindings(e),r}(t,e,r,s)}class Nt extends U{constructor(t){super(t),this.type=b.Stack,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:E.Left,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:E.Bottom,this._gap="gap"in t?t.gap:0}toJSON(){let t={args:{}};return t.type=this.type,t.args.orientation=this._orientation,t.args.direction=this._direction,t.args.left=this._left,t.args.top=this._top,t.args.gap=this._gap,t.args.horzCellAlignment=this._horzCellAlignment,t.args.vertCellAlignment=this._vertCellAlignment,t}clone(){let t=new Nt({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}_stackAreasVert(){let t=this.group.children,e=this.group.bounds,i=this._vertCellAlignment===E.Top?e.top:e.bottom,s=this._vertCellAlignment===E.Top?1:-1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],l=Math.abs(a.y-o.y),h=i+r[t]*s,c=i+(r[t]+l)*s;a._doTranslate(0,h-a.y),o._doTranslate(0,c-o.y),r[t]+=l}e._updateBounds()}if(this.vertCellAlignment===E.Middle)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.middle+r[t]/2;s._doTranslate(0,o-e.bottom),a._doTranslate(0,o-e.bottom)}i._updateBounds()}this.group._updateBounds()}_stackAreasHorz(){let t=this.group.children,e=this.group.bounds,i=this._horzCellAlignment===E.Right?e.right:e.left,s=this._horzCellAlignment===E.Right?-1:1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],l=Math.abs(a.x-o.x),h=i+r[t]*s,c=i+(r[t]+l)*s;a._doTranslate(0,h-a.y),o._doTranslate(0,c-o.y),r[t]+=l}e._updateBounds()}if(this._horzCellAlignment===E.Center)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.center-r[t]/2;s._doTranslate(0,o-e.left),a._doTranslate(0,o-e.left)}i._updateBounds()}this.group._updateBounds()}_stackAreas(){this.group.children[0].orientation===w?this._stackAreasVert():this._stackAreasHorz()}_stackArcs(){let t=this.group,e=this.startAngle?this.startAngle:90;if((this._direction?this._direction:C.Clockwise)===C.Clockwise)for(let i of t.children){let t=Ot(e-i.angle);i.adjustAngle(t,e),e=t}else for(let i of t.children){let t=Ot(e+i.angle);i.adjustAngle(e,t),e=t}}_stackRects(){let t=this.group.getScene(),e=this.group,i=this._orientation,s=e.children.map((t=>t.bounds)),n=s.map((t=>t.left)),r=s.map((t=>t.top)),a=s.map((t=>t.width)),o=s.map((t=>t.height)),l=null==this._left?Math.min(...n):this._left,h=null==this._top?Math.min(...r):this._top,c=Math.max(...a),d=Math.max(...o);if(i==x){let i=l+c/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=i-n.bounds.x,a=h+n.bounds.height/2-n.bounds.y;h+=n.bounds.height+this._gap,n._doTranslate(r,a);let o=0,d=0;if(!t.getEncodingByItem(n,"x"))switch(this._horzCellAlignment){case E.Left:o=l-n.bounds.left;break;case E.Center:o=l+c/2-n.bounds.x;break;case E.Right:o=l+c-n.bounds.right}n._doTranslate(o,d)}}else{let i=h+d/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=l+n.bounds.width/2-n.bounds.x,a=i-n.bounds.y;l+=n.bounds.width+this._gap,n._doTranslate(r,a);let o=0,c=0;if(!t.getEncodingByItem(n,"y"))switch(this._vertCellAlignment){case E.Top:c=h-n.bounds.top;break;case E.Middle:c=h+d/2-n.bounds.y;break;case E.Bottom:c=h+d-n.bounds.bottom}n._doTranslate(o,c)}}this.group._updateBounds()}run(){null!=this.group&&this.group.children&&0!==this.group.children.length&&("area"==this.group.children[0].type?this._stackAreas():this.group.children[0].type==I.Arc||this.group.children[0].type==I.Pie?this._stackArcs():this._stackRects())}set vertCellAlignment(t){if(t!=E.Top&&t!=E.Bottom&&t!=E.Middle)throw W.UNKOWN_ALIGNMENT;this._vertCellAlignment=t,this.run()}get vertCellAlignment(){return this._vertCellAlignment}set horzCellAlignment(t){if(t!=E.Left&&t!=E.Center&&t!=E.Right)throw W.UNKOWN_ALIGNMENT;this._horzCellAlignment=t,this.run()}get horzCellAlignment(){return this._horzCellAlignment}get cellBounds(){return this.group.children.map((t=>t.bounds))}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}}function Bt(t,e,i,s,n,r){let a=r?n.transformField(s,r):s,o=n.getFieldType(a);if(o!=O.String&&o!=O.Date)throw new Error(W.PARTITION_BY_NONCAT+": "+a+" is "+o);if(!md(e))throw new Error(W.COMPNT_NON_PARTITIONABLE);switch(e.type){case I.Line:return function(t,e,i,s){let n,r,a=st(e,t),o=s.getFieldSummary(i).unique.map((t=>new Mt(s).cross(i,t))),l={},h=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>h&&(h=e.length),l[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope,i.parent.addChild(s);let a=l[i.id],o=i.vertices[0].x,c=i.vertices[0].y,d=i.vertices[1].x,u=i.vertices[1].y;i.classId=e.id,i.vertices[0].x=o,i.vertices[0].y=c,i.vertices[1].x=o+(d-o)/h,i.vertices[1].y=c+(u-c)/h,i.dataScope=a[0],s.addChild(i);for(let t=1;t<a.length;t++){let e=i.duplicate();e.vertices[0].x=o+(d-o)*t/h,e.vertices[0].y=c+(u-c)*t/h,e.vertices[1].x=o+(d-o)*(t+1)/h,e.vertices[1].y=c+(u-c)*(t+1)/h,e.dataScope=a[t],s.addChild(e)}i==e&&(n=s)}return n}(t,e,a,n);case I.Circle:return function(t,e,i,s,n){let r,a,o=i||k,l=st(e,t);if(o==k)l.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/h,f=90;for(let s=0;s<h;s++){let n=t.mark("pie",{radius:i.radius,x:i.x,y:i.y,startAngle:Ot(f-u*(s+1)),endAngle:Ot(f-u*s),strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}c.layout=ud("stack",{direction:C.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)}));else{if(o!=S)throw W.UNKNOWN_Orientation+": "+o;l.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=i.radius/h;for(let s=0;s<h;s++){let n=t.mark("ring",{x:i.x,y:i.y,innerRadius:s*u,outerRadius:(s+1)*u,strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)}))}return r}(t,e,i,a,n);case I.Rect:return function(t,e,i,s,n){let r,a=st(e,t),o=i||w;if(o!=w&&o!=x)throw W.UNKNOWN_Orientation+": "+o;let l,h=n.getFieldSummary(s).unique.map((t=>new Mt(n).cross(s,t))),c={},d=0;for(let t of a){let e=h;t.dataScope&&(e=h.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>d&&(d=e.length),c[t.id]=e}for(let i of a){let s=t.collection();null==l&&(l=s.id),s.classId=l,s.dataScope=i.dataScope?i.dataScope:new Mt(n),i.parent.addChild(s);let a=c[i.id],h=i.bounds,u=h.left,f=h.top,p=o==w?h.width/d:h.width,g=o==w?h.height:h.height/d;i.classId=e.id,i.resize(p,g),i.dataScope=a[0],s.addChild(i);for(let t=1;t<a.length;t++){let e=i.duplicate();e.resize(p,g),e.dataScope=a[t],s.addChild(e)}s.layout=new Nt({orientation:o,left:u,top:f}),i==e&&(r=s)}t._reapplySizeBindings(r);let u=t.getRelatedAxes(e);for(let i of u)i._item.classId===e.classId&&(i._item=r,i._items=st(r,t));return r}(t,e,i,a,n);case I.Area:return function(t,e,i,s,n){let r,a=st(e,t),o=a[0];if(4==o.vertices.length&&i==w&&o.vertices[0].x!==o.vertices[1].x)for(let t of a){let e=t.vertices[1];t.vertices[1]=t.vertices[3],t.vertices[3]=e}let l,h=n.getFieldSummary(s).unique.map((t=>new Mt(n).cross(s,t)));for(let s of a){let a=t.collection();null==l&&(l=a.id),a.classId=l,a.dataScope=s.dataScope?s.dataScope:new Mt(n),s.parent.addChild(a);let o=s.left,c=s.top,d=i==w?s.width/h.length:s.width,u=i==w?s.height:s.height/h.length;s.classId=e.id,s.resizeArea(d,u),a.addChild(s);for(let t=1;t<h.length;t++){let t=s.duplicate();t.resizeArea(d,u),a.addChild(t)}for(let t=0;t<a.children.length;t++){let e=a.children[t];e.dataScope?e.dataScope=e.dataScope.merge(h[t]):e.dataScope=h[t];for(let t of e.vertices)t.dataScope?t.dataScope=e.dataScope.merge(t.dataScope):t.dataScope=e.dataScope}a.layout=new Nt({orientation:i,left:o,top:c}),s==e&&(r=a)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case I.Ring:return function(t,e,i,s,n){let r,a,o=i||k,l=st(e,t);if(o==k)return l.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/h,f=90;for(let s=0;s<h;s++){let n=t.mark("arc",{innerRadius:i.innerRadius,outerRadius:i.outerRadius,x:i.x,y:i.y,startAngle:Ot(f-u*(s+1)),endAngle:Ot(f-u*s),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}c.layout=ud("stack",{direction:C.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw W.UNKNOWN_Orientation+": "+o}(t,e,i,a,n);case I.Pie:case I.Arc:return function(t,e,i,s,n){let r,a,o=i||S,l=st(e,t);if(o==S)return l.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent;for(let s=0;s<h;s++){let n=t.mark("arc",{innerRadius:s*i.outerRadius/h,outerRadius:(s+1)*i.outerRadius/h,x:i.x,y:i.y,startAngle:i.startAngle,endAngle:i.endAngle,strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw W.UNKNOWN_Orientation+": "+o}(t,e,i,a,n)}}function Pt(t,e,i,s,n,r,a,o){let l=r?n.transformField(s,r):s,h=n.getFieldType(l);if(h!=O.String&&h!=O.Date&&h!=O.Number)throw new Error(W.DENSIFY_BY_NONCAT+": "+l+" is "+h);if(!yd(e))throw new Error(W.COMPNT_NON_DENSIFIABLE);switch(e.type){case I.Line:return function(t,e,i,s){let n,r=st(e,t);for(let a of r){let r=a.dataScope?a.dataScope:new Mt(s),o=s.getFieldSummary(i).unique.map((t=>r.cross(i,t)));o=o.filter((t=>!t.isEmpty()));let l=Object.assign({},a.styles);for(let t of Z.styles)a[t]&&(l[t]=a[t]);let h=a.vertices[0].x,c=a.vertices[0].y,d=[],u=a.vertices[1].x-h,f=a.vertices[1].y-c;for(let t=0;t<o.length;t++)d.push([h+t*u/(o.length-1),c+t*f/(o.length-1)]);l.vertices=d;let p=t.mark("path",l);p.classId=e.id,p.dataScope=r;let g=a.parent;g.addChild(p),g.removeChild(a);for(let[t,e]of p.vertices.entries())e.dataScope?e.dataScope=e.dataScope.merge(o[t]):e.dataScope=o[t];a==e&&(n=p)}return n}(t,e,l,n);case I.Circle:return function(t,e,i,s,n,r){let a;return st(e,t).forEach((o=>{let l=o.dataScope?o.dataScope:new Mt(s),h=s.getFieldSummary(i).unique.map((t=>l.cross(i,t)));h=h.filter((t=>!t.isEmpty()));let c=h.length;if(c<3)throw Error(W.INSUFFICIENT_DATA_SCOPES);let d=360/c,u=[],f=[],p="clockwise"==r?-1:1;for(let t=0;t<h.length;t++){let e=n+p*t*d;f[t]=e;let i=kt(o.x,o.y,o.radius,f[t]);u.push(i)}let g=t.mark("polygon",{x:o.x,y:o.y,radius:o.radius,vertices:u});g.dataScope=l,g.styles=Object.assign({},o.styles);for(let t of Z.styles)o[t]&&(g[t]=o[t]);let _=o.parent;_.addChild(g),_.removeChild(o);for(let[t,e]of g.vertices.entries())e.polarAngle=f[t],e.dataScope?e.dataScope=e.dataScope.merge(h[t]):e.dataScope=h[t];o==e&&(a=g)})),a}(t,e,l,n,a,o);case I.Rect:case I.Area:return function(t,e,i,s,n){let r,a=st(e,t);for(let o of a){let a=n.getFieldType(s),l=o.dataScope?o.dataScope:new Mt(n),h=n.getFieldSummary(s).unique.map((t=>l.cross(s,t)));h=a==O.Number?h:h.filter((t=>!t.isEmpty())),a!=O.Number&&a!=O.Date||h.sort(((t,e)=>t._field2value[s]>e._field2value[s]?1:-1));let c=Object.assign({},o.styles),d=o.vertices[0].x,u=o.vertices[0].y,f=o.vertices[o.vertices.length-2].x,p=o.vertices[o.vertices.length-2].y,g=[],_=f-d,m=p-u;for(let t=0;t<h.length;t++)g.push(i==x?[f,u+(h.length-1-t)*m/(h.length-1)]:[d+t*_/(h.length-1),u]);for(let t=0;t<h.length;t++)g.push(i==x?[d,u+t*m/(h.length-1)]:[d+(h.length-1-t)*_/(h.length-1),p]);c.vertices=g;let y=t.mark("area",c);y.classId="area"==o.type?o.classId:"area"+o.classId.substring(9),y.dataScope=l,y.orientation=i,y.baseline=i===w?E.Bottom:E.Left;let v=o.parent;v.addChild(y),v.removeChild(o);for(let[t,e]of y.vertices.entries())t>=h.length?e.dataScope=l.merge(h[2*h.length-1-t]):e.dataScope=l.merge(h[t]);o==e&&(r=y)}return r}(t,e,i,l,n)}}class Ft extends X{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}set height(t){this.resize(this.width,t)}set width(t){this.resize(t,this.height)}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(t,e,i,s){"right"===i?(this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x),"top"===s?(this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y),this._updateBounds()}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 Lt extends X{constructor(t){super(t),this.attrs.x="x"in t?t.x:0,this.attrs.y="y"in t?t.y:0,this.attrs.radius="radius"in t?t.radius:100}get radius(){return this.attrs.radius}get x(){return this.attrs.x}get y(){return this.attrs.y}get area(){return Math.PI*Math.pow(this.radius,2)}set x(t){this.attrs.x=t,this._updateBounds()}set y(t){this.attrs.y=t,this._updateBounds()}set radius(t){this.attrs.radius=t,this._updateBounds()}resize(t,e,i,s){let n=Math.min(t,e)/2,r=n-this.attrs.radius;this.attrs.radius=n,"right"==i?this.attrs.x-=r:this.attrs.x+=r,"top"==s?this.attrs.y+=r:this.attrs.y-=r,this._updateBounds()}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){this._bounds=new l(this.attrs.x-this.attrs.radius,this.attrs.y-this.attrs.radius,2*this.attrs.radius,2*this.attrs.radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t.attrs.x=this.attrs.x,t.attrs.y=this.attrs.y,t.attrs.radius=this.attrs.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(" ")}}function Dt(t){return t._query=function(){this.data=[];let t=this.field,e=this.items,i=this.aggregator;switch(this.datatable.getFieldType(t)){case O.Boolean:break;case O.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case O.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,i)))}},t._map=function(){let t,e=this.items,i=this.data,s=this.channel;if(t=dd(this.scaleType),null==this.data.find((t=>t<0))||"width"!=s&&"height"!=s||0!=e[0].type.indexOf("rect")){let n,r;t.domain=[0,Math.max(...i)],"radius"==s||"outerRadius"==s||"innerRadius"==s?(n=0,r=Math.max(...e.map((t=>t[s]))),r<20&&(r=20)):"area"==s?(n=0,r=Math.max(...e.map((t=>t.bounds.width*t.bounds.height))),r<400&&(r=400)):"fontSize"==s?(n=2,r=Math.max(...e.map((t=>parseFloat(t.styles.fontSize))))):"strokeWidth"==s?(n=1,r=Math.max(...e.map((t=>parseFloat(t.styles.strokeWidth)))),r==n&&(r=n+5)):(n=0,r=Math.max(...e.map((t=>t.bounds[s])))),this.rangeExtent&&(r=n+this.rangeExtent),this.range&&(n=this.range[0],r=this.range[1]),t._setRange([n,r])}else this._rectNegativeValues=!0,t.domain=[Math.min(...i),Math.max(...i)],"width"==s?t._setRange([0,Math.max(...e.map((t=>t.width)))]):t._setRange([0,Math.max(...e.map((t=>t.height)))]);this.scale||(this.scale=t),this.scale._addEncoding(this)},t._apply=function(){if("radius"==this.channel||"outerRadius"==this.channel||"innerRadius"==this.channel){for(let t=0;t<this.items.length;t++){this.items[t][this.channel]=this.scale.map(this.data[t])}this.scene._relayoutAncestors(this.anyItem,this.items)}else if(this._rectNegativeValues){if("width"==this.channel){let t=Math.min(...this.items.map((t=>t.bounds.left)));for(let e=0;e<this.items.length;e++){let i,s=this.items[e],n=s.leftSegment.vertex1.x,r=s.rightSegment.vertex1.x;i=s.parent&&s.parent.type==I.Collection?s.parent.bounds.left:t,s.rightSegment._doTranslate(i+this.scale.map(this.data[e])-r,0),s.leftSegment._doTranslate(i+this.scale.map(0)-n,0),s._updateBounds()}}else if("height"==this.channel){let t=Math.min(...this.items.map((t=>t.bounds.top)))+this.scale.rangeExtent;for(let e=0;e<this.items.length;e++){let i,s=this.items[e],n=s.topSegment.vertex1.y,r=s.bottomSegment.vertex1.y;if(s.parent&&s.parent.type===I.Collection){let t=s.parent.parent;if(t.type===I.Collection&&t.layout&&t.layout.type===b.Grid){let e=t.children.indexOf(s.parent);i=t.layout.cellBounds[e].bottom}else i=s.parent.bounds.bottom}else i=t;s.topSegment._doTranslate(0,i-this.scale.map(this.data[e])-n),s.bottomSegment._doTranslate(0,i-this.scale.map(0)-r),s._updateBounds()}}}else if("area"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=Math.sqrt(this.scale.map(this.data[t]));e.resize(i,i)}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("fontSize"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.fontSize=i+"px"}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("strokeWidth"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.strokeWidth=i}this.scene._relayoutAncestors(this.anyItem,this.items)}else{let t="left",e="bottom";if(this.anyItem.parent&&this.anyItem.parent.type==I.Glyph){let i=this.anyItem.parent.children;1==Tt(i.map((t=>t.bounds.right))).length&&(t="right"),1==Tt(i.map((t=>t.bounds.top))).length&&(e="top")}if(this.anyItem.type===I.Collection&&this.anyItem.layout&&this.anyItem.layout[this.channel])for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.layout[this.channel]=i}else for(let i=0;i<this.items.length;i++){let s=this.items[i],n=this.scale.map(this.data[i]),r="width"==this.channel?n:s.bounds.width,a="height"==this.channel?n:s.bounds.height;s.resize(r,a,t,e)}this.scene._relayoutAncestors(this.anyItem,this.items)}},t.run(),t}function jt(t){return t._query=function(){this.data=[],this.areas=st(this.items[0],this.scene);let t=this.areas.length;this.areaNum=t,this._vertices=[],this.indicator=[];for(let t of this.areas)for(let e=0;e<t.vertices.length;e++)this._vertices.push(t.vertices[e]),e<t.vertices.length/2?this.indicator.push(1):this.indicator.push(0);let e=this.field,i=this._vertices,s="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?i.map((t=>t.dataScope)):i.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(e)){case O.Boolean:break;case O.Date:this.data=s.map((t=>t.getFieldValue(e)));break;case O.String:this.data=s.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)));break;default:"x"==this.channel||"y"==this.channel?this.data=s.map((t=>t._field2value[e])):this.data=s.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)))}},t._map=function(){let t,e,i;switch(this.datatable.getFieldType(this.field)){case O.Boolean:break;case O.Date:t=dd("time"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=[e,i];break;case O.String:t=dd("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=this._includeZero||e<0?[0,i]:[e,i];break;default:t=dd("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=e<0?[0,i]:[e,i]}let s,n=Et(this.areas[0]),r=nt(this.anyItem);if(r){let t=r.cellBounds;s="width"==this.channel||"height"==this.channel?n==x?t[0].width:t[0].height:n==x?t[0].height:t[0].width}else if("width"==this.channel||"x"==this.channel){let t=this._vertices.map((t=>t.x));s=Math.max(...t)-Math.min(...t)}else{let t=this._vertices.map((t=>t.y));s=Math.max(...t)-Math.min(...t)}e<0?(t._scale.domain([e,i]),t._setRange([0,s])):t._setRange([0,s]),this.scale?this.scale._merge(t):this.scale=t,this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);let i=this.areas[0].orientation;if("width"===e||"height"===e){if(nt(this.areas[0])){let t=0,e=this.areas.map((t=>rt(t))),s=this.areas.map((t=>nt(t)));for(let[n,r]of this.areas.entries()){let a=e[n],o=s[n];for(let e=0;e<r.vertices.length;e++){let s,n,l=this._vertices[e+t];if(i===w)if(s=0,o.type===b.Stack)n=a.bottom-this.scale.map(this.data[e+t])-l.y;else if(o.type===b.Grid){switch(r.baseline){case"top":n=a.top+this.scale.map(this.data[e+t])-l.y;break;case"bottom":n=a.bottom-this.scale.map(this.data[e+t])-l.y;break;case"middle":{let i=r.vertices.length-1-e,s=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));n=this.indicator[e+t]?a.middle-s/2-l.y:a.middle+s/2-l.y;break}}}else n=0;else if(n=0,o.type===b.Stack)s=a.left+this.scale.map(this.data[e+t])-l.x;else if(o.type===b.Grid){switch(r.baseline){case"left":s=a.left+this.scale.map(this.data[e+t])-l.x;break;case"right":s=a.right-this.scale.map(this.data[e+t])-l.x;break;case"center":{let i=r.vertices.length-1-e,n=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));s=this.indicator[e+t]?a.center-n/2-l.x:a.center+n/2-l.x;break}}}else s=0;l._doTranslate(s,n)}t+=r.vertices.length}}else{let t="center"==this.areas[0].baseline||"middle"==this.areas[0].baseline,e=ht(this._vertices),s=i==x?this.areas[0].baseline!==E.Right?Math.min(...e.map((t=>t.bounds.left))):Math.max(...e.map((t=>t.bounds.right))):this.areas[0].baseline!=E.Top?Math.max(...e.map((t=>t.bounds.bottom))):Math.min(...e.map((t=>t.bounds.top)));for(let t=0;t<this._vertices.length;t++){let e=this._vertices[t],n=i==x?this.areas[0].baseline!==E.Right?s+this.scale.map(this.data[t])-e.x:s-this.scale.map(this.data[t])-e.x:0,r=i==x?0:this.areas[0].baseline!=E.Top?s-this.scale.map(this.data[t])-e.y:s+this.scale.map(this.data[t])-e.y;e._doTranslate(n,r)}if(1==t){let t=this._vertices.length/this.areaNum,e=ht(this._vertices),s=i==x?Math.min(...e.map((t=>t.bounds.x))):Math.max(...e.map((t=>t.bounds.y)));for(let e=0;e<this.areaNum;e++)for(let n=0;n<t/2;n++){let r=e*t+n,a=(e+1)*t-n-1,o=this._vertices[r],l=this._vertices[a],h=i==x?o.x-l.x:l.y-o.y,c=i==x?s+h/2-o.x:0,d=i==x?0:s+h/2-o.y,u=i==x?s-h/2-l.x:0,f=i==x?0:s-h/2-l.y;o._doTranslate(c,d),l._doTranslate(u,f)}}}}else{if(nt(this.anyItem)){let t=ht(this._vertices);void 0===this.scale.offset&&(this.scale.offset=i==w?Math.min(...t.map((t=>t.bounds.left))):Math.max(...t.map((t=>t.bounds.top))));for(let t=0;t<this._vertices.length;t++){let e=this._vertices[t],s=rt(e),n=i==x?0:s.left+this.scale.map(this.data[t])-e.x,r=i==x?s.bottom-this.scale.map(this.data[t])-e.y:0;e._doTranslate(n,r)}}else{let t=ht(this._vertices);void 0===this.scale.offset&&(this.scale.offset=i==w?Math.min(...t.map((t=>t.bounds.left))):Math.max(...t.map((t=>t.bounds.top))));for(let t=0;t<this._vertices.length;t++){let e=this._vertices[t],s=i==w?this.scale.offset+this.scale.map(this.data[t])-e.x:0,n=i==w?0:this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-e.y;e._doTranslate(s,n)}}}for(let t of this.areas)t._updateBounds();"width"!=e&&"height"!=e||this.scene._relayoutAncestors(this.areas[0],this.areas)},t.run(),t}class Vt{constructor(t,e,i,s,n){this.items=t,this.anyItem=this.items[0],this.scene=e,this.channel=i,this.field=s,this._aggregator=n.aggregator,this.datatable=n.datatable,this.scale=n.scale,this.scale?(this._flipScale=this.scale.isFlipped,this.scaleType=this.scale.type,this._includeZero=this.scale.includeZero):(this._flipScale=n.flipScale,this.scaleType=n.scaleType,this._includeZero=n.includeZero),this._mapping=n.mapping,this.rangeExtent=n.rangeExtent,this._scheme=n.scheme,this.range=n.range,"angle"==this.channel&&(this.startAngle="startAngle"in n?n.startAngle:90),this._query=void 0,this._map=void 0,this._apply=void 0}get id(){return["enc",lt(this.anyItem),this.channel,this.field].join("-")}set aggregator(t){this._aggregator=t,this.scale=void 0,this.run()}get aggregator(){return this._aggregator}toJSON(){let t={};return t.anyItem=this.anyItem.id,t.items=this.items.map((t=>t.id)),this.data&&(t.data=this.data),this._rectNegativeValues&&(t._rectNegativeValues=!0),t.args={},t.args.channel=this.channel,t.args.field=this.field,t.args.aggregator=this.aggregator,t.args.datatable=this.datatable.id,t.args.scale=this.scale.id,t.args.rangeExtent=this.rangeExtent,t.args.scaleType=this.scaleType,t.args.range=this.range,"angle"==this.channel&&(t.args.startAngle=this.startAngle),t}run(){this._query(),this._map(),this._apply()}get dataTable(){return this.datatable}_inferTickValues(){let t,e=this,i=e.scale.domain,s=e.scale.range;switch(e.scale.type){case"linear":case"log":{let n=Math.abs(s[0]-s[1]);if("width"==e.channel||"height"==e.channel){let t=ot(e.anyItem,"stack");if(t){let s=st(t.group,e.scene);n=Math.max(...s.map((t=>t.bounds[e.channel]))),i[1]=e.scale.invert(n)}}t="width"==e.channel||"x"==e.channel?45:30;let a=Math.floor(n/t);return"log"===e.scale.type?e.scale._scale.ticks(a):r.ticks(i[0],i[1],a)}case"point":{t="width"==e.channel||"x"==e.channel?80:30;let s=Math.floor(e.scale.rangeExtent/i.length),n=Math.ceil(t/s);return"x"==e.channel?i.filter(((t,e)=>e%n==0)):i}case"time":{t="width"==e.channel||"x"==e.channel?80:30;let n,a,o=Math.floor((s[1]-s[0])/t),l=Math.ceil((i[1]-i[0])/o)/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 n=Math.floor(l/h[t]),a=c[t],a(i[0],i[1],n);return l>h[h.length-1]?(n=Math.floor(l/h[h.length-1]),a=c[h.length-1],a(i[0],i[1],n)):[]}default:return[]}}getScaleRange(t){let e=t||this.anyItem;if(e.type!=I.Area){if("x"==this.channel){let t=nt(e);if(t&&t.type==b.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].left+this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}{let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}}if("y"==this.channel){let t=nt(e);if(t&&t.type==b.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].bottom,i[s].bottom-this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}{let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}}if("width"==this.channel){let t=ot(e);if("grid"===t.type){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].right]}if("stack"===t.type&&"horizontal"==t.orientation)return[t.group.bounds.left,t.group.bounds.right];{let t=st(e,this.scene),i=Math.min(...t.map((t=>t.bounds.left)));return[i,i+this.scale.rangeExtent]}}if("height"==this.channel){let t=ot(e,"grid");if(t){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent===t||e.parent.parent===t));return[i[s].bottom,i[s].bottom-i[s].height]}{let t=st(e,this.scene),i=Math.max(...t.map((t=>t.bounds.bottom)));return[i,i-this.scale.rangeExtent]}}if("radialDistance"==this.channel){let t=e.parent;return[t.x,t.x+this.scale.rangeExtent]}return this.scale.range}{let t,i=Et(e),s=nt(e);t=s?i==x?s.horzCellAlignment===E.Left:s.vertCellAlignment===E.Bottom:i==x?e.baseline==E.Left:e.baseline==E.Bottom;let n=at(e);if(n)switch(this.channel){case"x":return[n.left,n.left+this.scale.rangeExtent];case"width":return t?[n.left,n.left+this.scale.rangeExtent]:[n.right,n.right-this.scale.rangeExtent];case"y":return[n.bottom,n.bottom-this.scale.rangeExtent];case"height":return t?[n.bottom,n.bottom-this.scale.rangeExtent]:[n.top+this.scale.rangeExtent,n.top]}else if(s&&"stack"===s.type)switch(n=s.group.bounds,this.channel){case"x":return[n.left,n.left+this.scale.rangeExtent];case"width":return t?[n.left,n.left+this.scale.rangeExtent]:[n.right,n.right-this.scale.rangeExtent];case"y":return[n.bottom,n.bottom-this.scale.rangeExtent];case"height":return t?[n.bottom,n.bottom-this.scale.rangeExtent]:[n.top+this.scale.rangeExtent,n.top]}if(i==w)switch(this.channel){case"width":case"height":{let e=this._vertices,i=t?Math.max(...e.map((t=>t.y))):Math.min(...e.map((t=>t.y)));return t?[i,i-this.scale.rangeExtent]:[i+this.scale.rangeExtent,i]}case"x":case"y":{let t=st(e.firstVertex,this.scene),i=Math.min(...t.map((t=>t.x)));return[i,i+this.scale.rangeExtent]}}else if(i==x)switch(this.channel){case"x":case"y":{let t=st(e.firstVertex,this.scene),i=Math.max(...t.map((t=>t.y)));return[i,i-this.scale.rangeExtent]}case"height":case"width":{let i=st(e.firstVertex,this.scene),s=t?Math.min(...i.map((t=>t.x))):Math.max(...i.map((t=>t.x)));return t?[s,s+this.scale.rangeExtent]:[s-this.scale.rangeExtent,s]}}}}}function zt(t,e,i){return e.map((e=>[e,r.mean(i,(i=>t(e-i)))]))}function Gt(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}function Wt(t,e){if("field"in e){let i=e.field;if("value"in e)return t[i]==e.value;if("range"in e)return t[i]>=e.range[0]&&t[i]<=e.range[1];if("values"in e)return e.values.indexOf(t[i])>=0}else if("fields"in e){let i=e.fields[0],s=e.fields[1],n=t[i],r=t[s];switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}return!1}}class Ut{constructor(t,e,i){if(this.url=e,this.id=I.DataTable+_t[I.DataTable]++,this.data=t,this.rawData=JSON.parse(JSON.stringify(t)),this._dateMap=new Map,this._fields=Object.keys(this.data[0]),this._newField=0,i)this._fieldTypes=i;else{this._fieldTypes={};for(let t of this._fields)this._fieldTypes[t]=Jt(this.data.map((e=>e[t]))),"year"==t.toLowerCase()&&this._fieldTypes[t]==O.Integer&&(this._fieldTypes[t]=O.Date)}this._validate(this.data,this._fieldTypes),this._fieldSummaries={};for(let t of this._fields)this._fieldSummaries[t]=qt(this.data.map((e=>e[t])),this._fieldTypes[t]);this._fields.indexOf(c)<0&&this._addField(c,O.String,this.data.map(((t,e)=>"r"+e)))}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),i=t.substring(e);0!==i.indexOf("\\")&&0!==i.indexOf("/")||(i=i.substring(1));return i}(this.url):this.id}set sourceDataTable(t){this._sourceDataTable=t}get sourceDataTable(){return this._sourceDataTable}getEncodableFields(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":return this.numericFields.concat(this.nonNumericFields);case"area":case"strokeWidth":default:return this.numericFields}}toJSON(){let t={};return t.data=this.rawData,t.fieldTypes=this._fieldTypes,t.url=this.url,t.id=this.id,t.sourceDataTable=this._sourceDataTable,t.transform=this._transform,t.dateMap={},t}transformField(t,e,i){let s=this.data.map((i=>e(i[t]))),n=Jt(s),r=i||Date.now()+"_field"+this._newField++;return this._addField(r,n,s),r}setValueOrder(t,e){this._fieldSummaries[t].unique=e}_addField(t,e,i){this.data.forEach(((e,s)=>e[t]=i[s])),this._fieldTypes[t]=e,this._fields.push(t),this._fieldSummaries[t]=qt(i,e)}getFieldType(t){return this._fieldTypes[t]}get fields(){return this._fields}getFieldSummary(t){return this._fieldSummaries[t]}getFieldValues(t){return this.data.map((e=>e[t]))}getUniqueFieldValues(t){return this._fieldSummaries[t].unique}getRowCount(){return this.data.length}hasField(t){return this._fields.indexOf(t)>=0}parseFieldAsDate(t,e){let i=r.timeParse(e);for(let e of this.data){let s=e[t];null==s||null==s?(s="",e[t]=new Date(1899,11,31).getTime()):e[t]=i(s).getTime(),this._dateMap.set(e[t],s)}this._fieldTypes[t]=O.Date,this._fieldSummaries[t]=qt(this.data.map((e=>e[t])),O.Date)}getRawValue(t,e){return this.getFieldType(t)===O.Date?this._dateMap.get(e).toString():e}static get RowID(){return c}get nonNumericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!=O.Number&&this._fieldTypes[e]!=O.Integer&&e!=Ut.RowID&&t.push(e);return t}get numericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!==O.Number&&this._fieldTypes[e]!==O.Integer||e==Ut.RowID||t.push(e);return t}getFieldsByType(t){let e=[];for(let i in this._fieldTypes)this._fieldTypes[i]===t&&i!=Ut.RowID&&e.push(i);return e}transform(t,e,i){let s=i||{};switch(t){case"kde":return function(t,e,i){let s=e[0],n=t.nonNumericFields,r={};for(let e of t.data){let t=n.map((t=>String(e[t]))).join("_");t in r||(r[t]=n.map((t=>e[t])),r[t].push([])),r[t][r[t].length-1].push(e[s])}let a="min"in i?i.min:t.getFieldSummary(s).min,o="max"in i?i.max:t.getFieldSummary(s).max,l=a,h=[];for(;l<o;)h.push(l),l+=i.interval;h.push(l);let c=[];for(let t in r){let e=r[t].pop(),a=zt(Gt(i.bandwidth),h,e);for(let e of a){let i={};r[t].forEach(((t,e)=>i[n[e]]=t)),i[s]=e[0],i[s+"_density"]=e[1],c.push(i)}}let d={};return n.forEach((e=>d[e]=t.getFieldType(e))),d[s]=O.Number,d[s+"_density"]=O.Number,new Ut(c,t.url,d)}(this,e,s);case"bin":return function(t,e,i){let s=e[0],n=t.nonNumericFields,a={};for(let e of t.data){let t=n.map((t=>String(e[t]))).join("_");a.hasOwnProperty(t)||(a[t]=n.map((t=>e[t])),a[t].push([])),a[t][a[t].length-1].push(e[s])}let o=[];for(let t in a){let e=a[t].pop(),i=r.bin()(e);for(let e of i){let i={};a[t].forEach(((t,e)=>i[n[e]]=t)),i.x0=e.x0,i.x1=e.x1,i[s+"_count"]=e.length,o.push(i)}}let l={};n.forEach((e=>l[e]=t.getFieldType(e))),l.x0=O.Number,l.x1=O.Number,l[s+"_count"]=O.Number;let h=new Ut(o,t.url,l);return h.sourceDataTable=t,h.transform={type:"bin",args:e},h}(this,e);case"sort":return function(t,e,i){t.data.sort(((t,i)=>function(t,e,i,s){for(let s of i){if(t[s]<e[s])return-1;if(t[s]>e[s])return 1}return 0}(t,i,e))),t.summarize()}(this,e);case"filter":return function(t,e){let i=[];for(let s of t.data){let t=!0;for(let i of e)if(!Wt(s,i)){t=!1;break}t&&i.push(s)}let s=new Ut(i,t.url);return s.sourceDataTable=t,s.transform={type:"filter",args:e},s}(this,e)}}summarize(){for(let t of this._fields)this._fieldSummaries[t]=qt(this.data.map((e=>e[t])),this._fieldTypes[t])}_validate(t,e){for(let i of t)for(let t in e){let s,n=e[t],r=i[t];if(null==i[t]||null==i[t])switch(n){case O.Boolean:s=!1;break;case O.Date:s=new Date(1899,11,31).getTime();break;case O.String:s="";break;default:s=0}else switch(n){case O.Boolean:s=r;break;case O.Date:s=Number.isInteger(r)?new Date(r,0).getTime():new Date(r+"").getTime(),this._dateMap.set(s,r);break;case O.String:s=r.toString();break;default:s=r}i[t]=s}}}function qt(t,e){var i={};switch(e){case O.Boolean:i.trueCount=t.filter((t=>t)).length,i.falseCount=t.filter((t=>!t)).length;break;case O.Date:i.min=r.min(t),i.max=r.max(t),i.extent=[i.min,i.max],i.unique=[...new Set(t)];break;case O.String:i.unique=[...new Set(t)];break;default:i.min=r.min(t),i.max=r.max(t),i.extent=[i.min,i.max],i.mean=r.mean(t),i.median=r.median(t),i.unique=[...new Set(t)]}return i}var Ht={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return Ht.number(t)&&(t=+t)==~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function Jt(t){var e=Object.values(O);for(let i=0;i<t.length;i++){let s=t[i];if(null!=s){for(let t=0;t<e.length;t++)Ht[e[t]](s)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}class Yt extends J{constructor(t){super(t),this.type=I.PointText,this.attrs.x=0,this.attrs.y=0,"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"),void 0!==t&&("x"in t&&(this.attrs.x=t.x),"y"in t&&(this.attrs.y=t.y),this.attrs.text="text"in t?t.text:"",this.attrs.anchor="anchor"in t?t.anchor:["center","middle"]),this._updateBounds()}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this.attrs.x,t.y=this.attrs.y,t.text=this.text,t.anchor=[this.anchor[0],this.anchor[1]]}get bounds(){return this._bounds||this._updateBounds(),this._bounds}set text(t){this.attrs.text=t,this._updateBounds()}get text(){return this.attrs.text}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){let t,e,i=function(t,e,i){let s=vt.getContext();s.font=e;let n=s.measureText(t);return n.fontBoundingBoxAscent?{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}:n.actualBoundingBoxAscent?{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}:{width:n.width,height:i}}(this.attrs.text,[this.fontWeight,this.styles.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),s=i.width,n=i.height;switch(this.attrs.anchor[0]){case"left":t=this.attrs.x;break;case"right":t=this.attrs.x-s;break;case"center":t=this.attrs.x-s/2;break;default:t=this.attrs.x}switch(this.attrs.anchor[1]){case"top":e=this.attrs.y;break;case"bottom":e=this.attrs.y-n;break;case"middle":e=this.attrs.y-n/2}this._bounds=new l(t,e,s,n)}get center(){return{x:this.bounds.left+this.bounds.width/2,y:this.bounds.top+this.bounds.height/2}}get x(){return this.attrs.x}set x(t){this.attrs.x=t,this._updateBounds()}get y(){return this.attrs.y}set y(t){this.attrs.y=t,this._updateBounds()}get anchor(){return this.attrs.anchor}set anchor(t){this.attrs.anchor=t,this._updateBounds()}get fontSize(){return parseFloat(this.styles.fontSize)}set fontSize(t){this.styles.fontSize="number"==typeof t?t+"px":t,this._updateBounds()}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._updateBounds()}get fontFamily(){return this.styles.fontFamily}set fontFamily(t){this.styles.fontFamily=t,this._updateBounds()}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}}class $t extends At{constructor(t){super(),this.type=I.Axis,this.id=this.type+_t[this.type]++,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor?t.tickAnchor:"middle",this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelOffset="labelOffset"in t?t.labelOffset:15,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,"titleAnchor"in t?this._titleAnchor=t.titleAnchor:"x"==this.channel||"width"==this.channel?this._titleAnchor="top"==this._orientation?["center","bottom"]:["center","top"]:this._titleAnchor="left"==this._orientation?["right","middle"]:["left","middle"],this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._titlePosition=t.titlePosition,this._labelRotation="labelRotation"in t?t.labelRotation:0}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.field=this._field,t.channel=this._channel,"args"in t||(t.args={}),t.args.orientation=this._orientation,t.args.strokeColor=this._strokeColor,t.args.textColor=this._textColor,t.args.tickOffset=this._tickOffset,t.args.tickSize=this._tickSize,t.args.tickAnchor=this._tickAnchor,t.args.tickVisible=this._tickVisible,t.args.pathVisible=this._pathVisible,t.args.labelOffset=this._labelOffset,t.args.labelFormat=this._labelFormat,this._labelRotation&&(t.args.labelRotation=this._labelRotation),t.args.showTitle=this._showTitle,t.args.tickValues=this._tickValues,t.args.titleAnchor=this._titleAnchor,t.args.titleOffset=this._titleOffset,t.args.titlePosition=this._titlePosition,t.args.rotateTitle=this._rotateYTitle,t}get field(){return this._field}get channel(){return this._channel}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.reposition()}get pathX(){if("y"==this.channel||"height"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].x;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].x}}set pathX(t){"y"!=this.channel&&"height"!=this.channel||(this._posArg=t),this.reposition()}get pathPosition(){return"x"==this.channel||"width"==this.channel?this.pathY:this.pathX}set pathPosition(t){"x"==this.channel||"width"==this.channel?this.pathY=t:"y"!=this.channel&&"height"!=this.channel||(this.pathX=t)}get pathY(){if("x"==this.channel||"width"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].y;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].y}}set pathY(t){"x"!=this.channel&&"width"!=this.channel||(this._posArg=t),this.reposition()}get tickOffset(){return this._tickOffset}set tickOffset(t){this._tickOffset=t,this._positionTicks()}get titleOffset(){return this._titleOffset}set titleOffset(t){this._titleOffset=t}get tickSize(){return this._tickSize}set tickSize(t){this._tickSize=t,this._positionTicks()}set tickValues(t){this._tickValues=t,this._generateTicks(),this._positionTicks()}get tickValues(){return this._tickValues}set labelValues(t){this._labelValues=t,this._generateLabels(),this._positionLabels()}get labelValues(){return this._labelValues}get tickAnchor(){return this._tickAnchor}set tickAnchor(t){this._tickAnchor=t}get tickVisible(){return this._tickVisible}set tickVisible(t){this._tickVisible=t;for(let e of this._ticks.children)e.visibility=t?"visible":"hidden"}get pathVisible(){return this._pathVisible}set pathVisible(t){this._pathVisible=t;let e=[];this._path&&e.push(this._path),this._rules&&this._rules.children.forEach((t=>e.push(t)));for(let i of e)i.visibility=t?"visible":"hidden"}get labelOffset(){return this._labelOffset}set labelOffset(t){this._labelOffset=t,this._positionLabels()}get labelFormat(){return this._labelFormat}set labelFormat(t){this._labelFormat=t,this._generateLabels(),this._positionLabels()}get labelRotation(){return this._labelRotation}set labelRotation(t){if(this._labelRotation=t,this._labels&&this._labels.children){let e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(t)for(let t of this._labels.children)t._rotate=[this._labelRotation,t.x,t.y],t.anchor=["right",e[1]];else for(let t of this._labels.children)t._rotate=void 0}}get showTitle(){return this._showTitle}set showTitle(t){this._showTitle=t,this._title||(this._generateTitle(),this._positionTitle()),this._title.visibility=t?"visible":"hidden"}get titleAnchor(){return this._titleAnchor}set titleAnchor(t){this._titleAnchor=t}get titlePosition(){return this._titlePosition}set titlePosition(t){this._titlePosition=t}get rotateTitle(){return this._rotateYTitle}set rotateTitle(t){this._rotateYTitle=t}get title(){return this._titleText}set title(t){this._titleText=t}get includeZero(){return!!this.encoding&&this.encoding.scale.includeZero}set includeZero(t){this.encoding&&(this.encoding.scale.includeZero=t)}_generatePath(){}_generateTicks(){}_generateLabels(){}_generateTitle(){this._title=new Yt({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title.id=this.id+"-title",this.addChild(this._title)}_positionPath(){}_positionTicks(){}_positionLabels(){}_positionTitle(){}matches(t){}reposition(){this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle(),"radialDistance"===this._channel&&this._rotate&&(this._rotate=[this._rotate[0],this._item.parent.x,this._item.parent.y]),this._updateBounds()}}class Zt extends $t{constructor(t,e,i){super(i),this.encoding=t,this._field=this.encoding.field,this._channel=this.encoding.channel,this._orientation="orientation"in i?i.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?i.pathY:i.pathX,this._position=this._posArg,this._titleText="title"in i?i.title:this.encoding.field,this._item=e,this._ticks=new At,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new At,this._labels.id=this.id+"labels",this.addChild(this._labels),"radialDistance"===this._channel&&"rotation"in i&&(this._rotate=[-i.rotation,this._item.parent.x,this._item.parent.y]),this._showTitle=!("showTitle"in i)||i.showTitle,this._determineAxisFlip(),this._generatePath(),this._positionPath(),this._showTitle&&this._generateTitle(),this._showTitle&&this._positionTitle()}autoUpdateTicks(){let t=this.encoding._inferTickValues();this.tickValues=t,this.labelValues=t}_updateBounds(){this._bounds=this._path.bounds,this._ticks.children.length>0&&(this._bounds=this._bounds.union(this._ticks.bounds)),this._labels.children.length>0&&(this._bounds=this._bounds.union(this._labels.bounds)),this._title&&(this._bounds=this._bounds.union(this._title.bounds))}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"time"===this.encoding.scale.type&&(t.args.isDate=!0),this._rotate&&(t.args.rotation=this._rotate[0]),"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,t}get ticks(){return this._ticks}get labels(){return this._labels}get path(){return this._path}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;this._path.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_generatePath(){this._path=new X({strokeColor:this._strokeColor}),this._pathVisible||(this._path.visibility="hidden"),this._path.type=I.Line,this._path.id=this.id+"path",this.addChild(this._path)}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new X({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=I.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this.encoding.datatable.getFieldType(this.encoding.field)){case O.Date:t=r.timeFormat(this._labelFormat);break;case O.String:t=function(t){return t};break;default:t=r.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let s=new Yt({text:t(i),fontSize:this._fontSize,fillColor:this._textColor});s.id=this.id+"label"+e,this._labels.addChild(s)}}_positionPath(){this._range=this.encoding.getScaleRange(this._item),void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg;let t=[];if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].x));t.push([Math.min(...e.concat(this._range)),this._position]),t.push([Math.max(...e.concat(this._range)),this._position])}else if("y"==this._channel||"height"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].y));t.push([this._position,Math.min(...e.concat(this._range))]),t.push([this._position,Math.max(...e.concat(this._range))])}this._path._setVertices(t),this._path._updateBounds(),this._showTitle&&this._title&&this._positionTitle(),this._updateBounds()}_isAlignedLeft(t){switch(t.type){case b.Stack:case b.Grid:return t.horzCellAlignment===E.Left;default:return!0}}_isAlignedBottom(t){switch(t.type){case b.Stack:case b.Grid:return t.vertCellAlignment===E.Bottom;default:return!0}}_determineAxisFlip(){if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){if("width"==this._channel){let t=wt(this._item)?wt(this._item).layout:nt(this._item);if(t)this._flip=!this._isAlignedLeft(t);else if("area"==this._item.type){let t=this._item.baseline==E.Left||this._item.baseline==E.Center||this._item.baseline==E.Middle||null==this._item.baseline;this._flip=!t}}}else if(("y"==this._channel||"height"==this._channel)&&"height"==this._channel){let t=wt(this._item)?wt(this._item).layout:nt(this._item);if(t)this._flip=!this._isAlignedBottom(t);else if("area"==this._item.type){let t=this._item.baseline==E.Bottom||this._item.baseline==E.Center||this._item.baseline==E.Middle||null==this._item.baseline;this._flip=!t}}}_positionLabels(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize,e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._range[1]-this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i])-this.encoding.scale.range[0],s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]])}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize,e="left"==this._orientation?["right","middle"]:["left","middle"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]+this.encoding.scale.map(this._labelValues[i]),s.anchor=e;else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[1],s.anchor=e;else for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[0]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[0],s.anchor=e}this._labels._updateBounds(),this._updateBounds()}_computePosition(){let t;if("vertex"===this._item.type&&!this._item.parent.closed){let t=st(this._item,this._item.parent.getScene());if("x"===this._channel&&1==Tt(t.map((t=>t.bounds.middle))).length)return this._item.bounds.middle;if("y"===this._channel&&1==Tt(t.map((t=>t.bounds.center))).length)return this._item.bounds.center;if("radialDistance"===this._channel)return this._item.parent.y}if(this._item.type==I.Area&&(t=at(this._item)),void 0===t){let e=wt(this._item);void 0===e&&(e=xt(this._item)),t=e.bounds}return"x"===this._channel||"width"===this._channel?"top"==this._orientation?t.top-this._tickSize:t.bottom+this._tickSize:"y"===this._channel||"height"===this._channel?"left"==this._orientation?t.left-this._tickSize:t.right+this._tickSize:"radialDistance"===this._channel?this._item.parent.y:void 0}_positionTicks(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,this._range=this.encoding.getScaleRange(this._item),"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position+t]]),i._updateBounds()}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[1]+this.encoding.scale.map(this._tickValues[e])],[this._position,this._range[1]+this.encoding.scale.map(this._tickValues[e])]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries()){let s=this._range[1]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[1];i._setVertices([[this._position+t,s],[this._position,s]]),i._updateBounds()}else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]],[this._position,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]]]),i._updateBounds()}this._positionPath(),this._ticks._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._path.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel||"width"==this._channel?(this._title.x=t.x,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){let e=lt(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(lt(t.anyItem).split("_")[0]===e)return!0}return!1}get isFlipped(){return!!this._flip||!!this.encoding.scale.isFlipped}}class Kt extends $t{constructor(t,e,i,s,n){super(n),this._channel=i,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._item=t[0],this._items=t,this._mlayout=e,this._field=s,this._titleText="title"in n?n.title:this._field,this._showTitle="showTitle"in n&&n.showTitle,this._ticks=new At,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new At,this._labels.id=this.id+"labels",this.addChild(this._labels),this._rules=new At,this._rules.id=this.id+"paths",this.addChild(this._rules),this._generatePath(),this._generateTicks(),this._generateLabels(),this._showTitle&&this._generateTitle(),this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle()}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,this.classId&&(t.classId=this.classId),t}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;for(let e of this._rules.children)e.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_updateBounds(){this._bounds=this._rules.bounds.clone(),this._bounds=this._bounds.union(this._ticks.bounds),this._bounds=this._bounds.union(this._labels.bounds),this._showTitle&&(this._bounds=this._bounds.union(this._title.bounds))}_generatePath(){if(this._rules.removeAll(),this._mlayout.type==b.Grid){let t="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;for(let e=0;e<t;e++){let t=new X({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=I.Line,t.id=this.id+"rule"+e,this._rules.addChild(t)}}else if(this._mlayout.type===b.Stack){let t=new X({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=I.Line,t.id=this.id+"rule",this._rules.addChild(t)}}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._mlayout.group.children.length;t++){let e=new X({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=I.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this._item.dataScope.getFieldType(this._field)){case O.Date:t=r.timeFormat(this._labelFormat);break;case O.String:t=function(t){return t};break;default:t=r.format(this._labelFormat)}let e=this._mlayout.cellBounds;for(let i=0;i<e.length&&!(i>=this._mlayout.group.children.length);i++){let e=this._mlayout.group.children[i],s=new Yt({fillColor:this._textColor,fontSize:this._fontSize,text:t(e.dataScope.getFieldValue(this._field))});s.id=this.id+"label"+i,this._labels.addChild(s)}}_positionPath(){if(this._mlayout.type==b.Grid){let t=this._mlayout.cellBounds,e="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;if("x"==this._channel){let i=t[0].left,s=this._mlayout.numCols;for(let n=0;n<e;n++)this._rules.children[n]._setVertices([[i,this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:t[n*s][this._orientation]],[i+t[0].width*s+this._mlayout.colGap*(s-1),this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:t[n*s][this._orientation]]])}else{let i=t[0].top,s=this._mlayout.numRows;for(let n=0;n<e;n++)this._rules.children[n]._setVertices([[this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation],i],[this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation],i+t[0].height*s+this._mlayout.rowGap*(s-1)]])}}else if(this._mlayout.type===b.Stack){let t=this._mlayout.group.bounds;"x"==this._channel?this._rules.children[0]._setVertices([[t.left,this._posArg?this._posArg:t[this._orientation]],[t.right,this._posArg?this._posArg:t[this._orientation]]]):this._rules.children[0]._setVertices([[this._posArg?this._posArg:t[this._orientation],t.top],[this._posArg?this._posArg:t[this._orientation],t.bottom]])}this._rules.children.forEach((t=>t._updateBounds())),this._rules._updateBounds(),this._updateBounds()}_positionTicks(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?1:-1;for(let[i,s]of this._ticks.children.entries()){let n=this._posArg?t[i][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:t[i][this._orientation]+this._tickOffset*e;s._setVertices([[t[i].x,n],[t[i].x,n+e*this._tickSize]]),s._updateBounds()}}else if("y"==this._channel){let e="left"==this._orientation?-1:1;for(let[i,s]of this._ticks.children.entries()){let n=this._posArg?t[i][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:this._mlayout.group.bounds[this._orientation]+this._tickOffset*e,r="middle"==this._tickAnchor?t[i].y:t[i][this._tickAnchor];s._setVertices([[n,r],[n+e*this._tickSize,r]]),s._updateBounds()}}this._ticks._updateBounds(),this._updateBounds()}_positionLabels(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?["center","top"]:["center","bottom"],i="bottom"==this._orientation?this._labelOffset:-this._labelOffset;for(let[s,n]of this._labels.children.entries())n.x=t[s].x,n.y=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+i:t[s][this._orientation]+i,n.anchor=e,this._labelRotation&&(n._rotate=[this._labelRotation,n.x,n.y],n.anchor=["right",e[1]])}else if("y"==this._channel){let e="left"==this._orientation?["right","middle"]:["left","middle"],i="left"==this._orientation?-this._labelOffset:this._labelOffset;for(let[s,n]of this._labels.children.entries())n.x=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+i:this._mlayout.group.bounds[this._orientation]+i,n.y="middle"==this._tickAnchor?t[s].y:t[s][this._tickAnchor],n.anchor=e,this._labelRotation&&(n._rotate=[this._labelRotation,n.x,n.y])}this._labels._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._rules.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel?(this._title.x=t.x,this._titleOffset=this._labels.bounds.height+this._labelOffset+15,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._titleOffset=this._labels.bounds.width+this._labelOffset+15,this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){return lt(this._item).split("_")[0]===lt(t).split("_")[0]}}class Xt extends At{constructor(t,e){super(),this.type=I.Legend,this.id=this.type+_t[this.type]++,this.encoding=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._showTitle=!("showTitle"in e)||e.showTitle,"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._numCols=1,this._orientation="orientation"in e?e.orientation:x,this._initialize()}toJSON(){let t=super.toJSON();return"args"in t||(t.args={}),t.args.textColor=this._textColor,t.channel=this.encoding.channel,t.field=this.encoding.field,t.args.strokeColor=this._strokeColor,t.args.x=this._x,t.args.y=this._y,t.args.orientation=this._orientation,t}get field(){return this.encoding.field}get channel(){return this.encoding.channel}get fieldType(){return this.encoding.datatable.getFieldType(this.field)}_initialize(){let t=this.encoding.scene,e=this.encoding.field;switch(this.encoding.datatable.getFieldType(e)){case O.String:this._createCategoricalColorLegend(t,e);break;case O.Date:case O.Number:case O.Integer:this._createNumericalColorLegend(t,e)}this._updateBounds()}_createNumericalColorLegend(t,e){let i,s,n;if(this._orientation==x?(i=15,s=300):(i=300,s=15),this._showTitle){let s=t.mark("text",{fillColor:this._textColor,text:e,x:this._x+i/2,y:this._y,anchor:["center","middle"]});this.addChild(s),n=20}else n=0;let r,a=t.mark("rect",{top:this._y+n,left:this._x,width:i,height:s,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),o=[Math.min(...this.encoding.data),Math.max(...this.encoding.data)],l=this.encoding.scale.mapping,h=[],c=[];if(l){let e=Object.keys(l).map((t=>parseFloat(t))).sort(((t,e)=>t-e));this._orientation==x?(r=new H({x1:0,y1:100,x2:0,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,l[e],1);let d=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-a*s+n,y2:this._y+s-a*s+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+i+5+5,y:this._y+s-a*s+n,anchor:["left","middle"]});h.push(u)}))):(r=new H({x1:0,y1:0,x2:100,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,l[e],1);let d=t.mark("line",{x1:this._x+a*i,x2:this._x+a*i,y1:this._y+20-5+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+a*i,y:this._y+s+5+n,anchor:["center","top"]});h.push(u)})))}else{let a=this.encoding.scale.domain,o=this.encoding.datatable,l=o.getFieldType(e),d=[],u=l===O.Date?o.getUniqueFieldValues(e):Tt(this.encoding.data);if(u.length<=10)d=u,d.sort(((t,e)=>t-e));else if(l===O.Date){u.sort(((t,e)=>t-e));for(let t=0;t<u.length;t+=Math.ceil(u.length/10))d.push(u[t])}else{let t=(a[1]-a[0])/9;for(let e=0;e<10;e++)d.push(a[0]+e*t);let e=0;for(;t<1;)t*=10,e++;d=d.map((t=>t.toFixed(e)))}this._orientation==x?(r=new H({x1:0,y1:100,x2:0,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-u*s+n,y2:this._y+s-u*s+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:l===O.Date?o.getRawValue(e,d):d,x:this._x+i+5+5,y:this._y+s-u*s+n,anchor:["left","middle"]});h.push(p)}))):(r=new H({x1:0,y1:0,x2:100,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+u*i,x2:this._x+u*i,y1:this._y+s+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:l===O.Date?o.getRawValue(e,d):d,x:this._x+u*i,y:this._y+s+5+n,anchor:["center","top"]});h.push(p)})))}a.styles.fillColor=r,this.addChild(a);for(let t of h)this.addChild(t);for(let t of c)this.addChild(t)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.setTextColor(this)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.removeAll(),this._initialize()}setTextColor(t){if(t.children&&0!==t.children.length)for(let e of t.children)e.type===I.PointText?e.fillColor=this._textColor:e.children&&e.children.length>0&&this.setTextColor(e)}_createCategoricalColorLegend(t,e){let i=0;this._showTitle&&(this.addChild(new Yt({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),i=parseFloat(this._fontSize)+5);let s=t.mark("rect",{top:this._y+2+i,left:this._x,width:10,height:10,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),n=t.mark("text",{fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+i,anchor:["left","top"]}),r=t.glyph(s,n),a=this.encoding.scale,o=new Ut(a.domain.map((t=>({category:t,value:a.map(t)})))),l=t.repeat(r,o);t.encode(n,{channel:"text",field:"category",_remember:!1}),t.encode(s,{channel:"fillColor",field:"category",_remember:!1,scale:a}),l.layout=ud("grid",{numCols:this._numCols,numRows:this._numRows}),this.addChild(l)}pathHitTest(t,e){let i=ut(this);for(let s=i.length-1;s>=0;s--){let n=i[s];if(gt(n)&&n.contains(t,e))return n}return null}matches(t){let e=lt(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(lt(t.anyItem).split("_")[0]===e)return!0}return!1}}class Qt extends At{constructor(t){if(super(),this.type=I.Glyph,this._id=this.type+_t[this.type]++,t)for(let e of t)this.addChild(e)}duplicate(){let t=this.getScene().glyph();for(let e of this.children)t.addChild(e.duplicate());return t.classId=this.classId,this._dataScope&&(t.dataScope=this._dataScope.clone()),t}}class te extends X{constructor(t){super(t),this.type=I.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new K(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get baseline(){return this._baseline}set baseline(t){this._baseline=t}get orientation(){return this._orientation}set orientation(t){this._orientation=t}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(t){super.copyPropertiesTo(t),t._baseline=this._baseline}resizeArea(t,e){let i=this.vertices[this.vertices.length/2].x,s=this.vertices[this.vertices.length/2].y,n=this.width,r=this.height;for(let a of this.vertices)a.x=i+t/n*(a.x-i),a.y=s+e/r*(a.y-s);this._updateBounds()}getSVGPathData(){return super.getSVGPathData()+" z"}}class ee extends X{constructor(t){super(t),this.type=I.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t}get outerRadius(){return this._outerRadius}set outerRadius(t){this._outerRadius=t,this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new $(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}get thickness(){return this._outerRadius-this._innerRadius}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}_updateBounds(){this._bounds=new l(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._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 ie extends X{constructor(t){super(t),this.type=I.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}get center(){return new $(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}set radius(t){this._radius=t,this._updateBounds()}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}_doTranslate(t,e){this._x+=t,this._y+=e,super._doTranslate(t,e)}}class se{constructor(t,e){this.direction=e,this.items=t,this.type=A,this.id=this.type+"_"+[...new Set(this.items.map((t=>t.classId)))].join("_")}apply(){let t,e=this.direction;this.direction==E.Top||this.direction==E.Left?t=Math.min(...this.items.map((t=>t.bounds[e]))):this.direction==E.Bottom||this.direction==E.Right?t=Math.max(...this.items.map((t=>t.bounds[e]))):this.direction!=E.Center&&this.direction!=E.Middle||(t=r.mean(this.items.map((t=>t.bounds[e]))));let i=this.items.map((i=>t-i.bounds[e])),s=e==E.TOP||e==E.Middle||e==E.Bottom?"y":"x";this.items.forEach(((t,e)=>{if(t.parent&&t.parent.layout&&t.parent.layout.type==b.Stack){let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t.parent._doTranslate(n,r)}else{let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t._doTranslate(n,r)}}));let n={};this.items.forEach((t=>n[t.classId]=t)),Object.values(n).forEach((t=>t.getScene()._updateAncestorBounds(t)))}toJSON(){let t={};return t.items=this.items.map((t=>t.id)),t.direction=this.direction,t.type=this.type,t.id=this.id,t}}class ne{constructor(t,e,i,s,n,r,a){this.item=t,this.baseItem=e,this.scene=i,this.channel=s,this.itemAnchor=n,this.baseAnchor=r,this.offset=a,this.type=T,this.id=this.type+"_"+this.item.classId+"_"+this.baseItem.classId+"_"+s}apply(){let t=st(this.item,this.scene),e=st(this.baseItem,this.scene),i=this.itemAnchor,s=this.baseAnchor,n=this.item.type==I.PointText;if("radialDistance"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];a.type==I.Arc||a.type==I.Ring?r="top"==s?a.outerRadius+this.offset:"bottom"==s?a.innerRadius+this.offset:(a.outerRadius+a.innerRadius)/2+this.offset:a.type==I.Circle&&(r="top"==s?a.radius+this.offset:"bottom"==s?this.offset:a.radius/2+this.offset),o._doTranslate(a.x-o.x,a.y-r-o.bounds[i]),o._rotate?o._rotate=[o._rotate[0],a.x,a.y]:o._rotate=[0,a.x,a.y]}else if("angle"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];r=a.type==I.Arc?"left"==s?a.endAngle+this.offset:"center"==s?a.startAngle+a.angle/2+this.offset:a.startAngle+this.offset:90,o._rotate?o._rotate[0]=90-r:(o._doTranslate(a.x-o.bounds[i],a.y-t[n].y),o._rotate=[90-r,e[n].x,e[n].y])}else{let r;if(this.baseItem.type==I.Link)switch(s){case"left":case"top":r=0;break;case"center":case"middle":r=.5;break;case"right":case"bottom":r=1}for(let a=0;a<t.length;a++){let o=this.baseItem.type==I.Link?e[a].getPointAt(r)[this.channel]:e[a].bounds[s]+this.offset;n?(t[a].anchor["x"==this.channel?0:1]=this.itemAnchor,t[a][this.channel]=o):"x"==this.channel?t[a]._doTranslate(o-t[a].bounds[i],0):t[a]._doTranslate(0,o-t[a].bounds[i])}}this.item.getScene()._updateAncestorBounds(this.item),this.baseItem.getScene()._updateAncestorBounds(this.baseItem)}toJSON(){let t={};return t.item=this.item.id,t.baseItem=this.baseItem.id,t.channel=this.channel,t.itemAnchor=this.itemAnchor,t.baseAnchor=this.baseAnchor,t.offset=this.offset,t.type="affixation",t.id=this.id,t}}class re extends At{constructor(t,e,i){super(),this.type=I.Gridlines,this.id=this.type+_t[this.type]++,this.encoding=t,this.channel=this.encoding.channel,this._item=e,this._strokeColor="strokeColor"in i?i.strokeColor:"#ddd",this._strokeWidth="strokeWidth"in i?i.strokeWidth:1,"radialDistance"==this.channel&&"angle"in i&&(this._rotate=[-i.angle,this.encoding.x,this.encoding.y])}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.args.strokeColor=this._strokeColor,t.args.strokeWidth=this._strokeWidth,t.args.values=this._values,"time"===this.encoding.scale.type&&(t.args.isDate=!0),t.channel=this.encoding.channel,t.field=this.encoding.field,this._rotate&&(t.args.angle=this._rotate[0]),t}get values(){return this._values}set values(t){this._values=t,this.updateLines(),this.updateLinePositions()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t;for(let e of this.children)e.strokeColor=t}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t;for(let e of this.children)e.strokeWidth=t}matches(t){let e=lt(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(lt(t.anyItem).split("_")[0]===e)return!0}return!1}updateLinePositions(){let t=wt(this._item)?wt(this._item):xt(this._item);if("x"==this.channel||"width"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);for(let[t,s]of this.children.entries()){let n=i[0]+this.encoding.scale.map(this._values[t])-this.encoding.scale.range[0];s._setVertices([[n,e.top],[n,e.bottom]])}}else if("y"==this.channel||"height"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);if(this.encoding.flip)for(let[t,s]of this.children.entries()){let n=i[1]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}else for(let[t,s]of this.children.entries()){let n=i[0]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}}else if("radialDistance"==this.channel)for(let[t,e]of this.children.entries())e.x=this._item.parent.x,e.y=this._item.parent.y,e.radius=this.encoding.scale.map(this._values[t]);for(let t of this.children)t._updateBounds();this._updateBounds()}updateLines(){if(this.children=[],"x"==this.channel||"y"==this.channel||"width"==this.channel||"height"==this.channel)for(let t=0;t<this._values.length;t++){let e=new X({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=I.Line,e.id=this.id+"line"+t,this.addChild(e)}else if("radialDistance"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Lt({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=I.Circle,e.id=this.id+"line"+t,this.addChild(e)}}}class ae extends At{constructor(){super(),this.type=I.Collection,this._id=this.type+_t[this.type]++,this.classId=this.id,this._childrenOrder=void 0}get childrenOrder(){return this._childrenOrder?this._childrenOrder:{field:"atlas_rowId",direction:"asc"}}set childrenOrder(t){if(!("field"in t)&&!("direction"in t))return;let e,i=t.field;if(this.dataScope.dataTable.hasField(i)){if(this._childrenOrder=t,i===c)e=(t,e)=>parseInt(t.dataScope.getFieldValue(i).substring(1))-parseInt(e.dataScope.getFieldValue(i).substring(1));else{switch(this.children[0].dataScope.getFieldType(i)){case O.Date:break;case O.Number:case O.Integer:e=(t,e)=>t.dataScope.aggregateNumericalField(i)-e.dataScope.aggregateNumericalField(i);break;case O.String:e=t.ranking?(e,s)=>t.ranking.indexOf(e.dataScope.getFieldValue(i))-t.ranking.indexOf(s.dataScope.getFieldValue(i)):(t,e)=>t.dataScope.getFieldValue(i)<e.dataScope.getFieldValue(i)?-1:1}}this.children.sort(e),"desc"==t.direction&&this.children.reverse(),this.layout&&this.layout.run()}else console.warn("Cannot order collection children by an non-existent field",t.field)}duplicate(){let t=this.getScene().collection();for(let e=0;e<this.children.length;e++){let i=this.children[e];t.addChild(i.duplicate())}if(t.classId=this.classId,this.parent.addChild(t),this._layout){let e=this._layout.clone();t.layout=e}return t}}class oe extends X{constructor(t){super(t),this._type=I.Arc,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=Ct(this._startAngle),this._er=Ct(this._endAngle);let e=this._x+this._innerRadius*Math.cos(this._sr),i=this._y-this._innerRadius*Math.sin(this._sr),s=this._x+this._innerRadius*Math.cos(this._er),n=this._y-this._innerRadius*Math.sin(this._er),r=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([[e,i],[r,a],[o,l],[s,n]])}get type(){return 0===this._innerRadius?I.Pie:I.Arc}set type(t){this._type=t}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t,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[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}set outerRadius(t){this._outerRadius=t,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._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new $(this._x,this._y)}set x(t){this._x=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this._updateBounds()}set y(t){this._y=t,this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}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}sweepOver(t){let e=this.startAngle,i=this.endAngle;i<e&&(i+=360);let s=t.startAngle,n=t.endAngle;return n<s&&(n+=360),s>=e&&s<=i&&n>=e&&n<=i}_doTranslate(t,e){this._x+=t,this._y+=e,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._updateBounds()}_updateBounds(){this._bounds=new l(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>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,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}adjustAngle(t,e){this._startAngle=t,this._endAngle=e,this._sr=Ct(this._startAngle),this._er=Ct(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)}}class le extends J{constructor(t){super(t),this.type=I.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}toJSON(){let t=super.toJSON();return t.src=this._src,t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}get src(){return this._src}set src(t){this._src=t}get width(){return this._width}set width(t){this._width=t,this._updateBounds()}get height(){return this._height}set height(t){this._height=t,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new l(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}}class he extends X{constructor(t){super(t),this.type=I.Link,this.mode="mode"in t?t.mode:"linear",this.source=void 0,this.target=void 0,this.sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this.targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this.sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this.targetOffset="targetOffset"in t?t.targetOffset:[0,0]}radialvalue(t,e){let i=t-Math.PI/2;return[t=e*Math.cos(i),e*=Math.sin(t)]}bezierCurveHorizontal(t,e,i,s){return`M ${t} ${e} C ${(t+i)/2} ${e} ${t} ${s} ${i} ${s}`}bezierCurveVertical(t,e,i,s){return`M ${t} ${e} C ${t} ${(e+s)/2} ${i} ${e} ${i} ${s}`}bezierCurveRadial(t,e,i,s){let n=this.radialvalue(t,e),r=this.radialvalue(t,(e+s)/2),a=this.radialvalue(i,e),o=this.radialvalue(i,s);return`M ${n[0]} ${n[1]} C ${r[0]} ${r[1]} ${a[0]} ${a[1]} ${o[0]} ${o[1]}`}_updateBounds(){if(null!=this.source&&null!=this.target){let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];this._bounds=new l(Math.min(t,i),Math.min(e,s),Math.abs(t-i),Math.abs(e-s))}else this._bounds=new l(0,0,0,0)}getSVGPathData(){if(void 0===this.source||void 0===this.target)return"";let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];switch(this.mode){case"curveHorizontal":return this.bezierCurveHorizontal(t,e,i,s);case"curveVertical":return this.bezierCurveVertical(t,e,i,s);case"linear":default:return`M ${t} ${e} L ${i} ${s}`}}copyPropertiesTo(t){super.copyPropertiesTo(t),t.sourceAnchor=this.sourceAnchor.slice(),t.targetAnchor=this.targetAnchor.slice(),t.sourceOffset=this.sourceOffset.slice(),t.targetOffset=this.targetOffset.slice(),t.mode=this.mode}getPointAt(t){const e=bt.getSVG();let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",this.getSVGPathData()),e.appendChild(i);let s=i.getTotalLength();return i.getPointAtLength(s*t)}}const ce=function(t,e,i){let s=t.getScene();ft(t)||s._reapplyConstraints(t),s.getRelatedAxes(t).forEach((t=>{t.encoding&&void 0!==t.encoding.scale.offset&&(t.encoding.scale.offset+="x"===t.channel||"width"===t.channel?e:i),0===i||"x"!==t.channel&&"width"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+i),0===e||"y"!==t.channel&&"height"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+e),t.reposition()})),s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},de=function(t,e,i){let s=t.getScene();s._relayoutAncestors(t,e);let n=[t],r=t.firstChild;for(;r;)n.push(r),r=r.firstChild;for(let t of n)t.getScene()._reapplyConstraints(t);if(i)s.reCreateRelatedAxes(t);else{s.getRelatedAxes(t).forEach((t=>t.reposition()))}s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},ue=function(t){for(let e of t.encodings)e._map(),e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let i=e.anyItem,s=e.scene.getRelatedAxes(i);for(let i of s)i.encoding&&i.encoding.scale===t&&(i.tickValues=e.scene._inferTickValues(e),i.labelValues=e.scene._inferTickValues(e),i._positionPath(),i._showTitle&&i._positionTitle(),"radialDistance"===i._channel&&i._rotate&&(i._rotate=[i._rotate[0],i._item.parent.x,i._item.parent.y]),i._updateBounds());e.scene.getRelatedGridlines(i).forEach((t=>t.updateLinePositions()))}},fe=function(t){for(let e of t.encodings)e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let t=e.anyItem;e.scene.getRelatedAxes(t).forEach((t=>t.reposition())),e.scene.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))}},pe=function(t,e){let i=t.getScene();i._relayoutAncestors(t,e),i._reapplyConstraints(t),i.getRelatedAxes(t).forEach((t=>t.reposition())),i.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},ge=function(t,e){let i=e.getScene(),s=i.encodings[lt(t)];if(s){i.encodings[lt(e)]={};for(let n of["x","y"]){const r=s[n];r&&(r.anyItem=e,r.items=st(e,i),i.encodings[lt(e)][n]=r,delete i.encodings[lt(t)][n])}0===Object.keys(s)&&delete i.encodings[lt(t)]}},_e=function(t){let e=t.getScene(),i=e.encodings[lt(t)];for(let t in i)i[t]._apply();e.getRelatedAxes(t).forEach((t=>t.reposition())),e.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))};function me(t,e,i,s){let n=s.getFieldType(i);if(n!=O.String&&n!=O.Date&&n!=O.Integer)throw new Error(W.REPOPULATE_BY_NONCAT+": "+i+" is "+n);if(e.parent&&e.parent.dataScope&&!e.parent.dataScope.isFullTable()&&e.parent.dataScope.dataTable!=s)throw new Error(W.REPOPULATE_DT_MISMATCH);return function(t,e,i,s){let n=st(e.parent,t);1===n.length&&(e.parent.dataScope=void 0);for(let t of n){let e=s.getFieldSummary(i).unique.map((e=>t.dataScope?t.dataScope.cross(i,e):new Mt(s).cross(i,e)));e=e.filter((t=>!t.isEmpty()));const n=e.length-t.children.length,r=t.children.length-e.length;for(let e=0;e<r;e++)t.removeChildAt(t.children.length-1);const a=t.children.length;for(let e=0;e<n;e++){let e=t.children[Math.floor(Math.random()*a)].duplicate();t.addChild(e)}t.children.forEach(((t,i)=>t.dataScope=e[i]))}t._relayoutAncestors(e)}(t,e,i,s)}function ye(t,e){let i=t.item;if(e.innerRadius===i.outerRadius&&i.sweepOver(e))t.children.push({item:e,children:[]});else if(t.children&&t.children.length>0&&e.innerRadius>i.outerRadius&&i.sweepOver(e))for(let i of t.children)ye(i,e)}function ve(t,e,i,s){let n=t.item;if(n.innerRadius=e,n.outerRadius=e+s.map(i[n.id]),t.children&&t.children.length>0)for(let e of t.children)ve(e,n.outerRadius,i,s)}class be{constructor(t,e){this._type="tree";let i=[],s=[];this._nodeHash={},this._traverse(t,i,s),this._nodeTable=new Ut(i,"nodes"),this._linkTable=new Ut(s,"links"),this._nodeTable.tree=this,this._linkTable.tree=this,this._data=t,this.aggregateFromLeaves("value","average")}get type(){return this._type}_traverse(t,e,i,s=0){let n={};h in t||(t.id="n"+e.length),e.push(n),t._depth=s;for(let r in t)if("children"==r&&t[r]&&t[r].length>0)for(let n of t[r]){let r=this._traverse(n,e,i,s+1);i.push({parent:t.id,child:r})}else n[r]=t[r];return this._nodeHash[n.id]=n,n.id}getParent(t){let e,i=t.id,s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].child==i){e=s[t].parent;let i=n.findIndex((t=>t.id==e));return n[i]}}getChildren(t){let e=t.id,i=[],s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].parent==e){let e=s[t].child,r=n.findIndex((t=>t.id==e));i.push(n[r])}return i}getNodeDataScope(t){return new Mt(this._nodeTable).cross(c,t.atlas_rowId)}getMaxDepth(){return this._nodeTable._fieldSummaries._depth.max}getRoot(){return this._nodeTable.data[0]}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}getNode(t){return this._nodeTable.data.filter((e=>e.id==t))[0]}sumLeaves(t,e){if(!t)return 0;let i=t.id,s=[];if(s=this.getChildren(t),s&&s.length>0){let t=0;for(let i of s)t+=this.sumLeaves(i,e);this.getNode(i)["sum"+e]=t}else this.getNode(i)["sum"+e]=t[e];return t["sum"+e]}countLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0)for(let t of s)n+=this.countLeaves(t,e);else n=1;return this.getNode(i)["count"+e]=n,t["count"+e]}averageLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0){for(let t of s)n+=this.averageLeaves(t,e);n/=s.length,this.getNode(i)["average"+e]=n}else this.getNode(i)["average"+e]=t[e];return t["average"+e]}medianLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.medianLeaves(t,e));n.sort((function(t,e){return t-e}));let t=Math.floor(n.length/2);n.length%2?this.getNode(i)["median"+e]=n[t]:this.getNode(i)["median"+e]=(n[t-1]+n[t])/2}else this.getNode(i)["median"+e]=t[e];return t["median"+e]}maxLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.maxLeaves(t,e));this.getNode(i)["max"+e]=Math.max(...n)}else this.getNode(i)["max"+e]=t[e];return t["max"+e]}minLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.minLeaves(t,e));this.getNode(i)["min"+e]=Math.min(...n)}else this.getNode(i)["min"+e]=t[e];return t["min"+e]}aggregateFromLeaves(t,e){let i=this.getRoot();switch(e){case"sum":this.sumLeaves(i,t);break;case"count":this.countLeaves(i,t);break;case"average":this.averageLeaves(i,t);break;case"median":this.medianLeaves(i,t);break;case"max":this.maxLeaves(i,t);break;case"min":this.minLeaves(i,t)}}}function xe(t,e,i,s,n){switch(e.type){case I.Circle:return function(t,e,i,s,n){let r,a,o=i||C.Outward,l=s||50;if(o!==C.Inward&&o!==C.Outward)throw W.UNKNOWN_DIRECTION+" "+o;return st(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let h=i.parent;we(i,e.id,o,l,n,n.getRoot(),s,t,!0),s.layout=ud("strata",{direction:o,rootMark:i}),h.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n);case I.Rect:return function(t,e,i,s,n){let r,a,o=i||C.Down,l=s||50;if([C.Up,C.Down,C.Left,C.Right].indexOf(o)<0)throw W.UNKNOWN_DIRECTION+" "+o;return st(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let h=i.parent;ke(i,e.id,o,l,n,n.getRoot(),s,t,!0),s.layout=ud("strata",{direction:o,rootMark:i}),h.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n)}}function we(t,e,i,s,n,r,a,o,l){l&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let h=n.getChildren(r);if(0===h.length)return;let c=t.type===I.Circle||t.type===I.Ring?90:t.startAngle,d=(t.type===I.Circle||t.type===I.Ring?360:t.angle)/h.length;for(let r=0;r<h.length;r++){let l,u=t.type===I.Circle?t.radius:t.outerRadius;l=360===d?o.mark("ring",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}):o.mark("arc",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,startAngle:Ot(c+d*r),endAngle:Ot(c+d*(r+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),l.dataScope=n.getNodeDataScope(h[r]),l.classId=e,a.addChild(l),we(l,e,i,s,n,h[r],a,o)}}function ke(t,e,i,s,n,r,a,o,l){l&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let h,c,d,u=n.getChildren(r);if(0!==u.length){switch(i){case C.Up:case C.Down:case C.Left:case C.Right:default:h=t.left,c=t.bottom,d=t.width/u.length}for(let r=0;r<u.length;r++){let l=o.mark("rect",{left:h,top:c,width:d,height:s,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});h+=d,l.dataScope=n.getNodeDataScope(u[r]),l.classId=e,a.addChild(l),ke(l,e,i,s,n,u[r],a,o)}}}class Se{constructor(t,e,i,s){this._listener=t,this._eventType=e,this._selDef=i,this._targetDef=s}getCallbackFunction(t,e){let i=this;return function(s){s.stopPropagation();let n,a=e._getSelection(s,i.selectionDef,i._listener,t.getItem(r.select(this).attr("id"))),o=st(i.targetDef.item,t);i.selectionDef.remember?(e.addGlobalPredicate(t,a.predicate),n=e.getGlobalPredicates(t)):n=e.getGlobalPredicates(t).concat([a.predicate]);for(let t of o){let e=!0;for(let i of n)if(!Q(t,i)){e=!1;break}for(let s in i.targetDef.effect)s in t.staticProperties||(t.staticProperties[s]=t[s]),e?t[s]=i.targetDef.effect[s].selected:"unselected"in i.targetDef.effect[s]?t[s]=i.targetDef.effect[s].unselected:s in t.staticProperties&&(t[s]=t.staticProperties[s])}e._renderer.render(t,{visualOnly:!0})}}getRestoreFunction(t,e,i){let s=this;return function(){let n=st(s.targetDef.item,t);if(s.targetDef.effect)for(let t of n)for(let e in s.targetDef.effect)t[e]=t.staticProperties[e];else for(let t of n)for(let e in t.staticProperties)t[e]=t.staticProperties[e];i&&(e._globalPredicates={}),e._renderer.render(t,{visualOnly:!0})}}get listener(){return this._listener}get selectionDef(){return this._selDef}get targetDef(){return this._targetDef}get eventType(){return this._eventType}}class Ce extends At{constructor(t){super(),t&&t.fillColor&&(this.fillColor=t.fillColor),this.type=I.Scene,this._id=this.type+_t[this.type]++,this.encodings={},this.constraints={},this._itemMap={},this._interactions=[]}clear(){this.removeAll(),this.encodings={},this.constraints={},this._itemMap={}}group(t){let e=new At;if(e.classId=e.id,this.addChild(e),t&&t.length>0)for(let i of t)e.addChild(i);return this._itemMap[e.id]=e,e}mark(t,e){let i=void 0===e?{}:e,s=null;switch(i.type=t,t){case I.Rect:{"top"in i||(i.top=0),"left"in i||(i.left=0),"width"in i||(i.width=100),"height"in i||(i.height=100);let t=i.top,e=i.left,n=i.width,r=i.height;i.vertices=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]],delete i.top,delete i.left,delete i.width,delete i.height,"fillColor"in i||(i.fillColor="none"),s=new Ft(i);break}case I.Area:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,e],[s,n],[t,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new te(i);break;case I.Line:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new X(i),s.type=I.Line;break;case I.Path:s=new X(i);break;case I.Circle:s=new Lt(i);break;case I.Ring:s=new ee(i);break;case I.Arc:s=new oe(i);break;case I.Polygon:s=new ie(i);break;case I.Pie:i.innerRadius=0,"radius"in i&&(i.outerRadius=i.radius),s=new oe(i);break;case"text":case I.PointText:"anchor"in i||(i.anchor=["center","middle"]),s=new Yt(i);break;case I.Image:s=new le(i);break;case I.Link:s=new he(i)}return null!==s&&(s.id="id"in i?i.id:s.type+_t[s.type]++,s.classId=s.id,this.addChild(s),this._itemMap[s.id]=s),s}glyph(...t){let e=new Qt(t);return e.classId=e.id,this.addChild(e),this._itemMap[e.id]=e,e}collection(){let t=new ae;return this.addChild(t),this._itemMap[t.id]=t,t}attach(t,e){t.dataScope=new Mt(e)}repeat(t,e,i){if(!t||void 0===e)throw W.INCOMPLETE_REPEAT_INFO;if(e.nodeTable&&e.linkTable){if(!Array.isArray(t)||2!==t.length)throw W.REPEAT_NODE_LINK;return function(t,e,i,s){let n=s.nodeTable.getFieldSummary(h).unique.map((t=>e.dataScope?e.dataScope.cross(h,t):new Mt(s.nodeTable).cross(h,t))),r=t.collection(),a={};r.dataScope=e.dataScope?e.dataScope.clone():new Mt(s.nodeTable),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}r.children.forEach(((t,e)=>{t.dataScope=n[e],a[t.dataScope.getFieldValue(h)]=t}));let o=s.linkTable.getFieldSummary(c).unique.map((t=>i.dataScope?i.dataScope.cross(c,t):new Mt(s.linkTable).cross(c,t))),l=t.collection();l.dataScope=i.dataScope?i.dataScope.clone():new Mt(s.linkTable),l.addChild(i);for(let t=1;t<o.length;t++){let t=i.duplicate();l.addChild(t)}l.children.forEach(((t,e)=>t.dataScope=o[e]));let d="tree"===s.type?"parent":"source",u="tree"===s.type?"child":"target";for(let t of l.children){let e=t.dataScope.getFieldValue(d),i=t.dataScope.getFieldValue(u);t.source=a[e],t.target=a[i],t._updateBounds()}return t.addChild(l),t.addChild(r),[r,l]}(this,t[0],t[1],e)}{let s=i||{},n=s.field?s.field:Ut.RowID,r=s.callback;It(n,e);let a=Rt(this,t,n,e,r);return s.layout&&(a.layout=s.layout),a}}repopulate(t,e,i){if(!t||void 0===e)throw W.INCOMPLETE_REPEAT_INFO;let s=i||{},n=s.field?s.field:Ut.RowID;It(n,e),me(this,t,n,e)}densify(t,e,i){if(!t||void 0===e)throw W.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:Ut.RowID,a="startAngle"in s?s.startAngle:90,o="direction"in s?s.direction:"clockwise",l=s.callback;return It(r,e),Pt(this,t,n,r,e,l,a,o)}stratify(t,e,i){if(!(e instanceof be))throw W.STRATIFY_WITHOUT_TREE;if(t.type!==I.Circle&&t.type!==I.Rect)throw W.STRATIFY_WRONG_ITEM;let s=i||{};return xe(this,t,s.direction,s.size,e)}divide(t,e,i){if(!t||null==e)throw W.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:Ut.RowID,a=s.callback;It(r,e);let o=Bt(this,t,n,r,e,a);return s.layout&&(o.layout=s.layout),ge(t,o),o}_validateEncodeArgs(t,e){if(!t||!("channel"in e)||!("field"in e))throw W.INCOMPLETE_BINDING_INFO;let i=e.field;if("vertex"==t.type||"segment"==t.type){if(!t.parent.dataScope&&!t.dataScope)throw W.BIND_WITHOUT_DATASCOPE}else if(!t.dataScope)throw W.BIND_WITHOUT_DATASCOPE;It(i,e.table?e.table:t.dataScope?t.dataScope._dt:t.parent.dataScope._dt)}encode(t,e){let i;if(this._validateEncodeArgs(t,e),"vertex"==t.type&&t.parent.type==I.Area){let e=st(t.parent,this);i=[];let s=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;for(let t of e)i=s?i.concat(t.vertices.slice(0,t.vertices.length/2)):i.concat(t.vertices.slice(t.vertices.length/2))}else i=st(t,this);return this._doEncode(i,e)}_doEncode(t,e){let i=t[0],s=e.channel,n=e.field;"datatable"in e||(e.datatable=i.dataScope?i.dataScope.dataTable:i.parent.dataScope.dataTable),"aggregator"in e||(e.aggregator="sum"),"flipScale"in e||(e.flipScale=!1),"includeZero"in e||(e.includeZero=!1),"scaleType"in e||(e.scaleType="linear");let r=new Vt(t,this,s,n,e);switch(s){case"width":case"height":case"radius":case"outerRadius":case"innerRadius":case"area":case"fontSize":i.type==I.Area?jt(r):Dt(r);break;case"strokeWidth":i.type==I.Link?function(t){t._query=function(){let t=this.field,e=this.channel,i=this.items.map((t=>t.dataScope));if("strokeWidth"==e)if(this.datatable.hasField(t))this.data=i.map((e=>e.getFieldValue(t)));else if(t.startsWith("parent.")||t.startsWith("child.")){let e=this.datatable.tree.nodeTable,s=t.split(".")[0],n=t.split(".")[1],r=i.map((t=>t.getFieldValue(s)));this.data=r.map((t=>new Mt(e).cross(h,t).getFieldValue(n)))}},t._map=function(){let t,e=this.channel,i=this.items;if("strokeWidth"==e){let e,s;t=dd(this.scaleType),t.domain=[0,Math.max(...this.data)],e=1,s=Math.max(...i.map((t=>parseFloat(t.styles.strokeWidth)))),s==e&&(s=e+5),this.rangeExtent&&(s=e+this.rangeExtent),this.range&&(e=this.range[0],s=this.range[1]),t._setRange([e,s]),this.scale||(this.scale=t),this.scale._addEncoding(this)}},t._apply=function(){if("strokeWidth"==this.channel)for(let t=0;t<this.data.length;t++)this.items[t].styles.strokeWidth=this.scale.map(this.data[t])},t.run()}(r):Dt(r);break;case"x":case"y":i.type==I.Area?jt(r):function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case O.Boolean:break;case O.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case O.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t,e,i,s,n,r=this.channel,a=this.datatable.getFieldType(this.field),o=nt(this.anyItem);if(o&&o.type==b.Grid){let e=o.cellBounds;t="x"==r?e[0].width:e[0].height}else{let e=this.items.map((t=>t[r]));t=Math.max(...e)-Math.min(...e),t<100?t=100:t>500&&(t=500)}switch(this.rangeExtent&&(t=this.rangeExtent),a){case O.Boolean:break;case O.Date:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=s.concat(this.scale.domain);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=dd("time"),this.scale.isFlipped=this._flipScale,n=[0,t];break;case O.String:if(s=Array.from(new Set(this.data)),n=[0,t],this.scale){let t=this.scale.domain;for(let e of s)t.indexOf(e)<0&&t.push(e);s=t,n=this.scale.range}else this.scale=dd("point"),this.scale.isFlipped=this._flipScale,n=[0,t];break;default:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=s.concat(this.scale._scale.domain());s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=dd(this.scaleType),this.scale.isFlipped=this._flipScale,this.scale.includeZero=this._includeZero,n=[0,t];s[0]==s[1]&&(s[1]=1.1*s[0])}this.scale._scale.domain(s),this.scale._setRange(n),this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);if("x"==e){let i=nt(this.anyItem);if(i&&i.type==b.Grid)for(let t=0;t<this.items.length;t++){let i=this.items[t],s=rt(i).left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){let t=ht(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t[e]))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n)}}}else{let i=nt(this.anyItem);if(i&&i.type==b.Grid){let t=this.items.map((t=>rt(t)));for(let i=0;i<this.items.length;i++){let s=this.items[i],n=0,r=t[i].bottom-this.scale.map(this.data[i])-s[e];s._doTranslate(n,r),"vertex"!=s.type&&"segment"!=s.type||s.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n)}}}},t.run()}(r);break;case"fillColor":case"strokeColor":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case O.Boolean:this.data=[!0,!1];break;case O.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case O.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){switch(this.datatable.getFieldType(this.field)){case O.Boolean:if(!this.scale&&(this.scale=dd("ordinalColor"),this.scale.domain=this.data,this._mapping)){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;case O.String:if(this.scale)this.scale.domain=Array.from(new Set(this.scale.domain.concat(this.data)));else if(this.scale=dd("ordinalColor",this._scheme?this._scheme:"schemeCategory10"),this.scale.domain=this.data,this._mapping){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;default:if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=dd("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=dd("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=dd("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}}this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);"vertex"==e.type||"segment"==e.type?e[this.channel]=i:e.styles[this.channel]=i,e.vertices&&"strokeColor"==this.channel&&e.vertices.forEach((t=>t.fillColor=i))}},t.run()}(r);break;case"angle":!function(t){t._query=function(){this.data=[],this.id2data={};let t=this.field,e=this.items;switch(this.datatable.getFieldType(t)){case O.Boolean:break;case O.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case O.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator)))}for(let t=0;t<this.data.length;t++)this.id2data[e[t].id]=this.data[t]},t._map=function(){this.scale||(this.scale=dd("linear"),this.scale.domain=this.datatable.tree?[0,Math.max(...this.data)]:[0,this.data.reduce(((t,e)=>t+e),0)],this.scale._setRange([0,360]),this.scale._addEncoding(this))},t._apply=function(){let t;for(let e=0;e<this.items.length;e++)t=this.items[e],t.type!==I.Arc&&t.type!==I.Pie||t.adjustAngle(t.startAngle,Ot(t.startAngle+this.scale.map(this.data[e])));this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"text":!function(t){t._query=function(){this.data=[];let t,e,i=this.items;if(this.field.startsWith("parent.")||this.field.startsWith("child.")){e=this.datatable.tree.nodeTable,t=this.field.split(".")[1];let s=this.field.split(".")[0],n=i.map((t=>t.dataScope)).map((t=>t.getFieldValue(s)));e.getFieldType(t)==O.Integer||e.getFieldType(t)==O.Number?this.data=n.map((i=>new Mt(e).cross(h,i).aggregateNumericalField(t))):this.data=n.map((i=>new Mt(e).cross(h,i).getFieldValue(t)))}else e=this.datatable,t=this.field,e.getFieldType(t)==O.Integer||e.getFieldType(t)==O.Number?this.data=i.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator))):this.data=i.map((e=>e.dataScope.getFieldValue(t)))},t._map=function(){if(this.scale);else switch(this.datatable.getFieldType(this.field)){case O.Boolean:case O.Date:break;case O.String:default:this.scale=dd("ordinal"),this.scale.domain=[...new Set(this.data)],this.scale._scale.range(this.scale.domain.map((t=>t+"")))}},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.text=i}},t.run()}(r);break;case"radialDistance":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case O.Boolean:break;case O.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case O.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t=this.data;this.scale||(this.scale=dd("linear"),this.scale.domain=[0,Math.max(...t)],this.scale._setRange([0,this.anyItem.parent.radius])),this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]),s=kt(this.anyItem.parent.x,this.anyItem.parent.y,i,e.polarAngle);e.x=s[0],e.y=s[1]}this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"thickness":!function(t){t._query=function(){this.data={};let t=this.field,e=this.items,i=e.map((t=>t.dataScope));switch(this.datatable.getFieldType(t)){case O.Boolean:break;case O.Date:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t);break;case O.String:try{for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].aggregateNumericalField(t,this.aggregator)}},t._map=function(){let t=this.data;if(!this.scale){this.scale=dd(this.scaleType),this.scale.domain=[0,Math.max(...Object.values(t))];let e=1,i=this.rangeExtent?e+this.rangeExtent:Math.max(...this.items.map((t=>t.outerRadius)));this.scale._setRange([e,i])}this.scale._addEncoding(this)},t._apply=function(){this.items.sort(((t,e)=>(t.innerRadius+t.outerRadius)/2-(e.innerRadius+e.outerRadius)/2));let t={item:new oe({outerRadius:0,startAngle:0,endAngle:360}),children:[]};for(let e of this.items)ye(t,e);for(let e of t.children)ve(e,e.item.innerRadius,this.data,this.scale)},t.run()}(r)}return"_remember"in e&&1!=e._remember||this._registerBinding(r),s.indexOf("Color")<0&&this._updateAncestorBounds(i,r.items),r}encodeWithinCollection(t,e){this._validateEncodeArgs(t,e);let i=function(t,e){let i={},s=st(t,e);for(let t of s){let e=t.parent.id;e in i||(i[e]=[]),i[e].push(t)}return Object.keys(i).map((t=>i[t]))}(t,this),s=[];for(let t of i){let i=this._doEncode(t,e);s.push(i)}return s}getPeers(t){return st(t,this)}find(t){return tt(this,t)}align(t,e){if(!function(t,e,i){if(e==E.Top||e==E.Bottom||e==E.Middle){for(let e of t)if(!yt(e,i))return!1;return!0}if(e==E.Left||e==E.Right||e==E.Center){for(let e of t)if(!mt(e,i))return!1;return!0}}(t,e,this))return!1;let i=new se(t,e);if(i.id in this.constraints)return console.warn("constraint has been added"),!1;this.constraints[i.id]=i,i.apply(),this._updateAncestorBounds(t[0])}removeAllConstraints(){this.constraints={}}affix(t,e,i,s){let n=s||{},r="offset"in n?n.offset:0,a="itemAnchor"in n?n.itemAnchor:"x"==i||"angle"==i?"center":"middle",o="baseAnchor"in n?n.baseAnchor:"x"==i||"angle"==i?"center":"middle",l=new ne(t,e,this,i,a,o,r);l.id,this.constraints,this.constraints[l.id]=l,l.apply()}axis(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(s){s.datatable.getFieldType(e)!==O.Date||"labelFormat"in n||(n.labelFormat="%m/%d/%y");let t=new Zt(s,n.item?n.item:s.anyItem,n);return"tickValues"in n?(t.tickValues=n.tickValues,t.labelValues=n.tickValues):(t.tickValues=s._inferTickValues(),t.labelValues=s._inferTickValues()),this.addChildAt(t,0),this._itemMap[t.id]=t,this._updateBounds(),t}let r=n.item?n.item:tt(this,[{field:e}])[0];void 0===r&&console.warn(z+e);let a=nt(r);if(a&&(a.type===b.Grid||a.type===b.Stack)){if(a&&("x"==t||"y"==t)){let i,s,r=st(a.group,this);for(let a of r){let r=tt(a,[{field:e}])[0],o=st(r,a);r.dataScope.dataTable.getFieldType(e)!==O.Date||"labelFormat"in n||(n.labelFormat="%m/%d/%y"),i=new Kt(o,a.layout,t,e,n),null==s&&(s=i.id),i.classId=s,this.addChildAt(i,0),this._itemMap[i.id]=i}return this._updateBounds(),i}console.warn(z+e)}}getRelatedAxes(t){let e=[];if(ft(t))return e;for(let i of this.children){if(i.type!==I.Axis)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ct(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}removeItem(t){if(!ft(t)){let e=this.getRelatedEncodings(t);for(let t of e)this.removeEncoding(t);let i=this.getRelatedAxes(t);for(let t of i)this.removeItem(t);for(let e of this.getRelatedGridlines(t))this.removeItem(e)}delete this._itemMap[t.id],this.removeChild(t),this._updateBounds()}getRelatedEncodings(t){let e=[],i=t;for(;i;)if(e.push(lt(i)),i.type==I.Collection)i=i.firstChild;else if(i.type==I.Glyph){for(let t of i.children)e.push(lt(t));i=void 0}else i=void 0;let s=Object.keys(this.encodings),n=[];for(let t of s){let i=t.split("_")[0];if(e.indexOf(i)>=0)for(let e in this.encodings[t])n.push(this.encodings[t][e])}return n}removeAllEncodings(){this.encodings={},this.removeAllItemsByType(I.Axis),this.removeAllItemsByType(I.Legend),this.removeAllItemsByType(I.Gridlines)}removeEncoding(t){let e=lt(t.anyItem);delete this.encodings[e][t.channel];let i=[];for(let e of this.children)ft(e)&&e.encoding&&e.encoding===t&&i.push(e);for(let t of i)this.removeItem(t);this._updateBounds()}removeAllItemsByType(t){let e=[];for(let i of this.children)i.type===t&&e.push(i);for(let t of e)this.removeItem(t);this._updateBounds()}reCreateRelatedAxes(t){this.getRelatedAxes(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),delete e.tickValues,delete e.labelValues,this.removeItem(t),this.axis(t.channel,t.field,e)})),this._updateBounds()}reCreateRelatedLegends(t){this.getRelatedLegends(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),this.removeItem(t),this.legend(t.channel,t.field,e)})),this._updateBounds()}legend(t,e,i){let s=i||{},n=this.getEncodingByField(e,t);if(!n)throw W.INCORRECT_LEGEND_INFO+e;"x"in s||(s.x=100),"y"in s||(s.y=100);let r=new Xt(n,s);return this.addChild(r),this._itemMap[r.id]=r,this._updateBounds(),r}gridlines(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(!s)return!1;let r=new re(s,n.item?n.item:s.anyItem,n);return r.values="values"in n?n.values:s._inferTickValues(),this.addChildAt(r,0),this._itemMap[r.id]=r,this._updateBounds(),r}getRelatedLegends(t){let e=[];if(ft(t))return e;for(let i of this.children)i.type===I.Legend&&i.matches(t)&&e.push(i);return e}getRelatedGridlines(t){let e=[];if(ft(t))return e;for(let i of this.children){if(i.type!==I.Gridlines)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ct(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}propagate(t,e,...i){let s=st(t,this);for(let t of s)t[e](...i)}classify(t,e,i){let s,n={},r=t[0].parent;for(let i of t){let t=i.dataScope.getFieldValue(e);t in n||(n[t]=[]),n[t].push(i)}let a=[],o=t[0].dataScope._dt;for(let t in n){let r=this.collection();i.addChild(r),void 0===s&&(s=r.id),r.classId=s,r.dataScope=new Mt(o).cross(e,t);for(let e of n[t])r.addChild(e);a.push(r)}return 0===r.children.length&&r.parent.removeChild(r),a}getEncodingByItem(t,e){let i=this.encodings[lt(t)];return i&&i[e]?i[e]:null}getEncodingByField(t,e){for(let i in this.encodings){let s=this.encodings[i];if(s[e]&&s[e].field==t)return s[e]}return null}positionBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(!gt(t))return null;for(let i in this.encodings){if(i.split("_")[0]===t.classId&&e in this.encodings[i])return this.encodings[i][e]}}sizeBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(gt(t)){let i="width"===e||"height"===e||"radius"===e?["area"]:["width","height"],s="width"===e?["x"]:"height"===e?["y"]:["x","y"];for(let e in this.encodings){let n=e.split("_")[0];if(e.indexOf("_")<0){for(let s of i)if(n===t.classId&&s in this.encodings[e])return this.encodings[e][s]}else for(let i of s)if(n===t.classId&&i in this.encodings[e])return this.encodings[e][i]}}return null}setProperties(t,e){let i,s={};for(let t in e)s[t]=!0;if(Object.values(b).indexOf(t.type)>-1&&t.group){i=st(t.group,this);for(let t of i)for(let i in e)t.layout[i]=e[i]}else if(i=st(t,this),"vertex"===t.type)for(let t of i)for(let i in e)t[i]=e[i];else if(t instanceof J)for(let n in e)if("x"!==n&&"y"!==n||!this.positionBound(t,n))if("width"!==n&&"height"!==n&&"radius"!==n||!this.sizeBound(t,n))t.type!==I.Rect&&t.type!==I.Line||"width"!==n&&"height"!==n?t.type==I.Circle&&"radius"==n?i.forEach((t=>t.resize(2*e[n],2*e[n],e.xRef,e.yRef))):i.forEach((t=>t[n]=e[n])):"width"===n?i.forEach((t=>t.resize(e[n],t.bounds.height,e.xRef))):i.forEach((t=>t.resize(t.bounds.width,e[n],void 0,e.yRef)));else{let i=this.getEncodingByItem(t,n);i||"radius"!=n||(i=this.getEncodingByItem(t,"area"));let s=i.scale.rangeExtent*e[n]/t[n];i.scale.rangeExtent=s}else s[n]=!1;else if("collection"==t.type||"group"==t.type)for(let t of i)for(let i in e)t[i]="layout"===i&&void 0!==e[i]?e[i].clone():e[i];let n=Object.keys(s).filter((t=>s[t])),r=["width","height","fontSize","area","radius"];for(let e of r)if(n.indexOf(e)>=0&&pt(t)){pe(t,i);break}n.indexOf("baseline")>=0&&t.type===I.Area&&_e(t,i);let a=["layout","rowGap","colGap","numRows","numCols","vertCellAlignment","horzCellAlignment"];for(let t of a)if(n.indexOf(t)>=0){let t=n.indexOf("numRows")>=0||n.indexOf("numCols")>=0||n.indexOf("layout")>=0;de(i[0],i,t);break}return s}_canTranslate(t){let e={x:!0,y:!0};return t.type==I.Axis?("x"===t.channel||"width"===t.channel?e.x=!1:"y"!==t.channel&&"height"!==t.channel||(e.y=!1),e):(t.parent.type===I.Collection&&t.parent.layout&&(e.x=!1,e.y=!1),this.positionBound(t,"x")&&(e.x=!1),this.positionBound(t,"y")&&(e.y=!1),e)}translate(t,e,i){let s=this._canTranslate(t);if(!s.x&&!s.y)return s;const n=s.x?e:0,r=s.y?i:0;return t._doTranslate(n,r),this._updateAncestorBounds(t),ce(t,n,r),s}_updateAncestorBounds(t,e){let i=ht(e||st(t,this));for(;i.length>0;){for(let t of i)(t.children&&t.children.length>0||t.vertices)&&t._updateBounds();i=ht(i)}}_reapplyConstraints(t){let e=t,i=[t];for(;e.children;)e.type==I.Collection?i.push(e.firstChild):i=i.concat(e.children),e=e.firstChild;for(e=t.parent;e&&e.type!==I.Scene;)i.push(e),e=e.parent;const s=i.map((t=>t.classId));for(let t in this.constraints){const e=this.constraints[t];switch(e.type){case T:(s.indexOf(e.item.classId)>=0||s.indexOf(e.baseItem.classId)>=0)&&e.apply();break;case A:for(let t of e.items)if(s.indexOf(t.classId)>=0){e.apply();break}}}}_relayoutAncestors(t,e){let i=ht(e||st(t,this));for(;i.length>0;){for(let t of i)t.layout&&t.layout.run(),t.children&&t.children.length>0&&t._updateBounds(),t.vertices&&t._updateBounds();i=ht(i)}}_reapplySizeBindings(t){let e=["width","height"];for(let i in this.encodings){if(t.classId!=i)continue;let s=this.encodings[i],n=tt(this,[{classId:i}]);for(let t of e){let e=s[t];e&&e.run()}this._relayoutAncestors(n[0],n)}}_registerBinding(t){let e=this.encodings,i=lt(t.anyItem);return i in e||(e[i]={}),e[i][t.channel]=t,!0}toJSON(){let t=super.toJSON();this.fillColor&&(t.fillColor=this.fillColor);let e={};t.encodings=[],t.itemCounter=_t;for(let i in this.encodings)for(let s in this.encodings[i]){let n=this.encodings[i][s];t.encodings.push(n.toJSON()),n.scale&&!(n.scale.id in e)&&(e[n.scale.id]=n.scale.toJSON())}t.scales=e,t.constraints={};for(let e in this.constraints)t.constraints[e]=this.constraints[e].toJSON();t.tables={};let i=this.getDataTables();for(let e in i)t.tables[e]=i[e].toJSON();return t}getDataTables(){let t={};for(let e in this.encodings)for(let i in this.encodings[e]){let s=this.encodings[e][i];s.datatable.id in t||(t[s.datatable.id]=s.datatable)}for(let e of this.children)if(!ft(e)){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}if(e.children&&e.children.length>0){let i=e.firstChild;for(;i;){if(i.dataScope){t[i.dataScope.dataTable.id]=i.dataScope.dataTable;break}i=i.children&&i.children.length>0?i.firstChild:void 0}}}return t}getItem(t){let e=t.split("_")[0];if(t.indexOf("_v_")>0){let i=parseInt(t.split("_v_")[1]);return this._itemMap[e].vertices.find((t=>t._id===i))}if(t.indexOf("_s_")>0){let i=parseInt(t.split("_s_")[1]);return this._itemMap[e].segments.find((t=>t._id===i))}return this._itemMap[t]}addInteraction(t,e,i,s){let n=new Se(t,e,i,s);this._interactions.push(n)}}class Ee{constructor(t){this._renderer=t,this._globalPredicates={}}processInteraction(t,e){let i=t.listener;if(pt(i)){let s=i.classId?"."+i.classId:"#"+i.id;switch(t.eventType){case"hover":r.selectAll(s).on("mouseover",t.getCallbackFunction(e,this)),r.selectAll(s).on("mouseleave",t.getRestoreFunction(e,this));break;case"click":r.selectAll(s).on("mousedown",t.getCallbackFunction(e,this))}}else if(i.type==I.Scene){if(!t.targetDef||!t.targetDef.item)return;t.selectionDef.item||r.select("#"+this._renderer._svgId).on("mousedown",t.getRestoreFunction(e,this,!0))}}_getSelection(t,e,i,s){let n={};s?n.item=s:e.item;let r=e.field?e.field:c;return n.item&&(n.predicate={field:r,value:n.item.dataScope.getFieldValue(r)}),n}addGlobalPredicate(t,e){t.id in this._globalPredicates||(this._globalPredicates[t.id]={}),this._globalPredicates[t.id][e.field]=e}getGlobalPredicates(t){return t.id in this._globalPredicates?Object.values(this._globalPredicates[t.id]):[]}}class Ae{constructor(t){this._svgId=t,this._compMap={},this._decoMap={},this._interactionHandler=new Ee(this)}render(t,e){let i=e||{};for(let t in this._decoMap)this._decoMap[t].remove(),delete this._decoMap[t];this._removed={};for(let t in this._compMap)this._removed[t]=1;this._renderItem(t,i);for(let t in this._removed)this._compMap[t].remove(),delete this._compMap[t];if(!("visualOnly"in i))for(let e of t._interactions)this._interactionHandler.processInteraction(e,t)}clear(){let t=document.getElementById(this._svgId);for(;t.firstChild;)t.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(t,e){let i,s=t.id,n=t.parent;i=n&&n.id&&n.id in this._compMap?r.select("#"+this._svgId).select("#"+n.id):r.select("#"+this._svgId),s in this._compMap?delete this._removed[s]:this._compMap[s]=i.append(this._getSVGElementType(t)),t.type==I.Gridlines&&this._compMap[s].lower();let a=this._compMap[s];if(a.attr("id",s),t.classId&&a.attr("class",t.classId),t.type==I.Scene&&r.select("#"+this._svgId).style("background",t.fillColor?t.fillColor:"#fff"),"vertex"!=t.type){if(t.type==I.Path||t.type==I.Polygon||t.type==I.Link)a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==I.Line)a.attr("x1",t.vertices[0].x),a.attr("y1",t.vertices[0].y),a.attr("x2",t.vertices[1].x),a.attr("y2",t.vertices[1].y),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==I.Circle)a.attr("cx",t.x),a.attr("cy",t.y),a.attr("r",t.radius);else if(t.type==I.Rect){let e=t.bounds;a.attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height)}else t.type==I.PointText?a.attr("text-anchor",this._getTextAnchor(t.anchor[0])).attr("alignment-baseline",this._getTextAnchor(t.anchor[1])).attr("dominant-baseline",this._getTextAnchor(t.anchor[1])).text(t.text).attr("x",t.x).attr("y",t.y):t.type==I.Pie||t.type==I.Area?(a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges")):t.type==I.Ring||t.type==I.Arc?a.attr("d",t.getSVGPathData()):t.type==I.Image&&a.attr("href",t.src).attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height);for(let e in t.styles)if(void 0!==t.styles[e])if(e.indexOf("Color")>0&&t.styles[e].type==I.LinearGradient){r.select("#"+this._svgId).select("defs").empty()&&r.select("#"+this._svgId).append("defs");let i=r.select("defs"),s=t.styles[e];if(i.select("#"+s.id).empty()){let t=i.append("linearGradient").attr("id",s.id);t.attr("x1",s.x1+"%").attr("x2",s.x2+"%").attr("y1",s.y1+"%").attr("y2",s.y2+"%");for(let e of s.stops)t.append("stop").attr("offset",e.offset+"%").style("stop-color",e.color).style("stop-opacity",e.opacity)}a.style(V[e],"url(#"+s.id+")")}else a.style(V[e],t.styles[e]);if(t._rotate&&a.attr("transform","rotate("+t._rotate.join(" ")+")"),t.vertices&&this._renderVertices(t),t.type==I.Collection&&e&&e.collectionBounds){let e=t.bounds;t.layout&&"grid"==t.layout.type?this._renderLayout(t):(t.id in this._decoMap||(this._decoMap[t.id]=r.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[t.id].attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("fill","none").attr("stroke","#1ecb40").attr("stroke-width","2px").attr("stroke-dasharray","5,5"))}if(t.children)for(let i of t.children)this._renderItem(i,e)}}_renderVertices(t){let e=t.id+"-vertices";if(e in this._compMap)delete this._removed[e];else{let i=t.parent,s=i?i.id:this._svgId;this._compMap[e]=r.select("#"+s).append("g").attr("id",e)}if(0===t.vertices.map((t=>t.shape)).filter((t=>void 0!==t)).length)return void this._compMap[e].style("visible","hidden");this._compMap[e].style("visible","visible");let i=t.vertices.filter((t=>void 0!==t.shape));for(let t of i){let i=e+"-"+t.id;i in this._compMap?t.shape!==this._compMap[i].node().tagName?(this._compMap[i].remove(),this._compMap[i]=r.select("#"+e).append(t.shape).attr("id",i),delete this._removed[i]):delete this._removed[i]:this._compMap[i]=r.select("#"+e).append(t.shape).attr("id",i),"rect"==t.shape?r.select("#"+i).attr("x",t.x-t.width/2).attr("y",t.y-t.height/2).attr("width",t.width).attr("height",t.height):"circle"==t.shape&&r.select("#"+i).attr("cx",t.x).attr("cy",t.y).attr("r",t.radius),r.select("#"+i).style("fill",t.fillColor).style("opacity",t.opacity).style("stroke-width",t.strokeWidth).style("stroke",t.strokeColor)}}_renderLayout(t){let e=t.id+"-grid";e in this._decoMap||(this._decoMap[e]=r.select("#"+this._svgId).append("g").attr("id",e).attr("class","deco"));let i=t.layout.cellBounds,s=t.layout.rowGap;this._decoMap[e].selectAll("rect").remove(),this._decoMap[e].selectAll("rect").data(i.slice(0,i.length-1)).enter().append("rect").attr("x",(t=>t.left)).attr("y",(t=>t.bottom)).attr("width",(t=>t.width)).attr("height",s).style("fill","pink").style("opacity",.5);let n=Math.min(...i.map((t=>t.left))),a=Math.min(...i.map((t=>t.top)));this._decoMap[e].append("rect").attr("x",n).attr("y",a).attr("width",t.bounds.width).attr("height",t.bounds.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getTextAnchor(t){switch(t){case"top":return"text-before-edge";case"bottom":return"text-after-edge";case"left":return"start";case"right":return"end";case"center":case"middle":return"middle";default:return t}}_getSVGElementType(t){switch(t.type){case I.Rect:return"rect";case I.Collection:case I.Group:case I.Glyph:case I.Scene:case I.Axis:case I.Legend:case I.Gridlines:return"g";case I.Area:case I.Path:case I.Polygon:case I.Ring:case I.Pie:case I.Arc:case I.Link:return"path";case I.Circle:return"circle";case I.Line:return"line";case I.PointText:return"text";case"vertex":if("circle"==t.shape)return"circle";if("rect"==t.shape)return"rect";throw"argument exception";case"image":return"image"}}}class Te{constructor(t,e){switch(this._type=t,this._offset=void 0,this.id="scale"+_t.scale++,this._flipped=!1,this._includeZero=!1,t){case"linear":if(e){let t=Object.keys(e).map((t=>parseFloat(t))).sort(((t,e)=>t-e)),i=t.map((t=>e[t]));this._scale=r.scaleLinear(t,i),"clamp"in e&&this._scale.clamp(e.clamp),this._mapping=e}else 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(e&&"string"==typeof e?r[e]:r.schemeCategory10);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":case"divergingColor":e&&"string"==typeof e?(this._scale=r.scaleSequential(r[e]),this._scheme=e):this._scale=r.scaleSequential()}this.encodings=[]}set scheme(t){if(this._type.indexOf("Color")<0&&"linear"!==this._type)return;let e=r.scaleSequential(r[t]),i=this._scale.domain();if(Math.min(...i)*Math.max(...i)<0){let t=Math.max(Math.abs(Math.min(...i)),Math.abs(Math.max(...i)));i=[-t,t]}e.domain(i),this._scheme=t,this._scale=e,"linear"===this._type&&(this._type=this._scale.domain()[0]*this._scale.domain()[1]<0?"divergingColor":"sequentialColor",this._mapping&&(this._mapping=void 0));for(let e of this.encodings)e._mapping&&(e._mapping=void 0),e._scheme=t,e._apply()}get scheme(){return this._scheme}get type(){return this._type}set type(t){let e;switch(t){case"linear":e=r.scaleLinear();break;case"power":e=r.scalePow().exponent(2);break;case"sqrt":e=r.scalePow().exponent(.5);break;case"log":e=r.scaleLog()}if(e){this._type=t,e.domain(this._scale.domain()).range(this._scale.range()),this._scale=e;for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}else console.warn(G+t)}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.offset=this._offset,t.domain=this._scale.domain(),t.range=this.range,t.clamp=this.clamp,t.isFlipped=this.isFlipped,t.includeZero=this.includeZero,this._scheme&&(t.scheme=this._scheme),t}_merge(t){if(this.type!=t.type)throw W.DIFFERENT_SCALE_TYPE;let e,i;switch(this.type){case"linear":case"time":e=[Math.min(this.domain[0],t.domain[0]),Math.max(this.domain[1],t.domain[1])],i=[0,this.map(e[1])-this.map(e[0])];break;case"point":case"ordinalColor":e=[...new Set(this.domain.concat(t.domain))],i=[];break;default:console.log("TODO: merge scale type",this.type)}this._scale.domain(e),this._scale.range(i)}get domain(){if(this._includeZero){return[0,this._scale.domain()[1]]}return this._scale.domain()}set domain(t){this._scale.domain(t);for(let t of this.encodings)t._apply()}get range(){return this._scale.range()}
|
|
3
3
|
//to support this, the argument should be in real screen coordinates and need to do internal conversion
|
|
4
|
-
set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}_setRange(t){this._scale.range(t),de(this)}get clamp(){return"linear"==this.type&&this._scale.clamp()}set clamp(t){"linear"==this.type&&this._scale.clamp(t)}set rangeExtent(t){let e=this._scale.range();this._setRange([e[0],e[0]+t])}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}_addEncoding(t){this.encodings.indexOf(t)<0&&this.encodings.push(t)}map(t){let e=this._scale.copy();return e.domain(this.domain),this._flipped?(e.range(this._scale.range().reverse()),e(t)):e(t)}invert(t){return this._scale.invert(t)}get offset(){return this._offset}set offset(t){this._offset=t;for(let t of this.encodings)t._apply()}get isFlipped(){return this._flipped}set isFlipped(t){this._flipped=t}get includeZero(){return this._includeZero}set includeZero(t){this._includeZero=t,ce(this)}get mapping(){return this._mapping}getEncodedChannels(){let t={};for(let e of this.encodings)t[e.channel]=!0;return Object.keys(t)}}class Te extends G{constructor(t){super(t),this.type="packing",this.x="x"in t?t.x:400,this.y="y"in t?t.y:400,this.width=t.width,this.height=t.height}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this.x,t.args.y=this.y,t.args.width=this.width,t.args.height=this.height,t}clone(){return new Te({x:this.x,y:this.y,width:this.width,height:this.height})}run(){if(null==this.group)return;let t=this.group.children.map((t=>({name:t.id,radius:t.radius,itm:t}))),e=t.reduce(((t,e)=>t+Math.pow(e.radius,2)),0),i=Math.sqrt(e);void 0===this.width&&(this.width=i),void 0===this.height&&(this.height=i);let s=n.hierarchy({name:"root",children:t}).sum((t=>t.radius?t.radius:0)).sort(((t,e)=>e.value-t.value));n.pack().size([this.width,this.height]).radius((t=>t.value))(s);for(let t of s.children){let e=t.data.itm,i=this.x-s.x+t.x-e.x,n=this.y-s.y+t.y-e.y;e._doTranslate(i,n)}this.group._updateBounds()}}class Ae extends G{constructor(t){super(t),this.type="treemap",this._width=t.width,this._height=t.height,this._top=t.top,this._left=t.left}toJSON(){let t={args:{}};return t.type=this.type,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}clone(){return new Ae({})}run(){if(null==this.group||!this.group.children||0==this.group.children.length)return;let t=this._width?this._width:this.group.bounds.width,e=this._height?this._height:this.group.bounds.height,i=void 0===this._top?this.group.bounds.top:this._top,s=void 0===this._left?this.group.bounds.left:this._left,r=n.hierarchy(this.group).sum((t=>"rect"==t.type?t.bounds.width*t.bounds.height:0));n.treemap().size([t,e])(r),this._apply(r,s,i),this.group.getScene()._updateAncestorBounds(r.leaves()[0].data)}_apply(t,e,i){if("collection"==t.data.type&&t.children)for(let s of t.children)this._apply(s,e,i);else"rect"==t.data.type&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),t.data._doTranslate(t.x0+e-t.data.bounds.left,t.y0+i-t.data.bounds.top))}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get top(){return this._top}set top(t){this._top=t,this.run()}get left(){return this._left}set left(t){this._left=t,this.run()}}function Ie(t,e){let i=[t[0]],s=[e[0]];for(let n=1;n<e.length;n++){let r=!1,a=e[n];for(let e=0;e<s.length;e++){let o=s[e],h=new Set(a);if(o.forEach((t=>h.add(t))),h.size<a.length+o.length){s[e]=[...h],i[e]=i[e].concat(t[n]),r=!0;break}}r||(s.push(a),i.push(t[n]))}return{grouping:i,subgraphs:s}}class Oe{constructor(t,e){this._type="network",this._nodeTable=new Gt(t.nodes,"nodes"),this._linkTable=new Gt(t.links,"links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._nodes=t.nodes,this._links=t.links,this._name=e,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e.id]=e}get type(){return this._type}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodes(){return this._nodes}get links(){return this._links}getNode(t){return this._nodeHash[t]}getSources(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].target==i){e=s[t].source;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}getTargets(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].source==i){e=s[t].target;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}transform(t,e,i){switch(t){case"partition":return function(t){let e=t.nodes,i=t.links,s=i.map(((t,e)=>[e])),n=i.map((t=>[t.source,t.target])),r=Ie(s,n);for(;r.grouping.length!=s.length;)s=r.grouping,n=r.subgraphs,r=Ie(s,n);let a=[];for(let[t,s]of r.grouping.entries()){let n={nodes:[],links:[]};n.links=s.map((t=>i[t]));const o=r.subgraphs[t];n.nodes=e.filter((t=>o.indexOf(t.id)>=0)),a.push(new Oe(n))}return a}(this)}}isLinear(){let t={},e={};for(let i of this._links)i.source in e||(e[i.source]=0),i.target in t||(t[i.target]=0),e[i.source]++,t[i.target]++;for(let e in t)if(t[e]>1)return!1;for(let t in e)if(e[t]>1)return!1;return!0}}class Re extends G{constructor(t){super(t),this.type=y.TidyTree,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:b}toJSON(){let t={args:{}};return t.args.type=this.type,t.args.orientation=this._orientation,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt;if(!t.tree)throw z.LAYOUT_WITHOUT_TREE;{let e=n.hierarchy(t.tree._data),i=Math.max(...this.group.children.map((t=>t.bounds.width))),s=Math.max(...this.group.children.map((t=>t.bounds.height))),r=this._orientation==b?[this._height,this._width]:[this._width,this._height],a=n.tree().nodeSize([i,s]).size(r)(e);this._apply(a,this.group)}}_apply(t,e){let i,s,n=e.children.filter((e=>e.dataScope.getFieldValue(o)==t.data.id))[0];switch(this._orientation){case b:i=t.y+this._left,s=t.x+this._top;break;case v:i=t.x+this._left,s=this._top+t.y}if(n.x=i,n.y=s,t.children&&t.children.length>0)for(let i of t.children)this._apply(i,e)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get size(){return[this._width,this._height]}set size(t){this._width=t[0],this._height=t[1],this.run()}}class Me extends G{constructor(t){super(t),this.type=y.Force,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this._x,t.args.y=this._y,t.args.iterations=this._iterations,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt.graph;if(t){let e=t.links.map((e=>({source:t.getNode(e.source),target:t.getNode(e.target)}))),i=n.forceSimulation(t.nodes).force("charge",n.forceManyBody().strength(-this._repulsion)).force("link",n.forceLink(e).id((t=>t.id)).distance(this._linkDistance)).force("x",n.forceX()).force("y",n.forceY()).force("center",n.forceCenter(this._x,this._y).strength(this._attraction));i.stop(),i.tick(this._iterations);for(let e=0;e<this.group.children.length;e++)this.group.children[e].x=t.nodes[e].x,this.group.children[e].y=t.nodes[e].y}}}class Ne{constructor(){this.axes={},this.guideCmds=[],this.collectionCmds=[],this.glyphCmds=[],this.spec=[]}run(t){for(let e of t.children)switch(e.type){case T.Axis:{let t=e.classId?e.classId:e.id;this.axes[t]=e;break}case T.Gridlines:case T.Legend:{let t=e.toJSON();this.guideCmds.push({cmd:e.type,channel:t.channel,field:t.field,args:t.args});break}case T.Collection:case T.Group:case T.Glyph:{let i=[];this._analyze(e,i);for(let t=i.length-1;t>0;t--)for(let e of i[t].fields)i[t-1].fields.delete(e);for(let[e,s]of i.entries()){if(s.item instanceof q){let e={cmd:"mark",type:s.item.type,output:s.item,args:s.item.toJSON().args};this._inferMarkArgs(e,t),this.collectionCmds.push(e)}else if(s.item instanceof Kt)this.collectionCmds.push({cmd:"glyph",output:s.item,input:i.slice(0,e).map((t=>t.item)),args:{}});else if(s.item instanceof ne){let t=[...i[e-1].fields][0],n={cmd:"join",input:i[e-1].item,output:s.item,data:i[e-1].item.dataScope.dataTable.id,args:{field:t}};t==h&&delete n.field,this.collectionCmds.push(n)}s.item.dataScope&&0==s.item.dataScope.fields.length&&!s.item.parent.dataScope&&this.collectionCmds.push({cmd:"attach",input:s.item,data:s.item.dataScope.dataTable.id})}break}default:if(e instanceof q){let i={cmd:"mark",type:e.type,output:e,args:e.toJSON().args};this._inferMarkArgs(i,t),this.glyphCmds.push(i)}}this._inferJoin(),this._inferArgs(t);for(let t in this.axes){let e=this.axes[t].toJSON();this.guideCmds.push({cmd:e.type,channel:e.channel,field:e.field,args:e.args})}return this._generateFullSpec(t),this.spec}_inferJoin(){for(let t of this.collectionCmds){if("join"!=t.cmd)continue;let e=t.input,i=e.parent;switch(e.type){case T.Rect:i.layout&&i.layout.type==y.Stack?t.cmd="divide":t.cmd="repeat";break;default:t.cmd="repeat"}}}_inferArgs(t){for(let e of this.collectionCmds)switch(e.cmd){case"mark":this._inferMarkArgs(e,t);break;case"divide":this._inferDivideArgs(e,t)}}_inferDivideArgs(t){t.args.orientation=t.output.layout.orientation}_inferMarkArgs(t,e){let i=t.output,s=i.parent,n=et(i,e),r=et(s,e);switch(i.type){case T.Rect:s.layout&&s.layout.type==y.Grid?(t.args.width=s.layout.cellBounds[0].width,t.args.height=s.layout.cellBounds[0].height):s.layout&&s.layout.type==y.Stack?(t.args.width=Math.max(...r.map((t=>t.bounds.width))),t.args.height=Math.max(...r.map((t=>t.bounds.height)))):(t.args.width=Math.max(...n.map((t=>t.bounds.width))),t.args.height=Math.max(...n.map((t=>t.bounds.height)))),t.args.left=Math.min(...n.map((t=>t.bounds.left))),t.args.top=Math.min(...n.map((t=>t.bounds.top)));break;case T.Line:t.args.x1=Math.min(...n.map((t=>t.vertices[0].x))),t.args.y1=Math.min(...n.map((t=>t.vertices[0].y))),t.args.x2=Math.min(...n.map((t=>t.vertices[1].x))),t.args.y2=Math.min(...n.map((t=>t.vertices[1].y)));break;case T.Arc:t.args.x=i.x,t.args.y=i.y,t.args.innerRadius=i.innerRadius,t.args.outerRadius=i.outerRadius}for(let e in i.styles)t.args[e]=i.styles[e]}_analyze(t,e){if(t instanceof Kt)for(let i of t.children)this._analyze(i,e);else t instanceof St&&this._analyze(t.firstChild,e);let i={type:t.type,item:t};t.dataScope?i.fields=new Set(t.dataScope.fields):i.fields=new Set,e.push(i)}_generateFullSpec(t){this.spec=[],this.spec.push({cmd:"scene",args:{fillColor:t.fillColor}});let e=t.getDataTables(),i={},s=[];for(let t in e){let n=e[t];if(n.sourceDataTable)for(;n.sourceDataTable;)s.push({cmd:"transform",type:n.transform.type,args:n.transform.args,input:n.sourceDataTable.id,output:n.id}),n=n.sourceDataTable;n.id in i||(i[n.id]={cmd:"data",url:n.url,output:n.id})}this.spec=this.spec.concat(Object.values(i)),this.spec=this.spec.concat(s);let n=[];for(let t of this.collectionCmds){let e;t.output&&t.output.layout&&(e={cmd:"layout",type:t.output.layout.type,input:t.output.id,args:t.output.layout.toJSON().args}),this.spec.push(t),t.output&&t.output.childrenOrder&&n.push({cmd:"sortChildren",args:t.output.childrenOrder,input:t.output.id}),e&&this.spec.push(e),t.input&&Array.isArray(t.input)?t.input=t.input.map((t=>t.classId?t.classId:t.id)):t.input&&(t.input=t.input.classId?t.input.classId:t.input.id),t.output&&(t.output=t.output.classId?t.output.classId:t.output.id)}let r={},a=[];for(let e in t.encodings)for(let i in t.encodings[e]){let s=t.encodings[e][i];s.scale&&!(s.scale.id in r)&&(r[s.scale.id]=s.scale.toJSON());let n=s.toJSON().args;n.field=s.field,n.channel=s.channel,delete n.datatable,a.push({cmd:"encode",input:at(s.anyItem),scale:s.scale.id,args:n})}for(let t in r){let e=r[t];e.cmd="scale",this.spec.push(e)}this.spec=this.spec.concat(a),this.spec=this.spec.concat(n);for(let e in t.constraints){let i=t.constraints[e],s={cmd:"constraint",type:i.type,args:{}};switch(i.type){case E:s.item=i.item.classId?i.item.classId:i.item.id,s.baseItem=i.baseItem.classId?i.baseItem.classId:i.baseItem.id,s.channel=i.channel,s.args.itemAnchor=i.itemAnchor,s.args.baseAnchor=i.baseAnchor,s.args.offset=i.offset;break;case S:s.items=i.items.map((t=>t.classId?t.classId:t.id)),s.anchor=i.anchor}this.spec.push(s)}for(let t of this.guideCmds)this.spec.push(t);for(let t of this.glyphCmds)t.output&&(t.output=t.output.classId?t.output.classId:t.output.id),this.spec.push(t)}}class Fe{constructor(){this.axes={},this.legends=[],this.gridlines=[],this.scales={},this.tables={}}load(t){let e={};if(t.fillColor&&(e.fillColor=t.fillColor),t.itemCounter)for(let e in t.itemCounter)pt[e]=t.itemCounter[e];let i=qc(e);if(i.id=t.id,i.type=t.type,t.bounds&&(i._bounds=new a(t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height)),t.tables)for(let e in t.tables)this.tables[e]=new Gt(t.tables[e].data,t.tables[e].url,t.tables[e].fieldTypes),this.tables[e].id=t.tables[e].id;for(let e of t.children)this._processItem(i,e,i);if(t.scales)for(let e in t.scales)this._loadScale(t.scales[e],i);if(t.encodings)for(let e of t.encodings)this._loadEncoding(e,i);if(t.constraints)for(let e in t.constraints)this._loadConstraint(t.constraints[e],i);for(let t in this.axes)this._createGuide(i,this.axes[t]);for(let t of this.legends)this._createGuide(i,t);for(let t of this.gridlines)this._createGuide(i,t);return i}_loadScale(t){let e;"sequentialColor"===t.type&&t.scheme?e=Jc(t.type,t.scheme):(e=Jc(t.type),e.range=t.range),e.domain="time"==t.type?t.domain.map((t=>new Date(t))):t.domain,e.id=t.id,"offset"in t&&(e.offset=t.offset),e.isFlipped=t.isFlipped,e.clamp=t.clamp,"includeZero"in t&&(e.includeZero=t.includeZero),this.scales[e.id]=e}_loadEncoding(t,e){t.args.datatable&&(t.args.datatable=this.tables[t.args.datatable]),t.args.scale&&(t.args.scale=this.scales[t.args.scale]);let i=t.items.map((t=>e.getItem(t)));e._doEncode(i,t.args)}_createGuide(t,e){switch(e.type){case T.Axis:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.axis(e.channel,e.field,e.args);break;case T.Legend:t.legend(e.channel,e.field,e.args);break;case T.Gridlines:t.gridlines(e.channel,e.field,e.args)}}_processItem(t,e,i){switch(e.type){case T.Axis:{let t=e.classId?e.classId:e.id;e.args.tickValues&&e.args.isDate&&(e.args.tickValues=e.args.tickValues.map((t=>new Date(t)))),this.axes[t]=e;break}case T.Gridlines:e.args.values&&e.args.isDate&&(e.args.values=e.args.values.map((t=>new Date(t)))),this.gridlines.push(e);break;case T.Legend:this.legends.push(e);break;case T.Collection:{let s=i.collection();t.addChild(s),this._loadGroup(s,e,i);break}case T.Group:{let s=i.group();t.addChild(s),this._loadGroup(s,e,i);break}case T.Glyph:{let s=i.glyph();t.addChild(s),this._loadGroup(s,e,i);break}default:this._loadMark(t,e,i)}}_loadConstraint(t,e){switch(t.type){case"affixation":{let i=e.getItem(t.item),s=e.getItem(t.baseItem),n=new ie(i,s,e,t.channel,t.itemAnchor,t.baseAnchor,t.offset);return n.id=t.id,e.constraints[t.id]=n,n.apply(),n}case"alignment":{let i=t.items.map((t=>e.getItem(t))),s=new ee(i,t.direction);return s.id=t.id,e.constraints[t.id]=s,s.apply(),s}}}_loadDataScope(t){let e=new It(this.tables[t.dt]);for(let i in t.f2v)e._field2value[i]=t.f2v[i],e._updateTuples(i,t.f2v[i]);return e}_loadGroup(t,e,i){if(t.id=e.id,e.classId&&(t.classId=e.classId),e.dataScope&&(t.dataScope=this._loadDataScope(e.dataScope)),e.children)for(let s of e.children)this._processItem(t,s,i);if(e.layout){let i=this._loadLayout(e.layout);i.group=t,t._layout=i}e.bounds&&(t._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height))}_loadMark(t,e,i){if(e.args.fillColor&&"LinearGradient"===e.args.fillColor.type){let t=e.args.fillColor;e.args.fillColor=Hc(t),e.args.fillColor.id=t.id,e.args.fillColor._stops=t.stops}"id"in e&&(e.args.id=e.id);let s=i.mark(e.type,e.args);if(e.classId&&(s.classId=e.classId),e.dataScope&&(s.dataScope=this._loadDataScope(e.dataScope)),e.vertices){const t=[];for(let i of e.vertices){const e=H.fromJSON(i,s);e.dataScope&&(e.dataScope=this._loadDataScope(e.dataScope)),t.push(e)}s.vertices=t,s.segments=[];for(let t=1;t<s.vertices.length;t++)s.segments.push(new $(s.vertices[t-1],s.vertices[t],s,s.segmentCounter++))}e.bounds&&(s._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height)),ft(s)?(s.vertexCounter=e.vertexCounter,s.segmentCounter=e.segmentCounter,s.curveMode=e.curveMode):e.type===T.Image&&(s.src=e.src,s.width=e.width,s.height=e.height,s.x=e.x,s.y=e.y),t.addChild(s)}_loadLayout(t){let e=Yc(t.type,t.args);switch(t.type){case y.Grid:e._left=t.left,e._top=t.top}return e}}class Pe{constructor(){}async run(t){let e,i,s={},n={},r={};for(let a of t)switch(a.cmd){case"scene":e=qc(a.args);break;case"data":i=await Zc(a.url),n[a.output]=i;break;case"transform":n[a.output]=n[a.input].transform(a.type,a.args);break;case"mark":s[a.output]=e.mark(a.type,a.args);break;case"glyph":s[a.output]=e.glyph(...a.input.map((t=>s[t])));break;case"attach":e.attach(s[a.input],n[a.data]);break;case"repeat":{let t=e.repeat(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"divide":{let t=e.divide(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"layout":s[a.input].layout=Yc(a.type,a.args);break;case"sortChildren":"field"in a.args?s[a.input].sortChildrenByData(a.args.field,a.args.reverse,a.args.order):"channel"in a.args&&s[a.input].sortChildren(a.args.channel,a.args.reverse);break;case"scale":{let t=Jc(a.type);t.id=a.id,t.domain="time"==a.type?a.domain.map((t=>new Date(t))):a.domain,t.range=a.range,t.clamp=a.clamp,t.isFlipped=a.isFlipped,"offset"in a&&(t.offset=a.offset),r[t.id]=t;break}case"encode":let t,o=a.input;if(o.indexOf("_v_")>0){let e=parseInt(o.split("_v_")[1]);t=s[o.split("_v_")[0]].vertices[e]}else if(o.indexOf("_v")>0);else if(o.indexOf("_s_")>0){let e=parseInt(o.split("_s_")[1]);t=s[o.split("_s_")[0]].segments[e]}else o.indexOf("_s")>0||(t=s[a.input]);a.scale&&r[a.scale]&&(a.args.scale=r[a.scale]),e.encode(t,a.args);break;case"constraint":switch(a.type){case E:e.affix(s[a.item],s[a.baseItem],a.channel,a.args)}break;case"axis":e.axis(a.channel,a.field,a.args);break;case"legend":e.legend(a.channel,a.field,a.args);break;case"gridlines":e.gridlines(a.channel,a.field,a.args)}return e}}let Be=Math.PI/180;class Le{constructor(t){this._canvasId=t,this._doesCollectionHaveBounds=!1,this._app=new r.Application({antialias:!0,width:1600,height:1e3,view:document.getElementById(this._canvasId)}),this._app.renderer.autoResize=!0}render(t,e){let i=e||{};this._app.renderer.backgroundColor=Ve(t.fillColor?t.fillColor:"#fff"),this._doesCollectionHaveBounds=!!i.collectionBounds,this._app.stage.removeChildren(),this._app.renderer.clear();let s=this._renderItem(t);this._app.stage.addChild(s)}_renderItem(t){switch(t.type){case T.Ellipse:case T.LinearGradient:We("mark",t,z.FEATURE_NOT_IMPLEMENTED);break;case T.Circle:return this._renderCircle(t);case T.Pie:return this._renderArc(t);case T.Area:return this._renderArea(t);case T.Polygon:return this._renderPolygon(t);case T.Axis:return this._renderAxis(t);case T.Collection:return this._renderCollection(t);case T.Glyph:case T.Group:case T.Gridlines:case T.Legend:case T.Scene:return this._renderGroup(t);case T.Path:return this._renderPath(t);case T.Line:return this._renderLinearPath(t);case T.Rect:return this._renderRectangle(t);case T.PointText:return this._renderText(t);case T.Arc:return this._renderArc(t);case T.Image:return this._renderImage(t);case T.Link:return this._renderLink(t);case T.Ring:return this._renderRing(t);default:throw console.log(t.type),new Error(`Expect: itemType, Actual: ${t}\nWait that's illegal`)}}_renderRectangle(t){let e=new i.Graphics;return je(e,t.styles),e.lineStyle(t.styles.strokeWidth,Ve(t.styles.strokeColor)),Ue(t.styles,e,t.height),e.drawRect(0,0,t.width,t.height),e.x=t.left,e.y=t.top,e.endFill(),e}_renderText(t){let e=new i.TextStyle({fontSize:t.styles.fontSize,fontFamily:t.styles.fontFamily,fontWeight:De(t.styles.fontWeight),fill:Ve(t.styles.fillColor)}),s=new r.Text(t.text,e),n=new i.Container;je(s,t.styles),s.x=t.x,s.y=t.y,s.anchor.set(...function(t){let e,i;switch(t[0]){case"left":e=0;break;case"center":e=.5;break;case"right":e=1;break;default:We("x anchor",t[0],z.UNKNOWN_ANCHOR)}switch(t[1]){case"hanging":case"top":i=0;break;case"central":case"middle":i=.5;break;case"bottom":i=1;break;default:We("y anchor",t[1],z.UNKNOWN_ANCHOR)}return[e,i]}(t.anchor)),n.addChild(s);let a=Ge(t._rotate);return n.pivot.set(a[0],a[1]),n.angle=ze(t._rotate),n.position.set(a[0],a[1]),n}_renderGroup(t){let e=new i.Container;for(const i of t.children){let t=this._renderItem(i);if(null==t)throw new Error;e.addChild(t)}return e}_renderAxis(t){let e=this._renderGroup(t),i=Ge(t._rotate);return e.pivot.set(i[0],i[1]),e.angle=ze(t._rotate),e.position.set(i[0],i[1]),e}_renderCollection(t){let e=new i.Container,s=this._renderGroup(t);if(e.addChild(s),!this._doesCollectionHaveBounds)return e;let n=new i.Graphics,r=0,a=t.bounds,o=a.left,h=a.right,l=a.top,c=a.bottom,d={strokeWidth:1,color:2018112,dashLength:5,dashSpacing:5};return r=u(o,h,l,r,d,n),r=u(l,c,-h,r,d,n),r=u(h,o,c,r,d,n),u(c,l,-o,r,d,n),e.addChild(n),e;function u(t,e,i,s,n,r){let a=t<=e?1:-1,o=s>=0?{point:t+s*a}:{point:t},h=i>0?[o,{point:i}]:[{point:-i},o];r.lineStyle({width:n.strokeWidth,color:n.color}),r.moveTo(h[0].point,h[1].point),o.point=s*a+t+n.dashLength*a,r.lineTo(h[0].point,h[1].point);let l=!1;for(o.point+=n.dashLength*a;o.point*a<=e*a;)l?(r.lineTo(h[0].point,h[1].point),l=!1,o.point+=n.dashSpacing*a):(r.moveTo(h[0].point,h[1].point),l=!0,o.point+=n.dashLength*a);return l?(i>0?r.lineTo(e,i):r.lineTo(-i,e),(e-o.point)*a):(o.point-e)*a}}_renderArea(t){switch(t.curveMode){case"linear":return this._renderPolygon(t);case"basis":return this._renderBezierArea(t);default:return We("areaPath",t,z.FEATURE_NOT_IMPLEMENTED)}}_renderBezierArea(t){let e=new i.Graphics;je(e,t.styles),e.lineStyle({width:t.styles.strokeWidth,color:Ve(t.styles.strokeColor)});let s=He(t.getSVGPathData());return Ue(t.styles,e,t.bounds.height),Je(e,s),e.endFill(),e}_renderPolygon(t){let e=new r.Container,i=this._renderLinearPath(t);i.getChildAt(0).lineTo(t.vertices[0].x,t.vertices[0].y);let s=new r.Graphics;je(s,t.styles);let n=[];for(const e of t.vertices)n.push(e.x-t.bounds.left),n.push(e.y-t.bounds.top);return Ue(t.styles,s,t.bounds.height),s.drawPolygon(n),s.x+=t.bounds.left,s.y+=t.bounds.top,s.endFill(),e.addChild(s),e.addChild(i),e}_renderPath(t){switch(t.curveMode){case"linear":return this._renderLinearPath(t);case"bumpX":case"natural":return this._renderBezierPath(t);default:We("path",t,z.FEATURE_NOT_IMPLEMENTED)}}_renderLinearPath(t){let e=new i.Container,s=new i.Graphics,n="none"==t.styles.strokeDash;je(s,t.styles);let r=t.vertices[0];if(s.lineStyle({width:t.styles.strokeWidth,color:Ve(t.styles.strokeColor)}),s.moveTo(r.x,r.y),n)for(let e=1;e<t.vertices.length;e++){const i=t.vertices[e];s.lineTo(i.x,i.y)}else!function(t,e,i){let s,n,r,a=0,o=0,h=e.split(" "),l=Number(h[0]),c=Number(h[1]);for(s=0;s<t.length&&(n=t[s],s!=t.length-1);s++){r=t[s+1];let e=r.x-n.x,h=r.y-n.y,d=Math.sqrt(e*e+h*h),u={x:e/d,y:h/d},f=0;for(i.moveTo(n.x+o*u.x,n.y+o*u.y);f<=d;)f+=o,f+=a>0?a:l,f>d?(a=f-d,f=d):a=0,i.lineTo(n.x+f*u.x,n.y+f*u.y),f+=c,f>d&&0==a?o=f-d:(o=0,i.moveTo(n.x+f*u.x,n.y+f*u.y))}}(t.vertices,t.styles.strokeDash,s);e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderBezierPath(t){let e=new i.Container,s=new i.Graphics;je(s,t.styles),s.lineStyle({width:t.styles.strokeWidth,color:Ve(t.styles.strokeColor)}),Je(s,He(t.getSVGPathData())),e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderVertex(t){switch(t.shape){case"rect":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:Ve(t.strokeColor)}),e.beginFill(Ve(t.fillColor)),e.drawRect(t.x-t.width/2,t.y-t.height/2,t.width,t.height),e.endFill(),e}(t);case"circle":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:Ve(t.strokeColor)}),e.beginFill(Ve(t.fillColor)),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}(t);case void 0:return null;default:We("vertex shape",t.shape,z.FEATURE_NOT_IMPLEMENTED)}}_renderCircle(t){let e=new i.Graphics;return je(e,t.styles),e.lineStyle(t.styles.strokeWidth,Ve(t.styles.strokeColor)),Ue(t.styles,e,t.height),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}_renderRing(t){let e=new i.Graphics;return e.lineStyle(t.outerRadius-t.innerRadius,Ve(t.styles.fillColor)),e.drawCircle(t.x,t.y,(t.innerRadius+t.outerRadius)/2),e.endFill(),e}_renderArc(t){let e=new i.Graphics;return e.lineStyle({color:Ve(t.styles.strokeColor),width:t.styles.strokeWidth}),e.beginFill(Ve(t.styles.fillColor)),e.arc(t.x,t.y,t.outerRadius,-t.endAngle*Be,-t.startAngle*Be),e.arc(t.x,t.y,t.innerRadius,-t.startAngle*Be,-t.endAngle*Be,!0),e.endFill(),e}_renderImage(t){let e=r.Sprite.from(t.src);return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}_renderLink(t){switch(t.curveMode){case"linear":return function(t){let e=new i.Graphics;return je(e,t.styles),e.lineStyle({color:Ve(t.styles.strokeColor),width:t.styles.strokeWidth}),Je(e,He(t.getSVGPathData())),e}(t);default:We("link",t.curveMode,"unexpected curvemode")}}}function je(t,e){t.visible=function(t){switch(t){case"hidden":return!1;case null:case void 0:case"visible":default:return!0}}(e.visibility),t.alpha=function(t){switch(t){case void 0:case null:return 1;default:return t}}(e.opacity)}function De(t){switch(t){case"regular":case"normal":return"normal";case"bold":return"bold";default:console.log(t),We("font weight",t,z.FEATURE_NOT_IMPLEMENTED)}}function Ve(t){let e=n.color(t);if(null==e)return null;{let t=e.formatHex();return r.utils.string2hex(t)}}function ze(t){return void 0===t||"number"!=typeof t[0]?0:t[0]}function Ge(t){return void 0===t||"number"!=typeof t[0]?[0,0]:t.slice(1)}function We(t,e,i){throw console.log(e),new Error(`${i}. Source: ${t}, Actual: `)}function Ue(t,e,i){let s=t.fillColor;if("none"==s)return;let n=Ve(s);null!=n?e.beginFill(n):e.beginTextureFill({color:16777215,texture:qe(i,s.stops,s.y1>s.y2)})}function qe(t,e,i){const s=document.createElement("canvas");s.height=t,s.width=1;const n=s.getContext("2d"),a=n.createLinearGradient(0,0,0,t);for(let t=0;t<e.length;t++)i?a.addColorStop(1-e[t].offset/100,e[t].color):a.addColorStop(e[t].offset/100,e[t].color);return n.fillStyle=a,n.fillRect(0,0,1,t),r.Texture.from(s)}function Je(t,e){let i=e.pop(),s=()=>{};"Z"==i.code.toUpperCase()?s=()=>t.lineTo(e[0].end.x,e[0].end.y):e.push(i);for(const i of e)Ye(i,t);s()}function Ye(t,e){switch(t.code.toUpperCase()){case"M":e.moveTo(t.end.x,t.end.y);break;case"L":e.lineTo(t.end.x,t.end.y);break;case"Q":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp1.x,t.cp1.y,t.end.x,t.end.y);break;case"C":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.end.x,t.end.y);break;case"Z":throw new Error('Unexpected "z" marker. There\'s something wrong, I can feel it');default:return We("data",t,z.FEATURE_NOT_IMPLEMENTED)}}function He(t){let e={command:/\s*([achlmqstvz])/gi,number:/\s*([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/gi,comma:/\s*(?:(,)|\s)/g,flag:/\s*([01])/g},i={number:function(t){return+a("number",t)},"coordinate pair":function(t){let e=a("number",t);return null!==e||t?(a("comma"),{x:+e,y:+a("number",!0)}):null},"arc definition":function(t){let e=i["coordinate pair"](t);if(!e&&!t)return null;a("comma");let s=+a("number",!0);a("comma",!0);let n=!!+a("flag",!0);a("comma");let r=!!+a("flag",!0);return a("comma"),{radii:e,rotation:s,large:n,clockwise:r,end:i["coordinate pair"](!0)}}},s=0,n=[];for(;s<t.length;){let t,e=a("command"),i=e.toUpperCase(),h=e!==i;switch(i){case"M":t=o("coordinate pair").map((function(t,i){return 1===i&&(e=h?"l":"L"),r({end:t},e,h)}));break;case"L":case"T":t=o("coordinate pair").map((function(t){return r({end:t},e,h)}));break;case"C":if(t=o("coordinate pair"),t.length%3)throw Error("Expected coordinate pair triplet at position "+s);t=t.reduce((function(t,i,s){let n=s%3;if(n){t[t.length-1][1===n?"cp2":"end"]=i}else t.push(r({cp1:i},e,h));return t}),[]);break;case"Q":case"S":if(t=o("coordinate pair"),1&t.length)throw Error("Expected coordinate pair couple at position "+s);t=t.reduce((function(t,i,s){if(1&s){t[t.length-1].end=i}else t.push(r({cp:i},e,h));return t}),[]);break;case"H":case"V":t=o("number").map((function(t){return r({value:t},e,h)}));break;case"A":t=o("arc definition").map(r,e,h);break;case"Z":t=[{code:"Z"}]}n.push.apply(n,t)}return n;function r(t,e,i){return t.code=e,t.relative=i,t}function a(i,n){e[i].lastIndex=s;let r=e[i].exec(t);if(!r||r.index!==s){if(!n)return null;throw Error("Expected "+i+" at position "+s)}return s=e[i].lastIndex,r[1]}function o(t){let e,s=[],n=!0;for(;null!==(e=i[t](n));)s.push(e),n=!!a("comma");return s}}var $e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ze(t,e){return t(e={exports:{}},e.exports),e.exports}var Ke=function(){this.__data__=[],this.size=0};var Xe=function(t,e){return t===e||t!=t&&e!=e};var Qe=function(t,e){for(var i=t.length;i--;)if(Xe(t[i][0],e))return i;return-1},ti=Array.prototype.splice;var ei=function(t){var e=this.__data__,i=Qe(e,t);return!(i<0)&&(i==e.length-1?e.pop():ti.call(e,i,1),--this.size,!0)};var ii=function(t){var e=this.__data__,i=Qe(e,t);return i<0?void 0:e[i][1]};var si=function(t){return Qe(this.__data__,t)>-1};var ni=function(t,e){var i=this.__data__,s=Qe(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};function ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}ri.prototype.clear=Ke,ri.prototype.delete=ei,ri.prototype.get=ii,ri.prototype.has=si,ri.prototype.set=ni;var ai=ri;var oi=function(){this.__data__=new ai,this.size=0};var hi=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var li=function(t){return this.__data__.get(t)};var ci=function(t){return this.__data__.has(t)},di="object"==typeof $e&&$e&&$e.Object===Object&&$e,ui="object"==typeof self&&self&&self.Object===Object&&self,fi=di||ui||Function("return this")(),pi=fi.Symbol,gi=Object.prototype,_i=gi.hasOwnProperty,mi=gi.toString,yi=pi?pi.toStringTag:void 0;var vi=
|
|
4
|
+
set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}_setRange(t){this._scale.range(t),fe(this)}get clamp(){return"linear"==this.type&&this._scale.clamp()}set clamp(t){"linear"==this.type&&this._scale.clamp(t)}set rangeExtent(t){let e=this._scale.range();this._setRange([e[0],e[0]+t])}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}_addEncoding(t){this.encodings.indexOf(t)<0&&this.encodings.push(t)}map(t){let e=this._scale.copy();return e.domain(this.domain),this._flipped?(e.range(this._scale.range().reverse()),e(t)):e(t)}invert(t){return this._scale.invert(t)}get offset(){return this._offset}set offset(t){this._offset=t;for(let t of this.encodings)t._apply()}get isFlipped(){return this._flipped}set isFlipped(t){this._flipped=t}get includeZero(){return this._includeZero}set includeZero(t){this._includeZero=t,ue(this)}get mapping(){return this._mapping}getEncodedChannels(){let t={};for(let e of this.encodings)t[e.channel]=!0;return Object.keys(t)}}class Ie extends U{constructor(t){super(t),this.type="packing",this.x="x"in t?t.x:400,this.y="y"in t?t.y:400,this.width=t.width,this.height=t.height}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this.x,t.args.y=this.y,t.args.width=this.width,t.args.height=this.height,t}clone(){return new Ie({x:this.x,y:this.y,width:this.width,height:this.height})}run(){if(null==this.group)return;let t=this.group.children.map((t=>({name:t.id,radius:t.radius,itm:t}))),e=t.reduce(((t,e)=>t+Math.pow(e.radius,2)),0),i=Math.sqrt(e);void 0===this.width&&(this.width=i),void 0===this.height&&(this.height=i);let s=r.hierarchy({name:"root",children:t}).sum((t=>t.radius?t.radius:0)).sort(((t,e)=>e.value-t.value));r.pack().size([this.width,this.height]).radius((t=>t.value))(s);for(let t of s.children){let e=t.data.itm,i=this.x-s.x+t.x-e.x,n=this.y-s.y+t.y-e.y;e._doTranslate(i,n)}this.group._updateBounds()}}class Oe extends U{constructor(t){super(t),this.type="treemap",this._width=t.width,this._height=t.height,this._top=t.top,this._left=t.left}toJSON(){let t={args:{}};return t.type=this.type,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}clone(){return new Oe({})}run(){if(null==this.group||!this.group.children||0==this.group.children.length)return;let t=this._width?this._width:this.group.bounds.width,e=this._height?this._height:this.group.bounds.height,i=void 0===this._top?this.group.bounds.top:this._top,s=void 0===this._left?this.group.bounds.left:this._left,n=r.hierarchy(this.group).sum((t=>"rect"==t.type?t.bounds.width*t.bounds.height:0));r.treemap().size([t,e])(n),this._apply(n,s,i),this.group.getScene()._updateAncestorBounds(n.leaves()[0].data)}_apply(t,e,i){if("collection"==t.data.type&&t.children)for(let s of t.children)this._apply(s,e,i);else"rect"==t.data.type&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),t.data._doTranslate(t.x0+e-t.data.bounds.left,t.y0+i-t.data.bounds.top))}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get top(){return this._top}set top(t){this._top=t,this.run()}get left(){return this._left}set left(t){this._left=t,this.run()}}function Me(t,e){let i=[t[0]],s=[e[0]];for(let n=1;n<e.length;n++){let r=!1,a=e[n];for(let e=0;e<s.length;e++){let o=s[e],l=new Set(a);if(o.forEach((t=>l.add(t))),l.size<a.length+o.length){s[e]=[...l],i[e]=i[e].concat(t[n]),r=!0;break}}r||(s.push(a),i.push(t[n]))}return{grouping:i,subgraphs:s}}class Re{constructor(t,e){this._type="network",this._nodeTable=new Ut(t.nodes,"nodes"),this._linkTable=new Ut(t.links,"links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._nodes=t.nodes,this._links=t.links,this._name=e,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e.id]=e}get type(){return this._type}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodes(){return this._nodes}get links(){return this._links}getNode(t){return this._nodeHash[t]}getSources(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].target==i){e=s[t].source;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}getTargets(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].source==i){e=s[t].target;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}transform(t,e,i){switch(t){case"partition":return function(t){let e=t.nodes,i=t.links,s=i.map(((t,e)=>[e])),n=i.map((t=>[t.source,t.target])),r=Me(s,n);for(;r.grouping.length!=s.length;)s=r.grouping,n=r.subgraphs,r=Me(s,n);let a=[];for(let[t,s]of r.grouping.entries()){let n={nodes:[],links:[]};n.links=s.map((t=>i[t]));const o=r.subgraphs[t];n.nodes=e.filter((t=>o.indexOf(t.id)>=0)),a.push(new Re(n))}return a}(this)}}isLinear(){let t={},e={};for(let i of this._links)i.source in e||(e[i.source]=0),i.target in t||(t[i.target]=0),e[i.source]++,t[i.target]++;for(let e in t)if(t[e]>1)return!1;for(let t in e)if(e[t]>1)return!1;return!0}}class Ne extends U{constructor(t){super(t),this.type=b.TidyTree,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:w}toJSON(){let t={args:{}};return t.args.type=this.type,t.args.orientation=this._orientation,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt;if(!t.tree)throw W.LAYOUT_WITHOUT_TREE;{let e=r.hierarchy(t.tree._data),i=Math.max(...this.group.children.map((t=>t.bounds.width))),s=Math.max(...this.group.children.map((t=>t.bounds.height))),n=this._orientation==w?[this._height,this._width]:[this._width,this._height],a=r.tree().nodeSize([i,s]).size(n)(e);this._apply(a,this.group)}}_apply(t,e){let i,s,n=e.children.filter((e=>e.dataScope.getFieldValue(h)==t.data.id))[0];switch(this._orientation){case w:i=t.y+this._left,s=t.x+this._top;break;case x:i=t.x+this._left,s=this._top+t.y}if(n.x=i,n.y=s,t.children&&t.children.length>0)for(let i of t.children)this._apply(i,e)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get size(){return[this._width,this._height]}set size(t){this._width=t[0],this._height=t[1],this.run()}}class Be extends U{constructor(t){super(t),this.type=b.Force,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this._x,t.args.y=this._y,t.args.iterations=this._iterations,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt.graph;if(t){let e=t.links.map((e=>({source:t.getNode(e.source),target:t.getNode(e.target)}))),i=r.forceSimulation(t.nodes).force("charge",r.forceManyBody().strength(-this._repulsion)).force("link",r.forceLink(e).id((t=>t.id)).distance(this._linkDistance)).force("x",r.forceX()).force("y",r.forceY()).force("center",r.forceCenter(this._x,this._y).strength(this._attraction));i.stop(),i.tick(this._iterations);for(let e=0;e<this.group.children.length;e++)this.group.children[e].x=t.nodes[e].x,this.group.children[e].y=t.nodes[e].y}}}class Pe{constructor(){this.axes={},this.guideCmds=[],this.collectionCmds=[],this.glyphCmds=[],this.spec=[]}run(t){for(let e of t.children)switch(e.type){case I.Axis:{let t=e.classId?e.classId:e.id;this.axes[t]=e;break}case I.Gridlines:case I.Legend:{let t=e.toJSON();this.guideCmds.push({cmd:e.type,channel:t.channel,field:t.field,args:t.args});break}case I.Collection:case I.Group:case I.Glyph:{let i=[];this._analyze(e,i);for(let t=i.length-1;t>0;t--)for(let e of i[t].fields)i[t-1].fields.delete(e);for(let[e,s]of i.entries()){if(s.item instanceof J){let e={cmd:"mark",type:s.item.type,output:s.item,args:s.item.toJSON().args};this._inferMarkArgs(e,t),this.collectionCmds.push(e)}else if(s.item instanceof Qt)this.collectionCmds.push({cmd:"glyph",output:s.item,input:i.slice(0,e).map((t=>t.item)),args:{}});else if(s.item instanceof ae){let t=[...i[e-1].fields][0],n={cmd:"join",input:i[e-1].item,output:s.item,data:i[e-1].item.dataScope.dataTable.id,args:{field:t}};t==c&&delete n.field,this.collectionCmds.push(n)}s.item.dataScope&&0==s.item.dataScope.fields.length&&!s.item.parent.dataScope&&this.collectionCmds.push({cmd:"attach",input:s.item,data:s.item.dataScope.dataTable.id})}break}default:if(e instanceof J){let i={cmd:"mark",type:e.type,output:e,args:e.toJSON().args};this._inferMarkArgs(i,t),this.glyphCmds.push(i)}}this._inferJoin(),this._inferArgs(t);for(let t in this.axes){let e=this.axes[t].toJSON();this.guideCmds.push({cmd:e.type,channel:e.channel,field:e.field,args:e.args})}return this._generateFullSpec(t),this.spec}_inferJoin(){for(let t of this.collectionCmds){if("join"!=t.cmd)continue;let e=t.input,i=e.parent;switch(e.type){case I.Rect:i.layout&&i.layout.type==b.Stack?t.cmd="divide":t.cmd="repeat";break;default:t.cmd="repeat"}}}_inferArgs(t){for(let e of this.collectionCmds)switch(e.cmd){case"mark":this._inferMarkArgs(e,t);break;case"divide":this._inferDivideArgs(e,t)}}_inferDivideArgs(t){t.args.orientation=t.output.layout.orientation}_inferMarkArgs(t,e){let i=t.output,s=i.parent,n=st(i,e),r=st(s,e);switch(i.type){case I.Rect:s.layout&&s.layout.type==b.Grid?(t.args.width=s.layout.cellBounds[0].width,t.args.height=s.layout.cellBounds[0].height):s.layout&&s.layout.type==b.Stack?(t.args.width=Math.max(...r.map((t=>t.bounds.width))),t.args.height=Math.max(...r.map((t=>t.bounds.height)))):(t.args.width=Math.max(...n.map((t=>t.bounds.width))),t.args.height=Math.max(...n.map((t=>t.bounds.height)))),t.args.left=Math.min(...n.map((t=>t.bounds.left))),t.args.top=Math.min(...n.map((t=>t.bounds.top)));break;case I.Line:t.args.x1=Math.min(...n.map((t=>t.vertices[0].x))),t.args.y1=Math.min(...n.map((t=>t.vertices[0].y))),t.args.x2=Math.min(...n.map((t=>t.vertices[1].x))),t.args.y2=Math.min(...n.map((t=>t.vertices[1].y)));break;case I.Arc:t.args.x=i.x,t.args.y=i.y,t.args.innerRadius=i.innerRadius,t.args.outerRadius=i.outerRadius}for(let e in i.styles)t.args[e]=i.styles[e]}_analyze(t,e){if(t instanceof Qt)for(let i of t.children)this._analyze(i,e);else t instanceof At&&this._analyze(t.firstChild,e);let i={type:t.type,item:t};t.dataScope?i.fields=new Set(t.dataScope.fields):i.fields=new Set,e.push(i)}_generateFullSpec(t){this.spec=[],this.spec.push({cmd:"scene",args:{fillColor:t.fillColor}});let e=t.getDataTables(),i={},s=[];for(let t in e){let n=e[t];if(n.sourceDataTable)for(;n.sourceDataTable;)s.push({cmd:"transform",type:n.transform.type,args:n.transform.args,input:n.sourceDataTable.id,output:n.id}),n=n.sourceDataTable;n.id in i||(i[n.id]={cmd:"data",url:n.url,output:n.id})}this.spec=this.spec.concat(Object.values(i)),this.spec=this.spec.concat(s);let n=[];for(let t of this.collectionCmds){let e;t.output&&t.output.layout&&(e={cmd:"layout",type:t.output.layout.type,input:t.output.id,args:t.output.layout.toJSON().args}),this.spec.push(t),t.output&&t.output.childrenOrder&&n.push({cmd:"sortChildren",args:t.output.childrenOrder,input:t.output.id}),e&&this.spec.push(e),t.input&&Array.isArray(t.input)?t.input=t.input.map((t=>t.classId?t.classId:t.id)):t.input&&(t.input=t.input.classId?t.input.classId:t.input.id),t.output&&(t.output=t.output.classId?t.output.classId:t.output.id)}let r={},a=[];for(let e in t.encodings)for(let i in t.encodings[e]){let s=t.encodings[e][i];s.scale&&!(s.scale.id in r)&&(r[s.scale.id]=s.scale.toJSON());let n=s.toJSON().args;n.field=s.field,n.channel=s.channel,delete n.datatable,a.push({cmd:"encode",input:lt(s.anyItem),scale:s.scale.id,args:n})}for(let t in r){let e=r[t];e.cmd="scale",this.spec.push(e)}this.spec=this.spec.concat(a),this.spec=this.spec.concat(n);for(let e in t.constraints){let i=t.constraints[e],s={cmd:"constraint",type:i.type,args:{}};switch(i.type){case T:s.item=i.item.classId?i.item.classId:i.item.id,s.baseItem=i.baseItem.classId?i.baseItem.classId:i.baseItem.id,s.channel=i.channel,s.args.itemAnchor=i.itemAnchor,s.args.baseAnchor=i.baseAnchor,s.args.offset=i.offset;break;case A:s.items=i.items.map((t=>t.classId?t.classId:t.id)),s.anchor=i.anchor}this.spec.push(s)}for(let t of this.guideCmds)this.spec.push(t);for(let t of this.glyphCmds)t.output&&(t.output=t.output.classId?t.output.classId:t.output.id),this.spec.push(t)}}class Fe{constructor(){this.axes={},this.legends=[],this.gridlines=[],this.scales={},this.tables={}}load(t){let e={};if(t.fillColor&&(e.fillColor=t.fillColor),t.itemCounter)for(let e in t.itemCounter)_t[e]=t.itemCounter[e];let i=cd(e);if(i.id=t.id,i.type=t.type,t.bounds&&(i._bounds=new l(t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height)),t.tables)for(let e in t.tables)this.tables[e]=new Ut(t.tables[e].data,t.tables[e].url,t.tables[e].fieldTypes),this.tables[e].id=t.tables[e].id;for(let e of t.children)this._processItem(i,e,i);if(t.scales)for(let e in t.scales)this._loadScale(t.scales[e],i);if(t.encodings)for(let e of t.encodings)this._loadEncoding(e,i);if(t.constraints)for(let e in t.constraints)this._loadConstraint(t.constraints[e],i);for(let t in this.axes)this._createGuide(i,this.axes[t]);for(let t of this.legends)this._createGuide(i,t);for(let t of this.gridlines)this._createGuide(i,t);return i}_loadScale(t){let e;"sequentialColor"===t.type&&t.scheme?e=dd(t.type,t.scheme):(e=dd(t.type),e.range=t.range),e.domain="time"==t.type?t.domain.map((t=>new Date(t))):t.domain,e.id=t.id,"offset"in t&&(e.offset=t.offset),e.isFlipped=t.isFlipped,e.clamp=t.clamp,"includeZero"in t&&(e.includeZero=t.includeZero),this.scales[e.id]=e}_loadEncoding(t,e){t.args.datatable&&(t.args.datatable=this.tables[t.args.datatable]),t.args.scale&&(t.args.scale=this.scales[t.args.scale]);let i=t.items.map((t=>e.getItem(t)));e._doEncode(i,t.args)}_createGuide(t,e){switch(e.type){case I.Axis:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.axis(e.channel,e.field,e.args);break;case I.Legend:t.legend(e.channel,e.field,e.args);break;case I.Gridlines:t.gridlines(e.channel,e.field,e.args)}}_processItem(t,e,i){switch(e.type){case I.Axis:{let t=e.classId?e.classId:e.id;e.args.tickValues&&e.args.isDate&&(e.args.tickValues=e.args.tickValues.map((t=>new Date(t)))),this.axes[t]=e;break}case I.Gridlines:e.args.values&&e.args.isDate&&(e.args.values=e.args.values.map((t=>new Date(t)))),this.gridlines.push(e);break;case I.Legend:this.legends.push(e);break;case I.Collection:{let s=i.collection();t.addChild(s),this._loadGroup(s,e,i);break}case I.Group:{let s=i.group();t.addChild(s),this._loadGroup(s,e,i);break}case I.Glyph:{let s=i.glyph();t.addChild(s),this._loadGroup(s,e,i);break}default:this._loadMark(t,e,i)}}_loadConstraint(t,e){switch(t.type){case"affixation":{let i=e.getItem(t.item),s=e.getItem(t.baseItem),n=new ne(i,s,e,t.channel,t.itemAnchor,t.baseAnchor,t.offset);return n.id=t.id,e.constraints[t.id]=n,n.apply(),n}case"alignment":{let i=t.items.map((t=>e.getItem(t))),s=new se(i,t.direction);return s.id=t.id,e.constraints[t.id]=s,s.apply(),s}}}_loadDataScope(t){let e=new Mt(this.tables[t.dt]);for(let i in t.f2v)e._field2value[i]=t.f2v[i],e._updateTuples(i,t.f2v[i]);return e}_loadGroup(t,e,i){if(t.id=e.id,e.classId&&(t.classId=e.classId),e.dataScope&&(t.dataScope=this._loadDataScope(e.dataScope)),e.children)for(let s of e.children)this._processItem(t,s,i);if(e.layout){let i=this._loadLayout(e.layout);i.group=t,t._layout=i}e.bounds&&(t._bounds=new l(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height))}_loadMark(t,e,i){if(e.args.fillColor&&"LinearGradient"===e.args.fillColor.type){let t=e.args.fillColor;e.args.fillColor=fd(t),e.args.fillColor.id=t.id,e.args.fillColor._stops=t.stops}"id"in e&&(e.args.id=e.id);let s=i.mark(e.type,e.args);if(e.classId&&(s.classId=e.classId),e.dataScope&&(s.dataScope=this._loadDataScope(e.dataScope)),e.vertices){const t=[];for(let i of e.vertices){const e=Z.fromJSON(i,s);e.dataScope&&(e.dataScope=this._loadDataScope(e.dataScope)),t.push(e)}s.vertices=t,s.segments=[];for(let t=1;t<s.vertices.length;t++)s.segments.push(new K(s.vertices[t-1],s.vertices[t],s,s.segmentCounter++))}e.bounds&&(s._bounds=new l(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height)),gt(s)?(s.vertexCounter=e.vertexCounter,s.segmentCounter=e.segmentCounter,s.curveMode=e.curveMode):e.type===I.Image&&(s.src=e.src,s.width=e.width,s.height=e.height,s.x=e.x,s.y=e.y),t.addChild(s)}_loadLayout(t){let e=ud(t.type,t.args);switch(t.type){case b.Grid:e._left=t.left,e._top=t.top}return e}}class Le{constructor(){}async run(t){let e,i,s={},n={},r={};for(let a of t)switch(a.cmd){case"scene":e=cd(a.args);break;case"data":i=await gd(a.url),n[a.output]=i;break;case"transform":n[a.output]=n[a.input].transform(a.type,a.args);break;case"mark":s[a.output]=e.mark(a.type,a.args);break;case"glyph":s[a.output]=e.glyph(...a.input.map((t=>s[t])));break;case"attach":e.attach(s[a.input],n[a.data]);break;case"repeat":{let t=e.repeat(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"divide":{let t=e.divide(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"layout":s[a.input].layout=ud(a.type,a.args);break;case"sortChildren":"field"in a.args?s[a.input].sortChildrenByData(a.args.field,a.args.reverse,a.args.order):"channel"in a.args&&s[a.input].sortChildren(a.args.channel,a.args.reverse);break;case"scale":{let t=dd(a.type);t.id=a.id,t.domain="time"==a.type?a.domain.map((t=>new Date(t))):a.domain,t.range=a.range,t.clamp=a.clamp,t.isFlipped=a.isFlipped,"offset"in a&&(t.offset=a.offset),r[t.id]=t;break}case"encode":let t,o=a.input;if(o.indexOf("_v_")>0){let e=parseInt(o.split("_v_")[1]);t=s[o.split("_v_")[0]].vertices[e]}else if(o.indexOf("_v")>0);else if(o.indexOf("_s_")>0){let e=parseInt(o.split("_s_")[1]);t=s[o.split("_s_")[0]].segments[e]}else o.indexOf("_s")>0||(t=s[a.input]);a.scale&&r[a.scale]&&(a.args.scale=r[a.scale]),e.encode(t,a.args);break;case"constraint":switch(a.type){case T:e.affix(s[a.item],s[a.baseItem],a.channel,a.args)}break;case"axis":e.axis(a.channel,a.field,a.args);break;case"legend":e.legend(a.channel,a.field,a.args);break;case"gridlines":e.gridlines(a.channel,a.field,a.args)}return e}}const De=new a.Box3,je=new a.Vector3;class Ve extends a.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new a.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new a.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new a.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new a.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new a.InterleavedBufferAttribute(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new a.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new a.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new a.InterleavedBufferAttribute(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new a.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new a.Box3);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),De.setFromBufferAttribute(e),this.boundingBox.union(De))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new a.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let s=0;for(let n=0,r=t.count;n<r;n++)je.fromBufferAttribute(t,n),s=Math.max(s,i.distanceToSquared(je)),je.fromBufferAttribute(e,n),s=Math.max(s,i.distanceToSquared(je));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}Ve.prototype.isLineSegmentsGeometry=!0;(class extends Ve{constructor(){super(),this.type="LineGeometry"}setPositions(t){for(var e=t.length-3,i=new Float32Array(2*e),s=0;s<e;s+=3)i[2*s]=t[s],i[2*s+1]=t[s+1],i[2*s+2]=t[s+2],i[2*s+3]=t[s+3],i[2*s+4]=t[s+4],i[2*s+5]=t[s+5];return super.setPositions(i),this}setColors(t){for(var e=t.length-3,i=new Float32Array(2*e),s=0;s<e;s+=3)i[2*s]=t[s],i[2*s+1]=t[s+1],i[2*s+2]=t[s+2],i[2*s+3]=t[s+3],i[2*s+4]=t[s+4],i[2*s+5]=t[s+5];return super.setColors(i),this}fromLine(t){var e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}}).prototype.isLineGeometry=!0,a.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new a.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},a.ShaderLib.line={uniforms:a.UniformsUtils.merge([a.UniformsLib.common,a.UniformsLib.fog,a.UniformsLib.line]),vertexShader:"\n\t#include <common>\n\t#include <color_pars_vertex>\n\t#include <fog_pars_vertex>\n\t#include <logdepthbuf_pars_vertex>\n\t#include <clipping_planes_pars_vertex>\n\n\tuniform float linewidth;\n\tuniform vec2 resolution;\n\n\tattribute vec3 instanceStart;\n\tattribute vec3 instanceEnd;\n\n\tattribute vec3 instanceColorStart;\n\tattribute vec3 instanceColorEnd;\n\n\tvarying vec2 vUv;\n\tvarying vec4 worldPos;\n\tvarying vec3 worldStart;\n\tvarying vec3 worldEnd;\n\n\t#ifdef USE_DASH\n\n\t\tuniform float dashScale;\n\t\tattribute float instanceDistanceStart;\n\t\tattribute float instanceDistanceEnd;\n\t\tvarying float vLineDistance;\n\n\t#endif\n\n\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t// conservative estimate of the near plane\n\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t}\n\n\tvoid main() {\n\n\t\t#ifdef USE_COLOR\n\n\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t#endif\n\n\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\tvUv = uv;\n\n\t\t// camera space\n\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\tworldStart = start.xyz;\n\t\tworldEnd = end.xyz;\n\n\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\tif ( perspective ) {\n\n\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\ttrimSegment( start, end );\n\n\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\ttrimSegment( end, start );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// clip space\n\t\tvec4 clipStart = projectionMatrix * start;\n\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t// ndc space\n\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t// direction\n\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t// account for clip-space aspect ratio\n\t\tdir.x *= aspect;\n\t\tdir = normalize( dir );\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\tvec3 offset;\n\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t} else {\n\n\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t}\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t// won't be rendering the endcaps\n\t\t\t#ifndef USE_DASH\n\n\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\toffset.z += 0.5;\n\n\t\t\t#endif\n\n\t\t\t// endcaps\n\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t// set the world position\n\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\tworldPos.xyz += offset;\n\n\t\t\t// project the worldpos\n\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t// shift the depth of the projected points so the line\n\t\t\t// segements overlap neatly\n\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t#else\n\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t#endif\n\n\t\tgl_Position = clip;\n\n\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t#include <logdepthbuf_vertex>\n\t\t#include <clipping_planes_vertex>\n\t\t#include <fog_vertex>\n\n\t}\n\t",fragmentShader:"\n\tuniform vec3 diffuse;\n\tuniform float opacity;\n\tuniform float linewidth;\n\n\t#ifdef USE_DASH\n\n\t\tuniform float dashSize;\n\t\tuniform float gapSize;\n\n\t#endif\n\n\tvarying float vLineDistance;\n\tvarying vec4 worldPos;\n\tvarying vec3 worldStart;\n\tvarying vec3 worldEnd;\n\n\t#include <common>\n\t#include <color_pars_fragment>\n\t#include <fog_pars_fragment>\n\t#include <logdepthbuf_pars_fragment>\n\t#include <clipping_planes_pars_fragment>\n\n\tvarying vec2 vUv;\n\n\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\tfloat mua;\n\t\tfloat mub;\n\n\t\tvec3 p13 = p1 - p3;\n\t\tvec3 p43 = p4 - p3;\n\n\t\tvec3 p21 = p2 - p1;\n\n\t\tfloat d1343 = dot( p13, p43 );\n\t\tfloat d4321 = dot( p43, p21 );\n\t\tfloat d1321 = dot( p13, p21 );\n\t\tfloat d4343 = dot( p43, p43 );\n\t\tfloat d2121 = dot( p21, p21 );\n\n\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\tmua = numer / denom;\n\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\treturn vec2( mua, mub );\n\n\t}\n\n\tvoid main() {\n\n\t\t#include <clipping_planes_fragment>\n\n\t\t#ifdef USE_DASH\n\n\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t#endif\n\n\t\tfloat alpha = opacity;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\tvec3 delta = p1 - p2;\n\t\t\tfloat len = length( delta );\n\t\t\tfloat norm = len / linewidth;\n\n\t\t\t#ifndef USE_DASH\n\n\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t}\n\n\t\t\t#else\n\n\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t}\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t#include <logdepthbuf_fragment>\n\t\t#include <color_fragment>\n\n\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t#include <tonemapping_fragment>\n\t\t#include <encodings_fragment>\n\t\t#include <fog_fragment>\n\t\t#include <premultiplied_alpha_fragment>\n\n\t}\n\t"};class ze extends a.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:a.UniformsUtils.clone(a.ShaderLib.line.uniforms),vertexShader:a.ShaderLib.line.vertexShader,fragmentShader:a.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===t?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}ze.prototype.isLineMaterial=!0;const Ge=new a.Vector3,We=new a.Vector3,Ue=new a.Vector4,qe=new a.Vector4,He=new a.Vector4,Je=new a.Vector3,Ye=new a.Matrix4,$e=new a.Line3,Ze=new a.Vector3,Ke=new a.Box3,Xe=new a.Sphere,Qe=new a.Vector4;class ti extends a.Mesh{constructor(t=new Ve,e=new ze({color:16777215*Math.random()})){super(t,e),this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let t=0,n=0,r=e.count;t<r;t++,n+=2)Ge.fromBufferAttribute(e,t),We.fromBufferAttribute(i,t),s[n]=0===n?0:s[n-1],s[n+1]=s[n]+Ge.distanceTo(We);const n=new a.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new a.InterleavedBufferAttribute(n,1,0)),t.setAttribute("instanceDistanceEnd",new a.InterleavedBufferAttribute(n,1,1)),this}raycast(t,e){null===t.camera&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');const i=void 0!==t.params.Line2&&t.params.Line2.threshold||0,s=t.ray,n=t.camera,r=n.projectionMatrix,o=this.matrixWorld,l=this.geometry,h=this.material,c=h.resolution,d=h.linewidth+i,u=l.attributes.instanceStart,f=l.attributes.instanceEnd,p=-n.near,g=2*Math.max(d/c.width,d/c.height);null===l.boundingSphere&&l.computeBoundingSphere(),Xe.copy(l.boundingSphere).applyMatrix4(o);const _=Math.max(n.near,Xe.distanceToPoint(s.origin));Qe.set(0,0,-_,1).applyMatrix4(n.projectionMatrix),Qe.multiplyScalar(1/Qe.w),Qe.applyMatrix4(n.projectionMatrixInverse);const m=.5*Math.abs(g/Qe.w);if(Xe.radius+=m,!1===t.ray.intersectsSphere(Xe))return;null===l.boundingBox&&l.computeBoundingBox(),Ke.copy(l.boundingBox).applyMatrix4(o);const y=Math.max(n.near,Ke.distanceToPoint(s.origin));Qe.set(0,0,-y,1).applyMatrix4(n.projectionMatrix),Qe.multiplyScalar(1/Qe.w),Qe.applyMatrix4(n.projectionMatrixInverse);const v=.5*Math.abs(g/Qe.w);if(Ke.max.x+=v,Ke.max.y+=v,Ke.max.z+=v,Ke.min.x-=v,Ke.min.y-=v,Ke.min.z-=v,!1!==t.ray.intersectsBox(Ke)){s.at(1,He),He.w=1,He.applyMatrix4(n.matrixWorldInverse),He.applyMatrix4(r),He.multiplyScalar(1/He.w),He.x*=c.x/2,He.y*=c.y/2,He.z=0,Je.copy(He),Ye.multiplyMatrices(n.matrixWorldInverse,o);for(let t=0,i=u.count;t<i;t++){if(Ue.fromBufferAttribute(u,t),qe.fromBufferAttribute(f,t),Ue.w=1,qe.w=1,Ue.applyMatrix4(Ye),qe.applyMatrix4(Ye),Ue.z>p&&qe.z>p)continue;if(Ue.z>p){const t=Ue.z-qe.z,e=(Ue.z-p)/t;Ue.lerp(qe,e)}else if(qe.z>p){const t=qe.z-Ue.z,e=(qe.z-p)/t;qe.lerp(Ue,e)}Ue.applyMatrix4(r),qe.applyMatrix4(r),Ue.multiplyScalar(1/Ue.w),qe.multiplyScalar(1/qe.w),Ue.x*=c.x/2,Ue.y*=c.y/2,qe.x*=c.x/2,qe.y*=c.y/2,$e.start.copy(Ue),$e.start.z=0,$e.end.copy(qe),$e.end.z=0;const i=$e.closestPointToPointParameter(Je,!0);$e.at(i,Ze);const n=a.MathUtils.lerp(Ue.z,qe.z,i),l=n>=-1&&n<=1,h=Je.distanceTo(Ze)<.5*d;if(l&&h){$e.start.fromBufferAttribute(u,t),$e.end.fromBufferAttribute(f,t),$e.start.applyMatrix4(o),$e.end.applyMatrix4(o);const i=new a.Vector3,n=new a.Vector3;s.distanceSqToSegment($e.start,$e.end,n,i),e.push({point:n,pointOnLine:i,distance:s.origin.distanceTo(n),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}}ti.prototype.LineSegments2=!0;(class extends ti{constructor(t=new a.LineGeometry,e=new a.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Line2"}}).prototype.isLine2=!0;let ei=Math.PI/180;class ii{constructor(t){this._canvasId=t,this._doesCollectionHaveBounds=!1,this._app=new o.Application({antialias:!0,width:1600,height:1e3,view:document.getElementById(this._canvasId)}),this._app.renderer.autoResize=!0}render(t,e){let i=e||{};this._app.renderer.backgroundColor=ri(t.fillColor?t.fillColor:"#fff"),this._doesCollectionHaveBounds=!!i.collectionBounds,this._app.stage.removeChildren(),this._app.renderer.clear();let s=this._renderItem(t);this._app.stage.addChild(s)}_renderItem(t){switch(t.type){case I.Ellipse:case I.LinearGradient:li("mark",t,W.FEATURE_NOT_IMPLEMENTED);break;case I.Circle:return this._renderCircle(t);case I.Pie:return this._renderArc(t);case I.Area:return this._renderArea(t);case I.Polygon:return this._renderPolygon(t);case I.Axis:return this._renderAxis(t);case I.Collection:return this._renderCollection(t);case I.Glyph:case I.Group:case I.Gridlines:case I.Legend:case I.Scene:return this._renderGroup(t);case I.Path:return this._renderPath(t);case I.Line:return this._renderLinearPath(t);case I.Rect:return this._renderRectangle(t);case I.PointText:return this._renderText(t);case I.Arc:return this._renderArc(t);case I.Image:return this._renderImage(t);case I.Link:return this._renderLink(t);case I.Ring:return this._renderRing(t);default:throw console.log(t.type),new Error(`Expect: itemType, Actual: ${t}\nWait that's illegal`)}}_renderRectangle(t){let e=new s.Graphics;return si(e,t.styles),e.lineStyle(t.styles.strokeWidth,ri(t.styles.strokeColor)),hi(t.styles,e,t.height),e.drawRect(0,0,t.width,t.height),e.x=t.left,e.y=t.top,e.endFill(),e}_renderText(t){let e=new s.TextStyle({fontSize:t.styles.fontSize,fontFamily:t.styles.fontFamily,fontWeight:ni(t.styles.fontWeight),fill:ri(t.styles.fillColor)}),i=new o.Text(t.text,e),n=new s.Container;si(i,t.styles),i.x=t.x,i.y=t.y,i.anchor.set(...function(t){let e,i;switch(t[0]){case"left":e=0;break;case"center":e=.5;break;case"right":e=1;break;default:li("x anchor",t[0],W.UNKNOWN_ANCHOR)}switch(t[1]){case"hanging":case"top":i=0;break;case"central":case"middle":i=.5;break;case"bottom":i=1;break;default:li("y anchor",t[1],W.UNKNOWN_ANCHOR)}return[e,i]}(t.anchor)),n.addChild(i);let r=oi(t._rotate);return n.pivot.set(r[0],r[1]),n.angle=ai(t._rotate),n.position.set(r[0],r[1]),n}_renderGroup(t){let e=new s.Container;for(const i of t.children){let t=this._renderItem(i);if(null==t)throw new Error;e.addChild(t)}return e}_renderAxis(t){let e=this._renderGroup(t),i=oi(t._rotate);return e.pivot.set(i[0],i[1]),e.angle=ai(t._rotate),e.position.set(i[0],i[1]),e}_renderCollection(t){let e=new s.Container,i=this._renderGroup(t);if(e.addChild(i),!this._doesCollectionHaveBounds)return e;let n=new s.Graphics,r=0,a=t.bounds,o=a.left,l=a.right,h=a.top,c=a.bottom,d={strokeWidth:1,color:2018112,dashLength:5,dashSpacing:5};return r=u(o,l,h,r,d,n),r=u(h,c,-l,r,d,n),r=u(l,o,c,r,d,n),u(c,h,-o,r,d,n),e.addChild(n),e;function u(t,e,i,s,n,r){let a=t<=e?1:-1,o=s>=0?{point:t+s*a}:{point:t},l=i>0?[o,{point:i}]:[{point:-i},o];r.lineStyle({width:n.strokeWidth,color:n.color}),r.moveTo(l[0].point,l[1].point),o.point=s*a+t+n.dashLength*a,r.lineTo(l[0].point,l[1].point);let h=!1;for(o.point+=n.dashLength*a;o.point*a<=e*a;)h?(r.lineTo(l[0].point,l[1].point),h=!1,o.point+=n.dashSpacing*a):(r.moveTo(l[0].point,l[1].point),h=!0,o.point+=n.dashLength*a);return h?(i>0?r.lineTo(e,i):r.lineTo(-i,e),(e-o.point)*a):(o.point-e)*a}}_renderArea(t){switch(t.curveMode){case"linear":return this._renderPolygon(t);case"basis":return this._renderBezierArea(t);default:return li("areaPath",t,W.FEATURE_NOT_IMPLEMENTED)}}_renderBezierArea(t){let e=new s.Graphics;si(e,t.styles),e.lineStyle({width:t.styles.strokeWidth,color:ri(t.styles.strokeColor)});let i=fi(t.getSVGPathData());return hi(t.styles,e,t.bounds.height),di(e,i),e.endFill(),e}_renderPolygon(t){let e=new o.Container,i=this._renderLinearPath(t);i.getChildAt(0).lineTo(t.vertices[0].x,t.vertices[0].y);let s=new o.Graphics;si(s,t.styles);let n=[];for(const e of t.vertices)n.push(e.x-t.bounds.left),n.push(e.y-t.bounds.top);return hi(t.styles,s,t.bounds.height),s.drawPolygon(n),s.x+=t.bounds.left,s.y+=t.bounds.top,s.endFill(),e.addChild(s),e.addChild(i),e}_renderPath(t){switch(t.curveMode){case"linear":return this._renderLinearPath(t);case"bumpX":case"natural":return this._renderBezierPath(t);default:li("path",t,W.FEATURE_NOT_IMPLEMENTED)}}_renderLinearPath(t){let e=new s.Container,i=new s.Graphics,n="none"==t.styles.strokeDash;si(i,t.styles);let r=t.vertices[0];if(i.lineStyle({width:t.styles.strokeWidth,color:ri(t.styles.strokeColor)}),i.moveTo(r.x,r.y),n)for(let e=1;e<t.vertices.length;e++){const s=t.vertices[e];i.lineTo(s.x,s.y)}else!function(t,e,i){let s,n,r,a=0,o=0,l=e.split(" "),h=Number(l[0]),c=Number(l[1]);for(s=0;s<t.length&&(n=t[s],s!=t.length-1);s++){r=t[s+1];let e=r.x-n.x,l=r.y-n.y,d=Math.sqrt(e*e+l*l),u={x:e/d,y:l/d},f=0;for(i.moveTo(n.x+o*u.x,n.y+o*u.y);f<=d;)f+=o,f+=a>0?a:h,f>d?(a=f-d,f=d):a=0,i.lineTo(n.x+f*u.x,n.y+f*u.y),f+=c,f>d&&0==a?o=f-d:(o=0,i.moveTo(n.x+f*u.x,n.y+f*u.y))}}(t.vertices,t.styles.strokeDash,i);e.addChild(i);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderBezierPath(t){let e=new s.Container,i=new s.Graphics;si(i,t.styles),i.lineStyle({width:t.styles.strokeWidth,color:ri(t.styles.strokeColor)}),di(i,fi(t.getSVGPathData())),e.addChild(i);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderVertex(t){switch(t.shape){case"rect":return function(t){let e=new o.Graphics;return e.lineStyle({width:t.strokeWidth,color:ri(t.strokeColor)}),e.beginFill(ri(t.fillColor)),e.drawRect(t.x-t.width/2,t.y-t.height/2,t.width,t.height),e.endFill(),e}(t);case"circle":return function(t){let e=new o.Graphics;return e.lineStyle({width:t.strokeWidth,color:ri(t.strokeColor)}),e.beginFill(ri(t.fillColor)),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}(t);case void 0:return null;default:li("vertex shape",t.shape,W.FEATURE_NOT_IMPLEMENTED)}}_renderCircle(t){let e=new s.Graphics;return si(e,t.styles),e.lineStyle(t.styles.strokeWidth,ri(t.styles.strokeColor)),hi(t.styles,e,t.height),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}_renderRing(t){let e=new s.Graphics;return e.lineStyle(t.outerRadius-t.innerRadius,ri(t.styles.fillColor)),e.drawCircle(t.x,t.y,(t.innerRadius+t.outerRadius)/2),e.endFill(),e}_renderArc(t){let e=new s.Graphics;return e.lineStyle({color:ri(t.styles.strokeColor),width:t.styles.strokeWidth}),e.beginFill(ri(t.styles.fillColor)),e.arc(t.x,t.y,t.outerRadius,-t.endAngle*ei,-t.startAngle*ei),e.arc(t.x,t.y,t.innerRadius,-t.startAngle*ei,-t.endAngle*ei,!0),e.endFill(),e}_renderImage(t){let e=o.Sprite.from(t.src);return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}_renderLink(t){switch(t.curveMode){case"linear":return function(t){let e=new s.Graphics;return si(e,t.styles),e.lineStyle({color:ri(t.styles.strokeColor),width:t.styles.strokeWidth}),di(e,fi(t.getSVGPathData())),e}(t);default:li("link",t.curveMode,"unexpected curvemode")}}}function si(t,e){t.visible=function(t){switch(t){case"hidden":return!1;case null:case void 0:case"visible":default:return!0}}(e.visibility),t.alpha=function(t){switch(t){case void 0:case null:return 1;default:return t}}(e.opacity)}function ni(t){switch(t){case"regular":case"normal":return"normal";case"bold":return"bold";default:console.log(t),li("font weight",t,W.FEATURE_NOT_IMPLEMENTED)}}function ri(t){let e=r.color(t);if(null==e)return null;{let t=e.formatHex();return o.utils.string2hex(t)}}function ai(t){return void 0===t||"number"!=typeof t[0]?0:t[0]}function oi(t){return void 0===t||"number"!=typeof t[0]?[0,0]:t.slice(1)}function li(t,e,i){throw console.log(e),new Error(`${i}. Source: ${t}, Actual: `)}function hi(t,e,i){let s=t.fillColor;if("none"==s)return;let n=ri(s);null!=n?e.beginFill(n):e.beginTextureFill({color:16777215,texture:ci(i,s.stops,s.y1>s.y2)})}function ci(t,e,i){const s=document.createElement("canvas");s.height=t,s.width=1;const n=s.getContext("2d"),r=n.createLinearGradient(0,0,0,t);for(let t=0;t<e.length;t++)i?r.addColorStop(1-e[t].offset/100,e[t].color):r.addColorStop(e[t].offset/100,e[t].color);return n.fillStyle=r,n.fillRect(0,0,1,t),o.Texture.from(s)}function di(t,e){let i=e.pop(),s=()=>{};"Z"==i.code.toUpperCase()?s=()=>t.lineTo(e[0].end.x,e[0].end.y):e.push(i);for(const i of e)ui(i,t);s()}function ui(t,e){switch(t.code.toUpperCase()){case"M":e.moveTo(t.end.x,t.end.y);break;case"L":e.lineTo(t.end.x,t.end.y);break;case"Q":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp1.x,t.cp1.y,t.end.x,t.end.y);break;case"C":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.end.x,t.end.y);break;case"Z":throw new Error('Unexpected "z" marker. There\'s something wrong, I can feel it');default:return li("data",t,W.FEATURE_NOT_IMPLEMENTED)}}function fi(t){let e={command:/\s*([achlmqstvz])/gi,number:/\s*([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/gi,comma:/\s*(?:(,)|\s)/g,flag:/\s*([01])/g},i={number:function(t){return+a("number",t)},"coordinate pair":function(t){let e=a("number",t);return null!==e||t?(a("comma"),{x:+e,y:+a("number",!0)}):null},"arc definition":function(t){let e=i["coordinate pair"](t);if(!e&&!t)return null;a("comma");let s=+a("number",!0);a("comma",!0);let n=!!+a("flag",!0);a("comma");let r=!!+a("flag",!0);return a("comma"),{radii:e,rotation:s,large:n,clockwise:r,end:i["coordinate pair"](!0)}}},s=0,n=[];for(;s<t.length;){let t,e=a("command"),i=e.toUpperCase(),l=e!==i;switch(i){case"M":t=o("coordinate pair").map((function(t,i){return 1===i&&(e=l?"l":"L"),r({end:t},e,l)}));break;case"L":case"T":t=o("coordinate pair").map((function(t){return r({end:t},e,l)}));break;case"C":if(t=o("coordinate pair"),t.length%3)throw Error("Expected coordinate pair triplet at position "+s);t=t.reduce((function(t,i,s){let n=s%3;if(n){t[t.length-1][1===n?"cp2":"end"]=i}else t.push(r({cp1:i},e,l));return t}),[]);break;case"Q":case"S":if(t=o("coordinate pair"),1&t.length)throw Error("Expected coordinate pair couple at position "+s);t=t.reduce((function(t,i,s){if(1&s){t[t.length-1].end=i}else t.push(r({cp:i},e,l));return t}),[]);break;case"H":case"V":t=o("number").map((function(t){return r({value:t},e,l)}));break;case"A":t=o("arc definition").map(r,e,l);break;case"Z":t=[{code:"Z"}]}n.push.apply(n,t)}return n;function r(t,e,i){return t.code=e,t.relative=i,t}function a(i,n){e[i].lastIndex=s;let r=e[i].exec(t);if(!r||r.index!==s){if(!n)return null;throw Error("Expected "+i+" at position "+s)}return s=e[i].lastIndex,r[1]}function o(t){let e,s=[],n=!0;for(;null!==(e=i[t](n));)s.push(e),n=!!a("comma");return s}}var pi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function gi(t,e){return t(e={exports:{}},e.exports),e.exports}var _i=function(){this.__data__=[],this.size=0};var mi=function(t,e){return t===e||t!=t&&e!=e};var yi=function(t,e){for(var i=t.length;i--;)if(mi(t[i][0],e))return i;return-1},vi=Array.prototype.splice;var bi=function(t){var e=this.__data__,i=yi(e,t);return!(i<0)&&(i==e.length-1?e.pop():vi.call(e,i,1),--this.size,!0)};var xi=function(t){var e=this.__data__,i=yi(e,t);return i<0?void 0:e[i][1]};var wi=function(t){return yi(this.__data__,t)>-1};var ki=function(t,e){var i=this.__data__,s=yi(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};function Si(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}Si.prototype.clear=_i,Si.prototype.delete=bi,Si.prototype.get=xi,Si.prototype.has=wi,Si.prototype.set=ki;var Ci=Si;var Ei=function(){this.__data__=new Ci,this.size=0};var Ai=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Ti=function(t){return this.__data__.get(t)};var Ii=function(t){return this.__data__.has(t)},Oi="object"==typeof pi&&pi&&pi.Object===Object&&pi,Mi="object"==typeof self&&self&&self.Object===Object&&self,Ri=Oi||Mi||Function("return this")(),Ni=Ri.Symbol,Bi=Object.prototype,Pi=Bi.hasOwnProperty,Fi=Bi.toString,Li=Ni?Ni.toStringTag:void 0;var Di=
|
|
5
5
|
/**
|
|
6
6
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
7
7
|
*
|
|
@@ -9,7 +9,7 @@ set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let
|
|
|
9
9
|
* @param {*} value The value to query.
|
|
10
10
|
* @returns {string} Returns the raw `toStringTag`.
|
|
11
11
|
*/
|
|
12
|
-
function(t){var e=
|
|
12
|
+
function(t){var e=Pi.call(t,Li),i=t[Li];try{t[Li]=void 0;var s=!0}catch(t){}var n=Fi.call(t);return s&&(e?t[Li]=i:delete t[Li]),n},ji=Object.prototype.toString;var Vi=function(t){return ji.call(t)},zi=Ni?Ni.toStringTag:void 0;var Gi=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":zi&&zi in Object(t)?Di(t):Vi(t)};var Wi=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};var Ui,qi=function(t){if(!Wi(t))return!1;var e=Gi(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Hi=Ri["__core-js_shared__"],Ji=(Ui=/[^.]+$/.exec(Hi&&Hi.keys&&Hi.keys.IE_PROTO||""))?"Symbol(src)_1."+Ui:"";var Yi=function(t){return!!Ji&&Ji in t},$i=Function.prototype.toString;var Zi=function(t){if(null!=t){try{return $i.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Ki=/^\[object .+?Constructor\]$/,Xi=Function.prototype,Qi=Object.prototype,ts=Xi.toString,es=Qi.hasOwnProperty,is=RegExp("^"+ts.call(es).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var ss=function(t){return!(!Wi(t)||Yi(t))&&(qi(t)?is:Ki).test(Zi(t))};var ns=function(t,e){return null==t?void 0:t[e]};var rs=function(t,e){var i=ns(t,e);return ss(i)?i:void 0},as=rs(Ri,"Map"),os=rs(Object,"create");var ls=function(){this.__data__=os?os(null):{},this.size=0};var hs=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},cs=Object.prototype.hasOwnProperty;var ds=function(t){var e=this.__data__;if(os){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return cs.call(e,t)?e[t]:void 0},us=Object.prototype.hasOwnProperty;var fs=function(t){var e=this.__data__;return os?void 0!==e[t]:us.call(e,t)};var ps=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=os&&void 0===e?"__lodash_hash_undefined__":e,this};function gs(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}gs.prototype.clear=ls,gs.prototype.delete=hs,gs.prototype.get=ds,gs.prototype.has=fs,gs.prototype.set=ps;var _s=gs;var ms=function(){this.size=0,this.__data__={hash:new _s,map:new(as||Ci),string:new _s}};var ys=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var vs=function(t,e){var i=t.__data__;return ys(e)?i["string"==typeof e?"string":"hash"]:i.map};var bs=function(t){var e=vs(this,t).delete(t);return this.size-=e?1:0,e};var xs=function(t){return vs(this,t).get(t)};var ws=function(t){return vs(this,t).has(t)};var ks=function(t,e){var i=vs(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};function Ss(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}Ss.prototype.clear=ms,Ss.prototype.delete=bs,Ss.prototype.get=xs,Ss.prototype.has=ws,Ss.prototype.set=ks;var Cs=Ss;var Es=function(t,e){var i=this.__data__;if(i instanceof Ci){var s=i.__data__;if(!as||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new Cs(s)}return i.set(t,e),this.size=i.size,this};function As(t){var e=this.__data__=new Ci(t);this.size=e.size}As.prototype.clear=Ei,As.prototype.delete=Ai,As.prototype.get=Ti,As.prototype.has=Ii,As.prototype.set=Es;var Ts=As;
|
|
13
13
|
/**
|
|
14
14
|
* A specialized version of `_.forEach` for arrays without support for
|
|
15
15
|
* iteratee shorthands.
|
|
@@ -18,7 +18,7 @@ function(t){var e=_i.call(t,yi),i=t[yi];try{t[yi]=void 0;var s=!0}catch(t){}var
|
|
|
18
18
|
* @param {Array} [array] The array to iterate over.
|
|
19
19
|
* @param {Function} iteratee The function invoked per iteration.
|
|
20
20
|
* @returns {Array} Returns `array`.
|
|
21
|
-
*/var
|
|
21
|
+
*/var Is=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i,t););return t},Os=function(){try{var t=rs(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var Ms=function(t,e,i){"__proto__"==e&&Os?Os(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i},Rs=Object.prototype.hasOwnProperty;var Ns=function(t,e,i){var s=t[e];Rs.call(t,e)&&mi(s,i)&&(void 0!==i||e in t)||Ms(t,e,i)};var Bs=function(t,e,i,s){var n=!i;i||(i={});for(var r=-1,a=e.length;++r<a;){var o=e[r],l=s?s(i[o],t[o],o,i,t):void 0;void 0===l&&(l=t[o]),n?Ms(i,o,l):Ns(i,o,l)}return i};var Ps=function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s};var Fs=function(t){return null!=t&&"object"==typeof t};var Ls=function(t){return Fs(t)&&"[object Arguments]"==Gi(t)},Ds=Object.prototype,js=Ds.hasOwnProperty,Vs=Ds.propertyIsEnumerable,zs=Ls(function(){return arguments}())?Ls:function(t){return Fs(t)&&js.call(t,"callee")&&!Vs.call(t,"callee")},Gs=Array.isArray;var Ws=function(){return!1},Us=gi((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?Ri.Buffer:void 0,r=(n?n.isBuffer:void 0)||Ws;t.exports=r})),qs=/^(?:0|[1-9]\d*)$/;var Hs=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&qs.test(t))&&t>-1&&t%1==0&&t<e};var Js=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Ys={};Ys["[object Float32Array]"]=Ys["[object Float64Array]"]=Ys["[object Int8Array]"]=Ys["[object Int16Array]"]=Ys["[object Int32Array]"]=Ys["[object Uint8Array]"]=Ys["[object Uint8ClampedArray]"]=Ys["[object Uint16Array]"]=Ys["[object Uint32Array]"]=!0,Ys["[object Arguments]"]=Ys["[object Array]"]=Ys["[object ArrayBuffer]"]=Ys["[object Boolean]"]=Ys["[object DataView]"]=Ys["[object Date]"]=Ys["[object Error]"]=Ys["[object Function]"]=Ys["[object Map]"]=Ys["[object Number]"]=Ys["[object Object]"]=Ys["[object RegExp]"]=Ys["[object Set]"]=Ys["[object String]"]=Ys["[object WeakMap]"]=!1;var $s=function(t){return Fs(t)&&Js(t.length)&&!!Ys[Gi(t)]};var Zs=function(t){return function(e){return t(e)}},Ks=gi((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i&&Oi.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||n&&n.binding&&n.binding("util")}catch(t){}}();t.exports=r})),Xs=Ks&&Ks.isTypedArray,Qs=Xs?Zs(Xs):$s,tn=Object.prototype.hasOwnProperty;var en=function(t,e){var i=Gs(t),s=!i&&zs(t),n=!i&&!s&&Us(t),r=!i&&!s&&!n&&Qs(t),a=i||s||n||r,o=a?Ps(t.length,String):[],l=o.length;for(var h in t)!e&&!tn.call(t,h)||a&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Hs(h,l))||o.push(h);return o},sn=Object.prototype;var nn=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||sn)};var rn=function(t,e){return function(i){return t(e(i))}},an=rn(Object.keys,Object),on=Object.prototype.hasOwnProperty;var ln=function(t){if(!nn(t))return an(t);var e=[];for(var i in Object(t))on.call(t,i)&&"constructor"!=i&&e.push(i);return e};var hn=function(t){return null!=t&&Js(t.length)&&!qi(t)};var cn=function(t){return hn(t)?en(t):ln(t)};var dn=function(t,e){return t&&Bs(e,cn(e),t)};var un=function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e},fn=Object.prototype.hasOwnProperty;var pn=function(t){if(!Wi(t))return un(t);var e=nn(t),i=[];for(var s in t)("constructor"!=s||!e&&fn.call(t,s))&&i.push(s);return i};var gn=function(t){return hn(t)?en(t,!0):pn(t)};var _n=function(t,e){return t&&Bs(e,gn(e),t)},mn=gi((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?Ri.Buffer:void 0,r=n?n.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var i=t.length,s=r?r(i):new t.constructor(i);return t.copy(s),s}}));var yn=function(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e};
|
|
22
22
|
/**
|
|
23
23
|
* A specialized version of `_.filter` for arrays without support for
|
|
24
24
|
* iteratee shorthands.
|
|
@@ -27,7 +27,7 @@ function(t){var e=_i.call(t,yi),i=t[yi];try{t[yi]=void 0;var s=!0}catch(t){}var
|
|
|
27
27
|
* @param {Array} [array] The array to iterate over.
|
|
28
28
|
* @param {Function} predicate The function invoked per iteration.
|
|
29
29
|
* @returns {Array} Returns the new filtered array.
|
|
30
|
-
*/var
|
|
30
|
+
*/var vn=function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var a=t[i];e(a,i,t)&&(r[n++]=a)}return r};var bn=function(){return[]},xn=Object.prototype.propertyIsEnumerable,wn=Object.getOwnPropertySymbols,kn=wn?function(t){return null==t?[]:(t=Object(t),vn(wn(t),(function(e){return xn.call(t,e)})))}:bn;var Sn=function(t,e){return Bs(t,kn(t),e)};var Cn=function(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t},En=rn(Object.getPrototypeOf,Object),An=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Cn(e,kn(t)),t=En(t);return e}:bn;var Tn=function(t,e){return Bs(t,An(t),e)};var In=function(t,e,i){var s=e(t);return Gs(t)?s:Cn(s,i(t))};var On=function(t){return In(t,cn,kn)};var Mn=function(t){return In(t,gn,An)},Rn=rs(Ri,"DataView"),Nn=rs(Ri,"Promise"),Bn=rs(Ri,"Set"),Pn=rs(Ri,"WeakMap"),Fn="[object Map]",Ln="[object Promise]",Dn="[object Set]",jn="[object WeakMap]",Vn="[object DataView]",zn=Zi(Rn),Gn=Zi(as),Wn=Zi(Nn),Un=Zi(Bn),qn=Zi(Pn),Hn=Gi;(Rn&&Hn(new Rn(new ArrayBuffer(1)))!=Vn||as&&Hn(new as)!=Fn||Nn&&Hn(Nn.resolve())!=Ln||Bn&&Hn(new Bn)!=Dn||Pn&&Hn(new Pn)!=jn)&&(Hn=function(t){var e=Gi(t),i="[object Object]"==e?t.constructor:void 0,s=i?Zi(i):"";if(s)switch(s){case zn:return Vn;case Gn:return Fn;case Wn:return Ln;case Un:return Dn;case qn:return jn}return e});var Jn=Hn,Yn=Object.prototype.hasOwnProperty;var $n=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Yn.call(t,"index")&&(i.index=t.index,i.input=t.input),i},Zn=Ri.Uint8Array;var Kn=function(t){var e=new t.constructor(t.byteLength);return new Zn(e).set(new Zn(t)),e};var Xn=function(t,e){var i=e?Kn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)},Qn=/\w*$/;var tr=function(t){var e=new t.constructor(t.source,Qn.exec(t));return e.lastIndex=t.lastIndex,e},er=Ni?Ni.prototype:void 0,ir=er?er.valueOf:void 0;var sr=function(t){return ir?Object(ir.call(t)):{}};var nr=function(t,e){var i=e?Kn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var rr=function(t,e,i){var s=t.constructor;switch(e){case"[object ArrayBuffer]":return Kn(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return Xn(t,i);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 nr(t,i);case"[object Map]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return tr(t);case"[object Set]":return new s;case"[object Symbol]":return sr(t)}},ar=Object.create,or=function(){function t(){}return function(e){if(!Wi(e))return{};if(ar)return ar(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var lr=function(t){return"function"!=typeof t.constructor||nn(t)?{}:or(En(t))};var hr=function(t){return Fs(t)&&"[object Map]"==Jn(t)},cr=Ks&&Ks.isMap,dr=cr?Zs(cr):hr;var ur=function(t){return Fs(t)&&"[object Set]"==Jn(t)},fr=Ks&&Ks.isSet,pr=fr?Zs(fr):ur,gr="[object Arguments]",_r="[object Function]",mr="[object Object]",yr={};yr[gr]=yr["[object Array]"]=yr["[object ArrayBuffer]"]=yr["[object DataView]"]=yr["[object Boolean]"]=yr["[object Date]"]=yr["[object Float32Array]"]=yr["[object Float64Array]"]=yr["[object Int8Array]"]=yr["[object Int16Array]"]=yr["[object Int32Array]"]=yr["[object Map]"]=yr["[object Number]"]=yr[mr]=yr["[object RegExp]"]=yr["[object Set]"]=yr["[object String]"]=yr["[object Symbol]"]=yr["[object Uint8Array]"]=yr["[object Uint8ClampedArray]"]=yr["[object Uint16Array]"]=yr["[object Uint32Array]"]=!0,yr["[object Error]"]=yr[_r]=yr["[object WeakMap]"]=!1;var vr=function t(e,i,s,n,r,a){var o,l=1&i,h=2&i,c=4&i;if(s&&(o=r?s(e,n,r,a):s(e)),void 0!==o)return o;if(!Wi(e))return e;var d=Gs(e);if(d){if(o=$n(e),!l)return yn(e,o)}else{var u=Jn(e),f=u==_r||"[object GeneratorFunction]"==u;if(Us(e))return mn(e,l);if(u==mr||u==gr||f&&!r){if(o=h||f?{}:lr(e),!l)return h?Tn(e,_n(o,e)):Sn(e,dn(o,e))}else{if(!yr[u])return r?e:{};o=rr(e,u,l)}}a||(a=new Ts);var p=a.get(e);if(p)return p;a.set(e,o),pr(e)?e.forEach((function(n){o.add(t(n,i,s,n,e,a))})):dr(e)&&e.forEach((function(n,r){o.set(r,t(n,i,s,r,e,a))}));var g=d?void 0:(c?h?Mn:On:h?gn:cn)(e);return Is(g||e,(function(n,r){g&&(n=e[r=n]),Ns(o,r,t(n,i,s,r,e,a))})),o};var br=function(t){return vr(t,4)};var xr=function(t){return function(){return t}};var wr=function(t){return function(e,i,s){for(var n=-1,r=Object(e),a=s(e),o=a.length;o--;){var l=a[t?o:++n];if(!1===i(r[l],l,r))break}return e}}();var kr=function(t,e){return t&&wr(t,e,cn)};var Sr=function(t,e){return function(i,s){if(null==i)return i;if(!hn(i))return t(i,s);for(var n=i.length,r=e?n:-1,a=Object(i);(e?r--:++r<n)&&!1!==s(a[r],r,a););return i}}(kr);var Cr=function(t){return t};var Er=function(t){return"function"==typeof t?t:Cr};var Ar=function(t,e){return(Gs(t)?Is:Sr)(t,Er(e))},Tr=Ar;var Ir=function(t,e){var i=[];return Sr(t,(function(t,s,n){e(t,s,n)&&i.push(t)})),i};var Or=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};var Mr=function(t){return this.__data__.has(t)};function Rr(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Cs;++e<i;)this.add(t[e])}Rr.prototype.add=Rr.prototype.push=Or,Rr.prototype.has=Mr;var Nr=Rr;
|
|
31
31
|
/**
|
|
32
32
|
* A specialized version of `_.some` for arrays without support for iteratee
|
|
33
33
|
* shorthands.
|
|
@@ -37,7 +37,7 @@ function(t){var e=_i.call(t,yi),i=t[yi];try{t[yi]=void 0;var s=!0}catch(t){}var
|
|
|
37
37
|
* @param {Function} predicate The function invoked per iteration.
|
|
38
38
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
39
39
|
* else `false`.
|
|
40
|
-
*/var
|
|
40
|
+
*/var Br=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s;)if(e(t[i],i,t))return!0;return!1};var Pr=function(t,e){return t.has(e)};var Fr=
|
|
41
41
|
/**
|
|
42
42
|
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
43
43
|
* partial deep comparisons.
|
|
@@ -51,7 +51,7 @@ function(t){var e=_i.call(t,yi),i=t[yi];try{t[yi]=void 0;var s=!0}catch(t){}var
|
|
|
51
51
|
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
52
52
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
53
53
|
*/
|
|
54
|
-
function(t,e,i,s,n,r){var a=1&i,o=t.length,
|
|
54
|
+
function(t,e,i,s,n,r){var a=1&i,o=t.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var h=r.get(t),c=r.get(e);if(h&&c)return h==e&&c==t;var d=-1,u=!0,f=2&i?new Nr:void 0;for(r.set(t,e),r.set(e,t);++d<o;){var p=t[d],g=e[d];if(s)var _=a?s(g,p,d,e,t,r):s(p,g,d,t,e,r);if(void 0!==_){if(_)continue;u=!1;break}if(f){if(!Br(e,(function(t,e){if(!Pr(f,e)&&(p===t||n(p,t,i,s,r)))return f.push(e)}))){u=!1;break}}else if(p!==g&&!n(p,g,i,s,r)){u=!1;break}}return r.delete(t),r.delete(e),u};var Lr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,s){i[++e]=[s,t]})),i};var Dr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},jr=Ni?Ni.prototype:void 0,Vr=jr?jr.valueOf:void 0;var zr=
|
|
55
55
|
/**
|
|
56
56
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
57
57
|
* the same `toStringTag`.
|
|
@@ -69,7 +69,7 @@ function(t,e,i,s,n,r){var a=1&i,o=t.length,h=e.length;if(o!=h&&!(a&&h>o))return!
|
|
|
69
69
|
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
70
70
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
71
71
|
*/
|
|
72
|
-
function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new
|
|
72
|
+
function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new Zn(t),new Zn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return mi(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var o=Lr;case"[object Set]":var l=1&s;if(o||(o=Dr),t.size!=e.size&&!l)return!1;var h=a.get(t);if(h)return h==e;s|=2,a.set(t,e);var c=Fr(o(t),o(e),s,n,r,a);return a.delete(t),c;case"[object Symbol]":if(Vr)return Vr.call(t)==Vr.call(e)}return!1},Gr=Object.prototype.hasOwnProperty;var Wr=
|
|
73
73
|
/**
|
|
74
74
|
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
75
75
|
* partial deep comparisons.
|
|
@@ -83,7 +83,7 @@ function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byt
|
|
|
83
83
|
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
84
84
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
85
85
|
*/
|
|
86
|
-
function(t,e,i,s,n,r){var a=1&i,o=
|
|
86
|
+
function(t,e,i,s,n,r){var a=1&i,o=On(t),l=o.length;if(l!=On(e).length&&!a)return!1;for(var h=l;h--;){var c=o[h];if(!(a?c in e:Gr.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var f=!0;r.set(t,e),r.set(e,t);for(var p=a;++h<l;){var g=t[c=o[h]],_=e[c];if(s)var m=a?s(_,g,c,e,t,r):s(g,_,c,t,e,r);if(!(void 0===m?g===_||n(g,_,i,s,r):m)){f=!1;break}p||(p="constructor"==c)}if(f&&!p){var y=t.constructor,v=e.constructor;y==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v||(f=!1)}return r.delete(t),r.delete(e),f},Ur="[object Arguments]",qr="[object Array]",Hr="[object Object]",Jr=Object.prototype.hasOwnProperty;var Yr=
|
|
87
87
|
/**
|
|
88
88
|
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
89
89
|
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
@@ -98,7 +98,7 @@ function(t,e,i,s,n,r){var a=1&i,o=dn(t),h=o.length;if(h!=dn(e).length&&!a)return
|
|
|
98
98
|
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
99
99
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
100
100
|
*/
|
|
101
|
-
function(t,e,i,s,n,r){var a=
|
|
101
|
+
function(t,e,i,s,n,r){var a=Gs(t),o=Gs(e),l=a?qr:Jn(t),h=o?qr:Jn(e),c=(l=l==Ur?Hr:l)==Hr,d=(h=h==Ur?Hr:h)==Hr,u=l==h;if(u&&Us(t)){if(!Us(e))return!1;a=!0,c=!1}if(u&&!c)return r||(r=new Ts),a||Qs(t)?Fr(t,e,i,s,n,r):zr(t,e,l,i,s,n,r);if(!(1&i)){var f=c&&Jr.call(t,"__wrapped__"),p=d&&Jr.call(e,"__wrapped__");if(f||p){var g=f?t.value():t,_=p?e.value():e;return r||(r=new Ts),n(g,_,i,s,r)}}return!!u&&(r||(r=new Ts),Wr(t,e,i,s,n,r))};var $r=function t(e,i,s,n,r){return e===i||(null==e||null==i||!Fs(e)&&!Fs(i)?e!=e&&i!=i:Yr(e,i,s,n,t,r))};var Zr=function(t,e,i,s){var n=i.length,r=n,a=!s;if(null==t)return!r;for(t=Object(t);n--;){var o=i[n];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<r;){var l=(o=i[n])[0],h=t[l],c=o[1];if(a&&o[2]){if(void 0===h&&!(l in t))return!1}else{var d=new Ts;if(s)var u=s(h,c,l,t,e,d);if(!(void 0===u?$r(c,h,3,s,d):u))return!1}}return!0};var Kr=function(t){return t==t&&!Wi(t)};var Xr=function(t){for(var e=cn(t),i=e.length;i--;){var s=e[i],n=t[s];e[i]=[s,n,Kr(n)]}return e};
|
|
102
102
|
/**
|
|
103
103
|
* A specialized version of `matchesProperty` for source values suitable
|
|
104
104
|
* for strict equality comparisons, i.e. `===`.
|
|
@@ -107,7 +107,7 @@ function(t,e,i,s,n,r){var a=ks(t),o=ks(e),h=a?Er:An(t),l=o?Er:An(e),c=(h=h==Sr?T
|
|
|
107
107
|
* @param {string} key The key of the property to get.
|
|
108
108
|
* @param {*} srcValue The value to match.
|
|
109
109
|
* @returns {Function} Returns the new spec function.
|
|
110
|
-
*/var
|
|
110
|
+
*/var Qr=function(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in Object(i)))}};var ta=function(t){var e=Xr(t);return 1==e.length&&e[0][2]?Qr(e[0][0],e[0][1]):function(i){return i===t||Zr(i,t,e)}};var ea=function(t){return"symbol"==typeof t||Fs(t)&&"[object Symbol]"==Gi(t)},ia=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,sa=/^\w*$/;var na=function(t,e){if(Gs(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!ea(t))||(sa.test(t)||!ia.test(t)||null!=e&&t in Object(e))};function ra(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var i=function(){var s=arguments,n=e?e.apply(this,s):s[0],r=i.cache;if(r.has(n))return r.get(n);var a=t.apply(this,s);return i.cache=r.set(n,a)||r,a};return i.cache=new(ra.Cache||Cs),i}ra.Cache=Cs;var aa=ra;var oa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,la=/\\(\\)?/g,ha=
|
|
111
111
|
/**
|
|
112
112
|
* A specialized version of `_.memoize` which clears the memoized function's
|
|
113
113
|
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
@@ -116,7 +116,7 @@ function(t,e,i,s,n,r){var a=ks(t),o=ks(e),h=a?Er:An(t),l=o?Er:An(e),c=(h=h==Sr?T
|
|
|
116
116
|
* @param {Function} func The function to have its output memoized.
|
|
117
117
|
* @returns {Function} Returns the new memoized function.
|
|
118
118
|
*/
|
|
119
|
-
function(t){var e=
|
|
119
|
+
function(t){var e=aa(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(oa,(function(t,i,s,n){e.push(s?n.replace(la,"$1"):i||t)})),e}));var ca=
|
|
120
120
|
/**
|
|
121
121
|
* A specialized version of `_.map` for arrays without support for iteratee
|
|
122
122
|
* shorthands.
|
|
@@ -126,14 +126,14 @@ function(t){var e=zr(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cach
|
|
|
126
126
|
* @param {Function} iteratee The function invoked per iteration.
|
|
127
127
|
* @returns {Array} Returns the new mapped array.
|
|
128
128
|
*/
|
|
129
|
-
function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,t);return n},
|
|
129
|
+
function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,t);return n},da=Ni?Ni.prototype:void 0,ua=da?da.toString:void 0;var fa=function t(e){if("string"==typeof e)return e;if(Gs(e))return ca(e,t)+"";if(ea(e))return ua?ua.call(e):"";var i=e+"";return"0"==i&&1/e==-Infinity?"-0":i};var pa=function(t){return null==t?"":fa(t)};var ga=function(t,e){return Gs(t)?t:na(t,e)?[t]:ha(pa(t))};var _a=function(t){if("string"==typeof t||ea(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var ma=function(t,e){for(var i=0,s=(e=ga(e,t)).length;null!=t&&i<s;)t=t[_a(e[i++])];return i&&i==s?t:void 0};var ya=function(t,e,i){var s=null==t?void 0:ma(t,e);return void 0===s?i:s};var va=function(t,e){return null!=t&&e in Object(t)};var ba=function(t,e,i){for(var s=-1,n=(e=ga(e,t)).length,r=!1;++s<n;){var a=_a(e[s]);if(!(r=null!=t&&i(t,a)))break;t=t[a]}return r||++s!=n?r:!!(n=null==t?0:t.length)&&Js(n)&&Hs(a,n)&&(Gs(t)||zs(t))};var xa=function(t,e){return null!=t&&ba(t,e,va)};var wa=function(t,e){return na(t)&&Kr(e)?Qr(_a(t),e):function(i){var s=ya(i,t);return void 0===s&&s===e?xa(i,t):$r(e,s,3)}};var ka=function(t){return function(e){return null==e?void 0:e[t]}};
|
|
130
130
|
/**
|
|
131
131
|
* A specialized version of `baseProperty` which supports deep paths.
|
|
132
132
|
*
|
|
133
133
|
* @private
|
|
134
134
|
* @param {Array|string} path The path of the property to get.
|
|
135
135
|
* @returns {Function} Returns the new accessor function.
|
|
136
|
-
*/var
|
|
136
|
+
*/var Sa=function(t){return function(e){return ma(e,t)}};var Ca=function(t){return na(t)?ka(_a(t)):Sa(t)};var Ea=function(t){return"function"==typeof t?t:null==t?Cr:"object"==typeof t?Gs(t)?wa(t[0],t[1]):ta(t):Ca(t)};var Aa=function(t,e){return(Gs(t)?vn:Ir)(t,Ea(e))},Ta=Object.prototype.hasOwnProperty;var Ia=function(t,e){return null!=t&&Ta.call(t,e)};var Oa=function(t,e){return null!=t&&ba(t,e,Ia)},Ma=Object.prototype.hasOwnProperty;var Ra=function(t){if(null==t)return!0;if(hn(t)&&(Gs(t)||"string"==typeof t||"function"==typeof t.splice||Us(t)||Qs(t)||zs(t)))return!t.length;var e=Jn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(nn(t))return!ln(t).length;for(var i in t)if(Ma.call(t,i))return!1;return!0};var Na=function(t){return void 0===t};var Ba=function(t,e){var i=-1,s=hn(t)?Array(t.length):[];return Sr(t,(function(t,n,r){s[++i]=e(t,n,r)})),s};var Pa=function(t,e){return(Gs(t)?ca:Ba)(t,Ea(e))};
|
|
137
137
|
/**
|
|
138
138
|
* A specialized version of `_.reduce` for arrays without support for
|
|
139
139
|
* iteratee shorthands.
|
|
@@ -145,7 +145,7 @@ function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,
|
|
|
145
145
|
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
|
146
146
|
* the initial value.
|
|
147
147
|
* @returns {*} Returns the accumulated value.
|
|
148
|
-
*/var
|
|
148
|
+
*/var Fa=function(t,e,i,s){var n=-1,r=null==t?0:t.length;for(s&&r&&(i=t[++n]);++n<r;)i=e(i,t[n],n,t);return i};var La=function(t,e,i,s,n){return n(t,(function(t,n,r){i=s?(s=!1,t):e(i,t,n,r)})),i};var Da=function(t,e,i){var s=Gs(t)?Fa:La,n=arguments.length<3;return s(t,Ea(e),i,n,Sr)};var ja=function(t){return"string"==typeof t||!Gs(t)&&Fs(t)&&"[object String]"==Gi(t)},Va=ka("length"),za=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Ga=function(t){return za.test(t)},Wa="[\\ud800-\\udfff]",Ua="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",qa="\\ud83c[\\udffb-\\udfff]",Ha="[^\\ud800-\\udfff]",Ja="(?:\\ud83c[\\udde6-\\uddff]){2}",Ya="[\\ud800-\\udbff][\\udc00-\\udfff]",$a="(?:"+Ua+"|"+qa+")"+"?",Za="[\\ufe0e\\ufe0f]?",Ka=Za+$a+("(?:\\u200d(?:"+[Ha,Ja,Ya].join("|")+")"+Za+$a+")*"),Xa="(?:"+[Ha+Ua+"?",Ua,Ja,Ya,Wa].join("|")+")",Qa=RegExp(qa+"(?="+qa+")|"+Xa+Ka,"g");var to=function(t){for(var e=Qa.lastIndex=0;Qa.test(t);)++e;return e};var eo=function(t){return Ga(t)?to(t):Va(t)};var io=function(t){if(null==t)return 0;if(hn(t))return ja(t)?eo(t):t.length;var e=Jn(t);return"[object Map]"==e||"[object Set]"==e?t.size:ln(t).length};var so=function(t,e,i){var s=Gs(t),n=s||Us(t)||Qs(t);if(e=Ea(e),null==i){var r=t&&t.constructor;i=n?s?new r:[]:Wi(t)&&qi(r)?or(En(t)):{}}return(n?Is:kr)(t,(function(t,s,n){return e(i,t,s,n)})),i},no=Ni?Ni.isConcatSpreadable:void 0;var ro=function(t){return Gs(t)||zs(t)||!!(no&&t&&t[no])};var ao=function t(e,i,s,n,r){var a=-1,o=e.length;for(s||(s=ro),r||(r=[]);++a<o;){var l=e[a];i>0&&s(l)?i>1?t(l,i-1,s,n,r):Cn(r,l):n||(r[r.length]=l)}return r};var oo=function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)},lo=Math.max;var ho=
|
|
149
149
|
/**
|
|
150
150
|
* A specialized version of `baseRest` which transforms the rest array.
|
|
151
151
|
*
|
|
@@ -155,7 +155,7 @@ function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,
|
|
|
155
155
|
* @param {Function} transform The rest array transform.
|
|
156
156
|
* @returns {Function} Returns the new function.
|
|
157
157
|
*/
|
|
158
|
-
function(t,e,i){return e=
|
|
158
|
+
function(t,e,i){return e=lo(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=lo(s.length-e,0),a=Array(r);++n<r;)a[n]=s[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=s[n];return o[e]=i(a),oo(t,this,o)}},co=Os?function(t,e){return Os(t,"toString",{configurable:!0,enumerable:!1,value:xr(e),writable:!0})}:Cr,uo=Date.now;var fo=function(t){var e=0,i=0;return function(){var s=uo(),n=16-(s-i);if(i=s,n>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(co);var po=function(t,e){return fo(ho(t,e,Cr),t+"")};var go=function(t,e,i,s){for(var n=t.length,r=i+(s?1:-1);s?r--:++r<n;)if(e(t[r],r,t))return r;return-1};var _o=function(t){return t!=t};
|
|
159
159
|
/**
|
|
160
160
|
* A specialized version of `_.indexOf` which performs strict equality
|
|
161
161
|
* comparisons of values, i.e. `===`.
|
|
@@ -165,7 +165,7 @@ function(t,e,i){return e=Wa(void 0===e?t.length-1:e,0),function(){for(var s=argu
|
|
|
165
165
|
* @param {*} value The value to search for.
|
|
166
166
|
* @param {number} fromIndex The index to search from.
|
|
167
167
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
168
|
-
*/var
|
|
168
|
+
*/var mo=function(t,e,i){for(var s=i-1,n=t.length;++s<n;)if(t[s]===e)return s;return-1};var yo=function(t,e,i){return e==e?mo(t,e,i):go(t,_o,i)};
|
|
169
169
|
/**
|
|
170
170
|
* A specialized version of `_.includes` for arrays without support for
|
|
171
171
|
* specifying an index to search from.
|
|
@@ -174,7 +174,7 @@ function(t,e,i){return e=Wa(void 0===e?t.length-1:e,0),function(){for(var s=argu
|
|
|
174
174
|
* @param {Array} [array] The array to inspect.
|
|
175
175
|
* @param {*} target The value to search for.
|
|
176
176
|
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
177
|
-
*/var Qa=function(t,e){return!!(null==t?0:t.length)&&Xa(t,e,0)>-1};var to=function(t,e,i){for(var s=-1,n=null==t?0:t.length;++s<n;)if(i(e,t[s]))return!0;return!1};var eo=function(){},io=gn&&1/vr(new gn([,-0]))[1]==1/0?function(t){return new gn(t)}:eo;var so=function(t,e,i){var s=-1,n=Qa,r=t.length,a=!0,o=[],h=o;if(i)a=!1,n=to;else if(r>=200){var l=e?null:io(t);if(l)return vr(l);a=!1,n=_r,h=new pr}else h=e?[]:o;t:for(;++s<r;){var c=t[s],d=e?e(c):c;if(c=i||0!==c?c:0,a&&d==d){for(var u=h.length;u--;)if(h[u]===d)continue t;e&&h.push(d),o.push(c)}else n(h,d,i)||(h!==o&&h.push(d),o.push(c))}return o};var no=function(t){return ms(t)&&Ws(t)},ro=Ha((function(t){return so(za(t,1,no,!0))}));var ao=function(t,e){return qr(e,(function(e){return t[e]}))};var oo,ho=function(t){return null==t?[]:ao(t,Us(t))};try{oo={clone:er,constant:ir,each:lr,filter:ha,has:da,isArray:ks,isEmpty:fa,isFunction:Ei,isUndefined:pa,keys:Us,map:_a,reduce:va,size:La,transform:ja,union:ro,values:ho}}catch(t){}oo||(oo=window._);var lo=oo,co=fo,uo="\0";function fo(t){this._isDirected=!lo.has(t,"directed")||t.directed,this._isMultigraph=!!lo.has(t,"multigraph")&&t.multigraph,this._isCompound=!!lo.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=lo.constant(void 0),this._defaultEdgeLabelFn=lo.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function po(t,e){t[e]?t[e]++:t[e]=1}function go(t,e){--t[e]||delete t[e]}function _o(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}return n+""+r+""+(lo.isUndefined(s)?"\0":s)}function mo(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}var o={v:n,w:r};return s&&(o.name=s),o}function yo(t,e){return _o(t,e.v,e.w,e.name)}fo.prototype._nodeCount=0,fo.prototype._edgeCount=0,fo.prototype.isDirected=function(){return this._isDirected},fo.prototype.isMultigraph=function(){return this._isMultigraph},fo.prototype.isCompound=function(){return this._isCompound},fo.prototype.setGraph=function(t){return this._label=t,this},fo.prototype.graph=function(){return this._label},fo.prototype.setDefaultNodeLabel=function(t){return lo.isFunction(t)||(t=lo.constant(t)),this._defaultNodeLabelFn=t,this},fo.prototype.nodeCount=function(){return this._nodeCount},fo.prototype.nodes=function(){return lo.keys(this._nodes)},fo.prototype.sources=function(){var t=this;return lo.filter(this.nodes(),(function(e){return lo.isEmpty(t._in[e])}))},fo.prototype.sinks=function(){var t=this;return lo.filter(this.nodes(),(function(e){return lo.isEmpty(t._out[e])}))},fo.prototype.setNodes=function(t,e){var i=arguments,s=this;return lo.each(t,(function(t){i.length>1?s.setNode(t,e):s.setNode(t)})),this},fo.prototype.setNode=function(t,e){return lo.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=uo,this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},fo.prototype.node=function(t){return this._nodes[t]},fo.prototype.hasNode=function(t){return lo.has(this._nodes,t)},fo.prototype.removeNode=function(t){var e=this;if(lo.has(this._nodes,t)){var i=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],lo.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),lo.each(lo.keys(this._in[t]),i),delete this._in[t],delete this._preds[t],lo.each(lo.keys(this._out[t]),i),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},fo.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(lo.isUndefined(e))e=uo;else{for(var i=e+="";!lo.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},fo.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},fo.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==uo)return e}},fo.prototype.children=function(t){if(lo.isUndefined(t)&&(t=uo),this._isCompound){var e=this._children[t];if(e)return lo.keys(e)}else{if(t===uo)return this.nodes();if(this.hasNode(t))return[]}},fo.prototype.predecessors=function(t){var e=this._preds[t];if(e)return lo.keys(e)},fo.prototype.successors=function(t){var e=this._sucs[t];if(e)return lo.keys(e)},fo.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return lo.union(e,this.successors(t))},fo.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},fo.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var i=this;lo.each(this._nodes,(function(i,s){t(s)&&e.setNode(s,i)})),lo.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,i.edge(t))}));var s={};function n(t){var r=i.parent(t);return void 0===r||e.hasNode(r)?(s[t]=r,r):r in s?s[r]:n(r)}return this._isCompound&&lo.each(e.nodes(),(function(t){e.setParent(t,n(t))})),e},fo.prototype.setDefaultEdgeLabel=function(t){return lo.isFunction(t)||(t=lo.constant(t)),this._defaultEdgeLabelFn=t,this},fo.prototype.edgeCount=function(){return this._edgeCount},fo.prototype.edges=function(){return lo.values(this._edgeObjs)},fo.prototype.setPath=function(t,e){var i=this,s=arguments;return lo.reduce(t,(function(t,n){return s.length>1?i.setEdge(t,n,e):i.setEdge(t,n),n})),this},fo.prototype.setEdge=function(){var t,e,i,s,n=!1,r=arguments[0];"object"==typeof r&&null!==r&&"v"in r?(t=r.v,e=r.w,i=r.name,2===arguments.length&&(s=arguments[1],n=!0)):(t=r,e=arguments[1],i=arguments[3],arguments.length>2&&(s=arguments[2],n=!0)),t=""+t,e=""+e,lo.isUndefined(i)||(i=""+i);var a=_o(this._isDirected,t,e,i);if(lo.has(this._edgeLabels,a))return n&&(this._edgeLabels[a]=s),this;if(!lo.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[a]=n?s:this._defaultEdgeLabelFn(t,e,i);var o=mo(this._isDirected,t,e,i);return t=o.v,e=o.w,Object.freeze(o),this._edgeObjs[a]=o,po(this._preds[e],t),po(this._sucs[t],e),this._in[e][a]=o,this._out[t][a]=o,this._edgeCount++,this},fo.prototype.edge=function(t,e,i){var s=1===arguments.length?yo(this._isDirected,arguments[0]):_o(this._isDirected,t,e,i);return this._edgeLabels[s]},fo.prototype.hasEdge=function(t,e,i){var s=1===arguments.length?yo(this._isDirected,arguments[0]):_o(this._isDirected,t,e,i);return lo.has(this._edgeLabels,s)},fo.prototype.removeEdge=function(t,e,i){var s=1===arguments.length?yo(this._isDirected,arguments[0]):_o(this._isDirected,t,e,i),n=this._edgeObjs[s];return n&&(t=n.v,e=n.w,delete this._edgeLabels[s],delete this._edgeObjs[s],go(this._preds[e],t),go(this._sucs[t],e),delete this._in[e][s],delete this._out[t][s],this._edgeCount--),this},fo.prototype.inEdges=function(t,e){var i=this._in[t];if(i){var s=lo.values(i);return e?lo.filter(s,(function(t){return t.v===e})):s}},fo.prototype.outEdges=function(t,e){var i=this._out[t];if(i){var s=lo.values(i);return e?lo.filter(s,(function(t){return t.w===e})):s}},fo.prototype.nodeEdges=function(t,e){var i=this.inEdges(t,e);if(i)return i.concat(this.outEdges(t,e))};var vo={Graph:co,version:"2.1.8"},bo={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:xo(t),edges:wo(t)};lo.isUndefined(t.graph())||(e.value=lo.clone(t.graph()));return e},read:function(t){var e=new co(t.options).setGraph(t.value);return lo.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)})),lo.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),e}};function xo(t){return lo.map(t.nodes(),(function(e){var i=t.node(e),s=t.parent(e),n={v:e};return lo.isUndefined(i)||(n.value=i),lo.isUndefined(s)||(n.parent=s),n}))}function wo(t){return lo.map(t.edges(),(function(e){var i=t.edge(e),s={v:e.v,w:e.w};return lo.isUndefined(e.name)||(s.name=e.name),lo.isUndefined(i)||(s.value=i),s}))}var ko=function(t){var e,i={},s=[];function n(s){lo.has(i,s)||(i[s]=!0,e.push(s),lo.each(t.successors(s),n),lo.each(t.predecessors(s),n))}return lo.each(t.nodes(),(function(t){e=[],n(t),e.length&&s.push(e)})),s};var Co=So;function So(){this._arr=[],this._keyIndices={}}So.prototype.size=function(){return this._arr.length},So.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},So.prototype.has=function(t){return lo.has(this._keyIndices,t)},So.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},So.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},So.prototype.add=function(t,e){var i=this._keyIndices;if(t=String(t),!lo.has(i,t)){var s=this._arr,n=s.length;return i[t]=n,s.push({key:t,priority:e}),this._decrease(n),!0}return!1},So.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},So.prototype.decrease=function(t,e){var i=this._keyIndices[t];if(e>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+e);this._arr[i].priority=e,this._decrease(i)},So.prototype._heapify=function(t){var e=this._arr,i=2*t,s=i+1,n=t;i<e.length&&(n=e[i].priority<e[n].priority?i:n,s<e.length&&(n=e[s].priority<e[n].priority?s:n),n!==t&&(this._swap(t,n),this._heapify(n)))},So.prototype._decrease=function(t){for(var e,i=this._arr,s=i[t].priority;0!==t&&!(i[e=t>>1].priority<s);)this._swap(t,e),t=e},So.prototype._swap=function(t,e){var i=this._arr,s=this._keyIndices,n=i[t],r=i[e];i[t]=r,i[e]=n,s[r.key]=t,s[n.key]=e};var Eo=function(t,e,i,s){return function(t,e,i,s){var n,r,a={},o=new Co,h=function(t){var e=t.v!==n?t.v:t.w,s=a[e],h=i(t),l=r.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+h);l<s.distance&&(s.distance=l,s.predecessor=n,o.decrease(e,l))};t.nodes().forEach((function(t){var i=t===e?0:Number.POSITIVE_INFINITY;a[t]={distance:i},o.add(t,i)}));for(;o.size()>0&&(n=o.removeMin(),(r=a[n]).distance!==Number.POSITIVE_INFINITY);)s(n).forEach(h);return a}(t,String(e),i||To,s||function(e){return t.outEdges(e)})},To=lo.constant(1);var Ao=function(t,e,i){return lo.transform(t.nodes(),(function(s,n){s[n]=Eo(t,n,e,i)}),{})};var Io=function(t){var e=0,i=[],s={},n=[];function r(a){var o=s[a]={onStack:!0,lowlink:e,index:e++};if(i.push(a),t.successors(a).forEach((function(t){lo.has(s,t)?s[t].onStack&&(o.lowlink=Math.min(o.lowlink,s[t].index)):(r(t),o.lowlink=Math.min(o.lowlink,s[t].lowlink))})),o.lowlink===o.index){var h,l=[];do{h=i.pop(),s[h].onStack=!1,l.push(h)}while(a!==h);n.push(l)}}return t.nodes().forEach((function(t){lo.has(s,t)||r(t)})),n};var Oo=function(t){return lo.filter(Io(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};var Ro=function(t,e,i){return function(t,e,i){var s={},n=t.nodes();return n.forEach((function(t){s[t]={},s[t][t]={distance:0},n.forEach((function(e){t!==e&&(s[t][e]={distance:Number.POSITIVE_INFINITY})})),i(t).forEach((function(i){var n=i.v===t?i.w:i.v,r=e(i);s[t][n]={distance:r,predecessor:t}}))})),n.forEach((function(t){var e=s[t];n.forEach((function(i){var r=s[i];n.forEach((function(i){var s=r[t],n=e[i],a=r[i],o=s.distance+n.distance;o<a.distance&&(a.distance=o,a.predecessor=n.predecessor)}))}))})),s}(t,e||Mo,i||function(e){return t.outEdges(e)})},Mo=lo.constant(1);var No=Fo;function Fo(t){var e={},i={},s=[];if(lo.each(t.sinks(),(function n(r){if(lo.has(i,r))throw new Po;lo.has(e,r)||(i[r]=!0,e[r]=!0,lo.each(t.predecessors(r),n),delete i[r],s.push(r))})),lo.size(e)!==t.nodeCount())throw new Po;return s}function Po(){}Fo.CycleException=Po,Po.prototype=new Error;var Bo=function(t,e,i){lo.isArray(e)||(e=[e]);var s=(t.isDirected()?t.successors:t.neighbors).bind(t),n=[],r={};return lo.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);Lo(t,e,"post"===i,r,s,n)})),n};function Lo(t,e,i,s,n,r){lo.has(s,e)||(s[e]=!0,i||r.push(e),lo.each(n(e),(function(e){Lo(t,e,i,s,n,r)})),i&&r.push(e))}var jo,Do={components:ko,dijkstra:Eo,dijkstraAll:Ao,findCycles:Oo,floydWarshall:Ro,isAcyclic:function(t){try{No(t)}catch(t){if(t instanceof No.CycleException)return!1;throw t}return!0},postorder:function(t,e){return Bo(t,e,"post")},preorder:function(t,e){return Bo(t,e,"pre")},prim:function(t,e){var i,s=new co,n={},r=new Co;function a(t){var s=t.v===i?t.w:t.v,a=r.priority(s);if(void 0!==a){var o=e(t);o<a&&(n[s]=i,r.decrease(s,o))}}if(0===t.nodeCount())return s;lo.each(t.nodes(),(function(t){r.add(t,Number.POSITIVE_INFINITY),s.setNode(t)})),r.decrease(t.nodes()[0],0);var o=!1;for(;r.size()>0;){if(i=r.removeMin(),lo.has(n,i))s.setEdge(i,n[i]);else{if(o)throw new Error("Input graph is not connected: "+t);o=!0}t.nodeEdges(i).forEach(a)}return s},tarjan:Io,topsort:No},Vo={Graph:vo.Graph,json:bo,alg:Do,version:vo.version};try{jo=Vo}catch(t){}jo||(jo=window.graphlib);var zo=jo;var Go=function(t){return tr(t,5)};var Wo=function(t,e,i){if(!Ci(i))return!1;var s=typeof e;return!!("number"==s?Ws(i)&&Ts(e,i.length):"string"==s&&e in i)&&Xe(i[e],t)},Uo=Object.prototype,qo=Uo.hasOwnProperty,Jo=Ha((function(t,e){t=Object(t);var i=-1,s=e.length,n=s>2?e[2]:void 0;for(n&&Wo(e[0],e[1],n)&&(s=1);++i<s;)for(var r=e[i],a=$s(r),o=-1,h=a.length;++o<h;){var l=a[o],c=t[l];(void 0===c||Xe(c,Uo[l])&&!qo.call(t,l))&&(t[l]=r[l])}return t}));var Yo=function(t){return function(e,i,s){var n=Object(e);if(!Ws(e)){var r=oa(i);e=Us(e),i=function(t){return r(n[t],t,n)}}var a=t(e,i,s);return a>-1?n[r?e[a]:a]:void 0}},Ho=/\s/;var $o=function(t){for(var e=t.length;e--&&Ho.test(t.charAt(e)););return e},Zo=/^\s+/;var Ko=function(t){return t?t.slice(0,$o(t)+1).replace(Zo,""):t},Xo=/^[-+]0x[0-9a-f]+$/i,Qo=/^0b[01]+$/i,th=/^0o[0-7]+$/i,eh=parseInt;var ih=function(t){if("number"==typeof t)return t;if(Br(t))return NaN;if(Ci(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ci(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ko(t);var i=Qo.test(t);return i||th.test(t)?eh(t.slice(2),i?2:8):Xo.test(t)?NaN:+t},sh=1/0;var nh=function(t){return t?(t=ih(t))===sh||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var rh=function(t){var e=nh(t),i=e%1;return e==e?i?e-i:e:0},ah=Math.max;var oh=Yo((function(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var n=null==i?0:rh(i);return n<0&&(n=ah(s+n,0)),$a(t,oa(e),n)}));var hh=function(t){return(null==t?0:t.length)?za(t,1):[]};var lh=function(t,e){return null==t?t:sr(t,or(e),$s)};var ch=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};var dh=function(t,e){var i={};return e=oa(e),nr(t,(function(t,s,n){us(i,s,e(t,s,n))})),i};var uh=function(t,e,i){for(var s=-1,n=t.length;++s<n;){var r=t[s],a=e(r);if(null!=a&&(void 0===o?a==a&&!Br(a):i(a,o)))var o=a,h=r}return h};var fh=function(t,e){return t>e};var ph=function(t){return t&&t.length?uh(t,ar,fh):void 0};var gh=function(t,e,i){(void 0!==i&&!Xe(t[e],i)||void 0===i&&!(e in t))&&us(t,e,i)},_h=Function.prototype,mh=Object.prototype,yh=_h.toString,vh=mh.hasOwnProperty,bh=yh.call(Object);var xh=function(t){if(!ms(t)||"[object Object]"!=ki(t))return!1;var e=on(t);if(null===e)return!0;var i=vh.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&yh.call(i)==bh};var wh=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var kh=function(t){return gs(t,$s(t))};
|
|
177
|
+
*/var vo=function(t,e){return!!(null==t?0:t.length)&&yo(t,e,0)>-1};var bo=function(t,e,i){for(var s=-1,n=null==t?0:t.length;++s<n;)if(i(e,t[s]))return!0;return!1};var xo=function(){},wo=Bn&&1/Dr(new Bn([,-0]))[1]==1/0?function(t){return new Bn(t)}:xo;var ko=function(t,e,i){var s=-1,n=vo,r=t.length,a=!0,o=[],l=o;if(i)a=!1,n=bo;else if(r>=200){var h=e?null:wo(t);if(h)return Dr(h);a=!1,n=Pr,l=new Nr}else l=e?[]:o;t:for(;++s<r;){var c=t[s],d=e?e(c):c;if(c=i||0!==c?c:0,a&&d==d){for(var u=l.length;u--;)if(l[u]===d)continue t;e&&l.push(d),o.push(c)}else n(l,d,i)||(l!==o&&l.push(d),o.push(c))}return o};var So=function(t){return Fs(t)&&hn(t)},Co=po((function(t){return ko(ao(t,1,So,!0))}));var Eo=function(t,e){return ca(e,(function(e){return t[e]}))};var Ao,To=function(t){return null==t?[]:Eo(t,cn(t))};try{Ao={clone:br,constant:xr,each:Tr,filter:Aa,has:Oa,isArray:Gs,isEmpty:Ra,isFunction:qi,isUndefined:Na,keys:cn,map:Pa,reduce:Da,size:io,transform:so,union:Co,values:To}}catch(t){}Ao||(Ao=window._);var Io=Ao,Oo=Ro,Mo="\0";function Ro(t){this._isDirected=!Io.has(t,"directed")||t.directed,this._isMultigraph=!!Io.has(t,"multigraph")&&t.multigraph,this._isCompound=!!Io.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=Io.constant(void 0),this._defaultEdgeLabelFn=Io.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function No(t,e){t[e]?t[e]++:t[e]=1}function Bo(t,e){--t[e]||delete t[e]}function Po(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}return n+""+r+""+(Io.isUndefined(s)?"\0":s)}function Fo(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}var o={v:n,w:r};return s&&(o.name=s),o}function Lo(t,e){return Po(t,e.v,e.w,e.name)}Ro.prototype._nodeCount=0,Ro.prototype._edgeCount=0,Ro.prototype.isDirected=function(){return this._isDirected},Ro.prototype.isMultigraph=function(){return this._isMultigraph},Ro.prototype.isCompound=function(){return this._isCompound},Ro.prototype.setGraph=function(t){return this._label=t,this},Ro.prototype.graph=function(){return this._label},Ro.prototype.setDefaultNodeLabel=function(t){return Io.isFunction(t)||(t=Io.constant(t)),this._defaultNodeLabelFn=t,this},Ro.prototype.nodeCount=function(){return this._nodeCount},Ro.prototype.nodes=function(){return Io.keys(this._nodes)},Ro.prototype.sources=function(){var t=this;return Io.filter(this.nodes(),(function(e){return Io.isEmpty(t._in[e])}))},Ro.prototype.sinks=function(){var t=this;return Io.filter(this.nodes(),(function(e){return Io.isEmpty(t._out[e])}))},Ro.prototype.setNodes=function(t,e){var i=arguments,s=this;return Io.each(t,(function(t){i.length>1?s.setNode(t,e):s.setNode(t)})),this},Ro.prototype.setNode=function(t,e){return Io.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=Mo,this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},Ro.prototype.node=function(t){return this._nodes[t]},Ro.prototype.hasNode=function(t){return Io.has(this._nodes,t)},Ro.prototype.removeNode=function(t){var e=this;if(Io.has(this._nodes,t)){var i=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],Io.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),Io.each(Io.keys(this._in[t]),i),delete this._in[t],delete this._preds[t],Io.each(Io.keys(this._out[t]),i),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},Ro.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(Io.isUndefined(e))e=Mo;else{for(var i=e+="";!Io.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},Ro.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},Ro.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==Mo)return e}},Ro.prototype.children=function(t){if(Io.isUndefined(t)&&(t=Mo),this._isCompound){var e=this._children[t];if(e)return Io.keys(e)}else{if(t===Mo)return this.nodes();if(this.hasNode(t))return[]}},Ro.prototype.predecessors=function(t){var e=this._preds[t];if(e)return Io.keys(e)},Ro.prototype.successors=function(t){var e=this._sucs[t];if(e)return Io.keys(e)},Ro.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return Io.union(e,this.successors(t))},Ro.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},Ro.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var i=this;Io.each(this._nodes,(function(i,s){t(s)&&e.setNode(s,i)})),Io.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,i.edge(t))}));var s={};function n(t){var r=i.parent(t);return void 0===r||e.hasNode(r)?(s[t]=r,r):r in s?s[r]:n(r)}return this._isCompound&&Io.each(e.nodes(),(function(t){e.setParent(t,n(t))})),e},Ro.prototype.setDefaultEdgeLabel=function(t){return Io.isFunction(t)||(t=Io.constant(t)),this._defaultEdgeLabelFn=t,this},Ro.prototype.edgeCount=function(){return this._edgeCount},Ro.prototype.edges=function(){return Io.values(this._edgeObjs)},Ro.prototype.setPath=function(t,e){var i=this,s=arguments;return Io.reduce(t,(function(t,n){return s.length>1?i.setEdge(t,n,e):i.setEdge(t,n),n})),this},Ro.prototype.setEdge=function(){var t,e,i,s,n=!1,r=arguments[0];"object"==typeof r&&null!==r&&"v"in r?(t=r.v,e=r.w,i=r.name,2===arguments.length&&(s=arguments[1],n=!0)):(t=r,e=arguments[1],i=arguments[3],arguments.length>2&&(s=arguments[2],n=!0)),t=""+t,e=""+e,Io.isUndefined(i)||(i=""+i);var a=Po(this._isDirected,t,e,i);if(Io.has(this._edgeLabels,a))return n&&(this._edgeLabels[a]=s),this;if(!Io.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[a]=n?s:this._defaultEdgeLabelFn(t,e,i);var o=Fo(this._isDirected,t,e,i);return t=o.v,e=o.w,Object.freeze(o),this._edgeObjs[a]=o,No(this._preds[e],t),No(this._sucs[t],e),this._in[e][a]=o,this._out[t][a]=o,this._edgeCount++,this},Ro.prototype.edge=function(t,e,i){var s=1===arguments.length?Lo(this._isDirected,arguments[0]):Po(this._isDirected,t,e,i);return this._edgeLabels[s]},Ro.prototype.hasEdge=function(t,e,i){var s=1===arguments.length?Lo(this._isDirected,arguments[0]):Po(this._isDirected,t,e,i);return Io.has(this._edgeLabels,s)},Ro.prototype.removeEdge=function(t,e,i){var s=1===arguments.length?Lo(this._isDirected,arguments[0]):Po(this._isDirected,t,e,i),n=this._edgeObjs[s];return n&&(t=n.v,e=n.w,delete this._edgeLabels[s],delete this._edgeObjs[s],Bo(this._preds[e],t),Bo(this._sucs[t],e),delete this._in[e][s],delete this._out[t][s],this._edgeCount--),this},Ro.prototype.inEdges=function(t,e){var i=this._in[t];if(i){var s=Io.values(i);return e?Io.filter(s,(function(t){return t.v===e})):s}},Ro.prototype.outEdges=function(t,e){var i=this._out[t];if(i){var s=Io.values(i);return e?Io.filter(s,(function(t){return t.w===e})):s}},Ro.prototype.nodeEdges=function(t,e){var i=this.inEdges(t,e);if(i)return i.concat(this.outEdges(t,e))};var Do={Graph:Oo,version:"2.1.8"},jo={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:Vo(t),edges:zo(t)};Io.isUndefined(t.graph())||(e.value=Io.clone(t.graph()));return e},read:function(t){var e=new Oo(t.options).setGraph(t.value);return Io.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)})),Io.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),e}};function Vo(t){return Io.map(t.nodes(),(function(e){var i=t.node(e),s=t.parent(e),n={v:e};return Io.isUndefined(i)||(n.value=i),Io.isUndefined(s)||(n.parent=s),n}))}function zo(t){return Io.map(t.edges(),(function(e){var i=t.edge(e),s={v:e.v,w:e.w};return Io.isUndefined(e.name)||(s.name=e.name),Io.isUndefined(i)||(s.value=i),s}))}var Go=function(t){var e,i={},s=[];function n(s){Io.has(i,s)||(i[s]=!0,e.push(s),Io.each(t.successors(s),n),Io.each(t.predecessors(s),n))}return Io.each(t.nodes(),(function(t){e=[],n(t),e.length&&s.push(e)})),s};var Wo=Uo;function Uo(){this._arr=[],this._keyIndices={}}Uo.prototype.size=function(){return this._arr.length},Uo.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},Uo.prototype.has=function(t){return Io.has(this._keyIndices,t)},Uo.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},Uo.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},Uo.prototype.add=function(t,e){var i=this._keyIndices;if(t=String(t),!Io.has(i,t)){var s=this._arr,n=s.length;return i[t]=n,s.push({key:t,priority:e}),this._decrease(n),!0}return!1},Uo.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},Uo.prototype.decrease=function(t,e){var i=this._keyIndices[t];if(e>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+e);this._arr[i].priority=e,this._decrease(i)},Uo.prototype._heapify=function(t){var e=this._arr,i=2*t,s=i+1,n=t;i<e.length&&(n=e[i].priority<e[n].priority?i:n,s<e.length&&(n=e[s].priority<e[n].priority?s:n),n!==t&&(this._swap(t,n),this._heapify(n)))},Uo.prototype._decrease=function(t){for(var e,i=this._arr,s=i[t].priority;0!==t&&!(i[e=t>>1].priority<s);)this._swap(t,e),t=e},Uo.prototype._swap=function(t,e){var i=this._arr,s=this._keyIndices,n=i[t],r=i[e];i[t]=r,i[e]=n,s[r.key]=t,s[n.key]=e};var qo=function(t,e,i,s){return function(t,e,i,s){var n,r,a={},o=new Wo,l=function(t){var e=t.v!==n?t.v:t.w,s=a[e],l=i(t),h=r.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+l);h<s.distance&&(s.distance=h,s.predecessor=n,o.decrease(e,h))};t.nodes().forEach((function(t){var i=t===e?0:Number.POSITIVE_INFINITY;a[t]={distance:i},o.add(t,i)}));for(;o.size()>0&&(n=o.removeMin(),(r=a[n]).distance!==Number.POSITIVE_INFINITY);)s(n).forEach(l);return a}(t,String(e),i||Ho,s||function(e){return t.outEdges(e)})},Ho=Io.constant(1);var Jo=function(t,e,i){return Io.transform(t.nodes(),(function(s,n){s[n]=qo(t,n,e,i)}),{})};var Yo=function(t){var e=0,i=[],s={},n=[];function r(a){var o=s[a]={onStack:!0,lowlink:e,index:e++};if(i.push(a),t.successors(a).forEach((function(t){Io.has(s,t)?s[t].onStack&&(o.lowlink=Math.min(o.lowlink,s[t].index)):(r(t),o.lowlink=Math.min(o.lowlink,s[t].lowlink))})),o.lowlink===o.index){var l,h=[];do{l=i.pop(),s[l].onStack=!1,h.push(l)}while(a!==l);n.push(h)}}return t.nodes().forEach((function(t){Io.has(s,t)||r(t)})),n};var $o=function(t){return Io.filter(Yo(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};var Zo=function(t,e,i){return function(t,e,i){var s={},n=t.nodes();return n.forEach((function(t){s[t]={},s[t][t]={distance:0},n.forEach((function(e){t!==e&&(s[t][e]={distance:Number.POSITIVE_INFINITY})})),i(t).forEach((function(i){var n=i.v===t?i.w:i.v,r=e(i);s[t][n]={distance:r,predecessor:t}}))})),n.forEach((function(t){var e=s[t];n.forEach((function(i){var r=s[i];n.forEach((function(i){var s=r[t],n=e[i],a=r[i],o=s.distance+n.distance;o<a.distance&&(a.distance=o,a.predecessor=n.predecessor)}))}))})),s}(t,e||Ko,i||function(e){return t.outEdges(e)})},Ko=Io.constant(1);var Xo=Qo;function Qo(t){var e={},i={},s=[];if(Io.each(t.sinks(),(function n(r){if(Io.has(i,r))throw new tl;Io.has(e,r)||(i[r]=!0,e[r]=!0,Io.each(t.predecessors(r),n),delete i[r],s.push(r))})),Io.size(e)!==t.nodeCount())throw new tl;return s}function tl(){}Qo.CycleException=tl,tl.prototype=new Error;var el=function(t,e,i){Io.isArray(e)||(e=[e]);var s=(t.isDirected()?t.successors:t.neighbors).bind(t),n=[],r={};return Io.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);il(t,e,"post"===i,r,s,n)})),n};function il(t,e,i,s,n,r){Io.has(s,e)||(s[e]=!0,i||r.push(e),Io.each(n(e),(function(e){il(t,e,i,s,n,r)})),i&&r.push(e))}var sl,nl={components:Go,dijkstra:qo,dijkstraAll:Jo,findCycles:$o,floydWarshall:Zo,isAcyclic:function(t){try{Xo(t)}catch(t){if(t instanceof Xo.CycleException)return!1;throw t}return!0},postorder:function(t,e){return el(t,e,"post")},preorder:function(t,e){return el(t,e,"pre")},prim:function(t,e){var i,s=new Oo,n={},r=new Wo;function a(t){var s=t.v===i?t.w:t.v,a=r.priority(s);if(void 0!==a){var o=e(t);o<a&&(n[s]=i,r.decrease(s,o))}}if(0===t.nodeCount())return s;Io.each(t.nodes(),(function(t){r.add(t,Number.POSITIVE_INFINITY),s.setNode(t)})),r.decrease(t.nodes()[0],0);var o=!1;for(;r.size()>0;){if(i=r.removeMin(),Io.has(n,i))s.setEdge(i,n[i]);else{if(o)throw new Error("Input graph is not connected: "+t);o=!0}t.nodeEdges(i).forEach(a)}return s},tarjan:Yo,topsort:Xo},rl={Graph:Do.Graph,json:jo,alg:nl,version:Do.version};try{sl=rl}catch(t){}sl||(sl=window.graphlib);var al=sl;var ol=function(t){return vr(t,5)};var ll=function(t,e,i){if(!Wi(i))return!1;var s=typeof e;return!!("number"==s?hn(i)&&Hs(e,i.length):"string"==s&&e in i)&&mi(i[e],t)},hl=Object.prototype,cl=hl.hasOwnProperty,dl=po((function(t,e){t=Object(t);var i=-1,s=e.length,n=s>2?e[2]:void 0;for(n&&ll(e[0],e[1],n)&&(s=1);++i<s;)for(var r=e[i],a=gn(r),o=-1,l=a.length;++o<l;){var h=a[o],c=t[h];(void 0===c||mi(c,hl[h])&&!cl.call(t,h))&&(t[h]=r[h])}return t}));var ul=function(t){return function(e,i,s){var n=Object(e);if(!hn(e)){var r=Ea(i);e=cn(e),i=function(t){return r(n[t],t,n)}}var a=t(e,i,s);return a>-1?n[r?e[a]:a]:void 0}},fl=/\s/;var pl=function(t){for(var e=t.length;e--&&fl.test(t.charAt(e)););return e},gl=/^\s+/;var _l=function(t){return t?t.slice(0,pl(t)+1).replace(gl,""):t},ml=/^[-+]0x[0-9a-f]+$/i,yl=/^0b[01]+$/i,vl=/^0o[0-7]+$/i,bl=parseInt;var xl=function(t){if("number"==typeof t)return t;if(ea(t))return NaN;if(Wi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Wi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=_l(t);var i=yl.test(t);return i||vl.test(t)?bl(t.slice(2),i?2:8):ml.test(t)?NaN:+t},wl=1/0;var kl=function(t){return t?(t=xl(t))===wl||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var Sl=function(t){var e=kl(t),i=e%1;return e==e?i?e-i:e:0},Cl=Math.max;var El=ul((function(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var n=null==i?0:Sl(i);return n<0&&(n=Cl(s+n,0)),go(t,Ea(e),n)}));var Al=function(t){return(null==t?0:t.length)?ao(t,1):[]};var Tl=function(t,e){return null==t?t:wr(t,Er(e),gn)};var Il=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};var Ol=function(t,e){var i={};return e=Ea(e),kr(t,(function(t,s,n){Ms(i,s,e(t,s,n))})),i};var Ml=function(t,e,i){for(var s=-1,n=t.length;++s<n;){var r=t[s],a=e(r);if(null!=a&&(void 0===o?a==a&&!ea(a):i(a,o)))var o=a,l=r}return l};var Rl=function(t,e){return t>e};var Nl=function(t){return t&&t.length?Ml(t,Cr,Rl):void 0};var Bl=function(t,e,i){(void 0!==i&&!mi(t[e],i)||void 0===i&&!(e in t))&&Ms(t,e,i)},Pl=Function.prototype,Fl=Object.prototype,Ll=Pl.toString,Dl=Fl.hasOwnProperty,jl=Ll.call(Object);var Vl=function(t){if(!Fs(t)||"[object Object]"!=Gi(t))return!1;var e=En(t);if(null===e)return!0;var i=Dl.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Ll.call(i)==jl};var zl=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Gl=function(t){return Bs(t,gn(t))};
|
|
178
178
|
/**
|
|
179
179
|
* A specialized version of `baseMerge` for arrays and objects which performs
|
|
180
180
|
* deep merges and tracks traversed objects enabling objects with circular
|
|
@@ -189,11 +189,11 @@ function(t,e,i){return e=Wa(void 0===e?t.length-1:e,0),function(){for(var s=argu
|
|
|
189
189
|
* @param {Function} [customizer] The function to customize assigned values.
|
|
190
190
|
* @param {Object} [stack] Tracks traversed source values and their merged
|
|
191
191
|
* counterparts.
|
|
192
|
-
*/var
|
|
192
|
+
*/var Wl=function(t,e,i,s,n,r,a){var o=zl(t,i),l=zl(e,i),h=a.get(l);if(h)Bl(t,i,h);else{var c=r?r(o,l,i+"",t,e,a):void 0,d=void 0===c;if(d){var u=Gs(l),f=!u&&Us(l),p=!u&&!f&&Qs(l);c=l,u||f||p?Gs(o)?c=o:So(o)?c=yn(o):f?(d=!1,c=mn(l,!0)):p?(d=!1,c=nr(l,!0)):c=[]:Vl(l)||zs(l)?(c=o,zs(o)?c=Gl(o):Wi(o)&&!qi(o)||(c=lr(l))):d=!1}d&&(a.set(l,c),n(c,l,s,r,a),a.delete(l)),Bl(t,i,c)}};var Ul=function t(e,i,s,n,r){e!==i&&wr(i,(function(a,o){if(r||(r=new Ts),Wi(a))Wl(e,i,o,s,t,n,r);else{var l=n?n(zl(e,o),a,o+"",e,i,r):void 0;void 0===l&&(l=a),Bl(e,o,l)}}),gn)};var ql=function(t){return po((function(e,i){var s=-1,n=i.length,r=n>1?i[n-1]:void 0,a=n>2?i[2]:void 0;for(r=t.length>3&&"function"==typeof r?(n--,r):void 0,a&&ll(i[0],i[1],a)&&(r=n<3?void 0:r,n=1),e=Object(e);++s<n;){var o=i[s];o&&t(e,o,s,r)}return e}))}((function(t,e,i){Ul(t,e,i)}));var Hl=function(t,e){return t<e};var Jl=function(t){return t&&t.length?Ml(t,Cr,Hl):void 0};var Yl=function(t,e){return t&&t.length?Ml(t,Ea(e),Hl):void 0},$l=function(){return Ri.Date.now()};var Zl=function(t,e,i,s){if(!Wi(t))return t;for(var n=-1,r=(e=ga(e,t)).length,a=r-1,o=t;null!=o&&++n<r;){var l=_a(e[n]),h=i;if("__proto__"===l||"constructor"===l||"prototype"===l)return t;if(n!=a){var c=o[l];void 0===(h=s?s(c,l,o):void 0)&&(h=Wi(c)?c:Hs(e[n+1])?[]:{})}Ns(o,l,h),o=o[l]}return t};var Kl=function(t,e,i){for(var s=-1,n=e.length,r={};++s<n;){var a=e[s],o=ma(t,a);i(o,a)&&Zl(r,ga(a,t),o)}return r};var Xl=function(t,e){return Kl(t,e,(function(e,i){return xa(t,i)}))};
|
|
193
193
|
/**
|
|
194
194
|
* A specialized version of `baseRest` which flattens the rest array.
|
|
195
195
|
*
|
|
196
196
|
* @private
|
|
197
197
|
* @param {Function} func The function to apply a rest parameter to.
|
|
198
198
|
* @returns {Function} Returns the new function.
|
|
199
|
-
*/var Fh=function(t){return Ya(Ua(t,void 0,hh),t+"")}((function(t,e){return null==t?{}:Nh(t,e)})),Ph=Math.ceil,Bh=Math.max;var Lh=function(t,e,i,s){for(var n=-1,r=Bh(Ph((e-t)/(i||1)),0),a=Array(r);r--;)a[s?r:++n]=t,t+=i;return a};var jh=function(t){return function(e,i,s){return s&&"number"!=typeof s&&Wo(e,i,s)&&(i=s=void 0),e=nh(e),void 0===i?(i=e,e=0):i=nh(i),s=void 0===s?e<i?1:-1:nh(s),Lh(e,i,s,t)}}();var Dh=function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t};var Vh=function(t,e){if(t!==e){var i=void 0!==t,s=null===t,n=t==t,r=Br(t),a=void 0!==e,o=null===e,h=e==e,l=Br(e);if(!o&&!l&&!r&&t>e||r&&a&&h&&!o&&!l||s&&a&&h||!i&&h||!n)return 1;if(!s&&!r&&!l&&t<e||l&&i&&n&&!s&&!r||o&&i&&n||!a&&n||!h)return-1}return 0};var zh=function(t,e,i){for(var s=-1,n=t.criteria,r=e.criteria,a=n.length,o=i.length;++s<a;){var h=Vh(n[s],r[s]);if(h)return s>=o?h:h*("desc"==i[s]?-1:1)}return t.index-e.index};var Gh=function(t,e,i){e=e.length?qr(e,(function(t){return ks(t)?function(e){return Xr(e,1===t.length?t[0]:t)}:t})):[ar];var s=-1;e=qr(e,Rs(oa));var n=ga(t,(function(t,i,n){return{criteria:qr(e,(function(e){return e(t)})),index:++s,value:t}}));return Dh(n,(function(t,e){return zh(t,e,i)}))},Wh=Ha((function(t,e){if(null==t)return[];var i=e.length;return i>1&&Wo(t,e[0],e[1])?e=[]:i>2&&Wo(e[0],e[1],e[2])&&(e=[e[0]]),Gh(t,za(e,1),[])})),Uh=0;var qh=function(t){var e=++Uh;return $r(t)+e};var Jh=function(t,e,i){for(var s=-1,n=t.length,r=e.length,a={};++s<n;){var o=s<r?e[s]:void 0;i(a,t[s],o)}return a};var Yh,Hh=function(t,e){return Jh(t||[],e||[],ps)};try{Yh={cloneDeep:Go,constant:ir,defaults:Jo,each:lr,filter:ha,find:oh,flatten:hh,forEach:hr,forIn:lh,has:da,isUndefined:pa,last:ch,map:_a,mapValues:dh,max:ph,merge:Eh,min:Ah,minBy:Ih,now:Oh,pick:Fh,range:jh,reduce:va,sortBy:Wh,uniqueId:qh,values:ho,zipObject:Hh}}catch(t){}Yh||(Yh=window._);var $h=Yh,Zh=Kh;function Kh(){var t={};t._next=t._prev=t,this._sentinel=t}function Xh(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function Qh(t,e){if("_next"!==t&&"_prev"!==t)return e}Kh.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return Xh(e),e},Kh.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&Xh(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},Kh.prototype.toString=function(){for(var t=[],e=this._sentinel,i=e._prev;i!==e;)t.push(JSON.stringify(i,Qh)),i=i._prev;return"["+t.join(", ")+"]"};var tl=zo.Graph,el=function(t,e){if(t.nodeCount()<=1)return[];var i=function(t,e){var i=new tl,s=0,n=0;$h.forEach(t.nodes(),(function(t){i.setNode(t,{v:t,in:0,out:0})})),$h.forEach(t.edges(),(function(t){var r=i.edge(t.v,t.w)||0,a=e(t),o=r+a;i.setEdge(t.v,t.w,o),n=Math.max(n,i.node(t.v).out+=a),s=Math.max(s,i.node(t.w).in+=a)}));var r=$h.range(n+s+3).map((function(){return new Zh})),a=s+1;return $h.forEach(i.nodes(),(function(t){nl(r,a,i.node(t))})),{graph:i,buckets:r,zeroIdx:a}}(t,e||il),s=function(t,e,i){var s,n=[],r=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;s=a.dequeue();)sl(t,e,i,s);for(;s=r.dequeue();)sl(t,e,i,s);if(t.nodeCount())for(var o=e.length-2;o>0;--o)if(s=e[o].dequeue()){n=n.concat(sl(t,e,i,s,!0));break}}return n}(i.graph,i.buckets,i.zeroIdx);return $h.flatten($h.map(s,(function(e){return t.outEdges(e.v,e.w)})),!0)},il=$h.constant(1);function sl(t,e,i,s,n){var r=n?[]:void 0;return $h.forEach(t.inEdges(s.v),(function(s){var a=t.edge(s),o=t.node(s.v);n&&r.push({v:s.v,w:s.w}),o.out-=a,nl(e,i,o)})),$h.forEach(t.outEdges(s.v),(function(s){var n=t.edge(s),r=s.w,a=t.node(r);a.in-=n,nl(e,i,a)})),t.removeNode(s.v),r}function nl(t,e,i){i.out?i.in?t[i.out-i.in+e].enqueue(i):t[t.length-1].enqueue(i):t[0].enqueue(i)}var rl={run:function(t){var e="greedy"===t.graph().acyclicer?el(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],i={},s={};function n(r){$h.has(s,r)||(s[r]=!0,i[r]=!0,$h.forEach(t.outEdges(r),(function(t){$h.has(i,t.w)?e.push(t):n(t.w)})),delete i[r])}return $h.forEach(t.nodes(),n),e}(t);$h.forEach(e,(function(e){var i=t.edge(e);t.removeEdge(e),i.forwardName=e.name,i.reversed=!0,t.setEdge(e.w,e.v,i,$h.uniqueId("rev"))}))},undo:function(t){$h.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.reversed){t.removeEdge(e);var s=i.forwardName;delete i.reversed,delete i.forwardName,t.setEdge(e.w,e.v,i,s)}}))}};var al=zo.Graph,ol={addDummyNode:hl,simplify:function(t){var e=(new al).setGraph(t.graph());return $h.forEach(t.nodes(),(function(i){e.setNode(i,t.node(i))})),$h.forEach(t.edges(),(function(i){var s=e.edge(i.v,i.w)||{weight:0,minlen:1},n=t.edge(i);e.setEdge(i.v,i.w,{weight:s.weight+n.weight,minlen:Math.max(s.minlen,n.minlen)})})),e},asNonCompoundGraph:function(t){var e=new al({multigraph:t.isMultigraph()}).setGraph(t.graph());return $h.forEach(t.nodes(),(function(i){t.children(i).length||e.setNode(i,t.node(i))})),$h.forEach(t.edges(),(function(i){e.setEdge(i,t.edge(i))})),e},successorWeights:function(t){var e=$h.map(t.nodes(),(function(e){var i={};return $h.forEach(t.outEdges(e),(function(e){i[e.w]=(i[e.w]||0)+t.edge(e).weight})),i}));return $h.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=$h.map(t.nodes(),(function(e){var i={};return $h.forEach(t.inEdges(e),(function(e){i[e.v]=(i[e.v]||0)+t.edge(e).weight})),i}));return $h.zipObject(t.nodes(),e)},intersectRect:function(t,e){var i,s,n=t.x,r=t.y,a=e.x-n,o=e.y-r,h=t.width/2,l=t.height/2;if(!a&&!o)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(o)*h>Math.abs(a)*l?(o<0&&(l=-l),i=l*a/o,s=l):(a<0&&(h=-h),i=h,s=h*o/a);return{x:n+i,y:r+s}},buildLayerMatrix:function(t){var e=$h.map($h.range(ll(t)+1),(function(){return[]}));return $h.forEach(t.nodes(),(function(i){var s=t.node(i),n=s.rank;$h.isUndefined(n)||(e[n][s.order]=i)})),e},normalizeRanks:function(t){var e=$h.min($h.map(t.nodes(),(function(e){return t.node(e).rank})));$h.forEach(t.nodes(),(function(i){var s=t.node(i);$h.has(s,"rank")&&(s.rank-=e)}))},removeEmptyRanks:function(t){var e=$h.min($h.map(t.nodes(),(function(e){return t.node(e).rank}))),i=[];$h.forEach(t.nodes(),(function(s){var n=t.node(s).rank-e;i[n]||(i[n]=[]),i[n].push(s)}));var s=0,n=t.graph().nodeRankFactor;$h.forEach(i,(function(e,i){$h.isUndefined(e)&&i%n!=0?--s:s&&$h.forEach(e,(function(e){t.node(e).rank+=s}))}))},addBorderNode:function(t,e,i,s){var n={width:0,height:0};arguments.length>=4&&(n.rank=i,n.order=s);return hl(t,"border",n,e)},maxRank:ll,partition:function(t,e){var i={lhs:[],rhs:[]};return $h.forEach(t,(function(t){e(t)?i.lhs.push(t):i.rhs.push(t)})),i},time:function(t,e){var i=$h.now();try{return e()}finally{console.log(t+" time: "+($h.now()-i)+"ms")}},notime:function(t,e){return e()}};function hl(t,e,i,s){var n;do{n=$h.uniqueId(s)}while(t.hasNode(n));return i.dummy=e,t.setNode(n,i),n}function ll(t){return $h.max($h.map(t.nodes(),(function(e){var i=t.node(e).rank;if(!$h.isUndefined(i))return i})))}var cl={run:function(t){t.graph().dummyChains=[],$h.forEach(t.edges(),(function(e){!function(t,e){var i,s,n,r=e.v,a=t.node(r).rank,o=e.w,h=t.node(o).rank,l=e.name,c=t.edge(e),d=c.labelRank;if(h===a+1)return;for(t.removeEdge(e),n=0,++a;a<h;++n,++a)c.points=[],s={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},i=ol.addDummyNode(t,"edge",s,"_d"),a===d&&(s.width=c.width,s.height=c.height,s.dummy="edge-label",s.labelpos=c.labelpos),t.setEdge(r,i,{weight:c.weight},l),0===n&&t.graph().dummyChains.push(i),r=i;t.setEdge(r,o,{weight:c.weight},l)}(t,e)}))},undo:function(t){$h.forEach(t.graph().dummyChains,(function(e){var i,s=t.node(e),n=s.edgeLabel;for(t.setEdge(s.edgeObj,n);s.dummy;)i=t.successors(e)[0],t.removeNode(e),n.points.push({x:s.x,y:s.y}),"edge-label"===s.dummy&&(n.x=s.x,n.y=s.y,n.width=s.width,n.height=s.height),e=i,s=t.node(e)}))}};var dl=function(t){var e={};$h.forEach(t.sources(),(function i(s){var n=t.node(s);if($h.has(e,s))return n.rank;e[s]=!0;var r=$h.min($h.map(t.outEdges(s),(function(e){return i(e.w)-t.edge(e).minlen})));return r!==Number.POSITIVE_INFINITY&&null!=r||(r=0),n.rank=r}))},ul=function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen};var fl=zo.Graph,pl=ul,gl=function(t){var e,i,s=new fl({directed:!1}),n=t.nodes()[0],r=t.nodeCount();s.setNode(n,{});for(;_l(s,t)<r;)e=ml(s,t),i=s.hasNode(e.v)?pl(t,e):-pl(t,e),yl(s,t,i);return s};function _l(t,e){return $h.forEach(t.nodes(),(function i(s){$h.forEach(e.nodeEdges(s),(function(n){var r=n.v,a=s===r?n.w:r;t.hasNode(a)||pl(e,n)||(t.setNode(a,{}),t.setEdge(s,a,{}),i(a))}))})),t.nodeCount()}function ml(t,e){return $h.minBy(e.edges(),(function(i){if(t.hasNode(i.v)!==t.hasNode(i.w))return pl(e,i)}))}function yl(t,e,i){$h.forEach(t.nodes(),(function(t){e.node(t).rank+=i}))}var vl=ul,bl=dl,xl=zo.alg.preorder,wl=zo.alg.postorder,kl=ol.simplify,Cl=Sl;function Sl(t){t=kl(t),bl(t);var e,i=gl(t);for(Al(i),El(i,t);e=Ol(i);)Ml(i,t,e,Rl(i,t,e))}function El(t,e){var i=wl(t,t.nodes());i=i.slice(0,i.length-1),$h.forEach(i,(function(i){!function(t,e,i){var s=t.node(i).parent;t.edge(i,s).cutvalue=Tl(t,e,i)}(t,e,i)}))}function Tl(t,e,i){var s=t.node(i).parent,n=!0,r=e.edge(i,s),a=0;return r||(n=!1,r=e.edge(s,i)),a=r.weight,$h.forEach(e.nodeEdges(i),(function(r){var o,h,l=r.v===i,c=l?r.w:r.v;if(c!==s){var d=l===n,u=e.edge(r).weight;if(a+=d?u:-u,o=i,h=c,t.hasEdge(o,h)){var f=t.edge(i,c).cutvalue;a+=d?-f:f}}})),a}function Al(t,e){arguments.length<2&&(e=t.nodes()[0]),Il(t,{},1,e)}function Il(t,e,i,s,n){var r=i,a=t.node(s);return e[s]=!0,$h.forEach(t.neighbors(s),(function(n){$h.has(e,n)||(i=Il(t,e,i,n,s))})),a.low=r,a.lim=i++,n?a.parent=n:delete a.parent,i}function Ol(t){return $h.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function Rl(t,e,i){var s=i.v,n=i.w;e.hasEdge(s,n)||(s=i.w,n=i.v);var r=t.node(s),a=t.node(n),o=r,h=!1;r.lim>a.lim&&(o=a,h=!0);var l=$h.filter(e.edges(),(function(e){return h===Nl(t,t.node(e.v),o)&&h!==Nl(t,t.node(e.w),o)}));return $h.minBy(l,(function(t){return vl(e,t)}))}function Ml(t,e,i,s){var n=i.v,r=i.w;t.removeEdge(n,r),t.setEdge(s.v,s.w,{}),Al(t),El(t,e),function(t,e){var i=$h.find(t.nodes(),(function(t){return!e.node(t).parent})),s=xl(t,i);s=s.slice(1),$h.forEach(s,(function(i){var s=t.node(i).parent,n=e.edge(i,s),r=!1;n||(n=e.edge(s,i),r=!0),e.node(i).rank=e.node(s).rank+(r?n.minlen:-n.minlen)}))}(t,e)}function Nl(t,e,i){return i.low<=e.lim&&e.lim<=i.lim}Sl.initLowLimValues=Al,Sl.initCutValues=El,Sl.calcCutValue=Tl,Sl.leaveEdge=Ol,Sl.enterEdge=Rl,Sl.exchangeEdges=Ml;var Fl=dl,Pl=function(t){switch(t.graph().ranker){case"network-simplex":Ll(t);break;case"tight-tree":!function(t){Fl(t),gl(t)}(t);break;case"longest-path":Bl(t);break;default:Ll(t)}};var Bl=Fl;function Ll(t){Cl(t)}var jl=function(t){var e=function(t){var e={},i=0;function s(n){var r=i;$h.forEach(t.children(n),s),e[n]={low:r,lim:i++}}return $h.forEach(t.children(),s),e}(t);$h.forEach(t.graph().dummyChains,(function(i){for(var s=t.node(i),n=s.edgeObj,r=function(t,e,i,s){var n,r,a=[],o=[],h=Math.min(e[i].low,e[s].low),l=Math.max(e[i].lim,e[s].lim);n=i;do{n=t.parent(n),a.push(n)}while(n&&(e[n].low>h||l>e[n].lim));r=n,n=s;for(;(n=t.parent(n))!==r;)o.push(n);return{path:a.concat(o.reverse()),lca:r}}(t,e,n.v,n.w),a=r.path,o=r.lca,h=0,l=a[h],c=!0;i!==n.w;){if(s=t.node(i),c){for(;(l=a[h])!==o&&t.node(l).maxRank<s.rank;)h++;l===o&&(c=!1)}if(!c){for(;h<a.length-1&&t.node(l=a[h+1]).minRank<=s.rank;)h++;l=a[h]}t.setParent(i,l),i=t.successors(i)[0]}}))};var Dl={run:function(t){var e=ol.addDummyNode(t,"root",{},"_root"),i=function(t){var e={};function i(s,n){var r=t.children(s);r&&r.length&&$h.forEach(r,(function(t){i(t,n+1)})),e[s]=n}return $h.forEach(t.children(),(function(t){i(t,1)})),e}(t),s=$h.max($h.values(i))-1,n=2*s+1;t.graph().nestingRoot=e,$h.forEach(t.edges(),(function(e){t.edge(e).minlen*=n}));var r=function(t){return $h.reduce(t.edges(),(function(e,i){return e+t.edge(i).weight}),0)}(t)+1;$h.forEach(t.children(),(function(a){Vl(t,e,n,r,s,i,a)})),t.graph().nodeRankFactor=n},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,$h.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function Vl(t,e,i,s,n,r,a){var o=t.children(a);if(o.length){var h=ol.addBorderNode(t,"_bt"),l=ol.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(h,a),c.borderTop=h,t.setParent(l,a),c.borderBottom=l,$h.forEach(o,(function(o){Vl(t,e,i,s,n,r,o);var c=t.node(o),d=c.borderTop?c.borderTop:o,u=c.borderBottom?c.borderBottom:o,f=c.borderTop?s:2*s,p=d!==u?1:n-r[a]+1;t.setEdge(h,d,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(u,l,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,h,{weight:0,minlen:n+r[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:i})}var zl=function(t){$h.forEach(t.children(),(function e(i){var s=t.children(i),n=t.node(i);if(s.length&&$h.forEach(s,e),$h.has(n,"minRank")){n.borderLeft=[],n.borderRight=[];for(var r=n.minRank,a=n.maxRank+1;r<a;++r)Gl(t,"borderLeft","_bl",i,n,r),Gl(t,"borderRight","_br",i,n,r)}}))};function Gl(t,e,i,s,n,r){var a={width:0,height:0,rank:r,borderType:e},o=n[e][r-1],h=ol.addDummyNode(t,"border",a,i);n[e][r]=h,t.setParent(h,s),o&&t.setEdge(o,h,{weight:1})}var Wl={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||Ul(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){$h.forEach(t.nodes(),(function(e){Jl(t.node(e))})),$h.forEach(t.edges(),(function(e){var i=t.edge(e);$h.forEach(i.points,Jl),$h.has(i,"y")&&Jl(i)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){$h.forEach(t.nodes(),(function(e){Yl(t.node(e))})),$h.forEach(t.edges(),(function(e){var i=t.edge(e);$h.forEach(i.points,Yl),$h.has(i,"x")&&Yl(i)}))}(t),Ul(t))}};function Ul(t){$h.forEach(t.nodes(),(function(e){ql(t.node(e))})),$h.forEach(t.edges(),(function(e){ql(t.edge(e))}))}function ql(t){var e=t.width;t.width=t.height,t.height=e}function Jl(t){t.y=-t.y}function Yl(t){var e=t.x;t.x=t.y,t.y=e}var Hl=function(t){var e={},i=$h.filter(t.nodes(),(function(e){return!t.children(e).length})),s=$h.max($h.map(i,(function(e){return t.node(e).rank}))),n=$h.map($h.range(s+1),(function(){return[]}));function r(i){if(!$h.has(e,i)){e[i]=!0;var s=t.node(i);n[s.rank].push(i),$h.forEach(t.successors(i),r)}}var a=$h.sortBy(i,(function(e){return t.node(e).rank}));return $h.forEach(a,r),n};var $l=function(t,e){for(var i=0,s=1;s<e.length;++s)i+=Zl(t,e[s-1],e[s]);return i};function Zl(t,e,i){for(var s=$h.zipObject(i,$h.map(i,(function(t,e){return e}))),n=$h.flatten($h.map(e,(function(e){return $h.sortBy($h.map(t.outEdges(e),(function(e){return{pos:s[e.w],weight:t.edge(e).weight}})),"pos")})),!0),r=1;r<i.length;)r<<=1;var a=2*r-1;r-=1;var o=$h.map(new Array(a),(function(){return 0})),h=0;return $h.forEach(n.forEach((function(t){var e=t.pos+r;o[e]+=t.weight;for(var i=0;e>0;)e%2&&(i+=o[e+1]),o[e=e-1>>1]+=t.weight;h+=t.weight*i}))),h}var Kl=function(t,e){return $h.map(e,(function(e){var i=t.inEdges(e);if(i.length){var s=$h.reduce(i,(function(e,i){var s=t.edge(i),n=t.node(i.v);return{sum:e.sum+s.weight*n.order,weight:e.weight+s.weight}}),{sum:0,weight:0});return{v:e,barycenter:s.sum/s.weight,weight:s.weight}}return{v:e}}))};var Xl=function(t,e){var i={};return $h.forEach(t,(function(t,e){var s=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};$h.isUndefined(t.barycenter)||(s.barycenter=t.barycenter,s.weight=t.weight)})),$h.forEach(e.edges(),(function(t){var e=i[t.v],s=i[t.w];$h.isUndefined(e)||$h.isUndefined(s)||(s.indegree++,e.out.push(i[t.w]))})),function(t){var e=[];function i(t){return function(e){e.merged||($h.isUndefined(e.barycenter)||$h.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var i=0,s=0;t.weight&&(i+=t.barycenter*t.weight,s+=t.weight);e.weight&&(i+=e.barycenter*e.weight,s+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=i/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function s(e){return function(i){i.in.push(e),0==--i.indegree&&t.push(i)}}for(;t.length;){var n=t.pop();e.push(n),$h.forEach(n.in.reverse(),i(n)),$h.forEach(n.out,s(n))}return $h.map($h.filter(e,(function(t){return!t.merged})),(function(t){return $h.pick(t,["vs","i","barycenter","weight"])}))}($h.filter(i,(function(t){return!t.indegree})))};var Ql=function(t,e){var i=ol.partition(t,(function(t){return $h.has(t,"barycenter")})),s=i.lhs,n=$h.sortBy(i.rhs,(function(t){return-t.i})),r=[],a=0,o=0,h=0;s.sort((l=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:l?e.i-t.i:t.i-e.i})),h=tc(r,n,h),$h.forEach(s,(function(t){h+=t.vs.length,r.push(t.vs),a+=t.barycenter*t.weight,o+=t.weight,h=tc(r,n,h)}));var l;var c={vs:$h.flatten(r,!0)};o&&(c.barycenter=a/o,c.weight=o);return c};function tc(t,e,i){for(var s;e.length&&(s=$h.last(e)).i<=i;)e.pop(),t.push(s.vs),i++;return i}var ec=function t(e,i,s,n){var r=e.children(i),a=e.node(i),o=a?a.borderLeft:void 0,h=a?a.borderRight:void 0,l={};o&&(r=$h.filter(r,(function(t){return t!==o&&t!==h})));var c=Kl(e,r);$h.forEach(c,(function(i){if(e.children(i.v).length){var r=t(e,i.v,s,n);l[i.v]=r,$h.has(r,"barycenter")&&(a=i,o=r,$h.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 d=Xl(c,s);!function(t,e){$h.forEach(t,(function(t){t.vs=$h.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(d,l);var u=Ql(d,n);if(o&&(u.vs=$h.flatten([o,u.vs,h],!0),e.predecessors(o).length)){var f=e.node(e.predecessors(o)[0]),p=e.node(e.predecessors(h)[0]);$h.has(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+f.order+p.order)/(u.weight+2),u.weight+=2}return u};var ic=zo.Graph,sc=function(t,e,i){var s=function(t){var e;for(;t.hasNode(e=$h.uniqueId("_root")););return e}(t),n=new ic({compound:!0}).setGraph({root:s}).setDefaultNodeLabel((function(e){return t.node(e)}));return $h.forEach(t.nodes(),(function(r){var a=t.node(r),o=t.parent(r);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(n.setNode(r),n.setParent(r,o||s),$h.forEach(t[i](r),(function(e){var i=e.v===r?e.w:e.v,s=n.edge(i,r),a=$h.isUndefined(s)?0:s.weight;n.setEdge(i,r,{weight:t.edge(e).weight+a})})),$h.has(a,"minRank")&&n.setNode(r,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),n};var nc=function(t,e,i){var s,n={};$h.forEach(i,(function(i){for(var r,a,o=t.parent(i);o;){if((r=t.parent(o))?(a=n[r],n[r]=o):(a=s,s=o),a&&a!==o)return void e.setEdge(a,o);o=r}}))};var rc=zo.Graph,ac=function(t){var e=ol.maxRank(t),i=oc(t,$h.range(1,e+1),"inEdges"),s=oc(t,$h.range(e-1,-1,-1),"outEdges"),n=Hl(t);lc(t,n);for(var r,a=Number.POSITIVE_INFINITY,o=0,h=0;h<4;++o,++h){hc(o%2?i:s,o%4>=2),n=ol.buildLayerMatrix(t);var l=$l(t,n);l<a&&(h=0,r=$h.cloneDeep(n),a=l)}lc(t,r)};function oc(t,e,i){return $h.map(e,(function(e){return sc(t,e,i)}))}function hc(t,e){var i=new rc;$h.forEach(t,(function(t){var s=t.graph().root,n=ec(t,s,i,e);$h.forEach(n.vs,(function(e,i){t.node(e).order=i})),nc(t,i,n.vs)}))}function lc(t,e){$h.forEach(e,(function(e){$h.forEach(e,(function(e,i){t.node(e).order=i}))}))}var cc=zo.Graph,dc=function(t){var e,i=ol.buildLayerMatrix(t),s=$h.merge(uc(t,i),fc(t,i)),n={};$h.forEach(["u","d"],(function(r){e="u"===r?i:$h.values(i).reverse(),$h.forEach(["l","r"],(function(i){"r"===i&&(e=$h.map(e,(function(t){return $h.values(t).reverse()})));var a=("u"===r?t.predecessors:t.successors).bind(t),o=_c(t,e,s,a),h=mc(t,e,o.root,o.align,"r"===i);"r"===i&&(h=$h.mapValues(h,(function(t){return-t}))),n[r+i]=h}))}));var r=yc(t,n);return vc(n,r),bc(n,t.graph().align)};function uc(t,e){var i={};return $h.reduce(e,(function(e,s){var n=0,r=0,a=e.length,o=$h.last(s);return $h.forEach(s,(function(e,h){var l=function(t,e){if(t.node(e).dummy)return $h.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=l?t.node(l).order:a;(l||e===o)&&($h.forEach(s.slice(r,h+1),(function(e){$h.forEach(t.predecessors(e),(function(s){var r=t.node(s),a=r.order;!(a<n||c<a)||r.dummy&&t.node(e).dummy||pc(i,s,e)}))})),r=h+1,n=c)})),s})),i}function fc(t,e){var i={};function s(e,s,n,r,a){var o;$h.forEach($h.range(s,n),(function(s){o=e[s],t.node(o).dummy&&$h.forEach(t.predecessors(o),(function(e){var s=t.node(e);s.dummy&&(s.order<r||s.order>a)&&pc(i,e,o)}))}))}return $h.reduce(e,(function(e,i){var n,r=-1,a=0;return $h.forEach(i,(function(o,h){if("border"===t.node(o).dummy){var l=t.predecessors(o);l.length&&(n=t.node(l[0]).order,s(i,a,h,r,n),a=h,r=n)}s(i,a,i.length,n,e.length)})),i})),i}function pc(t,e,i){if(e>i){var s=e;e=i,i=s}var n=t[e];n||(t[e]=n={}),n[i]=!0}function gc(t,e,i){if(e>i){var s=e;e=i,i=s}return $h.has(t[e],i)}function _c(t,e,i,s){var n={},r={},a={};return $h.forEach(e,(function(t){$h.forEach(t,(function(t,e){n[t]=t,r[t]=t,a[t]=e}))})),$h.forEach(e,(function(t){var e=-1;$h.forEach(t,(function(t){var o=s(t);if(o.length)for(var h=((o=$h.sortBy(o,(function(t){return a[t]}))).length-1)/2,l=Math.floor(h),c=Math.ceil(h);l<=c;++l){var d=o[l];r[t]===t&&e<a[d]&&!gc(i,t,d)&&(r[d]=t,r[t]=n[t]=n[d],e=a[d])}}))})),{root:n,align:r}}function mc(t,e,i,s,n){var r={},a=function(t,e,i,s){var n=new cc,r=t.graph(),a=function(t,e,i){return function(s,n,r){var a,o=s.node(n),h=s.node(r),l=0;if(l+=o.width/2,$h.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(l+=i?a:-a),a=0,l+=(o.dummy?e:t)/2,l+=(h.dummy?e:t)/2,l+=h.width/2,$h.has(h,"labelpos"))switch(h.labelpos.toLowerCase()){case"l":a=h.width/2;break;case"r":a=-h.width/2}return a&&(l+=i?a:-a),a=0,l}}(r.nodesep,r.edgesep,s);return $h.forEach(e,(function(e){var s;$h.forEach(e,(function(e){var r=i[e];if(n.setNode(r),s){var o=i[s],h=n.edge(o,r);n.setEdge(o,r,Math.max(a(t,e,s),h||0))}s=e}))})),n}(t,e,i,n),o=n?"borderLeft":"borderRight";function h(t,e){for(var i=a.nodes(),s=i.pop(),n={};s;)n[s]?t(s):(n[s]=!0,i.push(s),i=i.concat(e(s))),s=i.pop()}return h((function(t){r[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,r[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),h((function(e){var i=a.outEdges(e).reduce((function(t,e){return Math.min(t,r[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),s=t.node(e);i!==Number.POSITIVE_INFINITY&&s.borderType!==o&&(r[e]=Math.max(r[e],i))}),a.successors.bind(a)),$h.forEach(s,(function(t){r[t]=r[i[t]]})),r}function yc(t,e){return $h.minBy($h.values(e),(function(e){var i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return $h.forIn(e,(function(e,n){var r=function(t,e){return t.node(e).width}(t,n)/2;i=Math.max(e+r,i),s=Math.min(e-r,s)})),i-s}))}function vc(t,e){var i=$h.values(e),s=$h.min(i),n=$h.max(i);$h.forEach(["u","d"],(function(i){$h.forEach(["l","r"],(function(r){var a,o=i+r,h=t[o];if(h!==e){var l=$h.values(h);(a="l"===r?s-$h.min(l):n-$h.max(l))&&(t[o]=$h.mapValues(h,(function(t){return t+a})))}}))}))}function bc(t,e){return $h.mapValues(t.ul,(function(i,s){if(e)return t[e.toLowerCase()][s];var n=$h.sortBy($h.map(t,s));return(n[1]+n[2])/2}))}var xc=dc,wc=function(t){(function(t){var e=ol.buildLayerMatrix(t),i=t.graph().ranksep,s=0;$h.forEach(e,(function(e){var n=$h.max($h.map(e,(function(e){return t.node(e).height})));$h.forEach(e,(function(e){t.node(e).y=s+n/2})),s+=n+i}))})(t=ol.asNonCompoundGraph(t)),$h.forEach(xc(t),(function(e,i){t.node(i).x=e}))};var kc=ol.normalizeRanks,Cc=ol.removeEmptyRanks,Sc=ol,Ec=zo.Graph,Tc=function(t,e){var i=e&&e.debugTiming?Sc.time:Sc.notime;i("layout",(function(){var e=i(" buildLayoutGraph",(function(){return function(t){var e=new Ec({multigraph:!0,compound:!0}),i=Lc(t.graph());return e.setGraph($h.merge({},Ic,Bc(i,Ac),$h.pick(i,Oc))),$h.forEach(t.nodes(),(function(i){var s=Lc(t.node(i));e.setNode(i,$h.defaults(Bc(s,Rc),Mc)),e.setParent(i,t.parent(i))})),$h.forEach(t.edges(),(function(i){var s=Lc(t.edge(i));e.setEdge(i,$h.merge({},Fc,Bc(s,Nc),$h.pick(s,Pc)))})),e}(t)}));i(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,$h.forEach(t.edges(),(function(i){var s=t.edge(i);s.minlen*=2,"c"!==s.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?s.width+=s.labeloffset:s.height+=s.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){$h.forEach(t.edges(),(function(e){if(e.v===e.w){var i=t.node(e.v);i.selfEdges||(i.selfEdges=[]),i.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){rl.run(t)})),e(" nestingGraph.run",(function(){Dl.run(t)})),e(" rank",(function(){Pl(Sc.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){$h.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.width&&i.height){var s=t.node(e.v),n={rank:(t.node(e.w).rank-s.rank)/2+s.rank,e:e};Sc.addDummyNode(t,"edge-proxy",n,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){Cc(t)})),e(" nestingGraph.cleanup",(function(){Dl.cleanup(t)})),e(" normalizeRanks",(function(){kc(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;$h.forEach(t.nodes(),(function(i){var s=t.node(i);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=$h.max(e,s.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){$h.forEach(t.nodes(),(function(e){var i=t.node(e);"edge-proxy"===i.dummy&&(t.edge(i.e).labelRank=i.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){cl.run(t)})),e(" parentDummyChains",(function(){jl(t)})),e(" addBorderSegments",(function(){zl(t)})),e(" order",(function(){ac(t)})),e(" insertSelfEdges",(function(){!function(t){var e=Sc.buildLayerMatrix(t);$h.forEach(e,(function(e){var i=0;$h.forEach(e,(function(e,s){var n=t.node(e);n.order=s+i,$h.forEach(n.selfEdges,(function(e){Sc.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:n.rank,order:s+ ++i,e:e.e,label:e.label},"_se")})),delete n.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){Wl.adjust(t)})),e(" position",(function(){wc(t)})),e(" positionSelfEdges",(function(){!function(t){$h.forEach(t.nodes(),(function(e){var i=t.node(e);if("selfedge"===i.dummy){var s=t.node(i.e.v),n=s.x+s.width/2,r=s.y,a=i.x-n,o=s.height/2;t.setEdge(i.e,i.label),t.removeNode(e),i.label.points=[{x:n+2*a/3,y:r-o},{x:n+5*a/6,y:r-o},{x:n+a,y:r},{x:n+5*a/6,y:r+o},{x:n+2*a/3,y:r+o}],i.label.x=i.x,i.label.y=i.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){$h.forEach(t.nodes(),(function(e){if(t.children(e).length){var i=t.node(e),s=t.node(i.borderTop),n=t.node(i.borderBottom),r=t.node($h.last(i.borderLeft)),a=t.node($h.last(i.borderRight));i.width=Math.abs(a.x-r.x),i.height=Math.abs(n.y-s.y),i.x=r.x+i.width/2,i.y=s.y+i.height/2}})),$h.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){cl.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){$h.forEach(t.edges(),(function(e){var i=t.edge(e);if($h.has(i,"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}}))}(t)})),e(" undoCoordinateSystem",(function(){Wl.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,i=0,s=Number.POSITIVE_INFINITY,n=0,r=t.graph(),a=r.marginx||0,o=r.marginy||0;function h(t){var r=t.x,a=t.y,o=t.width,h=t.height;e=Math.min(e,r-o/2),i=Math.max(i,r+o/2),s=Math.min(s,a-h/2),n=Math.max(n,a+h/2)}$h.forEach(t.nodes(),(function(e){h(t.node(e))})),$h.forEach(t.edges(),(function(e){var i=t.edge(e);$h.has(i,"x")&&h(i)})),e-=a,s-=o,$h.forEach(t.nodes(),(function(i){var n=t.node(i);n.x-=e,n.y-=s})),$h.forEach(t.edges(),(function(i){var n=t.edge(i);$h.forEach(n.points,(function(t){t.x-=e,t.y-=s})),$h.has(n,"x")&&(n.x-=e),$h.has(n,"y")&&(n.y-=s)})),r.width=i-e+a,r.height=n-s+o}(t)})),e(" assignNodeIntersects",(function(){!function(t){$h.forEach(t.edges(),(function(e){var i,s,n=t.edge(e),r=t.node(e.v),a=t.node(e.w);n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=a,s=r),n.points.unshift(Sc.intersectRect(r,i)),n.points.push(Sc.intersectRect(a,s))}))}(t)})),e(" reversePoints",(function(){!function(t){$h.forEach(t.edges(),(function(e){var i=t.edge(e);i.reversed&&i.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){rl.undo(t)}))}(e,i)})),i(" updateInputGraph",(function(){!function(t,e){$h.forEach(t.nodes(),(function(i){var s=t.node(i),n=e.node(i);s&&(s.x=n.x,s.y=n.y,e.children(i).length&&(s.width=n.width,s.height=n.height))})),$h.forEach(t.edges(),(function(i){var s=t.edge(i),n=e.edge(i);s.points=n.points,$h.has(n,"x")&&(s.x=n.x,s.y=n.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var Ac=["nodesep","edgesep","ranksep","marginx","marginy"],Ic={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Oc=["acyclicer","ranker","rankdir","align"],Rc=["width","height"],Mc={width:0,height:0},Nc=["minlen","weight","width","height","labeloffset"],Fc={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Pc=["labelpos"];function Bc(t,e){return $h.mapValues($h.pick(t,e),Number)}function Lc(t){var e={};return $h.forEach(t,(function(t,i){e[i.toLowerCase()]=t})),e}var jc=zo.Graph;var Dc={graphlib:zo,layout:Tc,debug:{debugOrdering:function(t){var e=ol.buildLayerMatrix(t),i=new jc({compound:!0,multigraph:!0}).setGraph({});return $h.forEach(t.nodes(),(function(e){i.setNode(e,{label:e}),i.setParent(e,"layer"+t.node(e).rank)})),$h.forEach(t.edges(),(function(t){i.setEdge(t.v,t.w,{},t.name)})),$h.forEach(e,(function(t,e){var s="layer"+e;i.setNode(s,{rank:"same"}),$h.reduce(t,(function(t,e){return i.setEdge(t,e,{style:"invis"}),e}))})),i}},util:{time:ol.time,notime:ol.notime},version:"0.8.5"},Vc=Dc.graphlib,zc=Dc.layout;class Gc extends G{constructor(t){super(t),this.type=y.Sugiyama,this._width="width"in t?t.width:500,this._height="height"in t?t.height:300,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0}toJSON(){let t={args:{}};return t.type=this.type,t}run(){let t=this.group.children[0].dataScope._dt.graph;if(!t)return;var e=new Vc.Graph;e.setGraph({edgesep:50}),e.setDefaultEdgeLabel((function(){return{}}));let i=new Map;for(let t of this.group.children){let s=t.dataScope.getFieldValue(o);i.set(s,s+""),e.setNode(s,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let i of t.links)e.setEdge(i.source,i.target);zc(e);const s={};let n=Math.min(...e.nodes().map((t=>e.node(t).y))),r=Math.min(...e.nodes().map((t=>e.node(t).x))),a=this._left-r,h=this._top-n;for(const t of e.nodes())s[t]={x:e.node(t).x+a,y:e.node(t).y+h};for(let t of this.group.children){let e=t.dataScope.getFieldValue(o);t.x=s[i.get(e)].x,t.y=s[i.get(e)].y}}}class Wc extends G{constructor(t){super(t),this.type=y.Strata,this._direction=t.direction,this._rootMark=t.rootMark,this._gap="gap"in t?t.gap:0}toJSON(){}clone(){}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.group.firstChild.dataScope.dataTable.tree;if(!t)return;let e={};for(let t of this.group.children)e[t.dataScope.getFieldValue(o)]=t;this._rootMark.type===T.Rect?this._layoutRects(t.getRoot(),t,e):this._rootMark.type===T.Circle&&this._layoutArcs(t.getRoot(),t,e)}_layoutArcs(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n=i[t.id],r=n.type==T.Arc||n.type==T.Pie?n.startAngle:90;for(let t=0;t<s.length;t++){let n=s[t],a=i[n.id];if(a.type===T.Arc){let t=At(r+a.angle);a.adjustAngle(r,t),r=t}this._layoutArcs(n,e,i)}}_layoutRects(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n,r,a=i[t.id];switch(this._direction){case k.Down:default:n=a.left,r=a.bottom}for(let t=0;t<s.length;t++){let a=s[t],o=i[a.id];o._doTranslate(n-o.left,r-o.top),n+=o.width,this._layoutRects(a,e,i)}}}var Uc={};function qc(t){return new ke(t)}function Jc(t,e){if(l.indexOf(t)<0)throw new Error(z.UNKOWNN_SCALE_TYPE+": "+t);return new Ee(t,e)}function Yc(t,e){let i=e||{};switch(t.toLowerCase()){case"grid":return new W(i);case"packing":return new Te(i);case"treemap":return new Ae(i);case"stack":return new Rt(i);case"tidytree":return new Re(i);case"force":return new Me(i);case"sugiyama":return new Gc(i);case"strata":return new Wc(i)}}function Hc(t){return new U(t||{})}function $c(t,e){return new Promise((function(i,s){let n=new XMLHttpRequest;n.open(t,e),n.onload=function(){this.status>=200&&this.status<300?i(n.response):s({status:this.status,statusText:n.statusText})},n.onerror=function(){s({status:this.status,statusText:n.statusText})},n.send()}))}async function Zc(t){let e=await $c("GET",t),i=n.csvParse(e.trim(),n.autoType);return new Gt(i,t)}function Kc(t){return!(!ut(t)&&t.type!=T.Glyph||t.dataScope)||t.type==T.Collection}function Xc(t){if([T.Line,T.Circle,T.Rect,T.Area,T.Ring,T.Pie].indexOf(t.type)<0)return!1;if(t.dataScope){let e=et(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function Qc(t){if([T.Line,T.Circle,T.Rect,T.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=et(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}t.canDensify=Qc,t.canDivide=Xc,t.canRepeat=Kc,t.cartesianToPolar=function(t,e,i,s){return wt(t,e,i,s)},t.createScale=Jc,t.csv=Zc,t.csvFromFile=async function(t){let e=n.csvParse(t.trim(),n.autoType);return new Gt(e,"")},t.csvFromString=function(t,e){let i=n.csvParse(t.trim(),n.autoType);return new Gt(i,e)},t.csvSync=function(t,e){let i=!!e;var s=new XMLHttpRequest;if(s.open("GET",t,i),s.send(),!i&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(s)){let e=n.csvParse(s.responseText.trim(),n.autoType);return new Gt(e,t)}},t.getPeersInScene=function(t){return"vertex"==t.type||"segment"==t.type?et(t,t.parent.getScene()):et(t,t.getScene())},t.graphjson=async function(t){let e=await $c("GET",t);return new Oe(JSON.parse(e),t)},t.hitTest=function(t,e,i){if(!t.children||0==t.children.length)return t.contains(e,i)&&t.type!==T.Scene?t:null;for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];if(n.contains(e,i))return n}return null},t.hitTestAll=function(t,e,i){let s=ct(t);for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.inMarkHitTest=function(t,e,i,s){let n,r=lt(t),o=s||2,h=mt.getContext();for(let t of r){if(!(t instanceof Z))continue;let s=new Path2D(t.getSVGPathData());if(h.lineWidth=Math.max(t.strokeWidth,2*o),h.stroke(s),h.isPointInStroke(s,e,i)){n=t;break}}if(!n)return null;let l=[];for(let t of n.vertices){let e=Math.max(o,t.width,2*t.radius),i=Math.max(o,t.height,2*t.radius);l.push({i:t,b:new a(t.x-e/2,t.y-i/2,e,i)})}for(let t of l)if(t.b.contains(e,i))return t.i;if(n.segments&&n.segments.length>0)for(let t of n.segments){let s=new Path2D;if(s.moveTo(t.vertex1.x,t.vertex1.y),s.lineTo(t.vertex2.x,t.vertex2.y),h.lineWidth=Math.max(n.strokeWidth,o),h.stroke(s),h.isPointInStroke(s,e,i))return t}return null},t.inMarkRectHitTest=function t(e,i,s){let n=s||2;if(ut(e)){let t=[];for(let i of e.vertices){let e=Math.max(n,i.width,2*i.radius),s=Math.max(n,i.height,2*i.radius);t.push({i:i,b:new a(i.x-e/2,i.y-s/2,e,s)})}if(e.type===T.Rect)for(let i of e.segments){let s=Math.max(e.strokeWidth,n);"v"===(i.vertex1.x===i.vertex2.x?"v":"h")?t.push({i:i,b:new a(i.vertex1.x-s/2,Math.min(i.vertex1.y,i.vertex2.y)-s/2,s,Math.abs(i.vertex1.y-i.vertex2.y))}):t.push({i:i,b:new a(Math.min(i.vertex1.x,i.vertex2.x)-s/2,i.vertex1.y-s/2,Math.abs(i.vertex1.x-i.vertex2.x),s)})}for(let e of t)if(e.b.overlap(i))return e.i;return null}if(!dt(e)&&e.children&&e.children.length>0){for(let s of e.children)if(s.bounds.overlap(i)){let e=t(s,i,n);if(e)return e}return null}return null},t.layout=Yc,t.linearGradient=Hc,t.polarToCartesian=function(t,e,i,s){return xt(t,e,i,s)},t.rectHitTest=function(t,e){let i=[];if(!t.children||0==t.children.length)return t.bounds.overlap(e)&&t.type!==T.Scene?[t]:[];for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];n.bounds.overlap(e)&&i.push(n)}return i},t.renderer=function(t,e){switch(t){case"svg":return new Se(e);case"webgl":return e in Uc||(Uc[e]=new Le(e)),Uc[e]}},t.scene=qc,t.sceneLoader=function(){return new Fe},t.specExecutor=function(){return new Pe},t.specGenerator=function(){return new Ne},t.treejson=async function(t){let e=await $c("GET",t);return new ye(JSON.parse(e),t)},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
199
|
+
*/var Ql=function(t){return fo(ho(t,void 0,Al),t+"")}((function(t,e){return null==t?{}:Xl(t,e)})),th=Math.ceil,eh=Math.max;var ih=function(t,e,i,s){for(var n=-1,r=eh(th((e-t)/(i||1)),0),a=Array(r);r--;)a[s?r:++n]=t,t+=i;return a};var sh=function(t){return function(e,i,s){return s&&"number"!=typeof s&&ll(e,i,s)&&(i=s=void 0),e=kl(e),void 0===i?(i=e,e=0):i=kl(i),s=void 0===s?e<i?1:-1:kl(s),ih(e,i,s,t)}}();var nh=function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t};var rh=function(t,e){if(t!==e){var i=void 0!==t,s=null===t,n=t==t,r=ea(t),a=void 0!==e,o=null===e,l=e==e,h=ea(e);if(!o&&!h&&!r&&t>e||r&&a&&l&&!o&&!h||s&&a&&l||!i&&l||!n)return 1;if(!s&&!r&&!h&&t<e||h&&i&&n&&!s&&!r||o&&i&&n||!a&&n||!l)return-1}return 0};var ah=function(t,e,i){for(var s=-1,n=t.criteria,r=e.criteria,a=n.length,o=i.length;++s<a;){var l=rh(n[s],r[s]);if(l)return s>=o?l:l*("desc"==i[s]?-1:1)}return t.index-e.index};var oh=function(t,e,i){e=e.length?ca(e,(function(t){return Gs(t)?function(e){return ma(e,1===t.length?t[0]:t)}:t})):[Cr];var s=-1;e=ca(e,Zs(Ea));var n=Ba(t,(function(t,i,n){return{criteria:ca(e,(function(e){return e(t)})),index:++s,value:t}}));return nh(n,(function(t,e){return ah(t,e,i)}))},lh=po((function(t,e){if(null==t)return[];var i=e.length;return i>1&&ll(t,e[0],e[1])?e=[]:i>2&&ll(e[0],e[1],e[2])&&(e=[e[0]]),oh(t,ao(e,1),[])})),hh=0;var ch=function(t){var e=++hh;return pa(t)+e};var dh=function(t,e,i){for(var s=-1,n=t.length,r=e.length,a={};++s<n;){var o=s<r?e[s]:void 0;i(a,t[s],o)}return a};var uh,fh=function(t,e){return dh(t||[],e||[],Ns)};try{uh={cloneDeep:ol,constant:xr,defaults:dl,each:Tr,filter:Aa,find:El,flatten:Al,forEach:Ar,forIn:Tl,has:Oa,isUndefined:Na,last:Il,map:Pa,mapValues:Ol,max:Nl,merge:ql,min:Jl,minBy:Yl,now:$l,pick:Ql,range:sh,reduce:Da,sortBy:lh,uniqueId:ch,values:To,zipObject:fh}}catch(t){}uh||(uh=window._);var ph=uh,gh=_h;function _h(){var t={};t._next=t._prev=t,this._sentinel=t}function mh(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function yh(t,e){if("_next"!==t&&"_prev"!==t)return e}_h.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return mh(e),e},_h.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&mh(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},_h.prototype.toString=function(){for(var t=[],e=this._sentinel,i=e._prev;i!==e;)t.push(JSON.stringify(i,yh)),i=i._prev;return"["+t.join(", ")+"]"};var vh=al.Graph,bh=function(t,e){if(t.nodeCount()<=1)return[];var i=function(t,e){var i=new vh,s=0,n=0;ph.forEach(t.nodes(),(function(t){i.setNode(t,{v:t,in:0,out:0})})),ph.forEach(t.edges(),(function(t){var r=i.edge(t.v,t.w)||0,a=e(t),o=r+a;i.setEdge(t.v,t.w,o),n=Math.max(n,i.node(t.v).out+=a),s=Math.max(s,i.node(t.w).in+=a)}));var r=ph.range(n+s+3).map((function(){return new gh})),a=s+1;return ph.forEach(i.nodes(),(function(t){kh(r,a,i.node(t))})),{graph:i,buckets:r,zeroIdx:a}}(t,e||xh),s=function(t,e,i){var s,n=[],r=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;s=a.dequeue();)wh(t,e,i,s);for(;s=r.dequeue();)wh(t,e,i,s);if(t.nodeCount())for(var o=e.length-2;o>0;--o)if(s=e[o].dequeue()){n=n.concat(wh(t,e,i,s,!0));break}}return n}(i.graph,i.buckets,i.zeroIdx);return ph.flatten(ph.map(s,(function(e){return t.outEdges(e.v,e.w)})),!0)},xh=ph.constant(1);function wh(t,e,i,s,n){var r=n?[]:void 0;return ph.forEach(t.inEdges(s.v),(function(s){var a=t.edge(s),o=t.node(s.v);n&&r.push({v:s.v,w:s.w}),o.out-=a,kh(e,i,o)})),ph.forEach(t.outEdges(s.v),(function(s){var n=t.edge(s),r=s.w,a=t.node(r);a.in-=n,kh(e,i,a)})),t.removeNode(s.v),r}function kh(t,e,i){i.out?i.in?t[i.out-i.in+e].enqueue(i):t[t.length-1].enqueue(i):t[0].enqueue(i)}var Sh={run:function(t){var e="greedy"===t.graph().acyclicer?bh(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],i={},s={};function n(r){ph.has(s,r)||(s[r]=!0,i[r]=!0,ph.forEach(t.outEdges(r),(function(t){ph.has(i,t.w)?e.push(t):n(t.w)})),delete i[r])}return ph.forEach(t.nodes(),n),e}(t);ph.forEach(e,(function(e){var i=t.edge(e);t.removeEdge(e),i.forwardName=e.name,i.reversed=!0,t.setEdge(e.w,e.v,i,ph.uniqueId("rev"))}))},undo:function(t){ph.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.reversed){t.removeEdge(e);var s=i.forwardName;delete i.reversed,delete i.forwardName,t.setEdge(e.w,e.v,i,s)}}))}};var Ch=al.Graph,Eh={addDummyNode:Ah,simplify:function(t){var e=(new Ch).setGraph(t.graph());return ph.forEach(t.nodes(),(function(i){e.setNode(i,t.node(i))})),ph.forEach(t.edges(),(function(i){var s=e.edge(i.v,i.w)||{weight:0,minlen:1},n=t.edge(i);e.setEdge(i.v,i.w,{weight:s.weight+n.weight,minlen:Math.max(s.minlen,n.minlen)})})),e},asNonCompoundGraph:function(t){var e=new Ch({multigraph:t.isMultigraph()}).setGraph(t.graph());return ph.forEach(t.nodes(),(function(i){t.children(i).length||e.setNode(i,t.node(i))})),ph.forEach(t.edges(),(function(i){e.setEdge(i,t.edge(i))})),e},successorWeights:function(t){var e=ph.map(t.nodes(),(function(e){var i={};return ph.forEach(t.outEdges(e),(function(e){i[e.w]=(i[e.w]||0)+t.edge(e).weight})),i}));return ph.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=ph.map(t.nodes(),(function(e){var i={};return ph.forEach(t.inEdges(e),(function(e){i[e.v]=(i[e.v]||0)+t.edge(e).weight})),i}));return ph.zipObject(t.nodes(),e)},intersectRect:function(t,e){var i,s,n=t.x,r=t.y,a=e.x-n,o=e.y-r,l=t.width/2,h=t.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,s=h):(a<0&&(l=-l),i=l,s=l*o/a);return{x:n+i,y:r+s}},buildLayerMatrix:function(t){var e=ph.map(ph.range(Th(t)+1),(function(){return[]}));return ph.forEach(t.nodes(),(function(i){var s=t.node(i),n=s.rank;ph.isUndefined(n)||(e[n][s.order]=i)})),e},normalizeRanks:function(t){var e=ph.min(ph.map(t.nodes(),(function(e){return t.node(e).rank})));ph.forEach(t.nodes(),(function(i){var s=t.node(i);ph.has(s,"rank")&&(s.rank-=e)}))},removeEmptyRanks:function(t){var e=ph.min(ph.map(t.nodes(),(function(e){return t.node(e).rank}))),i=[];ph.forEach(t.nodes(),(function(s){var n=t.node(s).rank-e;i[n]||(i[n]=[]),i[n].push(s)}));var s=0,n=t.graph().nodeRankFactor;ph.forEach(i,(function(e,i){ph.isUndefined(e)&&i%n!=0?--s:s&&ph.forEach(e,(function(e){t.node(e).rank+=s}))}))},addBorderNode:function(t,e,i,s){var n={width:0,height:0};arguments.length>=4&&(n.rank=i,n.order=s);return Ah(t,"border",n,e)},maxRank:Th,partition:function(t,e){var i={lhs:[],rhs:[]};return ph.forEach(t,(function(t){e(t)?i.lhs.push(t):i.rhs.push(t)})),i},time:function(t,e){var i=ph.now();try{return e()}finally{console.log(t+" time: "+(ph.now()-i)+"ms")}},notime:function(t,e){return e()}};function Ah(t,e,i,s){var n;do{n=ph.uniqueId(s)}while(t.hasNode(n));return i.dummy=e,t.setNode(n,i),n}function Th(t){return ph.max(ph.map(t.nodes(),(function(e){var i=t.node(e).rank;if(!ph.isUndefined(i))return i})))}var Ih={run:function(t){t.graph().dummyChains=[],ph.forEach(t.edges(),(function(e){!function(t,e){var i,s,n,r=e.v,a=t.node(r).rank,o=e.w,l=t.node(o).rank,h=e.name,c=t.edge(e),d=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),n=0,++a;a<l;++n,++a)c.points=[],s={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},i=Eh.addDummyNode(t,"edge",s,"_d"),a===d&&(s.width=c.width,s.height=c.height,s.dummy="edge-label",s.labelpos=c.labelpos),t.setEdge(r,i,{weight:c.weight},h),0===n&&t.graph().dummyChains.push(i),r=i;t.setEdge(r,o,{weight:c.weight},h)}(t,e)}))},undo:function(t){ph.forEach(t.graph().dummyChains,(function(e){var i,s=t.node(e),n=s.edgeLabel;for(t.setEdge(s.edgeObj,n);s.dummy;)i=t.successors(e)[0],t.removeNode(e),n.points.push({x:s.x,y:s.y}),"edge-label"===s.dummy&&(n.x=s.x,n.y=s.y,n.width=s.width,n.height=s.height),e=i,s=t.node(e)}))}};var Oh=function(t){var e={};ph.forEach(t.sources(),(function i(s){var n=t.node(s);if(ph.has(e,s))return n.rank;e[s]=!0;var r=ph.min(ph.map(t.outEdges(s),(function(e){return i(e.w)-t.edge(e).minlen})));return r!==Number.POSITIVE_INFINITY&&null!=r||(r=0),n.rank=r}))},Mh=function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen};var Rh=al.Graph,Nh=Mh,Bh=function(t){var e,i,s=new Rh({directed:!1}),n=t.nodes()[0],r=t.nodeCount();s.setNode(n,{});for(;Ph(s,t)<r;)e=Fh(s,t),i=s.hasNode(e.v)?Nh(t,e):-Nh(t,e),Lh(s,t,i);return s};function Ph(t,e){return ph.forEach(t.nodes(),(function i(s){ph.forEach(e.nodeEdges(s),(function(n){var r=n.v,a=s===r?n.w:r;t.hasNode(a)||Nh(e,n)||(t.setNode(a,{}),t.setEdge(s,a,{}),i(a))}))})),t.nodeCount()}function Fh(t,e){return ph.minBy(e.edges(),(function(i){if(t.hasNode(i.v)!==t.hasNode(i.w))return Nh(e,i)}))}function Lh(t,e,i){ph.forEach(t.nodes(),(function(t){e.node(t).rank+=i}))}var Dh=Mh,jh=Oh,Vh=al.alg.preorder,zh=al.alg.postorder,Gh=Eh.simplify,Wh=Uh;function Uh(t){t=Gh(t),jh(t);var e,i=Bh(t);for(Jh(i),qh(i,t);e=$h(i);)Kh(i,t,e,Zh(i,t,e))}function qh(t,e){var i=zh(t,t.nodes());i=i.slice(0,i.length-1),ph.forEach(i,(function(i){!function(t,e,i){var s=t.node(i).parent;t.edge(i,s).cutvalue=Hh(t,e,i)}(t,e,i)}))}function Hh(t,e,i){var s=t.node(i).parent,n=!0,r=e.edge(i,s),a=0;return r||(n=!1,r=e.edge(s,i)),a=r.weight,ph.forEach(e.nodeEdges(i),(function(r){var o,l,h=r.v===i,c=h?r.w:r.v;if(c!==s){var d=h===n,u=e.edge(r).weight;if(a+=d?u:-u,o=i,l=c,t.hasEdge(o,l)){var f=t.edge(i,c).cutvalue;a+=d?-f:f}}})),a}function Jh(t,e){arguments.length<2&&(e=t.nodes()[0]),Yh(t,{},1,e)}function Yh(t,e,i,s,n){var r=i,a=t.node(s);return e[s]=!0,ph.forEach(t.neighbors(s),(function(n){ph.has(e,n)||(i=Yh(t,e,i,n,s))})),a.low=r,a.lim=i++,n?a.parent=n:delete a.parent,i}function $h(t){return ph.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function Zh(t,e,i){var s=i.v,n=i.w;e.hasEdge(s,n)||(s=i.w,n=i.v);var r=t.node(s),a=t.node(n),o=r,l=!1;r.lim>a.lim&&(o=a,l=!0);var h=ph.filter(e.edges(),(function(e){return l===Xh(t,t.node(e.v),o)&&l!==Xh(t,t.node(e.w),o)}));return ph.minBy(h,(function(t){return Dh(e,t)}))}function Kh(t,e,i,s){var n=i.v,r=i.w;t.removeEdge(n,r),t.setEdge(s.v,s.w,{}),Jh(t),qh(t,e),function(t,e){var i=ph.find(t.nodes(),(function(t){return!e.node(t).parent})),s=Vh(t,i);s=s.slice(1),ph.forEach(s,(function(i){var s=t.node(i).parent,n=e.edge(i,s),r=!1;n||(n=e.edge(s,i),r=!0),e.node(i).rank=e.node(s).rank+(r?n.minlen:-n.minlen)}))}(t,e)}function Xh(t,e,i){return i.low<=e.lim&&e.lim<=i.lim}Uh.initLowLimValues=Jh,Uh.initCutValues=qh,Uh.calcCutValue=Hh,Uh.leaveEdge=$h,Uh.enterEdge=Zh,Uh.exchangeEdges=Kh;var Qh=Oh,tc=function(t){switch(t.graph().ranker){case"network-simplex":ic(t);break;case"tight-tree":!function(t){Qh(t),Bh(t)}(t);break;case"longest-path":ec(t);break;default:ic(t)}};var ec=Qh;function ic(t){Wh(t)}var sc=function(t){var e=function(t){var e={},i=0;function s(n){var r=i;ph.forEach(t.children(n),s),e[n]={low:r,lim:i++}}return ph.forEach(t.children(),s),e}(t);ph.forEach(t.graph().dummyChains,(function(i){for(var s=t.node(i),n=s.edgeObj,r=function(t,e,i,s){var n,r,a=[],o=[],l=Math.min(e[i].low,e[s].low),h=Math.max(e[i].lim,e[s].lim);n=i;do{n=t.parent(n),a.push(n)}while(n&&(e[n].low>l||h>e[n].lim));r=n,n=s;for(;(n=t.parent(n))!==r;)o.push(n);return{path:a.concat(o.reverse()),lca:r}}(t,e,n.v,n.w),a=r.path,o=r.lca,l=0,h=a[l],c=!0;i!==n.w;){if(s=t.node(i),c){for(;(h=a[l])!==o&&t.node(h).maxRank<s.rank;)l++;h===o&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(h=a[l+1]).minRank<=s.rank;)l++;h=a[l]}t.setParent(i,h),i=t.successors(i)[0]}}))};var nc={run:function(t){var e=Eh.addDummyNode(t,"root",{},"_root"),i=function(t){var e={};function i(s,n){var r=t.children(s);r&&r.length&&ph.forEach(r,(function(t){i(t,n+1)})),e[s]=n}return ph.forEach(t.children(),(function(t){i(t,1)})),e}(t),s=ph.max(ph.values(i))-1,n=2*s+1;t.graph().nestingRoot=e,ph.forEach(t.edges(),(function(e){t.edge(e).minlen*=n}));var r=function(t){return ph.reduce(t.edges(),(function(e,i){return e+t.edge(i).weight}),0)}(t)+1;ph.forEach(t.children(),(function(a){rc(t,e,n,r,s,i,a)})),t.graph().nodeRankFactor=n},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,ph.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function rc(t,e,i,s,n,r,a){var o=t.children(a);if(o.length){var l=Eh.addBorderNode(t,"_bt"),h=Eh.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(h,a),c.borderBottom=h,ph.forEach(o,(function(o){rc(t,e,i,s,n,r,o);var c=t.node(o),d=c.borderTop?c.borderTop:o,u=c.borderBottom?c.borderBottom:o,f=c.borderTop?s:2*s,p=d!==u?1:n-r[a]+1;t.setEdge(l,d,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(u,h,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:n+r[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:i})}var ac=function(t){ph.forEach(t.children(),(function e(i){var s=t.children(i),n=t.node(i);if(s.length&&ph.forEach(s,e),ph.has(n,"minRank")){n.borderLeft=[],n.borderRight=[];for(var r=n.minRank,a=n.maxRank+1;r<a;++r)oc(t,"borderLeft","_bl",i,n,r),oc(t,"borderRight","_br",i,n,r)}}))};function oc(t,e,i,s,n,r){var a={width:0,height:0,rank:r,borderType:e},o=n[e][r-1],l=Eh.addDummyNode(t,"border",a,i);n[e][r]=l,t.setParent(l,s),o&&t.setEdge(o,l,{weight:1})}var lc={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||hc(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){ph.forEach(t.nodes(),(function(e){dc(t.node(e))})),ph.forEach(t.edges(),(function(e){var i=t.edge(e);ph.forEach(i.points,dc),ph.has(i,"y")&&dc(i)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){ph.forEach(t.nodes(),(function(e){uc(t.node(e))})),ph.forEach(t.edges(),(function(e){var i=t.edge(e);ph.forEach(i.points,uc),ph.has(i,"x")&&uc(i)}))}(t),hc(t))}};function hc(t){ph.forEach(t.nodes(),(function(e){cc(t.node(e))})),ph.forEach(t.edges(),(function(e){cc(t.edge(e))}))}function cc(t){var e=t.width;t.width=t.height,t.height=e}function dc(t){t.y=-t.y}function uc(t){var e=t.x;t.x=t.y,t.y=e}var fc=function(t){var e={},i=ph.filter(t.nodes(),(function(e){return!t.children(e).length})),s=ph.max(ph.map(i,(function(e){return t.node(e).rank}))),n=ph.map(ph.range(s+1),(function(){return[]}));function r(i){if(!ph.has(e,i)){e[i]=!0;var s=t.node(i);n[s.rank].push(i),ph.forEach(t.successors(i),r)}}var a=ph.sortBy(i,(function(e){return t.node(e).rank}));return ph.forEach(a,r),n};var pc=function(t,e){for(var i=0,s=1;s<e.length;++s)i+=gc(t,e[s-1],e[s]);return i};function gc(t,e,i){for(var s=ph.zipObject(i,ph.map(i,(function(t,e){return e}))),n=ph.flatten(ph.map(e,(function(e){return ph.sortBy(ph.map(t.outEdges(e),(function(e){return{pos:s[e.w],weight:t.edge(e).weight}})),"pos")})),!0),r=1;r<i.length;)r<<=1;var a=2*r-1;r-=1;var o=ph.map(new Array(a),(function(){return 0})),l=0;return ph.forEach(n.forEach((function(t){var e=t.pos+r;o[e]+=t.weight;for(var i=0;e>0;)e%2&&(i+=o[e+1]),o[e=e-1>>1]+=t.weight;l+=t.weight*i}))),l}var _c=function(t,e){return ph.map(e,(function(e){var i=t.inEdges(e);if(i.length){var s=ph.reduce(i,(function(e,i){var s=t.edge(i),n=t.node(i.v);return{sum:e.sum+s.weight*n.order,weight:e.weight+s.weight}}),{sum:0,weight:0});return{v:e,barycenter:s.sum/s.weight,weight:s.weight}}return{v:e}}))};var mc=function(t,e){var i={};return ph.forEach(t,(function(t,e){var s=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};ph.isUndefined(t.barycenter)||(s.barycenter=t.barycenter,s.weight=t.weight)})),ph.forEach(e.edges(),(function(t){var e=i[t.v],s=i[t.w];ph.isUndefined(e)||ph.isUndefined(s)||(s.indegree++,e.out.push(i[t.w]))})),function(t){var e=[];function i(t){return function(e){e.merged||(ph.isUndefined(e.barycenter)||ph.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var i=0,s=0;t.weight&&(i+=t.barycenter*t.weight,s+=t.weight);e.weight&&(i+=e.barycenter*e.weight,s+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=i/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function s(e){return function(i){i.in.push(e),0==--i.indegree&&t.push(i)}}for(;t.length;){var n=t.pop();e.push(n),ph.forEach(n.in.reverse(),i(n)),ph.forEach(n.out,s(n))}return ph.map(ph.filter(e,(function(t){return!t.merged})),(function(t){return ph.pick(t,["vs","i","barycenter","weight"])}))}(ph.filter(i,(function(t){return!t.indegree})))};var yc=function(t,e){var i=Eh.partition(t,(function(t){return ph.has(t,"barycenter")})),s=i.lhs,n=ph.sortBy(i.rhs,(function(t){return-t.i})),r=[],a=0,o=0,l=0;s.sort((h=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:h?e.i-t.i:t.i-e.i})),l=vc(r,n,l),ph.forEach(s,(function(t){l+=t.vs.length,r.push(t.vs),a+=t.barycenter*t.weight,o+=t.weight,l=vc(r,n,l)}));var h;var c={vs:ph.flatten(r,!0)};o&&(c.barycenter=a/o,c.weight=o);return c};function vc(t,e,i){for(var s;e.length&&(s=ph.last(e)).i<=i;)e.pop(),t.push(s.vs),i++;return i}var bc=function t(e,i,s,n){var r=e.children(i),a=e.node(i),o=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,h={};o&&(r=ph.filter(r,(function(t){return t!==o&&t!==l})));var c=_c(e,r);ph.forEach(c,(function(i){if(e.children(i.v).length){var r=t(e,i.v,s,n);h[i.v]=r,ph.has(r,"barycenter")&&(a=i,o=r,ph.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 d=mc(c,s);!function(t,e){ph.forEach(t,(function(t){t.vs=ph.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(d,h);var u=yc(d,n);if(o&&(u.vs=ph.flatten([o,u.vs,l],!0),e.predecessors(o).length)){var f=e.node(e.predecessors(o)[0]),p=e.node(e.predecessors(l)[0]);ph.has(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+f.order+p.order)/(u.weight+2),u.weight+=2}return u};var xc=al.Graph,wc=function(t,e,i){var s=function(t){var e;for(;t.hasNode(e=ph.uniqueId("_root")););return e}(t),n=new xc({compound:!0}).setGraph({root:s}).setDefaultNodeLabel((function(e){return t.node(e)}));return ph.forEach(t.nodes(),(function(r){var a=t.node(r),o=t.parent(r);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(n.setNode(r),n.setParent(r,o||s),ph.forEach(t[i](r),(function(e){var i=e.v===r?e.w:e.v,s=n.edge(i,r),a=ph.isUndefined(s)?0:s.weight;n.setEdge(i,r,{weight:t.edge(e).weight+a})})),ph.has(a,"minRank")&&n.setNode(r,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),n};var kc=function(t,e,i){var s,n={};ph.forEach(i,(function(i){for(var r,a,o=t.parent(i);o;){if((r=t.parent(o))?(a=n[r],n[r]=o):(a=s,s=o),a&&a!==o)return void e.setEdge(a,o);o=r}}))};var Sc=al.Graph,Cc=function(t){var e=Eh.maxRank(t),i=Ec(t,ph.range(1,e+1),"inEdges"),s=Ec(t,ph.range(e-1,-1,-1),"outEdges"),n=fc(t);Tc(t,n);for(var r,a=Number.POSITIVE_INFINITY,o=0,l=0;l<4;++o,++l){Ac(o%2?i:s,o%4>=2),n=Eh.buildLayerMatrix(t);var h=pc(t,n);h<a&&(l=0,r=ph.cloneDeep(n),a=h)}Tc(t,r)};function Ec(t,e,i){return ph.map(e,(function(e){return wc(t,e,i)}))}function Ac(t,e){var i=new Sc;ph.forEach(t,(function(t){var s=t.graph().root,n=bc(t,s,i,e);ph.forEach(n.vs,(function(e,i){t.node(e).order=i})),kc(t,i,n.vs)}))}function Tc(t,e){ph.forEach(e,(function(e){ph.forEach(e,(function(e,i){t.node(e).order=i}))}))}var Ic=al.Graph,Oc=function(t){var e,i=Eh.buildLayerMatrix(t),s=ph.merge(Mc(t,i),Rc(t,i)),n={};ph.forEach(["u","d"],(function(r){e="u"===r?i:ph.values(i).reverse(),ph.forEach(["l","r"],(function(i){"r"===i&&(e=ph.map(e,(function(t){return ph.values(t).reverse()})));var a=("u"===r?t.predecessors:t.successors).bind(t),o=Pc(t,e,s,a),l=Fc(t,e,o.root,o.align,"r"===i);"r"===i&&(l=ph.mapValues(l,(function(t){return-t}))),n[r+i]=l}))}));var r=Lc(t,n);return Dc(n,r),jc(n,t.graph().align)};function Mc(t,e){var i={};return ph.reduce(e,(function(e,s){var n=0,r=0,a=e.length,o=ph.last(s);return ph.forEach(s,(function(e,l){var h=function(t,e){if(t.node(e).dummy)return ph.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=h?t.node(h).order:a;(h||e===o)&&(ph.forEach(s.slice(r,l+1),(function(e){ph.forEach(t.predecessors(e),(function(s){var r=t.node(s),a=r.order;!(a<n||c<a)||r.dummy&&t.node(e).dummy||Nc(i,s,e)}))})),r=l+1,n=c)})),s})),i}function Rc(t,e){var i={};function s(e,s,n,r,a){var o;ph.forEach(ph.range(s,n),(function(s){o=e[s],t.node(o).dummy&&ph.forEach(t.predecessors(o),(function(e){var s=t.node(e);s.dummy&&(s.order<r||s.order>a)&&Nc(i,e,o)}))}))}return ph.reduce(e,(function(e,i){var n,r=-1,a=0;return ph.forEach(i,(function(o,l){if("border"===t.node(o).dummy){var h=t.predecessors(o);h.length&&(n=t.node(h[0]).order,s(i,a,l,r,n),a=l,r=n)}s(i,a,i.length,n,e.length)})),i})),i}function Nc(t,e,i){if(e>i){var s=e;e=i,i=s}var n=t[e];n||(t[e]=n={}),n[i]=!0}function Bc(t,e,i){if(e>i){var s=e;e=i,i=s}return ph.has(t[e],i)}function Pc(t,e,i,s){var n={},r={},a={};return ph.forEach(e,(function(t){ph.forEach(t,(function(t,e){n[t]=t,r[t]=t,a[t]=e}))})),ph.forEach(e,(function(t){var e=-1;ph.forEach(t,(function(t){var o=s(t);if(o.length)for(var l=((o=ph.sortBy(o,(function(t){return a[t]}))).length-1)/2,h=Math.floor(l),c=Math.ceil(l);h<=c;++h){var d=o[h];r[t]===t&&e<a[d]&&!Bc(i,t,d)&&(r[d]=t,r[t]=n[t]=n[d],e=a[d])}}))})),{root:n,align:r}}function Fc(t,e,i,s,n){var r={},a=function(t,e,i,s){var n=new Ic,r=t.graph(),a=function(t,e,i){return function(s,n,r){var a,o=s.node(n),l=s.node(r),h=0;if(h+=o.width/2,ph.has(o,"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?e:t)/2,h+=(l.dummy?e:t)/2,h+=l.width/2,ph.has(l,"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}}(r.nodesep,r.edgesep,s);return ph.forEach(e,(function(e){var s;ph.forEach(e,(function(e){var r=i[e];if(n.setNode(r),s){var o=i[s],l=n.edge(o,r);n.setEdge(o,r,Math.max(a(t,e,s),l||0))}s=e}))})),n}(t,e,i,n),o=n?"borderLeft":"borderRight";function l(t,e){for(var i=a.nodes(),s=i.pop(),n={};s;)n[s]?t(s):(n[s]=!0,i.push(s),i=i.concat(e(s))),s=i.pop()}return l((function(t){r[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,r[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),l((function(e){var i=a.outEdges(e).reduce((function(t,e){return Math.min(t,r[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),s=t.node(e);i!==Number.POSITIVE_INFINITY&&s.borderType!==o&&(r[e]=Math.max(r[e],i))}),a.successors.bind(a)),ph.forEach(s,(function(t){r[t]=r[i[t]]})),r}function Lc(t,e){return ph.minBy(ph.values(e),(function(e){var i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return ph.forIn(e,(function(e,n){var r=function(t,e){return t.node(e).width}(t,n)/2;i=Math.max(e+r,i),s=Math.min(e-r,s)})),i-s}))}function Dc(t,e){var i=ph.values(e),s=ph.min(i),n=ph.max(i);ph.forEach(["u","d"],(function(i){ph.forEach(["l","r"],(function(r){var a,o=i+r,l=t[o];if(l!==e){var h=ph.values(l);(a="l"===r?s-ph.min(h):n-ph.max(h))&&(t[o]=ph.mapValues(l,(function(t){return t+a})))}}))}))}function jc(t,e){return ph.mapValues(t.ul,(function(i,s){if(e)return t[e.toLowerCase()][s];var n=ph.sortBy(ph.map(t,s));return(n[1]+n[2])/2}))}var Vc=Oc,zc=function(t){(function(t){var e=Eh.buildLayerMatrix(t),i=t.graph().ranksep,s=0;ph.forEach(e,(function(e){var n=ph.max(ph.map(e,(function(e){return t.node(e).height})));ph.forEach(e,(function(e){t.node(e).y=s+n/2})),s+=n+i}))})(t=Eh.asNonCompoundGraph(t)),ph.forEach(Vc(t),(function(e,i){t.node(i).x=e}))};var Gc=Eh.normalizeRanks,Wc=Eh.removeEmptyRanks,Uc=Eh,qc=al.Graph,Hc=function(t,e){var i=e&&e.debugTiming?Uc.time:Uc.notime;i("layout",(function(){var e=i(" buildLayoutGraph",(function(){return function(t){var e=new qc({multigraph:!0,compound:!0}),i=id(t.graph());return e.setGraph(ph.merge({},Yc,ed(i,Jc),ph.pick(i,$c))),ph.forEach(t.nodes(),(function(i){var s=id(t.node(i));e.setNode(i,ph.defaults(ed(s,Zc),Kc)),e.setParent(i,t.parent(i))})),ph.forEach(t.edges(),(function(i){var s=id(t.edge(i));e.setEdge(i,ph.merge({},Qc,ed(s,Xc),ph.pick(s,td)))})),e}(t)}));i(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,ph.forEach(t.edges(),(function(i){var s=t.edge(i);s.minlen*=2,"c"!==s.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?s.width+=s.labeloffset:s.height+=s.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){ph.forEach(t.edges(),(function(e){if(e.v===e.w){var i=t.node(e.v);i.selfEdges||(i.selfEdges=[]),i.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){Sh.run(t)})),e(" nestingGraph.run",(function(){nc.run(t)})),e(" rank",(function(){tc(Uc.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){ph.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.width&&i.height){var s=t.node(e.v),n={rank:(t.node(e.w).rank-s.rank)/2+s.rank,e:e};Uc.addDummyNode(t,"edge-proxy",n,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){Wc(t)})),e(" nestingGraph.cleanup",(function(){nc.cleanup(t)})),e(" normalizeRanks",(function(){Gc(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;ph.forEach(t.nodes(),(function(i){var s=t.node(i);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=ph.max(e,s.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){ph.forEach(t.nodes(),(function(e){var i=t.node(e);"edge-proxy"===i.dummy&&(t.edge(i.e).labelRank=i.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){Ih.run(t)})),e(" parentDummyChains",(function(){sc(t)})),e(" addBorderSegments",(function(){ac(t)})),e(" order",(function(){Cc(t)})),e(" insertSelfEdges",(function(){!function(t){var e=Uc.buildLayerMatrix(t);ph.forEach(e,(function(e){var i=0;ph.forEach(e,(function(e,s){var n=t.node(e);n.order=s+i,ph.forEach(n.selfEdges,(function(e){Uc.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:n.rank,order:s+ ++i,e:e.e,label:e.label},"_se")})),delete n.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){lc.adjust(t)})),e(" position",(function(){zc(t)})),e(" positionSelfEdges",(function(){!function(t){ph.forEach(t.nodes(),(function(e){var i=t.node(e);if("selfedge"===i.dummy){var s=t.node(i.e.v),n=s.x+s.width/2,r=s.y,a=i.x-n,o=s.height/2;t.setEdge(i.e,i.label),t.removeNode(e),i.label.points=[{x:n+2*a/3,y:r-o},{x:n+5*a/6,y:r-o},{x:n+a,y:r},{x:n+5*a/6,y:r+o},{x:n+2*a/3,y:r+o}],i.label.x=i.x,i.label.y=i.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){ph.forEach(t.nodes(),(function(e){if(t.children(e).length){var i=t.node(e),s=t.node(i.borderTop),n=t.node(i.borderBottom),r=t.node(ph.last(i.borderLeft)),a=t.node(ph.last(i.borderRight));i.width=Math.abs(a.x-r.x),i.height=Math.abs(n.y-s.y),i.x=r.x+i.width/2,i.y=s.y+i.height/2}})),ph.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){Ih.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){ph.forEach(t.edges(),(function(e){var i=t.edge(e);if(ph.has(i,"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}}))}(t)})),e(" undoCoordinateSystem",(function(){lc.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,i=0,s=Number.POSITIVE_INFINITY,n=0,r=t.graph(),a=r.marginx||0,o=r.marginy||0;function l(t){var r=t.x,a=t.y,o=t.width,l=t.height;e=Math.min(e,r-o/2),i=Math.max(i,r+o/2),s=Math.min(s,a-l/2),n=Math.max(n,a+l/2)}ph.forEach(t.nodes(),(function(e){l(t.node(e))})),ph.forEach(t.edges(),(function(e){var i=t.edge(e);ph.has(i,"x")&&l(i)})),e-=a,s-=o,ph.forEach(t.nodes(),(function(i){var n=t.node(i);n.x-=e,n.y-=s})),ph.forEach(t.edges(),(function(i){var n=t.edge(i);ph.forEach(n.points,(function(t){t.x-=e,t.y-=s})),ph.has(n,"x")&&(n.x-=e),ph.has(n,"y")&&(n.y-=s)})),r.width=i-e+a,r.height=n-s+o}(t)})),e(" assignNodeIntersects",(function(){!function(t){ph.forEach(t.edges(),(function(e){var i,s,n=t.edge(e),r=t.node(e.v),a=t.node(e.w);n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=a,s=r),n.points.unshift(Uc.intersectRect(r,i)),n.points.push(Uc.intersectRect(a,s))}))}(t)})),e(" reversePoints",(function(){!function(t){ph.forEach(t.edges(),(function(e){var i=t.edge(e);i.reversed&&i.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){Sh.undo(t)}))}(e,i)})),i(" updateInputGraph",(function(){!function(t,e){ph.forEach(t.nodes(),(function(i){var s=t.node(i),n=e.node(i);s&&(s.x=n.x,s.y=n.y,e.children(i).length&&(s.width=n.width,s.height=n.height))})),ph.forEach(t.edges(),(function(i){var s=t.edge(i),n=e.edge(i);s.points=n.points,ph.has(n,"x")&&(s.x=n.x,s.y=n.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var Jc=["nodesep","edgesep","ranksep","marginx","marginy"],Yc={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},$c=["acyclicer","ranker","rankdir","align"],Zc=["width","height"],Kc={width:0,height:0},Xc=["minlen","weight","width","height","labeloffset"],Qc={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},td=["labelpos"];function ed(t,e){return ph.mapValues(ph.pick(t,e),Number)}function id(t){var e={};return ph.forEach(t,(function(t,i){e[i.toLowerCase()]=t})),e}var sd=al.Graph;var nd={graphlib:al,layout:Hc,debug:{debugOrdering:function(t){var e=Eh.buildLayerMatrix(t),i=new sd({compound:!0,multigraph:!0}).setGraph({});return ph.forEach(t.nodes(),(function(e){i.setNode(e,{label:e}),i.setParent(e,"layer"+t.node(e).rank)})),ph.forEach(t.edges(),(function(t){i.setEdge(t.v,t.w,{},t.name)})),ph.forEach(e,(function(t,e){var s="layer"+e;i.setNode(s,{rank:"same"}),ph.reduce(t,(function(t,e){return i.setEdge(t,e,{style:"invis"}),e}))})),i}},util:{time:Eh.time,notime:Eh.notime},version:"0.8.5"},rd=nd.graphlib,ad=nd.layout;class od extends U{constructor(t){super(t),this.type=b.Sugiyama,this._width="width"in t?t.width:500,this._height="height"in t?t.height:300,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0}toJSON(){let t={args:{}};return t.type=this.type,t}run(){let t=this.group.children[0].dataScope._dt.graph;if(!t)return;var e=new rd.Graph;e.setGraph({edgesep:50}),e.setDefaultEdgeLabel((function(){return{}}));let i=new Map;for(let t of this.group.children){let s=t.dataScope.getFieldValue(h);i.set(s,s+""),e.setNode(s,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let i of t.links)e.setEdge(i.source,i.target);ad(e);const s={};let n=Math.min(...e.nodes().map((t=>e.node(t).y))),r=Math.min(...e.nodes().map((t=>e.node(t).x))),a=this._left-r,o=this._top-n;for(const t of e.nodes())s[t]={x:e.node(t).x+a,y:e.node(t).y+o};for(let t of this.group.children){let e=t.dataScope.getFieldValue(h);t.x=s[i.get(e)].x,t.y=s[i.get(e)].y}}}class ld extends U{constructor(t){super(t),this.type=b.Strata,this._direction=t.direction,this._rootMark=t.rootMark,this._gap="gap"in t?t.gap:0}toJSON(){}clone(){}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.group.firstChild.dataScope.dataTable.tree;if(!t)return;let e={};for(let t of this.group.children)e[t.dataScope.getFieldValue(h)]=t;this._rootMark.type===I.Rect?this._layoutRects(t.getRoot(),t,e):this._rootMark.type===I.Circle&&this._layoutArcs(t.getRoot(),t,e)}_layoutArcs(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n=i[t.id],r=n.type==I.Arc||n.type==I.Pie?n.startAngle:90;for(let t=0;t<s.length;t++){let n=s[t],a=i[n.id];if(a.type===I.Arc){let t=Ot(r+a.angle);a.adjustAngle(r,t),r=t}this._layoutArcs(n,e,i)}}_layoutRects(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n,r,a=i[t.id];switch(this._direction){case C.Down:default:n=a.left,r=a.bottom}for(let t=0;t<s.length;t++){let a=s[t],o=i[a.id];o._doTranslate(n-o.left,r-o.top),n+=o.width,this._layoutRects(a,e,i)}}}var hd={};function cd(t){return new Ce(t)}function dd(t,e){if(d.indexOf(t)<0)throw new Error(W.UNKOWNN_SCALE_TYPE+": "+t);return new Te(t,e)}function ud(t,e){let i=e||{};switch(t.toLowerCase()){case"grid":return new q(i);case"packing":return new Ie(i);case"treemap":return new Oe(i);case"stack":return new Nt(i);case"tidytree":return new Ne(i);case"force":return new Be(i);case"sugiyama":return new od(i);case"strata":return new ld(i)}}function fd(t){return new H(t||{})}function pd(t,e){return new Promise((function(i,s){let n=new XMLHttpRequest;n.open(t,e),n.onload=function(){this.status>=200&&this.status<300?i(n.response):s({status:this.status,statusText:n.statusText})},n.onerror=function(){s({status:this.status,statusText:n.statusText})},n.send()}))}async function gd(t){let e=await pd("GET",t),i=r.csvParse(e.trim(),r.autoType);return new Ut(i,t)}function _d(t){return!(!pt(t)&&t.type!=I.Glyph||t.dataScope)||t.type==I.Collection}function md(t){if([I.Line,I.Circle,I.Rect,I.Area,I.Ring,I.Pie].indexOf(t.type)<0)return!1;if(t.dataScope){let e=st(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function yd(t){if([I.Line,I.Circle,I.Rect,I.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=st(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}t.canDensify=yd,t.canDivide=md,t.canRepeat=_d,t.cartesianToPolar=function(t,e,i,s){return St(t,e,i,s)},t.createScale=dd,t.csv=gd,t.csvFromFile=async function(t){let e=r.csvParse(t.trim(),r.autoType);return new Ut(e,"")},t.csvFromString=function(t,e){let i=r.csvParse(t.trim(),r.autoType);return new Ut(i,e)},t.csvSync=function(t,e){let i=!!e;var s=new XMLHttpRequest;if(s.open("GET",t,i),s.send(),!i&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(s)){let e=r.csvParse(s.responseText.trim(),r.autoType);return new Ut(e,t)}},t.getPeersInScene=function(t){return"vertex"==t.type||"segment"==t.type?st(t,t.parent.getScene()):st(t,t.getScene())},t.graphjson=async function(t){let e=await pd("GET",t);return new Re(JSON.parse(e),t)},t.hitTest=function(t,e,i){if(!t.children||0==t.children.length)return t.contains(e,i)&&t.type!==I.Scene?t:null;for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];if(n.contains(e,i))return n}return null},t.hitTestAll=function(t,e,i){let s=ut(t);for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.inMarkHitTest=function(t,e,i,s){let n,r=dt(t),a=s||2,o=vt.getContext();for(let t of r){if(!(t instanceof X))continue;let s=new Path2D(t.getSVGPathData());if(o.lineWidth=Math.max(t.strokeWidth,2*a),o.stroke(s),o.isPointInStroke(s,e,i)){n=t;break}}if(!n)return null;let h=[];for(let t of n.vertices){let e=Math.max(a,t.width,2*t.radius),i=Math.max(a,t.height,2*t.radius);h.push({i:t,b:new l(t.x-e/2,t.y-i/2,e,i)})}for(let t of h)if(t.b.contains(e,i))return t.i;if(n.segments&&n.segments.length>0)for(let t of n.segments){let s=new Path2D;if(s.moveTo(t.vertex1.x,t.vertex1.y),s.lineTo(t.vertex2.x,t.vertex2.y),o.lineWidth=Math.max(n.strokeWidth,a),o.stroke(s),o.isPointInStroke(s,e,i))return t}return null},t.inMarkRectHitTest=function t(e,i,s){let n=s||2;if(pt(e)){let t=[];for(let i of e.vertices){let e=Math.max(n,i.width,2*i.radius),s=Math.max(n,i.height,2*i.radius);t.push({i:i,b:new l(i.x-e/2,i.y-s/2,e,s)})}if(e.type===I.Rect)for(let i of e.segments){let s=Math.max(e.strokeWidth,n);"v"===(i.vertex1.x===i.vertex2.x?"v":"h")?t.push({i:i,b:new l(i.vertex1.x-s/2,Math.min(i.vertex1.y,i.vertex2.y)-s/2,s,Math.abs(i.vertex1.y-i.vertex2.y))}):t.push({i:i,b:new l(Math.min(i.vertex1.x,i.vertex2.x)-s/2,i.vertex1.y-s/2,Math.abs(i.vertex1.x-i.vertex2.x),s)})}for(let e of t)if(e.b.overlap(i))return e.i;return null}if(!ft(e)&&e.children&&e.children.length>0){for(let s of e.children)if(s.bounds.overlap(i)){let e=t(s,i,n);if(e)return e}return null}return null},t.layout=ud,t.linearGradient=fd,t.polarToCartesian=function(t,e,i,s){return kt(t,e,i,s)},t.rectHitTest=function(t,e){let i=[];if(!t.children||0==t.children.length)return t.bounds.overlap(e)&&t.type!==I.Scene?[t]:[];for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];n.bounds.overlap(e)&&i.push(n)}return i},t.renderer=function(t,e){switch(t){case"svg":return new Ae(e);case"webgl":return e in hd||(hd[e]=new ii(e)),hd[e]}},t.scene=cd,t.sceneLoader=function(){return new Fe},t.specExecutor=function(){return new Le},t.specGenerator=function(){return new Pe},t.treejson=async function(t){let e=await pd("GET",t);return new be(JSON.parse(e),t)},Object.defineProperty(t,"__esModule",{value:!0})}));
|