tradex-chart
Version:
TradeX-chart is a highly customizable stock trade chart with **one** dependency written in plain JavaScript; use it with any framework or backend.
11 lines • 851 kB
JavaScript
(function(oA,Xt){typeof exports=="object"&&typeof module<"u"?Xt(exports):typeof define=="function"&&define.amd?define(["exports"],Xt):(oA=typeof globalThis<"u"?globalThis:oA||self,Xt(oA["TradeX-chart"]={}))})(this,function(oA){"use strict";function Xt(n,A){for(var e=0;e<A.length;e++){const i=A[e];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const jt="TradeX-Chart",Te="TX",Uh="tradeXutils",zI="tradeXmenus",Ph="tradeXmenu",Ag="tradeXdividers",eg="tradeXwindows",xh="tradeXwindow",tg="tradeXprogress",Oh=500,ig="stream_None",$t="stream_Listening",qs="stream_Started",sg="stream_Stopped",qh="stream_Error",ki="stream_candleFirst",Qe="stream_candleUpdate",vi="stream_candleNew",Jh=250,Hh=8,ng=2,_h=2,og=18,zt=100,Ai=/^(\d*\.?\d+)\s?(px|em|ex|%|in|cn|mm|pt|pc+)$/igm,Wh=6e4,Ti="1m",Ui=Wh,ag=.05,Yh=100,rg=100,Js=.2,Hs=1.2,ct=8;class Z{static default=new Z("default");static percent=new Z("percent");static relative=new Z("relative");static log=new Z("log");static valid(A){return A instanceof Z?A:Z.default}static get types(){let A=[];for(let e in Z)Z[e]instanceof Z&&A.push(e);return A}constructor(A){this.name=A}}const Zh=Z.types,_s=30,Pi=200,Ws=200,Ys=20,Zs=1920,xi=5,Ig=50,gg=30,Vh=8,Vs=30,Xh=[!0,"top"];class RA{static t=0;static o=1;static h=2;static l=3;static c=4;static v=5}const Oi={mainPane:{},primaryPane:{},secondaryPane:{},scale:{},timeline:{}};Array.from(Object.keys(Oi));function jh(n,A){return n=Math.ceil(n)+1,A=Math.floor(A),Math.floor(Math.random()*(A-n)+n)}function qi(n){const A={};return A.value=n,A.sign=!!n,A.integers=lg(n),A.decimals=$h(n),A.total=A.integers+A.decimals,A}function lg(n){return(Math.log10((n^n>>31)-(n>>31))|0)+1}function he(n,A=0){var e=n*Math.pow(10,A),i=Math.round(e),s=(e>0?e:-e)%1===.5?i%2===0?i:i-1:i;return s/Math.pow(10,A)}function $h(n){if(typeof n!="number"&&(n=parseFloat(n)),isNaN(n)||!isFinite(n))return 0;for(var A=1,e=0;Math.round(n*A)/A!==n&&(A*=10,A!==1/0);)e++;return e}function Xs(n,A){if(n==0)return"0";const e=qi(n);if(H(A))return`${new Number(e.value).toFixed(A)}`;let{sign:i,integers:s,decimals:o,value:a}=e;A=isNaN(A)?og:A,o=j(o,0,A),a=new Number(a).toFixed(o);let r=`${a}`,I="",l=0,E=0;return i=i?0:1,i>0&&(I+="-",l++),s==0?(I+="0",l++):(I+=r.slice(l,s),l+=s),o!=0&&(I+=`${r.slice(l)}`,s<=1?E=o:s>3?E=2:s>=2&&(E=3)),I=Number.parseFloat(I).toFixed(E),I}function zh(n){return Math.log(n)/Math.log(10)}function j(n,A,e){return Math.min(e,Math.max(A,n))}function AE(n){const e=Math.abs(n).toString(16);return e.length%2===0?e:"0"+e}let eE=Object.prototype.hasOwnProperty;function tE(n,A,e=void 0){const i=o=>String.prototype.split.call(A,o).filter(Boolean).reduce((a,r)=>a!=null?a[r]:a,n),s=i(/[,[\]]+?/)||i(/[,[\].]+?/);return s===void 0||s===n?e:s}function iE(n,A,e){if(A.length===0)return;let i=n,s=A[A.length-1];if(A.length===1)return Q(i)?i[s]=e:void 0;for(let o=0;o<A.length-1;o++){let a=A[o];(!eE.call(i,a)||!Q(i[a]))&&(i[a]={}),i=i[a]}return i[s]=e}function sE(n,A){let e=Object.getPrototypeOf(A);for(;n--;)e=Object.getPrototypeOf(e);return e}function ee(n,A){return!Q(n)||!Q(A)?A:(Object.keys(A).forEach(e=>{const i=n[e],s=A[e];k(i)&&k(s)?n[e]=ee(i.concat([]),s):Q(i)&&Q(s)?n[e]=ee(Object.assign({},i),s):n[e]=s}),n)}function Ji(n,A){if(n===null||typeof n!="object")return n;let e;n instanceof Date?e=new n.constructor:e=k(n)?[]:{};for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&(typeof n[i]!="object"||n[i]===n?e[i]=n[i]:e[i]=Ji(n[i]));return e}function rA(n){try{return structuredClone(n)}catch{return Ji(n)}}function Cg(n,A){if(n==null)return String(n);switch(typeof n){case"string":return'"'+n+'"';case"function":return n.toString();case"object":let e=Array(A||1).join(" "),i=Array.isArray(n);return"{["[+i]+Object.keys(n).map(function(s){return`
`+e+s+": "+Cg(n[s],(A||1)+1)}).join(",")+`
`+e+"}]"[+i];default:return n.toString()}}function hg(n,A){if(Q(n))for(let e in n)typeof n[e]=="object"&&n[e]!==null?hg(n[e],A):n.hasOwnProperty(e)&&A(e,n[e])}const Eg=(n,A,e)=>{if(n.Id===A)return e(n);for(let i in n)n[i]!==null&&typeof n[i]=="object"&&(n[i]=Eg(n[i],A,e));return n};function nE(n,A){n.split(".")}function js(n,A,e){const[i,...s]=A.split(".");return{...n,[i]:s.length?js(n[i],s.join("."),e):e}}function $s(n,A){return A.split(".").reduce((i,s)=>i&&i[s]!=="undefined"?i[s]:void 0,n)}class oE{constructor(){this.nodes=[]}get size(){return this.nodes.length}get head(){return this.size?this.nodes[0]:null}get tail(){return this.size?this.nodes[this.size-1]:null}insertAt(A,e){const i=this.nodes[A-1]||null,s=this.nodes[A]||null,o={value:e,next:s,previous:i};i&&(i.next=o),s&&(s.previous=o),this.nodes.splice(A,0,o)}insertFirst(A){this.insertAt(0,A)}insertLast(A){this.insertAt(this.size,A)}getAt(A){return this.nodes[A]}removeAt(A){const e=this.nodes[A-1]||null,i=this.nodes[A+1]||null;return e&&(e.next=i),i&&(i.previous=e),this.nodes.splice(A,1)}clear(){this.nodes=[]}reverse(){this.nodes=this.nodes.reduce((A,{value:e})=>{const i=A[0]||null,s={value:e,next:i,previous:null};return i&&(i.previous=s),[s,...A]},[])}*[Symbol.iterator](){yield*this.nodes}}function Hi(n,A){if(!k(n)||!k(A)||n.length!==A.length)return!1;let e=n.length;for(;e--;){if(k(n[e])||k(A[e])){if(!Hi(n[e],A[e]))return!1;continue}if(Q(n[e])||Q(n[e])){if(!je(n[e],A[e]))return!1;continue}if(n[e]!==A[e])return!1}return!0}function aE(n,A){let e=1/0,i=-1,s=null,o=0;for(;o++<A.length;){let a=A[o],r=Math.abs(a-n);r<e&&(e=r,i=o,s=a)}return[i,s]}function ug(n,A,e){let i=n[A];n.splice(A,1),n.splice(e,0,i)}function cg(n,A,e){[n[A],n[e]]=[n[e],n[A]]}function _i(n,A){return k(A)?k(n)?n.every(e=>A.includes(e)):A.includes(n):!1}const rE=n=>[...new Set(n)],IE=(n,A)=>Object.values(n.reduce((e,i)=>(e[A(i)]=i,e),{})),gE=(n,A)=>n.filter(e=>A.includes(e)),ei=(n,A)=>n.filter(e=>!A.includes(e)),lE=(n,A)=>ei(n,A).concat(ei(A,n)),CE=(n,A)=>ei(n,A).concat(A);function hE(n){return!(!Q(n)||Object.keys.length)}function Bg(n){return Q(n)?!!Object.keys(n).length:!1}function je(n,A){if(!Q(n)||!Q(A))return!1;const e=Object.keys(n).sort(),i=Object.keys(A).sort();return e.length!==i.length?!1:e.every((o,a)=>{const r=n[o],I=A[i[a]];return k(r)||k(I)?Hi(r,I):Q(r)||Q(I)?je(r,I):r===I})}function mA(n="ID"){G(n)?n=n.toString():S(n)||(n="ID"),n=Ue(n);const A=Date.now().toString(36),e=Math.random().toString(36).substring(2,5);return`${n}_${A}_${e}`}function Ue(n){return String(n).replace(/ |,|;|:|\.|#/g,"_")}function EE(n,A,e){A=A||"",e=e||512;let i=atob(n),s=[];for(let a=0;a<i.length;a+=e){let r=i.slice(a,a+e),I=new Array(r.length);for(let E=0;E<r.length;E++)I[E]=r.charCodeAt(E);let l=new Uint8Array(I);s.push(l)}return new Blob(s,{type:A})}function uE(n,A){return A instanceof Map?{dataType:"Map",value:[...A.entries()]}:A}function cE(n,A){return typeof A=="object"&&A!==null&&A.dataType==="Map"?new Map(A.value):A}const Qg=n=>n.entries().next().value,dg=n=>n.entries().next().value[0],mg=n=>n.entries().next().value[1],Dg=n=>[...n].pop(),pg=n=>[...n.keys()].pop(),yg=n=>[...n.values()].pop();class pA extends Map{constructor(A){super(A)}indexOfKey(A){return[...this.keys()].indexOf(A)}indexOfValue(A){return[...this.values()].indexOf(A)}entryAtIndex(A){return[...this.entries()][A]}keyAtIndex(A){return[...this.keys()][A]}valueAtIndex(A){return[...this.values()][A]}insert(A,e,i){return this.insertIndex(i,A,e)}remove(A){return this.removeIndex(A)}firstEntry(){return Qg(this)}firstKey(){return dg(this)}firstValue(){return mg(this)}lastEntry(){return Dg(this)}lastKey(){return pg(this)}lastValue(){return yg(this)}prevCurrNext(A){let e=curr=next=null;for(let i of this)if(e=curr,curr=i,i.key==A)break;return{prev:e,curr,next}}union(...A){if(typeof super.prototype.union=="function")super.union(...A);else for(const e of A)for(const i of e)this.set(...i)}setMultiple(A){return k(A)?(A.forEach(([e,i])=>this.set(e,i)),!0):!1}populate(A){return k(A)?(this.clear(),A.forEach(([e,i])=>this.set(e,i)),!0):!1}insertIndex(A,e,i){if(!G(A))return!1;const s=[...this];return s.splice(A,0,[e,i]),this.populate(s),!0}removeIndex(A){if(!G(A))return!1;const e=[...this];return e.splice(A,1),this.populate(e),!0}swapIndices(A,e){if(!G(A)||!G(e))return!1;const i=[...this];return cg(i,A,e),this.populate(i),!0}swapKeys(A,e){const i=[...this],s=i.findIndex(([a])=>a===A),o=i.findIndex(([a])=>a===e);return[i[s],i[o]]=[i[o],i[s]],this.clear(),i.forEach(([a,r])=>this.set(a,r)),!0}}function VA(n,A=100,e,i=!1){let s;return function(){let o=e||this,a=arguments,r=function(){s=null,i||n.apply(o,a)},I=i&&!s;clearTimeout(s),s=setTimeout(r,A),I&&n.apply(o,a)}}function wg(n,A=250,e){let i,s,o=function(){let r=e||this,I=new Date,l=arguments;i&&I<i+A?(clearTimeout(s),s=setTimeout(function(){i=I,n.apply(r,l)},A)):(i=I,n.apply(r,l))};function a(){timeout&&(clearTimeout(s),timeout=void 0)}return o.reset=function(){a(),i=0},o}const BE=(n,...A)=>{class e extends n{constructor(...o){super(...o),A.forEach(a=>{i(this,new a)})}}let i=(s,o)=>{Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o)).forEach(a=>{a.match(/^(?:constructor|prototype|arguments|caller|name|bind|call|apply|toString|length)$/)||Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(o,a))})};return A.forEach(s=>{i(e.prototype,s.prototype),i(e,s)}),e};function QE(n){const A={};return Promise.race([n,A]).then(e=>e===A?"pending":"fulfilled",()=>"rejected")}class dE{constructor(){this.promise=new Promise((A,e)=>{this.resolve=A,this.reject=e})}}function fg(n){return String.fromCharCode.apply(null,new Uint16Array(n))}function Mg(n){let A=new ArrayBuffer(n.length*2),e=new Uint16Array(A);for(let i=0,s=n.length;i<s;i++)e[i]=n.charCodeAt(i);return A}function mE(n){const A=document.createElement("canvas"),e=A.getContext("2d");let i;n.isView(n)?i=n:typeof n=="string"&&(i=Mg(n));const s=new Uint8ClampedArray.from(i),o=s.length;A.height=1,A.width=o,e.putImageData(s);const a=e.toDataURL(),r=getBase64StringFromDataURL(a);return{dataURL:a,base64:r}}function DE(n,A,e="string"){const i=new Image,s=document.createElement("canvas").getContext("2d");return i.src=n,i.decode().then(()=>{s.width=i.width,s.height=i.height,s.drawImage(i,0,0);const o=s.getImageData(0,0,i.width,i.height).data,a=e==="string"?fg(o):o;A(a)})}class yA{static#A=new pA;static get entries(){return yA.#A}static isValid(A,e,i,s){return!Q(A)||!IA(e)||!S(i)||!J(s)}static add(A,e,i,s){if(!this.isValid(A,e,i,s))return!1;e.addEventListener(i,s),yA.#A.has(A)||yA.#A.set(A,new pA);const o=yA.#A.get(A);o.has(e)||o.set(e,{});const a=o.get(e);return k(a[i])||(a[i]=[]),a[i].push(s),!0}static remove(A,e,i,s){if(!yA.isValid(A,e,i,s)||!yA.#A.has(A))return!1;const o=yA.#A.get(A);if(!o.has(e))return!1;const a=o.get(e);if(!(i in a))return!1;const r=a[i].indexOf(s);return r<0?!1:(a[i].splice(r,1),a[i].length==0&&delete a[i],Object.keys(a).length==0&&o.delete(e),o.size==0&&yA.#A.delete(A),!0)}static expungeEvent(A,e,i){if(!Q(A)||!IA(e)||!S(i))return!1;const s=yA.#A.get(A);if(!s.has(e))return!1;const o=s.get(e);if(i in o){for(let a of o[i])e.removeEventListener(i,a);delete o[i]}return!0}static expungeElement(A,e){if(!Q(A)||!IA(e))return!1;const i=yA.#A.get(A);if(i.has(e)){let s=i.get(e);for(let o in s)yA.expungeEvent(A,e,o);i.delete(e)}return!0}static expungeContext(A){if(!Q(A))return!1;if(yA.#A.has(A)){const e=yA.#A.get(A);for(let i of e)yA.expungeElement(A,i);yA.#A.delete(A)}return!0}static expungeAll(){}static destroy(){for(let A of yA.#A)yA.expungeContext(A);return yA.#A=void 0,!0}}async function pE(n,A){const e=r=>new Uint8Array([...decodeURIComponent(encodeURIComponent(r))].map(I=>I.charCodeAt(0))),i=e(n),s=e(A),o=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:"SHA-256"},!0,["sign"]),a=await crypto.subtle.sign("HMAC",o,s);return btoa(String.fromCharCode(...new Uint8Array(a)))}async function yE(n){const A=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",A);return Array.from(new Uint8Array(e)).map(o=>o.toString(16).padStart(2,"0")).join("")}function zs(n,A=0){let e=3735928559^A,i=1103547991^A;for(let s=0,o;s<n.length;s++)o=n.charCodeAt(s),e=Math.imul(e^o,2654435761),i=Math.imul(i^o,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(e^e>>>13,3266489909),(i>>>0).toString(16).padStart(8,0)+(e>>>0).toString(16).padStart(8,0)}const wE=Object.freeze(Object.defineProperty({__proto__:null,Deferred:dE,DoubleLinkedList:oE,EventHandlers:yA,H:yE,HMAC:pE,_get:tE,_set:iE,ab2str:fg,arrayMove:ug,b64toBlob:EE,copyDeep:Ji,cyrb53:zs,debounce:VA,decodePNGDataStore:DE,diff:ei,doStructuredClone:rA,encodePNGDataStore:mE,extender:BE,findInObjectById:Eg,firstEntryInMap:Qg,firstKeyInMap:dg,firstValueInMap:mg,getProperty:$s,getPrototypeAt:sE,idSanitize:Ue,intersection:gE,isArrayEqual:Hi,isObjectAndEmpty:hE,isObjectEqual:je,isObjectNotEmpty:Bg,lastEntryInMap:Dg,lastKeyInMap:pg,lastValueInMap:yg,mergeDeep:ee,nearestArrayValue:aE,objRecurse:hg,objRecurseUpdate:nE,objToString:Cg,promiseState:QE,replacer:uE,reviver:cE,setProperty:js,str2ab:Mg,swapArrayElements:cg,symDiff:lE,throttle:wg,uid:mA,union:CE,unique:rE,uniqueBy:IE,valuesInArray:_i,xMap:pA},Symbol.toStringTag,{value:"Module"}));class ti{#A;#e;#t;#i;#s=!0;#n=!1;#o=Ui;#a=Ti;#I=0;#r=Pi;valueMin=0;valueMax=1;valueDiff=1;volumeMin=0;volumeMax=0;volumeDiff=0;valueMinIdx=0;valueMaxIdx=0;volumeMinIdx=0;volumeMaxIdx=0;#g={};#l={};#C=_s;#h=Pi;#E=Ws;#c=Ys;#B=Zs;#Q=Js;anchor;constructor(A,e,i){if(!Q(i)||!(i?.core instanceof W))throw new Error("Range requires a config");this.#A=mA(`${Te}_Range`),this.#s=!0,this.setConfig(i);let s;if(H(i?.interval)?s=i.interval:S(i?.interval)?s=Le(i?.interval):s=Ui,this.data.length==0){let o=Date.now();A=this.rangeLimit*-2,e=this.rangeLimit*2,this.#o=s,this.#a=qA(this.#o),this.anchor=o-o%s}else this.data.length<2?(this.#o=s,this.#a=qA(this.interval)):(this.#o=ii(this.data),this.#a=qA(this.interval));(!H(A)||this.isPastLimit(A))&&(A=this.data.length-this.#C),(!H(e)||this.isFutureLimit(e))&&(e=this.data.length),e-A>this.#B&&(e=e-(e-A-this.#B)),e==0&&this.data.length>=this.rangeLimit?e=this.rangeLimit:e==0&&(e=this.data.length),this.set(A,e),`${this.maxMinPriceVol.toString()}`}get id(){return this.#A}get core(){return this.#e}get allData(){return this.#t.allData}get data(){return this.allData?.data||[]}get dataLength(){return this.allData?.data.length?this.allData.data.length-1:0}get Length(){return this.indexEnd-this.indexStart}get timeDuration(){return this.timeFinish-this.timeStart}get timeMin(){return this.value(this.indexStart)[0]}get timeMax(){return this.value(this.indexEnd)[0]}get rangeDuration(){return this.timeMax-this.timeMin}get timeStart(){return this.value(0)[0]}get timeFinish(){return this.value(this.dataLength)[0]}set interval(A){this.#o=A}get interval(){return this.#o}set intervalStr(A){this.#a=A}get intervalStr(){return this.#a}get timeFrame(){return this.#a}get timeFrameMS(){return this.#o}get indexStart(){return this.#I}get indexEnd(){return this.#r}get indexed(){return this.#n}get indexEndTS(){return this.value(this.indexEnd)[0]}get indexStartTS(){return this.value(this.indexStart)[0]}get indexPastLimit(){return this.limitPast*-1}get indexFutureLimit(){return this.dataLength+this.limitFuture-1}set initialCnt(A){H(A)&&(this.#C=A)}get initialCnt(){return this.#C}get limitFuture(){return this.#h}get limitPast(){return this.#E}get minCandles(){return this.#c}get maxCandles(){return this.#B}get yAxisBounds(){return this.#Q}get rangeLimit(){return this.#h}get secondaryMaxMin(){return this.#g}get diff(){return this?.valueDiff}end(){}isFutureLimit(A=this.indexEnd){if(H(A))return A>this.indexFutureLimit}isPastLimit(A=this.indexStart){if(H(A))return A<this.indexPastLimit}set(A=this.indexStart,e=this.indexEnd,i=this.maxCandles){if(!H(A)||!H(e)||!H(i))return!1;A=A|0,e=e|0,i=i|0,i=j(i,this.minCandles,this.maxCandles),A>e&&([A,e]=[e,A]),e=j(e,A+this.minCandles,A+i);let s=e-A;A=j(A,this.limitPast*-1,this.dataLength+this.limitFuture-this.minCandles-1),e=j(e,A+this.minCandles,this.dataLength+this.limitFuture-1),A=e-A<s?A-(s-(e-A)):A;const o=A,a=e,r=this.indexStart,I=this.indexEnd;let l=this.Length;return this.#I=A,this.#r=e,l-=this.Length,this.setMaxCandles(i),this.setAllMaxMin(),(this.#s||this.#l.valueMax!=this.valueMax||this.#l.valueMin!=this.valueMin)&&this.#e.emit("range_valueMaxMin",{max:this.valueMax,min:this.valueMin}),this.#e.emit("range_set",[o,a,r,I]),!0}setConfig(A){let e=A?.state;this.#t=e;let i=A?.core;if(!(i instanceof W))throw new Error("Range requires a valid TradeXchart instance");this.#e=i;let s=H(A?.initialCnt)?A.initialCnt:_s;this.#C=this.#e.config?.range?.initialCnt||s,this.#h=H(A?.limitFuture)?A.limitFuture:Pi,this.#E=H(A?.limitPast)?A.limitPast:Ws,this.#Q=G(A?.yAxisBounds)?A.yAxisBounds:Js,this.#c=H(A?.minCandles)?A.minCandles:Ys,this.setMaxCandles(A?.maxCandles)}setMaxCandles(A){let e=this.#e?.MainPane?.graph?.width||Math.floor(this.#e?.parentElement?.clientWidth)||Zs;this.#B=H(A)?A:e}setMaxMin(A){for(let e in A)this.#l[e]=this[e],this[e]=A[e];this.scale=this.dataLength!=0?this.Length/this.dataLength:1}value(A,e="chart"){let i;if(e=="chart")i=this.data;else if(i=this.getDataById(e),!i)return null;H(A)||(A=i.length-1);let s=i[A];if(s!==void 0)return s;{const o=i.length-1;return s=[null,null,null,null,null,null],i.length<1?(s[0]=Date.now()+this.interval*A,s):A<0?(s[0]=i[0][0]+this.interval*A,s):A>o?(s[0]=i[o][0]+this.interval*(A-o),s):null}}valueByTS(A,e=""){if(!H(A)||!S(e))return!1;const i=this.getTimeIndex(A);let s;switch(e){case"chart":break;case"primary":break;case"secondary":break;case"dataset":break;case"all":break;default:e.length===0?s=this.value(i):e.split("_");break}return s}getDataById(A="chart"){if(!S(A))return!1;if(A=="chart")return this.data;const e=[this.allData.primaryPane,this.allData.secondaryPane,this.allData.datasets];for(let i of e)for(let s of i)if(A==s?.id)return s.data;return!1}getTimeIndex(A){if(!H(A))return!1;A=A-A%this.interval;let e=this.data.length>0?this.data[0][0]:this.anchor;return A===e?0:A<e?(e-A)/this.interval*-1:(A-e)/this.interval}inRange(A){return A>=this.timeMin&&A<=this.timeMax}inPriceHistory(A){return A>=this.timeStart&&A<=this.timeFinish}inRenderRange(A){let e=this.getTimeIndex(A),i=this.#e.rangeScrollOffset;return e>=this.indexStart-i&&e<=this.indexEnd+i}rangeIndex(A){return this.getTimeIndex(A)-this.indexStart}setAllMaxMin(){let A=this.maxMinPriceVol({data:this.data,start:this.indexStart,end:this.indexEnd,that:this});this.setMaxMin(A),this.maxMinDatasets()}maxMinPriceVol(A){let{data:e,start:i,end:s,that:o}={...A},a=he(o.core.bufferPx/o.core.candleW),r=e?.length-1;if(a=H(a)?a:0,i=H(i)?i-a:0,i=i>0?i:0,s=H(s)?s:r,r<0)return{valueLo:0,valueHi:1,valueMin:0,valueMax:1,valueDiff:1,valueLast:void 0,valueLive:void 0,valueLiveMin:void 0,valueLiveMax:void 0,volumeMin:0,volumeMax:0,volumeDiff:0,valueMinIdx:0,valueMaxIdx:0,volumeMinIdx:0,volumeMaxIdx:0};let I=_A(i,0,r),l=_A(s,0,r),E=e[I][3]||1/0,f=e[I][2]||-1/0,L=e[I][5]||1/0,R=e[I][5]||-1/0,v=I,U=I,V=I,X=I,_;for(;I++<l;)_=e[I][3],G(_)&&_<E&&(E=_,v=I),_=e[I][2],G(_)&&_>f&&(f=_,U=I),_=e[I][5],G(_)&&_<L&&(L=_,V=I),G(_)&&_>R&&(R=_,X=I);let aA=f-E,tA=E,lA=f,iA=e[e.length-1][4]||null,LA=o.core.stream?.lastTick[4]||null,KA=o.core.stream?.lastPriceMin||null,BA=o.core.stream?.lastPriceMax||null;return E-=aA*o.yAxisBounds,E=E>0?E:0,f+=aA*o.yAxisBounds,aA=f-E,{valueLo:tA,valueHi:lA,valueMin:E,valueMax:f,valueDiff:f-E,valueLast:iA,valueLive:LA,valueLiveMin:KA,valueLiveMax:BA,volumeMin:L,volumeMax:R,volumeDiff:R-L,valueMinIdx:v,valueMaxIdx:U,volumeMinIdx:V,volumeMaxIdx:X};function _A(FA,$,z){return Math.min(z,Math.max($,FA))}}maxMinDatasets(){if(!this.allData?.secondaryPane?.length)return;let A=Object.keys(this.#g)||[];for(let e of this.allData.secondaryPane){let i=A.indexOf(e.id),s={data:e.data,start:this.indexStart,end:this.indexEnd,that:this};this.#g[e.id]=this.maxMinData(s),i!==-1&&A.splice(i,1)}for(let e of A)delete this.#g[e]}maxMinData(A){let{data:e,start:i,end:s,that:o}={...A},a=he(o.#e.bufferPx/o.#e.candleW),r=e.length-1,I=this.dataLength-e.length,l=e[0]?.length-1||0;const E={},f={min:0,max:1,minIdx:0,maxIdx:0,diff:1,last:void 0};if(r<1)return{data:f};for(let iA=l;iA>0;iA--)E[`data${iA}`]=f;if(a=H(a)?a:0,i=H(i)?i-a:0,i=i>0?i-I:0,s=H(s)?s-I:r,r<0||e[0].length==0)return E;let L=j(i,0,r),R=j(s,0,r),v,U,V,X,_,aA,tA,lA;for(let iA in E){for(X=e[L][l]||-1/0,V=e[L][l]||1/0,v=L;v++<R;)U=e[v][l],G&&(U<=V&&(E[iA].min=U,E[iA].minIdx=v,V=U),U>=X&&(E[iA].max=U,E[iA].maxIdx=v,X=U));(aA===void 0||V<aA)&&(aA=V),(tA===void 0||X>tA)&&(tA=X),_=E[iA].max-E[iA].min,E[iA].diff=isNaN(_)?0:_,--l}return lA=tA-aA,aA-=lA*this.yAxisBounds,tA+=lA*this.yAxisBounds,lA=tA-aA,E.data={min:aA,max:tA,diff:tA-aA},E}snapshot(A,e){let i=this.export();return i.snapshot=!0,i.ts=Date.now(),i.data=this.data,i.dataLength=this.dataLength,i.Length=this.Length,i}export(A){let e={};A=k(A)?A:[];for(let i of fE)A.includes(i)||(e[i]=this[i]);return e}}function ii(n){if(!k(n)||n.length<2)return 1/0;let A=Math.min(n.length-1,99),e=1/0;return n.slice(0,A).forEach((i,s)=>{let o=n[s+1][0]-i[0];o===o&&o<e&&(e=o)}),e}const fE=["indexEnd","indexStart","scale","secondaryMaxMin","valueDiff","valueHi","valueLo","valueMax","valueMaxIdx","valueMin","valueMinIdx","volumeDiff","volumeMax","volumeMaxIdx","volumeMin","volumeMinIdx","diff","indexFutureLimit","id","indexed","initialCnt","interval","intervalStr","limitFuture","limitPast","maxCandles","minCandles","indexPastLimit","rangeDuration","rangeLimit","timeDuration","timeFinish","timeFrame","timeFrameMS","timeMax","timeMin","timeStart","yAxisBounds"],Sg=["y","M","d","h","m","s","ms"],Rg=["years","months","days","hours","minutes","seconds","milliseconds"],ME=[0,31,59,90,120,151,181,212,243,273,304,334],SE=[0,31,60,91,121,152,182,213,244,274,305,335],Lg=[31,28,31,30,31,30,31,31,30,31,30,31],RE=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],si=1231006505e3,Pe=1,fA=1e3,wA=fA*60,GA=wA*60,hA=GA*24,Bt=hA*7,XA=hA*30;function Ng(n=3,A=!1){let e=Lg[n%12]*hA;return A&&n>0&&(e+=hA),e}const te=hA*365,ni={y:te,M:XA,w:Bt,d:hA,h:GA,m:wA,s:fA,u:Pe},Gg={years:te,months:XA,weeks:Bt,days:hA,hours:GA,minutes:wA,seconds:fA,milliseconds:Pe},LE={...ni,...Gg},Se={YEARS10:[te*10,"years",10],YEARS5:[te*5,"years",5],YEARS3:[te*3,"years",3],YEARS2:[te*2,"years",2],YEARS:[te,"years",1],MONTH6:[XA*6,"months",6],MONTH4:[XA*4,"months",4],MONTH3:[XA*3,"months",3],MONTH2:[XA*2,"months",2],MONTH:[XA,"months",1],DAY15:[hA*15,"years",15],DAY10:[hA*10,"days",10],DAY7:[hA*7,"days",7],DAY5:[hA*5,"days",5],DAY3:[hA*3,"days",3],DAY2:[hA*2,"days",2],DAY:[hA,"days",1],HOUR12:[GA*12,"hours",12],HOUR6:[GA*6,"hours",6],HOUR4:[GA*4,"hours",4],HOUR3:[GA*3,"hours",3],HOUR2:[GA*2,"hours",2],HOUR:[GA,"hours",1],MINUTE30:[wA*30,"minutes",30],MINUTE15:[wA*15,"minutes",15],MINUTE10:[wA*10,"minutes",10],MINUTE5:[wA*5,"minutes",5],MINUTE3:[wA*3,"minutes",3],MINUTE2:[wA*2,"minutes",2],MINUTE:[wA,"minutes",1],SECOND30:[fA*30,"seconds",30],SECOND15:[fA*15,"seconds",15],SECOND10:[fA*10,"seconds",10],SECOND5:[fA*5,"seconds",5],SECOND2:[fA*2,"seconds",2],SECOND:[fA,"seconds",1],MILLISECOND500:[Pe*500,"milliseconds",500],MILLISECOND250:[Pe*250,"milliseconds",250],MILLISECOND100:[Pe*100,"milliseconds",100],MILLISECOND50:[Pe*50,"milliseconds",50],MILLISECOND:[Pe,"milliseconds",1]},An={};for(let n of Object.values(Se)){let A=n[0],e=qA(A);A<6e4||(An[`${e}`]=A)}Object.freeze(An);const NE=An,Kg=wA,GE=Kg,Fg=Se.YEARS10[0],KE=Fg,oi=(()=>{const n=Object.values(Se),A=[];for(let e=n.length;--e;e>0)A[e]=n[e][0];return A})(),en=(()=>{const n=Object.values(Se),A=[];for(let e=n.length;--e;e>0)A[e]=n[e][1];return A})(),FE=Object.keys(Se),bE=(()=>{const n={};for(const[A,e]of Object.entries(Se))n[A]=e[0];return n})();function tn(){const n=new Date().getTimezoneOffset();return Object.prototype.hasOwnProperty.call(timezones,n)?timezones[n.toString()]:"Etc/UTC"}function kE(){const n={};for(let A in ni){let e=0;n[A]=[];do n[A].push(Math.round(ni[A]*e)),e+=.125;while(e<1)}return n}function Re(n){const A=new Date(n);return A instanceof Date&&!isNaN(A.valueOf())&&isFinite(A.valueOf())}function Wi(n,A=si,e=Date.now()){return Re(n)?n>A&&n<e:!1}function ai(n,A,e){n=new Date(n),A=new Date(A);var i=A.getTime(),s=n.getTime();return parseInt((i-s)/e)}const xe={inSeconds:function(n,A){return ai(n,A,fA)},inMinutes:function(n,A){return ai(n,A,wA)},inHours:function(n,A){return ai(n,A,GA)},inDays:function(n,A){return ai(n,A,hA)},inWeeks:function(n,A){return ai(n,A,Bt)},inMonths:function(n,A){n=new Date(n),A=new Date(A);let e=n.getUTCFullYear(),i=A.getUTCFullYear(),s=n.getUTCMonth();return A.getUTCMonth()+12*i-(s+12*e)},inYears:function(n,A){let e=new Date(n);return new Date(A).getUTCFullYear()-e.getUTCFullYear()}};function vE(n,A){let e=xe.inYears(n,A),i=xe.inMonths(n,A),s=xe.inWeeks(n,A),o=xe.inDays(n,A),a=xe.inHours(n,A),r=xe.inMinutes(n,A),I=xe.inSeconds(n,A),l=new Date(A).getTime()-new Date(n).getTime();return{y:e,M:i,w:s,d:o,h:a,m:r,s:I,ms:l,years:e,months:i,weeks:s,days:o,hours:a,minutes:r,seconds:I,milliseconds:l}}function sn(n){return H(n)&&!(n<fA)&&n!==1/0}function Yi(n){let A=fA;return S(n)?(A=Le(n),A?n=n:(A=fA,n="1s")):H(n)?(A=n,n=qA(n)):n="1s",{tf:n,ms:A}}function Le(n){if(!S(n))return!1;const A=/([0-9]{1,2})([s|m|h|d|w|M|y])/gm;let e;return(e=A.exec(n))!==null?ni[e[2]]*e[1]:!1}function nn(n){let A=Math.floor(n/1e3),e=Math.floor(A/60);A=A%60;let i=Math.floor(e/60);e=e%60;let s=Math.floor(i/24);i=i%24;let o=Math.floor(s/7);s=s%7;let a=Math.floor(o/4),r=Math.floor(o/52),I=o%4;return a=a%13,{y:r,M:a,w:I,d:s,h:i,m:e,s:A,years:r,months:a,weeks:I,days:s,hours:i,minutes:e,seconds:A}}function qA(n){const A=nn(n);for(const e in A)if(A[e])return`${A[e]}${e}`}function bg(n){return n?new Date(n).getUTCSeconds():null}function on(n){return new Date(n).setUTCMilliseconds(0,0)}function kg(n){return n?new Date(n).getUTCMinutes():null}function an(n){return new Date(n).setUTCSeconds(0,0)}function vg(n){return n?new Date(n).getUTCHours():null}function rn(n){return new Date(n).setUTCMinutes(0,0,0)}function In(n){return n?new Date(n).getUTCDate():null}function Tg(n,A="en-GB",e="short"){return new Date(n).toLocaleDateString(A,{weekday:e})}function ri(n){return new Date(n).setUTCHours(0,0,0,0)}function gn(n){if(n)return new Date(n).getUTCMonth()}function Ug(n,A="en-GB",e="short"){return new Date(n).toLocaleDateString(A,{month:e})}function ln(n){let A=new Date(n);return Date.UTC(A.getUTCFullYear(),A.getUTCMonth(),1)}function Pg(n){let A=(gn(n)+1)%12;return n+=Ng(A,Zi(n)),n}function xg(n){if(n)return new Date(n).getUTCFullYear()}function Cn(n){return Date.UTC(new Date(n).getUTCFullYear())}function Og(n){return n=n+te+hA,Zi(n),n}function Zi(n){let e=new Date(n).getUTCFullYear();return e&3?!1:e%100!=0||e%400==0}function TE(n){let A=new Date(n),e=A.getUTCMonth(),i=A.getUTCDate(),s=dayCount[e]+i;return e>1&&Zi()&&s++,s}function Vi(n,A){return{years:i=>Cn(i),months:i=>ln(i),weeks:i=>ri(i),days:i=>ri(i),hours:i=>rn(i),minutes:i=>an(i),seconds:i=>on(i)}[A](n)}function UE(n,A){let e,i;switch(A){case"years":e=Cn(n),i=Og(n);break;case"months":e=ln(n),i=Pg(n);break;case"weeks":e=ri(n),i=e+hA;break;case"days":e=ri(n),i=e+hA;break;case"hours":e=rn(n),i=e+GA;break;case"minutes":e=an(n),i=e+wA;break;case"seconds":e=on(n),i=e+fA}return{start:e,end:i}}function hn(n){let{h:A,m:e}=un(n);return A==0&&e==0?`${d}`:`${A}:${e}`}function PE(n){let{h:A,m:e,s:i}=un(n);return A==0&&e==0&&i==0?`${d}`:`${A}:${e}:${i}`}function En(n){let{h:A,m:e,s:i}=un(n);return A==0&&e==0&&i==0?`${d}`:`${e}:${i}`}function un(n){let A,e,i,s;return A=String(In(n)),e=String(vg(n)).padStart(2,"0"),i=String(kg(n)).padStart(2,"0"),s=String(bg(n)).padStart(2,"0"),{d:A,h:e,m:i,s}}function xE(n,A){let e=1/0,i=null,s=-1;for(let o=0;o<A.length;o++){let a=A[o][0];Math.abs(a-n)<e&&(e=Math.abs(a-n),i=A[o],s=o)}return[s,i]}class cn{#A={};#e=Ii();#t=Intl.DateTimeFormat().resolvedOptions().timeZone;static timeUnits=Sg;static timeUnitsLong=Rg;static timeUnitsValues=Se;static timeScaleValues=Se;static BTCGenesis=si;constructor(A){A instanceof ti&&(this.#A=A),this.setTimeZone(Intl.DateTimeFormat().resolvedOptions().timeZone)}get range(){return this.#A}get timeFrameMS(){return this.#A.interval}get timeFrame(){return this.#A.intervalStr}set timeZone(A){this.setTimeZone(A)}get timeZone(){return this.#t}set timeZoneOffset(A){this.#e=G(A)?A:new Date().getTimezoneOffset()}get timeZoneOffset(){return this.#e}get timeZoneLocal(){return tn()}get indexed(){return this.#A.indexed}setTimeZone(A){Intl.supportedValuesOf("timeZone").includes(A)&&(this.#t=A,this.#e=Ii(A))}isValidTimestamp(A){return Re(A)}isValidTimeInRange(A,e=si,i=Date.now()){return Wi(A,e,i)}interval2MS(A){return Le(A)}ms2Interval(A){return qA(A)}static timezoneLocal(){return tn()}static timezoneOffset(A,e){return Ii(A,e)}static IANATimeZone(A){return qg(A)}static isValidTimestamp(A){return Re(A)}static isValidTimeInRange(A,e=si,i=Date.now()){return Wi(A,e,i)}static interval2MS(A){return Le(A)}static ms2Interval(A){return qA(A)}}function qg(n="en-US"){const A={};return Intl.supportedValuesOf("timeZone").forEach(e=>{let i=Ii(e,n);A[e]=i}),A}function Ii(n=Intl.DateTimeFormat().resolvedOptions().timeZone,A="en-US"){const e=new Date,i=e.toLocaleString(A,{timeZone:n}),s=e.toLocaleString(A);return-((Date.parse(s)-Date.parse(i))/36e5+e.getTimezoneOffset()/60)}const OE=Object.freeze(Object.defineProperty({__proto__:null,BTCGENESIS:si,DAY_MS:hA,HM:hn,HMS:PE,HOUR_MS:GA,IANATimeZones:qg,INTERVALMAX:KE,INTERVALMIN:GE,MILLISECOND:Pe,MINUTE_MS:wA,MONTHMAP:RE,MONTHR_MS:XA,MONTH_MS:Ng,MS:En,SECOND_MS:fA,TIMEFRAMEMAX:Fg,TIMEFRAMEMIN:Kg,TIMESCALES:oi,TIMESCALESKEYS:FE,TIMESCALESRANK:en,TIMESCALESVALUES:Se,TIMESCALESVALUESKEYS:bE,TIMEUNITS:Sg,TIMEUNITSLONG:Rg,TIMEUNITSVALUES:LE,TIMEUNITSVALUESLONG:Gg,TIMEUNITSVALUESSHORT:ni,TimeData:cn,WEEK_MS:Bt,YEAR_MS:te,buildSubGrads:kE,dayCntInc:ME,dayCntLeapInc:SE,dayOfYear:TE,day_start:ri,defaultTimeFrames:NE,getTimezone:tn,getTimezoneOffset:Ii,get_day:In,get_dayName:Tg,get_hour:vg,get_minute:kg,get_month:gn,get_monthName:Ug,get_second:bg,get_year:xg,hour_start:rn,interval2MS:Le,isLeapYear:Zi,isTimeFrame:Yi,isTimeFrameMS:sn,isValidTimeInRange:Wi,isValidTimestamp:Re,minute_start:an,monthDayCnt:Lg,month_start:ln,ms2Interval:qA,ms2TimeUnits:nn,nearestTs:xE,nextMonth:Pg,nextYear:Og,second_start:on,time_start:Vi,timestampDiff:xe,timestampDifference:vE,unitRange:UE,year_start:Cn},Symbol.toStringTag,{value:"Module"}));function k(n){return Array.isArray(n)}function gi(n,A){return k(n)?n.every(e=>hi(A,e)):!1}function J(n){return n&&typeof n=="function"}function Q(n){return typeof n=="object"&&!Array.isArray(n)&&n!==null}function Bn(n,A,e){if(!Q(n)||!Q(A))return!1;const i=Object.keys(n),s=Object.keys(A);if(e&&!Hi(i,s))return!1;for(let o of s)if(!hi(A[o],n[o]))return!1;return!0}function G(n){return typeof n=="number"&&!isNaN(n)}function H(n){return typeof n=="number"&&Math.abs(n%1)===0}function Jg(n){return n!=null}function EA(n){return typeof n=="boolean"}function S(n){return typeof n=="string"}function Hg(n){return n instanceof Map}function li(n){return!!n&&(Q(n)||J(n))&&J(n.then)&&n[Symbol.toStringTag]==="Promise"}function _g(n){return n instanceof Error}function Ci(n){return!(n&&n.constructor===Function)||n.prototype===void 0||Object.getOwnPropertyNames(n).includes("arguments")||Object.getOwnPropertyNames(n).includes("arguments")||Object.getOwnPropertyNames(n).includes("arguments")?!1:Function.prototype!==Object.getPrototypeOf(n)?!0:Object.getOwnPropertyNames(n.prototype).length>1}const Wg=["array","error","class","function","map","promise","object","integer","number","boolean","string"];function hi(n,A){const e=[...Wg,"timestamp","valid"];if(A==null||!e.includes(n))return!1;switch(n){case"array":return k(A);case"function":return J(A);case"object":return Q(A);case"integer":return H(A);case"number":return G(A);case"valid":return Jg(A);case"boolean":return EA(A);case"string":return S(A);case"map":return Hg(A);case"promise":return li(A);case"error":return _g(A);case"class":return Ci(A);case"timestamp":return Re(A);default:throw new Error(`No known test for type: ${n}`)}}function qE(n){for(let A of Wg)try{if(hi(A,n))return A}catch{return typeof n}}const JE=Object.freeze(Object.defineProperty({__proto__:null,checkType:hi,isArray:k,isArrayOfType:gi,isBoolean:EA,isClass:Ci,isError:_g,isFunction:J,isInteger:H,isMap:Hg,isNumber:G,isObject:Q,isObjectOfTypes:Bn,isPromise:li,isString:S,isValid:Jg,typeOf:qE},Symbol.toStringTag,{value:"Module"})),Yg=["id","class","style","alt","width","height","title"],Zg=[...Yg,"name","type","value","default","placeholder","max","min","maxlenght","src","checked","disabled","pattern","readonly","required","size","step","multiple","autofocus","list","autocomplete"],HE=["button","color","date","datetime-local","email","file","hidden","image","month","number","password","radio","range","reset","search","submit","tel","text","time","url","week"];function _E(n,A=document){return A.getElementById(n)}function WE(n,A=document){return A.getElementsByClassName(n)}function YE(n,A=document){return A.getElementsByName(n)}function ZE(n,A=document){return A.getElementsByTagName(n)}function Vg(n,A=document){return A.querySelector(n)}function Xg(n,A=document){return A.querySelectorAll(n)}function VE(n){return typeof Node=="object"?n instanceof Node:n&&typeof n=="object"&&typeof n.nodeType=="number"&&typeof n.nodeName=="string"}function IA(n){return typeof HTMLElement=="object"?n instanceof HTMLElement:n&&typeof n=="object"&&n!==null&&n.nodeType===1&&typeof n.nodeName=="string"}function $e(n){return IA(n)?!!n&&!!(n.offsetWidth||n.offsetHeight||n.getClientRects().length):!1}function Qn(n){if(!IA(n))return!1;const A=n.getBoundingClientRect();return A.top>=0&&A.left>=0&&A.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&A.right<=(window.innerWidth||document.documentElement.clientWidth)}function XE(n){if(!IA(n))return!1;const A=getComputedStyle(n);if(A.display==="none"||A.visibility!=="visible"||parseFloat(A.opacity)<.1||n.offsetWidth+n.offsetHeight+n.getBoundingClientRect().height+n.getBoundingClientRect().width===0)return!1;const e={x:n.getBoundingClientRect().left+n.offsetWidth/2,y:n.getBoundingClientRect().top+n.offsetHeight/2};if(e.x<0||e.x>(document.documentElement.clientWidth||window.innerWidth)||e.y<0||e.y>(document.documentElement.clientHeight||window.innerHeight))return!1;let i=document.elementFromPoint(e.x,e.y);do if(i===elem)return!0;while(i=i.parentNode);return!1}function dn(n,A){if(mn(n)){var e=window.URL||window.webkitURL||window;n=new Blob([n],{type:"image/svg+xml"}),n=e.createObjectURL(n)}const i=new Image;if(i.src=n,J(A))i.complete?A(i):(i.onload=()=>A(i),i.onerror=()=>A(!1));else return new Promise(function(s,o){i.complete?s(i):(i.onload=()=>s(i),i.onerror=()=>o(!1))})}function mn(n){return S(n)?/<\s*svg[^>]*>(.*?)<\s*\/\s*svg>/.test(n):!1}function jE(n){return new Promise(A=>{if(document.querySelector(n))return A(document.querySelector(n));const e=new MutationObserver(i=>{document.querySelector(n)&&(e.disconnect(),A(document.querySelector(n)))});e.observe(document.body,{childList:!0,subtree:!0})})}function JA(n){if(!IA(n))return!1;let A=0,e=0,i=n;for(;i&&i.tagName.toLowerCase()!="body"&&!isNaN(i.offsetLeft)&&!isNaN(i.offsetTop);)A+=i.offsetLeft-i.scrollLeft,e+=i.offsetTop-i.scrollTop,i=i.offsetParent;const s=n.getBoundingClientRect();let o=s.right-s.left,a=s.bottom-s.top,r=$e(n),I=Qn(n);return{top:e,bottom:e+a,left:A,right:A+o,width:o,height:a,visible:r,viewport:I}}function $E(n,A){if(!IA(n)||!IA(n))return!1;const e=JA(n),i=JA(A);return{x:e.top-i.top,y:e.left-i.left,el1Location:e,el2Location:i}}function jg(n){if(!S(n))return!1;const A=document.createElement("template");return n=n.trim(),A.innerHTML=n,A.content.firstChild}function zE(n){if(!S(n))return!1;const A=document.createElement("template");return A.innerHTML=n,A.content.childNodes}function Xi(n,A,e){if(!mn(n)||!G(e?.w)||!G(e?.h))return!1;let i=e.w,s=e.h,o=document.createElement("canvas");o.width=i,o.height=s;let a=jg(n);a.style.fill=A,a.setAttribute("width",i),a.setAttribute("height",s),a.xmlns="http://www.w3.org/2000/svg";let r=new XMLSerializer().serializeToString(a),E="data:image/svg+xml;base64,"+btoa(r),f=new Image;return f.setAttribute("width",i),f.setAttribute("height",s),f.onload=()=>{o.getContext("2d").drawImage(f,0,0,i,s)},f.src=E,f}function Au(n){if(!IA(n))return!1;const A=i=>{!n.contains(i.target)&&$e(n)&&(n.style.display="none",e())},e=()=>{document.removeEventListener("click",A)};document.addEventListener("click",A)}function eu(n,A){if(!IA(n))return!1;const e=s=>{!n.contains(s.target)&&$e(n)&&(A(),i())},i=()=>{document.removeEventListener("click",e)};document.addEventListener("click",e)}function $g(n,A){let e,i;if(S(n))e=document.getElementById(n);else if(IA(n))e=n;else return!1;const s=(e.ownerDocument||document).defaultView;return S(A)?(s&&s.getComputedStyle?(A=A.replace(/([A-Z])/g,"-$1").toLowerCase(),i=document.defaultView.getComputedStyle(e,null).getPropertyValue(A)):e.currentStyle&&(i=e.currentStyle[A]),i):!1}function tu(n,A,e,i){let s=Dn(n,A,e,i);if(s)s.i>=0?s.rules[s.i].style[s.property]=s.value:Al(s.styleSheet,s.selector,s.rules,s.index);else return}function iu(n,A,e){let i=Dn(n,A,e,"");(i.styleSheet.deleteRule||i.styleSheet.removeRule)(i.i)}function Dn(n,A,e,i){if(!n||!Q(n))return null;if(n.constructor.name=="HTMLStyleElement")n=n.sheet;else if(n.constructor.name!="CSSStyleSheet")return null;let s=zg(A,e,i);A=s[0],e=s[1],i=s[2];const o=n.cssRules||n.rules;for(var a=o.length-1;a>0&&o[a].selectorText!==A;--a);return{styleSheet:n,rules:o,selector:A,property:e,value:i,i:a}}function zg(n,A,e){return[n=n.toLowerCase().replace(/\s+/g," "),A=A.toLowerCase(),e=e.toLowerCase()]}function Al(n,A,e,i){n.insertRule?n.insertRule(A+"{"+e+"}",i):n.addRule(A,e,i)}function pn(n,A){return!IA(n)||!S(A)?null:n.classList.contains(A)?n:pn(n.parentElement,A)}function el(n,A){let e=S(A?.entry)?A?.entry:"",s=`${S(n)?`<label for="${e}">${n}</label>`:""}<input id="${e}" class="subject" `;for(let o in A)(Zg.includes(o)||/^(data-[^\t\n\f \/>"'=]+)/g.test(o))&&(s+=`${o}="${A[o]}" `);return s+=`>
`}function su(n,A){let e=S(A?.entry)?A?.entry:"",i=S(n)?`<label for="${e}">${n}</label>`:"",s="";for(let a in A?.options)s+=`<option value="${A.options[a]}">${a}</option>`;return`${i}<select id="${e}" class="subject">${s}</select>
`}const nu={addCSSRule:Al,addStyleRule:tu,deleteStyleRule:iu,elementDimPos:JA,elementsDistance:$E,findByClass:WE,findByID:_E,findByName:YE,findBySelector:Vg,findBySelectorAll:Xg,findStyleRule:Dn,findTargetParentWithClass:pn,fndByTag:ZE,getStyle:$g,hideOnClickOutside:Au,htmlAttr:Yg,htmlInput:el,htmlToElement:jg,htmlToElements:zE,inputAttr:Zg,inputTypes:HE,isHTMLElement:IA,isImage:dn,isInViewport:Qn,isNode:VE,isSVG:mn,isVisible:$e,isVisibleToUser:XE,onClickOutside:eu,styleRuleSanitize:zg,svgToImage:Xi,waitForElm:jE},ou=typeof window<"u"&&typeof window.document<"u";typeof process<"u"&&process.versions!=null&&process.versions.node!=null,typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));const au=(n=>typeof n<"u"&&("onorientationchange"in n||typeof n.matchMedia=="function"&&n.matchMedia("(any-pointer:coarse)").matches||typeof navigator<"u"&&(navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0||"ontouchstart"in n||n.DocumentTouch&&document instanceof n.DocumentTouch)))(typeof window<"u"?window:{}),ru={idle:0,dragStart:1,dragging:2};class ze{#A=0;#e=0;constructor(){if(arguments.length===1){const{x:A,y:e}=arguments[0];this.x=A||0,this.y=e||0}else if(arguments.length>1){const[A,e]=arguments;this.x=A||0,this.y=e||0}}set x(A){G(A)&&(this.#A=A)}get x(){return this.#A}set y(A){G(A)&&(this.#e=A)}get y(){return this.#e}clone(){return new ze(this.x,this.y)}}function Iu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var tl={exports:{}};/*! Hammer.JS - v2.0.7 - 2016-04-22
* http://hammerjs.github.io/
*
* Copyright (c) 2016 Jorik Tangelder;
* Licensed under the MIT license */(function(n){(function(A,e,i,s){var o=["","webkit","Moz","MS","ms","o"],a=e.createElement("div"),r="function",I=Math.round,l=Math.abs,E=Date.now;function f(g,C,c){return setTimeout(aA(g,c),C)}function L(g,C,c){return Array.isArray(g)?(R(g,c[C],c),!0):!1}function R(g,C,c){var p;if(g)if(g.forEach)g.forEach(C,c);else if(g.length!==s)for(p=0;p<g.length;)C.call(c,g[p],p,g),p++;else for(p in g)g.hasOwnProperty(p)&&C.call(c,g[p],p,g)}function v(g,C,c){var p="DEPRECATED METHOD: "+C+`
`+c+` AT
`;return function(){var N=new Error("get-stack-trace"),b=N&&N.stack?N.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",Y=A.console&&(A.console.warn||A.console.log);return Y&&Y.call(A.console,p,b),g.apply(this,arguments)}}var U;typeof Object.assign!="function"?U=function(C){if(C===s||C===null)throw new TypeError("Cannot convert undefined or null to object");for(var c=Object(C),p=1;p<arguments.length;p++){var N=arguments[p];if(N!==s&&N!==null)for(var b in N)N.hasOwnProperty(b)&&(c[b]=N[b])}return c}:U=Object.assign;var V=v(function(C,c,p){for(var N=Object.keys(c),b=0;b<N.length;)(!p||p&&C[N[b]]===s)&&(C[N[b]]=c[N[b]]),b++;return C},"extend","Use `assign`."),X=v(function(C,c){return V(C,c,!0)},"merge","Use `assign`.");function _(g,C,c){var p=C.prototype,N;N=g.prototype=Object.create(p),N.constructor=g,N._super=p,c&&U(N,c)}function aA(g,C){return function(){return g.apply(C,arguments)}}function tA(g,C){return typeof g==r?g.apply(C&&C[0]||s,C):g}function lA(g,C){return g===s?C:g}function iA(g,C,c){R(_A(C),function(p){g.addEventListener(p,c,!1)})}function LA(g,C,c){R(_A(C),function(p){g.removeEventListener(p,c,!1)})}function KA(g,C){for(;g;){if(g==C)return!0;g=g.parentNode}return!1}function BA(g,C){return g.indexOf(C)>-1}function _A(g){return g.trim().split(/\s+/g)}function FA(g,C,c){if(g.indexOf&&!c)return g.indexOf(C);for(var p=0;p<g.length;){if(c&&g[p][c]==C||!c&&g[p]===C)return p;p++}return-1}function $(g){return Array.prototype.slice.call(g,0)}function z(g,C,c){for(var p=[],N=[],b=0;b<g.length;){var Y=g[b][C];FA(N,Y)<0&&p.push(g[b]),N[b]=Y,b++}return p=p.sort(function(sA,eA){return sA[C]>eA[C]}),p}function ae(g,C){for(var c,p,N=C[0].toUpperCase()+C.slice(1),b=0;b<o.length;){if(c=o[b],p=c?c+N:C,p in g)return p;b++}return s}var xI=1;function at(){return xI++}function kt(g){var C=g.ownerDocument||g;return C.defaultView||C.parentWindow||A}var vt=/mobile|tablet|ip(ad|hone|od)|android/i,ce="ontouchstart"in A,OI=ae(A,"PointerEvent")!==s,qI=ce&&vt.test(navigator.userAgent),rt="touch",JI="pen",Tt="mouse",Ss="kinect",HI=25,NA=1,Ke=2,dA=4,bA=8,Ut=1,ye=2,Fe=4,re=8,we=16,Ie=ye|Fe,Be=re|we,ge=Ie|Be,yi=["x","y"],Ve=["clientX","clientY"];function WA(g,C){var c=this;this.manager=g,this.callback=C,this.element=g.element,this.target=g.options.inputTarget,this.domHandler=function(p){tA(g.options.enable,[g])&&c.handler(p)},this.init()}WA.prototype={handler:function(){},init:function(){this.evEl&&iA(this.element,this.evEl,this.domHandler),this.evTarget&&iA(this.target,this.evTarget,this.domHandler),this.evWin&&iA(kt(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&LA(this.element,this.evEl,this.domHandler),this.evTarget&&LA(this.target,this.evTarget,this.domHandler),this.evWin&&LA(kt(this.element),this.evWin,this.domHandler)}};function Rs(g){var C,c=g.options.inputClass;return c?C=c:OI?C=Si:qI?C=Ct:ce?C=Li:C=xt,new C(g,wi)}function wi(g,C,c){var p=c.pointers.length,N=c.changedPointers.length,b=C&NA&&p-N===0,Y=C&(dA|bA)&&p-N===0;c.isFirst=!!b,c.isFinal=!!Y,b&&(g.session={}),c.eventType=C,_I(g,c),g.emit("hammer.input",c),g.recognize(c),g.session.prevInput=c}function _I(g,C){var c=g.session,p=C.pointers,N=p.length;c.firstInput||(c.firstInput=Ns(C)),N>1&&!c.firstMultiple?c.firstMultiple=Ns(C):N===1&&(c.firstMultiple=!1);var b=c.firstInput,Y=c.firstMultiple,CA=Y?Y.center:b.center,sA=C.center=Gs(p);C.timeStamp=E(),C.deltaTime=C.timeStamp-b.timeStamp,C.angle=fi(CA,sA),C.distance=Pt(CA,sA),Ls(c,C),C.offsetDirection=Fs(C.deltaX,C.deltaY);var eA=Ks(C.deltaTime,C.deltaX,C.deltaY);C.overallVelocityX=eA.x,C.overallVelocityY=eA.y,C.overallVelocity=l(eA.x)>l(eA.y)?eA.x:eA.y,C.scale=Y?It(Y.pointers,p):1,C.rotation=Y?fe(Y.pointers,p):0,C.maxPointers=c.prevInput?C.pointers.length>c.prevInput.maxPointers?C.pointers.length:c.prevInput.maxPointers:C.pointers.length,WI(c,C);var OA=g.element;KA(C.srcEvent.target,OA)&&(OA=C.srcEvent.target),C.target=OA}function Ls(g,C){var c=C.center,p=g.offsetDelta||{},N=g.prevDelta||{},b=g.prevInput||{};(C.eventType===NA||b.eventType===dA)&&(N=g.prevDelta={x:b.deltaX||0,y:b.deltaY||0},p=g.offsetDelta={x:c.x,y:c.y}),C.deltaX=N.x+(c.x-p.x),C.deltaY=N.y+(c.y-p.y)}function WI(g,C){var c=g.lastInterval||C,p=C.timeStamp-c.timeStamp,N,b,Y,CA;if(C.eventType!=bA&&(p>HI||c.velocity===s)){var sA=C.deltaX-c.deltaX,eA=C.deltaY-c.deltaY,OA=Ks(p,sA,eA);b=OA.x,Y=OA.y,N=l(OA.x)>l(OA.y)?OA.x:OA.y,CA=Fs(sA,eA),g.lastInterval=C}else N=c.velocity,b=c.velocityX,Y=c.velocityY,CA=c.direction;C.velocity=N,C.velocityX=b,C.velocityY=Y,C.direction=CA}function Ns(g){for(var C=[],c=0;c<g.pointers.length;)C[c]={clientX:I(g.pointers[c].clientX),clientY:I(g.pointers[c].clientY)},c++;return{timeStamp:E(),pointers:C,center:Gs(C),deltaX:g.deltaX,deltaY:g.deltaY}}function Gs(g){var C=g.length;if(C===1)return{x:I(g[0].clientX),y:I(g[0].clientY)};for(var c=0,p=0,N=0;N<C;)c+=g[N].clientX,p+=g[N].clientY,N++;return{x:I(c/C),y:I(p/C)}}function Ks(g,C,c){return{x:C/g||0,y:c/g||0}}function Fs(g,C){return g===C?Ut:l(g)>=l(C)?g<0?ye:Fe:C<0?re:we}function Pt(g,C,c){c||(c=yi);var p=C[c[0]]-g[c[0]],N=C[c[1]]-g[c[1]];return Math.sqrt(p*p+N*N)}function fi(g,C,c){c||(c=yi);var p=C[c[0]]-g[c[0]],N=C[c[1]]-g[c[1]];return Math.atan2(N,p)*180/Math.PI}function fe(g,C){return fi(C[1],C[0],Ve)+fi(g[1],g[0],Ve)}function It(g,C){return Pt(C[0],C[1],Ve)/Pt(g[0],g[1],Ve)}var bs={mousedown:NA,mousemove:Ke,mouseup:dA},ks="mousedown",gt="mousemove mouseup";function xt(){this.evEl=ks,this.evWin=gt,this.pressed=!1,WA.apply(this,arguments)}_(xt,WA,{handler:function(C){var c=bs[C.type];c&NA&&C.button===0&&(this.pressed=!0),c&Ke&&C.which!==1&&(c=dA),this.pressed&&(c&dA&&(this.pressed=!1),this.callback(this.manager,c,{pointers:[C],changedPointers:[C],pointerType:Tt,srcEvent:C}))}});var vs={pointerdown:NA,pointermove:Ke,pointerup:dA,pointercancel:bA,pointerout:bA},Ts={2:rt,3:JI,4:Tt,5:Ss},kA="pointerdown",Mi="pointermove pointerup pointercancel";A.MSPointerEvent&&!A.PointerEvent&&(kA="MSPointerDown",Mi="MSPointerMove MSPointerUp MSPointerCancel");function Si(){this.evEl=kA,this.evWin=Mi,WA.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}_(Si,WA,{handler:function(C){var c=this.store,p=!1,N=C.type.toLowerCase().replace("ms",""),b=vs[N],Y=Ts[C.pointerType]||C.pointerType,CA=Y==rt,sA=FA(c,C.pointerId,"pointerId");b&NA&&(C.button===0||CA)?sA<0&&(c.push(C),sA=c.length-1):b&(dA|bA)&&(p=!0),!(sA<0)&&(c[sA]=C,this.callback(this.manager,b,{pointers:c,changedPointers:[C],pointerType:Y,srcEvent:C}),p&&c.splice(sA,1))}});var YI={touchstart:NA,touchmove:Ke,touchend:dA,touchcancel:bA},xA="touchstart",Ot="touchstart touchmove touchend touchcancel";function lt(){this.evTarget=xA,this.evWin=Ot,this.started=!1,WA.apply(this,arguments)}_(lt,WA,{handler:function(C){var c=YI[C.type];if(c===NA&&(this.started=!0),!!this.started){var p=Us.call(this,C,c);c&(dA|bA)&&p[0].length-p[1].length===0&&(this.started=!1),this.callback(this.manager,c,{pointers:p[0],changedPointers:p[1],pointerType:rt,srcEvent:C})}}});function Us(g,C){var c=$(g.touches),p=$(g.changedTouches);return C&(dA|bA)&&(c=z(c.concat(p),"identifier")),[c,p]}var qt={touchstart:NA,touchmove:Ke,touchend:dA,touchcancel:bA},ZI="touchstart touchmove touchend touchcancel";function Ct(){this.evTarget=ZI,this.targetIds={},WA.apply(this,arguments)}_(Ct,WA,{handler:function(C){var c=qt[C.type],p=Ri.call(this,C,c);p&&this.callback(this.manager,c,{pointers:p[0],changedPointers:p[1],pointerType:rt,srcEvent:C})}});function Ri(g,C){var c=$(g.touches),p=this.targetIds;if(C&(NA|Ke)&&c.length===1)return p[c[0].identifier]=!0,[c,c];var N,b,Y=$(g.changedTouches),CA=[],sA=this.target;if(b=c.filter(function(eA){return KA(eA.target,sA)}),C===NA)for(N=0;N<b.length;)p[b[N].identifier]=!0,N++;for(N=0;N<Y.length;)p[Y[N].identifier]&&CA.push(Y[N]),C&(dA|bA)&&delete p[Y[N].identifier],N++;if(CA.length)return[z(b.concat(CA),"identifier"),CA]}var Jt=2500,Ps=25;function Li(){WA.apply(this,arguments);var g=aA(this.handler,this);this.touch=new Ct(this.manager,g),this.mouse=new xt(this.manager,g),this.primaryTouch=null,this.lastTouches=[]}_(Li,WA,{handler:function(C,c,p){var N=p.pointerType==rt,b=p.pointerType==Tt;if(!(b&&p.sourceCapabilities&&p.sourceCapabilities.firesTouchEvents)){if(N)VI.call(this,c,p);else if(b&&XI.call(this,p))return;this.callback(C,c,p)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function VI(g,C){g&NA?(this.primaryTouch=C.changedPointers[0].identifier,ht.call(this,C)):g&(dA|bA)&&ht.call(this,C)}function ht(g){var C=g.changedPointers[0];if(C.identifier===this.primaryTouch){var c={x:C.clientX,y:C.clientY};this.lastTouches.push(c);var p=this.lastTouches,N=function(){var b=p.indexOf(c);b>-1&&p.splice(b,1)};setTimeout(N,Jt)}}function XI(g){for(var C=g.srcEvent.clientX,c=g.srcEvent.clientY,p=0;p<this.lastTouches.length;p++){var N=this.lastTouches[p],b=Math.abs(C-N.x),Y=Math.abs(c-N.y);if(b<=Ps&&Y<=Ps)return!0}return!1}var xs=ae(a.style,"touchAction"),Os=xs!==s,Ni="compute",Gi="auto",Ki="manipulation",Me="none",be="pan-x",ke="pan-y",Ht=$I();function _t(g,C){this.manager=g,this.set(C)}_t.prototype={set:function(g){g==Ni&&(g=this.compute()),Os&&this.manager.element.style&&Ht[g]&&(this.manager.element.