UNPKG

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.

1,794 lines 1.02 MB
function vh(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 ni = "TradeX-Chart", We = "TX", Th = "tradeXutils", XI = "tradeXmenus", Uh = "tradeXmenu", jI = "tradeXdividers", $I = "tradeXwindows", Ph = "tradeXwindow", zI = "tradeXprogress", xh = 500, dl = "stream_None", Ii = "stream_Listening", js = "stream_Started", ml = "stream_Stopped", Oh = "stream_Error", gs = "stream_candleFirst", ye = "stream_candleUpdate", ls = "stream_candleNew", qh = 250, Jh = 8, Ag = 2, Hh = 2, Dl = 18, Qi = 100, gi = /^(\d*\.?\d+)\s?(px|em|ex|%|in|cn|mm|pt|pc+)$/igm, _h = 6e4, Cs = "1m", hs = _h, eg = 0.05, Wh = 100, tg = 100, vn = 0.2, pl = 1.2, Nt = 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 tS = Z.types, Tn = 30, ji = 200, Un = 200, Pn = 20, xn = 1920, ys = 5, ig = 50, sg = 30, Yh = 8, On = 30, Zh = [!0, "top"]; class LA { static t = 0; static o = 1; static h = 2; static l = 3; static c = 4; static v = 5; } const $i = { mainPane: {}, primaryPane: {}, secondaryPane: {}, scale: {}, timeline: {} }; Array.from(Object.keys($i)); function Vh(n, A) { return n = Math.ceil(n) + 1, A = Math.floor(A), Math.floor(Math.random() * (A - n) + n); } function zi(n) { const A = {}; return A.value = n, A.sign = !!n, A.integers = yl(n), A.decimals = Xh(n), A.total = A.integers + A.decimals, A; } function yl(n) { return (Math.log10((n ^ n >> 31) - (n >> 31)) | 0) + 1; } function ue(n, A = 0) { var e = n * Math.pow(10, A), i = Math.round(e), s = (e > 0 ? e : -e) % 1 === 0.5 ? i % 2 === 0 ? i : i - 1 : i; return s / Math.pow(10, A); } function Xh(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 qn(n, A) { if (n == 0) return "0"; const e = zi(n); if (H(A)) return `${new Number(e.value).toFixed(A)}`; let { sign: i, integers: s, decimals: o, value: a } = e; A = isNaN(A) ? Dl : A, o = $(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 jh(n) { return Math.log(n) / Math.log(10); } function $(n, A, e) { return Math.min(e, Math.max(A, n)); } function $h(n) { const e = Math.abs(n).toString(16); return e.length % 2 === 0 ? e : "0" + e; } let zh = Object.prototype.hasOwnProperty; function AE(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 eE(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]; (!zh.call(i, a) || !Q(i[a])) && (i[a] = {}), i = i[a]; } return i[s] = e; } function tE(n, A) { let e = Object.getPrototypeOf(A); for (; n--; ) e = Object.getPrototypeOf(e); return e; } function ce(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] = ce(i.concat([]), s) : Q(i) && Q(s) ? n[e] = ce(Object.assign({}, i), s) : n[e] = s; }), n); } function lo(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] = lo(n[i])); return e; } function gA(n) { try { return structuredClone(n); } catch { return lo(n); } } function wl(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 + ": " + wl(n[s], (A || 1) + 1); }).join(",") + ` ` + e + "}]"[+i]; default: return n.toString(); } } function fl(n, A) { if (Q(n)) for (let e in n) typeof n[e] == "object" && n[e] !== null ? fl(n[e], A) : n.hasOwnProperty(e) && A(e, n[e]); } const Ml = (n, A, e) => { if (n.Id === A) return e(n); for (let i in n) n[i] !== null && typeof n[i] == "object" && (n[i] = Ml(n[i], A, e)); return n; }; function iE(n, A) { n.split("."); } function Co(n, A, e) { const [i, ...s] = A.split("."); return { ...n, [i]: s.length ? Co(n[i], s.join("."), e) : e }; } function Jn(n, A) { return A.split(".").reduce((i, s) => i && i[s] !== "undefined" ? i[s] : void 0, n); } class sE { 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 ws(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 (!ws(n[e], A[e])) return !1; continue; } if (Q(n[e]) || Q(n[e])) { if (!It(n[e], A[e])) return !1; continue; } if (n[e] !== A[e]) return !1; } return !0; } function nE(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 Sl(n, A, e) { let i = n[A]; n.splice(A, 1), n.splice(e, 0, i); } function Rl(n, A, e) { [n[A], n[e]] = [n[e], n[A]]; } function fs(n, A) { return k(A) ? k(n) ? n.every((e) => A.includes(e)) : A.includes(n) : !1; } const oE = (n) => [...new Set(n)], aE = (n, A) => Object.values(n.reduce((e, i) => (e[A(i)] = i, e), {})), rE = (n, A) => n.filter((e) => A.includes(e)), di = (n, A) => n.filter((e) => !A.includes(e)), IE = (n, A) => di(n, A).concat(di(A, n)), gE = (n, A) => di(n, A).concat(A); function lE(n) { return !(!Q(n) || Object.keys.length); } function Ll(n) { return Q(n) ? !!Object.keys(n).length : !1; } function It(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) ? ws(r, I) : Q(r) || Q(I) ? It(r, I) : r === I; }); } function yA(n = "ID") { K(n) ? n = n.toString() : S(n) || (n = "ID"), n = Ye(n); const A = Date.now().toString(36), e = Math.random().toString(36).substring(2, 5); return `${n}_${A}_${e}`; } function Ye(n) { return String(n).replace(/ |,|;|:|\.|#/g, "_"); } function CE(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 hE(n, A) { return A instanceof Map ? { dataType: "Map", value: [...A.entries()] } : A; } function EE(n, A) { return typeof A == "object" && A !== null && A.dataType === "Map" ? new Map(A.value) : A; } const Nl = (n) => n.entries().next().value, Gl = (n) => n.entries().next().value[0], Kl = (n) => n.entries().next().value[1], Fl = (n) => [...n].pop(), bl = (n) => [...n.keys()].pop(), kl = (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 Nl(this); } firstKey() { return Gl(this); } firstValue() { return Kl(this); } lastEntry() { return Fl(this); } lastKey() { return bl(this); } lastValue() { return kl(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 (!K(A)) return !1; const s = [...this]; return s.splice(A, 0, [e, i]), this.populate(s), !0; } removeIndex(A) { if (!K(A)) return !1; const e = [...this]; return e.splice(A, 1), this.populate(e), !0; } swapIndices(A, e) { if (!K(A) || !K(e)) return !1; const i = [...this]; return Rl(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 zA(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 vl(n, A = 250, e) { let i, s, o = function() { let r = e || this, I = /* @__PURE__ */ 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 uE = (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 cE(n) { const A = {}; return Promise.race([n, A]).then((e) => e === A ? "pending" : "fulfilled", () => "rejected"); } class BE { constructor() { this.promise = new Promise((A, e) => { this.resolve = A, this.reject = e; }); } } function Tl(n) { return String.fromCharCode.apply(null, new Uint16Array(n)); } function Ul(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 QE(n) { const A = document.createElement("canvas"), e = A.getContext("2d"); let i; n.isView(n) ? i = n : typeof n == "string" && (i = Ul(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" ? Tl(o) : o; A(a); }); } class mA { static #A = new pA(); static get entries() { return mA.#A; } static isValid(A, e, i, s) { return !Q(A) || !lA(e) || !S(i) || !J(s); } static add(A, e, i, s) { if (!this.isValid(A, e, i, s)) return !1; e.addEventListener(i, s), mA.#A.has(A) || mA.#A.set(A, new pA()); const o = mA.#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 (!mA.isValid(A, e, i, s) || !mA.#A.has(A)) return !1; const o = mA.#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 && mA.#A.delete(A), !0); } static expungeEvent(A, e, i) { if (!Q(A) || !lA(e) || !S(i)) return !1; const s = mA.#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) || !lA(e)) return !1; const i = mA.#A.get(A); if (i.has(e)) { let s = i.get(e); for (let o in s) mA.expungeEvent(A, e, o); i.delete(e); } return !0; } static expungeContext(A) { if (!Q(A)) return !1; if (mA.#A.has(A)) { const e = mA.#A.get(A); for (let i of e) mA.expungeElement(A, i); mA.#A.delete(A); } return !0; } static expungeAll() { } static destroy() { for (let A of mA.#A) mA.expungeContext(A); return mA.#A = void 0, !0; } } async function mE(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 DE(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 ho(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 iS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Deferred: BE, DoubleLinkedList: sE, EventHandlers: mA, H: DE, HMAC: mE, _get: AE, _set: eE, ab2str: Tl, arrayMove: Sl, b64toBlob: CE, copyDeep: lo, cyrb53: ho, debounce: zA, decodePNGDataStore: dE, diff: di, doStructuredClone: gA, encodePNGDataStore: QE, extender: uE, findInObjectById: Ml, firstEntryInMap: Nl, firstKeyInMap: Gl, firstValueInMap: Kl, getProperty: Jn, getPrototypeAt: tE, idSanitize: Ye, intersection: rE, isArrayEqual: ws, isObjectAndEmpty: lE, isObjectEqual: It, isObjectNotEmpty: Ll, lastEntryInMap: Fl, lastKeyInMap: bl, lastValueInMap: kl, mergeDeep: ce, nearestArrayValue: nE, objRecurse: fl, objRecurseUpdate: iE, objToString: wl, promiseState: cE, replacer: hE, reviver: EE, setProperty: Co, str2ab: Ul, swapArrayElements: Rl, symDiff: IE, throttle: vl, uid: yA, union: gE, unique: oE, uniqueBy: aE, valuesInArray: fs, xMap: pA }, Symbol.toStringTag, { value: "Module" })); class Es { #A; #e; #t; #i; #s = !0; #n = !1; #o = hs; #a = Cs; #I = 0; #r = ji; valueMin = 0; valueMax = 1; valueDiff = 1; volumeMin = 0; volumeMax = 0; volumeDiff = 0; valueMinIdx = 0; valueMaxIdx = 0; volumeMinIdx = 0; volumeMaxIdx = 0; #g = {}; #l = {}; #C = Tn; #h = ji; #E = Un; #c = Pn; #B = xn; #Q = vn; anchor; constructor(A, e, i) { if (!Q(i) || !(i?.core instanceof Y)) throw new Error("Range requires a config"); this.#A = yA(`${We}_Range`), this.#s = !0, this.setConfig(i); let s; if (H(i?.interval) ? s = i.interval : S(i?.interval) ? s = ke(i?.interval) : s = hs, this.data.length == 0) { let o = Date.now(); A = this.rangeLimit * -2, e = this.rangeLimit * 2, this.#o = s, this.#a = OA(this.#o), this.anchor = o - o % s; } else this.data.length < 2 ? (this.#o = s, this.#a = OA(this.interval)) : (this.#o = mi(this.data), this.#a = OA(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 = $(i, this.minCandles, this.maxCandles), A > e && ([A, e] = [e, A]), e = $(e, A + this.minCandles, A + i); let s = e - A; A = $(A, this.limitPast * -1, this.dataLength + this.limitFuture - this.minCandles - 1), e = $(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 Y)) throw new Error("Range requires a valid TradeXchart instance"); this.#e = i; let s = H(A?.initialCnt) ? A.initialCnt : Tn; this.#C = this.#e.config?.range?.initialCnt || s, this.#h = H(A?.limitFuture) ? A.limitFuture : ji, this.#E = H(A?.limitPast) ? A.limitPast : Un, this.#Q = K(A?.yAxisBounds) ? A.yAxisBounds : vn, this.#c = H(A?.minCandles) ? A.minCandles : Pn, this.setMaxCandles(A?.maxCandles); } setMaxCandles(A) { let e = this.#e?.MainPane?.graph?.width || Math.floor(this.#e?.parentElement?.clientWidth) || xn; 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 = ue(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 = JA(i, 0, r), l = JA(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], K(_) && _ < E && (E = _, v = I), _ = e[I][2], K(_) && _ > f && (f = _, U = I), _ = e[I][5], K(_) && _ < L && (L = _, V = I), K(_) && _ > R && (R = _, X = I); let oA = f - E, tA = E, aA = f, iA = e[e.length - 1][4] || null, SA = o.core.stream?.lastTick[4] || null, NA = o.core.stream?.lastPriceMin || null, uA = o.core.stream?.lastPriceMax || null; return E -= oA * o.yAxisBounds, E = E > 0 ? E : 0, f += oA * o.yAxisBounds, oA = f - E, { valueLo: tA, valueHi: aA, valueMin: E, valueMax: f, valueDiff: f - E, valueLast: iA, valueLive: SA, valueLiveMin: NA, valueLiveMax: uA, volumeMin: L, volumeMax: R, volumeDiff: R - L, valueMinIdx: v, valueMaxIdx: U, volumeMinIdx: V, volumeMaxIdx: X }; function JA(GA, j, z) { return Math.min(z, Math.max(j, GA)); } } 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 = ue(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 = $(i, 0, r), R = $(s, 0, r), v, U, V, X, _, oA, tA, aA; 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], K && (U <= V && (E[iA].min = U, E[iA].minIdx = v, V = U), U >= X && (E[iA].max = U, E[iA].maxIdx = v, X = U)); (oA === void 0 || V < oA) && (oA = V), (tA === void 0 || X > tA) && (tA = X), _ = E[iA].max - E[iA].min, E[iA].diff = isNaN(_) ? 0 : _, --l; } return aA = tA - oA, oA -= aA * this.yAxisBounds, tA += aA * this.yAxisBounds, aA = tA - oA, E.data = { min: oA, max: tA, diff: tA - oA }, 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 pE) A.includes(i) || (e[i] = this[i]); return e; } } function mi(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 pE = [ "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" ], Pl = ["y", "M", "d", "h", "m", "s", "ms"], xl = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"], yE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], wE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335], Ol = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], fE = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], ui = 1231006505e3, Oe = 1, fA = 1e3, DA = fA * 60, vA = DA * 60, CA = vA * 24, qt = CA * 7, $A = CA * 30; function ql(n = 3, A = !1) { let e = Ol[n % 12] * CA; return A && n > 0 && (e += CA), e; } const Ie = CA * 365, Di = { y: Ie, M: $A, w: qt, d: CA, h: vA, m: DA, s: fA, u: Oe }, Jl = { years: Ie, months: $A, weeks: qt, days: CA, hours: vA, minutes: DA, seconds: fA, milliseconds: Oe }, ME = { ...Di, ...Jl }, Fe = { YEARS10: [Ie * 10, "years", 10], YEARS5: [Ie * 5, "years", 5], YEARS3: [Ie * 3, "years", 3], YEARS2: [Ie * 2, "years", 2], YEARS: [Ie, "years", 1], MONTH6: [$A * 6, "months", 6], MONTH4: [$A * 4, "months", 4], MONTH3: [$A * 3, "months", 3], MONTH2: [$A * 2, "months", 2], MONTH: [$A, "months", 1], DAY15: [CA * 15, "years", 15], DAY10: [CA * 10, "days", 10], DAY7: [CA * 7, "days", 7], DAY5: [CA * 5, "days", 5], DAY3: [CA * 3, "days", 3], DAY2: [CA * 2, "days", 2], DAY: [CA, "days", 1], HOUR12: [vA * 12, "hours", 12], HOUR6: [vA * 6, "hours", 6], HOUR4: [vA * 4, "hours", 4], HOUR3: [vA * 3, "hours", 3], HOUR2: [vA * 2, "hours", 2], HOUR: [vA, "hours", 1], MINUTE30: [DA * 30, "minutes", 30], MINUTE15: [DA * 15, "minutes", 15], MINUTE10: [DA * 10, "minutes", 10], MINUTE5: [DA * 5, "minutes", 5], MINUTE3: [DA * 3, "minutes", 3], MINUTE2: [DA * 2, "minutes", 2], MINUTE: [DA, "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: [Oe * 500, "milliseconds", 500], MILLISECOND250: [Oe * 250, "milliseconds", 250], MILLISECOND100: [Oe * 100, "milliseconds", 100], MILLISECOND50: [Oe * 50, "milliseconds", 50], MILLISECOND: [Oe, "milliseconds", 1] }, Eo = {}; for (let n of Object.values(Fe)) { let A = n[0], e = OA(A); A < 6e4 || (Eo[`${e}`] = A); } Object.freeze(Eo); const SE = Eo, Hl = DA, RE = Hl, _l = Fe.YEARS10[0], LE = _l, NE = () => { const n = Object.values(Fe), A = []; for (let e = n.length; --e; e > 0) A[e] = n[e][0]; return A; }, li = NE(), GE = () => { const n = Object.values(Fe), A = []; for (let e = n.length; --e; e > 0) A[e] = n[e][1]; return A; }, Hn = GE(), KE = Object.keys(Fe), FE = () => { const n = {}; for (const [A, e] of Object.entries(Fe)) n[A] = e[0]; return n; }, bE = FE(); function _n() { const n = (/* @__PURE__ */ new Date()).getTimezoneOffset(); return Object.prototype.hasOwnProperty.call(timezones, n) ? timezones[n.toString()] : "Etc/UTC"; } function kE() { const n = {}; for (let A in Di) { let e = 0; n[A] = []; do n[A].push(Math.round(Di[A] * e)), e += 0.125; while (e < 1); } return n; } function be(n) { const A = new Date(n); return A instanceof Date && !isNaN(A.valueOf()) && isFinite(A.valueOf()); } function us(n, A = ui, e = Date.now()) { return be(n) ? n > A && n < e : !1; } function oi(n, A, e) { n = new Date(n), A = new Date(A); var i = A.getTime(), s = n.getTime(); return parseInt((i - s) / e); } const Ue = { inSeconds: function(n, A) { return oi(n, A, fA); }, inMinutes: function(n, A) { return oi(n, A, DA); }, inHours: function(n, A) { return oi(n, A, vA); }, inDays: function(n, A) { return oi(n, A, CA); }, inWeeks: function(n, A) { return oi(n, A, qt); }, 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 = Ue.inYears(n, A), i = Ue.inMonths(n, A), s = Ue.inWeeks(n, A), o = Ue.inDays(n, A), a = Ue.inHours(n, A), r = Ue.inMinutes(n, A), I = Ue.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 uo(n) { return H(n) && !(n < fA) && n !== 1 / 0; } function Ms(n) { let A = fA; return S(n) ? (A = ke(n), A ? n = n : (A = fA, n = "1s")) : H(n) ? (A = n, n = OA(n)) : n = "1s", { tf: n, ms: A }; } function ke(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 ? Di[e[2]] * e[1] : !1; } function co(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 OA(n) { const A = co(n); for (const e in A) if (A[e]) return `${A[e]}${e}`; } function Wl(n) { return n ? new Date(n).getUTCSeconds() : null; } function Bo(n) { return new Date(n).setUTCMilliseconds(0, 0); } function Yl(n) { return n ? new Date(n).getUTCMinutes() : null; } function Qo(n) { return new Date(n).setUTCSeconds(0, 0); } function Zl(n) { return n ? new Date(n).getUTCHours() : null; } function mo(n) { return new Date(n).setUTCMinutes(0, 0, 0); } function Do(n) { return n ? new Date(n).getUTCDate() : null; } function Vl(n, A = "en-GB", e = "short") { return new Date(n).toLocaleDateString(A, { weekday: e }); } function pi(n) { return new Date(n).setUTCHours(0, 0, 0, 0); } function po(n) { if (n) return new Date(n).getUTCMonth(); } function Xl(n, A = "en-GB", e = "short") { return new Date(n).toLocaleDateString(A, { month: e }); } function yo(n) { let A = new Date(n); return Date.UTC( A.getUTCFullYear(), A.getUTCMonth(), 1 ); } function jl(n) { let A = (po(n) + 1) % 12; return n += ql(A, Ss(n)), n; } function $l(n) { if (n) return new Date(n).getUTCFullYear(); } function wo(n) { return Date.UTC(new Date(n).getUTCFullYear()); } function zl(n) { return n = n + Ie + CA, Ss(n), n; } function Ss(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 && Ss() && s++, s; } function As(n, A) { return { years: (i) => wo(i), months: (i) => yo(i), weeks: (i) => pi(i), days: (i) => pi(i), hours: (i) => mo(i), minutes: (i) => Qo(i), seconds: (i) => Bo(i) }[A](n); } function UE(n, A) { let e, i; switch (A) { case "years": e = wo(n), i = zl(n); break; case "months": e = yo(n), i = jl(n); break; case "weeks": e = pi(n), i = e + CA; break; case "days": e = pi(n), i = e + CA; break; case "hours": e = mo(n), i = e + vA; break; case "minutes": e = Qo(n), i = e + DA; break; case "seconds": e = Bo(n), i = e + fA; } return { start: e, end: i }; } function Wn(n) { let { h: A, m: e } = fo(n); return A == 0 && e == 0 ? `${d}` : `${A}:${e}`; } function PE(n) { let { h: A, m: e, s: i } = fo(n); return A == 0 && e == 0 && i == 0 ? `${d}` : `${A}:${e}:${i}`; } function Yn(n) { let { h: A, m: e, s: i } = fo(n); return A == 0 && e == 0 && i == 0 ? `${d}` : `${e}:${i}`; } function fo(n) { let A, e, i, s; return A = String(Do(n)), e = String(Zl(n)).padStart(2, "0"), i = String(Yl(n)).padStart(2, "0"), s = String(Wl(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 AC { #A = {}; #e = ci(); #t = Intl.DateTimeFormat().resolvedOptions().timeZone; static timeUnits = Pl; static timeUnitsLong = xl; static timeUnitsValues = Fe; static timeScaleValues = Fe; static BTCGenesis = ui; constructor(A) { A instanceof Es && (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 = K(A) ? A : (/* @__PURE__ */ new Date()).getTimezoneOffset(); } get timeZoneOffset() { return this.#e; } get timeZoneLocal() { return _n(); } get indexed() { return this.#A.indexed; } setTimeZone(A) { Intl.supportedValuesOf("timeZone").includes(A) && (this.#t = A, this.#e = ci(A)); } isValidTimestamp(A) { return be(A); } isValidTimeInRange(A, e = ui, i = Date.now()) { return us(A, e, i); } interval2MS(A) { return ke(A); } ms2Interval(A) { return OA(A); } static timezoneLocal() { return _n(); } static timezoneOffset(A, e) { return ci(A, e); } static IANATimeZone(A) { return eC(A); } static isValidTimestamp(A) { return be(A); } static isValidTimeInRange(A, e = ui, i = Date.now()) { return us(A, e, i); } static interval2MS(A) { return ke(A); } static ms2Interval(A) { return OA(A); } } function eC(n = "en-US") { const A = {}; return Intl.supportedValuesOf("timeZone").forEach((e) => { let i = ci(e, n); A[e] = i; }), A; } function ci(n = Intl.DateTimeFormat().resolvedOptions().timeZone, A = "en-US") { const e = /* @__PURE__ */ 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 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, BTCGENESIS: ui, DAY_MS: CA, HM: Wn, HMS: PE, HOUR_MS: vA, IANATimeZones: eC, INTERVALMAX: LE, INTERVALMIN: RE, MILLISECOND: Oe, MINUTE_MS: DA, MONTHMAP: fE, MONTHR_MS: $A, MONTH_MS: ql, MS: Yn, SECOND_MS: fA, TIMEFRAMEMAX: _l, TIMEFRAMEMIN: Hl, TIMESCALES: li, TIMESCALESKEYS: KE, TIMESCALESRANK: Hn, TIMESCALESVALUES: Fe, TIMESCALESVALUESKEYS: bE, TIMEUNITS: Pl, TIMEUNITSLONG: xl, TIMEUNITSVALUES: ME, TIMEUNITSVALUESLONG: Jl, TIMEUNITSVALUESSHORT: Di, TimeData: AC, WEEK_MS: qt, YEAR_MS: Ie, buildSubGrads: kE, dayCntInc: yE, dayCntLeapInc: wE, dayOfYear: TE, day_start: pi, defaultTimeFrames: SE, getTimezone: _n, getTimezoneOffset: ci, get_day: Do, get_dayName: Vl, get_hour: Zl, get_minute: Yl, get_month: po, get_monthName: Xl, get_second: Wl, get_year: $l, hour_start: mo, interval2MS: ke, isLeapYear: Ss, isTimeFrame: Ms, isTimeFrameMS: uo, isValidTimeInRange: us, isValidTimestamp: be, minute_start: Qo, monthDayCnt: Ol, month_start: yo, ms2Interval: OA, ms2TimeUnits: co, nearestTs: xE, nextMonth: jl, nextYear: zl, second_start: Bo, time_start: As, timestampDiff: Ue, timestampDifference: vE, unitRange: UE, year_start: wo }, Symbol.toStringTag, { value: "Module" })); function k(n) { return Array.isArray(n); } function Si(n, A) { return k(n) ? n.every((e) => Ri(A, e)) : !1; } function J(n) { return n && typeof n == "function"; } function Q(n) { return typeof n == "object" && !Array.isArray(n) && n !== null; } function Mo(n, A, e) { if (!Q(n) || !Q(A)) return !1; const i = Object.keys(n), s = Object.keys(A); if (e && !ws(i, s)) return !1; for (let o of s) if (!Ri(A[o], n[o])) return !1; return !0; } function K(n) { return typeof n == "number" && !isNaN(n); } function H(n) { return typeof n == "number" && Math.abs(n % 1) === 0; } function tC(n) { return n != null; } function hA(n) { return typeof n == "boolean"; } function S(n) { return typeof n == "string"; } function iC(n) { return n instanceof Map; } function Rs(n) { return !!n && (Q(n) || J(n)) && J(n.then) && n[Symbol.toStringTag] === "Promise"; } function sC(n) { return n instanceof Error; } function yi(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 nC = [ "array", "error", "class", "function", "map", "promise", "object", "integer", "number", "boolean", "string" ]; function Ri(n, A) { const e = [...nC, "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 K(A); case "valid": return tC(A); case "boolean": return hA(A); case "string": return S(A); case "map": return iC(A); case "promise": return Rs(A); case "error": return sC(A); case "class": return yi(A); case "timestamp": return be(A); default: throw new Error(`No known test for type: ${n}`); } } function qE(n) { for (let A of nC) try { if (Ri(A, n)) return A; } catch { return typeof n; } } const sS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, checkType: Ri, isArray: k, isArrayOfType: Si, isBoolean: hA, isClass: yi, isError: sC, isFunction: J, isInteger: H, isMap: iC, isNumber: K, isObject: Q, isObjectOfTypes: Mo, isPromise: Rs, isString: S, isValid: tC, typeOf: qE }, Symbol.toStringTag, { value: "Module" })), oC = ["id", "class", "style", "alt", "width", "height", "title"], aC = [...oC, "name", "type", "value", "default", "placeholder", "max", "min", "maxlenght", "src", "checked", "disabled", "pattern", "readonly", "required", "size", "step", "multiple", "autofocus", "list", "autocomplete"], JE = ["button", "color", "date", "datetime-local", "email", "file", "hidden", "image", "month", "number", "password", "radio", "range", "reset", "search", "submit", "tel", "text", "time", "url", "week"]; function HE(n, A = document) { return A.getElementById(n); } function _E(n, A = document) { return A.getElementsByClassName(n); } function WE(n, A = document) { return A.getElementsByName(n); } function YE(n, A = document) { return A.getElementsByTagName(n); } function rC(n, A = document) { return A.querySelector(n); } function IC(n, A = document) { return A.querySelectorAll(n); } function ZE(n) { return typeof Node == "object" ? n instanceof Node : n && typeof n == "object" && typeof n.nodeType == "number" && typeof n.nodeName == "string"; } function lA(n) { return typeof HTMLElement == "object" ? n instanceof HTMLElement : n && typeof n == "object" && n !== null && n.nodeType === 1 && typeof n.nodeName == "string"; } function Ct(n) { return lA(n) ? !!n && !!(n.offsetWidth || n.offsetHeight || n.getClientRects().length) : !1; } function So(n) { if (!lA(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 VE(n) { if (!lA(n)) return !1; const A = getComputedStyle(n); if (A.display === "none" || A.visibility !== "visible" || parseFloat(A.opacity) < 0.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 Ro(n, A) { if (Lo(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 Lo(n) { return S(n) ? /<\s*svg[^>]*>(.*?)<\s*\/\s*svg>/.test(n) : !1; } function XE(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 qA(n) { if (!lA(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 = Ct(n), I = So(n); return { top: e, bottom: e + a, left: A, right: A + o, width: o, height: a, visible: r, viewport: I }; } function jE(n, A) { if (!lA(n) || !lA(n)) return !1; const e = qA(n), i = qA(A); return { x: e.top - i.top, y: e.left - i.left, el1Location: e, el2Location: i }; } function gC(n) { if (!S(n)) return !1; const A = document.createElement("template"); return n = n.trim(), A.innerHTML = n, A.content.firstChild; } function $E(n) { if (!S(n)) return !1; const A = document.createElement("template"); return A.innerHTML = n, A.content.childNodes; } function cs(n, A, e) { if (!Lo(n) || !K(e?.w) || !K(e?.h)) return !1; let i = e.w, s = e.h, o = document.createElement("canvas"); o.width = i, o.height = s; let a = gC(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 zE(n) { if (!lA(n)) return !1; const A = (i) => { !n.contains(i.target) && Ct(n) && (n.style.display = "none", e()); }, e = () => { document.removeEventListener("click", A); }; document.addEventListener("click", A); } function Au(n, A) { if (!lA(n)) return !1; const e = (s) => { !n.contains(s.target) && Ct(n) && (A(), i()); }, i = () => { document.removeEventListener("click", e); }; document.addEventListener("click", e); } function lC(n, A) { let e, i; if (S(n)) e = document.getElementById(n); else if (lA(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 eu(n, A, e, i) { let s = No(n, A, e, i); if (s) s.i >= 0 ? s.rules[s.i].style[s.property] = s.value : hC(s.styleSheet, s.selector, s.rules, s.index); else return; } function tu(n, A, e) { let i = No(n, A, e, ""); (i.styleSheet.deleteRule || i.styleSheet.removeRule)(i.i); } function No(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 = CC(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 CC(n, A, e) { return [ n = n.toLowerCase().replace(/\s+/g, " "), A = A.toLowerCase(), e = e.toLowerCase() ]; } function hC(n, A, e, i) { n.insert