@lightningchart/lcjs
Version:
A high-performance charting library.
2 lines • 1.33 MB
JavaScript
/* LightningChart JS v7.0.3 */
import*as t from"immutable";import{Record as i}from"immutable";import s from"earcut";class e{constructor(){this.o=!0}u(){return this.o}}class h extends e{constructor(t,i){super(),this.S=t,this.M=t,this.o=i}_(t){return t!==this.S&&(this.M=this.S,this.S=t,this.o=!0),this}C(){return this.S}u(){return super.u()}}const r=(t,i)=>({x:t,y:i}),n=(t,i)=>({x:t,y:i}),o=(t,i,s)=>({position:t,high:i,low:s}),a=(t,i,s)=>({x:t,y:i,z:s}),l=t=>{const i=Array(0),s=Array(0);return t.length>0&&t.forEach((t=>{i.push(r(t.position,t.high)),s.push(r(t.position,t.low))})),[i,s]},u=(t,i)=>({min:t,max:i}),c=(t,i,s,e)=>({x:t,y:i,width:s,height:e}),d=(t,i=!0)=>new h(t,i),f=(t=0,i=0,s=0,e=0)=>({left:t,top:i,right:s,bottom:e}),A=f,g=(t,i)=>({left:void 0!==i.left?i.left:t.left,top:void 0!==i.top?i.top:t.top,right:void 0!==i.right?i.right:t.right,bottom:void 0!==i.bottom?i.bottom:t.bottom}),v=i({type:"color",r:1,g:1,b:1,a:1});class y extends v{constructor(t){super(t)}toUint32(){return void 0!==this.T||(this.T=F(this.getR(),this.getG(),this.getB(),this.getA())),this.T}toString(){return`color:${this.r},${this.g},${this.b},${this.a}`}setA(t){return this.set("a",t/255)}setR(t){return this.set("r",t/255)}setG(t){return this.set("g",t/255)}setB(t){return this.set("b",t/255)}getA(){return 255*this.get("a")}getR(){return 255*this.get("r")}getG(){return 255*this.get("g")}getB(){return 255*this.get("b")}getHighlight(){return this.F||(this.F=new y({r:this.r+.45*(1-this.r),g:this.g+.45*(1-this.g),b:this.b+.45*(1-this.b),a:this.a<1?this.a+.45*(1-this.a):1})),this.F}getLighter(){return this.I||(this.I=new y({r:this.r+.4*(1-this.r),g:this.g+.4*(1-this.g),b:this.b+.4*(1-this.b),a:this.a})),this.I}getDarker(){return this.P||(this.P=new y({r:this.r-.4*(1-this.r),g:this.g-.4*(1-this.g),b:this.b-.4*(1-this.b),a:this.a})),this.P}toRGBAString(){return`rgba( ${255*this.r}, ${255*this.g}, ${255*this.b}, ${255*this.a} )`}}const p=t=>!(!t||"object"!=typeof t||!("type"in t)||"color"!==t.type),m=(t,i,s,e=255)=>new y({r:t/255,g:i/255,b:s/255,a:e/255}),S=t=>{const i=t.startsWith("#")?t.substring(1):t.startsWith("0x")?t.substr(2):t;switch(i.length){case 8:return new y({r:Number(`0x${i.substring(0,2)}`)/255,g:Number(`0x${i.substring(2,4)}`)/255,b:Number(`0x${i.substring(4,6)}`)/255,a:Number(`0x${i.substring(6,8)}`)/255});case 6:return new y({r:Number(`0x${i.substring(0,2)}`)/255,g:Number(`0x${i.substring(2,4)}`)/255,b:Number(`0x${i.substring(4,6)}`)/255});case 4:return new y({r:Number(`0x${i.charAt(0)}${i.charAt(0)}`)/255,g:Number(`0x${i.charAt(1)}${i.charAt(1)}`)/255,b:Number(`0x${i.charAt(2)}${i.charAt(2)}`)/255,a:Number(`0x${i.charAt(3)}${i.charAt(3)}`)/255});case 3:return new y({r:Number(`0x${i.charAt(0)}${i.charAt(0)}`)/255,g:Number(`0x${i.charAt(1)}${i.charAt(1)}`)/255,b:Number(`0x${i.charAt(2)}${i.charAt(2)}`)/255});default:throw new Error(`ColorHEX parsing error | input: ${t}`)}},b=(t,i=1,s=1)=>{let e,h,r;t/=360;const n=Math.floor(6*t),o=6*t-n,a=s*(1-i),l=s*(1-o*i),u=s*(1-(1-o)*i);switch(n%6){case 0:e=s,h=u,r=a;break;case 1:e=l,h=s,r=a;break;case 2:e=a,h=s,r=u;break;case 3:e=a,h=l,r=s;break;case 4:e=u,h=a,r=s;break;default:e=s,h=a,r=l}return new y({r:e,g:h,b:r})},x=t=>{try{if(t.startsWith("rgba")){const i=t.substr(5).slice(0,-1),s=JSON.parse(`[${i}]`);return m(s[0],s[1],s[2],255*s[3])}if(t.startsWith("rgb")){const i=t.substr(4).slice(0,-1),s=JSON.parse(`[${i}]`);return m(s[0],s[1],s[2])}if(t.startsWith("hsl")){const i=t.substr(4).slice(0,-1).split(",").map(parseFloat),s=w(i[0],i[1],i[2]);return m(s[0],s[1],s[2])}return t.startsWith("#")||t.startsWith("0x")?S(t):S(C(t))}catch(t){}return console.warn(`ColorCSS parsing error: ${t}`),S("#fff")},M=t=>m(255&t,255&(t>>=8),255&(t>>=8),255&(t>>=8)),w=(t,i,s)=>{i/=100,s/=100;const e=(1-Math.abs(2*s-1))*i,h=t/60,r=e*(1-Math.abs(h%2-1));let n=[];isNaN(t)?n=[0,0,0]:h<=1?n=[e,r,0]:h<=2?n=[r,e,0]:h<=3?n=[0,e,r]:h<=4?n=[0,r,e]:h<=5?n=[r,0,e]:h<=6&&(n=[e,0,r]);const o=s-.5*e;return[Math.round(255*(n[0]+o)),Math.round(255*(n[1]+o)),Math.round(255*(n[2]+o))]},_={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},C=t=>{const i=_[t.toLowerCase()];if(i)return i;throw new Error(`Unknown color code: ${t}`)},k=new y({}),T=m(0,0,0,0),F=(t,i,s,e=255)=>(e<<24|s<<16|i<<8|t)>>>0,I=t=>F(255*t.r,255*t.g,255*t.b,255*t.a),P=(t,i)=>t.value-i.value,L=i({type:"lut",steps:[],title:"",units:"",interpolate:!0,color:m(0,0,0,255),length:0,min:0,max:0,subranges:[],isValid:!1,percentageValues:!1}),B=t=>{const{steps:i}=t,s=i.length;i.sort(P);const[e,h]=s>0?[i[0].value,i[s-1].value]:[0,0],r=s>0?s-1:0,n=Array(r);for(let t=0;t<r;t+=1)n[t]={min:i[t],max:i[t+1]};return{min:e,max:h,length:s,steps:i,subranges:n,isValid:s>0&&e!==h}};class D extends L{constructor(t){super(((t,i)=>({steps:t.steps,title:t.title,units:t.units,interpolate:t.interpolate,percentageValues:t.percentageValues,color:t.color,length:i.length,min:i.min,max:i.max,subranges:i.subranges,isValid:i.isValid}))(t,B(t)))}toString(){return`LUT:interpolate=${this.interpolate},steps=${this.steps.length},percentage=${this.percentageValues}`}setSteps(t){return this.merge(B({...this,steps:t}))}getSteps(){return this.get("steps")}setTitle(t){return this.set("title",t)}getTitle(){return this.get("title")}setUnits(t){return this.set("units",t)}getUnits(){return this.get("units")}setInterpolation(t){return this.set("interpolate",t)}getInterpolation(){return this.get("interpolate")}setFallbackColor(t){return this.set("color",t)}getFallbackColor(){return this.get("color")}setPercentageValues(t){return this.set("percentageValues",t)}getPercentageValues(){return this.get("percentageValues")}getColors(t,i){if(Array.isArray(t)){if(Array.isArray(t[0])){const s=t,e=s.length,h=s[0].length,r=[...Array(e)].map((()=>Array(h)));for(let t=0;t<e;t+=1)for(let e=0;e<h;e+=1)r[t][e]=this.L(s[t][e],i);return r}const s=t,e=s.length,h=Array(e);for(let t=0;t<e;t+=1)h[t]=this.L(s[t],i);return h}return this.L(t,i)}L(t,i){const{steps:s}=this,e=s.length;if(0===e)return this.getFallbackColor();if(1===e)return s[0].color||this.color;if(this.percentageValues,this.percentageValues&&i&&(t=Math.max(Math.min((t-i.min)/(i.max-i.min),1),0)),this.interpolate){for(let i=0;i<e-1;i+=1){const e=s[i],o=s[i+1],a=Math.min(e.value,o.value),l=Math.max(e.value,o.value);if(t>=a&&t<=l){if(a===l)return e.color;const i=(t-e.value)/(o.value-e.value);return h=e.color,r=o.color,n=i,new y({r:h.r+(r.r-h.r)*n,g:h.g+(r.g-h.g)*n,b:h.b+(r.b-h.b)*n,a:h.a+(r.a-h.a)*n})}}return t<s[0].value?s[0].color:s[e-1].color}var h,r,n;for(let i=e-1;i>=0;i-=1)if(t>=s[i].value)return s[i].color;return s[0].color}}const E=t=>!(!t||"object"!=typeof t||!("type"in t)||"lut"!==t.type),R=i({type:"fillstyle",fillType:"empty"});class z extends R{toString(){return"emptyFill"}}const V=new z,O=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"empty"===t.fillType),N=i({type:"fillstyle",fillType:"solid",color:m(255,255,255)});class G extends N{}class $ extends G{constructor(t){super({...t,fillType:"solid"})}toString(){return`solidFill:${this.color.toString()}`}setColor(t){return p(t)?this.set("color",t):this.set("color",t(this.get("color")))}getColor(){return this.get("color")}setA(t){return this.setColor(this.getColor().setA(t))}setR(t){return this.setColor(this.getColor().setR(t))}setG(t){return this.setColor(this.getColor().setG(t))}setB(t){return this.setColor(this.getColor().setB(t))}}const U=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"solid"===t.fillType);class Y extends G{constructor(t){super({...t,fillType:"individual"})}toString(){return`individualPointFill:${this.color.toString()}`}setFallbackColor(t){return p(t)?this.set("color",t):this.set("color",t(this.get("color")))}getFallbackColor(){return this.get("color")}}const H=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"individual"===t.fillType),X=i({type:"fillstyle",fillType:"palette",lut:new D({steps:[]}),lookUpProperty:"value"});class W extends X{constructor(t){super({...t,fillType:"palette"})}toString(){return`palettedFill:lut=${this.lut.toString()},lookUpProperty=${this.lookUpProperty}`}getPalette(){return this.get("lut")}setLookUpProperty(t){return"function"==typeof t?this.set("lookUpProperty",t(this.get("lookUpProperty"))):this.set("lookUpProperty",t)}getLookUpProperty(){return this.get("lookUpProperty")}}const j=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"palette"===t.fillType);var Z,Q;!function(t){t.circle="circle",t.ellipse="ellipse"}(Z||(Z={})),function(t){t.closestSide="closest-side",t.closestCorner="closest-corner",t.farthestSide="farthest-side",t.farthestCorner="farthest-corner"}(Q||(Q={}));const J=i({type:"fillstyle",fillType:"radial-gradient",stops:[{color:S("#f00"),offset:0},{color:S("#0f0"),offset:1}],position:r(.5,.5),shape:Z.ellipse,extent:Q.farthestCorner});class K extends J{constructor(t){if(super(t),null===t||t&&null===t.stops||t&&t.stops&&!Array.isArray(t.stops)||t&&t.stops&&Array.isArray(t.stops)&&t.stops.length<2)throw new Error("RadialGradientFill requires minimum two color stops to be defined.")}toString(){return`radialGradientFill:${this.shape},${this.extent},${this.position.x},${this.position.y},${this.stops.map((t=>`${t.offset},${t.color.toString()}`)).join(",")}`}setColorStops(t){if(t.length<2)throw new Error("Minimum of two color stops required");return this.set("stops",t)}getColorStops(){return this.get("stops")}setPosition(t){return this.set("position",t)}getPosition(){return this.get("position")}setShape(t){return this.set("shape",t)}getShape(){return this.get("shape")}setExtent(t){return this.set("extent",t)}getExtent(){return this.get("extent")}}const q=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"radial-gradient"===t.fillType),tt=i({type:"fillstyle",fillType:"linear-gradient",stops:[{color:S("#f00"),offset:0},{color:S("#0f0"),offset:1}],angle:0});class it extends tt{constructor(t){if(super(t),null===t||t&&null===t.stops||t&&t.stops&&!Array.isArray(t.stops)||t&&t.stops&&Array.isArray(t.stops)&&t.stops.length<2)throw new Error("LinearGradientFill requires minimum two color stops to be defined.")}toString(){return`linearGradientFill:${this.angle},${this.stops.map((t=>`${t.offset},${t.color.toString()}`)).join(",")}`}setColorStops(t){if(t.length<2)throw new Error("Minimum of two color stops required");const i=t.sort(((t,i)=>t.offset-i.offset));return this.set("stops",i)}getColorStops(){return this.get("stops")}setAngle(t,i){return this.set("angle",i?function(t){return 180*t/Math.PI}(t):t)}getAngle(t){return t?se(this.get("angle")):this.get("angle")}}const st=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"linear-gradient"===t.fillType);class et{constructor(t,i,s,e){this.D=new zt,this.cellIndex=t,this.cellSpan=i,this.cellsAmount=s,this.observedAmount=e,this.x=new ht,this.y=new ht,this.z=new ht;const h={...t},r={...i};if(e){const t=t=>{const i=t.value;this.cellsAmount.x=i.reduce(Is,0),this.cellIndex.x=i.reduce(((t,i,s)=>s>=h.x?t:t+i),0),this.cellSpan.x=i.reduce(((t,i,s)=>s>=h.x&&s<h.x+r.x?t+i:t),0),this.D.R("cellresize",{})};e.x.V("change",t),t({value:e.x.C()});const i=t=>{const i=t.value;this.cellsAmount.y=i.reduce(Is,0),this.cellIndex.y=i.reduce(((t,i,s)=>s>=h.y?t:t+i),0),this.cellSpan.y=i.reduce(((t,i,s)=>s>=h.y&&s<h.y+r.y?t+i:t),0),this.D.R("cellresize",{})};e.y.V("change",i),i({value:e.y.C()}),this.O=()=>{e.x.N("change",t),e.y.N("change",i)}}}G(){return this.O&&(this.O(),this.O=void 0),this}addEventListener(t,i,s){this.D.addEventListener(t,i,s)}removeEventListener(t,i){this.D.removeEventListener(t,i)}}class ht extends e{constructor(){super(...arguments),this.$=0,this.U=10,this.Y=1}H(){return this.o=!1,this}X(){return this.o=!0,this}getInnerStart(){return this.$}getInnerEnd(){return this.U}getInnerInterval(){return Math.abs(this.getInnerEnd()-this.getInnerStart())}W(t,i){return this.$=t,this.U=i,this.j(),this}Z(t){return this.Y=t,this.j(),this}J(t){return t/this.Y}j(){const t=this.J(this.U-this.$),i=this.Y;void 0!==this.K&&!1!==di(t,this.K)||(this.o=!0,this.q=i,this.K=t)}tt(){return this.K}it(){return this.q}st(){return this.U<this.$}et(t,i){return!0}}const rt={d1:t=>new t.scale1DConstructor(0,1,1,void 0),d2:t=>(new t.scaleXYConstructor).ht({x:0,y:0},{x:1,y:1},{x:1,y:1},void 0),d3:()=>new et({x:0,y:0},{x:1,y:1},{x:1,y:1},void 0)},nt=(t,i,s)=>i===s?t:s.rt(i.nt(t)),ot=(t,i,s)=>{if(i===s)return t;const e=i instanceof Se?i.x:i.x instanceof Se?i.x.x:i.x.ot,h=i instanceof Se?i.y:i.y instanceof Se?i.y.y:i.y.ot,r=s instanceof Se?s.x:s.x instanceof Se?s.x.x:s.x.ot,n=s instanceof Se?s.y:s.y instanceof Se?s.y.y:s.y.ot;return{...t,x:nt(t.x,e,r),y:nt(t.y,h,n)}},at=(t,i,s)=>{const e=t(i,s);return t=>new $({color:e(t)})},lt=(t,i,s)=>{const e=t(i+1,s);return t=>new K({stops:[{offset:0,color:e(t)},{offset:1,color:e(t).getDarker()}]})},ut=(t,i,s,e)=>{const h=t(i+1,e);return t=>new it({stops:[{offset:0,color:h(t).getDarker()},{offset:.5,color:h(t)},{offset:1,color:h(t).getDarker()}],angle:s||90})},ct=(...t)=>{if(0===t.length)return{remove:ci};let i=!1;const s=t.map((s=>{const e=e=>{((s,e,h)=>{i||(i=!0,t.filter((t=>t!==s)).forEach((t=>t.ut(e,h,!1,s.getStopped(),"synchronizedAxis"))),i=!1)})(s,e.start,e.end)};return s.addEventListener("intervalchange",e),e}));let e=!1;const h=t.map((i=>{const s=s=>{((i,s)=>{e||(e=!0,t.filter((t=>t!==i)).forEach((t=>t.setStopped(s))),e=!1)})(i,s.isStopped)};return i.addEventListener("stoppedchange",s),s}));return{remove:()=>{t.forEach(((t,i)=>{t.removeEventListener("intervalchange",s[i]),t.removeEventListener("stoppedchange",h[i])}))}}},dt=(t,i,s,e)=>{if(!s||0===s.length)throw new Error("Invalid use regularColorSteps 'colorPalette' is undefined or empty");const h=null==e?void 0:e.formatLabels,r=null==e?void 0:e.alpha;return s.map(((e,n)=>{const o=t+n/(s.length-1)*(i-t);return{color:void 0!==r?e.setA(r):e,value:o,label:h?h(o):void 0}}))},ft=t=>t&&"object"==typeof t&&"column"in t&&"row"in t,At=t=>t&&"object"==typeof t&&"z"in t&&"column"in t&&"row"in t,gt=t=>t&&"object"==typeof t&&"position"in t&&"open"in t&&"high"in t&&"isPacked"in t,vt=t=>t&&"object"==typeof t&&"annulus"in t&&"sector"in t,yt=t=>t&&"object"==typeof t&&"index"in t,pt=t=>t&&"object"==typeof t&&"xSize"in t&&"ySize"in t&&"zSize"in t,mt=t=>t&&"object"==typeof t&&"figure"in t&&"x1"in t&&"y2"in t&&"height"in t,St=t=>t&&"object"==typeof t&&"figure"in t&&"start"in t&&"end"in t&&"median"in t&&"upperQuartile"in t,bt=t=>t&&"object"==typeof t&&"figure"in t&&"x"in t&&"radiusX"in t&&"radiusY"in t,xt=t=>t&&"object"==typeof t&&"figure"in t&&"x"in t&&"coordinates"in t,Mt=t=>t&&"object"==typeof t&&"figure"in t&&"startX"in t&&"endX"in t,wt=t=>t&&"object"==typeof t&&"x"in t&&"y"in t,_t=t=>!0===t.isLcjsArtificialEvent;var Ct;!function(t){t[t.Nearest=0]="Nearest",t[t.NearestX=1]="NearestX",t[t.NearestY=2]="NearestY"}(Ct||(Ct={}));const kt=(t,i,s,e,h,r,n,o,a,l)=>{const u=t.length;if(0===u)return;const c=e?1:0,d=u-(h?2:1);if(s===Ct.Nearest)return Tt(t,i,r,n,c,d);if(s===Ct.NearestX||s===Ct.NearestY){if("boolean"==typeof l&&("x"===a&&s===Ct.NearestX||"y"===a&&s===Ct.NearestY))return Pt(t,ot(i,n,r),a,l,c,d);if(s===Ct.NearestX)return Ft(t,ot(i,n,r),o,c,d);if(s===Ct.NearestY)return It(t,ot(i,n,r),o,c,d)}},Tt=(t,i,s,e,h,r)=>{let n,o=Number.MAX_VALUE;for(let a=h;a<=r;a+=1){const h=t[a];if(!Number.isNaN(h.x)&&!Number.isNaN(h.y)){const t=ot(h,s,e),r=(t.x-i.x)**2+(t.y-i.y)**2;r<o&&(o=r,n=a)}}return n},Ft=(t,i,s,e,h)=>{if(i.x<s.min.x||i.x>s.max.x)return;let r,n=Number.MAX_VALUE;for(let s=e;s<=h;s+=1){const e=t[s],h=e.x>i.x?e.x-i.x:i.x-e.x;h<n&&!Number.isNaN(e.x)&&!Number.isNaN(e.y)&&(n=h,r=s)}return r},It=(t,i,s,e,h)=>{if(i.y<s.min.y||i.y>s.max.y)return;let r,n=Number.MAX_VALUE;for(let s=e;s<=h;s+=1){const e=t[s],h=e.y>i.y?e.y-i.y:i.y-e.y;h<n&&!Number.isNaN(e.x)&&!Number.isNaN(e.y)&&(n=h,r=s)}return r},Pt=(t,i,s,e,h,r)=>{const n="x"===s,o=n?i.x:i.y,a=t[h],l=t[r],u=a.x<l.x?a.x:l.x,c=a.y<l.y?a.y:l.y,d=a.x>l.x?a.x:l.x,f=a.y>l.y?a.y:l.y;if(n&&(o<u||o>d)||!n&&(o<c||o>f))return;let A=h,g=Math.floor((h+r)/2),v=r,y=-1;for(;;){const i=o-(n?t[g].x:t[g].y);if(i*(e?-1:1)>0)A=Math.min(g+1,v),y=Math.floor((A+v)/2);else{if(0===Math.abs(i))return g;v=Math.max(g-1,A),y=Math.floor((A+v)/2)}if(y===g){const s=g>h?Math.abs(o-(n?t[g-1].x:t[g-1].y)):bs,e=g<r?Math.abs(o-(n?t[g+1].x:t[g+1].y)):bs,a=Math.abs(i);switch(Math.min(a,s,e)){case s:return g-1;case e:return g+1;default:return g}}else g=y}},Lt=(t,i,s,e,h,r)=>{const n="x"===s,o=n?i.x:i.y,a=t[h],l=t[r],u=a.x<l.x?a.x:l.x,c=a.y<l.y?a.y:l.y,d=a.x>l.x?a.x:l.x,f=a.y>l.y?a.y:l.y;if(n&&(o<u||o>d)||!n&&(o<c||o>f))return;let A=h,g=Math.floor((h+r)/2),v=r,y=-1;for(;;){const s=o-(n?t[g].x:t[g].y);if(s*(e?-1:1)>0)A=Math.min(g+1,v),y=Math.floor((A+v)/2);else{if(0===Math.abs(s))return{a:g,b:g,lerpAmount:0};v=Math.max(g-1,A),y=Math.floor((A+v)/2)}if(y===g){if(s*(e?-1:1)<0&&g>h){const s=t[g-1],e=t[g];return{a:g-1,b:g,lerpAmount:n?(i.x-s.x)/(e.x-s.x):(i.y-s.y)/(e.y-s.y)}}if(g<r){const s=t[g],e=t[g+1];return{a:g,b:g+1,lerpAmount:n?(i.x-s.x)/(e.x-s.x):(i.y-s.y)/(e.y-s.y)}}return{a:g,b:g,lerpAmount:0}}g=y}};let Bt=0;class Dt{constructor(t,i,s){this.ct=d(!0),this.dt=!1,this.ft=!0,this.At=!1,this.vt=void 0,this.yt=0,this.D=new zt,this.St=t,this.bt=i,this.xt=s,this.Mt=Bt,Bt+=1,this.wt=t._t.highlightColorOffset}Ct(){let t;return this.kt("DataPattern",(i=>(t=i.pattern,!0))),"ProgressiveX"===t||"RegressiveX"===t?Ct.NearestX:"ProgressiveY"===t||"RegressiveY"===t?Ct.NearestY:Ct.Nearest}Tt(){}addEventListener(t,i,s){this.D.addEventListener(t,i,s)}R(t,i,s,e){this.D.R(t,i,{collectionMember:s,info:e})}removeEventListener(t,i){this.D.removeEventListener(t,i)}Ft(t){return void 0!==this.xt.find((i=>i.type===t))}kt(t,i){var s;return!!this.Ft(t)&&!0===i(null===(s=this.xt.find((i=>i.type===t)))||void 0===s?void 0:s.args)}dispose(){return this.dt||(this.St.It(this),this.dt=!0,this.bt(this),this.D.R("dispose",{})),this}isDisposed(){return this.dt}setVisible(t){const i=this.ft;return this.ft=t,!t&&i&&this.ct.C()&&this.St.It(this),this}getVisible(){return this.ft}setPointerEvents(t){const i=this.ct.C();return this.ct._(t),t||i&&this.St.It(this),this}getPointerEvents(){return this.ct.C()}Pt(t){return this.vt=t,this}Lt(){return this.vt?this.vt:Et}Bt(t){return this.yt=t,this}Dt(){return this.yt}Et(t){return this.wt=t,this}Rt(){return this.wt}}const Et=u(r(0,0),r(0,0)),Rt={click:!0,contextmenu:!0,dblclick:!0,gotpointercapture:!0,lostpointercapture:!0,pointercancel:!0,pointerdown:!0,pointerenter:!0,pointerleave:!0,pointermove:!0,pointerout:!0,pointerover:!0,pointerup:!0,touchcancel:!0,touchend:!0,touchmove:!0,touchstart:!0,wheel:!0,drag:!0,dragend:!0,dragenter:!0,dragleave:!0,dragover:!0,dragstart:!0,drop:!0};class zt{constructor(){this.zt=new Array,this.Vt=[],this.ct=!0,this.Ot=!1}setPointerEvents(t){this.ct=t,this.Vt.forEach((i=>i.setPointerEvents(t)))}getPointerEvents(){return this.ct}addEventListener(t,i,s){this.zt.push({listener:i,key:t,options:s||{}})}removeEventListener(t,i){const s=this.zt.findIndex((t=>t.listener===i));s>=0&&this.zt.splice(s,1)}set draggable(t){this.Ot=t,this.Vt.forEach((i=>{i.At=t}))}get draggable(){return this.Ot}R(t,i,s=void 0){this.zt.slice().reverse().forEach((e=>{e.key===t&&(e.listener(i,s),!0===e.options.once&&this.removeEventListener(t,e.listener))}))}Nt(t,i){Object.keys(Rt).forEach((s=>{t.addEventListener(s,((t,e)=>{const h=Vt(t)?{clientX:t.changedTouches[0].clientX,clientY:t.changedTouches[0].clientY}:t,r=(null==i?void 0:i.getExtraData)&&void 0!==h.clientX?i.getExtraData(h,e.collectionMember,e.info):{};this.R(s,t,r),!t.defaultPrevented&&(null==i?void 0:i.continueIfNotPrevented)&&i.continueIfNotPrevented(s,t,r)}))})),this.Vt.push(t),t.addEventListener("dispose",(()=>{const i=this.Vt.indexOf(t);i>=0&&this.Vt.splice(i,1)})),t.At=this.Ot,t.setPointerEvents(this.ct)}Gt(t,i){Object.keys(Rt).forEach((s=>{t.addEventListener(s,((t,e)=>{const h=i(e.collectionMember);h&&this.R(s,t,h)}))})),this.Vt.push(t),t.addEventListener("dispose",(()=>{const i=this.Vt.indexOf(t);i>=0&&this.Vt.splice(i,1)})),t.setPointerEvents(this.ct),t.At=this.Ot}$t(t){Object.keys(Rt).forEach((i=>{t.addEventListener(i,((t,s)=>{this.R(i,t,s)}))})),t.setPointerEvents(this.ct),t.draggable=this.Ot}}const Vt=t=>!(!t||"object"!=typeof t||!("touches"in t)),Ot={linear:(t,i,s)=>{const e=i-t;return h=>h<s?t+e/s*h:i},easeIn:(t,i,s)=>e=>e<s?t+Math.abs(2*(Math.sqrt(.5)*e/s)**2)*(i-t):i,easeOut:(t,i,s)=>e=>e<s?t+Math.abs(1-2*(Math.sqrt(.5)*(1-e/s))**2)*(i-t):i,ease:(t,i,s)=>e=>e<s?t+(e<s/2?.5*(e/s*2)**2.5:.5+.5*(1-(1-2*(e/s-.5))**2.5))*(i-t):i,logarithmic:t=>{const i=Oi(t);return(s,e,h)=>{const r=i(s),n=i(e);return i=>i<h?t**(r+Math.abs(1-2*(Math.sqrt(.5)*(1-i/h))**2)*(n-r)):e}}};class Nt{constructor(t,i,s,e=Ot.linear,h){this.delta=0,this.nextAnimations=new Array,this.Ut=!1,this.easing=Ot.linear,this.isOver=()=>(this.delta===this.duration||this.Ut)&&0===this.nextAnimations.length,this.D=new zt,this.values=t,this.action=i,this.duration=s,this.easing=e,this.Yt=h,this.eases=t.map((([t,i])=>e(t,i,s)))}Ht(){this.D.R("start",{})}start(){return this.Yt.includes(this)||this.Yt.push(this),this}addNextAnimations(t){return t instanceof Array?t.forEach((t=>this.nextAnimations.push(t))):this.nextAnimations.push(t),this}NextAnimation(t,i,s=this.duration,e=this.easing){const h=new Nt(t,i,s,e,this.Yt);return this.nextAnimations.push(h),h}finish(t=!0){if(this.Ut=!0,this.Yt.splice(this.Yt.indexOf(this),1),this.nextAnimations.length>0){const i=this.nextAnimations[0];return t&&this.D.zt.forEach((t=>{"allAnimationEnd"===t.key&&i.addEventListener("allAnimationEnd",t.listener),"everyAnimationEnd"===t.key&&i.addEventListener("everyAnimationEnd",t.listener)})),i.addNextAnimations(this.nextAnimations.slice(1)),i.start(),t&&(this.D.R("end",{nextAnimation:i}),this.D.R("everyAnimationEnd",{nextAnimation:i})),i}t&&(this.D.R("end",{nextAnimation:void 0}),this.D.R("everyAnimationEnd",{nextAnimation:void 0}),this.D.R("allAnimationEnd",{}))}finishAll(t=!0){let i=this;for(;i;)i=i.finish(t)}getFinalValues(){return this.nextAnimations.length>0?this.nextAnimations[this.nextAnimations.length-1].values.map(li):this.values.map(li)}getTimeUntilFinish(){let t=this.duration-this.delta;for(let i=0;i<this.nextAnimations.length;i+=1)t+=this.nextAnimations[i].duration-this.nextAnimations[i].delta;return t}addEventListener(t,i,s){this.D.addEventListener(t,i,s)}removeEventListener(t,i){this.D.removeEventListener(t,i)}}const Gt=(t,i=60)=>{i>60&&console.log("Note: Animator FPS is usually capped at 60 by the browser!");const s=[];let e,h,r=0;const n=()=>{e=void 0;const o=Date.now();h=h||o,r=o-h,r/1e3>=1/i&&(h=Date.now()-r%(1e3/i),s.forEach((t=>{0===t.delta&&t.Ht(),t.delta+=r-r%(1e3/i),t.delta>t.duration&&(t.delta=t.duration),t.action(t.eases.map((i=>i(t.delta)))),t.delta===t.duration&&t.finish()})),t()),s.length>0?e=ni.requestAnimationFrame(n):(e=void 0,h=void 0)};return(t=1e3,i=Ot.linear)=>(h,r,o=t)=>{const a=new Nt(h,r,o,i,s).start();return e||(e=ni.requestAnimationFrame(n)),a}};var $t;!function(t){t[t.Fill=0]="Fill",t[t.Fit=1]="Fit",t[t.Stretch=2]="Stretch",t[t.Center=3]="Center",t[t.Tile=4]="Tile"}($t||($t={}));const Ut=i({type:"fillstyle",fillType:"image",source:void 0,surroundingColor:m(0,0,0,0),sourceMissingColor:m(0,0,0,0),fitMode:$t.Fill});class Yt extends Ut{constructor(t){super(t)}setSource(t){return this.set("source",t)}getSource(){return this.get("source")}setSurroundingColor(t){return p(t)?this.set("surroundingColor",t):this.set("surroundingColor",t(this.get("surroundingColor")))}getSurroundingColor(){return this.get("surroundingColor")}setSourceMissingColor(t){return p(t)?this.set("sourceMissingColor",t):this.set("sourceMissingColor",t(this.get("sourceMissingColor")))}getSourceMissingColor(){return this.get("sourceMissingColor")}setFitMode(t){return this.set("fitMode",t)}getFitMode(){return this.get("fitMode")}toString(){return`imagefill:${this.fitMode}`}}const Ht=t=>!!(t&&"object"==typeof t&&"type"in t&&"fillstyle"===t.type&&"fillType"in t&&"image"===t.fillType),Xt=i({type:"linestyle",lineType:"empty"}),Wt=new class extends Xt{constructor(){super(...arguments),this.thickness=0}setThickness(t){return this}getThickness(){return 0}Xt(){return 0}setFillStyle(t){return this}getFillStyle(){return V}},jt=t=>!(!t||"object"!=typeof t||!("lineType"in t)||"empty"!==t.lineType),Zt=-34028234663852886e22,Qt="-340282346638528859811704183484516925440.0";class Jt extends Error{constructor(t,i){super(`ChartError: ${t} ${i?`in ${i.constructor.name}`:""}`),Object.setPrototypeOf(this,Jt.prototype)}}class Kt extends Error{constructor(t,i,s=!1){const e=`EngineError: ${t} ${i?`in ${i.constructor.name}`:""}`;super(e),s&&ni.alert(e),Object.setPrototypeOf(this,Kt.prototype)}}class qt extends Kt{constructor(t){super(t),Object.setPrototypeOf(this,qt.prototype)}}var ti,ii,si,ei;!function(t){t[t.Content=0]="Content",t[t.PaddedContent=1]="PaddedContent",t[t.PaddedBackground=2]="PaddedBackground",t[t.Everything=3]="Everything"}(ti||(ti={})),function(t){t[t.never=0]="never",t[t.always=1]="always",t[t.whenHovered=2]="whenHovered",t[t.whenDragged=3]="whenDragged",t[t.whenNotDragged=4]="whenNotDragged",t[t.whenHoveredOrDragged=5]="whenHoveredOrDragged"}(ii||(ii={})),function(t){t[t.notDraggable=0]="notDraggable",t[t.draggable=1]="draggable",t[t.onlyHorizontal=2]="onlyHorizontal",t[t.onlyVertical=3]="onlyVertical"}(si||(si={})),function(t){t[t.Up=0]="Up",t[t.Right=1]="Right",t[t.Down=2]="Down",t[t.Left=3]="Left"}(ei||(ei={}));const hi=(...t)=>{const i=t=>t&&"object"==typeof t&&!Array.isArray(t);return t.reduce(((t,s)=>s?(Object.keys(s).forEach((e=>{const h=t[e],r=s[e];i(h)&&i(r)?t[e]=hi(h,r):t[e]=r})),t):t),{})},ri=t=>{if(t.resourcesBaseUrl){const i=t.styleFactory(t.resourcesBaseUrl),s=Ht(i)&&i.getSource(),e=s&&s instanceof Image?s:void 0;return null==e||e.addEventListener("error",(()=>{as(t.resourcesBaseUrl,e.src,"Theme resource",{shouldCrash:!1})})),i}const i=`${ni.location.origin}/resources`,s=t.styleFactory(i);if(Ht(s)){const i=s.getSource();i instanceof Image&&i.addEventListener("error",(()=>{const s=t.styleFactory("https://lcjs-resources.lightningchart.com/v1"),e=Ht(s)&&s.getSource(),h=e&&e instanceof Image?e:void 0;ni.console.warn("LightningChart JS warning | fallbacking to publicly hosted asset resources.\nFor more information, please see https://lightningchart.com/js-charts/docs/troubleshooting/warning-using-publicly-hosted-resources/"),null==h||h.addEventListener("load",(()=>{t.apply(s)})),null==h||h.addEventListener("error",(()=>{as(t.resourcesBaseUrl,i.src,"Theme resource",{shouldCrash:!1})}))}))}return s},ni="undefined"!=typeof window?window:"undefined"!=typeof global&&global._lcjs?global._lcjs:{},oi=(t,i)=>t.x===i.x&&t.y===i.y,ai=t=>t!==bs&&t!==xs&&!Number.isNaN(t)&&Number.isFinite(t)&&t!==1/0&&t!==-1/0,li=t=>t[1],ui=t=>t.dispose(),ci=()=>{},di=(t,i)=>t===i,fi=(t,i,s)=>s>i?Math.min(Math.max(t,i),s):Math.min(Math.max(t,s),i),Ai=t=>Array.prototype.concat.apply([],t),gi=(t,i)=>void 0===t||Number.isNaN(t)?i:t,vi=t=>t.Wt(),yi=t=>t.jt(),pi=t=>t.Zt(),mi=t=>t.Qt(),Si=t=>t.min.x,bi=t=>t.max.x,xi=t=>t.min.y,Mi=t=>t.max.y,wi=(t,i,s,e,h)=>{if(t.length>0){let r=h?e(h):void 0;for(let e=0;e<t.length;e+=1){const h=i(t[e]);void 0!==h&&(r=void 0!==r?s(r,h):h)}return r}if(h)return e(h)},_i=(t,i)=>t.position===i.position&&t.high===i.high&&t.low===i.low,Ci=r(0,1),ki=r(1,0),Ti=r(0,-1),Fi=r(-1,0),Ii=r(0,0),Pi=t=>{switch(t){case ei.Up:return Ci;case ei.Right:return ki;case ei.Down:return Ti;case ei.Left:return Fi;default:return Ii}},Li=t=>t===ei.Left||t===ei.Right,Bi=t=>{t.stopPropagation(),t.preventDefault()},Di=(t,i)=>{if(!i)return t;const s=t.length,e=new Float32Array(2*s);let h=0;for(let i=0;i<s;i+=1){const s=t[i],r=Math.fround(s);e[h+0]=r,e[h+1]=s-r,h+=2}return e},Ei=(t,i,s=Float32Array)=>{if(!i){const i=t.length,e=new s(2*i);let h=0;for(let s=0;s<i;s+=1){const i=t[s];e[h+0]=i.x,e[h+1]=i.y,h+=2}return e}const e=t.length,h=new s(4*e);let r=0;for(let i=0;i<e;i+=1){const s=t[i],e=Math.fround(s.x),n=Math.fround(s.y);h[r+0]=e,h[r+1]=n,h[r+2]=s.x-e,h[r+3]=s.y-n,r+=4}return h},Ri=t=>{const i=t.length,s=new Float32Array(3*i);let e=0;for(let h=0;h<i;h+=1){const i=t[h];s[e+0]=i.x,s[e+1]=i.y,s[e+2]=i.z,e+=3}return s},zi=t=>i=>{const s=t.indexOf(i);s>=0&&t.splice(s,1)},Vi=t=>{let i=t.length;for(let s=0;s<i-1;s+=1)t[s].x===t[s+1].x&&t[s].y===t[s+1].y&&(t.splice(s,1),s-=1,i-=1);return t},Oi=t=>{const i=Math.log(t);return t=>Math.log(t)/i},Ni=Oi(Math.E),Gi=(t,i)=>{const s=i[t];return s?s():void 0},$i=(t,i)=>{let s;if(i)s=i;else{const i={x:0,y:0};for(let s=0;s<t.length;s+=1)i.x+=t[s].x/t.length,i.y+=t[s].y/t.length;s=i}return t.sort(((t,i)=>ee(Zs(t,s))-ee(Zs(i,s))))},Ui=(t,i,s)=>{if(0===t.length)return!1===s.canReturnB?i.slice():i;const e=i.length;if(e<1e5)return t.push.apply(t,i),t;for(let s=0;s<e;s+=1)t.push(i[s]);return t},Yi=(t,i,s)=>s<0?t:s>1?i:m(t.getR()+s*(i.getR()-t.getR()),t.getG()+s*(i.getG()-t.getG()),t.getB()+s*(i.getB()-t.getB()),t.getA()+s*(i.getA()-t.getA())),Hi=t=>255===t.getA()?t:t.setA(255),Xi=(()=>{const t=m(0,0,0);return i=>(i=Hi(i),new it({angle:180,stops:[{offset:0,color:i},{offset:1,color:Yi(i,t,.5)}]}))})(),Wi=(()=>{const t=t=>{var i;if(t){if(U(t)){if(0===t.getColor().getA())return;return t.getColor()}if(q(t)||st(t)){const s=t.getColorStops();return 3===s.length?s[1].color:null===(i=s[0])||void 0===i?void 0:i.color}j(t)}};return(i,s,e,h)=>{var r;const n=[];if(h.fill&&n.push(h.fill),h.fill2&&n.push(h.fill2),h.stroke){const t=h.stroke.getFillStyle();t!==V&&("stroke"===(null===(r=h.behavior)||void 0===r?void 0:r.priority)?n.unshift(t):n.push(t))}if(h.point3D){const t=h.point3D;n.push(t.getFillStyle())}let o;if(h.behavior&&!0===h.behavior.colorStep){const[i,e]=n.reduce(((i,s)=>{if(i[0]&&i[1])return i;const e=t(s);return e&&(void 0===i[0]?i[0]=e:i[1]=e),i}),[void 0,void 0]);o=i&&e?(a=i)===(l=e)||a.getR()===l.getR()&&a.getG()===l.getG()&&a.getB()===l.getB()?Xi(a):(a=Hi(a),l=Hi(l),new it({angle:0,stops:[{offset:0,color:l},{offset:.5,color:l},{offset:.5,color:a},{offset:1,color:a}]})):s.uiButtonFillStyle}else{const i=n.reduce(((i,s)=>i||t(s)),void 0);o=i?e?new $({color:i}):Xi(i):s.uiButtonFillStyle}var a,l;i.setButtonOnFillStyle(o)}})(),ji=(t,i)=>{const s=t;if(j(s))return{lut:s.getPalette(),lookUpProperty:s.getLookUpProperty(),valueRange:i}},Zi=t=>{let i=0;return()=>(i+=1,`${t}-${i}`)},Qi=(t,i)=>{let s="string"==typeof t?t:String(t);const e=s.indexOf(".");let h=e>=0?e:s.length;for(;h<i;h+=1)s=`0${s}`;return s},Ji=(t,i)=>"function"==typeof t?t(i):t,Ki=(t,i)=>i(),qi=()=>new Error("LightningChart JS encountered an unexpected error.\nPlease report this issue to https://lightningchart.com/js-charts/docs/contact");new $({color:m(255,255,255,1)});const ts=t=>t===Ms||t.min.x===Ms.min.x&&t.max.x===Ms.max.x&&t.min.y===Ms.min.y&&t.max.y===Ms.max.y,is=t=>Array.from(new Set(t)),ss=t=>t.filter((t=>void 0!==t)),es=t=>"boolean"==typeof t?t?1:0:t>1?1:t<0?0:t,hs=(t,i,s)=>{i.length<=0||(t.setText(s.label).setOn(i[0].getVisible()),s.style&&t.setButtonOnFillStyle(s.style),s.toggleVisibilityOnClick&&t.addEventListener("switch",(t=>{i.forEach((i=>i.setVisible(t.state)))})),t.addEventListener("pointerenter",(()=>{i.forEach((t=>t.setHighlight(!0)))})),t.addEventListener("pointerleave",(()=>{i.forEach((t=>t.setHighlight(!1)))})),i.forEach((i=>i.addEventListener("pointerenter",(()=>t.setHighlight(!0))))),i.forEach((i=>i.addEventListener("pointerleave",(()=>t.setHighlight(!1))))))},rs=(t,i)=>{throw new Error(i)},ns=t=>{let i;return()=>i||(i=t(),i)},os=t=>{if(t===Wt)return 0;const i=t.getThickness();return i<0?1:1*i},as=(t,i,s,e)=>{const h=`LightningChart JS Resources not found.\nresourcesBaseUrl: "${t}"\ninitiator: ${s}\nresource url: ${i}\nFor more information, please see https://lightningchart.com/js-charts/docs/troubleshooting/error-resources-not-found/`;if(e.shouldCrash)throw ni.alert(h),new Error(h);ni.console.warn(h)},ls=(t,i,s,e=0)=>{if(t<s(e)||s(i)<t)return;const h=i;for(;e!==i;){const h=Math.ceil((e+i)/2);t<s(h)?i=h-1:e=h}const r=Math.abs(t-s(e));return e<h&&Math.abs(t-s(e+1))<r?e+1:e},us=()=>{const t=new Map;return{Jt:i=>(Object.keys(Rt).forEach((s=>{i.addEventListener(s,((i,e)=>{const h=e.collectionMember&&t.get(e.collectionMember);if(!h)return;const r=Vt(i)?{clientX:i.changedTouches[0].clientX,clientY:i.changedTouches[0].clientY}:i,n=h.Kt(e.info,r);h.D.R(s,i,n)}))})),i),qt:(i,s)=>{t.set(i,s)},ti:()=>{t.clear()}}},cs={left:0,right:0,top:0,bottom:0},ds=()=>Math.round(Math.random()*Number.MAX_SAFE_INTEGER),fs=(t,i,s)=>{i&&i.ii();const e=s();return Object.keys(e).forEach((i=>{const s=i,h=e[s];t.addEventListener(s,h)})),{si:t,ii:()=>{Object.entries(e).forEach((([i,s])=>{const e=i,h=s;t.removeEventListener(e,h)}))}}},As=(t,i,s)=>{let e;const h=()=>(e=s(),e),r={...t,resolve:()=>e||h()};for(const t of Object.keys(i))Object.defineProperty(r,t,{get:function(){return e?e[t]:h()[t]}});return r},gs=t=>{if(t)return"resolve"in t?t.resolve():t},vs=t=>{let i=t;return{ei:t=>{const s=i;return i=s+t,[s,t]}}},ys=t=>{ni.document.body.addEventListener(t,(t=>{t.stopPropagation(),t.preventDefault()}),{once:!0,capture:!0})},ps=()=>{const t=ni.performance.now();ni.document.body.addEventListener("contextmenu",(i=>{ni.performance.now()-t>5e3||i.preventDefault()}),{once:!0})},ms=()=>{const t=ni.performance.now();ni.document.body.addEventListener("touchstart",(i=>{ni.performance.now()-t>5e3||i.preventDefault()}),{once:!0})},Ss={add:(t,i)=>a(t.x+i,t.y+i,t.z+i),addVec(t,...i){const s={x:t.x,y:t.y,z:t.z};for(const t of i)s.x+=t.x,s.y+=t.y,s.z+=t.z;return s},subtract:(t,i)=>a(t.x-i,t.y-i,t.z-i),subtractVec(t,...i){const s={x:t.x,y:t.y,z:t.z};for(const t of i)s.x-=t.x,s.y-=t.y,s.z-=t.z;return s},multiply:(t,i)=>a(t.x*i,t.y*i,t.z*i),divide:(t,i)=>a(t.x/i,t.y/i,t.z/i),multiplyVec(t,...i){const s={x:t.x,y:t.y,z:t.z};for(const t of i)s.x*=t.x,s.y*=t.y,s.z*=t.z;return s},divideVec(t,...i){const s={x:t.x,y:t.y,z:t.z};for(const t of i)s.x/=t.x,s.y/=t.y,s.z/=t.z;return s},length:t=>Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z),normalize:t=>Ss.divide(t,Ss.length(t)),dot:(t,i)=>t.x*i.x+t.y*i.y+t.z*i.z,cross:(t,i)=>a(t.y*i.z-t.z*i.y,t.z*i.x-t.x*i.z,t.x*i.y-t.y*i.x),angle:(t,i)=>Math.acos(Ss.dot(t,i)/(Ss.length(t)*Ss.length(i))),rotateAroundAxis(t,i,s){const e=Math.cos(s),h=Math.sin(s),r=Ss.dot(i,t),n=Ss.cross(i,t);return Ss.addVec(Ss.multiply(t,e),Ss.addVec(Ss.multiply(i,(1-e)*r),Ss.multiply(n,h)))},lerp:(t,i,s)=>(s=fi(s,0,1),Ss.addVec(Ss.multiply(t,1-s),Ss.multiply(i,s))),equals:(t,i)=>di(t.x,i.x)&&di(t.y,i.y)&&di(t.z,i.z),abs:t=>({x:Math.abs(t.x),y:Math.abs(t.y),z:Math.abs(t.z)}),sign:t=>({x:Math.sign(t.x),y:Math.sign(t.y),z:Math.sign(t.z)})},bs=Number.MAX_SAFE_INTEGER,xs=-Number.MAX_SAFE_INTEGER,Ms=u(r(bs,bs),r(xs,xs)),ws=u(a(bs,bs,bs),a(xs,xs,xs)),_s=(t,i)=>{const s=Math.log(t)/Math.log(i);return Math.floor((t=>(Math.ceil(t)-t<1e-4?t=Math.ceil(t):t-Math.floor(t)<1e-4&&(t=Math.floor(t)),t))(s))},Cs=(t,i)=>!(i.min.x>t.max.x||i.max.x<t.min.x||i.min.y>t.max.y||i.max.y<t.min.y),ks=(t,i)=>!(t[1].x<i[0].x||t[0].x>i[1].x||t[3].y<i[0].y||t[0].y>i[3].y),Ts=(t,i)=>({min:{x:Math.min(t[0].x,i[0].x),y:Math.min(t[0].y,i[0].y)},max:{x:Math.max(t[2].x,i[2].x),y:Math.max(t[2].y,i[2].y)}}),Fs=t=>{const i=t.length;for(let s=0;s<i;s+=1)for(let e=s+1;e<i;e+=1)if(Cs(t[s],t[e]))return!0;return!1},Is=(t,i)=>i+t,Ps=(t,i,s)=>{const e=Zs(i,t),h=e.x*e.x+e.y*e.y;if(0===h)return t;const n=Zs(s,t),o=(n.x*e.x+n.y*e.y)/h;return o<=0?t:o>=1?i:r(t.x+o*e.x,t.y+o*e.y)},Ls=(t,i,s)=>s>i?t>=i&&t<=s:t>=s&&t<=i,Bs=(t,i)=>{const s=t.x-i.x,e=t.y-i.y;return Math.sqrt(s*s+e*e)},Ds=(t,i)=>{const s=t.x-i.x,e=t.y-i.y;return s*s+e*e},Es=(t,i,s)=>js(t,Ws(Zs(i,t),s)),Rs=(t,i,s)=>Ss.addVec(t,Ss.multiply(Ss.subtractVec(i,t),s));function zs(t){const i=t.length;if(i>0){let s=t[0].x,e=t[0].x,h=t[0].y,n=t[0].y;for(let r=0;r<i;r+=1){const i=t[r];i.x>s&&(s=i.x),i.x<e&&(e=i.x),i.y>h&&(h=i.y),i.y<n&&(n=i.y)}return u(r(e,n),r(s,h))}return Ms}function Vs(t){const i=t.length;if(i>0){let s=t[0].x,e=t[0].x,h=t[0].y,r=t[0].y,n=t[0].z,o=t[0].z;for(let a=0;a<i;a+=1){const i=t[a];i.x>s&&(s=i.x),i.x<e&&(e=i.x),i.y>h&&(h=i.y),i.y<r&&(r=i.y),i.z>n&&(n=i.z),i.z<o&&(o=i.z)}return u(a(e,r,o),a(s,h,n))}return ws}const Os=(...t)=>{const i={min:{x:bs,y:bs},max:{x:xs,y:xs}};for(const s of t)i.min.x=i.min.x<s.min.x?i.min.x:s.min.x,i.max.x=i.max.x>s.max.x?i.max.x:s.max.x,i.min.y=i.min.y<s.min.y?i.min.y:s.min.y,i.max.y=i.max.y>s.max.y?i.max.y:s.max.y;return i},Ns=(t,i)=>u(a(t.min.x<i.min.x?t.min.x:i.min.x,t.min.y<i.min.y?t.min.y:i.min.y,t.min.z<i.min.z?t.min.z:i.min.z),a(t.max.x>i.max.x?t.max.x:i.max.x,t.max.y>i.max.y?t.max.y:i.max.y,t.max.z>i.max.z?t.max.z:i.max.z));function Gs(t,i,s,e){const h=t.x-e.x,r=t.y-e.y,n=e.x-s.x,o=s.y-e.y,a=o*h+n*r,l=(e.y-i.y)*h+(i.x-e.x)*r,u=o*(i.x-e.x)+n*(i.y-e.y);return u<0?a<=0&&l<=0&&a+l>=u:a>=0&&l>=0&&a+l<=u}function $s(t,i,s){return r(Math.cos(s)*(t.x-i.x)+Math.sin(s)*(t.y-i.y)+i.x,-Math.sin(s)*(t.x-i.x)+Math.cos(s)*(t.y-i.y)+i.y)}function Us(t,i){return r(t.x-i.x,t.y-i.y)}function Ys(t){const i=Xs(t);return 0===i?r(0,0):r(t.x/i,t.y/i)}function Hs(t,i){let s={x:i.x-t.x,y:i.y-t.y};s=Ys(s);const e=Math.PI/2,h=s.x;return s.x=-Math.sin(e)*s.y,s.y=h*Math.sin(e),s}function Xs(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function Ws(t,i){return r(t.x*i,t.y*i)}function js(t,i){return r(t.x+i.x,t.y+i.y)}function Zs(t,i){return r(t.x-i.x,t.y-i.y)}function Qs(t,i){return r(t.x*i.x,t.y*i.y)}function Js(t,i){return r(t.x/i.x,t.y/i.y)}function Ks(t){return Ws(t,-1)}function qs(t,i){return t.x*i.x+t.y*i.y}const te=(t,i,s)=>{const e=(s.y-i.y)/(s.x-i.x),h=i.y+(t-i.x)*e;return r(t,h)},ie=(t,i,s)=>{const e=(s.y-i.y)/(s.x-i.x),h=i.x+(t-i.y)/e;return r(h,t)};function se(t){return t*Math.PI/180}function ee(t){return 180*Math.atan2(t.y,t.x)/Math.PI}function he(t){return r(Math.cos(t),Math.sin(t))}const re=(t,i,s,e)=>{let h,n,o,a;if(i.x-t.x!=0||e.x-s.x!=0)return i.x-t.x==0?(o=i.x,n=(e.y-s.y)/(e.x-s.x),a=n*(o-s.x)+s.y):e.x-s.x==0?(o=e.x,h=(i.y-t.y)/(i.x-t.x),a=h*(o-t.x)+t.y):(h=(i.y-t.y)/(i.x-t.x),n=(e.y-s.y)/(e.x-s.x),o=(s.y-n*s.x+h*t.x-t.y)/(h-n),a=h*(o-t.x)+t.y),r(o,a)},ne=(t,i)=>{const s=t.length,e=i.length,h=new Uint16Array(s+e);return h.set(t,0),h.set(i,s),h};class oe{constructor(){this.hi=!0}getInnerStart(){return this.$}getInnerEnd(){return this.U}getInnerInterval(){return Math.abs(this.U-this.$)}W(t,i){return this.hi=t!==this.$||i!==this.U,this.$=t,this.U=i,this}H(){return this.hi=!1,this}X(){return this.hi=!0,this}}class ae extends oe{constructor(t,i,s,e){if(super(),this.ri=!0,this.ni=!0,this.oi=[0,0],this.ai=!0,this.li=t,this.ui=i,this.ci=s,this.di=t,this.fi=i,e){const t=t=>{this.Ai(t.value)};e.V("change",t),this.Ai(e.C()),this.gi=()=>e.N("change",t)}}Z(t){return this.Y=t,this.ni=!0,this}yi(t){return this.oi=t.map(Math.abs),this.ai=!0,this}pi(){return this.li/this.ci*this.Y+this.oi[0]}mi(){return(this.li+this.ui)/this.ci*this.Y-this.oi[1]}Si(){return this.getCellSize()-this.bi()}xi(){return this.Y}getCellSize(){return this.Mi(this.Y)}bi(){return this.oi[0]+this.oi[1]}wi(){return this.oi}Ai(t){this.ci=t.reduce(Is,0),this.li=t.reduce(((t,i,s)=>s>=this.di?t:t+i),0),this.ui=t.reduce(((t,i,s)=>s>=this.di&&s<this.di+this.fi?t+i:t),0),this.ri=!0,this._i()}Mi(t){return t*this.ui/this.ci}H(){return super.H(),this.ni=!1,this.ai=!1,this.ri=!1,this}X(){return super.X(),this.ni=!0,this.ai=!0,this.ri=!0,this}}class le extends ae{constructor(t,i,s,e){super(t,i,s,e),this.Ci={internal:10,function:ue(10),number:10},this.Y=1e3,this.W(1,1e3),this.ki=this.Ti()}et(t,i,s,e,h){if(t===i)return!1;const r=Math.min(t,i)<de,n=Math.max(t,i)>fe;return!r&&!n||!!h&&(i>t?{start:r?de:t,end:n?fe:i}:{start:n?fe:t,end:r?de:i})}nt(t){const i=this.pi(),s=this.mi(),e=Math.max(t,de);return i+(this.Ci.function(e)-this.ki.scaleStartLog)/this.ki.scaleIntervalLog*(s-i)}rt(t){const i=this.pi(),s=(t-i)/(this.mi()-i),e=this.ki.scaleStartLog+s*this.ki.scaleIntervalLog;return this.Ci.number**e}_i(){this.Ci&&this.Ti()}W(t,i){return super.W(t,i),this.Ci&&this.Ti(),this}yi(t){return super.yi(t),this.Ci&&this.Ti(),this}Z(t){return super.Z(t),this.Ci&&this.Ti(),this}Fi(t){return this.Ci={internal:t,function:ue(t),number:ce(t)},this}Ii(){return this.Ci.internal}Pi(t,i){const s=this.nt(t)+i;return this.rt(s)}Li(){return this.ni||this.hi||this.ai||this.ri}Ti(){const t=this.Ci.function(this.$),i=this.Ci.function(this.U)-t,s=2*this.pi()/this.Y-1,e=2*this.mi()/this.Y-1-s;return this.ki={scaleStartLog:t,scaleIntervalLog:i,viewportStart:s,viewportSize:e},this.ki}Bi(){return this.ki}}const ue=t=>"e"===t?Ni:Oi(t),ce=t=>"e"===t?Math.E:t,de=.9*10**-20,fe=1.1*10**25,Ae=[{prefix:"T",unit:10**12},{prefix:"B",unit:10**9},{prefix:"M",unit:1e6},{prefix:"K",unit:1e3}],ge=(t,i,s)=>{const e=Math.abs(s-i);if(0===e)return t.toFixed(0);const h=Math.max(2-_s(e,10),0);return t.toFixed(h)},ve={Numeric:(t,i)=>{const{start:s,end:e}=i;return ge(t,s,e)},NumericUnits:(t,i)=>{const{start:s,end:e}=i,h=Math.abs(e-s),r=t<0;t=Math.abs(t);let n="",o="";if(h>=1e3&&t>1e3){let i="";for(const s of Ae){const e=Math.round(1e3*t/s.unit)/1e3;if(e>=1){i=e.toString(),o=s.prefix;break}}n=(r?"-":"")+i}else{let i=String(Math.floor(t));const s=_s(t,1e3);for(let t=1;t<=s;t+=1){const s=i.length-(3*t+(t-1));i=`${i.substring(0,s)} ${i.substring(s,i.length)}`}n=(r?"-":"")+i+(h<=10?((t,i)=>{if(0===i)return"";let s=(Math.abs(t)-Math.abs(Math.floor(t))).toString().substring(1);return s.length>i&&(s=s.substring(0,i+1)),s})(t,2-_s(h,10)):"")}return n+=o,n},LogarithmicExponentsRounded:(t,i,s,e=10)=>{const h=ue(e)(t);return`${e}${ye(h)}`},LogarithmicExponents:(t,i,s,e=10)=>{const h=ue(e),r=Math.floor(h(t)),n=t/ce(e)**r;return`${Math.round(n)}×${e}${ye(r)}`},LogarithmicExtreme:(t,i,s,e=10)=>{const h=ue(e),r=Math.floor(h(t));return`${(t/ce(e)**r).toFixed(2)}×${e}${ye(r)}`},LogarithmicNoExponents:(t,i,s,e=10)=>{const h=ue(e);if("e"===e)return`${Math.floor(h(t))}e`;const r=t.toString();if(t>1)return r;const n=Math.floor(h(t));return t.toFixed(Math.abs(n))},Scientific:(t,i)=>{const{start:s,end:e}=i,h=Math.max(Math.abs(s),Math.abs(e)),r=Math.floor(Math.log10(h));return 0===t?`0.00e${r<0?"":"+"}${r}`:t.toExponential(2)}},ye=t=>Math.round(t).toString().split("").map((t=>{switch(t){case"0":return"⁰";case"1":return"¹";case"2":return"²";case"3":return"³";case"4":return"⁴";case"5":return"⁵";case"6":return"⁶";case"7":return"⁷";case"8":return"⁸";case"9":return"⁹";case"-":return"⁻";default:return t}})).join("");class pe extends ae{constructor(t,i,s,e){super(t,i,s,e),this.Di=!1,this.Ei=!1,this.Ri=0,this.Y=1e3,this.W(0,10),this.j()}Li(){return this.Ei}et(t,i,s,e,h){if(t===i)return!1;const r=Math.abs(e-s),n=Math.abs(i-t);if(!this.Di){const s=((t,i,s)=>{const e=((t,i)=>{if(i<bs&&i>xs&&t<bs&&t>xs){const s=Math.abs(t/2**23),e=Math.abs(i/2**23),h=Math.min(s,e);return 10**Math.floor(Math.log10(h))}})(t,i);if(void 0!==e)return e*s})(t,i,this.getCellSize());if(void 0===s)return!1;if(n>s)return!0;const e=(i+t)/2,o=(h?s/2:r/2)*(t>i?-1:1);return{start:e-o,end:e+o}}const o=10**-(12-Math.log10(Math.max(Math.abs(t),1)));if(n>o)return!0;const a=(i+t)/2,l=(h?o/2:r/2)*(t>i?-1:1);return{start:a-l,end:a+l}}_i(){this.j()}nt(t){return this.pi()+(t-this.$)/(this.U-this.$)*(this.mi()-this.pi())}rt(t){return this.$+(t-this.pi())/(this.mi()-this.pi())*(this.U-this.$)}W(t,i){return super.W(t,i),this.j(),this}yi(t){return super.yi(t),this.j(),this}Z(t){return super.Z(t),this.zi=me(this.U-this.$,this.oi,this.Y,this.ui,this.ci),this.j(),this}Vi(){return this.Di=!0,this}Oi(){return this.Di}Ni(){return Math.abs(this.Gi)}$i(){return this.Ni()/this.zi}Ui(){return this.Yi}Hi(){return this.Xi}getPixelSize(){return this.zi}Bi(){return this.ki}X(){return super.X(),this.Ei=!0,this}H(){return super.H(),this.Ei=!1,this}Wi(t,i=ve.Numeric){return i(t,{start:this.$,end:this.U})}ji(){const t=Math.abs(this.getInnerEnd()).toString().length,i=Math.abs(this.getInnerStart()).toString().length;return t>i?t:i}Zi(t){return me(t,this.oi,this.Y,this.ui,this.ci)}j(){let t=this.$,i=this.U,s=0;this.Di&&(t=0,i=this.U-this.$,s=this.$);const e=i-t,h=me(e,this.oi,this.Y,this.ui,this.ci);this.Xi=t-this.oi[0]*h,this.Yi=i+this.oi[1]*h;const r=this.Yi-this.Xi,n=r-this.Gi,o=Math.abs(n/h),a=e-this.Ri,l=Math.abs(a/h);(!this.ki||o>=.4||l>=.4)&&(this.Ri=e,this.Gi=r,this.zi=h,this.Ei=!0);const u=this.Gi*this.ci/(2*this.ui),c=-(this.Xi-this.Gi*this.li/this.ui)-u,d=2*this.pi()/this.Y-1,f=2*this.mi()/this.Y-1-d;this.ki={displacement:c,scaling:u,highPrecisionOffset:s,viewportStart:d,viewportSize:f,scaleStartLog:0,scaleIntervalLog:0}}Pi(t,i){return t+this.zi*i}}const me=(t,i,s,e=1,h=1)=>t/(s*e/h-(i[0]+i[1]));class Se{Qi(t,i){return"x"in t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=i),this}H(){return this.x.H(),this.y.H(),this}X(){return this.x.X(),this.y.X(),this}Z(t,i){return"object"==typeof t?(this.x.Z(t.x),this.y.Z(t.y)):(this.x.Z(t),this.y.Z(i)),this}xi(){return r(this.x.xi(),this.y.xi())}Ji(t){return this.x.yi(t),this}Ki(t){return this.y.yi(t),this}bi(){return r(this.x.bi(),this.y.bi())}qi(t,i){return this.x.W(t,i),this}ts(t,i){return this.y.W(t,i),this}getInnerIntervalPixels(){const t=this.x.getCellSize(),i=this.y.getCellSize();return{x:t-this.x.bi(),y:i-this.y.bi()}}ss(){return this.x.Li()||this.y.Li()}}class be extends Se{constructor(){super(...arguments),this.es="LinearScaleXY"}ht(t,i,s,e){return this.x=new pe(t.x,i.x,s.x,e?e.x:void 0),this.y=new pe(t.y,i.y,s.y,e?e.y:void 0),this}Oi(){return this.x.Oi()||this.y.Oi()}hs(){return r(this.x.getPixelSize(),this.y.getPixelSize())}Bi(){return{x:this.x.Bi(),y:this.y.Bi()}}Pi(t,i){const s=this.hs();return{x:t.x+i.x*s.x,y:t.y+i.y*s.y}}rs(t,i,s,e){const h=this.hs(),r=Hs(t,i);return r.x*=e,r.y*=e,{x:t.x+s*h.x*r.x,y:t.y+s*h.y*r.y}}}class xe extends Se{constructor(){super(...arguments),this.es="MixedScaleXY"}Oi(){return!1}Pi(t,i){const s=this.x.nt(t.x),e=this.y.nt(t.y),h={x:s+i.x,y:e+i.y};return{x:this.x.rt(h.x),y:this.y.rt(h.y)}}rs(t,i,s,e){const h={x:this.x.nt(t.x),y:this.y.nt(t.y)},r={x:this.x.nt(i.x),y:this.y.nt(i.y)},n=Ys(Zs(r,h)),o=Hs(r,h),a={x:h.x+n.x*e+o.x*s,y:h.y+n.y*e+o.y*s};return{x:this.x.rt(a.x),y:this.y.rt(a.y)}}Bi(){const t=this.x.Bi(),i=this.y.Bi();return{uScaleStart:[this.x.$,this.y.$],uScaleInterval:[this.x.getInnerInterval(),this.y.getInnerInterval()],uScaleStartLog:[t.scaleStartLog,i.scaleStartLog],uScaleIntervalLog:[t.scaleIntervalLog,i.scaleIntervalLog],uViewportStart:[t.viewportStart,i.viewportStart],uViewportSize:[t.viewportSize,i.viewportSize]}}}const Me=(t,i)=>t instanceof le||i instanceof le?(new xe).Qi(t,i):(new be).Qi(t,i),we=t=>"client"===t,_e=t=>!!(t&&"object"==typeof t&&"clientX"in t&&"number"==typeof t.clientX&&"clientY"in t&&"number"==typeof t.clientY),Ce=t=>"relative"===t,ke=t=>!!(t&&"object"==typeof t&&"x"in t&&"number"==typeof t.x&&"y"in t&&"number"==typeof t.y),Te=(t,i,s,e,h,r)=>{if(!t)return;let n=t;if(s instanceof PointerEvent&&"mouse"===s.pointerType)if(0===s.button){if(!1===t.lmb)return;void 0!==t.lmb&&(n=hi(n,t.lmb))}else if(1===s.button){if(!1===t.mmb)return;void 0!==t.mmb&&(n=hi(n,t.mmb))}else if(2===s.button){if(!1===t.rmb)return;void 0!==t.rmb&&(n=hi(n,t.rmb))}if(e){if(!1===t.shift)return;n=hi(n,t.shift)}if(h){if(!1===t.ctrl)return;n=hi(n,t.ctrl)}if(r){if(!1===t.alt)return;n=hi(n,t.alt)}if(!i)return n;const o=n[i];return o?!0===o?n:hi(n,o):void 0},Fe=t=>{const i=[];return{push:t=>{i.push(t)},end:()=>{i.length>1&&t&&ni.co