From 4fbee579f28641afdd97652bd5a28de738867b92 Mon Sep 17 00:00:00 2001 From: PotatoGamo Date: Sun, 5 Oct 2025 02:00:01 -0700 Subject: [PATCH] feat: add hand tracking and painting functionality using ml5.js handPose model - Implemented hand tracking with real-time video capture - Added GUI controls for canvas background, keypoints, connections, and hand settings - Enabled painting with hand gestures, including pinch to draw and clear gesture - Configured rendering options for keypoints and connections - Introduced bounds visualization for detected hands --- default_cam | 19 + index.html | 33 + libraries/ml5.min.js | 23069 +++++++++++++++++++++++++++++++++++++++++ libraries/p5.min.js | 2 + sketch.js | 322 + 5 files changed, 23445 insertions(+) create mode 100755 default_cam create mode 100644 index.html create mode 100644 libraries/ml5.min.js create mode 100644 libraries/p5.min.js create mode 100644 sketch.js diff --git a/default_cam b/default_cam new file mode 100755 index 0000000..f56bc9d --- /dev/null +++ b/default_cam @@ -0,0 +1,19 @@ +#!/bin/bash +# Make default camera /dev/video0 point to the "best" camera present. + +if [ -h /dev/video0 ]; then + sudo rm /dev/video0 # not first run: remove our old symlink +elif [ -e /dev/video0 ]; then + sudo mv /dev/video0 /dev/video0.original # first run: rename original video0 +fi +if [ -e /dev/video1 ]; then + sudo ln -s /dev/video1 /dev/video0 # symlink to video1 since it exists + echo "Set default camera /dev/video0 --> external camera /dev/video1" +elif [ -e /dev/video0.original ]; then # symlink to video0.original otherwise + sudo ln -s /dev/video0.original /dev/video0 + echo "Set default camera /dev/video0 --> integrated camera /dev/video0.original" +else + echo "Sorry, does this machine have no camera devices?" + ls -l /dev/video* +fi + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..71d07dd --- /dev/null +++ b/index.html @@ -0,0 +1,33 @@ + + + + + + handtracking + + + + + + + + + + + \ No newline at end of file diff --git a/libraries/ml5.min.js b/libraries/ml5.min.js new file mode 100644 index 0000000..365f18b --- /dev/null +++ b/libraries/ml5.min.js @@ -0,0 +1,23069 @@ +!function (e, t) { "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.ml5 = t() : e.ml5 = t() }(self, (() => (() => { + var e = { + 2726: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.g = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.g }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l, c = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) l = Object.setPrototypeOf; else { var h; e: { var d = {}; try { d.__proto__ = { a: !0 }, h = d.a; break e } catch (e) { } h = !1 } l = h ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var f = l; function p(e, t) { if (e.prototype = c(t.prototype), e.prototype.constructor = e, f) f(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.ea = t.prototype } function m() { this.l = !1, this.i = null, this.h = void 0, this.g = 1, this.s = this.m = 0, this.j = null } function g(e) { if (e.l) throw new TypeError("Generator is already running"); e.l = !0 } function y(e, t) { e.j = { U: t, V: !0 }, e.g = e.m || e.s } function b(e, t, n) { return e.g = n, { value: t } } function v(e) { this.g = new m, this.h = e } function x(e, t, n, r) { try { var i = t.call(e.g.i, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.g.l = !1, i; var a = i.value } catch (t) { return e.g.i = null, y(e.g, t), w(e) } return e.g.i = null, r.call(e.g, a), w(e) } function w(e) { for (; e.g.g;)try { var t = e.h(e.g); if (t) return e.g.l = !1, { value: t.value, done: !1 } } catch (t) { e.g.h = void 0, y(e.g, t) } if (e.g.l = !1, e.g.j) { if (t = e.g.j, e.g.j = null, t.V) throw t.U; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function k(e) { this.next = function (t) { return g(e.g), e.g.i ? t = x(e, e.g.i.next, t, e.g.o) : (e.g.o(t), t = w(e)), t }, this.throw = function (t) { return g(e.g), e.g.i ? t = x(e, e.g.i.throw, t, e.g.o) : (y(e.g, t), t = w(e)), t }, this.return = function (t) { return function (e, t) { g(e.g); var n = e.g.i; return n ? x(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.g.return) : (e.g.return(t), w(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function S(e, t) { return t = new k(new v(t)), f && e.prototype && f(t, e.prototype), t } m.prototype.o = function (e) { this.h = e }, m.prototype.return = function (e) { this.j = { return: e }, this.g = this.s }; var _ = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || _ })), a("Promise", (function (e) { function t(e) { this.h = 0, this.i = void 0, this.g = [], this.o = !1; var t = this.j(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.g = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.h = function (e) { if (null == this.g) { this.g = []; var t = this; this.i((function () { t.l() })) } this.g.push(e) }; var a = i.setTimeout; n.prototype.i = function (e) { a(e, 0) }, n.prototype.l = function () { for (; this.g && this.g.length;) { var e = this.g; this.g = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.j(e) } } } this.g = null }, n.prototype.j = function (e) { this.i((function () { throw e })) }, t.prototype.j = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.C), reject: e(this.l) } }, t.prototype.C = function (e) { if (e === this) this.l(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.F(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.u(e) : this.m(e) } }, t.prototype.u = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.l(e) } "function" == typeof t ? this.G(t, e) : this.m(e) }, t.prototype.l = function (e) { this.s(2, e) }, t.prototype.m = function (e) { this.s(1, e) }, t.prototype.s = function (e, t) { if (0 != this.h) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.h); this.h = e, this.i = t, 2 === this.h && this.D(), this.A() }, t.prototype.D = function () { var e = this; a((function () { if (e.B()) { var t = i.console; void 0 !== t && t.error(e.i) } }), 1) }, t.prototype.B = function () { if (this.o) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.i, n(e)) }, t.prototype.A = function () { if (null != this.g) { for (var e = 0; e < this.g.length; ++e)o.h(this.g[e]); this.g = null } }; var o = new n; return t.prototype.F = function (e) { var t = this.j(); e.J(t.resolve, t.reject) }, t.prototype.G = function (e, t) { var n = this.j(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.J(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.J = function (e, t) { function n() { switch (r.h) { case 1: e(r.i); break; case 2: t(r.i); break; default: throw Error("Unexpected state: " + r.h) } } var r = this; null == this.g ? o.h(n) : this.g.push(n), this.o = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).J(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).J(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })); var C = this || self; function A(e, t) { e = e.split("."); var n, r = C; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function T(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var E, N, I = "undefined" != typeof TextDecoder, M = "undefined" != typeof TextEncoder; function F(e) { if (M) e = (N || (N = new TextEncoder)).encode(e); else { var t = void 0; t = void 0 !== t && t; for (var n = 0, r = new Uint8Array(3 * e.length), i = 0; i < e.length; i++) { var a = e.charCodeAt(i); if (128 > a) r[n++] = a; else { if (2048 > a) r[n++] = a >> 6 | 192; else { if (55296 <= a && 57343 >= a) { if (56319 >= a && i < e.length) { var o = e.charCodeAt(++i); if (56320 <= o && 57343 >= o) { a = 1024 * (a - 55296) + o - 56320 + 65536, r[n++] = a >> 18 | 240, r[n++] = a >> 12 & 63 | 128, r[n++] = a >> 6 & 63 | 128, r[n++] = 63 & a | 128; continue } i-- } if (t) throw Error("Found an unpaired surrogate"); a = 65533 } r[n++] = a >> 12 | 224, r[n++] = a >> 6 & 63 | 128 } r[n++] = 63 & a | 128 } } e = r.subarray(0, n) } return e } var D = {}, $ = null; function R(e, t) { void 0 === t && (t = 0), z(), t = D[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } function O(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = $[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } z(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), r.subarray(0, i) } function z() { if (!$) { $ = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); D[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === $[a] && ($[a] = i) } } } } var P, B = "function" == typeof Uint8Array.prototype.slice; function L(e, t, n) { return t === n ? P || (P = new Uint8Array(0)) : B ? e.slice(t, n) : new Uint8Array(e.subarray(t, n)) } var j = 0; function U(e, t) { t = void 0 !== (t = void 0 === t ? {} : t).v && t.v, this.h = null, this.g = this.j = this.l = 0, this.m = !1, this.v = t, e && W(this, e) } function W(e, t) { t = t.constructor === Uint8Array ? t : t.constructor === ArrayBuffer || t.constructor === Array ? new Uint8Array(t) : t.constructor === String ? O(t) : t instanceof Uint8Array ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(0), e.h = t, e.l = 0, e.j = e.h.length, e.g = e.l } function V(e) { for (var t = 128, n = 0, r = 0, i = 0; 4 > i && 128 <= t; i++)n |= (127 & (t = e.h[e.g++])) << 7 * i; if (128 <= t && (n |= (127 & (t = e.h[e.g++])) << 28, r |= (127 & t) >> 4), 128 <= t) for (i = 0; 5 > i && 128 <= t; i++)r |= (127 & (t = e.h[e.g++])) << 7 * i + 3; if (128 > t) return e = n >>> 0, (r = 2147483648 & (t = r >>> 0)) && (t = ~t >>> 0, 0 == (e = 1 + ~e >>> 0) && (t = t + 1 >>> 0)), e = 4294967296 * t + (e >>> 0), r ? -e : e; e.m = !0 } U.prototype.reset = function () { this.g = this.l }, U.prototype.i = function () { var e = this.h, t = e[this.g], n = 127 & t; return 128 > t ? (this.g += 1, n) : (n |= (127 & (t = e[this.g + 1])) << 7, 128 > t ? (this.g += 2, n) : (n |= (127 & (t = e[this.g + 2])) << 14, 128 > t ? (this.g += 3, n) : (n |= (127 & (t = e[this.g + 3])) << 21, 128 > t ? (this.g += 4, n) : (n |= (15 & (t = e[this.g + 4])) << 28, 128 > t ? (this.g += 5, n >>> 0) : (this.g += 5, 128 <= e[this.g++] && 128 <= e[this.g++] && 128 <= e[this.g++] && 128 <= e[this.g++] && this.g++, n))))) }, U.prototype.o = function () { var e = this.h[this.g], t = this.h[this.g + 1], n = this.h[this.g + 2], r = this.h[this.g + 3]; return this.g += 4, e = 2 * ((n = (e | t << 8 | n << 16 | r << 24) >>> 0) >> 31) + 1, t = n >>> 23 & 255, n &= 8388607, 255 == t ? n ? NaN : 1 / 0 * e : 0 == t ? e * Math.pow(2, -149) * n : e * Math.pow(2, t - 150) * (n + Math.pow(2, 23)) }; var G = []; function H() { this.g = new Uint8Array(64), this.h = 0 } function q(e, t) { for (; 127 < t;)e.push(127 & t | 128), t >>>= 7; e.push(t) } function Y(e) { var t = {}, n = void 0 !== t.N && t.N; this.o = { v: void 0 !== t.v && t.v }, this.N = n, t = this.o, G.length ? (n = G.pop(), t && (n.v = t.v), e && W(n, e), e = n) : e = new U(e, t), this.g = e, this.m = this.g.g, this.h = this.i = this.l = -1, this.j = !1 } function X(e) { var t = e.g; if ((t = t.g == t.j) || (t = e.j) || (t = (t = e.g).m || 0 > t.g || t.g > t.j), t) return !1; e.m = e.g.g; var n = 7 & (t = e.g.i()); return 0 != n && 5 != n && 1 != n && 2 != n && 3 != n && 4 != n ? (e.j = !0, !1) : (e.i = t, e.l = t >>> 3, e.h = n, !0) } function K(e) { switch (e.h) { case 0: if (0 != e.h) K(e); else { for (e = e.g; 128 & e.h[e.g];)e.g++; e.g++ } break; case 1: 1 != e.h ? K(e) : (e = e.g).g += 8; break; case 2: if (2 != e.h) K(e); else { var t = e.g.i(); (e = e.g).g += t } break; case 5: 5 != e.h ? K(e) : (e = e.g).g += 4; break; case 3: for (t = e.l; ;) { if (!X(e)) { e.j = !0; break } if (4 == e.h) { e.l != t && (e.j = !0); break } K(e) } break; default: e.j = !0 } } function Z(e, t, n) { var r = e.g.j, i = e.g.i(), a = e.g.g + i; if (e.g.j = a, n(t, e), 0 !== (n = a - e.g.g)) throw Error("Message parsing ended unexpectedly. Expected to read " + i + " bytes, instead read " + (i - n) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.g.g = a, e.g.j = r, t } function J(e) { return e.g.o() } function Q(e) { var t, n = e.g.i(), r = (e = e.g).g; if (e.g += n, e = e.h, I) (t = E) || (t = E = new TextDecoder("utf-8", { fatal: !1 })), t = t.decode(e.subarray(r, r + n)); else { n = r + n; for (var i, a, o, s = [], u = null; r < n;)128 > (i = e[r++]) ? s.push(i) : 224 > i ? r >= n ? s.push(65533) : (a = e[r++], 194 > i || 128 != (192 & a) ? (r--, s.push(65533)) : s.push((31 & i) << 6 | 63 & a)) : 240 > i ? r >= n - 1 ? s.push(65533) : 128 != (192 & (a = e[r++])) || 224 === i && 160 > a || 237 === i && 160 <= a || 128 != (192 & (t = e[r++])) ? (r--, s.push(65533)) : s.push((15 & i) << 12 | (63 & a) << 6 | 63 & t) : 244 >= i ? r >= n - 2 ? s.push(65533) : 128 != (192 & (a = e[r++])) || a - 144 + (i << 28) >> 30 || 128 != (192 & (t = e[r++])) || 128 != (192 & (o = e[r++])) ? (r--, s.push(65533)) : (i = (7 & i) << 18 | (63 & a) << 12 | (63 & t) << 6 | 63 & o, i -= 65536, s.push(55296 + (i >> 10 & 1023), 56320 + (1023 & i))) : s.push(65533), 8192 <= s.length && (u = T(u, s), s.length = 0); t = T(u, s) } return t } function ee(e, t, n) { var r = e.g.i(); for (r = e.g.g + r; e.g.g < r;)n.push(t.call(e.g)) } function te(e, t) { 2 == e.h ? ee(e, U.prototype.o, t) : t.push(J(e)) } function ne() { this.h = [], this.i = 0, this.g = new H } function re(e, t) { 0 !== t.length && (e.h.push(t), e.i += t.length) } function ie(e) { var t = e.i + e.g.length(); if (0 === t) return new Uint8Array(0); t = new Uint8Array(t); for (var n = e.h, r = n.length, i = 0, a = 0; a < r; a++) { var o = n[a]; 0 !== o.length && (t.set(o, i), i += o.length) } return 0 !== (r = (n = e.g).h) && (t.set(n.g.subarray(0, r), i), n.h = 0), e.h = [t], t } function ae(e, t, n) { if (null != n) { q(e.g, 8 * t + 5), e = e.g; var r = n; 0 === (r = (n = 0 > r ? 1 : 0) ? -r : r) ? 0 < 1 / r ? j = 0 : j = 2147483648 : isNaN(r) ? j = 2147483647 : 34028234663852886e22 < r ? j = (n << 31 | 2139095040) >>> 0 : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), j = (n << 31 | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, j = (n << 31 | t + 127 << 23 | 8388607 & r) >>> 0), n = j, e.push(n >>> 0 & 255), e.push(n >>> 8 & 255), e.push(n >>> 16 & 255), e.push(n >>> 24 & 255) } } H.prototype.push = function (e) { if (!(this.h + 1 < this.g.length)) { var t = this.g; this.g = new Uint8Array(Math.ceil(1 + 2 * this.g.length)), this.g.set(t) } this.g[this.h++] = e }, H.prototype.length = function () { return this.h }, H.prototype.end = function () { var e = this.g, t = this.h; return this.h = 0, L(e, 0, t) }, Y.prototype.reset = function () { this.g.reset(), this.h = this.l = -1 }; var oe = "function" == typeof Uint8Array; function se(e, t, n) { if (null != e) return "object" == typeof e ? oe && e instanceof Uint8Array ? n(e) : ue(e, t, n) : t(e) } function ue(e, t, n) { if (Array.isArray(e)) { for (var r = Array(e.length), i = 0; i < e.length; i++)r[i] = se(e[i], t, n); return Array.isArray(e) && e.W && de(r), r } for (i in r = {}, e) r[i] = se(e[i], t, n); return r } function le(e) { return "number" == typeof e ? isFinite(e) ? e : String(e) : e } var ce, he = { W: { value: !0, configurable: !0 } }; function de(e) { return Array.isArray(e) && !Object.isFrozen(e) && Object.defineProperties(e, he), e } function fe(e, t, n) { var r = ce; if (ce = null, e || (e = r), r = this.constructor.ca, e || (e = r ? [r] : []), this.j = r ? 0 : -1, this.m = this.g = null, this.h = e, e = (r = this.h.length) - 1, !r || (null === (r = this.h[e]) || "object" != typeof r || Array.isArray(r) || oe && r instanceof Uint8Array) ? void 0 !== t && -1 < t ? (this.l = Math.max(t, e + 1 - this.j), this.i = null) : this.l = Number.MAX_VALUE : (this.l = e - this.j, this.i = r), n) for (t = 0; t < n.length; t++)(e = n[t]) < this.l ? (e += this.j, (r = this.h[e]) ? de(r) : this.h[e] = pe) : (me(this), (r = this.i[e]) ? de(r) : this.i[e] = pe) } var pe = Object.freeze(de([])); function me(e) { var t = e.l + e.j; e.h[t] || (e.i = e.h[t] = {}) } function ge(e, t, n) { return -1 === t ? null : void 0 !== n && n || t >= e.l ? e.i ? e.i[t] : void 0 : e.h[t + e.j] } function ye(e, t) { var n = void 0 !== n && n, r = ge(e, t, n); return null == r && (r = pe), r === pe && we(e, t, r = de([]), n), r } function be(e) { var t = ye(e, 3); if (e.m || (e.m = {}), !e.m[3]) { for (var n = 0; n < t.length; n++)t[n] = +t[n]; e.m[3] = !0 } return t } function ve(e, t, n) { return null == (e = ge(e, t)) ? n : e } function xe(e, t, n) { return null == (e = null == (e = ge(e, t)) ? e : +e) ? void 0 === n ? 0 : n : e } function we(e, t, n, r) { void 0 !== r && r || t >= e.l ? (me(e), e.i[t] = n) : e.h[t + e.j] = n } function ke(e, t, n) { if (-1 === n) return null; if (e.g || (e.g = {}), !e.g[n]) { var r = ge(e, n, !1); r && (e.g[n] = new t(r)) } return e.g[n] } function Se(e, t) { e.g || (e.g = {}); var n = e.g[1]; if (!n) { var r = ye(e, 1); n = []; for (var i = 0; i < r.length; i++)n[i] = new t(r[i]); e.g[1] = n } return n } function _e(e, t, n) { var r = void 0 !== r && r; e.g || (e.g = {}); var i = n ? Ae(n, !1) : n; e.g[t] = n, we(e, t, i, r) } function Ce(e, t, n, r) { var i = Se(e, n); t = t || new n, e = ye(e, 1), null != r ? (i.splice(r, 0, t), e.splice(r, 0, Ae(t, !1))) : (i.push(t), e.push(Ae(t, !1))) } function Ae(e, t) { if (e.g) for (var n in e.g) { var r = e.g[n]; if (Array.isArray(r)) for (var i = 0; i < r.length; i++)r[i] && Ae(r[i], t); else r && Ae(r, t) } return e.h } function Te(e, t) { if (e = e.o) { re(t, t.g.end()); for (var n = 0; n < e.length; n++)re(t, e[n]) } } function Ee(e, t) { if (4 == t.h) return !1; var n = t.m; return K(t), t.N || (t = L(t.g.h, n, t.g.g), (n = e.o) ? n.push(t) : e.o = [t]), !0 } function Ne(e) { fe.call(this, e, -1, Me) } function Ie(e, t) { for (; X(t);)switch (t.i) { case 8: var n = t.g.i(); we(e, 1, n); break; case 16: we(e, 2, n = t.g.i()); break; case 29: case 26: te(t, e.getPackedDataList()); break; case 32: we(e, 4, n = V(t.g)); break; default: if (!Ee(e, t)) return e }return e } fe.prototype.toJSON = function () { return ue(Ae(this, !1), le, R) }, fe.prototype.toString = function () { return Ae(this, !1).toString() }, p(Ne, fe), Ne.prototype.getRows = function () { return ge(this, 1) }, Ne.prototype.getCols = function () { return ge(this, 2) }, Ne.prototype.getPackedDataList = function () { return be(this) }, Ne.prototype.getLayout = function () { return ve(this, 4, 0) }; var Me = [3]; function Fe(e, t) { var n = void 0; return new (n || (n = Promise))((function (r, i) { function a(e) { try { s(t.next(e)) } catch (e) { i(e) } } function o(e) { try { s(t.throw(e)) } catch (e) { i(e) } } function s(e) { e.done ? r(e.value) : new n((function (t) { t(e.value) })).then(a, o) } s((t = t.apply(e, void 0)).next()) })) } function De(e) { fe.call(this, e) } function $e(e, t) { for (; X(t);)switch (t.i) { case 8: var n = t.g.i(); we(e, 1, n); break; case 21: we(e, 2, n = J(t)); break; case 26: we(e, 3, n = Q(t)); break; case 34: we(e, 4, n = Q(t)); break; default: if (!Ee(e, t)) return e }return e } function Re(e) { fe.call(this, e, -1, Oe) } p(De, fe), p(Re, fe), Re.prototype.addClassification = function (e, t) { return Ce(this, e, De, t), this }; var Oe = [1]; function ze(e) { fe.call(this, e) } function Pe(e, t) { for (; X(t);)switch (t.i) { case 13: var n = J(t); we(e, 1, n); break; case 21: we(e, 2, n = J(t)); break; case 29: we(e, 3, n = J(t)); break; case 37: we(e, 4, n = J(t)); break; case 45: we(e, 5, n = J(t)); break; default: if (!Ee(e, t)) return e }return e } function Be(e) { fe.call(this, e, -1, je) } function Le(e) { e: { var t = new Be; for (e = new Y(e); X(e);)if (10 === e.i) { Ce(t, Z(e, new ze, Pe), ze, void 0) } else if (!Ee(t, e)) break e } return t } p(ze, fe), p(Be, fe); var je = [1]; function Ue(e) { fe.call(this, e) } function We(e) { fe.call(this, e, -1, Ge) } function Ve(e, t) { for (; X(t);)switch (t.i) { case 8: var n = V(t.g); we(e, 1, n); break; case 16: we(e, 2, n = V(t.g)); break; case 29: case 26: te(t, e.getVertexBufferList()); break; case 32: case 34: n = t; var r = e.getIndexBufferList(); 2 == n.h ? ee(n, U.prototype.i, r) : r.push(n.g.i()); break; default: if (!Ee(e, t)) return e }return e } p(Ue, fe), p(We, fe), We.prototype.getVertexType = function () { return ve(this, 1, 0) }, We.prototype.getPrimitiveType = function () { return ve(this, 2, 0) }, We.prototype.getVertexBufferList = function () { return be(this) }, We.prototype.getIndexBufferList = function () { return ye(this, 4) }; var Ge = [3, 4]; function He(e) { fe.call(this, e) } function qe(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function Ye(e) { return Se(e, De).map((function (e) { return { index: ve(e, 1, 0), Y: xe(e, 2), label: null != ge(e, 3) ? ve(e, 3, "") : void 0, displayName: null != ge(e, 4) ? ve(e, 4, "") : void 0 } })) } function Xe(e) { return { x: xe(e, 1), y: xe(e, 2), z: xe(e, 3), visibility: null != ge(e, 4) ? xe(e, 4) : void 0 } } function Ke(e, t) { this.h = e, this.g = t, this.l = 0 } function Ze(e, t, n) { return function (e, t) { var n = e.g; if (void 0 === e.m) { var r = qe(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = qe(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.m = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.j = { I: n.getAttribLocation(r, "aVertex"), H: n.getAttribLocation(r, "aTex"), da: i }, e.s = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.enableVertexAttribArray(e.j.I), n.vertexAttribPointer(e.j.I, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.o = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.o), n.enableVertexAttribArray(e.j.H), n.vertexAttribPointer(e.j.H, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.j, n.useProgram(e.m), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.h.bindTexture2d(t.glName), n.enableVertexAttribArray(r.I), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.vertexAttribPointer(r.I, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.H), n.bindBuffer(n.ARRAY_BUFFER, e.o), n.vertexAttribPointer(r.H, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.I), n.disableVertexAttribArray(r.H), n.bindBuffer(n.ARRAY_BUFFER, null), e.h.bindTexture2d(0) }(e, t), "function" == typeof e.g.canvas.transferToImageBitmap ? Promise.resolve(e.g.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.g.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.g.canvas) : (void 0 === e.i && (e.i = document.createElement("canvas")), new Promise((function (t) { e.i.height = e.g.canvas.height, e.i.width = e.g.canvas.width, e.i.getContext("2d", {}).drawImage(e.g.canvas, 0, 0, e.g.canvas.width, e.g.canvas.height), t(e.i) }))) } function Je(e) { this.g = e } p(He, fe), He.prototype.getMesh = function () { return ke(this, We, 1) }, He.prototype.getPoseTransformMatrix = function () { return ke(this, Ne, 2) }; var Qe = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function et(e, t) { return t + e } function tt(e, t) { window[e] = t } function nt(e) { if (this.g = e, this.listeners = {}, this.j = {}, this.F = {}, this.m = {}, this.s = {}, this.G = this.o = this.R = !0, this.C = Promise.resolve(), this.P = "", this.B = {}, this.locateFile = e && e.locateFile || et, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.S = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.j[n] = "function" == typeof r ? r() : r) } } function rt(e) { return Fe(e, (function e() { var t, n, r, i, a, o, s, l, c, h, d, f = this; return S(e, (function (e) { switch (e.g) { case 1: return t = f, f.R ? (n = function (e, t) { return void 0 === e.g.files ? [] : "function" == typeof e.g.files ? e.g.files(t) : e.g.files }(f, f.j), b(e, function () { return Fe(this, (function e() { return S(e, (function (e) { switch (e.g) { case 1: return e.m = 2, b(e, WebAssembly.instantiate(Qe), 4); case 4: e.g = 3, e.m = 0; break; case 2: return e.m = 0, e.j = null, e.return(!1); case 3: return e.return(!0) } })) })) }(), 2)) : e.return(); case 2: if (r = e.h, "object" == typeof window) return tt("createMediapipeSolutionsWasm", { locateFile: f.locateFile }), tt("createMediapipeSolutionsPackedAssets", { locateFile: f.locateFile }), o = n.filter((function (e) { return void 0 !== e.data })), s = n.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (e) { var n = it(t, e.url); if (void 0 !== e.path) { var r = e.path; n = n.then((function (e) { return t.overrideFile(r, e), Promise.resolve(e) })) } return n }))), c = Promise.all(s.map((function (e) { return void 0 === e.simd || e.simd && r || !e.simd && !r ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(t.locateFile(e.url, t.S)) : Promise.resolve() }))).then((function () { return Fe(t, (function e() { var t, n, r = this; return S(e, (function (e) { if (1 == e.g) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, b(e, t(n), 2); r.h = e.h, e.g = 0 })) })) })), h = Fe(t, (function e() { var t = this; return S(e, (function (e) { return t.g.graph && t.g.graph.url ? e = b(e, it(t, t.g.graph.url), 0) : (e.g = 0, e = void 0), e })) })), b(e, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return i = n.filter((function (e) { return void 0 === e.simd || e.simd && r || !e.simd && !r })).map((function (e) { return t.locateFile(e.url, t.S) })), importScripts.apply(null, u(i)), b(e, createMediapipeSolutionsWasm(Module), 6); case 6: f.h = e.h, f.l = new OffscreenCanvas(1, 1), f.h.canvas = f.l, a = f.h.GL.createContext(f.l, { antialias: !1, alpha: !1, ba: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), f.h.GL.makeContextCurrent(a), e.g = 4; break; case 7: if (f.l = document.createElement("canvas"), !(d = f.l.getContext("webgl2", {})) && !(d = f.l.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), e.return(); f.D = d, f.h.canvas = f.l, f.h.createContext(f.l, !0, !0, {}); case 4: f.i = new f.h.SolutionWasm, f.R = !1, e.g = 0 } })) })) } function it(e, t) { return Fe(e, (function e() { var n, r, i = this; return S(e, (function (e) { return t in i.F ? e.return(i.F[t]) : (n = i.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), i.F[t] = r, e.return(r)) })) })) } function at(e, t, n) { return Fe(e, (function e() { var r, i, a, o, u, l, c, h, d, f, p, m, g, y, v = this; return S(e, (function (e) { switch (e.g) { case 1: if (!n) return e.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (v.G = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { e.g = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, b(e, function (e, t, n) { return Fe(e, (function e() { var r, i = this; return S(e, (function (e) { return "number" == typeof n || n instanceof Uint8Array || n instanceof i.h.Uint8BlobList ? e.return(n) : n instanceof i.h.Texture2dDataOut ? ((r = i.s[t]) || (r = new Ke(i.h, i.D), i.s[t] = r), e.return(Ze(r, n, i.G))) : e.return(void 0) })) })) }(v, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), _ = [], C = 0; C < x.size(); ++C) { var A = x.get(C); e: { var T = new Ue; for (A = new Y(A); X(A);)switch (A.i) { case 13: var E = J(A); we(T, 1, E); break; case 21: we(T, 2, E = J(A)); break; case 29: we(T, 3, E = J(A)); break; case 37: we(T, 4, E = J(A)); break; case 45: we(T, 5, E = J(A)); break; case 48: we(T, 6, E = V(A.g)); break; default: if (!Ee(T, A)) break e } } T = { Z: xe(T, 1), $: xe(T, 2), height: xe(T, 3), width: xe(T, 4), rotation: xe(T, 5, 0), X: ve(T, 6, 0) }, A = Se(Le(w.get(C)), ze).map(Xe); var N = k.get(C); e: for (E = new Re, N = new Y(N); X(N);)if (10 === N.i) E.addClassification(Z(N, new De, $e)); else if (!Ee(E, N)) break e; T = { T, O: A, M: Ye(E) }, _.push(T) } x = _ } else x = []; r[h] = x, e.g = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, e.g = 7; break } if (void 0 === f) { e.g = 3; break } if ("float_list" === d.type) { r[h] = f, e.g = 7; break } if ("proto" === d.type) { r[h] = f, e.g = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = v.s[h]) || (p = new Ke(v.h, v.D), v.s[h] = p), b(e, Ze(p, f, v.G), 13); case 13: m = e.h, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), e.g = 3; break; case 14: g[y] = e.h; case 3: o = c.next(), e.g = 2; break; case 4: return e.return(r) } })) })) } function ot(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.h.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.h.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.C = at(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.C = n) }))) } }), e.i.attachMultiListener(i, a), i.delete() } function st(e) { e = function (e) { e: { var t = new He; for (e = new Y(e); X(e);)switch (e.i) { case 10: var n = Z(e, new We, Ve); _e(t, 1, n); break; case 18: _e(t, 2, n = Z(e, new Ne, Ie)); break; default: if (!Ee(t, e)) break e } } return t }(e); var t = e.getMesh(); if (!t) return e; var n = new Float32Array(t.getVertexBufferList()); t.getVertexBufferList = function () { return n }; var r = new Uint32Array(t.getIndexBufferList()); return t.getIndexBufferList = function () { return r }, e } (e = nt.prototype).close = function () { return this.i && this.i.delete(), Promise.resolve() }, e.reset = function () { return Fe(this, (function e() { var t = this; return S(e, (function (e) { t.i && (t.i.reset(), t.m = {}, t.s = {}), e.g = 0 })) })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.g.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { K: a.K, L: a.L }, u = o.next()) { var l = u.value; l in this.j && this.j[l] === e[l] || (this.j[l] = e[l], void 0 !== (u = t[l]) && (u.onChange && (a.K = u.onChange, a.L = e[l], r.push(function (e) { return function () { return Fe(n, (function t() { var n = this; return S(t, (function (t) { if (1 == t.g) return b(t, e.K(e.L), 2); !0 === t.h && (n.o = !0), t.g = 0 })) })) } }(a))), u.graphOptionXref && (l = { valueNumber: 1 === u.type ? e[l] : 0, valueBoolean: 0 === u.type && e[l], valueString: 2 === u.type ? e[l] : "" }, u = Object.assign(Object.assign(Object.assign({}, { calculatorName: "", calculatorIndex: 0 }), u.graphOptionXref), l), i.push(u)))) } 0 === r.length && 0 === i.length || (this.o = !0, this.A = (void 0 === this.A ? [] : this.A).concat(i), this.u = (void 0 === this.u ? [] : this.u).concat(r)) } }, e.initialize = function () { return Fe(this, (function e() { var t = this; return S(e, (function (e) { return 1 == e.g ? b(e, rt(t), 2) : 3 != e.g ? b(e, Fe(t, (function e() { var t, n, r, i, a, o, u, l, c = this; return S(e, (function (e) { if (1 == e.g) return c.g.graph && c.g.graph.url && c.P === c.g.graph.url ? e.return() : (c.o = !0, c.g.graph && c.g.graph.url ? (c.P = c.g.graph.url, b(e, it(c, c.g.graph.url), 3)) : void (e.g = 2)); for (2 != e.g && (t = e.h, c.i.loadGraph(t)), n = s(Object.keys(c.B)), r = n.next(); !r.done; r = n.next())i = r.value, c.i.overrideFile(i, c.B[i]); if (c.B = {}, c.g.listeners) for (a = s(c.g.listeners), o = a.next(); !o.done; o = a.next())u = o.value, ot(c, u); l = c.j, c.j = {}, c.setOptions(l), e.g = 0 })) })), 3) : b(e, function (e) { return Fe(e, (function e() { var t, n, r, i, a, o, u = this; return S(e, (function (e) { switch (e.g) { case 1: if (!u.o) return e.return(); if (!u.u) { e.g = 2; break } t = s(u.u), n = t.next(); case 3: if (n.done) { e.g = 5; break } return b(e, (0, n.value)(), 4); case 4: n = t.next(), e.g = 3; break; case 5: u.u = void 0; case 2: if (u.A) { for (r = new u.h.GraphOptionChangeRequestList, i = s(u.A), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); u.i.changeOptions(r), r.delete(), u.A = void 0 } u.o = !1, e.g = 0 } })) })) }(t), 0) })) })) }, e.overrideFile = function (e, t) { this.i ? this.i.overrideFile(e, t) : this.B[e] = t }, e.clearOverriddenFiles = function () { this.B = {}, this.i && this.i.clearOverriddenFiles() }, e.send = function (e, t) { return Fe(this, (function n() { var r, i, a, o, u, l, c, h, d, f = this; return S(n, (function (n) { switch (n.g) { case 1: return f.g.inputs ? (r = 1e3 * (null == t ? performance.now() : t), b(n, f.C, 2)) : n.return(); case 2: return b(n, f.initialize(), 3); case 3: for (i = new f.h.PacketDataList, a = s(Object.keys(e)), o = a.next(); !o.done; o = a.next())if (u = o.value, l = f.g.inputs[u]) { e: { var p = f, m = e[u]; switch (l.type) { case "video": var g = p.m[l.stream]; if (g || (g = new Ke(p.h, p.D), p.m[l.stream] = g), 0 === (p = g).l && (p.l = p.h.createTexture()), "undefined" != typeof HTMLVideoElement && m instanceof HTMLVideoElement) { var y = m.videoWidth; g = m.videoHeight } else "undefined" != typeof HTMLImageElement && m instanceof HTMLImageElement ? (y = m.naturalWidth, g = m.naturalHeight) : (y = m.width, g = m.height); g = { glName: p.l, width: y, height: g }, (y = p.g).canvas.width = g.width, y.canvas.height = g.height, y.activeTexture(y.TEXTURE0), p.h.bindTexture2d(p.l), y.texImage2D(y.TEXTURE_2D, 0, y.RGBA, y.RGBA, y.UNSIGNED_BYTE, m), p.h.bindTexture2d(0), p = g; break e; case "detections": for ((g = p.m[l.stream]) || (g = new Je(p.h), p.m[l.stream] = g), (p = g).data || (p.data = new p.g.DetectionListData), p.data.reset(m.length), g = 0; g < m.length; ++g) { y = m[g]; var v = p.data, x = v.setBoundingBox, w = g, k = y.T, S = new Ue; we(S, 1, k.Z), we(S, 2, k.$), we(S, 3, k.height), we(S, 4, k.width), we(S, 5, k.rotation), we(S, 6, k.X); var _ = k = new ne; ae(_, 1, ge(S, 1)), ae(_, 2, ge(S, 2)), ae(_, 3, ge(S, 3)), ae(_, 4, ge(S, 4)), ae(_, 5, ge(S, 5)); var C = ge(S, 6); if (null != C && null != C) { q(_.g, 48); var A = _.g, T = C; C = 0 > T; var E = (T = Math.abs(T)) >>> 0; for (T = Math.floor((T - E) / 4294967296), T >>>= 0, C && (T = ~T >>> 0, 4294967295 < (E = 1 + (~E >>> 0)) && (E = 0, 4294967295 < ++T && (T = 0))), C = j = E, E = T; 0 < E || 127 < C;)A.push(127 & C | 128), C = (C >>> 7 | E << 25) >>> 0, E >>>= 7; A.push(C) } if (Te(S, _), k = ie(k), x.call(v, w, k), y.O) for (v = 0; v < y.O.length; ++v)_ = !!(S = y.O[v]).visibility, w = (x = p.data).addNormalizedLandmark, k = g, S = Object.assign(Object.assign({}, S), { visibility: _ ? S.visibility : 0 }), we(_ = new ze, 1, S.x), we(_, 2, S.y), we(_, 3, S.z), S.visibility && we(_, 4, S.visibility), ae(A = S = new ne, 1, ge(_, 1)), ae(A, 2, ge(_, 2)), ae(A, 3, ge(_, 3)), ae(A, 4, ge(_, 4)), ae(A, 5, ge(_, 5)), Te(_, A), S = ie(S), w.call(x, k, S); if (y.M) for (v = 0; v < y.M.length; ++v) { if (w = (x = p.data).addClassification, k = g, S = y.M[v], we(_ = new De, 2, S.Y), S.index && we(_, 1, S.index), S.label && we(_, 3, S.label), S.displayName && we(_, 4, S.displayName), A = S = new ne, null != (E = ge(_, 1)) && null != E) if (q(A.g, 8), C = A.g, 0 <= E) q(C, E); else { for (T = 0; 9 > T; T++)C.push(127 & E | 128), E >>= 7; C.push(1) } ae(A, 2, ge(_, 2)), null != (C = ge(_, 3)) && (C = F(C), q(A.g, 26), q(A.g, C.length), re(A, A.g.end()), re(A, C)), null != (C = ge(_, 4)) && (C = F(C), q(A.g, 34), q(A.g, C.length), re(A, A.g.end()), re(A, C)), Te(_, A), S = ie(S), w.call(x, k, S) } } p = p.data; break e; default: p = {} } } switch (c = p, h = l.stream, l.type) { case "video": i.pushTexture2d(Object.assign(Object.assign({}, c), { stream: h, timestamp: r })); break; case "detections": (d = c).stream = h, d.timestamp = r, i.pushDetectionList(d); break; default: throw Error("Unknown input config type: '" + l.type + "'") } } return f.i.send(i), b(n, f.C, 4); case 4: i.delete(), n.g = 0 } })) })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, A("Solution", nt), A("OptionType", { BOOL: 0, NUMBER: 1, aa: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }); var ut = { files: [{ url: "face_mesh_solution_packed_assets_loader.js" }, { simd: !0, url: "face_mesh_solution_simd_wasm_bin.js" }, { simd: !1, url: "face_mesh_solution_wasm_bin.js" }], graph: { url: "face_mesh.binarypb" }, listeners: [{ wants: ["multi_face_geometry", "image_transformed", "multi_face_landmarks"], outs: { image: "image_transformed", multiFaceGeometry: { type: "proto_list", stream: "multi_face_geometry", transform: function (e) { return e.map(st) } }, multiFaceLandmarks: { type: "proto_list", stream: "multi_face_landmarks", transform: function (e) { return e.map((function (e) { return Se(Le(e), ze).map(Xe) })) } } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document }, enableFaceGeometry: { type: 0, graphOptionXref: { calculatorName: "EnableFaceGeometryConstant", calculatorType: "ConstantSidePacketCalculator", fieldName: "bool_value" } }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, maxNumFaces: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorNumFaces", fieldName: "int_value" } }, refineLandmarks: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorRefineLandmarks", fieldName: "bool_value" } }, minDetectionConfidence: { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "facelandmarkfrontgpu__facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }, minTrackingConfidence: { type: 1, graphOptionXref: { calculatorType: "ThresholdingCalculator", calculatorName: "facelandmarkfrontgpu__facelandmarkgpu__ThresholdingCalculator", fieldName: "threshold" } }, cameraNear: { type: 1, graphOptionXref: { calculatorType: "FaceGeometryEnvGeneratorCalculator", fieldName: "near" } }, cameraFar: { type: 1, graphOptionXref: { calculatorType: "FaceGeometryEnvGeneratorCalculator", fieldName: "far" } }, cameraVerticalFovDegrees: { type: 1, graphOptionXref: { calculatorType: "FaceGeometryEnvGeneratorCalculator", fieldName: "vertical_fov_degrees" } } } }, lt = [[61, 146], [146, 91], [91, 181], [181, 84], [84, 17], [17, 314], [314, 405], [405, 321], [321, 375], [375, 291], [61, 185], [185, 40], [40, 39], [39, 37], [37, 0], [0, 267], [267, 269], [269, 270], [270, 409], [409, 291], [78, 95], [95, 88], [88, 178], [178, 87], [87, 14], [14, 317], [317, 402], [402, 318], [318, 324], [324, 308], [78, 191], [191, 80], [80, 81], [81, 82], [82, 13], [13, 312], [312, 311], [311, 310], [310, 415], [415, 308]], ct = [[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]], ht = [[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]], dt = [[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]], ft = [[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]], pt = [[10, 338], [338, 297], [297, 332], [332, 284], [284, 251], [251, 389], [389, 356], [356, 454], [454, 323], [323, 361], [361, 288], [288, 397], [397, 365], [365, 379], [379, 378], [378, 400], [400, 377], [377, 152], [152, 148], [148, 176], [176, 149], [149, 150], [150, 136], [136, 172], [172, 58], [58, 132], [132, 93], [93, 234], [234, 127], [127, 162], [162, 21], [21, 54], [54, 103], [103, 67], [67, 109], [109, 10]], mt = [].concat(u(lt), u(ct), u(ht), u(dt), u(ft), u(pt)); function gt(e) { e = e || {}, e = Object.assign(Object.assign({}, ut), e), this.g = new nt(e) } (e = gt.prototype).close = function () { return this.g.close(), Promise.resolve() }, e.onResults = function (e) { this.g.onResults(e) }, e.initialize = function () { return Fe(this, (function e() { var t = this; return S(e, (function (e) { return b(e, t.g.initialize(), 0) })) })) }, e.reset = function () { this.g.reset() }, e.send = function (e) { return Fe(this, (function t() { var n = this; return S(t, (function (t) { return b(t, n.g.send(e), 0) })) })) }, e.setOptions = function (e) { this.g.setOptions(e) }, A("FACE_GEOMETRY", { Layout: { COLUMN_MAJOR: 0, ROW_MAJOR: 1, 0: "COLUMN_MAJOR", 1: "ROW_MAJOR" }, PrimitiveType: { TRIANGLE: 0, 0: "TRIANGLE" }, VertexType: { VERTEX_PT: 0, 0: "VERTEX_PT" }, DEFAULT_CAMERA_PARAMS: { verticalFovDegrees: 63, near: 1, far: 1e4 } }), A("FaceMesh", gt), A("FACEMESH_LIPS", lt), A("FACEMESH_LEFT_EYE", ct), A("FACEMESH_LEFT_EYEBROW", ht), A("FACEMESH_LEFT_IRIS", [[474, 475], [475, 476], [476, 477], [477, 474]]), A("FACEMESH_RIGHT_EYE", dt), A("FACEMESH_RIGHT_EYEBROW", ft), A("FACEMESH_RIGHT_IRIS", [[469, 470], [470, 471], [471, 472], [472, 469]]), A("FACEMESH_FACE_OVAL", pt), A("FACEMESH_CONTOURS", mt), A("FACEMESH_TESSELATION", [[127, 34], [34, 139], [139, 127], [11, 0], [0, 37], [37, 11], [232, 231], [231, 120], [120, 232], [72, 37], [37, 39], [39, 72], [128, 121], [121, 47], [47, 128], [232, 121], [121, 128], [128, 232], [104, 69], [69, 67], [67, 104], [175, 171], [171, 148], [148, 175], [118, 50], [50, 101], [101, 118], [73, 39], [39, 40], [40, 73], [9, 151], [151, 108], [108, 9], [48, 115], [115, 131], [131, 48], [194, 204], [204, 211], [211, 194], [74, 40], [40, 185], [185, 74], [80, 42], [42, 183], [183, 80], [40, 92], [92, 186], [186, 40], [230, 229], [229, 118], [118, 230], [202, 212], [212, 214], [214, 202], [83, 18], [18, 17], [17, 83], [76, 61], [61, 146], [146, 76], [160, 29], [29, 30], [30, 160], [56, 157], [157, 173], [173, 56], [106, 204], [204, 194], [194, 106], [135, 214], [214, 192], [192, 135], [203, 165], [165, 98], [98, 203], [21, 71], [71, 68], [68, 21], [51, 45], [45, 4], [4, 51], [144, 24], [24, 23], [23, 144], [77, 146], [146, 91], [91, 77], [205, 50], [50, 187], [187, 205], [201, 200], [200, 18], [18, 201], [91, 106], [106, 182], [182, 91], [90, 91], [91, 181], [181, 90], [85, 84], [84, 17], [17, 85], [206, 203], [203, 36], [36, 206], [148, 171], [171, 140], [140, 148], [92, 40], [40, 39], [39, 92], [193, 189], [189, 244], [244, 193], [159, 158], [158, 28], [28, 159], [247, 246], [246, 161], [161, 247], [236, 3], [3, 196], [196, 236], [54, 68], [68, 104], [104, 54], [193, 168], [168, 8], [8, 193], [117, 228], [228, 31], [31, 117], [189, 193], [193, 55], [55, 189], [98, 97], [97, 99], [99, 98], [126, 47], [47, 100], [100, 126], [166, 79], [79, 218], [218, 166], [155, 154], [154, 26], [26, 155], [209, 49], [49, 131], [131, 209], [135, 136], [136, 150], [150, 135], [47, 126], [126, 217], [217, 47], [223, 52], [52, 53], [53, 223], [45, 51], [51, 134], [134, 45], [211, 170], [170, 140], [140, 211], [67, 69], [69, 108], [108, 67], [43, 106], [106, 91], [91, 43], [230, 119], [119, 120], [120, 230], [226, 130], [130, 247], [247, 226], [63, 53], [53, 52], [52, 63], [238, 20], [20, 242], [242, 238], [46, 70], [70, 156], [156, 46], [78, 62], [62, 96], [96, 78], [46, 53], [53, 63], [63, 46], [143, 34], [34, 227], [227, 143], [123, 117], [117, 111], [111, 123], [44, 125], [125, 19], [19, 44], [236, 134], [134, 51], [51, 236], [216, 206], [206, 205], [205, 216], [154, 153], [153, 22], [22, 154], [39, 37], [37, 167], [167, 39], [200, 201], [201, 208], [208, 200], [36, 142], [142, 100], [100, 36], [57, 212], [212, 202], [202, 57], [20, 60], [60, 99], [99, 20], [28, 158], [158, 157], [157, 28], [35, 226], [226, 113], [113, 35], [160, 159], [159, 27], [27, 160], [204, 202], [202, 210], [210, 204], [113, 225], [225, 46], [46, 113], [43, 202], [202, 204], [204, 43], [62, 76], [76, 77], [77, 62], [137, 123], [123, 116], [116, 137], [41, 38], [38, 72], [72, 41], [203, 129], [129, 142], [142, 203], [64, 98], [98, 240], [240, 64], [49, 102], [102, 64], [64, 49], [41, 73], [73, 74], [74, 41], [212, 216], [216, 207], [207, 212], [42, 74], [74, 184], [184, 42], [169, 170], [170, 211], [211, 169], [170, 149], [149, 176], [176, 170], [105, 66], [66, 69], [69, 105], [122, 6], [6, 168], [168, 122], [123, 147], [147, 187], [187, 123], [96, 77], [77, 90], [90, 96], [65, 55], [55, 107], [107, 65], [89, 90], [90, 180], [180, 89], [101, 100], [100, 120], [120, 101], [63, 105], [105, 104], [104, 63], [93, 137], [137, 227], [227, 93], [15, 86], [86, 85], [85, 15], [129, 102], [102, 49], [49, 129], [14, 87], [87, 86], [86, 14], [55, 8], [8, 9], [9, 55], [100, 47], [47, 121], [121, 100], [145, 23], [23, 22], [22, 145], [88, 89], [89, 179], [179, 88], [6, 122], [122, 196], [196, 6], [88, 95], [95, 96], [96, 88], [138, 172], [172, 136], [136, 138], [215, 58], [58, 172], [172, 215], [115, 48], [48, 219], [219, 115], [42, 80], [80, 81], [81, 42], [195, 3], [3, 51], [51, 195], [43, 146], [146, 61], [61, 43], [171, 175], [175, 199], [199, 171], [81, 82], [82, 38], [38, 81], [53, 46], [46, 225], [225, 53], [144, 163], [163, 110], [110, 144], [52, 65], [65, 66], [66, 52], [229, 228], [228, 117], [117, 229], [34, 127], [127, 234], [234, 34], [107, 108], [108, 69], [69, 107], [109, 108], [108, 151], [151, 109], [48, 64], [64, 235], [235, 48], [62, 78], [78, 191], [191, 62], [129, 209], [209, 126], [126, 129], [111, 35], [35, 143], [143, 111], [117, 123], [123, 50], [50, 117], [222, 65], [65, 52], [52, 222], [19, 125], [125, 141], [141, 19], [221, 55], [55, 65], [65, 221], [3, 195], [195, 197], [197, 3], [25, 7], [7, 33], [33, 25], [220, 237], [237, 44], [44, 220], [70, 71], [71, 139], [139, 70], [122, 193], [193, 245], [245, 122], [247, 130], [130, 33], [33, 247], [71, 21], [21, 162], [162, 71], [170, 169], [169, 150], [150, 170], [188, 174], [174, 196], [196, 188], [216, 186], [186, 92], [92, 216], [2, 97], [97, 167], [167, 2], [141, 125], [125, 241], [241, 141], [164, 167], [167, 37], [37, 164], [72, 38], [38, 12], [12, 72], [38, 82], [82, 13], [13, 38], [63, 68], [68, 71], [71, 63], [226, 35], [35, 111], [111, 226], [101, 50], [50, 205], [205, 101], [206, 92], [92, 165], [165, 206], [209, 198], [198, 217], [217, 209], [165, 167], [167, 97], [97, 165], [220, 115], [115, 218], [218, 220], [133, 112], [112, 243], [243, 133], [239, 238], [238, 241], [241, 239], [214, 135], [135, 169], [169, 214], [190, 173], [173, 133], [133, 190], [171, 208], [208, 32], [32, 171], [125, 44], [44, 237], [237, 125], [86, 87], [87, 178], [178, 86], [85, 86], [86, 179], [179, 85], [84, 85], [85, 180], [180, 84], [83, 84], [84, 181], [181, 83], [201, 83], [83, 182], [182, 201], [137, 93], [93, 132], [132, 137], [76, 62], [62, 183], [183, 76], [61, 76], [76, 184], [184, 61], [57, 61], [61, 185], [185, 57], [212, 57], [57, 186], [186, 212], [214, 207], [207, 187], [187, 214], [34, 143], [143, 156], [156, 34], [79, 239], [239, 237], [237, 79], [123, 137], [137, 177], [177, 123], [44, 1], [1, 4], [4, 44], [201, 194], [194, 32], [32, 201], [64, 102], [102, 129], [129, 64], [213, 215], [215, 138], [138, 213], [59, 166], [166, 219], [219, 59], [242, 99], [99, 97], [97, 242], [2, 94], [94, 141], [141, 2], [75, 59], [59, 235], [235, 75], [24, 110], [110, 228], [228, 24], [25, 130], [130, 226], [226, 25], [23, 24], [24, 229], [229, 23], [22, 23], [23, 230], [230, 22], [26, 22], [22, 231], [231, 26], [112, 26], [26, 232], [232, 112], [189, 190], [190, 243], [243, 189], [221, 56], [56, 190], [190, 221], [28, 56], [56, 221], [221, 28], [27, 28], [28, 222], [222, 27], [29, 27], [27, 223], [223, 29], [30, 29], [29, 224], [224, 30], [247, 30], [30, 225], [225, 247], [238, 79], [79, 20], [20, 238], [166, 59], [59, 75], [75, 166], [60, 75], [75, 240], [240, 60], [147, 177], [177, 215], [215, 147], [20, 79], [79, 166], [166, 20], [187, 147], [147, 213], [213, 187], [112, 233], [233, 244], [244, 112], [233, 128], [128, 245], [245, 233], [128, 114], [114, 188], [188, 128], [114, 217], [217, 174], [174, 114], [131, 115], [115, 220], [220, 131], [217, 198], [198, 236], [236, 217], [198, 131], [131, 134], [134, 198], [177, 132], [132, 58], [58, 177], [143, 35], [35, 124], [124, 143], [110, 163], [163, 7], [7, 110], [228, 110], [110, 25], [25, 228], [356, 389], [389, 368], [368, 356], [11, 302], [302, 267], [267, 11], [452, 350], [350, 349], [349, 452], [302, 303], [303, 269], [269, 302], [357, 343], [343, 277], [277, 357], [452, 453], [453, 357], [357, 452], [333, 332], [332, 297], [297, 333], [175, 152], [152, 377], [377, 175], [347, 348], [348, 330], [330, 347], [303, 304], [304, 270], [270, 303], [9, 336], [336, 337], [337, 9], [278, 279], [279, 360], [360, 278], [418, 262], [262, 431], [431, 418], [304, 408], [408, 409], [409, 304], [310, 415], [415, 407], [407, 310], [270, 409], [409, 410], [410, 270], [450, 348], [348, 347], [347, 450], [422, 430], [430, 434], [434, 422], [313, 314], [314, 17], [17, 313], [306, 307], [307, 375], [375, 306], [387, 388], [388, 260], [260, 387], [286, 414], [414, 398], [398, 286], [335, 406], [406, 418], [418, 335], [364, 367], [367, 416], [416, 364], [423, 358], [358, 327], [327, 423], [251, 284], [284, 298], [298, 251], [281, 5], [5, 4], [4, 281], [373, 374], [374, 253], [253, 373], [307, 320], [320, 321], [321, 307], [425, 427], [427, 411], [411, 425], [421, 313], [313, 18], [18, 421], [321, 405], [405, 406], [406, 321], [320, 404], [404, 405], [405, 320], [315, 16], [16, 17], [17, 315], [426, 425], [425, 266], [266, 426], [377, 400], [400, 369], [369, 377], [322, 391], [391, 269], [269, 322], [417, 465], [465, 464], [464, 417], [386, 257], [257, 258], [258, 386], [466, 260], [260, 388], [388, 466], [456, 399], [399, 419], [419, 456], [284, 332], [332, 333], [333, 284], [417, 285], [285, 8], [8, 417], [346, 340], [340, 261], [261, 346], [413, 441], [441, 285], [285, 413], [327, 460], [460, 328], [328, 327], [355, 371], [371, 329], [329, 355], [392, 439], [439, 438], [438, 392], [382, 341], [341, 256], [256, 382], [429, 420], [420, 360], [360, 429], [364, 394], [394, 379], [379, 364], [277, 343], [343, 437], [437, 277], [443, 444], [444, 283], [283, 443], [275, 440], [440, 363], [363, 275], [431, 262], [262, 369], [369, 431], [297, 338], [338, 337], [337, 297], [273, 375], [375, 321], [321, 273], [450, 451], [451, 349], [349, 450], [446, 342], [342, 467], [467, 446], [293, 334], [334, 282], [282, 293], [458, 461], [461, 462], [462, 458], [276, 353], [353, 383], [383, 276], [308, 324], [324, 325], [325, 308], [276, 300], [300, 293], [293, 276], [372, 345], [345, 447], [447, 372], [352, 345], [345, 340], [340, 352], [274, 1], [1, 19], [19, 274], [456, 248], [248, 281], [281, 456], [436, 427], [427, 425], [425, 436], [381, 256], [256, 252], [252, 381], [269, 391], [391, 393], [393, 269], [200, 199], [199, 428], [428, 200], [266, 330], [330, 329], [329, 266], [287, 273], [273, 422], [422, 287], [250, 462], [462, 328], [328, 250], [258, 286], [286, 384], [384, 258], [265, 353], [353, 342], [342, 265], [387, 259], [259, 257], [257, 387], [424, 431], [431, 430], [430, 424], [342, 353], [353, 276], [276, 342], [273, 335], [335, 424], [424, 273], [292, 325], [325, 307], [307, 292], [366, 447], [447, 345], [345, 366], [271, 303], [303, 302], [302, 271], [423, 266], [266, 371], [371, 423], [294, 455], [455, 460], [460, 294], [279, 278], [278, 294], [294, 279], [271, 272], [272, 304], [304, 271], [432, 434], [434, 427], [427, 432], [272, 407], [407, 408], [408, 272], [394, 430], [430, 431], [431, 394], [395, 369], [369, 400], [400, 395], [334, 333], [333, 299], [299, 334], [351, 417], [417, 168], [168, 351], [352, 280], [280, 411], [411, 352], [325, 319], [319, 320], [320, 325], [295, 296], [296, 336], [336, 295], [319, 403], [403, 404], [404, 319], [330, 348], [348, 349], [349, 330], [293, 298], [298, 333], [333, 293], [323, 454], [454, 447], [447, 323], [15, 16], [16, 315], [315, 15], [358, 429], [429, 279], [279, 358], [14, 15], [15, 316], [316, 14], [285, 336], [336, 9], [9, 285], [329, 349], [349, 350], [350, 329], [374, 380], [380, 252], [252, 374], [318, 402], [402, 403], [403, 318], [6, 197], [197, 419], [419, 6], [318, 319], [319, 325], [325, 318], [367, 364], [364, 365], [365, 367], [435, 367], [367, 397], [397, 435], [344, 438], [438, 439], [439, 344], [272, 271], [271, 311], [311, 272], [195, 5], [5, 281], [281, 195], [273, 287], [287, 291], [291, 273], [396, 428], [428, 199], [199, 396], [311, 271], [271, 268], [268, 311], [283, 444], [444, 445], [445, 283], [373, 254], [254, 339], [339, 373], [282, 334], [334, 296], [296, 282], [449, 347], [347, 346], [346, 449], [264, 447], [447, 454], [454, 264], [336, 296], [296, 299], [299, 336], [338, 10], [10, 151], [151, 338], [278, 439], [439, 455], [455, 278], [292, 407], [407, 415], [415, 292], [358, 371], [371, 355], [355, 358], [340, 345], [345, 372], [372, 340], [346, 347], [347, 280], [280, 346], [442, 443], [443, 282], [282, 442], [19, 94], [94, 370], [370, 19], [441, 442], [442, 295], [295, 441], [248, 419], [419, 197], [197, 248], [263, 255], [255, 359], [359, 263], [440, 275], [275, 274], [274, 440], [300, 383], [383, 368], [368, 300], [351, 412], [412, 465], [465, 351], [263, 467], [467, 466], [466, 263], [301, 368], [368, 389], [389, 301], [395, 378], [378, 379], [379, 395], [412, 351], [351, 419], [419, 412], [436, 426], [426, 322], [322, 436], [2, 164], [164, 393], [393, 2], [370, 462], [462, 461], [461, 370], [164, 0], [0, 267], [267, 164], [302, 11], [11, 12], [12, 302], [268, 12], [12, 13], [13, 268], [293, 300], [300, 301], [301, 293], [446, 261], [261, 340], [340, 446], [330, 266], [266, 425], [425, 330], [426, 423], [423, 391], [391, 426], [429, 355], [355, 437], [437, 429], [391, 327], [327, 326], [326, 391], [440, 457], [457, 438], [438, 440], [341, 382], [382, 362], [362, 341], [459, 457], [457, 461], [461, 459], [434, 430], [430, 394], [394, 434], [414, 463], [463, 362], [362, 414], [396, 369], [369, 262], [262, 396], [354, 461], [461, 457], [457, 354], [316, 403], [403, 402], [402, 316], [315, 404], [404, 403], [403, 315], [314, 405], [405, 404], [404, 314], [313, 406], [406, 405], [405, 313], [421, 418], [418, 406], [406, 421], [366, 401], [401, 361], [361, 366], [306, 408], [408, 407], [407, 306], [291, 409], [409, 408], [408, 291], [287, 410], [410, 409], [409, 287], [432, 436], [436, 410], [410, 432], [434, 416], [416, 411], [411, 434], [264, 368], [368, 383], [383, 264], [309, 438], [438, 457], [457, 309], [352, 376], [376, 401], [401, 352], [274, 275], [275, 4], [4, 274], [421, 428], [428, 262], [262, 421], [294, 327], [327, 358], [358, 294], [433, 416], [416, 367], [367, 433], [289, 455], [455, 439], [439, 289], [462, 370], [370, 326], [326, 462], [2, 326], [326, 370], [370, 2], [305, 460], [460, 455], [455, 305], [254, 449], [449, 448], [448, 254], [255, 261], [261, 446], [446, 255], [253, 450], [450, 449], [449, 253], [252, 451], [451, 450], [450, 252], [256, 452], [452, 451], [451, 256], [341, 453], [453, 452], [452, 341], [413, 464], [464, 463], [463, 413], [441, 413], [413, 414], [414, 441], [258, 442], [442, 441], [441, 258], [257, 443], [443, 442], [442, 257], [259, 444], [444, 443], [443, 259], [260, 445], [445, 444], [444, 260], [467, 342], [342, 445], [445, 467], [459, 458], [458, 250], [250, 459], [289, 392], [392, 290], [290, 289], [290, 328], [328, 460], [460, 290], [376, 433], [433, 435], [435, 376], [250, 290], [290, 392], [392, 250], [411, 416], [416, 433], [433, 411], [341, 463], [463, 464], [464, 341], [453, 464], [464, 465], [465, 453], [357, 465], [465, 412], [412, 357], [343, 412], [412, 399], [399, 343], [360, 363], [363, 440], [440, 360], [437, 399], [399, 456], [456, 437], [420, 456], [456, 363], [363, 420], [401, 435], [435, 288], [288, 401], [372, 383], [383, 353], [353, 372], [339, 255], [255, 249], [249, 339], [448, 261], [261, 255], [255, 448], [133, 243], [243, 190], [190, 133], [133, 155], [155, 112], [112, 133], [33, 246], [246, 247], [247, 33], [33, 130], [130, 25], [25, 33], [398, 384], [384, 286], [286, 398], [362, 398], [398, 414], [414, 362], [362, 463], [463, 341], [341, 362], [263, 359], [359, 467], [467, 263], [263, 249], [249, 255], [255, 263], [466, 467], [467, 260], [260, 466], [75, 60], [60, 166], [166, 75], [238, 239], [239, 79], [79, 238], [162, 127], [127, 139], [139, 162], [72, 11], [11, 37], [37, 72], [121, 232], [232, 120], [120, 121], [73, 72], [72, 39], [39, 73], [114, 128], [128, 47], [47, 114], [233, 232], [232, 128], [128, 233], [103, 104], [104, 67], [67, 103], [152, 175], [175, 148], [148, 152], [119, 118], [118, 101], [101, 119], [74, 73], [73, 40], [40, 74], [107, 9], [9, 108], [108, 107], [49, 48], [48, 131], [131, 49], [32, 194], [194, 211], [211, 32], [184, 74], [74, 185], [185, 184], [191, 80], [80, 183], [183, 191], [185, 40], [40, 186], [186, 185], [119, 230], [230, 118], [118, 119], [210, 202], [202, 214], [214, 210], [84, 83], [83, 17], [17, 84], [77, 76], [76, 146], [146, 77], [161, 160], [160, 30], [30, 161], [190, 56], [56, 173], [173, 190], [182, 106], [106, 194], [194, 182], [138, 135], [135, 192], [192, 138], [129, 203], [203, 98], [98, 129], [54, 21], [21, 68], [68, 54], [5, 51], [51, 4], [4, 5], [145, 144], [144, 23], [23, 145], [90, 77], [77, 91], [91, 90], [207, 205], [205, 187], [187, 207], [83, 201], [201, 18], [18, 83], [181, 91], [91, 182], [182, 181], [180, 90], [90, 181], [181, 180], [16, 85], [85, 17], [17, 16], [205, 206], [206, 36], [36, 205], [176, 148], [148, 140], [140, 176], [165, 92], [92, 39], [39, 165], [245, 193], [193, 244], [244, 245], [27, 159], [159, 28], [28, 27], [30, 247], [247, 161], [161, 30], [174, 236], [236, 196], [196, 174], [103, 54], [54, 104], [104, 103], [55, 193], [193, 8], [8, 55], [111, 117], [117, 31], [31, 111], [221, 189], [189, 55], [55, 221], [240, 98], [98, 99], [99, 240], [142, 126], [126, 100], [100, 142], [219, 166], [166, 218], [218, 219], [112, 155], [155, 26], [26, 112], [198, 209], [209, 131], [131, 198], [169, 135], [135, 150], [150, 169], [114, 47], [47, 217], [217, 114], [224, 223], [223, 53], [53, 224], [220, 45], [45, 134], [134, 220], [32, 211], [211, 140], [140, 32], [109, 67], [67, 108], [108, 109], [146, 43], [43, 91], [91, 146], [231, 230], [230, 120], [120, 231], [113, 226], [226, 247], [247, 113], [105, 63], [63, 52], [52, 105], [241, 238], [238, 242], [242, 241], [124, 46], [46, 156], [156, 124], [95, 78], [78, 96], [96, 95], [70, 46], [46, 63], [63, 70], [116, 143], [143, 227], [227, 116], [116, 123], [123, 111], [111, 116], [1, 44], [44, 19], [19, 1], [3, 236], [236, 51], [51, 3], [207, 216], [216, 205], [205, 207], [26, 154], [154, 22], [22, 26], [165, 39], [39, 167], [167, 165], [199, 200], [200, 208], [208, 199], [101, 36], [36, 100], [100, 101], [43, 57], [57, 202], [202, 43], [242, 20], [20, 99], [99, 242], [56, 28], [28, 157], [157, 56], [124, 35], [35, 113], [113, 124], [29, 160], [160, 27], [27, 29], [211, 204], [204, 210], [210, 211], [124, 113], [113, 46], [46, 124], [106, 43], [43, 204], [204, 106], [96, 62], [62, 77], [77, 96], [227, 137], [137, 116], [116, 227], [73, 41], [41, 72], [72, 73], [36, 203], [203, 142], [142, 36], [235, 64], [64, 240], [240, 235], [48, 49], [49, 64], [64, 48], [42, 41], [41, 74], [74, 42], [214, 212], [212, 207], [207, 214], [183, 42], [42, 184], [184, 183], [210, 169], [169, 211], [211, 210], [140, 170], [170, 176], [176, 140], [104, 105], [105, 69], [69, 104], [193, 122], [122, 168], [168, 193], [50, 123], [123, 187], [187, 50], [89, 96], [96, 90], [90, 89], [66, 65], [65, 107], [107, 66], [179, 89], [89, 180], [180, 179], [119, 101], [101, 120], [120, 119], [68, 63], [63, 104], [104, 68], [234, 93], [93, 227], [227, 234], [16, 15], [15, 85], [85, 16], [209, 129], [129, 49], [49, 209], [15, 14], [14, 86], [86, 15], [107, 55], [55, 9], [9, 107], [120, 100], [100, 121], [121, 120], [153, 145], [145, 22], [22, 153], [178, 88], [88, 179], [179, 178], [197, 6], [6, 196], [196, 197], [89, 88], [88, 96], [96, 89], [135, 138], [138, 136], [136, 135], [138, 215], [215, 172], [172, 138], [218, 115], [115, 219], [219, 218], [41, 42], [42, 81], [81, 41], [5, 195], [195, 51], [51, 5], [57, 43], [43, 61], [61, 57], [208, 171], [171, 199], [199, 208], [41, 81], [81, 38], [38, 41], [224, 53], [53, 225], [225, 224], [24, 144], [144, 110], [110, 24], [105, 52], [52, 66], [66, 105], [118, 229], [229, 117], [117, 118], [227, 34], [34, 234], [234, 227], [66, 107], [107, 69], [69, 66], [10, 109], [109, 151], [151, 10], [219, 48], [48, 235], [235, 219], [183, 62], [62, 191], [191, 183], [142, 129], [129, 126], [126, 142], [116, 111], [111, 143], [143, 116], [118, 117], [117, 50], [50, 118], [223, 222], [222, 52], [52, 223], [94, 19], [19, 141], [141, 94], [222, 221], [221, 65], [65, 222], [196, 3], [3, 197], [197, 196], [45, 220], [220, 44], [44, 45], [156, 70], [70, 139], [139, 156], [188, 122], [122, 245], [245, 188], [139, 71], [71, 162], [162, 139], [149, 170], [170, 150], [150, 149], [122, 188], [188, 196], [196, 122], [206, 216], [216, 92], [92, 206], [164, 2], [2, 167], [167, 164], [242, 141], [141, 241], [241, 242], [0, 164], [164, 37], [37, 0], [11, 72], [72, 12], [12, 11], [12, 38], [38, 13], [13, 12], [70, 63], [63, 71], [71, 70], [31, 226], [226, 111], [111, 31], [36, 101], [101, 205], [205, 36], [203, 206], [206, 165], [165, 203], [126, 209], [209, 217], [217, 126], [98, 165], [165, 97], [97, 98], [237, 220], [220, 218], [218, 237], [237, 239], [239, 241], [241, 237], [210, 214], [214, 169], [169, 210], [140, 171], [171, 32], [32, 140], [241, 125], [125, 237], [237, 241], [179, 86], [86, 178], [178, 179], [180, 85], [85, 179], [179, 180], [181, 84], [84, 180], [180, 181], [182, 83], [83, 181], [181, 182], [194, 201], [201, 182], [182, 194], [177, 137], [137, 132], [132, 177], [184, 76], [76, 183], [183, 184], [185, 61], [61, 184], [184, 185], [186, 57], [57, 185], [185, 186], [216, 212], [212, 186], [186, 216], [192, 214], [214, 187], [187, 192], [139, 34], [34, 156], [156, 139], [218, 79], [79, 237], [237, 218], [147, 123], [123, 177], [177, 147], [45, 44], [44, 4], [4, 45], [208, 201], [201, 32], [32, 208], [98, 64], [64, 129], [129, 98], [192, 213], [213, 138], [138, 192], [235, 59], [59, 219], [219, 235], [141, 242], [242, 97], [97, 141], [97, 2], [2, 141], [141, 97], [240, 75], [75, 235], [235, 240], [229, 24], [24, 228], [228, 229], [31, 25], [25, 226], [226, 31], [230, 23], [23, 229], [229, 230], [231, 22], [22, 230], [230, 231], [232, 26], [26, 231], [231, 232], [233, 112], [112, 232], [232, 233], [244, 189], [189, 243], [243, 244], [189, 221], [221, 190], [190, 189], [222, 28], [28, 221], [221, 222], [223, 27], [27, 222], [222, 223], [224, 29], [29, 223], [223, 224], [225, 30], [30, 224], [224, 225], [113, 247], [247, 225], [225, 113], [99, 60], [60, 240], [240, 99], [213, 147], [147, 215], [215, 213], [60, 20], [20, 166], [166, 60], [192, 187], [187, 213], [213, 192], [243, 112], [112, 244], [244, 243], [244, 233], [233, 245], [245, 244], [245, 128], [128, 188], [188, 245], [188, 114], [114, 174], [174, 188], [134, 131], [131, 220], [220, 134], [174, 217], [217, 236], [236, 174], [236, 198], [198, 134], [134, 236], [215, 177], [177, 58], [58, 215], [156, 143], [143, 124], [124, 156], [25, 110], [110, 7], [7, 25], [31, 228], [228, 25], [25, 31], [264, 356], [356, 368], [368, 264], [0, 11], [11, 267], [267, 0], [451, 452], [452, 349], [349, 451], [267, 302], [302, 269], [269, 267], [350, 357], [357, 277], [277, 350], [350, 452], [452, 357], [357, 350], [299, 333], [333, 297], [297, 299], [396, 175], [175, 377], [377, 396], [280, 347], [347, 330], [330, 280], [269, 303], [303, 270], [270, 269], [151, 9], [9, 337], [337, 151], [344, 278], [278, 360], [360, 344], [424, 418], [418, 431], [431, 424], [270, 304], [304, 409], [409, 270], [272, 310], [310, 407], [407, 272], [322, 270], [270, 410], [410, 322], [449, 450], [450, 347], [347, 449], [432, 422], [422, 434], [434, 432], [18, 313], [313, 17], [17, 18], [291, 306], [306, 375], [375, 291], [259, 387], [387, 260], [260, 259], [424, 335], [335, 418], [418, 424], [434, 364], [364, 416], [416, 434], [391, 423], [423, 327], [327, 391], [301, 251], [251, 298], [298, 301], [275, 281], [281, 4], [4, 275], [254, 373], [373, 253], [253, 254], [375, 307], [307, 321], [321, 375], [280, 425], [425, 411], [411, 280], [200, 421], [421, 18], [18, 200], [335, 321], [321, 406], [406, 335], [321, 320], [320, 405], [405, 321], [314, 315], [315, 17], [17, 314], [423, 426], [426, 266], [266, 423], [396, 377], [377, 369], [369, 396], [270, 322], [322, 269], [269, 270], [413, 417], [417, 464], [464, 413], [385, 386], [386, 258], [258, 385], [248, 456], [456, 419], [419, 248], [298, 284], [284, 333], [333, 298], [168, 417], [417, 8], [8, 168], [448, 346], [346, 261], [261, 448], [417, 413], [413, 285], [285, 417], [326, 327], [327, 328], [328, 326], [277, 355], [355, 329], [329, 277], [309, 392], [392, 438], [438, 309], [381, 382], [382, 256], [256, 381], [279, 429], [429, 360], [360, 279], [365, 364], [364, 379], [379, 365], [355, 277], [277, 437], [437, 355], [282, 443], [443, 283], [283, 282], [281, 275], [275, 363], [363, 281], [395, 431], [431, 369], [369, 395], [299, 297], [297, 337], [337, 299], [335, 273], [273, 321], [321, 335], [348, 450], [450, 349], [349, 348], [359, 446], [446, 467], [467, 359], [283, 293], [293, 282], [282, 283], [250, 458], [458, 462], [462, 250], [300, 276], [276, 383], [383, 300], [292, 308], [308, 325], [325, 292], [283, 276], [276, 293], [293, 283], [264, 372], [372, 447], [447, 264], [346, 352], [352, 340], [340, 346], [354, 274], [274, 19], [19, 354], [363, 456], [456, 281], [281, 363], [426, 436], [436, 425], [425, 426], [380, 381], [381, 252], [252, 380], [267, 269], [269, 393], [393, 267], [421, 200], [200, 428], [428, 421], [371, 266], [266, 329], [329, 371], [432, 287], [287, 422], [422, 432], [290, 250], [250, 328], [328, 290], [385, 258], [258, 384], [384, 385], [446, 265], [265, 342], [342, 446], [386, 387], [387, 257], [257, 386], [422, 424], [424, 430], [430, 422], [445, 342], [342, 276], [276, 445], [422, 273], [273, 424], [424, 422], [306, 292], [292, 307], [307, 306], [352, 366], [366, 345], [345, 352], [268, 271], [271, 302], [302, 268], [358, 423], [423, 371], [371, 358], [327, 294], [294, 460], [460, 327], [331, 279], [279, 294], [294, 331], [303, 271], [271, 304], [304, 303], [436, 432], [432, 427], [427, 436], [304, 272], [272, 408], [408, 304], [395, 394], [394, 431], [431, 395], [378, 395], [395, 400], [400, 378], [296, 334], [334, 299], [299, 296], [6, 351], [351, 168], [168, 6], [376, 352], [352, 411], [411, 376], [307, 325], [325, 320], [320, 307], [285, 295], [295, 336], [336, 285], [320, 319], [319, 404], [404, 320], [329, 330], [330, 349], [349, 329], [334, 293], [293, 333], [333, 334], [366, 323], [323, 447], [447, 366], [316, 15], [15, 315], [315, 316], [331, 358], [358, 279], [279, 331], [317, 14], [14, 316], [316, 317], [8, 285], [285, 9], [9, 8], [277, 329], [329, 350], [350, 277], [253, 374], [374, 252], [252, 253], [319, 318], [318, 403], [403, 319], [351, 6], [6, 419], [419, 351], [324, 318], [318, 325], [325, 324], [397, 367], [367, 365], [365, 397], [288, 435], [435, 397], [397, 288], [278, 344], [344, 439], [439, 278], [310, 272], [272, 311], [311, 310], [248, 195], [195, 281], [281, 248], [375, 273], [273, 291], [291, 375], [175, 396], [396, 199], [199, 175], [312, 311], [311, 268], [268, 312], [276, 283], [283, 445], [445, 276], [390, 373], [373, 339], [339, 390], [295, 282], [282, 296], [296, 295], [448, 449], [449, 346], [346, 448], [356, 264], [264, 454], [454, 356], [337, 336], [336, 299], [299, 337], [337, 338], [338, 151], [151, 337], [294, 278], [278, 455], [455, 294], [308, 292], [292, 415], [415, 308], [429, 358], [358, 355], [355, 429], [265, 340], [340, 372], [372, 265], [352, 346], [346, 280], [280, 352], [295, 442], [442, 282], [282, 295], [354, 19], [19, 370], [370, 354], [285, 441], [441, 295], [295, 285], [195, 248], [248, 197], [197, 195], [457, 440], [440, 274], [274, 457], [301, 300], [300, 368], [368, 301], [417, 351], [351, 465], [465, 417], [251, 301], [301, 389], [389, 251], [394, 395], [395, 379], [379, 394], [399, 412], [412, 419], [419, 399], [410, 436], [436, 322], [322, 410], [326, 2], [2, 393], [393, 326], [354, 370], [370, 461], [461, 354], [393, 164], [164, 267], [267, 393], [268, 302], [302, 12], [12, 268], [312, 268], [268, 13], [13, 312], [298, 293], [293, 301], [301, 298], [265, 446], [446, 340], [340, 265], [280, 330], [330, 425], [425, 280], [322, 426], [426, 391], [391, 322], [420, 429], [429, 437], [437, 420], [393, 391], [391, 326], [326, 393], [344, 440], [440, 438], [438, 344], [458, 459], [459, 461], [461, 458], [364, 434], [434, 394], [394, 364], [428, 396], [396, 262], [262, 428], [274, 354], [354, 457], [457, 274], [317, 316], [316, 402], [402, 317], [316, 315], [315, 403], [403, 316], [315, 314], [314, 404], [404, 315], [314, 313], [313, 405], [405, 314], [313, 421], [421, 406], [406, 313], [323, 366], [366, 361], [361, 323], [292, 306], [306, 407], [407, 292], [306, 291], [291, 408], [408, 306], [291, 287], [287, 409], [409, 291], [287, 432], [432, 410], [410, 287], [427, 434], [434, 411], [411, 427], [372, 264], [264, 383], [383, 372], [459, 309], [309, 457], [457, 459], [366, 352], [352, 401], [401, 366], [1, 274], [274, 4], [4, 1], [418, 421], [421, 262], [262, 418], [331, 294], [294, 358], [358, 331], [435, 433], [433, 367], [367, 435], [392, 289], [289, 439], [439, 392], [328, 462], [462, 326], [326, 328], [94, 2], [2, 370], [370, 94], [289, 305], [305, 455], [455, 289], [339, 254], [254, 448], [448, 339], [359, 255], [255, 446], [446, 359], [254, 253], [253, 449], [449, 254], [253, 252], [252, 450], [450, 253], [252, 256], [256, 451], [451, 252], [256, 341], [341, 452], [452, 256], [414, 413], [413, 463], [463, 414], [286, 441], [441, 414], [414, 286], [286, 258], [258, 441], [441, 286], [258, 257], [257, 442], [442, 258], [257, 259], [259, 443], [443, 257], [259, 260], [260, 444], [444, 259], [260, 467], [467, 445], [445, 260], [309, 459], [459, 250], [250, 309], [305, 289], [289, 290], [290, 305], [305, 290], [290, 460], [460, 305], [401, 376], [376, 435], [435, 401], [309, 250], [250, 392], [392, 309], [376, 411], [411, 433], [433, 376], [453, 341], [341, 464], [464, 453], [357, 453], [453, 465], [465, 357], [343, 357], [357, 412], [412, 343], [437, 343], [343, 399], [399, 437], [344, 360], [360, 440], [440, 344], [420, 437], [437, 456], [456, 420], [360, 420], [420, 363], [363, 360], [361, 401], [401, 288], [288, 361], [265, 372], [372, 353], [353, 265], [390, 339], [339, 249], [249, 390], [339, 448], [448, 255], [255, 339]]), A("matrixDataToMatrix", (function (e) { for (var t = e.getCols(), n = e.getRows(), r = e.getPackedDataList(), i = [], a = 0; a < n; a++)i.push(Array(t)); for (a = 0; a < n; a++)for (var o = 0; o < t; o++) { var s = 1 === e.getLayout() ? a * t + o : o * n + a; i[a][o] = r[s] } return i })), A("VERSION", "0.4.1633559619") }).call(this) }, 8554: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.h = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.h }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || l })); var c, h = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) c = Object.setPrototypeOf; else { var d; e: { var f = {}; try { f.__proto__ = { a: !0 }, d = f.a; break e } catch (e) { } d = !1 } c = d ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var p = c; function m(e, t) { if (e.prototype = h(t.prototype), e.prototype.constructor = e, p) p(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.ya = t.prototype } function g() { this.m = !1, this.j = null, this.i = void 0, this.h = 1, this.v = this.s = 0, this.l = null } function y(e) { if (e.m) throw new TypeError("Generator is already running"); e.m = !0 } function b(e, t) { e.l = { ma: t, na: !0 }, e.h = e.s || e.v } function v(e, t, n) { return e.h = n, { value: t } } function x(e) { this.h = new g, this.i = e } function w(e, t, n, r) { try { var i = t.call(e.h.j, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.h.m = !1, i; var a = i.value } catch (t) { return e.h.j = null, b(e.h, t), k(e) } return e.h.j = null, r.call(e.h, a), k(e) } function k(e) { for (; e.h.h;)try { var t = e.i(e.h); if (t) return e.h.m = !1, { value: t.value, done: !1 } } catch (t) { e.h.i = void 0, b(e.h, t) } if (e.h.m = !1, e.h.l) { if (t = e.h.l, e.h.l = null, t.na) throw t.ma; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function S(e) { this.next = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.next, t, e.h.u) : (e.h.u(t), t = k(e)), t }, this.throw = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.throw, t, e.h.u) : (b(e.h, t), t = k(e)), t }, this.return = function (t) { return function (e, t) { y(e.h); var n = e.h.j; return n ? w(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.h.return) : (e.h.return(t), k(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function _(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new S(new x(e))) } function C(e) { return e || Array.prototype.fill } g.prototype.u = function (e) { this.i = e }, g.prototype.return = function (e) { this.l = { return: e }, this.h = this.v }, a("Promise", (function (e) { function t(e) { this.i = 0, this.j = void 0, this.h = [], this.u = !1; var t = this.l(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.h = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.i = function (e) { if (null == this.h) { this.h = []; var t = this; this.j((function () { t.m() })) } this.h.push(e) }; var a = i.setTimeout; n.prototype.j = function (e) { a(e, 0) }, n.prototype.m = function () { for (; this.h && this.h.length;) { var e = this.h; this.h = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.l(e) } } } this.h = null }, n.prototype.l = function (e) { this.j((function () { throw e })) }, t.prototype.l = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.I), reject: e(this.m) } }, t.prototype.I = function (e) { if (e === this) this.m(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.L(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.F(e) : this.s(e) } }, t.prototype.F = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.m(e) } "function" == typeof t ? this.M(t, e) : this.s(e) }, t.prototype.m = function (e) { this.v(2, e) }, t.prototype.s = function (e) { this.v(1, e) }, t.prototype.v = function (e, t) { if (0 != this.i) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.i); this.i = e, this.j = t, 2 === this.i && this.K(), this.H() }, t.prototype.K = function () { var e = this; a((function () { if (e.D()) { var t = i.console; void 0 !== t && t.error(e.j) } }), 1) }, t.prototype.D = function () { if (this.u) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.j, n(e)) }, t.prototype.H = function () { if (null != this.h) { for (var e = 0; e < this.h.length; ++e)o.i(this.h[e]); this.h = null } }; var o = new n; return t.prototype.L = function (e) { var t = this.l(); e.T(t.resolve, t.reject) }, t.prototype.M = function (e, t) { var n = this.l(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.T(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.T = function (e, t) { function n() { switch (r.i) { case 1: e(r.j); break; case 2: t(r.j); break; default: throw Error("Unexpected state: " + r.i) } } var r = this; null == this.h ? o.i(n) : this.h.push(n), this.u = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).T(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).T(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })), a("Array.prototype.fill", (function (e) { return e || function (e, t, n) { var r = this.length || 0; for (0 > t && (t = Math.max(0, r + t)), (null == n || n > r) && (n = r), 0 > (n = Number(n)) && (n = Math.max(0, r + n)), t = Number(t || 0); t < n; t++)this[t] = e; return this } })), a("Int8Array.prototype.fill", C), a("Uint8Array.prototype.fill", C), a("Uint8ClampedArray.prototype.fill", C), a("Int16Array.prototype.fill", C), a("Uint16Array.prototype.fill", C), a("Int32Array.prototype.fill", C), a("Uint32Array.prototype.fill", C), a("Float32Array.prototype.fill", C), a("Float64Array.prototype.fill", C), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })); var A = this || self; function T(e, t) { e = e.split("."); var n, r = A; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function E(e) { var t; return (t = A.navigator) && (t = t.userAgent) || (t = ""), -1 != t.indexOf(e) } var N = Array.prototype.map ? function (e, t) { return Array.prototype.map.call(e, t, void 0) } : function (e, t) { for (var n = e.length, r = Array(n), i = "string" == typeof e ? e.split("") : e, a = 0; a < n; a++)a in i && (r[a] = t.call(void 0, i[a], a, e)); return r }, I = {}, M = null; function F(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = M[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } D(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function D() { if (!M) { M = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); I[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === M[a] && (M[a] = i) } } } } var $ = "undefined" != typeof Uint8Array, R = !(E("Trident") || E("MSIE")) && "function" == typeof A.btoa; function O(e) { if (!R) { var t; void 0 === t && (t = 0), D(), t = I[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } for (t = ""; 10240 < e.length;)t += String.fromCharCode.apply(null, e.subarray(0, 10240)), e = e.subarray(10240); return t += String.fromCharCode.apply(null, e), btoa(t) } var z, P = RegExp("[-_.]", "g"); function B(e) { switch (e) { case "-": return "+"; case "_": return "/"; case ".": return "="; default: return "" } } function L(e) { if (!R) return F(e); P.test(e) && (e = e.replace(P, B)), e = atob(e); for (var t = new Uint8Array(e.length), n = 0; n < e.length; n++)t[n] = e.charCodeAt(n); return t } function j() { return z || (z = new Uint8Array(0)) } var U = {}, W = "function" == typeof Uint8Array.prototype.slice, V = 0, G = 0; function H(e) { var t = 0 > e, n = (e = Math.abs(e)) >>> 0; e = Math.floor((e - n) / 4294967296), t && (t = (n = s(X(n, e))).next().value, e = n.next().value, n = t), V = n >>> 0, G = e >>> 0 } var q, Y = "function" == typeof BigInt; function X(e, t) { return t = ~t, e ? e = 1 + ~e : t += 1, [e, t] } function K(e, t) { this.i = e >>> 0, this.h = t >>> 0 } function Z(e) { if (!e) return q || (q = new K(0, 0)); if (!/^-?\d+$/.test(e)) return null; if (16 > e.length) H(Number(e)); else if (Y) e = BigInt(e), V = Number(e & BigInt(4294967295)) >>> 0, G = Number(e >> BigInt(32) & BigInt(4294967295)); else { var t = +("-" === e[0]); G = V = 0; for (var n = e.length, r = t, i = (n - t) % 6 + t; i <= n; r = i, i += 6)r = Number(e.slice(r, i)), G *= 1e6, 4294967296 <= (V = 1e6 * V + r) && (G += V / 4294967296 | 0, V %= 4294967296); t && (e = (t = s(X(V, G))).next().value, t = t.next().value, V = e, G = t) } return new K(V, G) } function J(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function Q() { return Error("Failed to read varint, encoding is invalid.") } function ee(e, t) { return Error("Tried to read past the end of the data " + t + " > " + e) } function te() { throw Error("Invalid UTF8") } function ne(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var re, ie, ae, oe = void 0, se = "undefined" != typeof TextDecoder, ue = "undefined" != typeof TextEncoder; function le(e) { if (e !== U) throw Error("illegal external caller") } function ce(e, t) { if (le(t), this.V = e, null != e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } function he() { return ae || (ae = new ce(null, U)) } function de(e) { le(U); var t = e.V; return null == (t = null == t || $ && null != t && t instanceof Uint8Array ? t : "string" == typeof t ? L(t) : null) ? t : e.V = t } function fe(e, t) { this.i = null, this.m = !1, this.h = this.j = this.l = 0, pe(this, e, t) } function pe(e, t, n) { n = void 0 === n ? {} : n, e.S = void 0 !== n.S && n.S, t && (t = function (e) { if ("string" == typeof e) return { buffer: L(e), C: !1 }; if (Array.isArray(e)) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === Uint8Array) return { buffer: e, C: !1 }; if (e.constructor === ArrayBuffer) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === ce) return { buffer: de(e) || j(), C: !0 }; if (e instanceof Uint8Array) return { buffer: new Uint8Array(e.buffer, e.byteOffset, e.byteLength), C: !1 }; throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers") }(t), e.i = t.buffer, e.m = t.C, e.l = 0, e.j = e.i.length, e.h = e.l) } function me(e, t) { if (e.h = t, t > e.j) throw ee(e.j, t) } function ge(e) { var t = e.i, n = e.h, r = t[n++], i = 127 & r; if (128 & r && (i |= (127 & (r = t[n++])) << 7, 128 & r && (i |= (127 & (r = t[n++])) << 14, 128 & r && (i |= (127 & (r = t[n++])) << 21, 128 & r && (i |= (r = t[n++]) << 28, 128 & r && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++]))))) throw Q(); return me(e, n), i } function ye(e, t) { if (0 > t) throw Error("Tried to read a negative byte length: " + t); var n = e.h, r = n + t; if (r > e.j) throw ee(t, e.j - n); return e.h = r, n } fe.prototype.reset = function () { this.h = this.l }; var be = []; function ve() { this.h = [] } function xe(e, t, n) { for (; 0 < n || 127 < t;)e.h.push(127 & t | 128), t = (t >>> 7 | n << 25) >>> 0, n >>>= 7; e.h.push(t) } function we(e, t) { for (; 127 < t;)e.h.push(127 & t | 128), t >>>= 7; e.h.push(t) } function ke(e, t) { if (be.length) { var n = be.pop(); pe(n, e, t), e = n } else e = new fe(e, t); this.h = e, this.j = this.h.h, this.i = this.l = -1, this.setOptions(t) } function Se(e) { var t = e.h; if (t.h == t.j) return !1; e.j = e.h.h; var n = ge(e.h) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw J(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.l = t, e.i = n, !0 } function _e(e) { switch (e.i) { case 0: if (0 != e.i) _e(e); else e: { for (var t = (e = e.h).h, n = t + 10, r = e.i; t < n;)if (!(128 & r[t++])) { me(e, t); break e } throw Q() } break; case 1: me(e = e.h, e.h + 8); break; case 2: 2 != e.i ? _e(e) : (t = ge(e.h) >>> 0, me(e = e.h, e.h + t)); break; case 5: me(e = e.h, e.h + 4); break; case 3: for (t = e.l; ;) { if (!Se(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.i) { if (e.l != t) throw Error("Unmatched end-group tag"); break } _e(e) } break; default: throw J(e.i, e.j) } } ve.prototype.length = function () { return this.h.length }, ve.prototype.end = function () { var e = this.h; return this.h = [], e }, ke.prototype.setOptions = function (e) { e = void 0 === e ? {} : e, this.ca = void 0 !== e.ca && e.ca }, ke.prototype.reset = function () { this.h.reset(), this.j = this.h.h, this.i = this.l = -1 }; var Ce = []; function Ae() { this.j = [], this.i = 0, this.h = new ve } function Te(e, t) { 0 !== t.length && (e.j.push(t), e.i += t.length) } var Ee = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol() : void 0; function Ne(e, t) { return Ee ? e[Ee] |= t : void 0 !== e.A ? e.A |= t : (Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }), t) } function Ie(e, t) { Ee ? e[Ee] && (e[Ee] &= ~t) : void 0 !== e.A && (e.A &= ~t) } function Me(e) { var t; return null == (t = Ee ? e[Ee] : e.A) ? 0 : t } function Fe(e, t) { Ee ? e[Ee] = t : void 0 !== e.A ? e.A = t : Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }) } function De(e) { return Ne(e, 1), e } function $e(e, t) { Fe(t, -51 & e) } function Re(e, t) { Fe(t, -41 & e | 18) } var Oe = {}; function ze(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var Pe, Be, Le = []; function je(e) { if (2 & Me(e.o)) throw Error("Cannot mutate an immutable Message") } function Ue(e) { var t = e.length; (t = t ? e[t - 1] : void 0) && ze(t) ? t.g = 1 : (t = {}, e.push((t.g = 1, t))) } function We(e) { var t = e.i + e.G; return e.B || (e.B = e.o[t] = {}) } function Ve(e, t) { return -1 === t ? null : t >= e.i ? e.B ? e.B[t] : void 0 : e.o[t + e.G] } function Ge(e, t, n, r) { je(e), He(e, t, n, r) } function He(e, t, n, r) { e.j && (e.j = void 0), t >= e.i || r ? We(e)[t] = n : (e.o[t + e.G] = n, (e = e.B) && t in e && delete e[t]) } function qe(e, t, n, r) { var i = Ve(e, t); Array.isArray(i) || (i = Pe); var a = Me(i); if (1 & a || De(i), r) 2 & a || Ne(i, 2), 1 & n || Object.freeze(i); else { r = !(2 & n); var o = 2 & a; 1 & n || !o ? r && 16 & a && !o && Ie(i, 16) : He(e, t, i = De(Array.prototype.slice.call(i))) } return i } function Ye(e, t) { var n = Ve(e, t), r = null == n ? n : "number" == typeof n || "NaN" === n || "Infinity" === n || "-Infinity" === n ? Number(n) : void 0; return null != r && r !== n && He(e, t, r), r } function Xe(e, t, n, r, i) { e.h || (e.h = {}); var a = e.h[n], o = qe(e, n, 3, i); if (!a) { var s = o; a = []; var u = !!(16 & Me(e.o)); o = !!(2 & Me(s)); var l = s; !i && o && (s = Array.prototype.slice.call(s)); for (var c = o, h = 0; h < s.length; h++) { var d = s[h], f = t, p = !1; if (p = void 0 !== p && p, void 0 !== (d = Array.isArray(d) ? new f(d) : p ? new f : void 0)) { var m = p = Me(f = d.o); o && (m |= 2), u && (m |= 16), m != p && Fe(f, m), f = m, c = c || !!(2 & f), a.push(d) } } return e.h[n] = a, t = 33 | (u = Me(s)), u != (t = c ? -9 & t : 8 | t) && (c = s, Object.isFrozen(c) && (c = Array.prototype.slice.call(c)), Fe(c, t), s = c), l !== s && He(e, n, s), (i || r && o) && Ne(a, 2), r && Object.freeze(a), a } return i || (i = Object.isFrozen(a), r && !i ? Object.freeze(a) : !r && i && (a = Array.prototype.slice.call(a), e.h[n] = a)), a } function Ke(e, t, n) { var r = !!(2 & Me(e.o)); if (t = Xe(e, t, n, r, r), e = qe(e, n, 3, r), !(r || 8 & Me(e))) { for (r = 0; r < t.length; r++) { if (2 & Me((n = t[r]).o)) { var i = ut(n, !1); i.j = n } else i = n; n !== i && (t[r] = i, e[r] = i.o) } Ne(e, 8) } return t } function Ze(e, t, n) { if (null != n && "number" != typeof n) throw Error("Value of float/double field must be a number|null|undefined, found " + typeof n + ": " + n); Ge(e, t, n) } function Je(e, t, n, r, i) { je(e); var a = Xe(e, n, t, !1, !1); return n = null != r ? r : new n, e = qe(e, t, 2, !1), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.o)) : (a.push(n), e.push(n.o)), n.C() && Ie(e, 8), n } function Qe(e, t) { return null == e ? t : e } function et(e, t, n) { return n = void 0 === n ? 0 : n, Qe(Ye(e, t), n) } function tt(e, t, n, r) { if (null != e) { if (Array.isArray(e)) e = nt(e, t, n, void 0 !== r); else if (ze(e)) { var i, a = {}; for (i in e) a[i] = tt(e[i], t, n, r); e = a } else e = t(e, r); return e } } function nt(e, t, n, r) { var i = Me(e); r = r ? !!(16 & i) : void 0, e = Array.prototype.slice.call(e); for (var a = 0; a < e.length; a++)e[a] = tt(e[a], t, n, r); return n(i, e), e } function rt(e) { return e.ja === Oe ? e.toJSON() : function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e) if (Array.isArray(e)) { if (128 & Me(e)) return Ue(e = Array.prototype.slice.call(e)), e } else { if ($ && null != e && e instanceof Uint8Array) return O(e); if (e instanceof ce) { var t = e.V; return null == t ? "" : "string" == typeof t ? t : e.V = O(t) } } }return e }(e) } function it(e, t) { 128 & e && Ue(t) } function at(e, t, n) { if (n = void 0 === n ? Re : n, null != e) { if ($ && e instanceof Uint8Array) return e.length ? new ce(new Uint8Array(e), U) : he(); if (Array.isArray(e)) { var r = Me(e); return 2 & r ? e : !t || 32 & r || !(16 & r || 0 === r) ? (4 & (t = Me(e = nt(e, at, 4 & r ? Re : n, !0))) && 2 & t && Object.freeze(e), e) : (Fe(e, 2 | r), e) } return e.ja === Oe ? st(e) : e } } function ot(e, t, n, r, i, a, o) { if (e = e.h && e.h[n]) { if (2 & (r = Me(e)) ? r = e : (Re(r, a = N(e, st)), Object.freeze(a), r = a), je(t), o = null == r ? Pe : De([]), null != r) { for (a = !!r.length, e = 0; e < r.length; e++) { var s = r[e]; a = a && !(2 & Me(s.o)), o[e] = s.o } a = 1 | (a ? 8 : 0), ((e = Me(o)) & a) !== a && (Object.isFrozen(o) && (o = Array.prototype.slice.call(o)), Fe(o, e | a)), t.h || (t.h = {}), t.h[n] = r } else t.h && (t.h[n] = void 0); He(t, n, o, i) } else Ge(t, n, at(r, a, o), i) } function st(e) { return 2 & Me(e.o) || Ne((e = ut(e, !0)).o, 2), e } function ut(e, t) { var n = e.o, r = []; Ne(r, 16); var i = e.constructor.h; if (i && r.push(i), i = e.B) { r.length = n.length, r.fill(void 0, r.length, n.length); var a = {}; r[r.length - 1] = a } 128 & Me(n) && Ue(r), t = t || e.C() ? Re : $e, a = e.constructor, Be = r, r = new a(r), Be = void 0, e.R && (r.R = e.R.slice()), a = !!(16 & Me(n)); for (var o = i ? n.length - 1 : n.length, s = 0; s < o; s++)ot(e, r, s - e.G, n[s], !1, a, t); if (i) for (var u in i) ot(e, r, +u, i[u], !0, a, t); return r } function lt(e, t, n) { null == e && (e = Be), Be = void 0; var r, i = this.constructor.i || 0, a = 0 < i, o = this.constructor.h, s = !1; if (null == e) { var u = 48, l = !0; a && (i = 0, u |= 128), Fe(e = o ? [o] : [], u) } else { if (!Array.isArray(e)) throw Error(); if (o && o !== e[0]) throw Error(); var c = u = Ne(e, 0); if ((l = !!(16 & c)) && ((s = !!(32 & c)) || (c |= 32)), a) { if (128 & c) i = 0; else if (0 < e.length) { var h = e[e.length - 1]; if (ze(h) && "g" in h) { i = 0, c |= 128, delete h.g; var d, f = !0; for (d in h) { f = !1; break } f && e.pop() } } } else if (128 & c) throw Error(); u !== c && Fe(e, c) } if (this.G = (o ? 0 : -1) - i, this.h = void 0, this.o = e, i = (o = this.o.length) - 1, o && ze(o = this.o[i]) ? (this.B = o, this.i = i - this.G) : void 0 !== t && -1 < t ? (this.i = Math.max(t, i + 1 - this.G), this.B = void 0) : this.i = Number.MAX_VALUE, !a && this.B && "g" in this.B) throw Error('Unexpected "g" flag in sparse object of message that is not a group type.'); if (n) for (t = l && !s && !0, a = this.i, l = 0; l < n.length; l++)(s = n[l]) < a ? (i = e[s += this.G]) ? ct(i, t) : e[s] = Pe : (r || (r = We(this)), (i = r[s]) ? ct(i, t) : r[s] = Pe) } function ct(e, t) { if (Array.isArray(e)) { var n = Me(e), r = 1; !t || 2 & n || (r |= 16), (n & r) !== r && Fe(e, n | r) } } function ht(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.qa; o || (i.J = a.wa || a.oa.W, a.ia ? (i.aa = vt(a.ia), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.aa) } }(i)) : a.ka ? (i.Z = xt(a.da.P, a.ka), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.Z) } }(i)) : o = i.J, a.qa = o), o(t, e, a.da), i = { J: i.J, aa: i.aa, Z: i.Z } } } !function (e, t) { if (t = t.R) { Te(e, e.h.end()); for (var n = 0; n < t.length; n++)Te(e, de(t[n]) || j()) } }(t, e) } Fe(Le, 23), Pe = Object.freeze(Le), lt.prototype.toJSON = function () { return nt(this.o, rt, it) }, lt.prototype.C = function () { return !!(2 & Me(this.o)) }, lt.prototype.ja = Oe, lt.prototype.toString = function () { return this.o.toString() }; var dt = Symbol(); function ft(e, t, n) { return e[dt] || (e[dt] = function (e, r) { return t(e, r, n) }) } function pt(e) { var t = e[dt]; if (!t) { var n = Ft(e); t = function (e, t) { return Dt(e, t, n) }, e[dt] = t } return t } function mt(e) { var t = function (e) { var t = e.ia; return t ? pt(t) : (t = e.va) ? ft(e.da.P, t, e.ka) : void 0 }(e), n = e.da, r = e.oa.U; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function gt(e, t) { var n = e[t]; return "function" == typeof n && 0 === n.length && (n = n(), e[t] = n), Array.isArray(n) && (Tt in n || wt in n || 0 < n.length && "function" == typeof n[0]) ? n : void 0 } function yt(e, t, n, r, i, a) { t.P = e[0]; var o = 1; if (e.length > o && "number" != typeof e[o]) { var s = e[o++]; n(t, s) } for (; o < e.length;) { n = e[o++]; for (var u = o + 1; u < e.length && "number" != typeof e[u];)u++; switch (s = e[o++], u -= o) { case 0: r(t, n, s); break; case 1: (u = gt(e, o)) ? (o++, i(t, n, s, u)) : r(t, n, s, e[o++]); break; case 2: i(t, n, s, u = gt(e, u = o++), e[o++]); break; case 3: a(t, n, s, e[o++], e[o++], e[o++]); break; case 4: a(t, n, s, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + u) } } return t } var bt = Symbol(); function vt(e) { var t = e[bt]; if (!t) { var n = At(e); t = function (e, t) { return $t(e, t, n) }, e[bt] = t } return t } function xt(e, t) { var n = e[bt]; return n || (n = function (e, n) { return ht(e, n, t) }, e[bt] = n), n } var wt = Symbol(); function kt(e, t) { e.push(t) } function St(e, t, n) { e.push(t, n.W) } function _t(e, t, n, r) { var i = vt(r), a = At(r).P, o = n.W; e.push(t, (function (e, t, n) { return o(e, t, n, a, i) })) } function Ct(e, t, n, r, i, a) { var o = xt(r, a), s = n.W; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function At(e) { var t = e[wt]; return t || (t = yt(e, e[wt] = [], kt, St, _t, Ct), Tt in e && wt in e && (e.length = 0), t) } var Tt = Symbol(); function Et(e, t) { e[0] = t } function Nt(e, t, n, r) { var i = n.U; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function It(e, t, n, r, i) { var a = n.U, o = pt(r), s = Ft(r).P; e[t] = function (e, t, n) { return a(e, t, n, s, o, i) } } function Mt(e, t, n, r, i, a, o) { var s = n.U, u = ft(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Ft(e) { var t = e[Tt]; return t || (t = yt(e, e[Tt] = {}, Et, Nt, It, Mt), Tt in e && wt in e && (e.length = 0), t) } function Dt(e, t, n) { for (; Se(t) && 4 != t.i;) { var r = t.l, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = mt(a)) } if (!i || !i(t, e, r)) { r = e, a = (i = t).j, _e(i); var o = i; if (!o.ca) { if (i = o.h.h - a, o.h.h = a, o = o.h, 0 == i) i = he(); else { if (a = ye(o, i), o.S && o.m) i = o.i.subarray(a, a + i); else { o = o.i; var s = a; i = s === (i = a + i) ? j() : W ? o.slice(s, i) : new Uint8Array(o.subarray(s, i)) } i = 0 == i.length ? he() : new ce(i, U) } (a = r.R) ? a.push(i) : r.R = [i] } } } return e } function $t(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); ht(e, t, i ? n[0] : void 0) } function Rt(e, t) { return { U: e, W: t } } var Ot = Rt((function (e, t, n) { if (5 !== e.i) return !1; var r = (e = e.h).i, i = e.h, a = r[i], o = r[i + 1], s = r[i + 2]; return r = r[i + 3], me(e, e.h + 4), e = 2 * ((o = (a | o << 8 | s << 16 | r << 24) >>> 0) >> 31) + 1, a = o >>> 23 & 255, o &= 8388607, Ge(t, n, 255 == a ? o ? NaN : 1 / 0 * e : 0 == a ? e * Math.pow(2, -149) * o : e * Math.pow(2, a - 150) * (o + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = Ye(t, n))) { we(e.h, 8 * n + 5), e = e.h; var r = +t; 0 === r ? 0 < 1 / r ? V = G = 0 : (G = 0, V = 2147483648) : isNaN(r) ? (G = 0, V = 2147483647) : 34028234663852886e22 < (r = (n = 0 > r ? -2147483648 : 0) ? -r : r) ? (G = 0, V = (2139095040 | n) >>> 0) : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), G = 0, V = (n | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, G = 0, V = (n | t + 127 << 23 | 8388607 & r) >>> 0), n = V, e.h.push(n >>> 0 & 255), e.h.push(n >>> 8 & 255), e.h.push(n >>> 16 & 255), e.h.push(n >>> 24 & 255) } })), zt = Rt((function (e, t, n) { if (0 !== e.i) return !1; var r = e.h, i = 0, a = e = 0, o = r.i, s = r.h; do { var u = o[s++]; i |= (127 & u) << a, a += 7 } while (32 > a && 128 & u); for (32 < a && (e |= (127 & u) >> 4), a = 3; 32 > a && 128 & u; a += 7)e |= (127 & (u = o[s++])) << a; if (me(r, s), !(128 > u)) throw Q(); return r = i >>> 0, (e = 2147483648 & (u = e >>> 0)) && (u = ~u >>> 0, 0 == (r = 1 + ~r >>> 0) && (u = u + 1 >>> 0)), r = 4294967296 * u + (r >>> 0), Ge(t, n, e ? -r : r), !0 }), (function (e, t, n) { null != (t = Ve(t, n)) && ("string" == typeof t && Z(t), null != t && (we(e.h, 8 * n), "number" == typeof t ? (e = e.h, H(t), xe(e, V, G)) : (n = Z(t), xe(e.h, n.i, n.h)))) })), Pt = Rt((function (e, t, n) { return 0 === e.i && (Ge(t, n, ge(e.h)), !0) }), (function (e, t, n) { if (null != (t = Ve(t, n)) && null != t) if (we(e.h, 8 * n), e = e.h, 0 <= (n = t)) we(e, n); else { for (t = 0; 9 > t; t++)e.h.push(127 & n | 128), n >>= 7; e.h.push(1) } })), Bt = Rt((function (e, t, n) { if (2 !== e.i) return !1; var r = ge(e.h) >>> 0, i = ye(e = e.h, r); if (e = e.i, se) { var a, o = e; (a = re) || (a = re = new TextDecoder("utf-8", { fatal: !0 })), e = i + r, o = 0 === i && e === o.length ? o : o.subarray(i, e); try { var s = a.decode(o) } catch (e) { if (void 0 === oe) { try { a.decode(new Uint8Array([128])) } catch (e) { } try { a.decode(new Uint8Array([97])), oe = !0 } catch (e) { oe = !1 } } throw !oe && (re = void 0), e } } else { r = (s = i) + r, i = []; for (var u, l, c = null; s < r;)128 > (u = e[s++]) ? i.push(u) : 224 > u ? s >= r ? te() : (l = e[s++], 194 > u || 128 != (192 & l) ? (s--, te()) : i.push((31 & u) << 6 | 63 & l)) : 240 > u ? s >= r - 1 ? te() : 128 != (192 & (l = e[s++])) || 224 === u && 160 > l || 237 === u && 160 <= l || 128 != (192 & (o = e[s++])) ? (s--, te()) : i.push((15 & u) << 12 | (63 & l) << 6 | 63 & o) : 244 >= u ? s >= r - 2 ? te() : 128 != (192 & (l = e[s++])) || l - 144 + (u << 28) >> 30 || 128 != (192 & (o = e[s++])) || 128 != (192 & (a = e[s++])) ? (s--, te()) : (u = (7 & u) << 18 | (63 & l) << 12 | (63 & o) << 6 | 63 & a, u -= 65536, i.push(55296 + (u >> 10 & 1023), 56320 + (1023 & u))) : te(), 8192 <= i.length && (c = ne(c, i), i.length = 0); s = ne(c, i) } return Ge(t, n, s), !0 }), (function (e, t, n) { if (null != (t = Ve(t, n))) { var r = !1; if (r = void 0 !== r && r, ue) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (ie || (ie = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = i === a.length ? a : a.subarray(0, i) } we(e.h, 8 * n + 2), we(e.h, t.length), Te(e, e.h.end()), Te(e, t) } })), Lt = Rt((function (e, t, n, r, i) { if (2 !== e.i) return !1; t = Je(t, n, r), n = e.h.j, r = ge(e.h) >>> 0; var a = e.h.h + r, o = a - n; if (0 >= o && (e.h.j = a, i(t, e, void 0, void 0, void 0), o = a - e.h.h), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.h.h = a, e.h.j = n, !0 }), (function (e, t, n, r, i) { if (null != (t = Ke(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; we(a.h, 8 * n + 2); var o = a.h.end(); Te(a, o), o.push(a.i), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.i + o.h.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.i++; a.push(s), o.i++ } })); function jt(e) { return function (t, n) { e: { if (Ce.length) { var r = Ce.pop(); r.setOptions(n), pe(r.h, t, n), t = r } else t = new ke(t, n); try { var i = Ft(e), a = Dt(new i.P, t, i); break e } finally { (i = t.h).i = null, i.m = !1, i.l = 0, i.j = 0, i.h = 0, i.S = !1, t.l = -1, t.i = -1, 100 > Ce.length && Ce.push(t) } a = void 0 } return a } } function Ut(e) { return function () { var t = new Ae; $t(this, t, At(e)), Te(t, t.h.end()); for (var n = new Uint8Array(t.i), r = t.j, i = r.length, a = 0, o = 0; o < i; o++) { var s = r[o]; n.set(s, a), a += s.length } return t.j = [n], n } } function Wt(e) { lt.call(this, e) } m(Wt, lt); var Vt = [Wt, 1, Pt, 2, Ot, 3, Bt, 4, Bt]; function Gt(e) { lt.call(this, e, -1, Ht) } Wt.prototype.l = Ut(Vt), m(Gt, lt), Gt.prototype.addClassification = function (e, t) { return Je(this, 1, Wt, e, t), this }; var Ht = [1], qt = jt([Gt, 1, Lt, Vt]); function Yt(e) { lt.call(this, e) } m(Yt, lt); var Xt = [Yt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot]; function Kt(e) { lt.call(this, e, -1, Zt) } Yt.prototype.l = Ut(Xt), m(Kt, lt); var Zt = [1], Jt = jt([Kt, 1, Lt, Xt]); function Qt(e) { lt.call(this, e) } m(Qt, lt); var en = [Qt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot, 6, zt], tn = jt(en); function nn(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function rn(e) { return Ke(e, Wt, 1).map((function (e) { var t = Ve(e, 1); return { index: null == t ? 0 : t, score: et(e, 2), label: null != Ve(e, 3) ? Qe(Ve(e, 3), "") : void 0, displayName: null != Ve(e, 4) ? Qe(Ve(e, 4), "") : void 0 } })) } function an(e) { return { x: et(e, 1), y: et(e, 2), z: et(e, 3), visibility: null != Ye(e, 4) ? et(e, 4) : void 0 } } function on(e) { return e.map((function (e) { return Ke(Jt(e), Yt, 1).map(an) })) } function sn(e, t) { this.i = e, this.h = t, this.m = 0 } function un(e, t, n) { return function (e, t) { var n = e.h; if (void 0 === e.s) { var r = nn(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = nn(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.s = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.l = { O: n.getAttribLocation(r, "aVertex"), N: n.getAttribLocation(r, "aTex"), xa: i }, e.v = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.enableVertexAttribArray(e.l.O), n.vertexAttribPointer(e.l.O, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.l.N), n.vertexAttribPointer(e.l.N, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.l, n.useProgram(e.s), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.i.bindTexture2d(t.glName), n.enableVertexAttribArray(r.O), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.vertexAttribPointer(r.O, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.N, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.O), n.disableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, null), e.i.bindTexture2d(0) }(e, t), "function" == typeof e.h.canvas.transferToImageBitmap ? Promise.resolve(e.h.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.h.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.h.canvas) : (void 0 === e.j && (e.j = document.createElement("canvas")), new Promise((function (t) { e.j.height = e.h.canvas.height, e.j.width = e.h.canvas.width, e.j.getContext("2d", {}).drawImage(e.h.canvas, 0, 0, e.h.canvas.width, e.h.canvas.height), t(e.j) }))) } function ln(e) { this.h = e } Qt.prototype.l = Ut(en); var cn = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function hn(e, t) { return t + e } function dn(e, t) { window[e] = t } function fn(e) { if (this.h = e, this.listeners = {}, this.l = {}, this.L = {}, this.s = {}, this.v = {}, this.M = this.u = this.ga = !0, this.I = Promise.resolve(), this.fa = "", this.D = {}, this.locateFile = e && e.locateFile || hn, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.ha = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.l[n] = "function" == typeof r ? r() : r) } } function pn(e) { var t, n, r, i, a, o, s, l, c, h, d; return _((function (f) { switch (f.h) { case 1: return e.ga ? (t = void 0 === e.h.files ? [] : "function" == typeof e.h.files ? e.h.files(e.l) : e.h.files, v(f, _((function (e) { switch (e.h) { case 1: return e.s = 2, v(e, WebAssembly.instantiate(cn), 4); case 4: e.h = 3, e.s = 0; break; case 2: return e.s = 0, e.l = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.i, "object" == typeof window) return dn("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), dn("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), s = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = mn(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(s.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.ha)) : Promise.resolve() }))).then((function () { var t, n, r; return _((function (i) { if (1 == i.h) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, v(i, t(n), 2); r.i = i.i, i.h = 0 })) })), h = _((function (t) { return e.h.graph && e.h.graph.url ? t = v(t, mn(e, e.h.graph.url), 0) : (t.h = 0, t = void 0), t })), v(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.ha) })), importScripts.apply(null, u(r)), i = e, v(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.i = f.i, e.m = new OffscreenCanvas(1, 1), e.i.canvas = e.m, a = e.i.GL.createContext(e.m, { antialias: !1, alpha: !1, ua: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.i.GL.makeContextCurrent(a), f.h = 4; break; case 7: if (e.m = document.createElement("canvas"), !(d = e.m.getContext("webgl2", {})) && !(d = e.m.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.K = d, e.i.canvas = e.m, e.i.createContext(e.m, !0, !0, {}); case 4: e.j = new e.i.SolutionWasm, e.ga = !1, f.h = 0 } })) } function mn(e, t) { var n, r; return _((function (i) { return t in e.L ? i.return(e.L[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.L[t] = r, i.return(r)) })) } function gn(e, t, n) { var r, i, a, o, u, l, c, h, d, f, p, m, g, y; return _((function (b) { switch (b.h) { case 1: if (!n) return b.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.M = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { b.h = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, v(b, function (e, t, n) { var r; return _((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.i.Uint8BlobList ? i.return(n) : n instanceof e.i.Texture2dDataOut ? ((r = e.v[t]) || (r = new sn(e.i, e.K), e.v[t] = r), i.return(un(r, n, e.M))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), S = [], C = 0; C < x.size(); ++C) { var A = tn(x.get(C)), T = void 0; T = void 0 === T ? 0 : T, A = { la: { ra: et(A, 1), sa: et(A, 2), height: et(A, 3), width: et(A, 4), rotation: et(A, 5, 0), pa: Qe(Ve(A, 6), T) }, ea: Ke(Jt(w.get(C)), Yt, 1).map(an), ba: rn(qt(k.get(C))) }, S.push(A) } x = S } else x = []; r[h] = x, b.h = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, b.h = 7; break } if (void 0 === f) { b.h = 3; break } if ("float_list" === d.type) { r[h] = f, b.h = 7; break } if ("proto" === d.type) { r[h] = f, b.h = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.v[h]) || (p = new sn(e.i, e.K), e.v[h] = p), v(b, un(p, f, e.M), 13); case 13: m = b.i, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), b.h = 3; break; case 14: g[y] = b.i; case 3: o = c.next(), b.h = 2; break; case 4: return b.return(r) } })) } function yn(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.i.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.i.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.I = gn(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.I = n) }))) } }), e.j.attachMultiListener(i, a), i.delete() } function bn(e) { return void 0 === e && (e = 0), 1 === e ? "hand_landmark_full.tflite" : "hand_landmark_lite.tflite" } function vn(e) { var t = this; e = e || {}, this.h = new fn({ locateFile: e.locateFile, files: function (e) { return [{ url: "hands_solution_packed_assets_loader.js" }, { simd: !1, url: "hands_solution_wasm_bin.js" }, { simd: !0, url: "hands_solution_simd_wasm_bin.js" }, { data: !0, url: bn(e.modelComplexity) }] }, graph: { url: "hands.binarypb" }, inputs: { image: { type: "video", stream: "input_frames_gpu" } }, listeners: [{ wants: ["multi_hand_landmarks", "multi_hand_world_landmarks", "image_transformed", "multi_handedness"], outs: { image: "image_transformed", multiHandLandmarks: { type: "proto_list", stream: "multi_hand_landmarks", transform: on }, multiHandWorldLandmarks: { type: "proto_list", stream: "multi_hand_world_landmarks", transform: on }, multiHandedness: { type: "proto_list", stream: "multi_handedness", transform: function (e) { return e.map((function (e) { return rn(qt(e))[0] })) } } } }], options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, maxNumHands: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculator", fieldName: "int_value" } }, modelComplexity: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorModelComplexity", fieldName: "int_value" }, onChange: function (e) { var n, r, i; return _((function (a) { return 1 == a.h ? (n = bn(e), r = "third_party/mediapipe/modules/hand_landmark/" + n, v(a, mn(t.h, n), 2)) : (i = a.i, t.h.overrideFile(r, i), a.return(!0)) })) } }, minDetectionConfidence: { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "handlandmarktrackinggpu__palmdetectiongpu__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }, minTrackingConfidence: { type: 1, graphOptionXref: { calculatorType: "ThresholdingCalculator", calculatorName: "handlandmarktrackinggpu__handlandmarkgpu__ThresholdingCalculator", fieldName: "threshold" } } } }) } (e = fn.prototype).close = function () { return this.j && this.j.delete(), Promise.resolve() }, e.reset = function () { var e = this; return _((function (t) { e.j && (e.j.reset(), e.s = {}, e.v = {}), t.h = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.h.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { X: a.X, Y: a.Y }, u = o.next())if (!((u = u.value) in this.l) || this.l[u] !== e[u]) { this.l[u] = e[u]; var l = t[u]; void 0 !== l && (l.onChange && (a.X = l.onChange, a.Y = e[u], r.push(function (e) { return function () { return _((function (t) { if (1 == t.h) return v(t, e.X(e.Y), 2); !0 === t.i && (n.u = !0), t.h = 0 })) } }(a))), l.graphOptionXref && (u = Object.assign({}, { calculatorName: "", calculatorIndex: 0 }, l.graphOptionXref, { valueNumber: 1 === l.type ? e[u] : 0, valueBoolean: 0 === l.type && e[u], valueString: 2 === l.type ? e[u] : "" }), i.push(u))) } 0 === r.length && 0 === i.length || (this.u = !0, this.H = (void 0 === this.H ? [] : this.H).concat(i), this.F = (void 0 === this.F ? [] : this.F).concat(r)) } }, e.initialize = function () { var e = this; return _((function (t) { return 1 == t.h ? v(t, pn(e), 2) : 3 != t.h ? v(t, function (e) { var t, n, r, i, a, o, u, l; return _((function (c) { if (1 == c.h) return e.h.graph && e.h.graph.url && e.fa === e.h.graph.url ? c.return() : (e.u = !0, e.h.graph && e.h.graph.url ? (e.fa = e.h.graph.url, v(c, mn(e, e.h.graph.url), 3)) : void (c.h = 2)); for (2 != c.h && (t = c.i, e.j.loadGraph(t)), n = s(Object.keys(e.D)), r = n.next(); !r.done; r = n.next())i = r.value, e.j.overrideFile(i, e.D[i]); if (e.D = {}, e.h.listeners) for (a = s(e.h.listeners), o = a.next(); !o.done; o = a.next())u = o.value, yn(e, u); l = e.l, e.l = {}, e.setOptions(l), c.h = 0 })) }(e), 3) : v(t, function (e) { var t, n, r, i, a, o; return _((function (u) { switch (u.h) { case 1: if (!e.u) return u.return(); if (!e.F) { u.h = 2; break } t = s(e.F), n = t.next(); case 3: if (n.done) { u.h = 5; break } return v(u, (0, n.value)(), 4); case 4: n = t.next(), u.h = 3; break; case 5: e.F = void 0; case 2: if (e.H) { for (r = new e.i.GraphOptionChangeRequestList, i = s(e.H), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); e.j.changeOptions(r), r.delete(), e.H = void 0 } e.u = !1, u.h = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.j ? this.j.overrideFile(e, t) : this.D[e] = t }, e.clearOverriddenFiles = function () { this.D = {}, this.j && this.j.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, o, u, l, c, h, d = this; return _((function (f) { switch (f.h) { case 1: return d.h.inputs ? (n = 1e3 * (null == t ? performance.now() : t), v(f, d.I, 2)) : f.return(); case 2: return v(f, d.initialize(), 3); case 3: for (r = new d.i.PacketDataList, i = s(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (o = a.value, u = d.h.inputs[o]) { e: { var p = e[o]; switch (u.type) { case "video": var m = d.s[u.stream]; if (m || (m = new sn(d.i, d.K), d.s[u.stream] = m), 0 === m.m && (m.m = m.i.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, y = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, y = p.naturalHeight) : (g = p.width, y = p.height); y = { glName: m.m, width: g, height: y }, (g = m.h).canvas.width = y.width, g.canvas.height = y.height, g.activeTexture(g.TEXTURE0), m.i.bindTexture2d(m.m), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.i.bindTexture2d(0), m = y; break e; case "detections": for ((m = d.s[u.stream]) || (m = new ln(d.i), d.s[u.stream] = m), m.data || (m.data = new m.h.DetectionListData), m.data.reset(p.length), y = 0; y < p.length; ++y) { g = p[y]; var b = m.data, x = b.setBoundingBox, w = y, k = g.la, S = new Qt; if (Ze(S, 1, k.ra), Ze(S, 2, k.sa), Ze(S, 3, k.height), Ze(S, 4, k.width), Ze(S, 5, k.rotation), Ge(S, 6, k.pa), k = S.l(), x.call(b, w, k), g.ea) for (b = 0; b < g.ea.length; ++b) { S = g.ea[b], w = (x = m.data).addNormalizedLandmark, k = y, S = Object.assign({}, S, { visibility: S.visibility ? S.visibility : 0 }); var _ = new Yt; Ze(_, 1, S.x), Ze(_, 2, S.y), Ze(_, 3, S.z), S.visibility && Ze(_, 4, S.visibility), S = _.l(), w.call(x, k, S) } if (g.ba) for (b = 0; b < g.ba.length; ++b)w = (x = m.data).addClassification, k = y, S = g.ba[b], Ze(_ = new Wt, 2, S.score), S.index && Ge(_, 1, S.index), S.label && Ge(_, 3, S.label), S.displayName && Ge(_, 4, S.displayName), S = _.l(), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign({}, l, { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.j.send(r), v(f, d.I, 4); case 4: r.delete(), f.h = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, T("Solution", fn), T("OptionType", { BOOL: 0, NUMBER: 1, ta: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = vn.prototype).close = function () { return this.h.close(), Promise.resolve() }, e.onResults = function (e) { this.h.onResults(e) }, e.initialize = function () { var e = this; return _((function (t) { return v(t, e.h.initialize(), 0) })) }, e.reset = function () { this.h.reset() }, e.send = function (e) { var t = this; return _((function (n) { return v(n, t.h.send(e), 0) })) }, e.setOptions = function (e) { this.h.setOptions(e) }, T("Hands", vn), T("HAND_CONNECTIONS", [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [5, 9], [9, 10], [10, 11], [11, 12], [9, 13], [13, 14], [14, 15], [15, 16], [13, 17], [0, 17], [17, 18], [18, 19], [19, 20]]), T("VERSION", "0.4.1675469240") }).call(this) }, 3242: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.h = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.h }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || l })); var c, h = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) c = Object.setPrototypeOf; else { var d; e: { var f = {}; try { f.__proto__ = { a: !0 }, d = f.a; break e } catch (e) { } d = !1 } c = d ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var p = c; function m(e, t) { if (e.prototype = h(t.prototype), e.prototype.constructor = e, p) p(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.za = t.prototype } function g() { this.m = !1, this.j = null, this.i = void 0, this.h = 1, this.v = this.s = 0, this.l = null } function y(e) { if (e.m) throw new TypeError("Generator is already running"); e.m = !0 } function b(e, t) { e.l = { ma: t, na: !0 }, e.h = e.s || e.v } function v(e, t, n) { return e.h = n, { value: t } } function x(e) { this.h = new g, this.i = e } function w(e, t, n, r) { try { var i = t.call(e.h.j, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.h.m = !1, i; var a = i.value } catch (t) { return e.h.j = null, b(e.h, t), k(e) } return e.h.j = null, r.call(e.h, a), k(e) } function k(e) { for (; e.h.h;)try { var t = e.i(e.h); if (t) return e.h.m = !1, { value: t.value, done: !1 } } catch (t) { e.h.i = void 0, b(e.h, t) } if (e.h.m = !1, e.h.l) { if (t = e.h.l, e.h.l = null, t.na) throw t.ma; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function S(e) { this.next = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.next, t, e.h.u) : (e.h.u(t), t = k(e)), t }, this.throw = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.throw, t, e.h.u) : (b(e.h, t), t = k(e)), t }, this.return = function (t) { return function (e, t) { y(e.h); var n = e.h.j; return n ? w(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.h.return) : (e.h.return(t), k(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function _(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new S(new x(e))) } function C(e) { return e || Array.prototype.fill } g.prototype.u = function (e) { this.i = e }, g.prototype.return = function (e) { this.l = { return: e }, this.h = this.v }, a("Promise", (function (e) { function t(e) { this.i = 0, this.j = void 0, this.h = [], this.u = !1; var t = this.l(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.h = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.i = function (e) { if (null == this.h) { this.h = []; var t = this; this.j((function () { t.m() })) } this.h.push(e) }; var a = i.setTimeout; n.prototype.j = function (e) { a(e, 0) }, n.prototype.m = function () { for (; this.h && this.h.length;) { var e = this.h; this.h = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.l(e) } } } this.h = null }, n.prototype.l = function (e) { this.j((function () { throw e })) }, t.prototype.l = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.I), reject: e(this.m) } }, t.prototype.I = function (e) { if (e === this) this.m(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.L(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.F(e) : this.s(e) } }, t.prototype.F = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.m(e) } "function" == typeof t ? this.M(t, e) : this.s(e) }, t.prototype.m = function (e) { this.v(2, e) }, t.prototype.s = function (e) { this.v(1, e) }, t.prototype.v = function (e, t) { if (0 != this.i) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.i); this.i = e, this.j = t, 2 === this.i && this.K(), this.H() }, t.prototype.K = function () { var e = this; a((function () { if (e.D()) { var t = i.console; void 0 !== t && t.error(e.j) } }), 1) }, t.prototype.D = function () { if (this.u) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.j, n(e)) }, t.prototype.H = function () { if (null != this.h) { for (var e = 0; e < this.h.length; ++e)o.i(this.h[e]); this.h = null } }; var o = new n; return t.prototype.L = function (e) { var t = this.l(); e.T(t.resolve, t.reject) }, t.prototype.M = function (e, t) { var n = this.l(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.T(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.T = function (e, t) { function n() { switch (r.i) { case 1: e(r.j); break; case 2: t(r.j); break; default: throw Error("Unexpected state: " + r.i) } } var r = this; null == this.h ? o.i(n) : this.h.push(n), this.u = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).T(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).T(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })), a("Array.prototype.fill", (function (e) { return e || function (e, t, n) { var r = this.length || 0; for (0 > t && (t = Math.max(0, r + t)), (null == n || n > r) && (n = r), 0 > (n = Number(n)) && (n = Math.max(0, r + n)), t = Number(t || 0); t < n; t++)this[t] = e; return this } })), a("Int8Array.prototype.fill", C), a("Uint8Array.prototype.fill", C), a("Uint8ClampedArray.prototype.fill", C), a("Int16Array.prototype.fill", C), a("Uint16Array.prototype.fill", C), a("Int32Array.prototype.fill", C), a("Uint32Array.prototype.fill", C), a("Float32Array.prototype.fill", C), a("Float64Array.prototype.fill", C), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })); var A = this || self; function T(e, t) { e = e.split("."); var n, r = A; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function E(e) { var t; return (t = A.navigator) && (t = t.userAgent) || (t = ""), -1 != t.indexOf(e) } var N = Array.prototype.map ? function (e, t) { return Array.prototype.map.call(e, t, void 0) } : function (e, t) { for (var n = e.length, r = Array(n), i = "string" == typeof e ? e.split("") : e, a = 0; a < n; a++)a in i && (r[a] = t.call(void 0, i[a], a, e)); return r }, I = {}, M = null; function F(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = M[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } D(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function D() { if (!M) { M = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); I[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === M[a] && (M[a] = i) } } } } var $ = "undefined" != typeof Uint8Array, R = !(E("Trident") || E("MSIE")) && "function" == typeof A.btoa; function O(e) { if (!R) { var t; void 0 === t && (t = 0), D(), t = I[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } for (t = ""; 10240 < e.length;)t += String.fromCharCode.apply(null, e.subarray(0, 10240)), e = e.subarray(10240); return t += String.fromCharCode.apply(null, e), btoa(t) } var z, P = RegExp("[-_.]", "g"); function B(e) { switch (e) { case "-": return "+"; case "_": return "/"; case ".": return "="; default: return "" } } function L(e) { if (!R) return F(e); P.test(e) && (e = e.replace(P, B)), e = atob(e); for (var t = new Uint8Array(e.length), n = 0; n < e.length; n++)t[n] = e.charCodeAt(n); return t } function j() { return z || (z = new Uint8Array(0)) } var U = {}, W = "function" == typeof Uint8Array.prototype.slice, V = 0, G = 0; function H(e) { var t = 0 > e, n = (e = Math.abs(e)) >>> 0; e = Math.floor((e - n) / 4294967296), t && (t = (n = s(X(n, e))).next().value, e = n.next().value, n = t), V = n >>> 0, G = e >>> 0 } var q, Y = "function" == typeof BigInt; function X(e, t) { return t = ~t, e ? e = 1 + ~e : t += 1, [e, t] } function K(e, t) { this.i = e >>> 0, this.h = t >>> 0 } function Z(e) { if (!e) return q || (q = new K(0, 0)); if (!/^-?\d+$/.test(e)) return null; if (16 > e.length) H(Number(e)); else if (Y) e = BigInt(e), V = Number(e & BigInt(4294967295)) >>> 0, G = Number(e >> BigInt(32) & BigInt(4294967295)); else { var t = +("-" === e[0]); G = V = 0; for (var n = e.length, r = t, i = (n - t) % 6 + t; i <= n; r = i, i += 6)r = Number(e.slice(r, i)), G *= 1e6, 4294967296 <= (V = 1e6 * V + r) && (G += V / 4294967296 | 0, V %= 4294967296); t && (e = (t = s(X(V, G))).next().value, t = t.next().value, V = e, G = t) } return new K(V, G) } function J(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function Q() { return Error("Failed to read varint, encoding is invalid.") } function ee(e, t) { return Error("Tried to read past the end of the data " + t + " > " + e) } function te() { throw Error("Invalid UTF8") } function ne(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var re, ie, ae, oe = void 0, se = "undefined" != typeof TextDecoder, ue = "undefined" != typeof TextEncoder; function le(e) { if (e !== U) throw Error("illegal external caller") } function ce(e, t) { if (le(t), this.V = e, null != e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } function he() { return ae || (ae = new ce(null, U)) } function de(e) { le(U); var t = e.V; return null == (t = null == t || $ && null != t && t instanceof Uint8Array ? t : "string" == typeof t ? L(t) : null) ? t : e.V = t } function fe(e, t) { this.i = null, this.m = !1, this.h = this.j = this.l = 0, pe(this, e, t) } function pe(e, t, n) { n = void 0 === n ? {} : n, e.S = void 0 !== n.S && n.S, t && (t = function (e) { if ("string" == typeof e) return { buffer: L(e), C: !1 }; if (Array.isArray(e)) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === Uint8Array) return { buffer: e, C: !1 }; if (e.constructor === ArrayBuffer) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === ce) return { buffer: de(e) || j(), C: !0 }; if (e instanceof Uint8Array) return { buffer: new Uint8Array(e.buffer, e.byteOffset, e.byteLength), C: !1 }; throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers") }(t), e.i = t.buffer, e.m = t.C, e.l = 0, e.j = e.i.length, e.h = e.l) } function me(e, t) { if (e.h = t, t > e.j) throw ee(e.j, t) } function ge(e) { var t = e.i, n = e.h, r = t[n++], i = 127 & r; if (128 & r && (i |= (127 & (r = t[n++])) << 7, 128 & r && (i |= (127 & (r = t[n++])) << 14, 128 & r && (i |= (127 & (r = t[n++])) << 21, 128 & r && (i |= (r = t[n++]) << 28, 128 & r && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++]))))) throw Q(); return me(e, n), i } function ye(e, t) { if (0 > t) throw Error("Tried to read a negative byte length: " + t); var n = e.h, r = n + t; if (r > e.j) throw ee(t, e.j - n); return e.h = r, n } fe.prototype.reset = function () { this.h = this.l }; var be = []; function ve() { this.h = [] } function xe(e, t, n) { for (; 0 < n || 127 < t;)e.h.push(127 & t | 128), t = (t >>> 7 | n << 25) >>> 0, n >>>= 7; e.h.push(t) } function we(e, t) { for (; 127 < t;)e.h.push(127 & t | 128), t >>>= 7; e.h.push(t) } function ke(e, t) { if (be.length) { var n = be.pop(); pe(n, e, t), e = n } else e = new fe(e, t); this.h = e, this.j = this.h.h, this.i = this.l = -1, this.setOptions(t) } function Se(e) { var t = e.h; if (t.h == t.j) return !1; e.j = e.h.h; var n = ge(e.h) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw J(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.l = t, e.i = n, !0 } function _e(e) { switch (e.i) { case 0: if (0 != e.i) _e(e); else e: { for (var t = (e = e.h).h, n = t + 10, r = e.i; t < n;)if (!(128 & r[t++])) { me(e, t); break e } throw Q() } break; case 1: me(e = e.h, e.h + 8); break; case 2: 2 != e.i ? _e(e) : (t = ge(e.h) >>> 0, me(e = e.h, e.h + t)); break; case 5: me(e = e.h, e.h + 4); break; case 3: for (t = e.l; ;) { if (!Se(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.i) { if (e.l != t) throw Error("Unmatched end-group tag"); break } _e(e) } break; default: throw J(e.i, e.j) } } ve.prototype.length = function () { return this.h.length }, ve.prototype.end = function () { var e = this.h; return this.h = [], e }, ke.prototype.setOptions = function (e) { e = void 0 === e ? {} : e, this.ca = void 0 !== e.ca && e.ca }, ke.prototype.reset = function () { this.h.reset(), this.j = this.h.h, this.i = this.l = -1 }; var Ce = []; function Ae() { this.j = [], this.i = 0, this.h = new ve } function Te(e, t) { 0 !== t.length && (e.j.push(t), e.i += t.length) } var Ee = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol() : void 0; function Ne(e, t) { return Ee ? e[Ee] |= t : void 0 !== e.A ? e.A |= t : (Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }), t) } function Ie(e, t) { Ee ? e[Ee] && (e[Ee] &= ~t) : void 0 !== e.A && (e.A &= ~t) } function Me(e) { var t; return null == (t = Ee ? e[Ee] : e.A) ? 0 : t } function Fe(e, t) { Ee ? e[Ee] = t : void 0 !== e.A ? e.A = t : Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }) } function De(e) { return Ne(e, 1), e } function $e(e, t) { Fe(t, -51 & e) } function Re(e, t) { Fe(t, -41 & e | 18) } var Oe = {}; function ze(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var Pe, Be, Le = []; function je(e) { if (2 & Me(e.o)) throw Error("Cannot mutate an immutable Message") } function Ue(e) { var t = e.length; (t = t ? e[t - 1] : void 0) && ze(t) ? t.g = 1 : (t = {}, e.push((t.g = 1, t))) } function We(e) { var t = e.i + e.G; return e.B || (e.B = e.o[t] = {}) } function Ve(e, t) { return -1 === t ? null : t >= e.i ? e.B ? e.B[t] : void 0 : e.o[t + e.G] } function Ge(e, t, n, r) { je(e), He(e, t, n, r) } function He(e, t, n, r) { e.j && (e.j = void 0), t >= e.i || r ? We(e)[t] = n : (e.o[t + e.G] = n, (e = e.B) && t in e && delete e[t]) } function qe(e, t, n, r) { var i = Ve(e, t); Array.isArray(i) || (i = Pe); var a = Me(i); if (1 & a || De(i), r) 2 & a || Ne(i, 2), 1 & n || Object.freeze(i); else { r = !(2 & n); var o = 2 & a; 1 & n || !o ? r && 16 & a && !o && Ie(i, 16) : He(e, t, i = De(Array.prototype.slice.call(i))) } return i } function Ye(e, t) { var n = Ve(e, t), r = null == n ? n : "number" == typeof n || "NaN" === n || "Infinity" === n || "-Infinity" === n ? Number(n) : void 0; return null != r && r !== n && He(e, t, r), r } function Xe(e, t, n, r, i) { e.h || (e.h = {}); var a = e.h[n], o = qe(e, n, 3, i); if (!a) { var s = o; a = []; var u = !!(16 & Me(e.o)); o = !!(2 & Me(s)); var l = s; !i && o && (s = Array.prototype.slice.call(s)); for (var c = o, h = 0; h < s.length; h++) { var d = s[h], f = t, p = !1; if (p = void 0 !== p && p, void 0 !== (d = Array.isArray(d) ? new f(d) : p ? new f : void 0)) { var m = p = Me(f = d.o); o && (m |= 2), u && (m |= 16), m != p && Fe(f, m), f = m, c = c || !!(2 & f), a.push(d) } } return e.h[n] = a, t = 33 | (u = Me(s)), u != (t = c ? -9 & t : 8 | t) && (c = s, Object.isFrozen(c) && (c = Array.prototype.slice.call(c)), Fe(c, t), s = c), l !== s && He(e, n, s), (i || r && o) && Ne(a, 2), r && Object.freeze(a), a } return i || (i = Object.isFrozen(a), r && !i ? Object.freeze(a) : !r && i && (a = Array.prototype.slice.call(a), e.h[n] = a)), a } function Ke(e, t, n) { var r = !!(2 & Me(e.o)); if (t = Xe(e, t, n, r, r), e = qe(e, n, 3, r), !(r || 8 & Me(e))) { for (r = 0; r < t.length; r++) { if (2 & Me((n = t[r]).o)) { var i = ut(n, !1); i.j = n } else i = n; n !== i && (t[r] = i, e[r] = i.o) } Ne(e, 8) } return t } function Ze(e, t, n) { if (null != n && "number" != typeof n) throw Error("Value of float/double field must be a number|null|undefined, found " + typeof n + ": " + n); Ge(e, t, n) } function Je(e, t, n, r, i) { je(e); var a = Xe(e, n, t, !1, !1); return n = null != r ? r : new n, e = qe(e, t, 2, !1), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.o)) : (a.push(n), e.push(n.o)), n.C() && Ie(e, 8), n } function Qe(e, t) { return null == e ? t : e } function et(e, t, n) { return n = void 0 === n ? 0 : n, Qe(Ye(e, t), n) } function tt(e, t, n, r) { if (null != e) { if (Array.isArray(e)) e = nt(e, t, n, void 0 !== r); else if (ze(e)) { var i, a = {}; for (i in e) a[i] = tt(e[i], t, n, r); e = a } else e = t(e, r); return e } } function nt(e, t, n, r) { var i = Me(e); r = r ? !!(16 & i) : void 0, e = Array.prototype.slice.call(e); for (var a = 0; a < e.length; a++)e[a] = tt(e[a], t, n, r); return n(i, e), e } function rt(e) { return e.ja === Oe ? e.toJSON() : function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e) if (Array.isArray(e)) { if (128 & Me(e)) return Ue(e = Array.prototype.slice.call(e)), e } else { if ($ && null != e && e instanceof Uint8Array) return O(e); if (e instanceof ce) { var t = e.V; return null == t ? "" : "string" == typeof t ? t : e.V = O(t) } } }return e }(e) } function it(e, t) { 128 & e && Ue(t) } function at(e, t, n) { if (n = void 0 === n ? Re : n, null != e) { if ($ && e instanceof Uint8Array) return e.length ? new ce(new Uint8Array(e), U) : he(); if (Array.isArray(e)) { var r = Me(e); return 2 & r ? e : !t || 32 & r || !(16 & r || 0 === r) ? (4 & (t = Me(e = nt(e, at, 4 & r ? Re : n, !0))) && 2 & t && Object.freeze(e), e) : (Fe(e, 2 | r), e) } return e.ja === Oe ? st(e) : e } } function ot(e, t, n, r, i, a, o) { if (e = e.h && e.h[n]) { if (2 & (r = Me(e)) ? r = e : (Re(r, a = N(e, st)), Object.freeze(a), r = a), je(t), o = null == r ? Pe : De([]), null != r) { for (a = !!r.length, e = 0; e < r.length; e++) { var s = r[e]; a = a && !(2 & Me(s.o)), o[e] = s.o } a = 1 | (a ? 8 : 0), ((e = Me(o)) & a) !== a && (Object.isFrozen(o) && (o = Array.prototype.slice.call(o)), Fe(o, e | a)), t.h || (t.h = {}), t.h[n] = r } else t.h && (t.h[n] = void 0); He(t, n, o, i) } else Ge(t, n, at(r, a, o), i) } function st(e) { return 2 & Me(e.o) || Ne((e = ut(e, !0)).o, 2), e } function ut(e, t) { var n = e.o, r = []; Ne(r, 16); var i = e.constructor.h; if (i && r.push(i), i = e.B) { r.length = n.length, r.fill(void 0, r.length, n.length); var a = {}; r[r.length - 1] = a } 128 & Me(n) && Ue(r), t = t || e.C() ? Re : $e, a = e.constructor, Be = r, r = new a(r), Be = void 0, e.R && (r.R = e.R.slice()), a = !!(16 & Me(n)); for (var o = i ? n.length - 1 : n.length, s = 0; s < o; s++)ot(e, r, s - e.G, n[s], !1, a, t); if (i) for (var u in i) ot(e, r, +u, i[u], !0, a, t); return r } function lt(e, t, n) { null == e && (e = Be), Be = void 0; var r, i = this.constructor.i || 0, a = 0 < i, o = this.constructor.h, s = !1; if (null == e) { var u = 48, l = !0; a && (i = 0, u |= 128), Fe(e = o ? [o] : [], u) } else { if (!Array.isArray(e)) throw Error(); if (o && o !== e[0]) throw Error(); var c = u = Ne(e, 0); if ((l = !!(16 & c)) && ((s = !!(32 & c)) || (c |= 32)), a) { if (128 & c) i = 0; else if (0 < e.length) { var h = e[e.length - 1]; if (ze(h) && "g" in h) { i = 0, c |= 128, delete h.g; var d, f = !0; for (d in h) { f = !1; break } f && e.pop() } } } else if (128 & c) throw Error(); u !== c && Fe(e, c) } if (this.G = (o ? 0 : -1) - i, this.h = void 0, this.o = e, i = (o = this.o.length) - 1, o && ze(o = this.o[i]) ? (this.B = o, this.i = i - this.G) : void 0 !== t && -1 < t ? (this.i = Math.max(t, i + 1 - this.G), this.B = void 0) : this.i = Number.MAX_VALUE, !a && this.B && "g" in this.B) throw Error('Unexpected "g" flag in sparse object of message that is not a group type.'); if (n) for (t = l && !s && !0, a = this.i, l = 0; l < n.length; l++)(s = n[l]) < a ? (i = e[s += this.G]) ? ct(i, t) : e[s] = Pe : (r || (r = We(this)), (i = r[s]) ? ct(i, t) : r[s] = Pe) } function ct(e, t) { if (Array.isArray(e)) { var n = Me(e), r = 1; !t || 2 & n || (r |= 16), (n & r) !== r && Fe(e, n | r) } } function ht(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.ra; o || (i.J = a.xa || a.oa.W, a.ia ? (i.aa = vt(a.ia), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.aa) } }(i)) : a.ka ? (i.Z = xt(a.da.P, a.ka), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.Z) } }(i)) : o = i.J, a.ra = o), o(t, e, a.da), i = { J: i.J, aa: i.aa, Z: i.Z } } } !function (e, t) { if (t = t.R) { Te(e, e.h.end()); for (var n = 0; n < t.length; n++)Te(e, de(t[n]) || j()) } }(t, e) } Fe(Le, 23), Pe = Object.freeze(Le), lt.prototype.toJSON = function () { return nt(this.o, rt, it) }, lt.prototype.C = function () { return !!(2 & Me(this.o)) }, lt.prototype.ja = Oe, lt.prototype.toString = function () { return this.o.toString() }; var dt = Symbol(); function ft(e, t, n) { return e[dt] || (e[dt] = function (e, r) { return t(e, r, n) }) } function pt(e) { var t = e[dt]; if (!t) { var n = Ft(e); t = function (e, t) { return Dt(e, t, n) }, e[dt] = t } return t } function mt(e) { var t = function (e) { var t = e.ia; return t ? pt(t) : (t = e.wa) ? ft(e.da.P, t, e.ka) : void 0 }(e), n = e.da, r = e.oa.U; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function gt(e, t) { var n = e[t]; return "function" == typeof n && 0 === n.length && (n = n(), e[t] = n), Array.isArray(n) && (Tt in n || wt in n || 0 < n.length && "function" == typeof n[0]) ? n : void 0 } function yt(e, t, n, r, i, a) { t.P = e[0]; var o = 1; if (e.length > o && "number" != typeof e[o]) { var s = e[o++]; n(t, s) } for (; o < e.length;) { n = e[o++]; for (var u = o + 1; u < e.length && "number" != typeof e[u];)u++; switch (s = e[o++], u -= o) { case 0: r(t, n, s); break; case 1: (u = gt(e, o)) ? (o++, i(t, n, s, u)) : r(t, n, s, e[o++]); break; case 2: i(t, n, s, u = gt(e, u = o++), e[o++]); break; case 3: a(t, n, s, e[o++], e[o++], e[o++]); break; case 4: a(t, n, s, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + u) } } return t } var bt = Symbol(); function vt(e) { var t = e[bt]; if (!t) { var n = At(e); t = function (e, t) { return $t(e, t, n) }, e[bt] = t } return t } function xt(e, t) { var n = e[bt]; return n || (n = function (e, n) { return ht(e, n, t) }, e[bt] = n), n } var wt = Symbol(); function kt(e, t) { e.push(t) } function St(e, t, n) { e.push(t, n.W) } function _t(e, t, n, r) { var i = vt(r), a = At(r).P, o = n.W; e.push(t, (function (e, t, n) { return o(e, t, n, a, i) })) } function Ct(e, t, n, r, i, a) { var o = xt(r, a), s = n.W; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function At(e) { var t = e[wt]; return t || (t = yt(e, e[wt] = [], kt, St, _t, Ct), Tt in e && wt in e && (e.length = 0), t) } var Tt = Symbol(); function Et(e, t) { e[0] = t } function Nt(e, t, n, r) { var i = n.U; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function It(e, t, n, r, i) { var a = n.U, o = pt(r), s = Ft(r).P; e[t] = function (e, t, n) { return a(e, t, n, s, o, i) } } function Mt(e, t, n, r, i, a, o) { var s = n.U, u = ft(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Ft(e) { var t = e[Tt]; return t || (t = yt(e, e[Tt] = {}, Et, Nt, It, Mt), Tt in e && wt in e && (e.length = 0), t) } function Dt(e, t, n) { for (; Se(t) && 4 != t.i;) { var r = t.l, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = mt(a)) } if (!i || !i(t, e, r)) { r = e, a = (i = t).j, _e(i); var o = i; if (!o.ca) { if (i = o.h.h - a, o.h.h = a, o = o.h, 0 == i) i = he(); else { if (a = ye(o, i), o.S && o.m) i = o.i.subarray(a, a + i); else { o = o.i; var s = a; i = s === (i = a + i) ? j() : W ? o.slice(s, i) : new Uint8Array(o.subarray(s, i)) } i = 0 == i.length ? he() : new ce(i, U) } (a = r.R) ? a.push(i) : r.R = [i] } } } return e } function $t(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); ht(e, t, i ? n[0] : void 0) } function Rt(e, t) { return { U: e, W: t } } var Ot = Rt((function (e, t, n) { if (5 !== e.i) return !1; var r = (e = e.h).i, i = e.h, a = r[i], o = r[i + 1], s = r[i + 2]; return r = r[i + 3], me(e, e.h + 4), e = 2 * ((o = (a | o << 8 | s << 16 | r << 24) >>> 0) >> 31) + 1, a = o >>> 23 & 255, o &= 8388607, Ge(t, n, 255 == a ? o ? NaN : 1 / 0 * e : 0 == a ? e * Math.pow(2, -149) * o : e * Math.pow(2, a - 150) * (o + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = Ye(t, n))) { we(e.h, 8 * n + 5), e = e.h; var r = +t; 0 === r ? 0 < 1 / r ? V = G = 0 : (G = 0, V = 2147483648) : isNaN(r) ? (G = 0, V = 2147483647) : 34028234663852886e22 < (r = (n = 0 > r ? -2147483648 : 0) ? -r : r) ? (G = 0, V = (2139095040 | n) >>> 0) : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), G = 0, V = (n | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, G = 0, V = (n | t + 127 << 23 | 8388607 & r) >>> 0), n = V, e.h.push(n >>> 0 & 255), e.h.push(n >>> 8 & 255), e.h.push(n >>> 16 & 255), e.h.push(n >>> 24 & 255) } })), zt = Rt((function (e, t, n) { if (0 !== e.i) return !1; var r = e.h, i = 0, a = e = 0, o = r.i, s = r.h; do { var u = o[s++]; i |= (127 & u) << a, a += 7 } while (32 > a && 128 & u); for (32 < a && (e |= (127 & u) >> 4), a = 3; 32 > a && 128 & u; a += 7)e |= (127 & (u = o[s++])) << a; if (me(r, s), !(128 > u)) throw Q(); return r = i >>> 0, (e = 2147483648 & (u = e >>> 0)) && (u = ~u >>> 0, 0 == (r = 1 + ~r >>> 0) && (u = u + 1 >>> 0)), r = 4294967296 * u + (r >>> 0), Ge(t, n, e ? -r : r), !0 }), (function (e, t, n) { null != (t = Ve(t, n)) && ("string" == typeof t && Z(t), null != t && (we(e.h, 8 * n), "number" == typeof t ? (e = e.h, H(t), xe(e, V, G)) : (n = Z(t), xe(e.h, n.i, n.h)))) })), Pt = Rt((function (e, t, n) { return 0 === e.i && (Ge(t, n, ge(e.h)), !0) }), (function (e, t, n) { if (null != (t = Ve(t, n)) && null != t) if (we(e.h, 8 * n), e = e.h, 0 <= (n = t)) we(e, n); else { for (t = 0; 9 > t; t++)e.h.push(127 & n | 128), n >>= 7; e.h.push(1) } })), Bt = Rt((function (e, t, n) { if (2 !== e.i) return !1; var r = ge(e.h) >>> 0, i = ye(e = e.h, r); if (e = e.i, se) { var a, o = e; (a = re) || (a = re = new TextDecoder("utf-8", { fatal: !0 })), e = i + r, o = 0 === i && e === o.length ? o : o.subarray(i, e); try { var s = a.decode(o) } catch (e) { if (void 0 === oe) { try { a.decode(new Uint8Array([128])) } catch (e) { } try { a.decode(new Uint8Array([97])), oe = !0 } catch (e) { oe = !1 } } throw !oe && (re = void 0), e } } else { r = (s = i) + r, i = []; for (var u, l, c = null; s < r;)128 > (u = e[s++]) ? i.push(u) : 224 > u ? s >= r ? te() : (l = e[s++], 194 > u || 128 != (192 & l) ? (s--, te()) : i.push((31 & u) << 6 | 63 & l)) : 240 > u ? s >= r - 1 ? te() : 128 != (192 & (l = e[s++])) || 224 === u && 160 > l || 237 === u && 160 <= l || 128 != (192 & (o = e[s++])) ? (s--, te()) : i.push((15 & u) << 12 | (63 & l) << 6 | 63 & o) : 244 >= u ? s >= r - 2 ? te() : 128 != (192 & (l = e[s++])) || l - 144 + (u << 28) >> 30 || 128 != (192 & (o = e[s++])) || 128 != (192 & (a = e[s++])) ? (s--, te()) : (u = (7 & u) << 18 | (63 & l) << 12 | (63 & o) << 6 | 63 & a, u -= 65536, i.push(55296 + (u >> 10 & 1023), 56320 + (1023 & u))) : te(), 8192 <= i.length && (c = ne(c, i), i.length = 0); s = ne(c, i) } return Ge(t, n, s), !0 }), (function (e, t, n) { if (null != (t = Ve(t, n))) { var r = !1; if (r = void 0 !== r && r, ue) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (ie || (ie = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = i === a.length ? a : a.subarray(0, i) } we(e.h, 8 * n + 2), we(e.h, t.length), Te(e, e.h.end()), Te(e, t) } })), Lt = Rt((function (e, t, n, r, i) { if (2 !== e.i) return !1; t = Je(t, n, r), n = e.h.j, r = ge(e.h) >>> 0; var a = e.h.h + r, o = a - n; if (0 >= o && (e.h.j = a, i(t, e, void 0, void 0, void 0), o = a - e.h.h), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.h.h = a, e.h.j = n, !0 }), (function (e, t, n, r, i) { if (null != (t = Ke(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; we(a.h, 8 * n + 2); var o = a.h.end(); Te(a, o), o.push(a.i), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.i + o.h.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.i++; a.push(s), o.i++ } })); function jt(e) { return function (t, n) { e: { if (Ce.length) { var r = Ce.pop(); r.setOptions(n), pe(r.h, t, n), t = r } else t = new ke(t, n); try { var i = Ft(e), a = Dt(new i.P, t, i); break e } finally { (i = t.h).i = null, i.m = !1, i.l = 0, i.j = 0, i.h = 0, i.S = !1, t.l = -1, t.i = -1, 100 > Ce.length && Ce.push(t) } a = void 0 } return a } } function Ut(e) { return function () { var t = new Ae; $t(this, t, At(e)), Te(t, t.h.end()); for (var n = new Uint8Array(t.i), r = t.j, i = r.length, a = 0, o = 0; o < i; o++) { var s = r[o]; n.set(s, a), a += s.length } return t.j = [n], n } } function Wt(e) { lt.call(this, e) } m(Wt, lt); var Vt = [Wt, 1, Pt, 2, Ot, 3, Bt, 4, Bt]; function Gt(e) { lt.call(this, e, -1, Ht) } Wt.prototype.l = Ut(Vt), m(Gt, lt), Gt.prototype.addClassification = function (e, t) { return Je(this, 1, Wt, e, t), this }; var Ht = [1], qt = jt([Gt, 1, Lt, Vt]); function Yt(e) { lt.call(this, e) } m(Yt, lt); var Xt = [Yt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot]; function Kt(e) { lt.call(this, e, -1, Zt) } Yt.prototype.l = Ut(Xt), m(Kt, lt); var Zt = [1], Jt = jt([Kt, 1, Lt, Xt]); function Qt(e) { lt.call(this, e) } m(Qt, lt); var en = [Qt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot, 6, zt], tn = jt(en); function nn(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function rn(e) { return Ke(e, Wt, 1).map((function (e) { var t = Ve(e, 1); return { index: null == t ? 0 : t, qa: et(e, 2), label: null != Ve(e, 3) ? Qe(Ve(e, 3), "") : void 0, displayName: null != Ve(e, 4) ? Qe(Ve(e, 4), "") : void 0 } })) } function an(e) { return { x: et(e, 1), y: et(e, 2), z: et(e, 3), visibility: null != Ye(e, 4) ? et(e, 4) : void 0 } } function on(e) { return Ke(Jt(e), Yt, 1).map(an) } function sn(e, t) { this.i = e, this.h = t, this.m = 0 } function un(e, t, n) { return function (e, t) { var n = e.h; if (void 0 === e.s) { var r = nn(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = nn(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.s = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.l = { O: n.getAttribLocation(r, "aVertex"), N: n.getAttribLocation(r, "aTex"), ya: i }, e.v = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.enableVertexAttribArray(e.l.O), n.vertexAttribPointer(e.l.O, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.l.N), n.vertexAttribPointer(e.l.N, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.l, n.useProgram(e.s), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.i.bindTexture2d(t.glName), n.enableVertexAttribArray(r.O), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.vertexAttribPointer(r.O, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.N, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.O), n.disableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, null), e.i.bindTexture2d(0) }(e, t), "function" == typeof e.h.canvas.transferToImageBitmap ? Promise.resolve(e.h.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.h.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.h.canvas) : (void 0 === e.j && (e.j = document.createElement("canvas")), new Promise((function (t) { e.j.height = e.h.canvas.height, e.j.width = e.h.canvas.width, e.j.getContext("2d", {}).drawImage(e.h.canvas, 0, 0, e.h.canvas.width, e.h.canvas.height), t(e.j) }))) } function ln(e) { this.h = e } Qt.prototype.l = Ut(en); var cn = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function hn(e, t) { return t + e } function dn(e, t) { window[e] = t } function fn(e) { if (this.h = e, this.listeners = {}, this.l = {}, this.L = {}, this.s = {}, this.v = {}, this.M = this.u = this.ga = !0, this.I = Promise.resolve(), this.fa = "", this.D = {}, this.locateFile = e && e.locateFile || hn, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.ha = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.l[n] = "function" == typeof r ? r() : r) } } function pn(e) { var t, n, r, i, a, o, s, l, c, h, d; return _((function (f) { switch (f.h) { case 1: return e.ga ? (t = void 0 === e.h.files ? [] : "function" == typeof e.h.files ? e.h.files(e.l) : e.h.files, v(f, _((function (e) { switch (e.h) { case 1: return e.s = 2, v(e, WebAssembly.instantiate(cn), 4); case 4: e.h = 3, e.s = 0; break; case 2: return e.s = 0, e.l = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.i, "object" == typeof window) return dn("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), dn("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), s = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = mn(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(s.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.ha)) : Promise.resolve() }))).then((function () { var t, n, r; return _((function (i) { if (1 == i.h) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, v(i, t(n), 2); r.i = i.i, i.h = 0 })) })), h = _((function (t) { return e.h.graph && e.h.graph.url ? t = v(t, mn(e, e.h.graph.url), 0) : (t.h = 0, t = void 0), t })), v(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.ha) })), importScripts.apply(null, u(r)), i = e, v(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.i = f.i, e.m = new OffscreenCanvas(1, 1), e.i.canvas = e.m, a = e.i.GL.createContext(e.m, { antialias: !1, alpha: !1, va: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.i.GL.makeContextCurrent(a), f.h = 4; break; case 7: if (e.m = document.createElement("canvas"), !(d = e.m.getContext("webgl2", {})) && !(d = e.m.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.K = d, e.i.canvas = e.m, e.i.createContext(e.m, !0, !0, {}); case 4: e.j = new e.i.SolutionWasm, e.ga = !1, f.h = 0 } })) } function mn(e, t) { var n, r; return _((function (i) { return t in e.L ? i.return(e.L[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.L[t] = r, i.return(r)) })) } function gn(e, t, n) { var r, i, a, o, u, l, c, h, d, f, p, m, g, y; return _((function (b) { switch (b.h) { case 1: if (!n) return b.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.M = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { b.h = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, v(b, function (e, t, n) { var r; return _((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.i.Uint8BlobList ? i.return(n) : n instanceof e.i.Texture2dDataOut ? ((r = e.v[t]) || (r = new sn(e.i, e.K), e.v[t] = r), i.return(un(r, n, e.M))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), S = [], C = 0; C < x.size(); ++C) { var A = tn(x.get(C)), T = void 0; T = void 0 === T ? 0 : T, A = { la: { sa: et(A, 1), ta: et(A, 2), height: et(A, 3), width: et(A, 4), rotation: et(A, 5, 0), pa: Qe(Ve(A, 6), T) }, ea: on(w.get(C)), ba: rn(qt(k.get(C))) }, S.push(A) } x = S } else x = []; r[h] = x, b.h = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, b.h = 7; break } if (void 0 === f) { b.h = 3; break } if ("float_list" === d.type) { r[h] = f, b.h = 7; break } if ("proto" === d.type) { r[h] = f, b.h = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.v[h]) || (p = new sn(e.i, e.K), e.v[h] = p), v(b, un(p, f, e.M), 13); case 13: m = b.i, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), b.h = 3; break; case 14: g[y] = b.i; case 3: o = c.next(), b.h = 2; break; case 4: return b.return(r) } })) } function yn(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.i.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.i.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.I = gn(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.I = n) }))) } }), e.j.attachMultiListener(i, a), i.delete() } function bn(e) { switch (void 0 === e && (e = 0), e) { case 1: return "pose_landmark_full.tflite"; case 2: return "pose_landmark_heavy.tflite"; default: return "pose_landmark_lite.tflite" } } function vn(e) { var t = this; e = e || {}, this.h = new fn({ locateFile: e.locateFile, files: function (e) { return [{ url: "pose_solution_packed_assets_loader.js" }, { simd: !1, url: "pose_solution_wasm_bin.js" }, { simd: !0, url: "pose_solution_simd_wasm_bin.js" }, { data: !0, url: bn(e.modelComplexity) }] }, graph: { url: "pose_web.binarypb" }, listeners: [{ wants: ["pose_landmarks", "world_landmarks", "segmentation_mask", "image_transformed"], outs: { image: { type: "texture", stream: "image_transformed" }, poseLandmarks: { type: "proto", stream: "pose_landmarks", transform: on }, poseWorldLandmarks: { type: "proto", stream: "world_landmarks", transform: on }, segmentationMask: { type: "texture", stream: "segmentation_mask" } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, modelComplexity: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorModelComplexity", fieldName: "int_value" }, onChange: function (e) { var n, r, i; return _((function (a) { return 1 == a.h ? (n = bn(e), r = "third_party/mediapipe/modules/pose_landmark/" + n, v(a, mn(t.h, n), 2)) : (i = a.i, t.h.overrideFile(r, i), a.return(!0)) })) } }, smoothLandmarks: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorSmoothLandmarks", fieldName: "bool_value" } }, enableSegmentation: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorEnableSegmentation", fieldName: "bool_value" } }, smoothSegmentation: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorSmoothSegmentation", fieldName: "bool_value" } }, minDetectionConfidence: { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "poselandmarkgpu__posedetectiongpu__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }, minTrackingConfidence: { type: 1, graphOptionXref: { calculatorType: "ThresholdingCalculator", calculatorName: "poselandmarkgpu__poselandmarkbyroigpu__tensorstoposelandmarksandsegmentation__ThresholdingCalculator", fieldName: "threshold" } } } }) } (e = fn.prototype).close = function () { return this.j && this.j.delete(), Promise.resolve() }, e.reset = function () { var e = this; return _((function (t) { e.j && (e.j.reset(), e.s = {}, e.v = {}), t.h = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.h.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { X: a.X, Y: a.Y }, u = o.next())if (!((u = u.value) in this.l) || this.l[u] !== e[u]) { this.l[u] = e[u]; var l = t[u]; void 0 !== l && (l.onChange && (a.X = l.onChange, a.Y = e[u], r.push(function (e) { return function () { return _((function (t) { if (1 == t.h) return v(t, e.X(e.Y), 2); !0 === t.i && (n.u = !0), t.h = 0 })) } }(a))), l.graphOptionXref && (u = Object.assign({}, { calculatorName: "", calculatorIndex: 0 }, l.graphOptionXref, { valueNumber: 1 === l.type ? e[u] : 0, valueBoolean: 0 === l.type && e[u], valueString: 2 === l.type ? e[u] : "" }), i.push(u))) } 0 === r.length && 0 === i.length || (this.u = !0, this.H = (void 0 === this.H ? [] : this.H).concat(i), this.F = (void 0 === this.F ? [] : this.F).concat(r)) } }, e.initialize = function () { var e = this; return _((function (t) { return 1 == t.h ? v(t, pn(e), 2) : 3 != t.h ? v(t, function (e) { var t, n, r, i, a, o, u, l; return _((function (c) { if (1 == c.h) return e.h.graph && e.h.graph.url && e.fa === e.h.graph.url ? c.return() : (e.u = !0, e.h.graph && e.h.graph.url ? (e.fa = e.h.graph.url, v(c, mn(e, e.h.graph.url), 3)) : void (c.h = 2)); for (2 != c.h && (t = c.i, e.j.loadGraph(t)), n = s(Object.keys(e.D)), r = n.next(); !r.done; r = n.next())i = r.value, e.j.overrideFile(i, e.D[i]); if (e.D = {}, e.h.listeners) for (a = s(e.h.listeners), o = a.next(); !o.done; o = a.next())u = o.value, yn(e, u); l = e.l, e.l = {}, e.setOptions(l), c.h = 0 })) }(e), 3) : v(t, function (e) { var t, n, r, i, a, o; return _((function (u) { switch (u.h) { case 1: if (!e.u) return u.return(); if (!e.F) { u.h = 2; break } t = s(e.F), n = t.next(); case 3: if (n.done) { u.h = 5; break } return v(u, (0, n.value)(), 4); case 4: n = t.next(), u.h = 3; break; case 5: e.F = void 0; case 2: if (e.H) { for (r = new e.i.GraphOptionChangeRequestList, i = s(e.H), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); e.j.changeOptions(r), r.delete(), e.H = void 0 } e.u = !1, u.h = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.j ? this.j.overrideFile(e, t) : this.D[e] = t }, e.clearOverriddenFiles = function () { this.D = {}, this.j && this.j.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, o, u, l, c, h, d = this; return _((function (f) { switch (f.h) { case 1: return d.h.inputs ? (n = 1e3 * (null == t ? performance.now() : t), v(f, d.I, 2)) : f.return(); case 2: return v(f, d.initialize(), 3); case 3: for (r = new d.i.PacketDataList, i = s(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (o = a.value, u = d.h.inputs[o]) { e: { var p = e[o]; switch (u.type) { case "video": var m = d.s[u.stream]; if (m || (m = new sn(d.i, d.K), d.s[u.stream] = m), 0 === m.m && (m.m = m.i.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, y = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, y = p.naturalHeight) : (g = p.width, y = p.height); y = { glName: m.m, width: g, height: y }, (g = m.h).canvas.width = y.width, g.canvas.height = y.height, g.activeTexture(g.TEXTURE0), m.i.bindTexture2d(m.m), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.i.bindTexture2d(0), m = y; break e; case "detections": for ((m = d.s[u.stream]) || (m = new ln(d.i), d.s[u.stream] = m), m.data || (m.data = new m.h.DetectionListData), m.data.reset(p.length), y = 0; y < p.length; ++y) { g = p[y]; var b = m.data, x = b.setBoundingBox, w = y, k = g.la, S = new Qt; if (Ze(S, 1, k.sa), Ze(S, 2, k.ta), Ze(S, 3, k.height), Ze(S, 4, k.width), Ze(S, 5, k.rotation), Ge(S, 6, k.pa), k = S.l(), x.call(b, w, k), g.ea) for (b = 0; b < g.ea.length; ++b) { S = g.ea[b], w = (x = m.data).addNormalizedLandmark, k = y, S = Object.assign({}, S, { visibility: S.visibility ? S.visibility : 0 }); var _ = new Yt; Ze(_, 1, S.x), Ze(_, 2, S.y), Ze(_, 3, S.z), S.visibility && Ze(_, 4, S.visibility), S = _.l(), w.call(x, k, S) } if (g.ba) for (b = 0; b < g.ba.length; ++b)w = (x = m.data).addClassification, k = y, S = g.ba[b], Ze(_ = new Wt, 2, S.qa), S.index && Ge(_, 1, S.index), S.label && Ge(_, 3, S.label), S.displayName && Ge(_, 4, S.displayName), S = _.l(), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign({}, l, { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.j.send(r), v(f, d.I, 4); case 4: r.delete(), f.h = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, T("Solution", fn), T("OptionType", { BOOL: 0, NUMBER: 1, ua: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = vn.prototype).reset = function () { this.h.reset() }, e.close = function () { return this.h.close(), Promise.resolve() }, e.onResults = function (e) { this.h.onResults(e) }, e.initialize = function () { var e = this; return _((function (t) { return v(t, e.h.initialize(), 0) })) }, e.send = function (e, t) { var n = this; return _((function (r) { return v(r, n.h.send(e, t), 0) })) }, e.setOptions = function (e) { this.h.setOptions(e) }, T("Pose", vn), T("POSE_CONNECTIONS", [[0, 1], [1, 2], [2, 3], [3, 7], [0, 4], [4, 5], [5, 6], [6, 8], [9, 10], [11, 12], [11, 13], [13, 15], [15, 17], [15, 19], [15, 21], [17, 19], [12, 14], [14, 16], [16, 18], [16, 20], [16, 22], [18, 20], [11, 23], [12, 24], [23, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 31], [30, 32], [27, 31], [28, 32]]), T("POSE_LANDMARKS", { NOSE: 0, LEFT_EYE_INNER: 1, LEFT_EYE: 2, LEFT_EYE_OUTER: 3, RIGHT_EYE_INNER: 4, RIGHT_EYE: 5, RIGHT_EYE_OUTER: 6, LEFT_EAR: 7, RIGHT_EAR: 8, LEFT_RIGHT: 9, RIGHT_LEFT: 10, LEFT_SHOULDER: 11, RIGHT_SHOULDER: 12, LEFT_ELBOW: 13, RIGHT_ELBOW: 14, LEFT_WRIST: 15, RIGHT_WRIST: 16, LEFT_PINKY: 17, RIGHT_PINKY: 18, LEFT_INDEX: 19, RIGHT_INDEX: 20, LEFT_THUMB: 21, RIGHT_THUMB: 22, LEFT_HIP: 23, RIGHT_HIP: 24, LEFT_KNEE: 25, RIGHT_KNEE: 26, LEFT_ANKLE: 27, RIGHT_ANKLE: 28, LEFT_HEEL: 29, RIGHT_HEEL: 30, LEFT_FOOT_INDEX: 31, RIGHT_FOOT_INDEX: 32 }), T("POSE_LANDMARKS_LEFT", { LEFT_EYE_INNER: 1, LEFT_EYE: 2, LEFT_EYE_OUTER: 3, LEFT_EAR: 7, LEFT_RIGHT: 9, LEFT_SHOULDER: 11, LEFT_ELBOW: 13, LEFT_WRIST: 15, LEFT_PINKY: 17, LEFT_INDEX: 19, LEFT_THUMB: 21, LEFT_HIP: 23, LEFT_KNEE: 25, LEFT_ANKLE: 27, LEFT_HEEL: 29, LEFT_FOOT_INDEX: 31 }), T("POSE_LANDMARKS_RIGHT", { RIGHT_EYE_INNER: 4, RIGHT_EYE: 5, RIGHT_EYE_OUTER: 6, RIGHT_EAR: 8, RIGHT_LEFT: 10, RIGHT_SHOULDER: 12, RIGHT_ELBOW: 14, RIGHT_WRIST: 16, RIGHT_PINKY: 18, RIGHT_INDEX: 20, RIGHT_THUMB: 22, RIGHT_HIP: 24, RIGHT_KNEE: 26, RIGHT_ANKLE: 28, RIGHT_HEEL: 30, RIGHT_FOOT_INDEX: 32 }), T("POSE_LANDMARKS_NEUTRAL", { NOSE: 0 }), T("VERSION", "0.5.1675469404") }).call(this) }, 9958: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.h = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.h }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || l })); var c, h = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) c = Object.setPrototypeOf; else { var d; e: { var f = {}; try { f.__proto__ = { a: !0 }, d = f.a; break e } catch (e) { } d = !1 } c = d ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var p = c; function m(e, t) { if (e.prototype = h(t.prototype), e.prototype.constructor = e, p) p(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.za = t.prototype } function g() { this.m = !1, this.j = null, this.i = void 0, this.h = 1, this.v = this.s = 0, this.l = null } function y(e) { if (e.m) throw new TypeError("Generator is already running"); e.m = !0 } function b(e, t) { e.l = { ma: t, na: !0 }, e.h = e.s || e.v } function v(e, t, n) { return e.h = n, { value: t } } function x(e) { this.h = new g, this.i = e } function w(e, t, n, r) { try { var i = t.call(e.h.j, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.h.m = !1, i; var a = i.value } catch (t) { return e.h.j = null, b(e.h, t), k(e) } return e.h.j = null, r.call(e.h, a), k(e) } function k(e) { for (; e.h.h;)try { var t = e.i(e.h); if (t) return e.h.m = !1, { value: t.value, done: !1 } } catch (t) { e.h.i = void 0, b(e.h, t) } if (e.h.m = !1, e.h.l) { if (t = e.h.l, e.h.l = null, t.na) throw t.ma; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function S(e) { this.next = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.next, t, e.h.u) : (e.h.u(t), t = k(e)), t }, this.throw = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.throw, t, e.h.u) : (b(e.h, t), t = k(e)), t }, this.return = function (t) { return function (e, t) { y(e.h); var n = e.h.j; return n ? w(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.h.return) : (e.h.return(t), k(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function _(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new S(new x(e))) } function C(e) { return e || Array.prototype.fill } g.prototype.u = function (e) { this.i = e }, g.prototype.return = function (e) { this.l = { return: e }, this.h = this.v }, a("Promise", (function (e) { function t(e) { this.i = 0, this.j = void 0, this.h = [], this.u = !1; var t = this.l(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.h = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.i = function (e) { if (null == this.h) { this.h = []; var t = this; this.j((function () { t.m() })) } this.h.push(e) }; var a = i.setTimeout; n.prototype.j = function (e) { a(e, 0) }, n.prototype.m = function () { for (; this.h && this.h.length;) { var e = this.h; this.h = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.l(e) } } } this.h = null }, n.prototype.l = function (e) { this.j((function () { throw e })) }, t.prototype.l = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.I), reject: e(this.m) } }, t.prototype.I = function (e) { if (e === this) this.m(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.L(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.F(e) : this.s(e) } }, t.prototype.F = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.m(e) } "function" == typeof t ? this.M(t, e) : this.s(e) }, t.prototype.m = function (e) { this.v(2, e) }, t.prototype.s = function (e) { this.v(1, e) }, t.prototype.v = function (e, t) { if (0 != this.i) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.i); this.i = e, this.j = t, 2 === this.i && this.K(), this.H() }, t.prototype.K = function () { var e = this; a((function () { if (e.D()) { var t = i.console; void 0 !== t && t.error(e.j) } }), 1) }, t.prototype.D = function () { if (this.u) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.j, n(e)) }, t.prototype.H = function () { if (null != this.h) { for (var e = 0; e < this.h.length; ++e)o.i(this.h[e]); this.h = null } }; var o = new n; return t.prototype.L = function (e) { var t = this.l(); e.T(t.resolve, t.reject) }, t.prototype.M = function (e, t) { var n = this.l(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.T(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.T = function (e, t) { function n() { switch (r.i) { case 1: e(r.j); break; case 2: t(r.j); break; default: throw Error("Unexpected state: " + r.i) } } var r = this; null == this.h ? o.i(n) : this.h.push(n), this.u = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).T(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).T(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })), a("Array.prototype.fill", (function (e) { return e || function (e, t, n) { var r = this.length || 0; for (0 > t && (t = Math.max(0, r + t)), (null == n || n > r) && (n = r), 0 > (n = Number(n)) && (n = Math.max(0, r + n)), t = Number(t || 0); t < n; t++)this[t] = e; return this } })), a("Int8Array.prototype.fill", C), a("Uint8Array.prototype.fill", C), a("Uint8ClampedArray.prototype.fill", C), a("Int16Array.prototype.fill", C), a("Uint16Array.prototype.fill", C), a("Int32Array.prototype.fill", C), a("Uint32Array.prototype.fill", C), a("Float32Array.prototype.fill", C), a("Float64Array.prototype.fill", C), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })); var A = this || self; function T(e, t) { e = e.split("."); var n, r = A; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function E(e) { var t; return (t = A.navigator) && (t = t.userAgent) || (t = ""), -1 != t.indexOf(e) } var N = Array.prototype.map ? function (e, t) { return Array.prototype.map.call(e, t, void 0) } : function (e, t) { for (var n = e.length, r = Array(n), i = "string" == typeof e ? e.split("") : e, a = 0; a < n; a++)a in i && (r[a] = t.call(void 0, i[a], a, e)); return r }, I = {}, M = null; function F(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = M[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } D(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function D() { if (!M) { M = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); I[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === M[a] && (M[a] = i) } } } } var $ = "undefined" != typeof Uint8Array, R = !(E("Trident") || E("MSIE")) && "function" == typeof A.btoa; function O(e) { if (!R) { var t; void 0 === t && (t = 0), D(), t = I[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } for (t = ""; 10240 < e.length;)t += String.fromCharCode.apply(null, e.subarray(0, 10240)), e = e.subarray(10240); return t += String.fromCharCode.apply(null, e), btoa(t) } var z, P = RegExp("[-_.]", "g"); function B(e) { switch (e) { case "-": return "+"; case "_": return "/"; case ".": return "="; default: return "" } } function L(e) { if (!R) return F(e); P.test(e) && (e = e.replace(P, B)), e = atob(e); for (var t = new Uint8Array(e.length), n = 0; n < e.length; n++)t[n] = e.charCodeAt(n); return t } function j() { return z || (z = new Uint8Array(0)) } var U = {}, W = "function" == typeof Uint8Array.prototype.slice, V = 0, G = 0; function H(e) { var t = 0 > e, n = (e = Math.abs(e)) >>> 0; e = Math.floor((e - n) / 4294967296), t && (t = (n = s(X(n, e))).next().value, e = n.next().value, n = t), V = n >>> 0, G = e >>> 0 } var q, Y = "function" == typeof BigInt; function X(e, t) { return t = ~t, e ? e = 1 + ~e : t += 1, [e, t] } function K(e, t) { this.i = e >>> 0, this.h = t >>> 0 } function Z(e) { if (!e) return q || (q = new K(0, 0)); if (!/^-?\d+$/.test(e)) return null; if (16 > e.length) H(Number(e)); else if (Y) e = BigInt(e), V = Number(e & BigInt(4294967295)) >>> 0, G = Number(e >> BigInt(32) & BigInt(4294967295)); else { var t = +("-" === e[0]); G = V = 0; for (var n = e.length, r = t, i = (n - t) % 6 + t; i <= n; r = i, i += 6)r = Number(e.slice(r, i)), G *= 1e6, 4294967296 <= (V = 1e6 * V + r) && (G += V / 4294967296 | 0, V %= 4294967296); t && (e = (t = s(X(V, G))).next().value, t = t.next().value, V = e, G = t) } return new K(V, G) } function J(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function Q() { return Error("Failed to read varint, encoding is invalid.") } function ee(e, t) { return Error("Tried to read past the end of the data " + t + " > " + e) } function te() { throw Error("Invalid UTF8") } function ne(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var re, ie, ae, oe = void 0, se = "undefined" != typeof TextDecoder, ue = "undefined" != typeof TextEncoder; function le(e) { if (e !== U) throw Error("illegal external caller") } function ce(e, t) { if (le(t), this.V = e, null != e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } function he() { return ae || (ae = new ce(null, U)) } function de(e) { le(U); var t = e.V; return null == (t = null == t || $ && null != t && t instanceof Uint8Array ? t : "string" == typeof t ? L(t) : null) ? t : e.V = t } function fe(e, t) { this.i = null, this.m = !1, this.h = this.j = this.l = 0, pe(this, e, t) } function pe(e, t, n) { n = void 0 === n ? {} : n, e.S = void 0 !== n.S && n.S, t && (t = function (e) { if ("string" == typeof e) return { buffer: L(e), C: !1 }; if (Array.isArray(e)) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === Uint8Array) return { buffer: e, C: !1 }; if (e.constructor === ArrayBuffer) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === ce) return { buffer: de(e) || j(), C: !0 }; if (e instanceof Uint8Array) return { buffer: new Uint8Array(e.buffer, e.byteOffset, e.byteLength), C: !1 }; throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers") }(t), e.i = t.buffer, e.m = t.C, e.l = 0, e.j = e.i.length, e.h = e.l) } function me(e, t) { if (e.h = t, t > e.j) throw ee(e.j, t) } function ge(e) { var t = e.i, n = e.h, r = t[n++], i = 127 & r; if (128 & r && (i |= (127 & (r = t[n++])) << 7, 128 & r && (i |= (127 & (r = t[n++])) << 14, 128 & r && (i |= (127 & (r = t[n++])) << 21, 128 & r && (i |= (r = t[n++]) << 28, 128 & r && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++]))))) throw Q(); return me(e, n), i } function ye(e, t) { if (0 > t) throw Error("Tried to read a negative byte length: " + t); var n = e.h, r = n + t; if (r > e.j) throw ee(t, e.j - n); return e.h = r, n } fe.prototype.reset = function () { this.h = this.l }; var be = []; function ve() { this.h = [] } function xe(e, t, n) { for (; 0 < n || 127 < t;)e.h.push(127 & t | 128), t = (t >>> 7 | n << 25) >>> 0, n >>>= 7; e.h.push(t) } function we(e, t) { for (; 127 < t;)e.h.push(127 & t | 128), t >>>= 7; e.h.push(t) } function ke(e, t) { if (be.length) { var n = be.pop(); pe(n, e, t), e = n } else e = new fe(e, t); this.h = e, this.j = this.h.h, this.i = this.l = -1, this.setOptions(t) } function Se(e) { var t = e.h; if (t.h == t.j) return !1; e.j = e.h.h; var n = ge(e.h) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw J(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.l = t, e.i = n, !0 } function _e(e) { switch (e.i) { case 0: if (0 != e.i) _e(e); else e: { for (var t = (e = e.h).h, n = t + 10, r = e.i; t < n;)if (!(128 & r[t++])) { me(e, t); break e } throw Q() } break; case 1: me(e = e.h, e.h + 8); break; case 2: 2 != e.i ? _e(e) : (t = ge(e.h) >>> 0, me(e = e.h, e.h + t)); break; case 5: me(e = e.h, e.h + 4); break; case 3: for (t = e.l; ;) { if (!Se(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.i) { if (e.l != t) throw Error("Unmatched end-group tag"); break } _e(e) } break; default: throw J(e.i, e.j) } } ve.prototype.length = function () { return this.h.length }, ve.prototype.end = function () { var e = this.h; return this.h = [], e }, ke.prototype.setOptions = function (e) { e = void 0 === e ? {} : e, this.ca = void 0 !== e.ca && e.ca }, ke.prototype.reset = function () { this.h.reset(), this.j = this.h.h, this.i = this.l = -1 }; var Ce = []; function Ae() { this.j = [], this.i = 0, this.h = new ve } function Te(e, t) { 0 !== t.length && (e.j.push(t), e.i += t.length) } var Ee = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol() : void 0; function Ne(e, t) { return Ee ? e[Ee] |= t : void 0 !== e.A ? e.A |= t : (Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }), t) } function Ie(e, t) { Ee ? e[Ee] && (e[Ee] &= ~t) : void 0 !== e.A && (e.A &= ~t) } function Me(e) { var t; return null == (t = Ee ? e[Ee] : e.A) ? 0 : t } function Fe(e, t) { Ee ? e[Ee] = t : void 0 !== e.A ? e.A = t : Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }) } function De(e) { return Ne(e, 1), e } function $e(e, t) { Fe(t, -51 & e) } function Re(e, t) { Fe(t, -41 & e | 18) } var Oe = {}; function ze(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var Pe, Be, Le = []; function je(e) { if (2 & Me(e.o)) throw Error("Cannot mutate an immutable Message") } function Ue(e) { var t = e.length; (t = t ? e[t - 1] : void 0) && ze(t) ? t.g = 1 : (t = {}, e.push((t.g = 1, t))) } function We(e) { var t = e.i + e.G; return e.B || (e.B = e.o[t] = {}) } function Ve(e, t) { return -1 === t ? null : t >= e.i ? e.B ? e.B[t] : void 0 : e.o[t + e.G] } function Ge(e, t, n, r) { je(e), He(e, t, n, r) } function He(e, t, n, r) { e.j && (e.j = void 0), t >= e.i || r ? We(e)[t] = n : (e.o[t + e.G] = n, (e = e.B) && t in e && delete e[t]) } function qe(e, t, n, r) { var i = Ve(e, t); Array.isArray(i) || (i = Pe); var a = Me(i); if (1 & a || De(i), r) 2 & a || Ne(i, 2), 1 & n || Object.freeze(i); else { r = !(2 & n); var o = 2 & a; 1 & n || !o ? r && 16 & a && !o && Ie(i, 16) : He(e, t, i = De(Array.prototype.slice.call(i))) } return i } function Ye(e, t) { var n = Ve(e, t), r = null == n ? n : "number" == typeof n || "NaN" === n || "Infinity" === n || "-Infinity" === n ? Number(n) : void 0; return null != r && r !== n && He(e, t, r), r } function Xe(e, t, n, r, i) { e.h || (e.h = {}); var a = e.h[n], o = qe(e, n, 3, i); if (!a) { var s = o; a = []; var u = !!(16 & Me(e.o)); o = !!(2 & Me(s)); var l = s; !i && o && (s = Array.prototype.slice.call(s)); for (var c = o, h = 0; h < s.length; h++) { var d = s[h], f = t, p = !1; if (p = void 0 !== p && p, void 0 !== (d = Array.isArray(d) ? new f(d) : p ? new f : void 0)) { var m = p = Me(f = d.o); o && (m |= 2), u && (m |= 16), m != p && Fe(f, m), f = m, c = c || !!(2 & f), a.push(d) } } return e.h[n] = a, t = 33 | (u = Me(s)), u != (t = c ? -9 & t : 8 | t) && (c = s, Object.isFrozen(c) && (c = Array.prototype.slice.call(c)), Fe(c, t), s = c), l !== s && He(e, n, s), (i || r && o) && Ne(a, 2), r && Object.freeze(a), a } return i || (i = Object.isFrozen(a), r && !i ? Object.freeze(a) : !r && i && (a = Array.prototype.slice.call(a), e.h[n] = a)), a } function Ke(e, t, n) { var r = !!(2 & Me(e.o)); if (t = Xe(e, t, n, r, r), e = qe(e, n, 3, r), !(r || 8 & Me(e))) { for (r = 0; r < t.length; r++) { if (2 & Me((n = t[r]).o)) { var i = ut(n, !1); i.j = n } else i = n; n !== i && (t[r] = i, e[r] = i.o) } Ne(e, 8) } return t } function Ze(e, t, n) { if (null != n && "number" != typeof n) throw Error("Value of float/double field must be a number|null|undefined, found " + typeof n + ": " + n); Ge(e, t, n) } function Je(e, t, n, r, i) { je(e); var a = Xe(e, n, t, !1, !1); return n = null != r ? r : new n, e = qe(e, t, 2, !1), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.o)) : (a.push(n), e.push(n.o)), n.C() && Ie(e, 8), n } function Qe(e, t) { return null == e ? t : e } function et(e, t, n) { return n = void 0 === n ? 0 : n, Qe(Ye(e, t), n) } function tt(e, t, n, r) { if (null != e) { if (Array.isArray(e)) e = nt(e, t, n, void 0 !== r); else if (ze(e)) { var i, a = {}; for (i in e) a[i] = tt(e[i], t, n, r); e = a } else e = t(e, r); return e } } function nt(e, t, n, r) { var i = Me(e); r = r ? !!(16 & i) : void 0, e = Array.prototype.slice.call(e); for (var a = 0; a < e.length; a++)e[a] = tt(e[a], t, n, r); return n(i, e), e } function rt(e) { return e.ja === Oe ? e.toJSON() : function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e) if (Array.isArray(e)) { if (128 & Me(e)) return Ue(e = Array.prototype.slice.call(e)), e } else { if ($ && null != e && e instanceof Uint8Array) return O(e); if (e instanceof ce) { var t = e.V; return null == t ? "" : "string" == typeof t ? t : e.V = O(t) } } }return e }(e) } function it(e, t) { 128 & e && Ue(t) } function at(e, t, n) { if (n = void 0 === n ? Re : n, null != e) { if ($ && e instanceof Uint8Array) return e.length ? new ce(new Uint8Array(e), U) : he(); if (Array.isArray(e)) { var r = Me(e); return 2 & r ? e : !t || 32 & r || !(16 & r || 0 === r) ? (4 & (t = Me(e = nt(e, at, 4 & r ? Re : n, !0))) && 2 & t && Object.freeze(e), e) : (Fe(e, 2 | r), e) } return e.ja === Oe ? st(e) : e } } function ot(e, t, n, r, i, a, o) { if (e = e.h && e.h[n]) { if (2 & (r = Me(e)) ? r = e : (Re(r, a = N(e, st)), Object.freeze(a), r = a), je(t), o = null == r ? Pe : De([]), null != r) { for (a = !!r.length, e = 0; e < r.length; e++) { var s = r[e]; a = a && !(2 & Me(s.o)), o[e] = s.o } a = 1 | (a ? 8 : 0), ((e = Me(o)) & a) !== a && (Object.isFrozen(o) && (o = Array.prototype.slice.call(o)), Fe(o, e | a)), t.h || (t.h = {}), t.h[n] = r } else t.h && (t.h[n] = void 0); He(t, n, o, i) } else Ge(t, n, at(r, a, o), i) } function st(e) { return 2 & Me(e.o) || Ne((e = ut(e, !0)).o, 2), e } function ut(e, t) { var n = e.o, r = []; Ne(r, 16); var i = e.constructor.h; if (i && r.push(i), i = e.B) { r.length = n.length, r.fill(void 0, r.length, n.length); var a = {}; r[r.length - 1] = a } 128 & Me(n) && Ue(r), t = t || e.C() ? Re : $e, a = e.constructor, Be = r, r = new a(r), Be = void 0, e.R && (r.R = e.R.slice()), a = !!(16 & Me(n)); for (var o = i ? n.length - 1 : n.length, s = 0; s < o; s++)ot(e, r, s - e.G, n[s], !1, a, t); if (i) for (var u in i) ot(e, r, +u, i[u], !0, a, t); return r } function lt(e, t, n) { null == e && (e = Be), Be = void 0; var r, i = this.constructor.i || 0, a = 0 < i, o = this.constructor.h, s = !1; if (null == e) { var u = 48, l = !0; a && (i = 0, u |= 128), Fe(e = o ? [o] : [], u) } else { if (!Array.isArray(e)) throw Error(); if (o && o !== e[0]) throw Error(); var c = u = Ne(e, 0); if ((l = !!(16 & c)) && ((s = !!(32 & c)) || (c |= 32)), a) { if (128 & c) i = 0; else if (0 < e.length) { var h = e[e.length - 1]; if (ze(h) && "g" in h) { i = 0, c |= 128, delete h.g; var d, f = !0; for (d in h) { f = !1; break } f && e.pop() } } } else if (128 & c) throw Error(); u !== c && Fe(e, c) } if (this.G = (o ? 0 : -1) - i, this.h = void 0, this.o = e, i = (o = this.o.length) - 1, o && ze(o = this.o[i]) ? (this.B = o, this.i = i - this.G) : void 0 !== t && -1 < t ? (this.i = Math.max(t, i + 1 - this.G), this.B = void 0) : this.i = Number.MAX_VALUE, !a && this.B && "g" in this.B) throw Error('Unexpected "g" flag in sparse object of message that is not a group type.'); if (n) for (t = l && !s && !0, a = this.i, l = 0; l < n.length; l++)(s = n[l]) < a ? (i = e[s += this.G]) ? ct(i, t) : e[s] = Pe : (r || (r = We(this)), (i = r[s]) ? ct(i, t) : r[s] = Pe) } function ct(e, t) { if (Array.isArray(e)) { var n = Me(e), r = 1; !t || 2 & n || (r |= 16), (n & r) !== r && Fe(e, n | r) } } function ht(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.ra; o || (i.J = a.xa || a.oa.W, a.ia ? (i.aa = vt(a.ia), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.aa) } }(i)) : a.ka ? (i.Z = xt(a.da.P, a.ka), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.Z) } }(i)) : o = i.J, a.ra = o), o(t, e, a.da), i = { J: i.J, aa: i.aa, Z: i.Z } } } !function (e, t) { if (t = t.R) { Te(e, e.h.end()); for (var n = 0; n < t.length; n++)Te(e, de(t[n]) || j()) } }(t, e) } Fe(Le, 23), Pe = Object.freeze(Le), lt.prototype.toJSON = function () { return nt(this.o, rt, it) }, lt.prototype.C = function () { return !!(2 & Me(this.o)) }, lt.prototype.ja = Oe, lt.prototype.toString = function () { return this.o.toString() }; var dt = Symbol(); function ft(e, t, n) { return e[dt] || (e[dt] = function (e, r) { return t(e, r, n) }) } function pt(e) { var t = e[dt]; if (!t) { var n = Ft(e); t = function (e, t) { return Dt(e, t, n) }, e[dt] = t } return t } function mt(e) { var t = function (e) { var t = e.ia; return t ? pt(t) : (t = e.wa) ? ft(e.da.P, t, e.ka) : void 0 }(e), n = e.da, r = e.oa.U; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function gt(e, t) { var n = e[t]; return "function" == typeof n && 0 === n.length && (n = n(), e[t] = n), Array.isArray(n) && (Tt in n || wt in n || 0 < n.length && "function" == typeof n[0]) ? n : void 0 } function yt(e, t, n, r, i, a) { t.P = e[0]; var o = 1; if (e.length > o && "number" != typeof e[o]) { var s = e[o++]; n(t, s) } for (; o < e.length;) { n = e[o++]; for (var u = o + 1; u < e.length && "number" != typeof e[u];)u++; switch (s = e[o++], u -= o) { case 0: r(t, n, s); break; case 1: (u = gt(e, o)) ? (o++, i(t, n, s, u)) : r(t, n, s, e[o++]); break; case 2: i(t, n, s, u = gt(e, u = o++), e[o++]); break; case 3: a(t, n, s, e[o++], e[o++], e[o++]); break; case 4: a(t, n, s, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + u) } } return t } var bt = Symbol(); function vt(e) { var t = e[bt]; if (!t) { var n = At(e); t = function (e, t) { return $t(e, t, n) }, e[bt] = t } return t } function xt(e, t) { var n = e[bt]; return n || (n = function (e, n) { return ht(e, n, t) }, e[bt] = n), n } var wt = Symbol(); function kt(e, t) { e.push(t) } function St(e, t, n) { e.push(t, n.W) } function _t(e, t, n, r) { var i = vt(r), a = At(r).P, o = n.W; e.push(t, (function (e, t, n) { return o(e, t, n, a, i) })) } function Ct(e, t, n, r, i, a) { var o = xt(r, a), s = n.W; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function At(e) { var t = e[wt]; return t || (t = yt(e, e[wt] = [], kt, St, _t, Ct), Tt in e && wt in e && (e.length = 0), t) } var Tt = Symbol(); function Et(e, t) { e[0] = t } function Nt(e, t, n, r) { var i = n.U; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function It(e, t, n, r, i) { var a = n.U, o = pt(r), s = Ft(r).P; e[t] = function (e, t, n) { return a(e, t, n, s, o, i) } } function Mt(e, t, n, r, i, a, o) { var s = n.U, u = ft(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Ft(e) { var t = e[Tt]; return t || (t = yt(e, e[Tt] = {}, Et, Nt, It, Mt), Tt in e && wt in e && (e.length = 0), t) } function Dt(e, t, n) { for (; Se(t) && 4 != t.i;) { var r = t.l, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = mt(a)) } if (!i || !i(t, e, r)) { r = e, a = (i = t).j, _e(i); var o = i; if (!o.ca) { if (i = o.h.h - a, o.h.h = a, o = o.h, 0 == i) i = he(); else { if (a = ye(o, i), o.S && o.m) i = o.i.subarray(a, a + i); else { o = o.i; var s = a; i = s === (i = a + i) ? j() : W ? o.slice(s, i) : new Uint8Array(o.subarray(s, i)) } i = 0 == i.length ? he() : new ce(i, U) } (a = r.R) ? a.push(i) : r.R = [i] } } } return e } function $t(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); ht(e, t, i ? n[0] : void 0) } function Rt(e, t) { return { U: e, W: t } } var Ot = Rt((function (e, t, n) { if (5 !== e.i) return !1; var r = (e = e.h).i, i = e.h, a = r[i], o = r[i + 1], s = r[i + 2]; return r = r[i + 3], me(e, e.h + 4), e = 2 * ((o = (a | o << 8 | s << 16 | r << 24) >>> 0) >> 31) + 1, a = o >>> 23 & 255, o &= 8388607, Ge(t, n, 255 == a ? o ? NaN : 1 / 0 * e : 0 == a ? e * Math.pow(2, -149) * o : e * Math.pow(2, a - 150) * (o + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = Ye(t, n))) { we(e.h, 8 * n + 5), e = e.h; var r = +t; 0 === r ? 0 < 1 / r ? V = G = 0 : (G = 0, V = 2147483648) : isNaN(r) ? (G = 0, V = 2147483647) : 34028234663852886e22 < (r = (n = 0 > r ? -2147483648 : 0) ? -r : r) ? (G = 0, V = (2139095040 | n) >>> 0) : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), G = 0, V = (n | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, G = 0, V = (n | t + 127 << 23 | 8388607 & r) >>> 0), n = V, e.h.push(n >>> 0 & 255), e.h.push(n >>> 8 & 255), e.h.push(n >>> 16 & 255), e.h.push(n >>> 24 & 255) } })), zt = Rt((function (e, t, n) { if (0 !== e.i) return !1; var r = e.h, i = 0, a = e = 0, o = r.i, s = r.h; do { var u = o[s++]; i |= (127 & u) << a, a += 7 } while (32 > a && 128 & u); for (32 < a && (e |= (127 & u) >> 4), a = 3; 32 > a && 128 & u; a += 7)e |= (127 & (u = o[s++])) << a; if (me(r, s), !(128 > u)) throw Q(); return r = i >>> 0, (e = 2147483648 & (u = e >>> 0)) && (u = ~u >>> 0, 0 == (r = 1 + ~r >>> 0) && (u = u + 1 >>> 0)), r = 4294967296 * u + (r >>> 0), Ge(t, n, e ? -r : r), !0 }), (function (e, t, n) { null != (t = Ve(t, n)) && ("string" == typeof t && Z(t), null != t && (we(e.h, 8 * n), "number" == typeof t ? (e = e.h, H(t), xe(e, V, G)) : (n = Z(t), xe(e.h, n.i, n.h)))) })), Pt = Rt((function (e, t, n) { return 0 === e.i && (Ge(t, n, ge(e.h)), !0) }), (function (e, t, n) { if (null != (t = Ve(t, n)) && null != t) if (we(e.h, 8 * n), e = e.h, 0 <= (n = t)) we(e, n); else { for (t = 0; 9 > t; t++)e.h.push(127 & n | 128), n >>= 7; e.h.push(1) } })), Bt = Rt((function (e, t, n) { if (2 !== e.i) return !1; var r = ge(e.h) >>> 0, i = ye(e = e.h, r); if (e = e.i, se) { var a, o = e; (a = re) || (a = re = new TextDecoder("utf-8", { fatal: !0 })), e = i + r, o = 0 === i && e === o.length ? o : o.subarray(i, e); try { var s = a.decode(o) } catch (e) { if (void 0 === oe) { try { a.decode(new Uint8Array([128])) } catch (e) { } try { a.decode(new Uint8Array([97])), oe = !0 } catch (e) { oe = !1 } } throw !oe && (re = void 0), e } } else { r = (s = i) + r, i = []; for (var u, l, c = null; s < r;)128 > (u = e[s++]) ? i.push(u) : 224 > u ? s >= r ? te() : (l = e[s++], 194 > u || 128 != (192 & l) ? (s--, te()) : i.push((31 & u) << 6 | 63 & l)) : 240 > u ? s >= r - 1 ? te() : 128 != (192 & (l = e[s++])) || 224 === u && 160 > l || 237 === u && 160 <= l || 128 != (192 & (o = e[s++])) ? (s--, te()) : i.push((15 & u) << 12 | (63 & l) << 6 | 63 & o) : 244 >= u ? s >= r - 2 ? te() : 128 != (192 & (l = e[s++])) || l - 144 + (u << 28) >> 30 || 128 != (192 & (o = e[s++])) || 128 != (192 & (a = e[s++])) ? (s--, te()) : (u = (7 & u) << 18 | (63 & l) << 12 | (63 & o) << 6 | 63 & a, u -= 65536, i.push(55296 + (u >> 10 & 1023), 56320 + (1023 & u))) : te(), 8192 <= i.length && (c = ne(c, i), i.length = 0); s = ne(c, i) } return Ge(t, n, s), !0 }), (function (e, t, n) { if (null != (t = Ve(t, n))) { var r = !1; if (r = void 0 !== r && r, ue) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (ie || (ie = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = i === a.length ? a : a.subarray(0, i) } we(e.h, 8 * n + 2), we(e.h, t.length), Te(e, e.h.end()), Te(e, t) } })), Lt = Rt((function (e, t, n, r, i) { if (2 !== e.i) return !1; t = Je(t, n, r), n = e.h.j, r = ge(e.h) >>> 0; var a = e.h.h + r, o = a - n; if (0 >= o && (e.h.j = a, i(t, e, void 0, void 0, void 0), o = a - e.h.h), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.h.h = a, e.h.j = n, !0 }), (function (e, t, n, r, i) { if (null != (t = Ke(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; we(a.h, 8 * n + 2); var o = a.h.end(); Te(a, o), o.push(a.i), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.i + o.h.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.i++; a.push(s), o.i++ } })); function jt(e) { return function (t, n) { e: { if (Ce.length) { var r = Ce.pop(); r.setOptions(n), pe(r.h, t, n), t = r } else t = new ke(t, n); try { var i = Ft(e), a = Dt(new i.P, t, i); break e } finally { (i = t.h).i = null, i.m = !1, i.l = 0, i.j = 0, i.h = 0, i.S = !1, t.l = -1, t.i = -1, 100 > Ce.length && Ce.push(t) } a = void 0 } return a } } function Ut(e) { return function () { var t = new Ae; $t(this, t, At(e)), Te(t, t.h.end()); for (var n = new Uint8Array(t.i), r = t.j, i = r.length, a = 0, o = 0; o < i; o++) { var s = r[o]; n.set(s, a), a += s.length } return t.j = [n], n } } function Wt(e) { lt.call(this, e) } m(Wt, lt); var Vt = [Wt, 1, Pt, 2, Ot, 3, Bt, 4, Bt]; function Gt(e) { lt.call(this, e, -1, Ht) } Wt.prototype.l = Ut(Vt), m(Gt, lt), Gt.prototype.addClassification = function (e, t) { return Je(this, 1, Wt, e, t), this }; var Ht = [1], qt = jt([Gt, 1, Lt, Vt]); function Yt(e) { lt.call(this, e) } m(Yt, lt); var Xt = [Yt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot]; function Kt(e) { lt.call(this, e, -1, Zt) } Yt.prototype.l = Ut(Xt), m(Kt, lt); var Zt = [1], Jt = jt([Kt, 1, Lt, Xt]); function Qt(e) { lt.call(this, e) } m(Qt, lt); var en = [Qt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot, 6, zt], tn = jt(en); function nn(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function rn(e) { return Ke(e, Wt, 1).map((function (e) { var t = Ve(e, 1); return { index: null == t ? 0 : t, qa: et(e, 2), label: null != Ve(e, 3) ? Qe(Ve(e, 3), "") : void 0, displayName: null != Ve(e, 4) ? Qe(Ve(e, 4), "") : void 0 } })) } function an(e) { return { x: et(e, 1), y: et(e, 2), z: et(e, 3), visibility: null != Ye(e, 4) ? et(e, 4) : void 0 } } function on(e, t) { this.i = e, this.h = t, this.m = 0 } function sn(e, t, n) { return function (e, t) { var n = e.h; if (void 0 === e.s) { var r = nn(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = nn(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.s = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.l = { O: n.getAttribLocation(r, "aVertex"), N: n.getAttribLocation(r, "aTex"), ya: i }, e.v = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.enableVertexAttribArray(e.l.O), n.vertexAttribPointer(e.l.O, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.l.N), n.vertexAttribPointer(e.l.N, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.l, n.useProgram(e.s), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.i.bindTexture2d(t.glName), n.enableVertexAttribArray(r.O), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.vertexAttribPointer(r.O, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.N, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.O), n.disableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, null), e.i.bindTexture2d(0) }(e, t), "function" == typeof e.h.canvas.transferToImageBitmap ? Promise.resolve(e.h.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.h.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.h.canvas) : (void 0 === e.j && (e.j = document.createElement("canvas")), new Promise((function (t) { e.j.height = e.h.canvas.height, e.j.width = e.h.canvas.width, e.j.getContext("2d", {}).drawImage(e.h.canvas, 0, 0, e.h.canvas.width, e.h.canvas.height), t(e.j) }))) } function un(e) { this.h = e } Qt.prototype.l = Ut(en); var ln = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function cn(e, t) { return t + e } function hn(e, t) { window[e] = t } function dn(e) { if (this.h = e, this.listeners = {}, this.l = {}, this.L = {}, this.s = {}, this.v = {}, this.M = this.u = this.ga = !0, this.I = Promise.resolve(), this.fa = "", this.D = {}, this.locateFile = e && e.locateFile || cn, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.ha = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.l[n] = "function" == typeof r ? r() : r) } } function fn(e) { var t, n, r, i, a, o, s, l, c, h, d; return _((function (f) { switch (f.h) { case 1: return e.ga ? (t = void 0 === e.h.files ? [] : "function" == typeof e.h.files ? e.h.files(e.l) : e.h.files, v(f, _((function (e) { switch (e.h) { case 1: return e.s = 2, v(e, WebAssembly.instantiate(ln), 4); case 4: e.h = 3, e.s = 0; break; case 2: return e.s = 0, e.l = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.i, "object" == typeof window) return hn("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), hn("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), s = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = pn(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(s.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.ha)) : Promise.resolve() }))).then((function () { var t, n, r; return _((function (i) { if (1 == i.h) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, v(i, t(n), 2); r.i = i.i, i.h = 0 })) })), h = _((function (t) { return e.h.graph && e.h.graph.url ? t = v(t, pn(e, e.h.graph.url), 0) : (t.h = 0, t = void 0), t })), v(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.ha) })), importScripts.apply(null, u(r)), i = e, v(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.i = f.i, e.m = new OffscreenCanvas(1, 1), e.i.canvas = e.m, a = e.i.GL.createContext(e.m, { antialias: !1, alpha: !1, va: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.i.GL.makeContextCurrent(a), f.h = 4; break; case 7: if (e.m = document.createElement("canvas"), !(d = e.m.getContext("webgl2", {})) && !(d = e.m.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.K = d, e.i.canvas = e.m, e.i.createContext(e.m, !0, !0, {}); case 4: e.j = new e.i.SolutionWasm, e.ga = !1, f.h = 0 } })) } function pn(e, t) { var n, r; return _((function (i) { return t in e.L ? i.return(e.L[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.L[t] = r, i.return(r)) })) } function mn(e, t, n) { var r, i, a, o, u, l, c, h, d, f, p, m, g, y; return _((function (b) { switch (b.h) { case 1: if (!n) return b.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.M = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { b.h = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, v(b, function (e, t, n) { var r; return _((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.i.Uint8BlobList ? i.return(n) : n instanceof e.i.Texture2dDataOut ? ((r = e.v[t]) || (r = new on(e.i, e.K), e.v[t] = r), i.return(sn(r, n, e.M))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), S = [], C = 0; C < x.size(); ++C) { var A = tn(x.get(C)), T = void 0; T = void 0 === T ? 0 : T, A = { la: { sa: et(A, 1), ta: et(A, 2), height: et(A, 3), width: et(A, 4), rotation: et(A, 5, 0), pa: Qe(Ve(A, 6), T) }, ea: Ke(Jt(w.get(C)), Yt, 1).map(an), ba: rn(qt(k.get(C))) }, S.push(A) } x = S } else x = []; r[h] = x, b.h = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, b.h = 7; break } if (void 0 === f) { b.h = 3; break } if ("float_list" === d.type) { r[h] = f, b.h = 7; break } if ("proto" === d.type) { r[h] = f, b.h = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.v[h]) || (p = new on(e.i, e.K), e.v[h] = p), v(b, sn(p, f, e.M), 13); case 13: m = b.i, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), b.h = 3; break; case 14: g[y] = b.i; case 3: o = c.next(), b.h = 2; break; case 4: return b.return(r) } })) } function gn(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.i.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.i.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.I = mn(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.I = n) }))) } }), e.j.attachMultiListener(i, a), i.delete() } function yn(e) { return void 0 === e && (e = 0), 1 === e ? "selfie_segmentation_landscape.tflite" : "selfie_segmentation.tflite" } function bn(e) { var t = this; e = e || {}, this.h = new dn({ locateFile: e.locateFile, files: function (e) { return [{ simd: !0, url: "selfie_segmentation_solution_simd_wasm_bin.js" }, { simd: !1, url: "selfie_segmentation_solution_wasm_bin.js" }, { data: !0, url: yn(e.modelSelection) }] }, graph: { url: "selfie_segmentation.binarypb" }, listeners: [{ wants: ["segmentation_mask", "image_transformed"], outs: { image: { type: "texture", stream: "image_transformed" }, segmentationMask: { type: "texture", stream: "segmentation_mask" } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, modelSelection: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorModelSelection", fieldName: "int_value" }, onChange: function (e) { var n, r, i; return _((function (a) { return 1 == a.h ? (n = yn(e), r = "third_party/mediapipe/modules/selfie_segmentation/" + n, v(a, pn(t.h, n), 2)) : (i = a.i, t.h.overrideFile(r, i), a.return(!0)) })) } } } }) } (e = dn.prototype).close = function () { return this.j && this.j.delete(), Promise.resolve() }, e.reset = function () { var e = this; return _((function (t) { e.j && (e.j.reset(), e.s = {}, e.v = {}), t.h = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.h.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { X: a.X, Y: a.Y }, u = o.next())if (!((u = u.value) in this.l) || this.l[u] !== e[u]) { this.l[u] = e[u]; var l = t[u]; void 0 !== l && (l.onChange && (a.X = l.onChange, a.Y = e[u], r.push(function (e) { return function () { return _((function (t) { if (1 == t.h) return v(t, e.X(e.Y), 2); !0 === t.i && (n.u = !0), t.h = 0 })) } }(a))), l.graphOptionXref && (u = Object.assign({}, { calculatorName: "", calculatorIndex: 0 }, l.graphOptionXref, { valueNumber: 1 === l.type ? e[u] : 0, valueBoolean: 0 === l.type && e[u], valueString: 2 === l.type ? e[u] : "" }), i.push(u))) } 0 === r.length && 0 === i.length || (this.u = !0, this.H = (void 0 === this.H ? [] : this.H).concat(i), this.F = (void 0 === this.F ? [] : this.F).concat(r)) } }, e.initialize = function () { var e = this; return _((function (t) { return 1 == t.h ? v(t, fn(e), 2) : 3 != t.h ? v(t, function (e) { var t, n, r, i, a, o, u, l; return _((function (c) { if (1 == c.h) return e.h.graph && e.h.graph.url && e.fa === e.h.graph.url ? c.return() : (e.u = !0, e.h.graph && e.h.graph.url ? (e.fa = e.h.graph.url, v(c, pn(e, e.h.graph.url), 3)) : void (c.h = 2)); for (2 != c.h && (t = c.i, e.j.loadGraph(t)), n = s(Object.keys(e.D)), r = n.next(); !r.done; r = n.next())i = r.value, e.j.overrideFile(i, e.D[i]); if (e.D = {}, e.h.listeners) for (a = s(e.h.listeners), o = a.next(); !o.done; o = a.next())u = o.value, gn(e, u); l = e.l, e.l = {}, e.setOptions(l), c.h = 0 })) }(e), 3) : v(t, function (e) { var t, n, r, i, a, o; return _((function (u) { switch (u.h) { case 1: if (!e.u) return u.return(); if (!e.F) { u.h = 2; break } t = s(e.F), n = t.next(); case 3: if (n.done) { u.h = 5; break } return v(u, (0, n.value)(), 4); case 4: n = t.next(), u.h = 3; break; case 5: e.F = void 0; case 2: if (e.H) { for (r = new e.i.GraphOptionChangeRequestList, i = s(e.H), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); e.j.changeOptions(r), r.delete(), e.H = void 0 } e.u = !1, u.h = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.j ? this.j.overrideFile(e, t) : this.D[e] = t }, e.clearOverriddenFiles = function () { this.D = {}, this.j && this.j.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, o, u, l, c, h, d = this; return _((function (f) { switch (f.h) { case 1: return d.h.inputs ? (n = 1e3 * (null == t ? performance.now() : t), v(f, d.I, 2)) : f.return(); case 2: return v(f, d.initialize(), 3); case 3: for (r = new d.i.PacketDataList, i = s(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (o = a.value, u = d.h.inputs[o]) { e: { var p = e[o]; switch (u.type) { case "video": var m = d.s[u.stream]; if (m || (m = new on(d.i, d.K), d.s[u.stream] = m), 0 === m.m && (m.m = m.i.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, y = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, y = p.naturalHeight) : (g = p.width, y = p.height); y = { glName: m.m, width: g, height: y }, (g = m.h).canvas.width = y.width, g.canvas.height = y.height, g.activeTexture(g.TEXTURE0), m.i.bindTexture2d(m.m), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.i.bindTexture2d(0), m = y; break e; case "detections": for ((m = d.s[u.stream]) || (m = new un(d.i), d.s[u.stream] = m), m.data || (m.data = new m.h.DetectionListData), m.data.reset(p.length), y = 0; y < p.length; ++y) { g = p[y]; var b = m.data, x = b.setBoundingBox, w = y, k = g.la, S = new Qt; if (Ze(S, 1, k.sa), Ze(S, 2, k.ta), Ze(S, 3, k.height), Ze(S, 4, k.width), Ze(S, 5, k.rotation), Ge(S, 6, k.pa), k = S.l(), x.call(b, w, k), g.ea) for (b = 0; b < g.ea.length; ++b) { S = g.ea[b], w = (x = m.data).addNormalizedLandmark, k = y, S = Object.assign({}, S, { visibility: S.visibility ? S.visibility : 0 }); var _ = new Yt; Ze(_, 1, S.x), Ze(_, 2, S.y), Ze(_, 3, S.z), S.visibility && Ze(_, 4, S.visibility), S = _.l(), w.call(x, k, S) } if (g.ba) for (b = 0; b < g.ba.length; ++b)w = (x = m.data).addClassification, k = y, S = g.ba[b], Ze(_ = new Wt, 2, S.qa), S.index && Ge(_, 1, S.index), S.label && Ge(_, 3, S.label), S.displayName && Ge(_, 4, S.displayName), S = _.l(), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign({}, l, { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.j.send(r), v(f, d.I, 4); case 4: r.delete(), f.h = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, T("Solution", dn), T("OptionType", { BOOL: 0, NUMBER: 1, ua: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = bn.prototype).close = function () { return this.h.close(), Promise.resolve() }, e.onResults = function (e) { this.h.onResults(e) }, e.initialize = function () { var e = this; return _((function (t) { return v(t, e.h.initialize(), 0) })) }, e.reset = function () { this.h.reset() }, e.send = function (e) { var t = this; return _((function (n) { return v(n, t.h.send(e), 0) })) }, e.setOptions = function (e) { this.h.setOptions(e) }, T("SelfieSegmentation", bn), T("VERSION", "0.1.1675465747") }).call(this) }, 3185: (e, t) => { + "use strict"; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + t.c6 = void 0, t.c6 = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] + }, 5149: (e, t, n) => { "use strict"; n.d(t, { GJ: () => r, uI: () => i }); class r { constructor(e, t) { this.backend = e, this.dataMover = t, this.data = new WeakMap, this.dataIdsCount = 0 } get(e) { return this.data.has(e) || this.dataMover.moveData(this.backend, e), this.data.get(e) } set(e, t) { this.dataIdsCount++, this.data.set(e, t) } has(e) { return this.data.has(e) } delete(e) { return this.dataIdsCount--, this.data.delete(e) } numDataIds() { return this.dataIdsCount } } class i { refCount(e) { return a("refCount") } incRef(e) { return a("incRef") } timerAvailable() { return !0 } time(e) { return a("time") } read(e) { return a("read") } readSync(e) { return a("readSync") } readToGPU(e, t) { return a("readToGPU") } numDataIds() { return a("numDataIds") } disposeData(e, t) { return a("disposeData") } write(e, t, n) { return a("write") } move(e, t, n, r, i) { return a("move") } createTensorFromGPUData(e, t, n) { return a("createTensorFromGPUData") } memory() { return a("memory") } floatPrecision() { return a("floatPrecision") } epsilon() { return 32 === this.floatPrecision() ? 1e-7 : 1e-4 } dispose() { return a("dispose") } } function a(e) { throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`) } }, 8360: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function r(e, t, n) { const r = function (e, t, n) { return function (e, t, n) { let r = 0, i = e.length, a = 0, o = !1; for (; r < i;) { a = r + (i - r >>> 1); const s = n(t, e[a]); s > 0 ? r = a + 1 : (i = a, o = !s) } return o ? r : -r - 1 }(e, t, n || i) }(e, t, n), a = r < 0 ? -(r + 1) : r; e.splice(a, 0, t) } function i(e, t) { return e > t ? 1 : e < t ? -1 : 0 } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function a(e, t, n, r, i) { return u(e, t, n, r, i, 0) } function o(e, t, n, r, i, a) { return u(e, t, n, r, i, 0, !1, a, !0) } function s(e, t, n, r, i, a) { return u(e, t, n, r, i, a, !0) } function u(e, t, n, i, a, o, s = !1, u = !1, d = !1) { const f = []; for (let e = 0; e < t.length; e++)t[e] > a && f.push({ score: t[e], boxIndex: e, suppressBeginIndex: 0 }); f.sort(h); const p = o > 0 ? -.5 / o : 0, m = [], g = []; for (; m.length < n && f.length > 0;) { const t = f.pop(), { score: n, boxIndex: o, suppressBeginIndex: s } = t; if (n < a) break; let u = !1; for (let n = m.length - 1; n >= s; --n) { const r = l(e, o, m[n]); if (r >= i) { u = !0; break } if (t.score = t.score * c(i, p, r), t.score <= a) break } t.suppressBeginIndex = m.length, u || (t.score === n ? (m.push(o), g.push(t.score)) : t.score > a && r(f, t, h)) } const y = m.length, b = n - y; u && b > 0 && (m.push(...new Array(b).fill(0)), g.push(...new Array(b).fill(0))); const v = { selectedIndices: m }; return s && (v.selectedScores = g), d && (v.validOutputs = y), v } function l(e, t, n) { const r = e.subarray(4 * t, 4 * t + 4), i = e.subarray(4 * n, 4 * n + 4), a = Math.min(r[0], r[2]), o = Math.min(r[1], r[3]), s = Math.max(r[0], r[2]), u = Math.max(r[1], r[3]), l = Math.min(i[0], i[2]), c = Math.min(i[1], i[3]), h = Math.max(i[0], i[2]), d = Math.max(i[1], i[3]), f = (s - a) * (u - o), p = (h - l) * (d - c); if (f <= 0 || p <= 0) return 0; const m = Math.max(a, l), g = Math.max(o, c), y = Math.min(s, h), b = Math.min(u, d), v = Math.max(y - m, 0) * Math.max(b - g, 0); return v / (f + p - v) } function c(e, t, n) { const r = Math.exp(t * n * n); return n <= e ? r : 0 } function h(e, t) { return e.score - t.score || e.score === t.score && t.boxIndex - e.boxIndex } n.d(t, { c7: () => a, ZS: () => o, ut: () => s }) + }, 4411: (e, t, n) => { + "use strict"; n.d(t, { Y: () => i }); var r = n(448); +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */function i(e, t) { const n = []; for (let e = 0; e < t.length; e++)t[e] && n.push(e); const i = (0, r.r)(e, "int32"), a = (0, r.r)([n.length, e.length], "int32"); for (let t = 0; t < n.length; t++) { const r = i.indexToLoc(n[t]), o = t * e.length; a.values.set(r, o) } return a.toTensor() } + }, 1585: (e, t, n) => { + "use strict"; n.d(t, { T2: () => x, Ye: () => v }); var r = n(5149), i = n(6574), a = n(1743), o = n(5441), s = n(7074), u = n(3673), l = n(3879), c = n(5119); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class h { constructor(e, t) { this.backendTimer = e, this.logger = t, null == t && (this.logger = new f) } profileKernel(e, t, n) { let r; const a = () => { r = n() }; let o; const s = l.now(); if (this.backendTimer.timerAvailable()) o = this.backendTimer.time(a); else { a(); for (const e of r) e.dataSync(); o = Promise.resolve({ kernelMs: l.now() - s }) } if ((0, i._K)().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let t = 0; t < r.length; t++) { const n = r[t]; n.data().then((t => { d(t, n.dtype, e) })) } return { kernelName: e, outputs: r, inputs: t, timeMs: o.then((e => e.kernelMs)), extraInfo: o.then((e => null != e.getExtraProfileInfo ? e.getExtraProfileInfo() : "")) } } logKernelProfile(e) { const { kernelName: t, outputs: n, timeMs: r, inputs: i, extraInfo: a } = e; n.forEach((e => { Promise.all([e.data(), r, a]).then((n => { this.logger.logKernelProfile(t, e, n[0], n[1], i, n[2]) })) })) } } function d(e, t, n) { if ("float32" !== t) return !1; for (let t = 0; t < e.length; t++) { const r = e[t]; if (isNaN(r) || !isFinite(r)) return console.warn(`Found ${r} in the result of '${n}'`), !0 } return !1 } class f { logKernelProfile(e, t, n, r, i, a) { const o = "number" == typeof r ? c.av(`${r}ms`, 9) : r.error, s = c.av(e, 25), u = t.rank, l = t.size, h = c.av(t.shape.toString(), 14); let d = ""; for (const e in i) { const n = i[e]; if (null != n) { const r = n.shape || t.shape, i = r.length; d += `${e}: ${i}D ${i > 0 ? r : ""} ` } } console.log(`%c${s}\t%c${o}\t%c${u}D ${h}\t%c${l}\t%c${d}\t%c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue") } } var p = n(259), m = n(565); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function g(e) { return null != e.kernelName } class y { constructor() { this.registeredVariables = {}, this.nextTapeNodeId = 0, this.numBytes = 0, this.numTensors = 0, this.numStringTensors = 0, this.numDataBuffers = 0, this.gradientDepth = 0, this.kernelDepth = 0, this.scopeStack = [], this.numDataMovesStack = [], this.nextScopeId = 0, this.tensorInfo = new WeakMap, this.profiling = !1, this.activeProfile = { newBytes: 0, newTensors: 0, peakBytes: 0, kernels: [], result: null, get kernelNames() { return Array.from(new Set(this.kernels.map((e => e.name)))) } } } dispose() { for (const e in this.registeredVariables) this.registeredVariables[e].dispose() } } class b { + constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new y } async ready() { if (null != this.pendingBackendInit) return this.pendingBackendInit.then((() => { })); if (null != this.backendInstance) return; const e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { const n = e[t]; if (await this.initializeBackend(n).success) return void await this.setBackend(n) } throw new Error("Could not initialize any backends, all backend initializations failed.") } get backend() { if (null != this.pendingBackendInit) throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`); if (null == this.backendInstance) { const { name: e, asyncInit: t } = this.initializeBackendsAndReturnBest(); if (t) throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`); this.setBackend(e) } return this.backendInstance } backendNames() { return Object.keys(this.registryFactory) } findBackend(e) { if (!(e in this.registry)) { if (!(e in this.registryFactory)) return null; { const { asyncInit: t } = this.initializeBackend(e); if (t) return null } } return this.registry[e] } findBackendFactory(e) { return e in this.registryFactory ? this.registryFactory[e].factory : null } registerBackend(e, t, n = 1) { return e in this.registryFactory ? (u.i(`${e} backend was already registered. Reusing existing backend factory.`), !1) : (this.registryFactory[e] = { factory: t, priority: n }, !0) } async setBackend(e) { if (null == this.registryFactory[e]) throw new Error(`Backend name '${e}' not found in registry`); if (this.backendName = e, null == this.registry[e]) { this.backendInstance = null; const { success: t, asyncInit: n } = this.initializeBackend(e); if (!(n ? await t : t)) return !1 } return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new h(this.backendInstance), !0 } setupRegisteredKernels() { (0, s.Op)(this.backendName).forEach((e => { null != e.setupFunc && e.setupFunc(this.backendInstance) })) } disposeRegisteredKernels(e) { (0, s.Op)(e).forEach((t => { null != t.disposeFunc && t.disposeFunc(this.registry[e]) })) } initializeBackend(e) { const t = this.registryFactory[e]; if (null == t) throw new Error(`Cannot initialize backend ${e}, no registration found.`); try { const n = t.factory(); if (!n || n instanceof r.uI || "function" != typeof n.then) return this.registry[e] = n, { success: !0, asyncInit: !1 }; { const t = ++this.pendingBackendInitId, r = n.then((n => !(t < this.pendingBackendInitId) && (this.registry[e] = n, this.pendingBackendInit = null, !0))).catch((n => (t < this.pendingBackendInitId || (this.pendingBackendInit = null, u.i(`Initialization of backend ${e} failed`), u.i(n.stack || n.message)), !1))); return this.pendingBackendInit = r, { success: r, asyncInit: !0 } } } catch (t) { return u.i(`Initialization of backend ${e} failed`), u.i(t.stack || t.message), { success: !1, asyncInit: !1 } } } removeBackend(e) { if (!(e in this.registryFactory)) throw new Error(`${e} backend not found in registry`); this.backendName === e && null != this.pendingBackendInit && this.pendingBackendInitId++, e in this.registry && (this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]), delete this.registryFactory[e], this.backendName === e && (this.pendingBackendInit = null, this.backendName = null, this.backendInstance = null) } getSortedBackends() { if (0 === Object.keys(this.registryFactory).length) throw new Error("No backend found in registry."); return Object.keys(this.registryFactory).sort(((e, t) => this.registryFactory[t].priority - this.registryFactory[e].priority)) } initializeBackendsAndReturnBest() { const e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { const n = e[t], { success: r, asyncInit: i } = this.initializeBackend(n); if (i || r) return { name: n, asyncInit: i } } throw new Error("Could not initialize any backends, all backend initializations failed.") } moveData(e, t) { const n = this.state.tensorInfo.get(t), r = n.backend, i = this.readSync(t), a = r.refCount(t); r.disposeData(t, !0), n.backend = e, e.move(t, i, n.shape, n.dtype, a), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++ } tidy(e, t) { let n, r = null; if (null == t) { if ("function" != typeof e) throw new Error("Please provide a function to tidy()"); t = e } else { if ("string" != typeof e && !(e instanceof String)) throw new Error("When calling with two arguments, the first argument to tidy() must be a string"); if ("function" != typeof t) throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function"); r = e } return this.scopedRun((() => this.startScope(r)), (() => this.endScope(n)), (() => (n = t(), n instanceof Promise && console.error("Cannot return a Promise inside of tidy."), n))) } scopedRun(e, t, n) { e(); try { const e = n(); return t(), e } catch (e) { throw t(), e } } nextTensorId() { return b.nextTensorId++ } nextVariableId() { return b.nextVariableId++ } clone(e) { const t = x.runKernel(o.lzr, { x: e }), n = { x: e }; return this.addTapeNode(this.state.activeScope.name, n, [t], (e => ({ x: () => { const t = { x: e }, n = { dtype: "float32" }; return x.runKernel(o.KXH, t, n) } })), [], {}), t } runKernel(e, t, n) { null == this.backendName && this.backend; if (!(null != (0, s._5)(e, this.backendName))) throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`); return this.runKernelFunc({ kernelName: e, inputs: t, attrs: n }) } shouldCheckForMemLeaks() { return this.ENV.getBool("IS_TEST") } checkKernelForMemLeak(e, t, n) { const r = this.backend.numDataIds(); let i = 0; n.forEach((e => { i += "complex64" === e.dtype ? 3 : 1 })); const a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], o = r - t - i - a; if (o > 0) throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`) } runKernelFunc(e) { let t, n = []; const r = this.isTapeOn(), i = this.state.numBytes, a = this.state.numTensors; let o, u; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0), null == this.backendName && this.backend; const l = g(e) ? e.kernelName : null != this.state.activeScope ? this.state.activeScope.name : ""; if (g(e)) { const { kernelName: t, inputs: i, attrs: a } = e; null == this.backendName && this.backend; const l = (0, s._5)(t, this.backendName); c.vA(null != l, (() => `Cannot find registered kernel '${t}' for backend '${this.backendName}'`)), o = () => { const e = this.backend.numDataIds(); u = l.kernelFunc({ inputs: i, attrs: a, backend: this.backend }); const o = Array.isArray(u) ? u : [u]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(t, e, o); const s = o.map((e => null != e.rank ? e : this.makeTensorFromTensorInfo(e))); if (r) { const e = this.getTensorsForGradient(t, i, s); n = this.saveTensorsForBackwardMode(e) } return s } } else { const { forwardFunc: t } = e, i = e => { r && (n = e.map((e => this.keep(this.clone(e))))) }; o = () => { const e = this.backend.numDataIds(); u = this.tidy((() => t(this.backend, i))); const n = Array.isArray(u) ? u : [u]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(l, e, n), n } } const { inputs: h, attrs: d } = e, f = g(e) ? null : e.backwardsFunc; let p; return this.scopedRun((() => this.state.kernelDepth++), (() => this.state.kernelDepth--), (() => { this.ENV.getBool("DEBUG") || this.state.profiling ? (p = this.profiler.profileKernel(l, h, (() => o())), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(p), t = p.outputs) : t = o() })), r && this.addTapeNode(l, h, t, f, n, d), this.state.profiling && this.state.activeProfile.kernels.push({ name: l, bytesAdded: this.state.numBytes - i, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(h).map((e => null != h[e] ? h[e].shape : null)), outputShapes: t.map((e => e.shape)), kernelTimeMs: p.timeMs, extraInfo: p.extraInfo }), Array.isArray(u) ? t : t[0] } saveTensorsForBackwardMode(e) { const t = e.map((e => this.keep(this.clone(e)))); return t } getTensorsForGradient(e, t, n) { const r = (0, s.vQ)(e); if (null != r) { const e = r.inputsToSave || [], i = r.outputsToSave || []; let a; r.saveAllInputs ? (c.vA(Array.isArray(t), (() => "saveAllInputs is true, expected inputs to be an array.")), a = Object.keys(t).map((e => t[e]))) : a = e.map((e => t[e])); const o = n.filter(((e, t) => i[t])); return a.concat(o) } return [] } makeTensor(e, t, n, r) { if (null == e) throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", r = r || this.backend; let i = e; "string" === n && c.Kg(e[0]) && (i = e.map((e => l.encodeString(e)))); const a = r.write(i, t, n), o = new p.qY(t, n, a, this.nextTensorId()); if (this.trackTensor(o, r), "string" === n) { const e = this.state.tensorInfo.get(a), t = (0, c.SL)(i); this.state.numBytes += t - e.bytes, e.bytes = t } return o } makeTensorFromDataId(e, t, n, r) { const i = { dataId: e, shape: t, dtype: n = n || "float32" }; return this.makeTensorFromTensorInfo(i, r) } makeTensorFromTensorInfo(e, t) { const { dataId: n, shape: r, dtype: i } = e, a = new p.qY(r, i, n, this.nextTensorId()); return this.trackTensor(a, t), a } makeVariable(e, t = !0, n, r) { n = n || this.nextVariableId().toString(), null != r && r !== e.dtype && (e = e.cast(r)); const i = new p.rT(e, t, n, this.nextTensorId()); if (null != this.state.registeredVariables[i.name]) throw new Error(`Variable with name ${i.name} was already registered`); return this.state.registeredVariables[i.name] = i, this.incRef(i, this.backend), i } trackTensor(e, t) { this.state.numTensors++, "string" === e.dtype && this.state.numStringTensors++; let n = 0; "complex64" !== e.dtype && "string" !== e.dtype && (n = e.size * c.jv(e.dtype)), this.state.numBytes += n, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t || this.backend, dtype: e.dtype, shape: e.shape, bytes: n })), e instanceof p.rT || this.track(e) } incRef(e, t) { this.trackTensor(e, t), this.backend.incRef(e.dataId) } removeDataId(e, t) { this.state.tensorInfo.has(e) && this.state.tensorInfo.get(e).backend === t && (this.state.tensorInfo.delete(e), this.state.numDataBuffers--) } disposeTensor(e) { if (!this.state.tensorInfo.has(e.dataId)) return; const t = this.state.tensorInfo.get(e.dataId); if (this.state.numTensors--, "string" === e.dtype && (this.state.numStringTensors--, this.state.numBytes -= t.bytes), "complex64" !== e.dtype && "string" !== e.dtype) { const t = e.size * c.jv(e.dtype); this.state.numBytes -= t } t.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t.backend) } disposeVariables() { for (const e in this.state.registeredVariables) { const t = this.state.registeredVariables[e]; this.disposeVariable(t) } } disposeVariable(e) { this.disposeTensor(e), null != this.state.registeredVariables[e.name] && delete this.state.registeredVariables[e.name] } memory() { const e = this.backend.memory(); return e.numTensors = this.state.numTensors, e.numDataBuffers = this.state.numDataBuffers, e.numBytes = this.state.numBytes, this.state.numStringTensors > 0 && (e.unreliable = !0, null == e.reasons && (e.reasons = []), e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")), e } async profile(e) { this.state.profiling = !0; const t = this.state.numBytes, n = this.state.numTensors; this.state.activeProfile.kernels = [], this.state.activeProfile.result = await e(), this.state.profiling = !1, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((e => e.totalBytesSnapshot))), this.state.activeProfile.newBytes = this.state.numBytes - t, this.state.activeProfile.newTensors = this.state.numTensors - n; for (const e of this.state.activeProfile.kernels) e.kernelTimeMs = await e.kernelTimeMs, e.extraInfo = await e.extraInfo; return this.state.activeProfile } isTapeOn() { return this.state.gradientDepth > 0 && 0 === this.state.kernelDepth } addTapeNode(e, t, n, r, i, a) { const o = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: i }, u = (0, s.vQ)(e); null != u && (r = u.gradFunc), null != r && (o.gradient = e => (e = e.map(((e, t) => { if (null == e) { const e = n[t], r = c.Ty(e.size, e.dtype); return this.makeTensor(r, e.shape, e.dtype) } return e })), r(e.length > 1 ? e : e[0], i, a))), this.state.activeTape.push(o) } keep(e) { return e.kept = !0, e } startTape() { 0 === this.state.gradientDepth && (this.state.activeTape = []), this.state.gradientDepth++ } endTape() { this.state.gradientDepth-- } startScope(e) { const t = { track: [], name: "unnamed scope", id: this.state.nextScopeId++ }; e && (t.name = e), this.state.scopeStack.push(t), this.state.activeScope = t } endScope(e) { const t = (0, m.getTensorsInContainer)(e), n = new Set(t.map((e => e.id))); for (let e = 0; e < this.state.activeScope.track.length; e++) { const t = this.state.activeScope.track[e]; t.kept || n.has(t.id) || t.dispose() } const r = this.state.scopeStack.pop(); this.state.activeScope = 0 === this.state.scopeStack.length ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t.forEach((e => { e.kept || e.scopeId !== r.id || this.track(e) })) } gradients(e, t, n, r = !1) { + if (c.vA(t.length > 0, (() => "gradients() received an empty list of xs.")), null != n && "float32" !== n.dtype) throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`); const i = this.scopedRun((() => this.startTape()), (() => this.endTape()), (() => this.tidy("forward", e))); c.vA(i instanceof p.qY, (() => "The result y returned by f() must be a tensor.")); const a = + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = {}, i = {}; for (let e = 0; e < t.length; e++)r[t[e].id] = !0; for (let n = 0; n < e.length; n++) { const a = e[n], o = a.inputs; for (const e in o) { const n = o[e]; let s = !1; for (let e = 0; e < t.length; e++)if (r[n.id]) { a.outputs.forEach((e => r[e.id] = !0)), s = !0, i[a.id] = !0; break } if (s) break } } const a = {}; a[n.id] = !0; const o = {}; for (let t = e.length - 1; t >= 0; t--) { const n = e[t], r = n.inputs; for (let e = 0; e < n.outputs.length; e++)if (a[n.outputs[e].id]) { for (const e in r) a[r[e].id] = !0, o[n.id] = !0; break } } const s = []; for (let t = 0; t < e.length; t++) { const n = e[t]; if (i[n.id] && o[n.id]) { const e = {}; for (const t in n.inputs) { const i = n.inputs[t]; r[i.id] && (e[t] = i) } const t = Object.assign({}, n); t.inputs = e, t.outputs = n.outputs, s.push(t) } } return s }(this.state.activeTape, t, i); if (!r && 0 === a.length && t.length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y."); return this.tidy("backward", (() => { const e = {}; e[i.id] = null == n ? function (e) { const t = (0, c.FZ)((0, c.Ze)(e), "float32"); return x.makeTensor(t, e, "float32") }(i.shape) : n, function (e, t, n, r) { for (let i = t.length - 1; i >= 0; i--) { const a = t[i], o = []; if (a.outputs.forEach((t => { const n = e[t.id]; null != n ? o.push(n) : o.push(null) })), null == a.gradient) throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`); const s = a.gradient(o); for (const t in a.inputs) { if (!(t in s)) throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`); const i = n((() => s[t]())); if ("float32" !== i.dtype) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${i.dtype}'`); const o = a.inputs[t]; if (!c.r1(i.shape, o.shape)) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${t}' has shape '${i.shape}', which does not match the shape of the input '${o.shape}'`); if (null == e[o.id]) e[o.id] = i; else { const t = e[o.id]; e[o.id] = r(t, i), t.dispose() } } } }(e, a, (e => this.tidy(e)), w); const r = t.map((t => e[t.id])); return 0 === this.state.gradientDepth && (this.state.activeTape.forEach((e => { for (const t of e.saved) t.dispose() })), this.state.activeTape = null), { value: i, grads: r } })) + } customGrad(e) { return c.vA(c.Tn(e), (() => "The f passed in customGrad(f) must be a function.")), (...t) => { let n; c.vA(t.every((e => e instanceof p.qY)), (() => "The args passed in customGrad(f)(x1, x2,...) must all be tensors")); const r = {}; t.forEach(((e, t) => { r[t] = e })); return this.runKernelFunc({ forwardFunc: (r, i) => (n = e(...t, i), c.vA(n.value instanceof p.qY, (() => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")), c.vA(c.Tn(n.gradFunc), (() => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")), n.value), backwardsFunc: (e, r) => { const i = n.gradFunc(e, r), a = Array.isArray(i) ? i : [i]; c.vA(a.length === t.length, (() => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")), c.vA(a.every((e => e instanceof p.qY)), (() => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.")); const o = {}; return a.forEach(((e, t) => { o[t] = () => e })), o }, inputs: r }) } } readSync(e) { return this.state.tensorInfo.get(e).backend.readSync(e) } read(e) { return this.state.tensorInfo.get(e).backend.read(e) } readToGPU(e, t) { return this.state.tensorInfo.get(e).backend.readToGPU(e, t) } async time(e) { const t = (0, l.now)(), n = await this.backend.time(e); return n.wallMs = (0, l.now)() - t, n } track(e) { return null != this.state.activeScope && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e } get registeredVariables() { return this.state.registeredVariables } reset() { this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new y; for (const e in this.registry) this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]; this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null } + } function v() { const e = (0, a.L)(); if (null == e._tfengine) { const t = new i.OH(e); e._tfengine = new b(t) } return (0, i.tj)(e._tfengine.ENV), (0, p.qP)((() => e._tfengine)), e._tfengine } b.nextTensorId = 0, b.nextVariableId = 0; const x = v(); function w(e, t) { const n = { a: e, b: t }; return x.runKernel(o.OMN, n) } + }, 6574: (e, t, n) => { + "use strict"; n.d(t, { Km: () => u, OH: () => a, _K: () => s, tj: () => l }); var r = n(5119); +/** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */const i = "tfjsflags"; class a { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = o, this.populateURLFlags() } setPlatform(e, t) { null != this.platform && (s().getBool("IS_TEST") || s().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, null != this.urlFlags[e]) { const t = this.urlFlags[e]; s().getBool("IS_TEST") || s().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${t}.`), this.set(e, t) } } async getAsync(e) { return e in this.flags || (this.flags[e] = await this.evaluateFlag(e)), this.flags[e] } get(e) { if (e in this.flags) return this.flags[e]; const t = this.evaluateFlag(e); if ((0, r.yL)(t)) throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`); return this.flags[e] = t, this.flags[e] } getNumber(e) { return this.get(e) } getBool(e) { return this.get(e) } getString(e) { return this.get(e) } getFlags() { return this.flags } get features() { return this.flags } set(e, t) { if (null == this.flagRegistry[e]) throw new Error(`Cannot set flag ${e} as it has not been registered.`); this.flags[e] = t, null != this.flagRegistry[e].setHook && this.flagRegistry[e].setHook(t) } evaluateFlag(e) { if (null == this.flagRegistry[e]) throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`); return this.flagRegistry[e].evaluationFn() } setFlags(e) { this.flags = Object.assign({}, e) } reset() { this.flags = {}, this.urlFlags = {}, this.populateURLFlags() } populateURLFlags() { if (void 0 === this.global || void 0 === this.global.location || void 0 === this.global.location.search) return; const e = this.getQueryParams(this.global.location.search); if (i in e) { e[i].split(",").forEach((e => { const [t, n] = e.split(":"); this.urlFlags[t] = function (e, t) { const n = t.toLowerCase(); return "true" === n || "false" === n ? "true" === n : "" + +n === n ? +n : t }(0, n) })) } } } function o(e) { const t = {}; return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, ((e, ...n) => (function (e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || "") }(t, n[0], n[1]), n.join("=")))), t } function s() { return u } let u = null; function l(e) { u = e } + }, 1743: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + let r; function i() { if (null == r) { let e; if ("undefined" != typeof window) e = window; else if (void 0 !== n.g) e = n.g; else if ("undefined" != typeof process) e = process; else { if ("undefined" == typeof self) throw new Error("Could not find a global object"); e = self } r = e } return r } function a(e, t) { const n = function () { const e = i(); return null == e._tfGlobals && (e._tfGlobals = new Map), e._tfGlobals }(); if (n.has(e)) return n.get(e); { const r = t(); return n.set(e, r), n.get(e) } } n.d(t, { L: () => i, m: () => a }) + }, 5287: (e, t, n) => { + "use strict"; n.d(t, { AS: () => g, DZ: () => m, Gc: () => x, Hi: () => d, Hs: () => A, IS: () => l, ME: () => p, Ok: () => T, Sm: () => s, W4: () => _, aC: () => y, fL: () => c, gJ: () => C, gY: () => u, go: () => S, jh: () => v, jz: () => w, kB: () => b, m1: () => f, rE: () => k, rm: () => h }); var r = n(1585), i = n(6574), a = n(259), o = n(565); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function s() { (0, i._K)().set("PROD", !0) } function u() { (0, i._K)().set("DEBUG", !0) } function l() { (0, i._K)().set("DEPRECATION_WARNINGS_ENABLED", !1), console.warn("TensorFlow.js deprecation warnings have been disabled.") } function c(e) { (0, i._K)().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(e + " You can disable deprecation warnings with tf.disableDeprecationWarnings().") } function h() { r.T2.disposeVariables() } function d() { return r.T2 } function f() { return r.T2.memory() } function p(e) { return r.T2.profile(e) } function m(e, t) { return r.T2.tidy(e, t) } function g(e) { (0, o.getTensorsInContainer)(e).forEach((e => e.dispose())) } function y(e) { return r.T2.keep(e) } function b(e) { return r.T2.time(e) } function v(e) { return r.T2.setBackend(e) } function x() { return r.T2.ready() } function w() { return r.T2.backendName } function k(e) { r.T2.removeBackend(e) } function S(e) { return r.T2.findBackend(e) } function _(e) { return r.T2.findBackendFactory(e) } function C(e, t, n = 1) { return r.T2.registerBackend(e, t, n) } function A() { return r.T2.backend } function T(e, t) { (0, i._K)().setPlatform(e, t) } (0, a.B4)(c) + }, 1830: (e, t, n) => { + "use strict"; n.d(t, { Dv: () => s, _X: () => d, jY: () => l, mu: () => c, ok: () => u, y7: () => h }); var r = n(1585), i = n(259), a = n(8189), o = n(5119); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function s(e) { return o.vA(o.Tn(e), (() => "The f passed in grad(f) must be a function")), (t, n) => { const i = (0, a.YT)(t, "x", "tf.grad", "string_or_numeric"), s = null != n ? (0, a.YT)(n, "dy", "tf.grad") : null; return r.T2.tidy((() => { const { value: t, grads: n } = r.T2.gradients((() => e(i)), [i], s); return null != s && o.O3(t.shape, s.shape, "The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"), f(n), n[0] })) } } function u(e) { return o.vA(o.Tn(e), (() => "The f passed in grads(f) must be a function")), (t, n) => { o.vA(Array.isArray(t), (() => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s")); const i = (0, a.j1)(t, "args", "tf.grads", "string_or_numeric"), s = null != n ? (0, a.YT)(n, "dy", "tf.grads") : null; return r.T2.tidy((() => { const { value: t, grads: n } = r.T2.gradients((() => e(...i)), i, s); return null != s && o.O3(t.shape, s.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), f(n), n })) } } function l(e) { return o.vA(o.Tn(e), (() => "The f passed in valueAndGrad(f) must be a function")), (t, n) => { o.vA(t instanceof i.qY, (() => "The x passed in valueAndGrad(f)(x) must be a tensor")), o.vA(null == n || n instanceof i.qY, (() => "The dy passed in valueAndGrad(f)(x, dy) must be a tensor")); const { grads: a, value: s } = r.T2.gradients((() => e(t)), [t], n); return f(a), { grad: a[0], value: s } } } function c(e) { return o.vA(o.Tn(e), (() => "The f passed in valueAndGrads(f) must be a function")), (t, n) => { o.vA(Array.isArray(t) && t.every((e => e instanceof i.qY)), (() => "The args passed in valueAndGrads(f)(args) must be array of tensors")), o.vA(null == n || n instanceof i.qY, (() => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor")); const a = r.T2.gradients((() => e(...t)), t, n); return null != n && o.O3(a.value.shape, n.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), f(a.grads), a } } function h(e, t) { o.vA(o.Tn(e), (() => "The f passed in variableGrads(f) must be a function")), o.vA(null == t || Array.isArray(t) && t.every((e => e instanceof i.rT)), (() => "The varList passed in variableGrads(f, varList) must be an array of variables")); const n = null != t; if (!n) { t = []; for (const e in r.T2.registeredVariables) t.push(r.T2.registeredVariables[e]) } const a = n ? t.filter((e => !e.trainable)) : null, s = t.length; t = t.filter((e => e.trainable)), o.vA(t.length > 0, (() => `variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`)); const { value: u, grads: l } = r.T2.gradients(e, t, null, !0); o.vA(l.some((e => null != e)), (() => "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().")), o.vA(0 === u.rank, (() => `The f passed in variableGrads(f) must return a scalar, but it returned a rank-${u.rank} tensor`)); const c = {}; return t.forEach(((e, t) => { null != l[t] && (c[e.name] = l[t]) })), null != a && a.forEach((e => c[e.name] = null)), { value: u, grads: c } } function d(e) { return r.T2.customGrad(e) } function f(e) { if (e.filter((e => null == e)).length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.") } + }, 5838: (e, t, n) => { + "use strict"; n.r(t), n.d(t, { Abs: () => yt.ljI, Acos: () => yt.Vvy, Acosh: () => yt.PH8, AdadeltaOptimizer: () => Ie, AdagradOptimizer: () => Fe, AdamOptimizer: () => Re, AdamaxOptimizer: () => Pe, Add: () => yt.OMN, AddN: () => yt.EkD, All: () => yt.u8Z, Any: () => yt.FSt, ArgMax: () => yt.Jp_, ArgMin: () => yt.p_m, Asin: () => yt.QKF, Asinh: () => yt.epO, Atan: () => yt.TyE, Atan2: () => yt.lxb, Atanh: () => yt.zP9, AvgPool: () => yt.ho8, AvgPool3D: () => yt.cS, AvgPool3DGrad: () => yt.wwC, AvgPoolGrad: () => yt.VCH, BatchMatMul: () => yt.jAQ, BatchToSpaceND: () => yt.Ik2, Bincount: () => yt.N4F, BitwiseAnd: () => yt.HNs, BroadcastArgs: () => yt.vj7, BroadcastTo: () => yt.LB5, Cast: () => yt.KXH, Ceil: () => yt.QDP, ClipByValue: () => yt.vaV, Complex: () => yt.pr3, ComplexAbs: () => yt.$zE, Concat: () => yt.$dB, Conv2D: () => yt.p2J, Conv2DBackpropFilter: () => yt.rFm, Conv2DBackpropInput: () => yt.jfg, Conv3D: () => yt.A1h, Conv3DBackpropFilterV2: () => yt.iGz, Conv3DBackpropInputV2: () => yt.gC7, Cos: () => yt.Mn0, Cosh: () => yt.MnK, CropAndResize: () => yt.MRQ, Cumprod: () => yt.jj_, Cumsum: () => yt.nY8, DataStorage: () => fr.GJ, DenseBincount: () => yt.wNW, DepthToSpace: () => yt.TMz, DepthwiseConv2dNative: () => yt.tGH, DepthwiseConv2dNativeBackpropFilter: () => yt.X$8, DepthwiseConv2dNativeBackpropInput: () => yt.nVu, Diag: () => yt.ORI, Dilation2D: () => yt.jxD, Dilation2DBackpropFilter: () => yt.pk0, Dilation2DBackpropInput: () => yt.bP9, Draw: () => yt.XmO, ENV: () => b.Km, Einsum: () => yt.Qgm, Elu: () => yt.Pah, EluGrad: () => yt.rsH, Environment: () => b.OH, Equal: () => yt.BRl, Erf: () => yt._s9, Exp: () => yt.ox3, ExpandDims: () => yt.ybN, Expm1: () => yt.ybj, FFT: () => yt.rGP, Fill: () => yt.SQl, FlipLeftRight: () => yt.BxF, Floor: () => yt.ZgB, FloorDiv: () => yt.ElG, FromPixels: () => yt.awo, FusedBatchNorm: () => yt.i5R, FusedConv2D: () => yt.aAr, FusedDepthwiseConv2D: () => yt.T7M, GatherNd: () => yt.O4G, GatherV2: () => yt.mxL, Greater: () => yt.XhZ, GreaterEqual: () => yt.lLS, IFFT: () => yt.OAQ, Identity: () => yt.lzr, Imag: () => yt.dv8, IsFinite: () => yt.gIW, IsInf: () => yt.E3$, IsNan: () => yt.iPs, KernelBackend: () => fr.uI, LRN: () => yt.jM4, LRNGrad: () => yt.ToN, LeakyRelu: () => yt.X0$, Less: () => yt.mIA, LessEqual: () => yt.CwD, LinSpace: () => yt.mnI, Log: () => yt.tG8, Log1p: () => yt.Cg$, LogSoftmax: () => yt.zfU, LogicalAnd: () => yt.RUm, LogicalNot: () => yt.nZd, LogicalOr: () => yt.LXA, LogicalXor: () => yt.RW8, LowerBound: () => yt.yPW, MatrixBandPart: () => yt.WRv, Max: () => yt.VAI, MaxPool: () => yt.t3d, MaxPool3D: () => yt.ySp, MaxPool3DGrad: () => yt.cHb, MaxPoolGrad: () => yt.RXX, MaxPoolWithArgmax: () => yt.TL8, Maximum: () => yt.LDN, Mean: () => yt.g5A, Min: () => yt.lNG, Minimum: () => yt.LG0, MirrorPad: () => yt.x7F, Mod: () => yt.BLA, MomentumOptimizer: () => Le, Multinomial: () => yt.WT3, Multiply: () => yt.xu7, Neg: () => yt.l0G, NonMaxSuppressionV3: () => yt.SDM, NonMaxSuppressionV4: () => yt.Zl4, NonMaxSuppressionV5: () => yt.e0f, NotEqual: () => yt.ylV, OP_SCOPE_SUFFIX: () => Zt.BTT, OneHot: () => yt.urI, OnesLike: () => yt.LWX, Optimizer: () => Ne, OptimizerConstructors: () => Xt, Pack: () => yt.mM$, PadV2: () => yt.ODT, Pool: () => yt.bCz, Pow: () => yt.pyJ, Prelu: () => yt.Ncv, Prod: () => yt.kdj, RMSPropOptimizer: () => je, RaggedGather: () => yt.oJ2, RaggedRange: () => yt.CQC, RaggedTensorToTensor: () => yt.mH5, Range: () => yt.Q6t, Rank: () => Kt.rg, Real: () => yt.LRy, RealDiv: () => yt.sDr, Reciprocal: () => yt.huO, Reduction: () => Jt.i, Relu: () => yt.fUj, Relu6: () => yt.P_L, Reshape: () => yt.R23, ResizeBilinear: () => yt.hgw, ResizeBilinearGrad: () => yt.FCQ, ResizeNearestNeighbor: () => yt.jOE, ResizeNearestNeighborGrad: () => yt.XQy, Reverse: () => yt.D7i, RotateWithOffset: () => yt.BK4, Round: () => yt.hVg, Rsqrt: () => yt.TOR, SGDOptimizer: () => Be, ScatterNd: () => yt.pJc, SearchSorted: () => yt.uWl, Select: () => yt.l6P, Selu: () => yt.u$b, Sigmoid: () => yt.vI1, Sign: () => yt.YVe, Sin: () => yt.hql, Sinh: () => yt.J3C, Slice: () => yt.JiE, Softmax: () => yt.rFG, Softplus: () => yt.Fin, SpaceToBatchND: () => yt.A8B, SparseFillEmptyRows: () => yt.C8s, SparseReshape: () => yt.BoJ, SparseSegmentMean: () => yt.L6G, SparseSegmentSum: () => yt.DvZ, SparseToDense: () => yt.jgd, SplitV: () => yt.Blb, Sqrt: () => yt.dFH, Square: () => yt.M6A, SquaredDifference: () => yt.Ddj, StaticRegexReplace: () => yt.GZp, Step: () => yt.pnw, StridedSlice: () => yt.UcO, StringNGrams: () => yt.YAb, StringSplit: () => yt.iW0, StringToHashBucketFast: () => yt.$jE, Sub: () => yt.PbM, Sum: () => yt.WuN, Tan: () => yt.oFs, Tanh: () => yt.iuW, Tensor: () => de.qY, TensorBuffer: () => de.yl, TensorScatterUpdate: () => yt.X4r, Tile: () => yt.FAs, TopK: () => yt.TBb, Transform: () => yt.dLy, Transpose: () => yt.wx0, Unique: () => yt.EwU, Unpack: () => yt.dXR, UnsortedSegmentSum: () => yt.pPe, UpperBound: () => yt.RMm, Variable: () => de.rT, ZerosLike: () => yt.xJ3, _FusedMatMul: () => yt.Dr, abs: () => Zt.tnl, acos: () => Zt.HQu, acosh: () => Zt.FqL, add: () => Zt.WQq, addN: () => Zt.QiD, all: () => Zt.Q7R, any: () => Zt.bzn, argMax: () => Zt.FLi, argMin: () => Zt.XRg, asin: () => Zt.qRo, asinh: () => Zt.yHs, atan: () => Zt.rYl, atan2: () => Zt.FPz, atanh: () => Zt.rfv, avgPool: () => Zt.$jT, avgPool3d: () => Zt.sub, backend: () => pe.Hs, backend_util: () => h, basicLSTMCell: () => Zt.lZX, batchNorm: () => Zt.$v7, batchNorm2d: () => Zt.BFc, batchNorm3d: () => Zt.kSi, batchNorm4d: () => Zt.T5N, batchToSpaceND: () => Zt.GTe, bincount: () => Zt.HbZ, bitwiseAnd: () => Zt.vjT, booleanMaskAsync: () => Zt.ftb, broadcastArgs: () => Zt.ROE, broadcastTo: () => Zt.hOW, broadcast_util: () => gt, browser: () => s, buffer: () => Zt.ra8, cast: () => Zt.wgE, ceil: () => Zt.mkO, clipByValue: () => Zt.zQh, clone: () => Zt.o8B, complex: () => Zt.faB, concat: () => Zt.xWs, concat1d: () => Zt.I1m, concat2d: () => Zt.RPU, concat3d: () => Zt.O5O, concat4d: () => Zt.P1l, conv1d: () => Zt.kA9, conv2d: () => Zt.Xtf, conv2dTranspose: () => Zt.wX9, conv3d: () => Zt.IPL, conv3dTranspose: () => Zt.jIJ, copyRegisteredKernels: () => bt.Cf, cos: () => Zt.gnS, cosh: () => Zt.yIG, cosineWindow: () => Zt._jP, cumprod: () => Zt.Lp0, cumsum: () => Zt.rCv, customGrad: () => we._X, denseBincount: () => Zt.aOp, deprecationWarn: () => pe.fL, depthToSpace: () => Zt.Rj8, depthwiseConv2d: () => Zt.Gl3, device_util: () => r, diag: () => Zt.smy, dilation2d: () => Zt.X7t, disableDeprecationWarnings: () => pe.IS, dispose: () => pe.AS, disposeVariables: () => pe.rm, div: () => Zt.y4m, divNoNan: () => Zt.ek5, dot: () => Zt.Omf, dropout: () => Zt.EZY, einsum: () => Zt._3C, elu: () => Zt.Pqc, enableDebugMode: () => pe.gY, enableProdMode: () => pe.Sm, enclosingPowerOfTwo: () => Zt.FJY, engine: () => pe.Hi, ensureShape: () => Zt.QP2, env: () => b._K, equal: () => Zt.LCg, erf: () => Zt.Y12, euclideanNorm: () => Zt.p4S, exp: () => Zt.oNF, expandDims: () => Zt.UG6, expm1: () => Zt.IYd, eye: () => Zt.y5U, fft: () => Zt.hVP, fill: () => Zt.GSj, findBackend: () => pe.go, findBackendFactory: () => pe.W4, floor: () => Zt.RIf, floorDiv: () => Zt.wh_, fused: () => Zt.cZk, gather: () => Zt.kgh, gatherND: () => Zt.SY9, gather_util: () => u, getBackend: () => pe.jz, getGradient: () => bt.vQ, getKernel: () => bt._5, getKernelsForBackend: () => bt.Op, grad: () => we.Dv, grads: () => we.ok, greater: () => Zt.rhj, greaterEqual: () => Zt.DQN, ifft: () => Zt.KGM, imag: () => Zt.ngS, image: () => Zt.Slp, inTopKAsync: () => Zt.U4u, io: () => a, irfft: () => Zt.ggX, isFinite: () => Zt.MIs, isInf: () => Zt.EN4, isNaN: () => Zt.yrW, keep: () => pe.aC, kernel_impls: () => d, leakyRelu: () => Zt.H8d, less: () => Zt.M7h, lessEqual: () => Zt.InN, linalg: () => Zt.mPL, linspace: () => Zt.mT8, localResponseNormalization: () => Zt.Kgs, log: () => Zt.Rm2, log1p: () => Zt.Kko, logSigmoid: () => Zt.nqI, logSoftmax: () => Zt.HPB, logSumExp: () => Zt.VZ, logicalAnd: () => Zt.n76, logicalNot: () => Zt.NSZ, logicalOr: () => Zt.ztW, logicalXor: () => Zt.rxB, losses: () => Zt.YYh, lowerBound: () => Zt.yzS, matMul: () => Zt.NoW, math: () => o, max: () => Zt.T9B, maxPool: () => Zt.jgi, maxPool3d: () => Zt.NYV, maxPoolWithArgmax: () => Zt.RO, maximum: () => Zt.PhQ, mean: () => Zt.i2o, memory: () => pe.m1, meshgrid: () => Zt.OYQ, min: () => Zt.jkA, minimum: () => Zt.BpO, mirrorPad: () => Zt.FFZ, mod: () => Zt.ziu, moments: () => Zt.Clk, movingAverage: () => Zt.CRk, mul: () => Zt.lKK, multiRNNCell: () => Zt.YDF, multinomial: () => Zt.OjQ, neg: () => Zt.HZy, nextFrame: () => tn, norm: () => Zt.xbf, notEqual: () => Zt.Ec, oneHot: () => Zt.Mw0, ones: () => Zt.SaS, onesLike: () => Zt.P61, op: () => Zt.op, outerProduct: () => Zt.X4o, pad: () => Zt.eVF, pad1d: () => Zt.BZs, pad2d: () => Zt.grY, pad3d: () => Zt.XHu, pad4d: () => Zt.WLX, pool: () => Zt.dzn, pow: () => Zt.n7C, prelu: () => Zt.NsG, print: () => Zt.yyV, prod: () => Zt._eU, profile: () => pe.ME, raggedGather: () => Zt.whe, raggedRange: () => Zt.iyU, raggedTensorToTensor: () => Zt.Q0_, rand: () => Zt._9M, randomGamma: () => Zt.pR9, randomNormal: () => Zt.FE$, randomStandardNormal: () => Zt.m0H, randomUniform: () => Zt.YeY, randomUniformInt: () => Zt.HYA, range: () => Zt.y17, ready: () => pe.Gc, real: () => Zt.xav, reciprocal: () => Zt.VOZ, registerBackend: () => pe.gJ, registerGradient: () => bt.kr, registerKernel: () => bt.tA, relu: () => Zt.VVh, relu6: () => Zt.j__, removeBackend: () => pe.rE, reshape: () => Zt.tQQ, reverse: () => Zt.BEg, reverse1d: () => Zt.QD2, reverse2d: () => Zt.LMr, reverse3d: () => Zt.I2l, reverse4d: () => Zt.JYU, rfft: () => Zt.z8$, round: () => Zt.LIG, rsqrt: () => Zt.Z$r, scalar: () => Zt.d_2, scatterND: () => Zt.NFr, scatter_util: () => It, searchSorted: () => Zt.sZg, selu: () => Zt.WfX, separableConv2d: () => Zt.wdz, serialization: () => i, setBackend: () => pe.jh, setPlatform: () => pe.Ok, setdiff1dAsync: () => Zt.F12, sigmoid: () => Zt.ry7, sign: () => Zt._SZ, signal: () => Zt.vPA, sin: () => Zt.F8e, sinh: () => Zt.L0l, slice: () => Zt.dik, slice1d: () => Zt.Q$M, slice2d: () => Zt.zAd, slice3d: () => Zt.wck, slice4d: () => Zt.R0O, slice_util: () => Mt, softmax: () => Zt.Vs9, softplus: () => Zt.lw0, spaceToBatchND: () => Zt.eDJ, sparse: () => Zt.lMo, sparseToDense: () => Zt.Zhr, spectral: () => Zt.lOn, split: () => Zt.lDo, sqrt: () => Zt.RZD, square: () => Zt.EwI, squaredDifference: () => Zt.Pbu, squeeze: () => Zt.r2V, stack: () => Zt.t$z, step: () => Zt.PMw, stridedSlice: () => Zt.Ym9, string: () => Zt.YjP, sub: () => Zt.jbE, sum: () => Zt.czq, sumOutType: () => Kt.ch, tan: () => Zt.Mlm, tanh: () => Zt.ymU, tensor: () => Zt.OEK, tensor1d: () => Zt.tGX, tensor2d: () => Zt.KtR, tensor3d: () => Zt.$_$, tensor4d: () => Zt.g9W, tensor5d: () => Zt.Lpo, tensor6d: () => Zt.yxw, tensorScatterUpdate: () => Zt.NNh, tensor_util: () => Ft, test_util: () => l, tidy: () => pe.DZ, tile: () => Zt.Vsq, time: () => pe.kB, topk: () => Zt.rfw, train: () => Qt, transpose: () => Zt.mgz, truncatedNormal: () => Zt.efE, unique: () => Zt.AmM, unregisterGradient: () => bt.rY, unregisterKernel: () => bt.iP, unsortedSegmentSum: () => Zt.zAU, unstack: () => Zt.K$i, upcastType: () => Kt.Tu, upperBound: () => Zt.rni, util: () => Dt, valueAndGrad: () => we.jY, valueAndGrads: () => we.mu, variable: () => Zt.bvq, variableGrads: () => we.y7, version_core: () => Yt, where: () => Zt._M9, whereAsync: () => Zt.YJN, zeros: () => Zt.Ul9, zerosLike: () => Zt.POl }); var r = {}; n.r(r), n.d(r, { isBrowser: () => y, isMobile: () => g, mockIsMobile: () => m }); var i = {}; n.r(i), n.d(i, { Serializable: () => Ce, SerializationMap: () => Ae, getRegisteredName: () => Ee, registerClass: () => Te }); var a = {}; n.r(a), n.d(a, { CompositeArrayBuffer: () => A.D, browserFiles: () => He, browserHTTPRequest: () => nt, concatenateArrayBuffers: () => x.AQ, copyModel: () => te, decodeWeights: () => x.CY, decodeWeightsStream: () => x.s5, encodeWeights: () => x.aG, fromMemory: () => ot, fromMemorySync: () => st, getLoadHandlers: () => C, getModelArtifactsForJSON: () => x.Ej, getModelArtifactsForJSONSync: () => x.Rl, getModelArtifactsInfoForJSON: () => x.oR, getSaveHandlers: () => _, getWeightSpecs: () => x.Xf, http: () => tt, isHTTPScheme: () => Qe, listModels: () => Q, loadWeights: () => Ke, moveModel: () => ne, registerLoadRouter: () => S, registerSaveRouter: () => k, removeModel: () => ee, weightsLoaderFactory: () => Ze, withSaveHandler: () => ut, withSaveHandlerSync: () => lt }); var o = {}; n.r(o), n.d(o, { confusionMatrix: () => mt }); var s = {}; n.r(s), n.d(s, { draw: () => Tt, fromPixels: () => Et, fromPixelsAsync: () => _t, toPixels: () => At }); var u = {}; n.r(u), n.d(u, { prepareAndValidate: () => Nt }); var l = {}; n.r(l), n.d(l, { TEST_EPSILON_FLOAT16: () => Rt, createVideoElement: () => Ht, encodeStrings: () => Gt, expectArrayBuffersEqual: () => Vt, expectArraysClose: () => Ot, expectArraysEqual: () => Lt, expectNumbersClose: () => jt, expectPromiseToFail: () => Bt, expectValuesInRange: () => Wt, play: () => qt, testEpsilon: () => zt }); var c = {}; n.r(c), n.d(c, { collectGatherOpShapeInfo: () => ur, computeOutShape: () => sr, segOpComputeOptimalWindowSize: () => or }); var h = {}; n.r(h), n.d(h, { ERF_A1: () => Sn, ERF_A2: () => _n, ERF_A3: () => Cn, ERF_A4: () => An, ERF_A5: () => Tn, ERF_P: () => kn, PARALLELIZE_THRESHOLD: () => fn, RowPartitionType: () => on, SELU_SCALE: () => wn.X, SELU_SCALEALPHA: () => wn.j, applyActivation: () => un.f2, assertAndGetBroadcastShape: () => gt.assertAndGetBroadcastShape, assertAxesAreInnerMostDims: () => nn.WC, assertParamsConsistent: () => rn, assignToTypedArray: () => $n, axesAreInnerMostDims: () => nn.WH, calculateShapes: () => It.calculateShapes, checkEinsumDimSizes: () => Wn, checkPadOnDimRoundingMode: () => sn.s_, combineLocations: () => nn.aF, combineRaggedTensorToTensorShapes: () => ln, complexWithEvenIndex: () => Mn, complexWithOddIndex: () => Fn, computeConv2DInfo: () => sn.uf, computeConv3DInfo: () => sn.p$, computeDefaultPad: () => sn.G8, computeDilation2DInfo: () => sn.YQ, computeOptimalWindowSize: () => pn, computeOutAndReduceShapes: () => nn.lb, computeOutShape: () => an, computePool2DInfo: () => sn.E6, computePool3DInfo: () => sn.l5, convertConv2DDataFormat: () => sn.$Q, decodeEinsumEquation: () => jn, eitherStridesOrDilationsAreOne: () => sn.G0, expandShapeToKeepDim: () => nn.SM, exponent: () => On, exponents: () => Rn, fromStringArrayToUint8: () => cr, fromUint8ToStringArray: () => lr, getAxesPermutation: () => nn.Em, getBroadcastDims: () => gt.getBroadcastDims, getComplexWithIndex: () => Dn, getEinsumComputePath: () => Vn, getEinsumPermutation: () => Un, getFusedBiasGradient: () => un.Do, getFusedDyActivation: () => un.XB, getImageCenter: () => mn, getInnerMostAxes: () => nn.fK, getPermuted: () => yn, getRaggedRank: () => hn, getReductionAxes: () => gt.getReductionAxes, getReshaped: () => gn, getReshapedPermuted: () => bn, getRowPartitionTypesHelper: () => cn, getSliceBeginCoords: () => vn, getSliceSize: () => xn, getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => Yn, getSparseFillEmptyRowsNegativeIndexErrorMessage: () => Xn, getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => Kn, getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => Qn, getSparseReshapeInputOutputMismatchErrorMessage: () => tr, getSparseReshapeInputOutputMultipleErrorMessage: () => er, getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => Zn, getSparseReshapeNegativeOutputDimErrorMessage: () => Jn, getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => ar, getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => nr, getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => rr, getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => ir, getUndoAxesPermutation: () => nn.gx, isIdentityPermutation: () => Gn, log: () => En.R, mergeRealAndImagArrays: () => Nn, prepareAndValidate: () => Nt, prepareSplitSize: () => qn, segment_util: () => c, shouldFuse: () => un.zE, slice_util: () => Mt, splitRealAndImagArrays: () => In, stridesOrDilationsArePositive: () => sn.qk, tupleValuesAreOne: () => sn.Dh, upcastType: () => Kt.Tu, validateDefaultValueShape: () => dn, validateInput: () => It.validateInput, validateUpdateShape: () => It.validateUpdateShape, warn: () => En.i }); var d = {}; n.r(d), n.d(d, { nonMaxSuppressionV3Impl: () => hr.c7, nonMaxSuppressionV4Impl: () => hr.ZS, nonMaxSuppressionV5Impl: () => hr.ut, whereImpl: () => dr.Y }); var f = n(1585); let p; function m(e) { p = e } function g(e) { if (void 0 !== p) return p; if (e || "undefined" != typeof navigator && null != navigator) { if (e || (e = navigator), "ReactNative" === e.product) return !0; const t = e.userAgent || e.vendor || ("undefined" != typeof window ? window.opera : ""); if (!t) { const t = e; return t.userAgentData && t.userAgentData.mobile } return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4)) } return !1 } function y() { return "undefined" != typeof window && null != window.document || "undefined" != typeof WorkerGlobalScope } var b = n(6574); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const v = (0, b._K)(); v.registerFlag("DEBUG", (() => !1), (e => { e && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.") })), v.registerFlag("IS_BROWSER", (() => y())), v.registerFlag("IS_NODE", (() => "undefined" != typeof process && void 0 !== process.versions && void 0 !== process.versions.node)), v.registerFlag("IS_CHROME", (() => "undefined" != typeof navigator && null != navigator && null != navigator.userAgent && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor))), v.registerFlag("IS_SAFARI", (() => "undefined" != typeof navigator && null != navigator && null != navigator.userAgent && /Safari/.test(navigator.userAgent) && /Apple/.test(navigator.vendor))), v.registerFlag("PROD", (() => !1)), v.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", (() => v.getBool("DEBUG"))), v.registerFlag("DEPRECATION_WARNINGS_ENABLED", (() => !0)), v.registerFlag("IS_TEST", (() => !1)), v.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", (() => v.getBool("DEBUG"))), v.registerFlag("WRAP_TO_IMAGEBITMAP", (() => !1)), v.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU", (() => !1)), v.registerFlag("USE_SETTIMEOUTCUSTOM", (() => !1)); var x = n(7084); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class w { constructor() { this.saveRouters = [], this.loadRouters = [] } static getInstance() { return null == w.instance && (w.instance = new w), w.instance } static registerSaveRouter(e) { w.getInstance().saveRouters.push(e) } static registerLoadRouter(e) { w.getInstance().loadRouters.push(e) } static getSaveHandlers(e) { return w.getHandlers(e, "save") } static getLoadHandlers(e, t) { return w.getHandlers(e, "load", t) } static getHandlers(e, t, n) { const r = []; return ("load" === t ? w.getInstance().loadRouters : w.getInstance().saveRouters).forEach((t => { const i = t(e, n); null !== i && r.push(i) })), r } } const k = e => w.registerSaveRouter(e), S = e => w.registerLoadRouter(e), _ = e => w.getSaveHandlers(e), C = (e, t) => w.getLoadHandlers(e, t); var A = n(6734); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const T = "tensorflowjs", E = "models_store", N = "model_info_store"; function I() { if (!(0, b._K)().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); const e = "undefined" == typeof window ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB; if (null == t) throw new Error("The current browser does not appear to support IndexedDB."); return t } function M(e) { const t = e.result; t.createObjectStore(E, { keyPath: "modelPath" }), t.createObjectStore(N, { keyPath: "modelPath" }) } class F { constructor(e) { if (this.indexedDB = I(), null == e || !e) throw new Error("For IndexedDB, modelPath must not be null, undefined or empty."); this.modelPath = e } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); return this.databaseAction(this.modelPath, e) } async load() { return this.databaseAction(this.modelPath) } databaseAction(e, t) { return new Promise(((e, n) => { const r = this.indexedDB.open(T, 1); r.onupgradeneeded = () => M(r), r.onsuccess = () => { const i = r.result; if (null == t) { const t = i.transaction(E, "readonly"), r = t.objectStore(E).get(this.modelPath); r.onsuccess = () => { if (null == r.result) return i.close(), n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`)); e(r.result.modelArtifacts) }, r.onerror = e => (i.close(), n(r.error)), t.oncomplete = () => i.close() } else { t.weightData = A.D.join(t.weightData); const r = (0, x.oR)(t), a = i.transaction(N, "readwrite"); let o, s, u = a.objectStore(N); try { o = u.put({ modelPath: this.modelPath, modelArtifactsInfo: r }) } catch (e) { return n(e) } o.onsuccess = () => { s = i.transaction(E, "readwrite"); const o = s.objectStore(E); let l; try { l = o.put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: r }) } catch (e) { return n(e) } l.onsuccess = () => e({ modelArtifactsInfo: r }), l.onerror = e => { u = a.objectStore(N); const t = u.delete(this.modelPath); t.onsuccess = () => (i.close(), n(l.error)), t.onerror = e => (i.close(), n(l.error)) } }, o.onerror = e => (i.close(), n(o.error)), a.oncomplete = () => { null == s ? i.close() : s.oncomplete = () => i.close() } } }, r.onerror = e => n(r.error) })) } } F.URL_SCHEME = "indexeddb://"; const D = e => { return (0, b._K)().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(F.URL_SCHEME) ? (t = e.slice(F.URL_SCHEME.length), new F(t)) : null; var t }; w.registerSaveRouter(D), w.registerLoadRouter(D); class $ { constructor() { this.indexedDB = I() } async listModels() { return new Promise(((e, t) => { const n = this.indexedDB.open(T, 1); n.onupgradeneeded = () => M(n), n.onsuccess = () => { const r = n.result, i = r.transaction(N, "readonly"), a = i.objectStore(N).getAll(); a.onsuccess = () => { const t = {}; for (const e of a.result) t[e.modelPath] = e.modelArtifactsInfo; e(t) }, a.onerror = e => (r.close(), t(a.error)), i.oncomplete = () => r.close() }, n.onerror = e => t(n.error) })) } async removeModel(e) { var t; return e = (t = e).startsWith(F.URL_SCHEME) ? t.slice(F.URL_SCHEME.length) : t, new Promise(((t, n) => { const r = this.indexedDB.open(T, 1); r.onupgradeneeded = () => M(r), r.onsuccess = () => { const i = r.result, a = i.transaction(N, "readwrite"), o = a.objectStore(N), s = o.get(e); let u; s.onsuccess = () => { if (null == s.result) return i.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { const r = o.delete(e), a = () => { u = i.transaction(E, "readwrite"); const r = u.objectStore(E).delete(e); r.onsuccess = () => t(s.result.modelArtifactsInfo), r.onerror = e => n(s.error) }; r.onsuccess = a, r.onerror = e => (a(), i.close(), n(s.error)) } }, s.onerror = e => (i.close(), n(s.error)), a.oncomplete = () => { null == u ? i.close() : u.oncomplete = () => i.close() } }, r.onerror = e => n(r.error) })) } } var R = n(5119); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const O = "/", z = "tensorflowjs_models", P = "info", B = "model_topology", L = "weight_specs", j = "weight_data", U = "model_metadata"; function W(e) { return { info: [z, e, P].join(O), topology: [z, e, B].join(O), weightSpecs: [z, e, L].join(O), weightData: [z, e, j].join(O), modelMetadata: [z, e, U].join(O) } } function V(e) { for (const t of Object.values(e)) window.localStorage.removeItem(t) } function G(e) { const t = e.split(O); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); return t.slice(1, t.length - 1).join(O) } class H { constructor(e) { if (!(0, b._K)().getBool("IS_BROWSER") || "undefined" == typeof window || void 0 === window.localStorage) throw new Error("The current environment does not support local storage."); if (this.LS = window.localStorage, null == e || !e) throw new Error("For local storage, modelPath must not be null, undefined or empty."); this.modelPath = e, this.keys = W(this.modelPath) } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); { const t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), r = (0, x.oR)(e), i = A.D.join(e.weightData); try { this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, (0, x.l3)(i)); const a = { format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, signature: null != e.signature ? e.signature : void 0, userDefinedMetadata: null != e.userDefinedMetadata ? e.userDefinedMetadata : void 0, modelInitializer: null != e.modelInitializer ? e.modelInitializer : void 0, initializerSignature: null != e.initializerSignature ? e.initializerSignature : void 0, trainingConfig: null != e.trainingConfig ? e.trainingConfig : void 0 }; return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(a)), { modelArtifactsInfo: r } } catch (e) { throw V(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`) } } } async load() { const e = JSON.parse(this.LS.getItem(this.keys.info)); if (null == e) throw new Error(`In local storage, there is no model with name '${this.modelPath}'`); if ("JSON" !== e.modelTopologyType) throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet."); const t = {}, n = JSON.parse(this.LS.getItem(this.keys.topology)); if (null == n) throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`); t.modelTopology = n; const r = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); if (null == r) throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`); t.weightSpecs = r; const i = this.LS.getItem(this.keys.modelMetadata); if (null != i) { const e = JSON.parse(i); t.format = e.format, t.generatedBy = e.generatedBy, t.convertedBy = e.convertedBy, null != e.signature && (t.signature = e.signature), null != e.userDefinedMetadata && (t.userDefinedMetadata = e.userDefinedMetadata), null != e.modelInitializer && (t.modelInitializer = e.modelInitializer), null != e.initializerSignature && (t.initializerSignature = e.initializerSignature), null != e.trainingConfig && (t.trainingConfig = e.trainingConfig) } const a = this.LS.getItem(this.keys.weightData); if (null == a) throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`); return t.weightData = (0, x.jf)(a), t } } H.URL_SCHEME = "localstorage://"; const q = e => { return (0, b._K)().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(H.URL_SCHEME) ? (t = e.slice(H.URL_SCHEME.length), new H(t)) : null; var t }; w.registerSaveRouter(q), w.registerLoadRouter(q); class Y { constructor() { (0, R.vA)((0, b._K)().getBool("IS_BROWSER"), (() => "Current environment is not a web browser")), (0, R.vA)("undefined" == typeof window || void 0 !== window.localStorage, (() => "Current browser does not appear to support localStorage")), this.LS = window.localStorage } async listModels() { const e = {}, t = z + O, n = O + P; for (let r = 0; r < this.LS.length; ++r) { const i = this.LS.key(r); if (i.startsWith(t) && i.endsWith(n)) { e[G(i)] = JSON.parse(this.LS.getItem(i)) } } return e } async removeModel(e) { var t; const n = W(e = (t = e).startsWith(H.URL_SCHEME) ? t.slice(H.URL_SCHEME.length) : t); if (null == this.LS.getItem(n.info)) throw new Error(`Cannot find model at path '${e}'`); const r = JSON.parse(this.LS.getItem(n.info)); return V(n), r } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const X = "://"; class K { constructor() { this.managers = {} } static getInstance() { return null == K.instance && (K.instance = new K), K.instance } static registerManager(e, t) { (0, R.vA)(null != e, (() => "scheme must not be undefined or null.")), e.endsWith(X) && (e = e.slice(0, e.indexOf(X))), (0, R.vA)(e.length > 0, (() => "scheme must not be an empty string.")); const n = K.getInstance(); (0, R.vA)(null == n.managers[e], (() => `A model store manager is already registered for scheme '${e}'.`)), n.managers[e] = t } static getManager(e) { const t = K.getInstance().managers[e]; if (null == t) throw new Error(`Cannot find model manager for scheme '${e}'`); return t } static getSchemes() { return Object.keys(K.getInstance().managers) } } function Z(e) { if (-1 === e.indexOf(X)) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${K.getSchemes().join(",")}`); return { scheme: e.split(X)[0], path: e.split(X)[1] } } async function J(e, t, n = !1) { (0, R.vA)(e !== t, (() => `Old path and new path are the same: '${e}'`)); const r = w.getLoadHandlers(e); (0, R.vA)(r.length > 0, (() => `Copying failed because no load handler is found for source URL ${e}.`)), (0, R.vA)(r.length < 2, (() => `Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`)); const i = r[0], a = w.getSaveHandlers(t); (0, R.vA)(a.length > 0, (() => `Copying failed because no save handler is found for destination URL ${t}.`)), (0, R.vA)(a.length < 2, (() => `Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`)); const o = a[0], s = Z(e).scheme, u = Z(e).path, l = s === Z(e).scheme, c = await i.load(); n && l && await K.getManager(s).removeModel(u); const h = await o.save(c); return n && !l && await K.getManager(s).removeModel(u), h.modelArtifactsInfo } async function Q() { const e = K.getSchemes(), t = {}; for (const n of e) { const e = await K.getManager(n).listModels(); for (const r in e) { t[n + X + r] = e[r] } } return t } async function ee(e) { const t = Z(e); return K.getManager(t.scheme).removeModel(t.path) } async function te(e, t) { return J(e, t, !1) } async function ne(e, t) { return J(e, t, !0) } var re = n(6448); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ie { constructor() { this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = !1 } fetch(e, t) { return fetch(e, t) } now() { return performance.now() } encode(e, t) { if ("utf-8" !== t && "utf8" !== t) throw new Error(`Browser's encoder only supports utf-8, but got ${t}`); return null == this.textEncoder && (this.textEncoder = new TextEncoder), this.textEncoder.encode(e) } decode(e, t) { return new TextDecoder(t).decode(e) } setTimeoutCustom(e, t) { "undefined" != typeof window && (0, b._K)().getBool("USE_SETTIMEOUTCUSTOM") ? (this.functionRefs.push(e), setTimeout((() => { window.postMessage({ name: this.messageName, index: this.functionRefs.length - 1 }, "*") }), t), this.hasEventListener || (this.hasEventListener = !0, window.addEventListener("message", (e => { if (e.source === window && e.data.name === this.messageName) { e.stopPropagation(); (0, this.functionRefs[e.data.index])(), this.handledMessageCount++, this.handledMessageCount === this.functionRefs.length && (this.functionRefs = [], this.handledMessageCount = 0) } }), !0))) : setTimeout(e, t) } isTypedArray(e) { return (0, re.Y)(e) } } if ((0, b._K)().get("IS_BROWSER")) { (0, b._K)().setPlatform("browser", new ie); try { K.registerManager(H.URL_SCHEME, new Y) } catch (e) { } try { K.registerManager(F.URL_SCHEME, new $) } catch (e) { } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const ae = () => n(5817); let oe; class se { constructor() { this.util = n(8590), this.textEncoder = new this.util.TextEncoder } fetch(e, t) { return null != (0, b._K)().global.fetch ? (0, b._K)().global.fetch(e, t) : (null == oe && (oe = ae()), oe(e, t)) } now() { const e = process.hrtime(); return 1e3 * e[0] + e[1] / 1e6 } encode(e, t) { if ("utf-8" !== t && "utf8" !== t) throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`); return this.textEncoder.encode(e) } decode(e, t) { return 0 === e.length ? "" : new this.util.TextDecoder(t).decode(e) } isTypedArray(e) { return this.util.types.isFloat32Array(e) || this.util.types.isInt32Array(e) || this.util.types.isUint8Array(e) || this.util.types.isUint8ClampedArray(e) } } (0, b._K)().get("IS_NODE") && !(0, b._K)().get("IS_BROWSER") && (0, b._K)().setPlatform("node", new se); var ue = n(448), le = n(9809), ce = n(125), he = n(5295), de = n(259); + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, f.Ye)(); const fe = { buffer: ue.r, cast: le.w, clone: ce.o, print: he.y }; (0, de.Q5)(fe); var pe = n(5287), me = n(7523), ge = n(9359), ye = n(9258), be = n(9348), ve = n(5793), xe = n(5537), we = n(1830), ke = n(5702); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Se = new Map, _e = new Map; class Ce { getClassName() { return this.constructor.className } static fromConfig(e, t) { return new e(t) } } class Ae { constructor() { this.classNameMap = {} } static getMap() { return null == Ae.instance && (Ae.instance = new Ae), Ae.instance } static register(e) { Ae.getMap().classNameMap[e.className] = [e, e.fromConfig] } } function Te(e, t, n) { (0, R.vA)(null != e.className, (() => "Class being registered does not have the static className property defined.")), (0, R.vA)("string" == typeof e.className, (() => "className is required to be a string, but got type " + typeof e.className)), (0, R.vA)(e.className.length > 0, (() => "Class being registered has an empty-string as its className, which is disallowed.")), void 0 === t && (t = "Custom"), void 0 === n && (n = e.className); const r = t + ">" + n; return Ae.register(e), Se.set(r, e), _e.set(e, r), e } function Ee(e) { return _e.has(e) ? _e.get(e) : e.className } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Ne extends Ce { minimize(e, t = !1, n) { const { value: r, grads: i } = this.computeGradients(e, n); if (null != n) { const e = n.map((e => ({ name: e.name, tensor: i[e.name] }))); this.applyGradients(e) } else this.applyGradients(i); return (0, pe.AS)(i), t ? r : (r.dispose(), null) } get iterations() { return null == this.iterations_ && (this.iterations_ = 0), this.iterations_ } incrementIterations() { this.iterations_ = this.iterations + 1 } computeGradients(e, t) { return (0, we.y7)(e, t) } dispose() { null != this.iterations_ && (0, pe.AS)(this.iterations_) } async saveIterations() { return null == this.iterations_ && (this.iterations_ = 0), { name: "iter", tensor: (0, ke.d)(this.iterations_, "int32") } } async getWeights() { throw new Error("getWeights() is not implemented for this optimizer yet.") } async setWeights(e) { throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`) } async extractIterations(e) { return this.iterations_ = (await e[0].tensor.data())[0], e.slice(1) } } Object.defineProperty(Ne, Symbol.hasInstance, { value: e => null != e.minimize && null != e.computeGradients && null != e.applyGradients }); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Ie extends Ne { static get className() { return "Adadelta" } constructor(e, t, n = null) { super(), this.learningRate = e, this.rho = t, this.epsilon = n, this.accumulatedGrads = [], this.accumulatedUpdates = [], null == n && (this.epsilon = f.T2.backend.epsilon()) } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t], i = !1; null == this.accumulatedGrads[n] && (this.accumulatedGrads[n] = { originalName: `${t}/accum_grad`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }), null == this.accumulatedUpdates[n] && (this.accumulatedUpdates[n] = { originalName: `${t}/accum_var`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }); const a = Array.isArray(e) ? e[n].tensor : e[t]; if (null == a) return; const o = this.accumulatedGrads[n].variable, s = this.accumulatedUpdates[n].variable; (0, pe.DZ)((() => { const e = (0, me.W)((0, ye.l)(o, this.rho), (0, ye.l)((0, ve.E)(a), 1 - this.rho)), t = (0, ye.l)((0, ge.y)((0, be.R)((0, me.W)(s, this.epsilon)), (0, be.R)((0, me.W)(o, this.epsilon))), a), n = (0, me.W)((0, ye.l)(s, this.rho), (0, ye.l)((0, ve.E)(t), 1 - this.rho)); o.assign(e), s.assign(n); const i = (0, me.W)((0, ye.l)(t, -this.learningRate), r); r.assign(i) })) })), this.incrementIterations() } dispose() { null != this.accumulatedUpdates && ((0, pe.AS)(this.accumulatedGrads.map((e => e.variable))), (0, pe.AS)(this.accumulatedUpdates.map((e => e.variable)))) } async getWeights() { const e = [...this.accumulatedGrads, ...this.accumulatedUpdates]; return [await this.saveIterations()].concat(e.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { const t = (e = await this.extractIterations(e)).length / 2, n = !1; this.accumulatedGrads = e.slice(0, t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.accumulatedUpdates = e.slice(t, 2 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))) } getConfig() { return { learningRate: this.learningRate, rho: this.rho, epsilon: this.epsilon } } static fromConfig(e, t) { return new e(t.learningRate, t.rho, t.epsilon) } } var Me = n(6111); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Fe extends Ne { static get className() { return "Adagrad" } constructor(e, t = .1) { super(), this.learningRate = e, this.initialAccumulatorValue = t, this.accumulatedGrads = [] } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t]; if (null == this.accumulatedGrads[n]) { const e = !1; this.accumulatedGrads[n] = { originalName: `${t}/accumulator`, variable: (0, pe.DZ)((() => (0, Me.G)(r.shape, this.initialAccumulatorValue).variable(e))) } } const i = Array.isArray(e) ? e[n].tensor : e[t]; if (null == i) return; const a = this.accumulatedGrads[n].variable; (0, pe.DZ)((() => { const e = (0, me.W)(a, (0, ve.E)(i)); a.assign(e); const t = (0, me.W)((0, ye.l)((0, ge.y)(i, (0, be.R)((0, me.W)(e, f.T2.backend.epsilon()))), -this.learningRate), r); r.assign(t) })) })), this.incrementIterations() } dispose() { null != this.accumulatedGrads && (0, pe.AS)(this.accumulatedGrads.map((e => e.variable))) } async getWeights() { return [await this.saveIterations()].concat(this.accumulatedGrads.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e); this.accumulatedGrads = e.map((e => ({ originalName: e.name, variable: e.tensor.variable(false) }))) } getConfig() { return { learningRate: this.learningRate, initialAccumulatorValue: this.initialAccumulatorValue } } static fromConfig(e, t) { return new e(t.learningRate, t.initialAccumulatorValue) } } var De = n(8990), $e = n(7126); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Re extends Ne { static get className() { return "Adam" } constructor(e, t, n, r = null) { super(), this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], (0, pe.DZ)((() => { this.accBeta1 = (0, ke.d)(t).variable(), this.accBeta2 = (0, ke.d)(n).variable() })), null == r && (this.epsilon = f.T2.backend.epsilon()) } applyGradients(e) { const t = Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e); (0, pe.DZ)((() => { const n = (0, $e.j)(1, this.accBeta1), r = (0, $e.j)(1, this.accBeta2); t.forEach(((t, i) => { const a = f.T2.registeredVariables[t], o = !1; null == this.accumulatedFirstMoment[i] && (this.accumulatedFirstMoment[i] = { originalName: `${t}/m`, variable: (0, pe.DZ)((() => (0, xe.P)(a).variable(o))) }), null == this.accumulatedSecondMoment[i] && (this.accumulatedSecondMoment[i] = { originalName: `${t}/v`, variable: (0, pe.DZ)((() => (0, xe.P)(a).variable(o))) }); const s = Array.isArray(e) ? e[i].tensor : e[t]; if (null == s) return; const u = this.accumulatedFirstMoment[i].variable, l = this.accumulatedSecondMoment[i].variable, c = (0, me.W)((0, ye.l)(u, this.beta1), (0, ye.l)(s, 1 - this.beta1)), h = (0, me.W)((0, ye.l)(l, this.beta2), (0, ye.l)((0, ve.E)(s), 1 - this.beta2)), d = (0, ge.y)(c, n), p = (0, ge.y)(h, r); u.assign(c), l.assign(h); const m = (0, me.W)((0, ye.l)((0, ge.y)(d, (0, me.W)((0, be.R)(p), this.epsilon)), -this.learningRate), a); a.assign(m) })), this.accBeta1.assign((0, ye.l)(this.accBeta1, this.beta1)), this.accBeta2.assign((0, ye.l)(this.accBeta2, this.beta2)) })), this.incrementIterations() } dispose() { this.accBeta1.dispose(), this.accBeta2.dispose(), null != this.accumulatedFirstMoment && (0, pe.AS)(this.accumulatedFirstMoment.map((e => e.variable))), null != this.accumulatedSecondMoment && (0, pe.AS)(this.accumulatedSecondMoment.map((e => e.variable))) } async getWeights() { const e = [...this.accumulatedFirstMoment, ...this.accumulatedSecondMoment]; return [await this.saveIterations()].concat(e.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e), (0, pe.DZ)((() => { this.accBeta1.assign((0, De.n)(this.beta1, this.iterations_ + 1)), this.accBeta2.assign((0, De.n)(this.beta2, this.iterations_ + 1)) })); const t = e.length / 2, n = !1; this.accumulatedFirstMoment = e.slice(0, t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.accumulatedSecondMoment = e.slice(t, 2 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))) } getConfig() { return { learningRate: this.learningRate, beta1: this.beta1, beta2: this.beta2, epsilon: this.epsilon } } static fromConfig(e, t) { return new e(t.learningRate, t.beta1, t.beta2, t.epsilon) } } var Oe = n(4888), ze = n(178); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Pe extends Ne { static get className() { return "Adamax" } constructor(e, t, n, r = null, i = 0) { super(), this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = r, this.decay = i, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], (0, pe.DZ)((() => { this.iteration = (0, ke.d)(0).variable(), this.accBeta1 = (0, ke.d)(t).variable() })), null == r && (this.epsilon = f.T2.backend.epsilon()) } applyGradients(e) { const t = Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e); (0, pe.DZ)((() => { const n = (0, $e.j)(1, this.accBeta1), r = (0, ge.y)(-this.learningRate, (0, me.W)((0, ye.l)(this.iteration, this.decay), 1)); t.forEach(((t, i) => { const a = f.T2.registeredVariables[t], o = !1; null == this.accumulatedFirstMoment[i] && (this.accumulatedFirstMoment[i] = { originalName: `${t}/m`, variable: (0, xe.P)(a).variable(o) }), null == this.accumulatedWeightedInfNorm[i] && (this.accumulatedWeightedInfNorm[i] = { originalName: `${t}/v`, variable: (0, xe.P)(a).variable(o) }); const s = Array.isArray(e) ? e[i].tensor : e[t]; if (null == s) return; const u = this.accumulatedFirstMoment[i].variable, l = this.accumulatedWeightedInfNorm[i].variable, c = (0, me.W)((0, ye.l)(u, this.beta1), (0, ye.l)(s, 1 - this.beta1)), h = (0, ye.l)(l, this.beta2), d = (0, Oe.t)(s), p = (0, ze.P)(h, d); u.assign(c), l.assign(p); const m = (0, me.W)((0, ye.l)((0, ge.y)(r, n), (0, ge.y)(c, (0, me.W)(p, this.epsilon))), a); a.assign(m) })), this.iteration.assign((0, me.W)(this.iteration, 1)), this.accBeta1.assign((0, ye.l)(this.accBeta1, this.beta1)) })), this.incrementIterations() } dispose() { this.accBeta1.dispose(), this.iteration.dispose(), null != this.accumulatedFirstMoment && (0, pe.AS)(this.accumulatedFirstMoment.map((e => e.variable))), null != this.accumulatedWeightedInfNorm && (0, pe.AS)(this.accumulatedWeightedInfNorm.map((e => e.variable))) } async getWeights() { throw new Error("getWeights() is not implemented for Adamax yet.") } async setWeights(e) { throw new Error("setWeights() is not implemented for Adamax yet.") } getConfig() { return { learningRate: this.learningRate, beta1: this.beta1, beta2: this.beta2, epsilon: this.epsilon, decay: this.decay } } static fromConfig(e, t) { return new e(t.learningRate, t.beta1, t.beta2, t.epsilon, t.decay) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Be extends Ne { static get className() { return "SGD" } constructor(e) { super(), this.learningRate = e, this.setLearningRate(e) } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = Array.isArray(e) ? e[n].tensor : e[t]; if (null == r) return; const i = f.T2.registeredVariables[t]; (0, pe.DZ)((() => { const e = (0, me.W)((0, ye.l)(this.c, r), i); i.assign(e) })) })), this.incrementIterations() } setLearningRate(e) { this.learningRate = e, null != this.c && this.c.dispose(), this.c = (0, pe.aC)((0, ke.d)(-e)) } dispose() { this.c.dispose() } async getWeights() { return [await this.saveIterations()] } async setWeights(e) { if (0 !== (e = await this.extractIterations(e)).length) throw new Error("SGD optimizer does not have settable weights.") } getConfig() { return { learningRate: this.learningRate } } static fromConfig(e, t) { return new e(t.learningRate) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Le extends Be { static get className() { return "Momentum" } constructor(e, t, n = !1) { super(e), this.learningRate = e, this.momentum = t, this.useNesterov = n, this.accumulations = [], this.m = (0, ke.d)(this.momentum) } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t]; if (null == this.accumulations[n]) { const e = !1; this.accumulations[n] = { originalName: `${t}/momentum`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(e))) } } const i = this.accumulations[n].variable, a = Array.isArray(e) ? e[n].tensor : e[t]; null != a && (0, pe.DZ)((() => { let e; const t = (0, me.W)((0, ye.l)(this.m, i), a); e = this.useNesterov ? (0, me.W)((0, ye.l)(this.c, (0, me.W)(a, (0, ye.l)(t, this.m))), r) : (0, me.W)((0, ye.l)(this.c, t), r), i.assign(t), r.assign(e) })) })), this.incrementIterations() } dispose() { this.m.dispose(), null != this.accumulations && (0, pe.AS)(this.accumulations.map((e => e.variable))) } setMomentum(e) { this.momentum = e } async getWeights() { return [await this.saveIterations()].concat(this.accumulations.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e); this.accumulations = e.map((e => ({ originalName: e.name, variable: e.tensor.variable(false) }))) } getConfig() { return { learningRate: this.learningRate, momentum: this.momentum, useNesterov: this.useNesterov } } static fromConfig(e, t) { return new e(t.learningRate, t.momentum, t.useNesterov) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class je extends Ne { static get className() { return "RMSProp" } constructor(e, t = .9, n = 0, r = null, i = !1) { if (super(), this.learningRate = e, this.decay = t, this.momentum = n, this.epsilon = r, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = i, null == r && (this.epsilon = f.T2.backend.epsilon()), null == e) throw new Error("learningRate for RMSPropOptimizer must be defined.") } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t], i = !1; null == this.accumulatedMeanSquares[n] && (this.accumulatedMeanSquares[n] = { originalName: `${t}/rms`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }), null == this.accumulatedMoments[n] && (this.accumulatedMoments[n] = { originalName: `${t}/momentum`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }), null == this.accumulatedMeanGrads[n] && this.centered && (this.accumulatedMeanGrads[n] = { originalName: `${t}/mg`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }); const a = Array.isArray(e) ? e[n].tensor : e[t]; if (null == a) return; const o = this.accumulatedMeanSquares[n].variable, s = this.accumulatedMoments[n].variable; (0, pe.DZ)((() => { const e = (0, me.W)((0, ye.l)(o, this.decay), (0, ye.l)((0, ve.E)(a), 1 - this.decay)); if (this.centered) { const t = this.accumulatedMeanGrads[n].variable, i = (0, me.W)((0, ye.l)(t, this.decay), (0, ye.l)(a, 1 - this.decay)), u = (0, ge.y)((0, ye.l)(a, this.learningRate), (0, be.R)((0, $e.j)(e, (0, me.W)((0, ve.E)(i), this.epsilon)))), l = (0, me.W)((0, ye.l)(s, this.momentum), u); o.assign(e), t.assign(i), s.assign(l); const c = (0, $e.j)(r, l); r.assign(c) } else { const e = (0, me.W)((0, ye.l)(o, this.decay), (0, ye.l)((0, ve.E)(a), 1 - this.decay)), t = (0, me.W)((0, ye.l)(s, this.momentum), (0, ge.y)((0, ye.l)(a, this.learningRate), (0, be.R)((0, me.W)(e, this.epsilon)))); o.assign(e), s.assign(t); const n = (0, $e.j)(r, t); r.assign(n) } })) })), this.incrementIterations() } dispose() { null != this.accumulatedMeanSquares && (0, pe.AS)(this.accumulatedMeanSquares.map((e => e.variable))), null != this.accumulatedMeanGrads && this.centered && (0, pe.AS)(this.accumulatedMeanGrads.map((e => e.variable))), null != this.accumulatedMoments && (0, pe.AS)(this.accumulatedMoments.map((e => e.variable))) } async getWeights() { const e = [...this.accumulatedMeanSquares, ...this.accumulatedMoments]; return this.centered && e.push(...this.accumulatedMeanGrads), [await this.saveIterations()].concat(e.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e); const t = this.centered ? e.length / 3 : e.length / 2, n = !1; this.accumulatedMeanSquares = e.slice(0, t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.accumulatedMoments = e.slice(t, 2 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.centered && (this.accumulatedMeanGrads = e.slice(2 * t, 3 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) })))) } getConfig() { return { learningRate: this.learningRate, decay: this.decay, momentum: this.momentum, epsilon: this.epsilon, centered: this.centered } } static fromConfig(e, t) { return new e(t.learningRate, t.decay, t.momentum, t.epsilon, t.centered) } } + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ue = [Ie, Fe, Re, Pe, Le, je, Be]; function We(e) { return new Promise((e => setTimeout(e))).then(e) } class Ve { constructor(e) { if (!(0, b._K)().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(Ve.URL_SCHEME) && (e = e.slice(Ve.URL_SCHEME.length)), null != e && 0 !== e.length || (e = "model"), this.modelJsonFileName = e + ".json", this.weightDataFileName = e + ".weights.bin" } async save(e) { if ("undefined" == typeof document) throw new Error("Browser downloads are not supported in this environment since `document` is not present"); const t = A.D.join(e.weightData), n = window.URL.createObjectURL(new Blob([t], { type: "application/octet-stream" })); if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet."); { const t = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], r = (0, x.zV)(e, t), i = window.URL.createObjectURL(new Blob([JSON.stringify(r)], { type: "application/json" })), a = null == this.modelJsonAnchor ? document.createElement("a") : this.modelJsonAnchor; if (a.download = this.modelJsonFileName, a.href = i, await We((() => a.dispatchEvent(new MouseEvent("click")))), null != e.weightData) { const e = null == this.weightDataAnchor ? document.createElement("a") : this.weightDataAnchor; e.download = this.weightDataFileName, e.href = n, await We((() => e.dispatchEvent(new MouseEvent("click")))) } return { modelArtifactsInfo: (0, x.oR)(e) } } } } Ve.URL_SCHEME = "downloads://"; class Ge { constructor(e) { if (null == e || e.length < 1) throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`); this.jsonFile = e[0], this.weightsFiles = e.slice(1) } async load() { return new Promise(((e, t) => { const n = new FileReader; n.onload = n => { const r = JSON.parse(n.target.result), i = r.modelTopology; if (null == i) return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); if (null == r.weightsManifest) return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`)); if (0 === this.weightsFiles.length) return void e({ modelTopology: i }); const a = (0, x.Ej)(r, (e => this.loadWeights(e))); e(a) }, n.onerror = e => t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), n.readAsText(this.jsonFile) })) } loadWeights(e) { const t = [], n = []; for (const r of e) t.push(...r.weights), n.push(...r.paths); const r = this.checkManifestAndWeightFiles(e), i = n.map((e => this.loadWeightsFile(e, r[e]))); return Promise.all(i).then((e => [t, e])) } loadWeightsFile(e, t) { return new Promise(((n, r) => { const i = new FileReader; i.onload = e => { const t = e.target.result; n(t) }, i.onerror = t => r(`Failed to weights data from file of path '${e}'.`), i.readAsArrayBuffer(t) })) } checkManifestAndWeightFiles(e) { const t = [], n = this.weightsFiles.map((e => (0, x.P8)(e.name))), r = {}; for (const i of e) i.paths.forEach((e => { const i = (0, x.P8)(e); if (-1 !== t.indexOf(i)) throw new Error(`Duplicate file basename found in weights manifest: '${i}'`); if (t.push(i), -1 === n.indexOf(i)) throw new Error(`Weight file with basename '${i}' is not provided.`); r[e] = this.weightsFiles[n.indexOf(i)] })); if (t.length !== this.weightsFiles.length) throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`); return r } } function He(e) { return new Ge(e) } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function qe(e, t, n, r) { !function (e) { (0, R.vA)(null != e && Array.isArray(e) && e.length > 0, (() => "promises must be a none empty array")) }(e), function (e, t) { (0, R.vA)(e >= 0 && e <= 1, (() => `Progress fraction must be in range [0, 1], but got startFraction ${e}`)), (0, R.vA)(t >= 0 && t <= 1, (() => `Progress fraction must be in range [0, 1], but got endFraction ${t}`)), (0, R.vA)(t >= e, (() => `startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`)) }(n = null == n ? 0 : n, r = null == r ? 1 : r); let i = 0; return Promise.all(e.map((a => (a.then((a => { const o = n + ++i / e.length * (r - n); return t(o), a })), a)))) } w.registerSaveRouter((e => (0, b._K)().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(Ve.URL_SCHEME) ? function (e = "model") { return new Ve(e) }(e.slice(Ve.URL_SCHEME.length)) : null)); var Ye = n(5685); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function Xe(e, t) { null == t && (t = {}); const n = null == t.fetchFunc ? (0, b._K)().platform.fetch : t.fetchFunc, r = e.map((e => n(e, t.requestInit, { isBinary: !0 }))), i = (null == t.onProgress ? await Promise.all(r) : await qe(r, t.onProgress, 0, .5)).map((e => e.arrayBuffer())); return null == t.onProgress ? await Promise.all(i) : await qe(i, t.onProgress, .5, 1) } async function Ke(e, t = "", n, r) { return Ze((e => Xe(e, { requestInit: r })))(e, t, n) } function Ze(e) { return async (t, n = "", r) => { const i = t.map((() => !1)), a = {}, o = null != r ? r.map((() => !1)) : [], s = []; if (t.forEach(((e, t) => { let n = 0; e.weights.forEach((e => { const u = "quantization" in e ? e.quantization.dtype : e.dtype, l = Ye.i[u] * R.Ze(e.shape), c = () => { i[t] = !0, null == a[t] && (a[t] = []), a[t].push({ manifestEntry: e, groupOffset: n, sizeBytes: l }) }; null != r ? r.forEach(((t, n) => { t === e.name && (c(), o[n] = !0) })) : c(), s.push(e.name), n += l })) })), !o.every((e => e))) { const e = r.filter(((e, t) => !o[t])); throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${s.join(", ")}.`) } const u = i.reduce(((e, t, n) => (t && e.push(n), e)), []), l = []; u.forEach((e => { t[e].paths.forEach((e => { const t = n + (n.endsWith("/") ? "" : "/") + e; l.push(t) })) })); const c = await e(l), h = {}; let d = 0; return u.forEach((e => { const n = t[e].paths.length, r = new A.D(c.slice(d, d + n)); a[e].forEach((e => { const t = r.slice(e.groupOffset, e.groupOffset + e.sizeBytes), n = (0, x.CY)(t, [e.manifestEntry]); for (const e in n) h[e] = n[e] })), d += n })), h } } class Je { constructor(e, t) { if (this.DEFAULT_METHOD = "POST", null == t && (t = {}), this.weightPathPrefix = t.weightPathPrefix, this.weightUrlConverter = t.weightUrlConverter, null != t.fetchFunc ? ((0, R.vA)("function" == typeof t.fetchFunc, (() => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)")), this.fetch = t.fetchFunc) : this.fetch = (0, b._K)().platform.fetch, (0, R.vA)(null != e && e.length > 0, (() => "URL path for http must not be null, undefined or empty.")), Array.isArray(e) && (0, R.vA)(2 === e.length, (() => `URL paths for http must have a length of 2, (actual length is ${e.length}).`)), this.path = e, null != t.requestInit && null != t.requestInit.body) throw new Error("requestInit is expected to have no pre-existing body, but has one."); this.requestInit = t.requestInit || {}, this.loadOptions = t } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); const t = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit); t.body = new FormData; const n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], r = (0, x.zV)(e, n); if (t.body.append("model.json", new Blob([JSON.stringify(r)], { type: "application/json" }), "model.json"), null != e.weightData) { const n = A.D.join(e.weightData); t.body.append("model.weights.bin", new Blob([n], { type: "application/octet-stream" }), "model.weights.bin") } const i = await this.fetch(this.path, t); if (i.ok) return { modelArtifactsInfo: (0, x.oR)(e), responses: [i] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${i.status}.`) } async loadModelJSON() { const e = await this.fetch(this.path, this.requestInit); if (!e.ok) throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`); let t; try { t = await e.json() } catch (e) { let t = `Failed to parse model JSON of response from ${this.path}.`; throw this.path.endsWith(".pb") ? t += " Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository." : t += " Please make sure the server is serving valid JSON for this request.", new Error(t) } const n = t.modelTopology, r = t.weightsManifest; if (null == n && null == r) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); return t } async load() { if (this.loadOptions.streamWeights) return this.loadStream(); const e = await this.loadModelJSON(); return (0, x.Ej)(e, (e => this.loadWeights(e))) } async loadStream() { const e = await this.loadModelJSON(), t = await this.getWeightUrls(e.weightsManifest), n = (0, x.Xf)(e.weightsManifest); return Object.assign(Object.assign({}, e), { weightSpecs: n, getWeightStream: () => function (e, t) { var n; const r = null == t.fetchFunc ? (0, b._K)().platform.fetch : t.fetchFunc; let i, a = 0; return null === (n = t.onProgress) || void 0 === n || n.call(t, 0), new ReadableStream({ pull: async n => { for (var o; a < e.length;) { if (!i) { const n = (await r(e[a], t.requestInit, { isBinary: !0 })).body; i = n.getReader() } const { done: s, value: u } = await i.read(); if (!s) return void n.enqueue(u); a++, i = void 0, null === (o = t.onProgress) || void 0 === o || o.call(t, a / e.length) } n.close() } }) }(t, this.loadOptions) }) } async getWeightUrls(e) { const t = Array.isArray(this.path) ? this.path[1] : this.path, [n, r] = function (e) { const t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), r = e.substring(0, t), i = n > t ? e.substring(n) : ""; return [r + "/", i] }(t), i = this.weightPathPrefix || n, a = [], o = []; for (const t of e) for (const e of t.paths) null != this.weightUrlConverter ? o.push(this.weightUrlConverter(e)) : a.push(i + e + r); return this.weightUrlConverter && a.push(...await Promise.all(o)), a } async loadWeights(e) { const t = await this.getWeightUrls(e); return [(0, x.Xf)(e), await Xe(t, this.loadOptions)] } } function Qe(e) { return null != e.match(Je.URL_SCHEME_REGEX) } Je.URL_SCHEME_REGEX = /^https?:\/\//; const et = (e, t) => { if ("undefined" == typeof fetch && (null == t || null == t.fetchFunc)) return null; { let n = !0; if (n = Array.isArray(e) ? e.every((e => Qe(e))) : Qe(e), n) return tt(e, t) } return null }; function tt(e, t) { return new Je(e, t) } function nt(e, t) { return tt(e, t) } w.registerSaveRouter(et), w.registerLoadRouter(et); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rt { constructor(e) { this.modelArtifacts = e } load() { return this.modelArtifacts } } class it { constructor(e) { this.saveHandler = e } save(e) { return this.saveHandler(e) } } class at { constructor(e) { e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = t => Promise.resolve(e.save(t))) } } function ot(e, t, n, r) { return new at(st(...arguments)) } function st(e, t, n, r) { if (1 === arguments.length) { return null != e.modelTopology || null != e.weightSpecs ? new rt(e) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new rt({ modelTopology: e })) } return console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new rt({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: r }) } function ut(e) { return new it(e) } function lt(e) { return new it(e) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var ct = n(8189), ht = n(5703), dt = n(1760), ft = n(929), pt = n(7703); const mt = (0, ft.op)({ + confusionMatrix_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, ct.YT)(e, "labels", "confusionMatrix"), i = (0, ct.YT)(t, "predictions", "confusionMatrix"); R.vA(null == n || n > 0 && Number.isInteger(n), (() => `If provided, numClasses must be a positive integer, but got ${n}`)), R.vA(1 === r.rank, (() => `Expected the rank of labels to be 1, but got ${r.rank}`)), R.vA(1 === i.rank, (() => `Expected the rank of predictions to be 1, but got ${i.rank}`)), R.vA(r.shape[0] === i.shape[0], (() => `Mismatch in the number of examples: ${r.shape[0]} vs. ${i.shape[0]}. Labels and predictions should have the same number of elements.`)), R.vA(n > 0 && Number.isInteger(n), (() => `numClasses is required to be a positive integer, but got ${n}`)); const a = (0, dt.M)((0, le.w)(r, "int32"), n), o = (0, dt.M)((0, le.w)(i, "int32"), n), s = (0, pt.m)(a), u = (0, ht.N)(s, o); return (0, le.w)(u, "int32") } + }); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var gt = n(2198), yt = n(5441), bt = n(7074), vt = n(2768); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + let xt, wt = !1; function kt(e, t = 3) { if (t > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (null == e) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); let n = !1, r = !1, i = !1, a = !1, o = !1, s = !1; if (e.data instanceof Uint8Array) n = !0; else if ("undefined" != typeof ImageData && e instanceof ImageData) r = !0; else if ("undefined" != typeof HTMLVideoElement && e instanceof HTMLVideoElement) i = !0; else if ("undefined" != typeof HTMLImageElement && e instanceof HTMLImageElement) a = !0; else if (null != e.getContext) o = !0; else { if (!("undefined" != typeof ImageBitmap && e instanceof ImageBitmap)) throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`); s = !0 } if (null != (0, bt._5)(yt.awo, f.T2.backendName)) { const n = { pixels: e }, r = { numChannels: t }; return f.T2.runKernel(yt.awo, n, r) } const [u, l] = i ? [e.videoWidth, e.videoHeight] : [e.width, e.height]; let c, h; if (o) c = e.getContext("2d").getImageData(0, 0, u, l).data; else if (r || n) c = e.data; else if (a || i || s) { if (null == xt) if ("undefined" == typeof document) { if ("undefined" == typeof OffscreenCanvas || "undefined" == typeof OffscreenCanvasRenderingContext2D) throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported."); xt = new OffscreenCanvas(1, 1).getContext("2d") } else xt = document.createElement("canvas").getContext("2d", { willReadFrequently: !0 }); xt.canvas.width = u, xt.canvas.height = l, xt.drawImage(e, 0, 0, u, l), c = xt.getImageData(0, 0, u, l).data } if (4 === t) h = new Int32Array(c); else { const e = u * l; h = new Int32Array(e * t); for (let n = 0; n < e; n++)for (let e = 0; e < t; ++e)h[n * t + e] = c[4 * n + e] } const d = [l, u, t]; return (0, vt.$)(h, d, "int32") } function St(e) { return "undefined" != typeof window && "undefined" != typeof ImageBitmap && window.hasOwnProperty("createImageBitmap") && !(e instanceof ImageBitmap) && function (e) { return null != e && 0 !== e.width && 0 !== e.height }(e) && !function (e) { return null != e && e.data instanceof Uint8Array }(e) } async function _t(e, t = 3) { let n = null; if ((0, b._K)().getBool("WRAP_TO_IMAGEBITMAP") && St(e)) { let t; try { t = await createImageBitmap(e, { premultiplyAlpha: "none" }) } catch (e) { t = null } n = null != t && t.width === e.width && t.height === e.height ? t : e } else n = e; return kt(n, t) } function Ct(e) { if (2 !== e.rank && 3 !== e.rank) throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${e.rank}.`); const t = 2 === e.rank ? 1 : e.shape[2]; if (t > 4 || 2 === t) throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${t}`); if ("float32" !== e.dtype && "int32" !== e.dtype) throw new Error(`Unsupported type for toPixels: ${e.dtype}. Please use float32 or int32 tensors.`) } async function At(e, t) { let n = (0, ct.YT)(e, "img", "toPixels"); if (!(e instanceof de.qY)) { const e = n; n = (0, le.w)(e, "int32"), e.dispose() } Ct(n); const [r, i] = n.shape.slice(0, 2), a = 2 === n.rank ? 1 : n.shape[2], o = await n.data(), s = "float32" === n.dtype ? 255 : 1, u = new Uint8ClampedArray(i * r * 4); for (let e = 0; e < r * i; ++e) { const t = [0, 0, 0, 255]; for (let r = 0; r < a; r++) { const i = o[e * a + r]; if ("float32" === n.dtype) { if (i < 0 || i > 1) throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${i}.`) } else if ("int32" === n.dtype && (i < 0 || i > 255)) throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${i}.`); 1 === a ? (t[0] = i * s, t[1] = i * s, t[2] = i * s) : t[r] = i * s } const r = 4 * e; u[r + 0] = Math.round(t[0]), u[r + 1] = Math.round(t[1]), u[r + 2] = Math.round(t[2]), u[r + 3] = Math.round(t[3]) } if (null != t) { if (!wt) { null != (0, bt._5)(yt.XmO, f.T2.backendName) && (console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."), wt = !0) } t.width = i, t.height = r; const e = t.getContext("2d"), n = new ImageData(u, i, r); e.putImageData(n, 0, 0) } return n !== e && n.dispose(), u } function Tt(e, t, n) { let r = (0, ct.YT)(e, "img", "draw"); if (!(e instanceof de.qY)) { const e = r; r = (0, le.w)(e, "int32"), e.dispose() } Ct(r), function (e) { const t = (null == e ? void 0 : e.alpha) || 1; if (t > 1 || t < 0) throw new Error(`Alpha value ${t} is suppoed to be in range [0 - 1].`) }(null == n ? void 0 : n.imageOptions); const i = { image: r }, a = { canvas: t, options: n }; f.T2.runKernel(yt.XmO, i, a) } const Et = (0, ft.op)({ fromPixels_: kt }); function Nt(e, t) { const n = e.shape.length, r = t.shape.length; if (n < 1) throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`); if (r < 1) throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`); if ("int32" !== t.dtype) throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`); if (t.shape[r - 1] > n) throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r - 1]} vs. ${n}`); if (0 === (0, R.Ze)(e.shape)) throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`); const i = t.shape, a = i[i.length - 1]; let o = 1; for (let e = 0; e < i.length - 1; ++e)o *= i[e]; const s = e.shape, u = i.slice(); u.pop(); let l = 1; for (let e = a; e < n; ++e)l *= s[e], u.push(s[e]); const c = [...(0, R.Ur)(e.shape).map((e => e / l)), 1].slice(0, a); return [u, o, l, c] } var It = n(6170), Mt = n(4969), Ft = n(565), Dt = n(3879); + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const $t = .001, Rt = .1; function Ot(e, t, n) { return null == n && (n = zt()), Pt(e, t, ((e, t) => Ut(e, t, n))) } function zt() { return 32 === f.T2.backend.floatPrecision() ? $t : Rt } function Pt(e, t, n) { let r = !0; if (((0, Dt.isTypedArray)(e) || (0, Dt.isTypedArray)(t)) && (r = !1), (0, Dt.isTypedArray)(e) && (0, Dt.isTypedArray)(t) && (r = !0), r) { const n = e.constructor.name, r = t.constructor.name; if (n !== r) throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`) } if (Array.isArray(e) && Array.isArray(t)) { const n = (0, ct.MZ)(e), r = (0, ct.MZ)(t); if (!(0, R.r1)(n, r)) throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`) } const i = (0, Dt.isTypedArray)(e) ? e : (0, Dt.flatten)(e), a = (0, Dt.isTypedArray)(t) ? t : (0, Dt.flatten)(t); if (i.length !== a.length) throw new Error(`Arrays have different lengths actual: ${i.length} vs expected: ${a.length}.\nActual: ${i}.\nExpected: ${a}.`); for (let e = 0; e < a.length; ++e) { const t = i[e], r = a[e]; if (!n(t, r)) throw new Error(`Arrays differ: actual[${e}] = ${t}, expected[${e}] = ${r}.\nActual: ${i}.\nExpected: ${a}.`) } "undefined" != typeof expect && expect().nothing() } function Bt(e, t) { e().then((() => t.fail()), (() => t())), "undefined" != typeof expect && expect().nothing() } function Lt(e, t) { const n = "string" == typeof t || "number" == typeof t || "boolean" == typeof t ? [t] : t; return (0, R.Kg)(e) || (0, R.Kg)(e[0]) || (0, R.Kg)(t) || (0, R.Kg)(t[0]) ? Pt(e, n, ((e, t) => e == t)) : Pt(e, t, ((e, t) => Ut(e, t, 0))) } function jt(e, t, n) { if (null == n && (n = zt()), !Ut(e, t, n)) throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`); "undefined" != typeof expect && expect().nothing() } function Ut(e, t, n) { return !isFinite(e) && !isFinite(t) || !(isNaN(e) || isNaN(t) || Math.abs(e - t) > n) } function Wt(e, t, n) { for (let r = 0; r < e.length; r++)if (e[r] < t || e[r] > n) throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`) } function Vt(e, t) { const n = new Float32Array(e), r = new Float32Array(t); if (n.length !== r.length) throw new Error(`Expected ArrayBuffer to be of length ${r.length}, but it was ${n.length}`); for (let e = 0; e < r.length; e++)if (n[e] !== r[e]) throw new Error(`Expected ArrayBuffer value at ${e} to be ${r[e]} but got ${n[e]} instead`) } function Gt(e) { for (let t = 0; t < e.length; t++) { const n = e[t]; Array.isArray(n) ? Gt(n) : e[t] = (0, Dt.encodeString)(n) } return e } function Ht(e) { const t = document.createElement("video"); return "playsInline" in t && (t.playsInline = !0), t.muted = !0, t.loop = !0, t.style.position = "fixed", t.style.left = "0px", t.style.top = "0px", t.preload = "auto", t.appendChild(e), new Promise((e => { t.addEventListener("loadeddata", (n => e(t))), t.load() })) } async function qt(e) { await e.play(), "requestVideoFrameCallback" in e && await new Promise((t => { e.requestVideoFrameCallback(t) })) } + /** @license See the LICENSE file. */ + const Yt = "4.22.0"; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Xt { static sgd(e) { return new Be(e) } static momentum(e, t, n = !1) { return new Le(e, t, n) } static rmsprop(e, t = .9, n = 0, r = null, i = !1) { return new je(e, t, n, r, i) } static adam(e = .001, t = .9, n = .999, r = null) { return new Re(e, t, n, r) } static adadelta(e = .001, t = .95, n = null) { return new Ie(e, t, n) } static adamax(e = .002, t = .9, n = .999, r = null, i = 0) { return new Pe(e, t, n, r, i) } static adagrad(e, t = .1) { return new Fe(e, t) } } var Kt = n(2046), Zt = n(7270), Jt = n(4703); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Qt = Xt, en = "undefined" != typeof requestAnimationFrame ? requestAnimationFrame : "undefined" != typeof setImmediate ? setImmediate : e => e(); function tn() { return new Promise((e => en((() => e())))) } var nn = n(1078); + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function rn(e, t) { const n = e[0].length; e.forEach(((e, t) => { R.vA(e.length === n, (() => `Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`)) })), R.vA(t >= 0 && t < n, (() => `Error in concat${n}D: axis must be between 0 and ${n - 1}.`)); const r = e[0]; e.forEach(((e, i) => { for (let a = 0; a < n; a++)R.vA(a === t || e[a] === r[a], (() => `Error in concat${n}D: Shape of tensors[${i}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${i}.`)) })) } function an(e, t) { const n = e[0].slice(); for (let r = 1; r < e.length; r++)n[t] += e[r][t]; return n } var on, sn = n(7195), un = n(8646); function ln(e, t, n) { let r = new Array; if (null == n && null == t) return r; if (null == t) for (; r.length < e + n.length;)r.push(-1); else r = t.slice(); if (null == n) return r; if (e + n.length !== r.length) throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e + n.length}, but shape.rank = ${r.length}`); for (let i = 1; i < n.length; ++i) { const a = n[i], o = r[r.length - n.length + i], s = r[o]; if (a >= 0) if (s >= 0) { if (s !== a) throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${i + e}] = ${a} but shape[${i + e}] = ${s}`) } else r[o] = a } return r } function cn(e) { const t = { FIRST_DIM_SIZE: on.FIRST_DIM_SIZE, VALUE_ROWIDS: on.VALUE_ROWIDS, ROW_LENGTHS: on.ROW_LENGTHS, ROW_SPLITS: on.ROW_SPLITS, ROW_LIMITS: on.ROW_LIMITS, ROW_STARTS: on.ROW_STARTS }, n = []; for (const r of e) { if (!(r in t)) break; n.push(t[r]) } return n } function hn(e) { return 0 === e.length ? 0 : e[0] === on.FIRST_DIM_SIZE ? e.length - 1 : e.length } function dn(e, t) { if (null == e || null == t) return; const n = e.length, r = t.length; if (n >= r) throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`); for (let i = 0; i < Math.min(n, r - 1); ++i) { const n = e[i], r = t[i + 1]; if (n >= 0 && r >= 0 && 1 !== n && n !== r) throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${i - e.length}] = ${n} but ragged tensor input.flatValues.shape[${i - e.length}] = ${r}`) } } !function (e) { e[e.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", e[e.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", e[e.ROW_LENGTHS = 2] = "ROW_LENGTHS", e[e.ROW_SPLITS = 3] = "ROW_SPLITS", e[e.ROW_LIMITS = 4] = "ROW_LIMITS", e[e.ROW_STARTS = 5] = "ROW_STARTS" }(on || (on = {})); + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const fn = 30; function pn(e) { return e <= fn ? e : (0, R.lK)(e, Math.floor(Math.sqrt(e))) } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function mn(e, t, n) { return [n * ("number" == typeof e ? e : e[0]), t * ("number" == typeof e ? e : e[1])] } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function gn(e, t, n, r = !0) { let i = []; if (r) i = i.concat(t.slice(0)), i.push(e[0] / n), i = i.concat(e.slice(1)); else { i = i.concat(e[0]); const n = t.length; for (let r = 0; r < n; ++r)i = i.concat([e[r + 1] / t[r], t[r]]); i = i.concat(e.slice(n + 1)) } return i } function yn(e, t, n = !0) { const r = []; if (n) { r.push(t); for (let n = t + 1; n < e; ++n)n <= 2 * t ? (r.push(n), r.push(n - (t + 1))) : r.push(n) } else { const n = [], i = []; for (let r = 1; r < e; ++r)r >= 2 * t + 1 || r % 2 == 1 ? i.push(r) : n.push(r); r.push(...n), r.push(0), r.push(...i) } return r } function bn(e, t, n, r = !0) { const i = []; r ? i.push(e[0] / n) : i.push(e[0] * n); for (let n = 1; n < e.length; ++n)n <= t.length ? r ? i.push(t[n - 1] * e[n]) : i.push(e[n] / t[n - 1]) : i.push(e[n]); return i } function vn(e, t) { const n = [0]; for (let r = 0; r < t; ++r)n.push(e[r][0]); return n } function xn(e, t, n) { const r = e.slice(0, 1); for (let i = 0; i < n; ++i)r.push(e[i + 1] - t[i][0] - t[i][1]); return r } var wn = n(8576); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const kn = .3275911, Sn = .254829592, _n = -.284496736, Cn = 1.421413741, An = -1.453152027, Tn = 1.061405429; var En = n(3673); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Nn(e, t) { if (e.length !== t.length) throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`); const n = new Float32Array(2 * e.length); for (let r = 0; r < n.length; r += 2)n[r] = e[r / 2], n[r + 1] = t[r / 2]; return n } function In(e) { const t = new Float32Array(e.length / 2), n = new Float32Array(e.length / 2); for (let r = 0; r < e.length; r += 2)t[r / 2] = e[r], n[r / 2] = e[r + 1]; return { real: t, imag: n } } function Mn(e) { const t = Math.ceil(e.length / 4), n = new Float32Array(t), r = new Float32Array(t); for (let t = 0; t < e.length; t += 4)n[Math.floor(t / 4)] = e[t], r[Math.floor(t / 4)] = e[t + 1]; return { real: n, imag: r } } function Fn(e) { const t = Math.floor(e.length / 4), n = new Float32Array(t), r = new Float32Array(t); for (let t = 2; t < e.length; t += 4)n[Math.floor(t / 4)] = e[t], r[Math.floor(t / 4)] = e[t + 1]; return { real: n, imag: r } } function Dn(e, t) { return { real: e[2 * t], imag: e[2 * t + 1] } } function $n(e, t, n, r) { e[2 * r] = t, e[2 * r + 1] = n } function Rn(e, t) { const n = new Float32Array(e / 2), r = new Float32Array(e / 2); for (let i = 0; i < Math.ceil(e / 2); i++) { const a = (t ? 2 : -2) * Math.PI * (i / e); n[i] = Math.cos(a), r[i] = Math.sin(a) } return { real: n, imag: r } } function On(e, t, n) { const r = (n ? 2 : -2) * Math.PI * (e / t); return { real: Math.cos(r), imag: Math.sin(r) } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const zn = "->", Pn = /->/g, Bn = ",", Ln = "..."; function jn(e, t) { const n = ((e = e.replace(/\s/g, "")).length - e.replace(Pn, "").length) / zn.length; if (n < 1) throw new Error("Equations without an arrow are not supported."); if (n > 1) throw new Error(`Equation must contain exactly one arrow ("${zn}").`); const [r, i] = e.split(zn); (0, R.vA)(-1 === r.indexOf(Ln), (() => `The ellipsis notation ("${Ln}") is not supported yet.`)); const a = r.split(Bn), o = a.length; if (t !== o) throw new Error(`Expected ${o} input tensors, received ${t}`); if (o > 2) throw new Error("Support for more than 2 input tensors is not implemented yet."); const s = []; for (let e = 0; e < i.length; ++e) { const t = i[e]; if (!a.some((e => -1 !== e.indexOf(t)))) throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`); -1 === s.indexOf(t) && s.push(t) } for (let e = 0; e < r.length; ++e) { const t = r[e]; -1 === s.indexOf(t) && t !== Bn && s.push(t) } const u = new Array(a.length); for (let e = 0; e < o; ++e) { if (new Set(a[e].split("")).size !== a[e].length) throw new Error(`Found duplicate axes in input component ${a[e]}. Support for duplicate axes in input is not implemented yet.`); u[e] = []; for (let t = 0; t < a[e].length; ++t)u[e].push(s.indexOf(a[e][t])) } const l = s.length, c = []; for (let e = i.length; e < l; ++e)c.push(e); return { allDims: s, summedDims: c, idDims: u } } function Un(e, t) { let n = new Array(e); n.fill(-1); for (let e = 0; e < t.length; ++e)n[t[e]] = e; const r = []; for (let t = 0; t < e; ++t)-1 === n[t] && r.push(t); return n = n.filter((e => -1 !== e)), { permutationIndices: n, expandDims: r } } function Wn(e, t, n) { const r = new Array(e); for (let e = 0; e < n.length; ++e) { const i = n[e].shape; for (let n = 0; n < t[e].length; ++n)void 0 === r[t[e][n]] ? r[t[e][n]] = i[n] : (0, R.vA)(r[t[e][n]] === i[n], (() => `Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(i)}, but got dimension ${i[n]}`)) } } function Vn(e, t) { const n = e, r = []; let i = 0; 0 === e.length && n.push(-1), i = e.length + 1; for (let e = 0; e < i; ++e)r.push([]); const a = []; for (let e = 0; e < n.length; ++e) { const i = Hn(t, n[e]); for (const t of i) -1 === a.indexOf(t) && (r[e].push(t), a.push(t)) } return { path: n, steps: r } } function Gn(e) { return e.every(((e, t) => e === t)) } function Hn(e, t) { const n = []; for (let r = 0; r < e.length; ++r)0 !== e[r].length && -1 === e[r].indexOf(t) && -1 !== t || n.push(r); return n } function qn(e, t, n = 0) { let r = []; if ("number" == typeof t) (0, R.vA)(e.shape[n] % t == 0, (() => "Number of splits must evenly divide the axis.")), r = new Array(t).fill(e.shape[n] / t); else { const i = t.reduce(((e, t) => (-1 === t && (e += 1), e)), 0); (0, R.vA)(i <= 1, (() => "There should be only one negative value in split array.")); const a = t.indexOf(-1); if (-1 !== a) { const r = t.reduce(((e, t) => t > 0 ? e + t : e)); t[a] = e.shape[n] - r } (0, R.vA)(e.shape[n] === t.reduce(((e, t) => e + t)), (() => "The sum of sizes must match the size of the axis dimension.")), r = t } return r } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Yn(e) { return `Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}` } function Xn(e, t) { return `indices(${e}, 0) is invalid: ${t} < 0` } function Kn(e, t, n) { return `indices(${e}, 0) is invalid: ${t} >= ${n}` } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Zn(e, t) { return `only one output dimension may be -1, not both ${e} and ${t}` } function Jn(e, t) { return `size ${e} must be non-negative, not ${t}` } function Qn() { return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero" } function er(e, t) { return `Input to reshape is a SparseTensor with ${(0, R.Ze)(e)}\n dense values, but the requested shape requires a multiple of ${(0, R.Ze)(t)}. inputShape=${e} outputShape= ${t}` } function tr(e, t) { return `Input to reshape is a tensor with ${(0, R.Ze)(e)} dense values, but the requested shape has ${(0, R.Ze)(t)}. inputShape=${e} outputShape=${t}` } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function nr() { return "segment ids must be >= 0" } function rr() { return "segment ids are not increasing" } function ir(e, t) { return `Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.` } function ar(e, t, n) { return `Bad: indices[${e}] == ${t} out of range [0, ${n})` } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function or(e, t) { let n, r = !1; for (e <= fn ? (n = e, r = !0) : n = (0, R.lK)(e, Math.floor(Math.sqrt(e))); !r;)n > t || n === e ? r = !0 : n = (0, R.lK)(e, n + 1); return n } function sr(e, t, n) { const r = [], i = e.length; for (let a = 0; a < i; a++)a !== t ? r.push(e[a]) : r.push(n); return r } function ur(e, t, n, r) { const i = t.shape.length, a = e.shape.length; if (0 !== r && (r < -i || r > i)) throw new Error(`Expect batchDims in the range of [-${i}, ${i}], but got ${r}`); if (r < 0 && (r += i), r > a) throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${a}).`); if (n < r) throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`); for (let n = 0; n < r; ++n)if (e.shape[n] !== t.shape[n]) throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`); const o = e.shape[n], s = []; let u = 1, l = 1, c = 1; for (let t = 0; t < r; ++t)s.push(e.shape[t]), u *= e.shape[t]; for (let t = r; t < n; t++)s.push(e.shape[t]), l *= e.shape[t]; for (let e = r; e < i; e++)s.push(t.shape[e]); for (let t = n + 1; t < a; t++)s.push(e.shape[t]), c *= e.shape[t]; return { batchSize: u, sliceSize: c, outerSize: l, dimSize: o, outputShape: s } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function lr(e) { try { return e.map((e => (0, Dt.decodeString)(e))) } catch (e) { throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`) } } function cr(e) { return e.map((e => (0, Dt.encodeString)(e))) } var hr = n(8360), dr = n(4411), fr = n(5149); + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + !function () { for (const e of Ue) Te(e) }() + }, 6734: (e, t, n) => { "use strict"; n.d(t, { D: () => i }); var r = n(3879); class i { static join(e) { return new i(e).slice() } constructor(e) { if (this.shards = [], this.previousShardIndex = 0, null == e) return; if (e instanceof Array || (e = [e]), 0 === (e = e.map((e => r.isTypedArray(e) ? e.buffer : e))).length) return; this.bufferUniformSize = e[0].byteLength; let t = 0; for (let n = 0; n < e.length; n++) { const r = e[n]; n !== e.length - 1 && r.byteLength !== this.bufferUniformSize && (this.bufferUniformSize = void 0); const i = t + r.byteLength; this.shards.push({ buffer: r, start: t, end: i }), t = i } 0 === this.shards.length && (this.byteLength = 0), this.byteLength = this.shards[this.shards.length - 1].end } slice(e = 0, t = this.byteLength) { if (0 === this.shards.length) return new ArrayBuffer(0); if (e = isNaN(Number(e)) ? 0 : e, t = isNaN(Number(t)) ? 0 : t, e = Math.max(0, e), (t = Math.min(this.byteLength, t)) <= e) return new ArrayBuffer(0); const n = this.findShardForByte(e); if (-1 === n) throw new Error(`Could not find start shard for byte ${e}`); const r = new ArrayBuffer(t - e), i = new Uint8Array(r); let a = 0; for (let r = n; r < this.shards.length; r++) { const n = this.shards[r], o = e + a - n.start, s = a, u = Math.min(t, n.end) - n.start, l = new Uint8Array(n.buffer, o, u - o); if (i.set(l, s), a += l.length, t < n.end) break } return r } findShardForByte(e) { if (0 === this.shards.length || e < 0 || e >= this.byteLength) return -1; if (null != this.bufferUniformSize) return this.previousShardIndex = Math.floor(e / this.bufferUniformSize), this.previousShardIndex; function t(t) { return e < t.start ? -1 : e >= t.end ? 1 : 0 } if (0 === t(this.shards[this.previousShardIndex])) return this.previousShardIndex; const n = function (e, t) { let n = 0, r = e.length; for (; n <= r;) { const i = Math.floor((r - n) / 2) + n, a = t(e[i]); if (0 === a) return i; a < 0 ? r = i : n = i + 1 } return -1 }(this.shards, t); return -1 === n ? -1 : (this.previousShardIndex = n, this.previousShardIndex) } } }, 7084: (e, t, n) => { + "use strict"; n.d(t, { AQ: () => S, CY: () => d, Ej: () => T, P8: () => _, Rl: () => A, Xf: () => N, aG: () => h, jf: () => k, l3: () => w, oR: () => E, s5: () => y, zV: () => C }); var r = n(7148), i = n(4027), a = n(5119), o = n(5685), s = n(6734), u = n(5287), l = n(6574); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const c = 4; async function h(e, t) { const n = [], r = [], i = Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e); for (let a = 0; a < i.length; ++a) { const o = i[a], s = Array.isArray(e) ? e[a].tensor : e[o]; if ("float32" !== s.dtype && "int32" !== s.dtype && "bool" !== s.dtype && "string" !== s.dtype && "complex64" !== s.dtype) throw new Error(`Unsupported dtype in weight '${o}': ${s.dtype}`); const u = { name: o, shape: s.shape, dtype: s.dtype }; if ("string" === s.dtype) { const e = new Promise((async e => { const t = await s.bytes(), n = t.reduce(((e, t) => e + t.length), 0) + c * t.length, r = new Uint8Array(n); let i = 0; for (let e = 0; e < t.length; e++) { const n = t[e], a = new Uint8Array(new Uint32Array([n.length]).buffer); r.set(a, i), i += c, r.set(n, i), i += n.length } e(r) })); r.push(e) } else r.push(s.data()); null != t && (u.group = t), n.push(u) } return { data: b(await Promise.all(r)), specs: n } } function d(e, t) { const n = new s.D(e), r = {}; let i = 0; for (const e of t) { const t = f(e, ((e, t) => n.slice(i + e, i + t))); r[e.name] = m(e, n.slice(i, i + t)), i += t } return r } function f(e, t) { const n = (0, a.Ze)(e.shape); let r; if ("quantization" in e) { const t = e.quantization; r = o.i[t.dtype] } else { if ("string" === e.dtype) { let e = 0; for (let r = 0; r < n; r++)e += c + new Uint32Array(t(e, e + c))[0]; return e } r = o.i[e.dtype] } return n * r } async function p(e, t) { const n = (0, a.Ze)(e.shape); let r; if ("quantization" in e) { const t = e.quantization; r = o.i[t.dtype] } else { if ("string" === e.dtype) { let e = 0; for (let r = 0; r < n; r++)e += c + new Uint32Array(await t(e, e + c))[0]; return e } r = o.i[e.dtype] } return n * r } function m(e, t) { const n = e.name, s = e.dtype, u = e.shape, l = (0, a.Ze)(u); let h, d = 0; if ("quantization" in e) { const r = e.quantization; if ("uint8" === r.dtype || "uint16" === r.dtype) { if (!("min" in r) || !("scale" in r)) throw new Error(`Weight ${e.name} with quantization ${r.dtype} doesn't have corresponding metadata min and scale.`) } else { if ("float16" !== r.dtype) throw new Error(`Weight ${e.name} has unknown quantization dtype ${r.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); if ("float32" !== s) throw new Error(`Weight ${e.name} is quantized with ${r.dtype} which only supports weights of type float32 not ${s}.`) } const i = o.i[r.dtype], a = "uint8" === r.dtype ? new Uint8Array(t) : new Uint16Array(t); if ("float32" === s) if ("uint8" === r.dtype || "uint16" === r.dtype) { h = new Float32Array(a.length); for (let e = 0; e < a.length; e++) { const t = a[e]; h[e] = t * r.scale + r.min } } else { if ("float16" !== r.dtype) throw new Error(`Unsupported quantization type ${r.dtype} for weight type float32.`); { const e = function () { const e = function () { const e = e => { let t = e << 13, n = 0; for (; !(8388608 & t);)n -= 8388608, t <<= 1; return t &= -8388609, n += 947912704, t | n }, t = new Uint32Array(2048); t[0] = 0; for (let n = 1; n < 1024; n++)t[n] = e(n); for (let e = 1024; e < 2048; e++)t[e] = 939524096 + (e - 1024 << 13); return t }(), t = function () { const e = new Uint32Array(64); e[0] = 0, e[31] = 1199570944, e[32] = 2147483648, e[63] = 3347054592; for (let t = 1; t < 31; t++)e[t] = t << 23; for (let t = 33; t < 63; t++)e[t] = 2147483648 + (t - 32 << 23); return e }(), n = function () { const e = new Uint32Array(64); for (let t = 0; t < 64; t++)e[t] = 1024; return e[0] = e[32] = 0, e }(); return r => { const i = new ArrayBuffer(4 * r.length), a = new Uint32Array(i); for (let i = 0; i < r.length; i++) { const o = r[i], s = e[n[o >> 10] + (1023 & o)] + t[o >> 10]; a[i] = s } return new Float32Array(i) } }(); h = e(a) } } else { if ("int32" !== s) throw new Error(`Unsupported dtype in weight '${n}': ${s}`); if ("uint8" !== r.dtype && "uint16" !== r.dtype) throw new Error(`Unsupported quantization type ${r.dtype} for weight type int32.`); h = new Int32Array(a.length); for (let e = 0; e < a.length; e++) { const t = a[e]; h[e] = Math.round(t * r.scale + r.min) } } d += l * i } else if ("string" === s) { const n = (0, a.Ze)(e.shape); h = []; for (let e = 0; e < n; e++) { const e = new Uint32Array(t.slice(d, d + c))[0]; d += c; const n = new Uint8Array(t.slice(d, d + e)); h.push(n), d += e } } else { const e = o.i[s]; if ("float32" === s) h = new Float32Array(t); else if ("int32" === s) h = new Int32Array(t); else { if ("bool" !== s) { if ("complex64" === s) { h = new Float32Array(t); const e = new Float32Array(h.length / 2), n = new Float32Array(h.length / 2); for (let t = 0; t < e.length; t++)e[t] = h[2 * t], n[t] = h[2 * t + 1]; const a = (0, i.O)(e, u, "float32"), o = (0, i.O)(n, u, "float32"), s = (0, r.f)(a, o); return a.dispose(), o.dispose(), s } throw new Error(`Unsupported dtype in weight '${n}': ${s}`) } h = new Uint8Array(t) } d += l * e } return (0, i.O)(h, u, s) } async function g(e, t, n) { let r = new Uint8Array(t); for (; r.byteLength < n;) { const { done: t, value: i } = await e.read(); if (t && null == i) { const e = n - r.byteLength; throw new Error(`Reader is done but ${e} bytes are still expected`) } const a = new Uint8Array(r.length + i.byteLength); a.set(r, 0), a.set(new Uint8Array(i), r.length), r = a } return r.buffer } async function y(e, t) { const n = {}, r = e.getReader(); let i = new ArrayBuffer(0); for (const e of t) { const t = await p(e, (async (e, t) => (i = await g(r, i, t), i.slice(e, t)))); i = await g(r, i, t); const o = i.slice(0, t); i = i.slice(t); const s = m(e, o); if (n[e.name] = s, "webgpu" === (0, u.jz)()) { const e = (0, u.Hs)(); "uploadToGPU" in e && (0, a.Ze)(s.shape) >= (0, l._K)().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD") && e.uploadToGPU(s.dataId) } } return n } function b(e) { if (null === e) throw new Error(`Invalid input value: ${JSON.stringify(e)}`); let t = 0; const n = []; e.forEach((e => { if (t += e.byteLength, n.push(e.byteLength === e.buffer.byteLength ? e : new e.constructor(e)), !(e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array)) throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`) })); const r = new Uint8Array(t); let i = 0; return n.forEach((e => { r.set(new Uint8Array(e.buffer), i), i += e.byteLength })), r.buffer } const v = "undefined" != typeof Buffer && ("undefined" == typeof Blob || "undefined" == typeof atob || "undefined" == typeof btoa); function x(e) { return v ? Buffer.byteLength(e, "utf8") : new Blob([e]).size } function w(e) { if (v) return Buffer.from(e).toString("base64"); const t = new Uint8Array(e); let n = ""; for (let e = 0, r = t.length; e < r; e++)n += String.fromCharCode(t[e]); return btoa(n) } function k(e) { if (v) { const t = Buffer.from(e, "base64"); return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength) } const t = atob(e), n = new Uint8Array(t.length); for (let e = 0; e < t.length; ++e)n.set([t.charCodeAt(e)], e); return n.buffer } function S(e) { return s.D.join(e) } function _(e) { for (e = e.trim(); e.endsWith("/");)e = e.slice(0, e.length - 1); const t = e.split("/"); return t[t.length - 1] } function C(e, t) { const n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, weightsManifest: t }; return null != e.signature && (n.signature = e.signature), null != e.userDefinedMetadata && (n.userDefinedMetadata = e.userDefinedMetadata), null != e.modelInitializer && (n.modelInitializer = e.modelInitializer), null != e.initializerSignature && (n.initializerSignature = e.initializerSignature), null != e.trainingConfig && (n.trainingConfig = e.trainingConfig), n } function A(e, t, n) { const r = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy }; if (null != e.trainingConfig && (r.trainingConfig = e.trainingConfig), null != e.weightsManifest) { if (!t) throw new Error("modelJSON has weightsManifest but weightSpecs is null"); if (!n) throw new Error("modelJSON has weightsManifest but weightData is null"); r.weightSpecs = t, r.weightData = n } return null != e.signature && (r.signature = e.signature), null != e.userDefinedMetadata && (r.userDefinedMetadata = e.userDefinedMetadata), null != e.modelInitializer && (r.modelInitializer = e.modelInitializer), null != e.initializerSignature && (r.initializerSignature = e.initializerSignature), r } async function T(e, t) { let n, r; return null != e.weightsManifest && ([n, r] = await t(e.weightsManifest)), A(e, n, r) } function E(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer."); return { dateSaved: new Date, modelTopologyType: "JSON", modelTopologyBytes: null == e.modelTopology ? 0 : x(JSON.stringify(e.modelTopology)), weightSpecsBytes: null == e.weightSpecs ? 0 : x(JSON.stringify(e.weightSpecs)), weightDataBytes: null == e.weightData ? 0 : new s.D(e.weightData).byteLength } } function N(e) { const t = []; for (const n of e) t.push(...n.weights); return t } + }, 5685: (e, t, n) => { + "use strict"; n.d(t, { i: () => r }); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const r = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 } + }, 5441: (e, t, n) => { "use strict"; n.d(t, { $dB: () => F, $jE: () => nn, $zE: () => M, A1h: () => O, A8B: () => Ut, BK4: () => bn, BLA: () => Ze, BRl: () => ae, Blb: () => Wt, BoJ: () => Ht, BxF: () => he, C8s: () => Gt, CQC: () => pt, Cg$: () => Ie, CwD: () => Te, D7i: () => At, Ddj: () => Kt, Dr: () => vn, DvZ: () => Yt, E3$: () => Se, EkD: () => s, ElG: () => fe, EwU: () => hn, FAs: () => sn, FCQ: () => _t, FSt: () => l, Fin: () => Bt, GZp: () => Jt, HNs: () => _, Ik2: () => k, J3C: () => Ot, JiE: () => $t, Jp_: () => c, KXH: () => T, L6G: () => qt, LB5: () => C, LDN: () => je, LG0: () => Xe, LRy: () => yt, LWX: () => at, LXA: () => De, M6A: () => Zt, MRQ: () => W, Mn0: () => B, MnK: () => L, N4F: () => S, Ncv: () => ht, O4G: () => ge, OAQ: () => xe, ODT: () => ut, OMN: () => o, ORI: () => X, PH8: () => a, P_L: () => Ct, Pah: () => ne, PbM: () => rn, Q6t: () => gt, QDP: () => E, QKF: () => d, Qgm: () => te, R23: () => xt, RMm: () => pn, RUm: () => Me, RW8: () => $e, RXX: () => We, SDM: () => nt, SQl: () => ce, T7M: () => wn, TBb: () => un, TL8: () => He, TMz: () => G, TOR: () => Et, ToN: () => Pe, TyE: () => p, UcO: () => Qt, VAI: () => Le, VCH: () => b, Vvy: () => i, WRv: () => Be, WT3: () => Je, WuN: () => jt, X$8: () => q, X0$: () => Ce, X4r: () => It, XQy: () => kt, XhZ: () => ye, XmO: () => Q, YAb: () => en, YVe: () => zt, ZgB: () => de, Zl4: () => rt, _s9: () => ie, aAr: () => xn, awo: () => yn, bCz: () => lt, bP9: () => Z, cHb: () => Ge, cS: () => v, dFH: () => Lt, dLy: () => ln, dXR: () => dn, dv8: () => we, e0f: () => it, epO: () => f, fUj: () => vt, g5A: () => qe, gC7: () => P, gIW: () => ke, hVg: () => Tt, hgw: () => St, ho8: () => y, hql: () => Rt, huO: () => bt, i5R: () => pe, iGz: () => z, iPs: () => _e, iW0: () => tn, iuW: () => on, jAQ: () => w, jM4: () => ze, jOE: () => wt, jfg: () => R, jgd: () => Xt, jj_: () => j, jxD: () => K, kdj: () => dt, l0G: () => et, l6P: () => Ft, lLS: () => be, lNG: () => Ye, ljI: () => r, lxb: () => g, lzr: () => ve, mH5: () => mt, mIA: () => Ae, mM$: () => st, mnI: () => Ee, mxL: () => me, nVu: () => Y, nY8: () => U, nZd: () => Fe, oFs: () => an, oJ2: () => ft, ox3: () => oe, p2J: () => D, pJc: () => Nt, pPe: () => fn, p_m: () => h, pk0: () => J, pnw: () => gn, pr3: () => I, pyJ: () => ct, rFG: () => Vt, rFm: () => $, rGP: () => le, rsH: () => re, sDr: () => ee, t3d: () => Ue, tG8: () => Ne, tGH: () => H, u$b: () => Dt, u8Z: () => u, uWl: () => Mt, urI: () => ot, vI1: () => Pt, vaV: () => N, vj7: () => A, wNW: () => V, wwC: () => x, wx0: () => cn, x7F: () => Ke, xJ3: () => mn, xu7: () => Qe, yPW: () => Oe, ySp: () => Ve, ybN: () => se, ybj: () => ue, ylV: () => tt, zP9: () => m, zfU: () => Re }); const r = "Abs", i = "Acos", a = "Acosh", o = "Add", s = "AddN", u = "All", l = "Any", c = "ArgMax", h = "ArgMin", d = "Asin", f = "Asinh", p = "Atan", m = "Atanh", g = "Atan2", y = "AvgPool", b = "AvgPoolGrad", v = "AvgPool3D", x = "AvgPool3DGrad", w = "BatchMatMul", k = "BatchToSpaceND", S = "Bincount", _ = "BitwiseAnd", C = "BroadcastTo", A = "BroadcastArgs", T = "Cast", E = "Ceil", N = "ClipByValue", I = "Complex", M = "ComplexAbs", F = "Concat", D = "Conv2D", $ = "Conv2DBackpropFilter", R = "Conv2DBackpropInput", O = "Conv3D", z = "Conv3DBackpropFilterV2", P = "Conv3DBackpropInputV2", B = "Cos", L = "Cosh", j = "Cumprod", U = "Cumsum", W = "CropAndResize", V = "DenseBincount", G = "DepthToSpace", H = "DepthwiseConv2dNative", q = "DepthwiseConv2dNativeBackpropFilter", Y = "DepthwiseConv2dNativeBackpropInput", X = "Diag", K = "Dilation2D", Z = "Dilation2DBackpropInput", J = "Dilation2DBackpropFilter", Q = "Draw", ee = "RealDiv", te = "Einsum", ne = "Elu", re = "EluGrad", ie = "Erf", ae = "Equal", oe = "Exp", se = "ExpandDims", ue = "Expm1", le = "FFT", ce = "Fill", he = "FlipLeftRight", de = "Floor", fe = "FloorDiv", pe = "FusedBatchNorm", me = "GatherV2", ge = "GatherNd", ye = "Greater", be = "GreaterEqual", ve = "Identity", xe = "IFFT", we = "Imag", ke = "IsFinite", Se = "IsInf", _e = "IsNan", Ce = "LeakyRelu", Ae = "Less", Te = "LessEqual", Ee = "LinSpace", Ne = "Log", Ie = "Log1p", Me = "LogicalAnd", Fe = "LogicalNot", De = "LogicalOr", $e = "LogicalXor", Re = "LogSoftmax", Oe = "LowerBound", ze = "LRN", Pe = "LRNGrad", Be = "MatrixBandPart", Le = "Max", je = "Maximum", Ue = "MaxPool", We = "MaxPoolGrad", Ve = "MaxPool3D", Ge = "MaxPool3DGrad", He = "MaxPoolWithArgmax", qe = "Mean", Ye = "Min", Xe = "Minimum", Ke = "MirrorPad", Ze = "Mod", Je = "Multinomial", Qe = "Multiply", et = "Neg", tt = "NotEqual", nt = "NonMaxSuppressionV3", rt = "NonMaxSuppressionV4", it = "NonMaxSuppressionV5", at = "OnesLike", ot = "OneHot", st = "Pack", ut = "PadV2", lt = "Pool", ct = "Pow", ht = "Prelu", dt = "Prod", ft = "RaggedGather", pt = "RaggedRange", mt = "RaggedTensorToTensor", gt = "Range", yt = "Real", bt = "Reciprocal", vt = "Relu", xt = "Reshape", wt = "ResizeNearestNeighbor", kt = "ResizeNearestNeighborGrad", St = "ResizeBilinear", _t = "ResizeBilinearGrad", Ct = "Relu6", At = "Reverse", Tt = "Round", Et = "Rsqrt", Nt = "ScatterNd", It = "TensorScatterUpdate", Mt = "SearchSorted", Ft = "Select", Dt = "Selu", $t = "Slice", Rt = "Sin", Ot = "Sinh", zt = "Sign", Pt = "Sigmoid", Bt = "Softplus", Lt = "Sqrt", jt = "Sum", Ut = "SpaceToBatchND", Wt = "SplitV", Vt = "Softmax", Gt = "SparseFillEmptyRows", Ht = "SparseReshape", qt = "SparseSegmentMean", Yt = "SparseSegmentSum", Xt = "SparseToDense", Kt = "SquaredDifference", Zt = "Square", Jt = "StaticRegexReplace", Qt = "StridedSlice", en = "StringNGrams", tn = "StringSplit", nn = "StringToHashBucketFast", rn = "Sub", an = "Tan", on = "Tanh", sn = "Tile", un = "TopK", ln = "Transform", cn = "Transpose", hn = "Unique", dn = "Unpack", fn = "UnsortedSegmentSum", pn = "UpperBound", mn = "ZerosLike", gn = "Step", yn = "FromPixels", bn = "RotateWithOffset", vn = "_FusedMatMul", xn = "FusedConv2D", wn = "FusedDepthwiseConv2D" }, 7074: (e, t, n) => { + "use strict"; n.d(t, { Cf: () => m, Op: () => c, _5: () => u, iP: () => f, kr: () => d, rY: () => p, tA: () => h, vQ: () => l }); var r = n(6574), i = n(1743), a = n(3673); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const o = (0, i.m)("kernelRegistry", (() => new Map)), s = (0, i.m)("gradRegistry", (() => new Map)); function u(e, t) { const n = g(e, t); return o.get(n) } function l(e) { return s.get(e) } function c(e) { const t = o.entries(), n = []; for (; ;) { const { done: r, value: i } = t.next(); if (r) break; const [a, o] = i, [s] = a.split("_"); s === e && n.push(o) } return n } function h(e) { const { kernelName: t, backendName: n } = e, r = g(t, n); o.has(r) && a.i(`The kernel '${t}' for backend '${n}' is already registered`), o.set(r, e) } function d(e) { const { kernelName: t } = e; s.has(t) && (0, r._K)().getBool("DEBUG") && a.i(`Overriding the gradient for '${t}'`), s.set(t, e) } function f(e, t) { const n = g(e, t); if (!o.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); o.delete(n) } function p(e) { if (!s.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); s.delete(e) } function m(e, t) { c(e).forEach((e => { h(Object.assign({}, e, { backendName: t })) })) } function g(e, t) { return `${t}_${e}` } + }, 3673: (e, t, n) => { + "use strict"; n.d(t, { R: () => a, i: () => i }); var r = n(6574); +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */function i(...e) { (0, r._K)().getBool("IS_TEST") || (0, r._K)().getBool("PROD") || console.warn(...e) } function a(...e) { (0, r._K)().getBool("IS_TEST") || (0, r._K)().getBool("PROD") || console.log(...e) } + }, 4888: (e, t, n) => { + "use strict"; n.d(t, { t: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + abs_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, a.YT)(e, "x", "abs"); if ("complex64" === t.dtype) { const e = { x: t }; return r.T2.runKernel(i.$zE, e) } { const e = { x: t }; return r.T2.runKernel(i.ljI, e) } } + }) + }, 2804: (e, t, n) => { + "use strict"; n.d(t, { H: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + acos_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "acos") }; return r.T2.runKernel(i.Vvy, t) } + }) + }, 7558: (e, t, n) => { + "use strict"; n.d(t, { F: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + acosh_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "acosh") }; return r.T2.runKernel(i.PH8, t) } + }) + }, 7523: (e, t, n) => { + "use strict"; n.d(t, { W: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + add_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "add"), s = (0, o.YT)(t, "b", "add");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.OMN, u) } + }) + }, 2307: (e, t, n) => { + "use strict"; n.d(t, { Q: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + all_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "all", "bool") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.u8Z, o, s) } + }) + }, 9326: (e, t, n) => { + "use strict"; n.d(t, { b: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + any_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "any", "bool") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.FSt, o, s) } + }) + }, 897: (e, t, n) => { + "use strict"; n.d(t, { F: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + argMax_: + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = { x: (0, a.YT)(e, "x", "argMax") }, o = { axis: t }; return r.T2.runKernel(i.Jp_, n, o) } + }) + }, 4339: (e, t, n) => { + "use strict"; n.d(t, { X: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + argMin_: + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = { x: (0, a.YT)(e, "x", "argMin") }, o = { axis: t }; return r.T2.runKernel(i.p_m, n, o) } + }) + }, 6841: (e, t, n) => { + "use strict"; n.d(t, { q: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + asin_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "asin") }; return r.T2.runKernel(i.QKF, t) } + }) + }, 269: (e, t, n) => { + "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + asinh_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "asinh") }; return r.T2.runKernel(i.epO, t) } + }) + }, 9580: (e, t, n) => { + "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + atan_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "atan") }; return r.T2.runKernel(i.TyE, t) } + }) + }, 1404: (e, t, n) => { + "use strict"; n.d(t, { F: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + atan2_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "atan2"), s = (0, o.YT)(t, "b", "atan2");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.lxb, u) } + }) + }, 3774: (e, t, n) => { + "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + atanh_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "atanh") }; return r.T2.runKernel(i.zP9, t) } + }) + }, 3909: (e, t, n) => { + "use strict"; n.d(t, { $: () => h }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(9809), u = n(7195), l = n(929), c = n(2302); const h = (0, l.op)({ + avgPool_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, l, h) { const d = (0, a.YT)(e, "x", "avgPool", "float32"); o.vA(u.G0(n, 1), (() => `Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)); let f = d, p = !1; 3 === d.rank && (p = !0, f = (0, c.t)(d, [1, d.shape[0], d.shape[1], d.shape[2]])), o.vA(4 === f.rank, (() => `Error in avgPool: x must be rank 4 but got rank ${f.rank}.`)), u.s_("avgPool", l, h); const m = { x: f }, g = { filterSize: t, strides: n, pad: l, dimRoundingMode: h }; let y = r.T2.runKernel(i.ho8, m, g); return y = (0, s.w)(y, d.dtype), p ? (0, c.t)(y, [y.shape[1], y.shape[2], y.shape[3]]) : y } + }) + }, 1078: (e, t, n) => { + "use strict"; n.d(t, { Em: () => l, SM: () => s, WC: () => u, WH: () => i, aF: () => a, fK: () => h, gx: () => c, lb: () => o }); var r = n(5119); +/** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */function i(e, t) { for (let n = 0; n < e.length; ++n)if (e[e.length - n - 1] !== t - 1 - n) return !1; return !0 } function a(e, t, n) { const r = e.length + t.length, i = []; let a = 0, o = 0; for (let s = 0; s < r; s++)-1 === n.indexOf(s) ? i.push(e[a++]) : i.push(t[o++]); return i } function o(e, t) { const n = [], r = e.length; for (let i = 0; i < r; i++)-1 === t.indexOf(i) && n.push(e[i]); return [n, t.map((t => e[t]))] } function s(e, t) { return a(e, t.map((e => 1)), t) } function u(e, t, n) { r.vA(i(t, n), (() => `${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)) } function l(e, t) { if (i(e, t)) return null; const n = []; for (let r = 0; r < t; ++r)-1 === e.indexOf(r) && n.push(r); return e.forEach((e => n.push(e))), n } function c(e) { return e.map(((e, t) => [t, e])).sort(((e, t) => e[1] - t[1])).map((e => e[0])) } function h(e, t) { const n = []; for (let r = t - e; r < t; ++r)n.push(r); return n } + }, 9772: (e, t, n) => { + "use strict"; n.d(t, { G: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + batchToSpaceND_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const s = (0, a.YT)(e, "x", "batchToSpaceND"), u = t.reduce(((e, t) => e * t)); o.vA(s.rank >= 1 + t.length, (() => `input rank is ${s.rank} but should be > than blockShape.length ${t.length}`)), o.vA(n.length === t.length, (() => `crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)), o.vA(s.shape[0] % u == 0, (() => `input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${u}`)); const l = { x: s }, c = { blockShape: t, crops: n }; return r.T2.runKernel(i.Ik2, l, c) } + }) + }, 9160: (e, t, n) => { + "use strict"; n.d(t, { $: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(2302); const u = (0, n(929).op)({ + batchNorm_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, u, l, c) { null == c && (c = .001); const h = (0, a.YT)(e, "x", "batchNorm"), d = (0, a.YT)(t, "mean", "batchNorm"), f = (0, a.YT)(n, "variance", "batchNorm"); let p, m; null != l && (p = (0, a.YT)(l, "scale", "batchNorm")), null != u && (m = (0, a.YT)(u, "offset", "batchNorm")), o.vA(d.rank === f.rank, (() => "Batch normalization gradient requires mean and variance to have equal ranks.")), o.vA(null == m || d.rank === m.rank, (() => "Batch normalization gradient requires mean and offset to have equal ranks.")), o.vA(null == p || d.rank === p.rank, (() => "Batch normalization gradient requires mean and scale to have equal ranks.")); const g = { x: function (e) { let t; return t = 0 === e.rank || 1 === e.rank ? (0, s.t)(e, [1, 1, 1, e.size]) : 2 === e.rank ? (0, s.t)(e, [1, 1, e.shape[0], e.shape[1]]) : 3 === e.rank ? (0, s.t)(e, [1, e.shape[0], e.shape[1], e.shape[2]]) : e, t }(h), scale: p, offset: m, mean: d, variance: f }, y = { varianceEpsilon: c }, b = r.T2.runKernel(i.i5R, g, y); return (0, s.t)(b, h.shape) } + }) + }, 3567: (e, t, n) => { + "use strict"; n.d(t, { h: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(125), u = n(929), l = n(2302); const c = (0, u.op)({ + broadcastTo_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, a.YT)(e, "broadcastTo", "x"); const u = n.shape; if ((0, o.SA)(t), t.length < n.rank) throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`); if (t.length > n.rank) { const e = n.shape.slice(); for (; e.length < t.length;)e.unshift(1); n = (0, l.t)(n, e) } const c = n.shape, h = Array.from(t); for (let e = t.length - 1; e >= 0; e--)if (c[e] === t[e]) h[e] = 1; else if (1 !== n.shape[e]) throw new Error(`broadcastTo(): [${u}] cannot be broadcast to [${t}].`); if (0 === h.map(((e, t) => e > 1 ? t : -1)).filter((e => e >= 0)).length) return (0, s.o)(n); const d = { x: n }, f = { reps: h }; return r.T2.runKernel(i.FAs, d, f) } + }) + }, 2198: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function r(e, t) { const n = e.length, r = []; for (let i = 0; i < n; i++) { const a = n - 1 - i, o = e[a] || 1; (t[t.length - 1 - i] || 1) > 1 && 1 === o && r.unshift(a) } return r } function i(e, t) { const n = []; for (let r = 0; r < t.length; r++) { const i = e[e.length - r - 1], a = t.length - r - 1, o = t[a]; (null == i || 1 === i && o > 1) && n.unshift(a) } return n } function a(e, t) { const n = Math.max(e.length, t.length), r = new Array(n); for (let i = 0; i < n; i++) { let a = e[e.length - i - 1]; null == a && (a = 1); let o = t[t.length - i - 1]; if (null == o && (o = 1), 1 === a) r[n - i - 1] = o; else if (1 === o) r[n - i - 1] = a; else { if (a !== o) { throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`) } r[n - i - 1] = a } } return r } n.r(t), n.d(t, { assertAndGetBroadcastShape: () => a, getBroadcastDims: () => r, getReductionAxes: () => i }) + }, 448: (e, t, n) => { + "use strict"; n.d(t, { r: () => a }); var r = n(259), i = n(5119); + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function a(e, t = "float32", n) { return t = t || "float32", i.SA(e), new r.yl(e, t, n) } + }, 9809: (e, t, n) => { + "use strict"; n.d(t, { w: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + cast_: + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, a.YT)(e, "x", "cast"); if (!o.xn(t)) throw new Error(`Failed to cast to unknown dtype ${t}`); if ("string" === t && "string" !== n.dtype || "string" !== t && "string" === n.dtype) throw new Error("Only strings can be casted to strings"); const s = { x: n }, u = { dtype: t }; return r.T2.runKernel(i.KXH, s, u) } + }) + }, 855: (e, t, n) => { + "use strict"; n.d(t, { m: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + ceil_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "ceil", "float32") }; return r.T2.runKernel(i.QDP, t) } + }) + }, 6928: (e, t, n) => { + "use strict"; n.d(t, { z: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(6111); const u = (0, n(929).op)({ + clipByValue_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const u = (0, a.YT)(e, "x", "clipByValue"); if (o.vA(t <= n, (() => `Error in clip: min (${t}) must be less than or equal to max (${n}).`)), t === n) return (0, s.G)(u.shape, t, u.dtype); const l = { x: u }, c = { clipValueMin: t, clipValueMax: n }; return r.T2.runKernel(i.vaV, l, c) } + }) + }, 125: (e, t, n) => { + "use strict"; n.d(t, { o: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + clone_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "clone", "string_or_numeric") }; return r.T2.runKernel(i.lzr, t) } + }) + }, 7148: (e, t, n) => { + "use strict"; n.d(t, { f: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + complex_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, a.YT)(e, "real", "complex"), s = (0, a.YT)(t, "imag", "complex"); o.O3(n.shape, s.shape, `real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`); const u = { real: n, imag: s }; return r.T2.runKernel(i.pr3, u) } + }) + }, 5030: (e, t, n) => { + "use strict"; n.d(t, { x: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(125); const u = (0, n(929).op)({ + concat_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { (0, o.vA)(e.length >= 1, (() => "Pass at least one tensor to concat")); const n = (0, a.j1)(e, "tensors", "concat", "string_or_numeric"); if ("complex64" === n[0].dtype && n.forEach((e => { if ("complex64" !== e.dtype) throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `) })), 1 === n.length) return (0, s.o)(n[0]); const u = n, l = { axis: t }; return r.T2.runKernel(i.$dB, u, l) } + }) + }, 3701: (e, t, n) => { "use strict"; n.d(t, { k: () => l }); var r = n(8189), i = n(5119), a = n(8794), o = n(7195), s = n(929), u = n(2302); const l = (0, s.op)({ conv1d_: function (e, t, n, s, l = "NWC", c = 1, h) { const d = (0, r.YT)(e, "x", "conv1d"), f = (0, r.YT)(t, "filter", "conv1d"); let p = d, m = !1; 2 === d.rank && (m = !0, p = (0, u.t)(d, [1, d.shape[0], d.shape[1]])), i.vA(3 === p.rank, (() => `Error in conv1d: input must be rank 3, but got rank ${p.rank}.`)), i.vA(3 === f.rank, (() => `Error in conv1d: filter must be rank 3, but got rank ${f.rank}.`)), o.s_("conv1d", s, h), i.vA(p.shape[2] === f.shape[1], (() => `Error in conv1d: depth of input (${p.shape[2]}) must match input depth for filter ${f.shape[1]}.`)), i.vA(o.G0(n, c), (() => `Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${c}'`)), i.vA(o.qk(c), (() => "Error in conv1D: Dilated rates should be larger than 0.")), i.vA(o.qk(n), (() => "Error in conv1D: Stride should be larger than 0.")), i.vA("NWC" === l, (() => `Error in conv1d: got dataFormat of ${l} but only NWC is currently supported.`)); const g = (0, u.t)(f, [1, f.shape[0], f.shape[1], f.shape[2]]), y = (0, u.t)(p, [p.shape[0], 1, p.shape[1], p.shape[2]]), b = [1, n], v = [1, c], x = (0, a.X)(y, g, b, s, "NHWC", v, h); return m ? (0, u.t)(x, [x.shape[2], x.shape[3]]) : (0, u.t)(x, [x.shape[0], x.shape[2], x.shape[3]]) } }) }, 8794: (e, t, n) => { + "use strict"; n.d(t, { X: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(7195), u = n(929), l = n(2302); const c = (0, u.op)({ + conv2d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, u, c = "NHWC", h = [1, 1], d) { const f = (0, a.YT)(e, "x", "conv2d", "float32"), p = (0, a.YT)(t, "filter", "conv2d", "float32"); let m = f, g = !1; 3 === f.rank && (g = !0, m = (0, l.t)(f, [1, f.shape[0], f.shape[1], f.shape[2]])), o.vA(4 === m.rank, (() => `Error in conv2d: input must be rank 4, but got rank ${m.rank}.`)), o.vA(4 === p.rank, (() => `Error in conv2d: filter must be rank 4, but got rank ${p.rank}.`)), s.s_("conv2d", u, d); const y = "NHWC" === c ? m.shape[3] : m.shape[1]; o.vA(y === p.shape[2], (() => `Error in conv2d: depth of input (${y}) must match input depth for filter ${p.shape[2]}.`)), o.vA(s.G0(n, h), (() => `Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${h}'`)), o.vA(s.qk(h), (() => "Error in conv2D: Dilated rates should be larger than 0.")), o.vA(s.qk(n), (() => "Error in conv2D: Strides should be larger than 0.")); const b = { x: m, filter: p }, v = { strides: n, pad: u, dataFormat: c, dilations: h, dimRoundingMode: d }, x = r.T2.runKernel(i.p2J, b, v); return g ? (0, l.t)(x, [x.shape[1], x.shape[2], x.shape[3]]) : x } + }) + }, 5248: (e, t, n) => { + "use strict"; n.d(t, { H: () => l }); var r = n(1585), i = n(5441), a = n(5119), o = n(7195), s = n(929), u = n(2302); const l = (0, s.op)({ + conv2DBackpropFilter_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, s, l, c = "NHWC", h) { let d = e; 3 === e.rank && (d = (0, u.t)(e, [1, e.shape[0], e.shape[1], e.shape[2]])); let f = t; 3 === f.rank && (f = (0, u.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]])), a.vA(4 === d.rank, (() => `Error in conv2dDerFilter: input must be rank 4, but got shape ${d.shape}.`)), a.vA(4 === f.rank, (() => `Error in conv2dDerFilter: dy must be rank 4, but got shape ${f.shape}.`)), a.vA(4 === n.length, (() => `Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`)); const p = "NHWC" === c ? d.shape[3] : d.shape[1], m = "NHWC" === c ? f.shape[3] : f.shape[1]; a.vA(p === n[2], (() => `Error in conv2dDerFilter: depth of input ${p}) must match input depth in filter (${n[2]}.`)), a.vA(m === n[3], (() => `Error in conv2dDerFilter: depth of dy (${m}) must match output depth for filter (${n[3]}).`)), o.s_("conv2dDerFilter", l, h); const g = { x: d, dy: f }, y = { strides: s, pad: l, dataFormat: c, dimRoundingMode: h, filterShape: n }; return r.T2.runKernel(i.rFm, g, y) } + }) + }, 252: (e, t, n) => { + "use strict"; n.d(t, { v: () => l }); var r = n(1585), i = n(5441), a = n(5119), o = n(7195), s = n(929), u = n(2302); const l = (0, s.op)({ + conv2DBackpropInput_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, s, l, c = "NHWC", h) { a.vA(e.length === t.rank, (() => `Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`)); let d = e, f = t, p = !1; 3 === t.rank && (p = !0, f = (0, u.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]]), d = [1, e[0], e[1], e[2]]), a.vA(4 === d.length, (() => `Error in conv2dDerInput: inShape must be length 4, but got length ${d.length}.`)), a.vA(4 === f.rank, (() => `Error in conv2dDerInput: dy must be rank 4, but got rank ${f.rank}`)), a.vA(4 === n.rank, (() => `Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`)); const m = "NHWC" === c ? d[3] : d[1], g = "NHWC" === c ? f.shape[3] : f.shape[1]; a.vA(m === n.shape[2], (() => `Error in conv2dDerInput: depth of input (${m}) must match input depth for filter ${n.shape[2]}.`)), a.vA(g === n.shape[3], (() => `Error in conv2dDerInput: depth of output (${g}) must match output depth for filter ${n.shape[3]}.`)), o.s_("conv2dDerInput", l, h); const y = { dy: f, filter: n }, b = { strides: s, pad: l, dataFormat: c, dimRoundingMode: h, inputShape: d }, v = r.T2.runKernel(i.jfg, y, b); return p ? (0, u.t)(v, [v.shape[1], v.shape[2], v.shape[3]]) : v } + }) + }, 1106: (e, t, n) => { "use strict"; n.d(t, { w: () => a }); var r = n(8189), i = n(252); const a = (0, n(929).op)({ conv2dTranspose_: function (e, t, n, a, o, s) { const u = (0, r.YT)(e, "x", "conv2dTranspose"), l = (0, r.YT)(t, "filter", "conv2dTranspose"); return (0, i.v)(n, u, l, a, o, "NHWC", s) } }) }, 1895: (e, t, n) => { + "use strict"; n.d(t, { c: () => u }); var r = n(1585), i = n(5441), a = n(5119), o = n(929), s = n(2302); const u = (0, o.op)({ + conv3DBackpropInput_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, o, u) { a.vA(e.length === t.rank, (() => `Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`)); let l = e, c = t, h = !1; 4 === t.rank && (h = !0, c = (0, s.t)(t, [1, t.shape[0], t.shape[1], t.shape[2], t.shape[3]]), l = [1, e[0], e[1], e[2], e[3]]); const d = l[4], f = c.shape[4]; a.vA(5 === l.length, (() => `Error in conv3dDerInput: inShape must be length 5, but got length ${l.length}.`)), a.vA(5 === c.rank, (() => `Error in conv3dDerInput: dy must be rank 5, but got rank ${c.rank}`)), a.vA(5 === n.rank, (() => `Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)), a.vA(d === n.shape[3], (() => `Error in conv3dDerInput: depth of input (${d}) must match input depth for filter ${n.shape[3]}.`)), a.vA(f === n.shape[4], (() => `Error in conv3dDerInput: depth of output (${f}) must match output depth for filter ${n.shape[4]}.`)); const p = { dy: c, filter: n }, m = { pad: u, strides: o, inputShape: l }, g = r.T2.runKernel(i.gC7, p, m); return h ? (0, s.t)(g, [g.shape[1], g.shape[2], g.shape[3], g.shape[4]]) : g } + }) + }, 7195: (e, t, n) => { + "use strict"; n.d(t, { $Q: () => y, Dh: () => p, E6: () => a, G0: () => m, G8: () => l, YQ: () => i, l5: () => o, p$: () => u, qk: () => g, s_: () => b, uf: () => s }); var r = n(5119); +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */function i(e, t, n, r, i = "NHWC", a) { return s(e, [...t, e[3]], n, a, r, null, null, y(i)) } function a(e, t, n, r, i, a, o = "channelsLast") { const [u, l] = c(t); let h; if ("channelsLast" === o) h = [u, l, e[3], e[3]]; else { if ("channelsFirst" !== o) throw new Error(`Unknown dataFormat ${o}`); h = [u, l, e[1], e[1]] } return s(e, h, n, r, i, a, !1, o) } function o(e, t, n, r, i, a, o = "NDHWC") { const [s, l, c] = h(t); let d, f; if ("NDHWC" === o) f = "channelsLast", d = [s, l, c, e[4], e[4]]; else { if ("NCDHW" !== o) throw new Error(`Unknown dataFormat ${o}`); f = "channelsFirst", d = [s, l, c, e[1], e[1]] } return u(e, d, n, r, i, !1, f, a) } function s(e, t, n, r, i, a, o = !1, s = "channelsLast") { let [u, h, p, m] = [-1, -1, -1, -1]; if ("channelsLast" === s) [u, h, p, m] = e; else { if ("channelsFirst" !== s) throw new Error(`Unknown dataFormat ${s}`);[u, m, h, p] = e } const [g, y, , b] = t, [v, x] = c(n), [w, k] = c(r), S = d(g, w), _ = d(y, k), { padInfo: C, outHeight: A, outWidth: T } = function (e, t, n, r, i, a, o, s, u) { let c, h, d; if ("number" == typeof e) { c = { top: e, bottom: e, left: e, right: e, type: 0 === e ? "VALID" : "NUMBER" }; const i = function (e, t, n, r, i) { null == r && (r = l(e, t, n)); const a = e[0], o = e[1], s = f((a - t + 2 * r) / n + 1, i), u = f((o - t + 2 * r) / n + 1, i); return [s, u] }([t, n], a, r, e, s); h = i[0], d = i[1] } else if ("same" === e) { h = Math.ceil(t / r), d = Math.ceil(n / i); const e = Math.max(0, (h - 1) * r + a - t), s = Math.max(0, (d - 1) * i + o - n), u = Math.floor(e / 2), l = e - u, f = Math.floor(s / 2); c = { top: u, bottom: l, left: f, right: s - f, type: "SAME" } } else if ("valid" === e) c = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, h = Math.ceil((t - a + 1) / r), d = Math.ceil((n - o + 1) / i); else { if ("object" != typeof e) throw Error(`Unknown padding parameter: ${e}`); { const l = "channelsLast" === u ? e[1][0] : e[2][0], p = "channelsLast" === u ? e[1][1] : e[2][1], m = "channelsLast" === u ? e[2][0] : e[3][0], g = "channelsLast" === u ? e[2][1] : e[3][1]; c = { top: l, bottom: p, left: m, right: g, type: 0 === l && 0 === p && 0 === m && 0 === g ? "VALID" : "EXPLICIT" }, h = f((t - a + l + p) / r + 1, s), d = f((n - o + m + g) / i + 1, s) } } return { padInfo: c, outHeight: h, outWidth: d } }(i, h, p, v, x, S, _, a, s), E = o ? b * m : b; let N; return "channelsFirst" === s ? N = [u, E, A, T] : "channelsLast" === s && (N = [u, A, T, E]), { batchSize: u, dataFormat: s, inHeight: h, inWidth: p, inChannels: m, outHeight: A, outWidth: T, outChannels: E, padInfo: C, strideHeight: v, strideWidth: x, filterHeight: g, filterWidth: y, effectiveFilterHeight: S, effectiveFilterWidth: _, dilationHeight: w, dilationWidth: k, inShape: e, outShape: N, filterShape: t } } function u(e, t, n, r, i, a = !1, o = "channelsLast", s) { let [u, c, p, m, g] = [-1, -1, -1, -1, -1]; if ("channelsLast" === o) [u, c, p, m, g] = e; else { if ("channelsFirst" !== o) throw new Error(`Unknown dataFormat ${o}`);[u, g, c, p, m] = e } const [y, b, v, , x] = t, [w, k, S] = h(n), [_, C, A] = h(r), T = d(y, _), E = d(b, C), N = d(v, A), { padInfo: I, outDepth: M, outHeight: F, outWidth: D } = function (e, t, n, r, i, a, o, s, u, c, h) { let d, p, m, g; "valid" === e && (e = 0); if ("number" == typeof e) { d = { top: e, bottom: e, left: e, right: e, front: e, back: e, type: 0 === e ? "VALID" : "NUMBER" }; const y = function (e, t, n, r, i, a) { null == i && (i = l(e, t[0], r[0])); const o = [0, 0, 0, n]; for (let n = 0; n < 3; n++)e[n] + 2 * i >= t[n] && (o[n] = f((e[n] - t[n] + 2 * i) / r[n] + 1, a)); return o }([t, n, r, 1], [s, u, c], 1, [i, a, o], e, h); p = y[0], m = y[1], g = y[2] } else { if ("same" !== e) throw Error(`Unknown padding parameter: ${e}`); { p = Math.ceil(t / i), m = Math.ceil(n / a), g = Math.ceil(r / o); const e = (p - 1) * i + s - t, l = (m - 1) * a + u - n, h = (g - 1) * o + c - r, f = Math.floor(e / 2), y = e - f, b = Math.floor(l / 2), v = l - b, x = Math.floor(h / 2); d = { top: b, bottom: v, left: x, right: h - x, front: f, back: y, type: "SAME" } } } return { padInfo: d, outDepth: p, outHeight: m, outWidth: g } }(i, c, p, m, w, k, S, T, E, N, s), $ = a ? x * g : x; let R; return "channelsFirst" === o ? R = [u, $, M, F, D] : "channelsLast" === o && (R = [u, M, F, D, $]), { batchSize: u, dataFormat: o, inDepth: c, inHeight: p, inWidth: m, inChannels: g, outDepth: M, outHeight: F, outWidth: D, outChannels: $, padInfo: I, strideDepth: w, strideHeight: k, strideWidth: S, filterDepth: y, filterHeight: b, filterWidth: v, effectiveFilterDepth: T, effectiveFilterHeight: E, effectiveFilterWidth: N, dilationDepth: _, dilationHeight: C, dilationWidth: A, inShape: e, outShape: R, filterShape: t } } function l(e, t, n, r = 1) { const i = d(t, r); return Math.floor((e[0] * (n - 1) - n + i) / 2) } function c(e) { return "number" == typeof e ? [e, e, e] : 2 === e.length ? [e[0], e[1], 1] : e } function h(e) { return "number" == typeof e ? [e, e, e] : e } function d(e, t) { return t <= 1 ? e : e + (e - 1) * (t - 1) } function f(e, t) { if (!t) return Math.trunc(e); switch (t) { case "round": return Math.round(e); case "ceil": return Math.ceil(e); case "floor": return Math.floor(e); default: throw new Error(`Unknown roundingMode ${t}`) } } function p(e) { const [t, n, r] = c(e); return 1 === t && 1 === n && 1 === r } function m(e, t) { return p(e) || p(t) } function g(e) { return c(e).every((e => e > 0)) } function y(e) { if ("NHWC" === e) return "channelsLast"; if ("NCHW" === e) return "channelsFirst"; throw new Error(`Unknown dataFormat ${e}`) } function b(e, t, n) { if (null != n) { if ("string" == typeof t) throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`); if ("number" == typeof t) r.vA(r.E6(t), (() => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`)); else { if ("object" != typeof t) throw Error(`Error in ${e}: Unknown padding parameter: ${t}`); t.forEach((t => { t.forEach((t => { r.vA(r.E6(t), (() => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`)) })) })) } } } + }, 9907: (e, t, n) => { + "use strict"; n.d(t, { g: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + cos_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "cos", "float32") }; return r.T2.runKernel(i.Mn0, t) } + }) + }, 7451: (e, t, n) => { + "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + cosh_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "cosh", "float32") }; return r.T2.runKernel(i.MnK, t) } + }) + }, 302: (e, t, n) => { + "use strict"; n.d(t, { L: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + cumprod_: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0, n = !1, o = !1) { const s = { x: (0, a.YT)(e, "x", "cumprod") }, u = { axis: t, exclusive: n, reverse: o }; return r.T2.runKernel(i.jj_, s, u) } + }) + }, 6808: (e, t, n) => { + "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + cumsum_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0, n = !1, o = !1) { const s = { x: (0, a.YT)(e, "x", "cumsum") }, u = { axis: t, exclusive: n, reverse: o }; return r.T2.runKernel(i.nY8, s, u) } + }) + }, 1216: (e, t, n) => { + "use strict"; n.d(t, { R: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + depthToSpace_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = "NHWC") { const s = (0, a.YT)(e, "x", "depthToSpace", "float32"), u = "NHWC" === n ? s.shape[1] : s.shape[2], l = "NHWC" === n ? s.shape[2] : s.shape[3], c = "NHWC" === n ? s.shape[3] : s.shape[1]; o.vA(t > 1, (() => `blockSize should be > 1 for depthToSpace, but was: ${t}`)), o.vA(u * t >= 0, (() => `Negative dimension size caused by overflow when multiplying\n ${u} and ${t} for depthToSpace with input shape\n ${s.shape}`)), o.vA(l * t >= 0, (() => `Negative dimension size caused by overflow when multiplying\n ${l} and ${t} for depthToSpace with input shape\n ${s.shape}`)), o.vA(c % (t * t) == 0, (() => `Dimension size must be evenly divisible by ${t * t} but is ${c} for depthToSpace with input shape ${s.shape}`)); const h = { x: s }, d = { blockSize: t, dataFormat: n }; return r.T2.runKernel(i.TMz, h, d) } + }) + }, 676: (e, t, n) => { + "use strict"; n.d(t, { G: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(7195), u = n(929), l = n(2302); const c = (0, u.op)({ + depthwiseConv2d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, u, c = "NHWC", h = [1, 1], d) { const f = (0, a.YT)(e, "x", "depthwiseConv2d", "float32"), p = (0, a.YT)(t, "filter", "depthwiseConv2d", "float32"); let m = f, g = !1; 3 === f.rank && (g = !0, m = (0, l.t)(f, [1, f.shape[0], f.shape[1], f.shape[2]])), o.vA(4 === m.rank, (() => `Error in depthwiseConv2d: input must be rank 4, but got rank ${m.rank}.`)), o.vA(4 === p.rank, (() => `Error in depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`)); const y = "NHWC" === c ? m.shape[3] : m.shape[1]; o.vA(y === p.shape[2], (() => `Error in depthwiseConv2d: number of input channels (${y}) must match the inChannels dimension in filter ${p.shape[2]}.`)), s.s_("depthwiseConv2d", u, d); const b = { x: m, filter: p }, v = { strides: n, pad: u, dataFormat: c, dilations: h, dimRoundingMode: d }, x = r.T2.runKernel(i.tGH, b, v); return g ? (0, l.t)(x, [x.shape[1], x.shape[2], x.shape[3]]) : x } + }) + }, 1890: (e, t, n) => { + "use strict"; n.d(t, { x: () => s }); var r = n(1585), i = n(5441), a = n(929), o = n(2302); const s = (0, a.op)({ + depthwiseConv2dNativeBackpropFilter_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, a, s, u = [1, 1], l) { let c = e; 3 === e.rank && (c = (0, o.t)(e, [1, e.shape[0], e.shape[1], e.shape[2]])); let h = t; 3 === h.rank && (h = (0, o.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]])); const d = { x: c, dy: h }, f = { strides: a, pad: s, dimRoundingMode: l, dilations: u, filterShape: n }; return r.T2.runKernel(i.X$8, d, f) } + }) + }, 3134: (e, t, n) => { + "use strict"; n.d(t, { l: () => s }); var r = n(1585), i = n(5441), a = n(929), o = n(2302); const s = (0, a.op)({ + depthwiseConv2dNativeBackpropInput_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, a, s, u = [1, 1], l) { let c = t, h = !1; 3 === t.rank && (h = !0, c = (0, o.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]])); const d = { dy: c, filter: n }, f = { strides: a, pad: s, dimRoundingMode: l, dilations: u, inputShape: e }, p = r.T2.runKernel(i.nVu, d, f); return h ? (0, o.t)(p, [p.shape[1], p.shape[2], p.shape[3]]) : p } + }) + }, 3002: (e, t, n) => { + "use strict"; n.d(t, { X: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ + dilation2d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, s, l = [1, 1], c = "NHWC") { const h = (0, a.YT)(e, "x", "dilation2d"), d = (0, a.YT)(t, "filter", "dilation2d"); o.vA(3 === h.rank || 4 === h.rank, (() => `Error in dilation2d: input must be rank 3 or 4, but got rank ${h.rank}.`)), o.vA(3 === d.rank, (() => `Error in dilation2d: filter must be rank 3, but got rank ${d.rank}.`)), o.vA("NHWC" === c, (() => `Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${c}`)); let f = h, p = !1; 3 === h.rank && (f = (0, u.t)(h, [1, h.shape[0], h.shape[1], h.shape[2]]), p = !0), o.vA(f.shape[3] === d.shape[2], (() => `Error in dilation2d: input and filter must have the same depth: ${f.shape[3]} vs ${d.shape[2]}`)); const m = { x: f, filter: d }, g = { strides: n, pad: s, dilations: l }, y = r.T2.runKernel(i.jxD, m, g); return p ? (0, u.t)(y, [y.shape[1], y.shape[2], y.shape[3]]) : y } + }) + }, 9359: (e, t, n) => { + "use strict"; n.d(t, { y: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(8991); const u = (0, n(929).op)({ + div_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "div"), u = (0, o.YT)(t, "b", "div"); if ([n, u] = (0, a.makeTypesMatch)(n, u), "int32" === n.dtype && "int32" === u.dtype) return (0, s.w)(n, u); const l = { a: n, b: u }; return r.T2.runKernel(i.sDr, l, {}) } + }) + }, 919: (e, t, n) => { + "use strict"; n.d(t, { e: () => c }); var r = n(565), i = n(8189), a = n(9359), o = n(3020), s = n(929), u = n(2151), l = n(5537); const c = (0, s.op)({ + divNoNan_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, i.YT)(e, "a", "div"), s = (0, i.YT)(t, "b", "div");[n, s] = (0, r.makeTypesMatch)(n, s); const c = (0, a.y)(n, s), h = (0, l.P)(c), d = (0, o.L)(s, h); return (0, u._)(d, h, c) } + }) + }, 9759: (e, t, n) => { + "use strict"; n.d(t, { O: () => u }); var r = n(8189), i = n(5119), a = n(5703), o = n(929), s = n(2302); const u = (0, o.op)({ + dot_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, r.YT)(e, "t1", "dot"), o = (0, r.YT)(t, "t2", "dot"); i.vA(!(1 !== n.rank && 2 !== n.rank || 1 !== o.rank && 2 !== o.rank), (() => `Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${o.rank}.`)); const u = 1 === n.rank ? n.size : n.shape[1], l = 1 === o.rank ? o.size : o.shape[0]; if (i.vA(u === l, (() => `Error in dot: inner dimensions of inputs must match, but got ${u} and ${l}.`)), 1 === n.rank && 1 === o.rank) { const e = (0, s.t)(n, [1, -1]), t = (0, s.t)(o, [-1, 1]), r = (0, a.N)(e, t); return (0, s.t)(r, []) } if (1 === n.rank && 2 === o.rank) { const e = (0, s.t)(n, [1, -1]), t = (0, s.t)(o, [o.shape[0], o.shape[1]]), r = (0, a.N)(e, t); return (0, s.t)(r, [r.size]) } if (2 === n.rank && 1 === o.rank) { const e = (0, s.t)(o, [-1, 1]), t = (0, a.N)(n, e); return (0, s.t)(t, [t.size]) } { const e = (0, s.t)(o, [o.shape[0], o.shape[1]]); return (0, a.N)(n, e) } } + }) + }, 3416: (e, t, n) => { + "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + elu_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "elu", "float32") }; return r.T2.runKernel(i.Pah, t) } + }) + }, 3020: (e, t, n) => { + "use strict"; n.d(t, { L: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + equal_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "equal", "string_or_numeric"), u = (0, o.YT)(t, "b", "equal", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.BRl, l) } + }) + }, 5207: (e, t, n) => { + "use strict"; n.d(t, { Y: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(9809); const u = (0, n(929).op)({ + erf_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { let t = (0, a.YT)(e, "x", "erf"); o.vA("int32" === t.dtype || "float32" === t.dtype, (() => "Input dtype must be `int32` or `float32`.")), "int32" === t.dtype && (t = (0, s.w)(t, "float32")); const n = { x: t }; return r.T2.runKernel(i._s9, n) } + }) + }, 4881: (e, t, n) => { + "use strict"; n.d(t, { p: () => i }); var r = n(2596); const i = (0, n(929).op)({ + euclideanNorm_: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { return (0, r.x)(e, "euclidean", t, n) } + }) + }, 8631: (e, t, n) => { + "use strict"; n.d(t, { o: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + exp_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "exp") }; return r.T2.runKernel(i.ox3, t) } + }) + }, 8710: (e, t, n) => { + "use strict"; n.d(t, { U: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + expandDims_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = (0, a.YT)(e, "x", "expandDims", "string_or_numeric"); o.vA(t <= n.rank, (() => "Axis must be <= rank of the tensor")); const s = { input: n }, u = { dim: t }; return r.T2.runKernel(i.ybN, s, u) } + }) + }, 517: (e, t, n) => { + "use strict"; n.d(t, { I: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + expm1_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "expm1") }; return r.T2.runKernel(i.ybj, t) } + }) + }, 6111: (e, t, n) => { + "use strict"; n.d(t, { G: () => o }); var r = n(1585), i = n(5441), a = n(5119); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function o(e, t, n) { (0, a.SA)(e); const o = { shape: e, value: t, dtype: n = n || (0, a.X$)(t) }; return r.T2.runKernel(i.SQl, {}, o) } + }, 5606: (e, t, n) => { + "use strict"; n.d(t, { R: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + floor_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "floor", "float32") }; return r.T2.runKernel(i.ZgB, t) } + }) + }, 8991: (e, t, n) => { + "use strict"; n.d(t, { w: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + floorDiv_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "floorDiv"), s = (0, o.YT)(t, "b", "floorDiv");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.ElG, u) } + }) + }, 8646: (e, t, n) => { + "use strict"; n.d(t, { Do: () => m, XB: () => p, f2: () => g, zE: () => y }); var r = n(2198), i = n(3416), a = n(6919), o = n(9258), s = n(4394), u = n(112), l = n(3732), c = n(2302), h = n(8968), d = n(700), f = n(3791); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function p(e, t, n) { if (null == n || "linear" === n) return e; if ("relu" === n) return (0, o.l)(e, (0, d.P)(t)); throw new Error(`Cannot compute gradient for fused activation ${n}.`) } function m(e, t) { let n = t; const i = r.getReductionAxes(e.shape, t.shape); return i.length > 0 && (n = (0, f.c)(n, i)), (0, c.t)(n, e.shape) } function g(e, t, n, r) { if ("linear" === t) return e; if ("relu" === t) return (0, u.V)(e); if ("elu" === t) return (0, i.P)(e); if ("relu6" === t) return (0, l.j)(e); if ("prelu" === t) return (0, s.N)(e, n); if ("leakyrelu" === t) return (0, a.H)(e, r); if ("sigmoid" === t) return (0, h.r)(e); throw new Error(`Unknown fused activation ${t}.`) } const y = (e, t) => !(e > 0) || "linear" === t + }, 8229: (e, t, n) => { + "use strict"; n.d(t, { k: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + gather_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = 0, o = 0) { const s = { x: (0, a.YT)(e, "x", "gather"), indices: (0, a.YT)(t, "indices", "gather", "int32") }, u = { axis: n, batchDims: o }; return r.T2.runKernel(i.mxL, s, u) } + }) + }, 2058: (e, t, n) => { + "use strict"; n.d(t, { r: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + greater_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "greater", "string_or_numeric"), u = (0, o.YT)(t, "b", "greater", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.XhZ, l) } + }) + }, 3337: (e, t, n) => { + "use strict"; n.d(t, { D: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + greaterEqual_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "greaterEqual", "string_or_numeric"), u = (0, o.YT)(t, "b", "greaterEqual", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.lLS, l) } + }) + }, 5040: (e, t, n) => { + "use strict"; n.d(t, { n: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + imag_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { input: (0, a.YT)(e, "input", "imag") }; return r.T2.runKernel(i.dv8, t) } + }) + }, 4711: (e, t, n) => { + "use strict"; n.d(t, { v: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ + resizeBilinear_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = !1, s = !1) { const l = (0, a.YT)(e, "images", "resizeBilinear"); o.vA(3 === l.rank || 4 === l.rank, (() => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${l.rank}.`)), o.vA(2 === t.length, (() => `Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)), o.vA(!1 === s || !1 === n, (() => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.")); let c = l, h = !1; 3 === l.rank && (h = !0, c = (0, u.t)(l, [1, l.shape[0], l.shape[1], l.shape[2]])); const [] = t, d = { images: c }, f = { alignCorners: n, halfPixelCenters: s, size: t }, p = r.T2.runKernel(i.hgw, d, f); return h ? (0, u.t)(p, [p.shape[1], p.shape[2], p.shape[3]]) : p } + }) + }, 2954: (e, t, n) => { + "use strict"; n.d(t, { b: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ + resizeNearestNeighbor_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = !1, s = !1) { const l = (0, a.YT)(e, "images", "resizeNearestNeighbor"); o.vA(3 === l.rank || 4 === l.rank, (() => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${l.rank}.`)), o.vA(2 === t.length, (() => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)), o.vA("float32" === l.dtype || "int32" === l.dtype, (() => "`images` must have `int32` or `float32` as dtype")), o.vA(!1 === s || !1 === n, (() => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.")); let c = l, h = !1; 3 === l.rank && (h = !0, c = (0, u.t)(l, [1, l.shape[0], l.shape[1], l.shape[2]])); const [] = t, d = { images: c }, f = { alignCorners: n, halfPixelCenters: s, size: t }, p = r.T2.runKernel(i.jOE, d, f); return h ? (0, u.t)(p, [p.shape[1], p.shape[2], p.shape[3]]) : p } + }) + }, 8318: (e, t, n) => { + "use strict"; n.d(t, { M: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + isFinite_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "isFinite") }; return r.T2.runKernel(i.gIW, t) } + }) + }, 3454: (e, t, n) => { + "use strict"; n.d(t, { E: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + isInf_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "isInf") }; return r.T2.runKernel(i.E3$, t) } + }) + }, 6300: (e, t, n) => { + "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + isNaN_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "isNaN") }; return r.T2.runKernel(i.iPs, t) } + }) + }, 6919: (e, t, n) => { + "use strict"; n.d(t, { H: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + leakyRelu_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = .2) { const n = { x: (0, a.YT)(e, "x", "leakyRelu") }, o = { alpha: t }; return r.T2.runKernel(i.X0$, n, o) } + }) + }, 1303: (e, t, n) => { + "use strict"; n.d(t, { M: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + less_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "less", "string_or_numeric"), u = (0, o.YT)(t, "b", "less", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.mIA, l) } + }) + }, 6508: (e, t, n) => { + "use strict"; n.d(t, { I: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + lessEqual_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "lessEqual", "string_or_numeric"), u = (0, o.YT)(t, "b", "lessEqual", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.CwD, l) } + }) + }, 3531: (e, t, n) => { + "use strict"; n.d(t, { K: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ + localResponseNormalization_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 5, n = 1, s = 1, l = .5) { const c = (0, a.YT)(e, "x", "localResponseNormalization"); o.vA(4 === c.rank || 3 === c.rank, (() => `Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${c.rank}.`)), o.vA(o.E6(t), (() => `Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`)); let h = c, d = !1; 3 === c.rank && (d = !0, h = (0, u.t)(c, [1, c.shape[0], c.shape[1], c.shape[2]])); const f = { x: h }, p = { depthRadius: t, bias: n, alpha: s, beta: l }, m = r.T2.runKernel(i.jM4, f, p); return d ? (0, u.t)(m, [m.shape[1], m.shape[2], m.shape[3]]) : m } + }) + }, 4010: (e, t, n) => { + "use strict"; n.d(t, { R: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + log_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "log", "float32") }; return r.T2.runKernel(i.tG8, t) } + }) + }, 2015: (e, t, n) => { + "use strict"; n.d(t, { K: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + log1p_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "log1p") }; return r.T2.runKernel(i.Cg$, t) } + }) + }, 5645: (e, t, n) => { + "use strict"; n.d(t, { n: () => c }); var r = n(1830), i = n(8189), a = n(9258), o = n(6522), s = n(929), u = n(8968), l = n(6030); const c = (0, s.op)({ + logSigmoid_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, i.YT)(e, "x", "logSigmoid"); return (0, r._X)((e => ({ value: (0, o.H)((0, l.l)((0, o.H)(e))), gradFunc: t => (0, a.l)(t, (0, u.r)((0, o.H)(e))) })))(t) } + }) + }, 7991: (e, t, n) => { + "use strict"; n.d(t, { H: () => f }); var r = n(1830), i = n(8189), a = n(9809), o = n(8631), s = n(4010), u = n(1938), l = n(9258), c = n(929), h = n(7126), d = n(3791); const f = (0, c.op)({ + logSoftmax_: + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = -1) { const n = (0, i.YT)(e, "logits", "logSoftmax"); if (-1 === t && (t = n.rank - 1), t !== n.rank - 1) throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`); return (0, r._X)(((e, n) => { const r = (0, u.T)(e, t, !0), i = (0, h.j)(e, r), c = (0, h.j)((0, a.w)(i, "float32"), (0, s.R)((0, d.c)((0, o.o)(i), t, !0))); n([c]); return { value: c, gradFunc: (e, n) => { const [r] = n, i = (0, o.o)(r); return (0, h.j)(e, (0, l.l)((0, d.c)(e, t, !0), i)) } } }))(n) } + }) + }, 3330: (e, t, n) => { + "use strict"; n.d(t, { V: () => p }); var r = n(8189), i = n(5119), a = n(7523), o = n(1078), s = n(8631), u = n(4010), l = n(1938), c = n(929), h = n(2302), d = n(7126), f = n(3791); const p = (0, c.op)({ + logSumExp_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { const c = (0, r.YT)(e, "x", "logSumExp"), p = (0, i.Y6)(t, c.shape), m = (0, l.T)(c, p, !0), g = (0, d.j)(c, m), y = (0, s.o)(g), b = (0, f.c)(y, p), v = (0, u.R)(b), x = (0, a.W)((0, h.t)(m, v.shape), v); if (n) { const e = (0, o.SM)(x.shape, p); return (0, h.t)(x, e) } return x } + }) + }, 3789: (e, t, n) => { + "use strict"; n.d(t, { n: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(2198); const s = (0, n(929).op)({ + logicalAnd_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, a.YT)(e, "a", "logicalAnd", "bool"), s = (0, a.YT)(t, "b", "logicalAnd", "bool"); (0, o.assertAndGetBroadcastShape)(n.shape, s.shape); const u = { a: n, b: s }; return r.T2.runKernel(i.RUm, u) } + }) + }, 9881: (e, t, n) => { + "use strict"; n.d(t, { N: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + logicalNot_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "logicalNot", "bool") }; return r.T2.runKernel(i.nZd, t) } + }) + }, 9879: (e, t, n) => { + "use strict"; n.d(t, { z: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(2198); const s = (0, n(929).op)({ + logicalOr_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, a.YT)(e, "a", "logicalOr", "bool"), s = (0, a.YT)(t, "b", "logicalOr", "bool"); (0, o.assertAndGetBroadcastShape)(n.shape, s.shape); const u = { a: n, b: s }; return r.T2.runKernel(i.LXA, u) } + }) + }, 9925: (e, t, n) => { + "use strict"; n.d(t, { r: () => u }); var r = n(8189), i = n(2198), a = n(3789), o = n(9881), s = n(9879); const u = (0, n(929).op)({ + logicalXor_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, r.YT)(e, "a", "logicalXor", "bool"), u = (0, r.YT)(t, "b", "logicalXor", "bool"); return (0, i.assertAndGetBroadcastShape)(n.shape, u.shape), (0, a.n)((0, s.z)(e, t), (0, o.N)((0, a.n)(e, t))) } + }) + }, 4703: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var r; n.d(t, { i: () => r }), function (e) { e[e.NONE = 0] = "NONE", e[e.MEAN = 1] = "MEAN", e[e.SUM = 2] = "SUM", e[e.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS" }(r || (r = {})) + }, 5703: (e, t, n) => { + "use strict"; n.d(t, { N: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + matMul_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = !1, s = !1) { let u = (0, o.YT)(e, "a", "matMul"), l = (0, o.YT)(t, "b", "matMul");[u, l] = (0, a.makeTypesMatch)(u, l); const c = { a: u, b: l }, h = { transposeA: n, transposeB: s }; return r.T2.runKernel(i.jAQ, c, h) } + }) + }, 1938: (e, t, n) => { + "use strict"; n.d(t, { T: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + max_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "max") }, s = { reductionIndices: t, keepDims: n }; return r.T2.runKernel(i.VAI, o, s) } + }) + }, 6999: (e, t, n) => { + "use strict"; n.d(t, { j: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(7195), u = n(929), l = n(2302); const c = (0, u.op)({ + maxPool_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, u, c) { const h = (0, a.YT)(e, "x", "maxPool"); let d = h, f = !1; 3 === h.rank && (f = !0, d = (0, l.t)(h, [1, h.shape[0], h.shape[1], h.shape[2]])), o.vA(4 === d.rank, (() => `Error in maxPool: input must be rank 4 but got rank ${d.rank}.`)), o.vA(s.G0(n, 1), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)), s.s_("maxPool", u, c); const p = { x: d }, m = { filterSize: t, strides: n, pad: u, dimRoundingMode: c }, g = r.T2.runKernel(i.t3d, p, m); return f ? (0, l.t)(g, [g.shape[1], g.shape[2], g.shape[3]]) : g } + }) + }, 178: (e, t, n) => { + "use strict"; n.d(t, { P: () => l }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198), u = n(9809); const l = (0, n(929).op)({ + maximum_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "maximum"), l = (0, o.YT)(t, "b", "maximum");[n, l] = (0, a.makeTypesMatch)(n, l), "bool" === n.dtype && (n = (0, u.w)(n, "int32"), l = (0, u.w)(l, "int32")), (0, s.assertAndGetBroadcastShape)(n.shape, l.shape); const c = { a: n, b: l }; return r.T2.runKernel(i.LDN, c) } + }) + }, 2611: (e, t, n) => { + "use strict"; n.d(t, { i: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + mean_: + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "mean") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.g5A, o, s) } + }) + }, 7436: (e, t, n) => { + "use strict"; n.d(t, { j: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + min_: + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "min") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.lNG, o, s) } + }) + }, 2644: (e, t, n) => { + "use strict"; n.d(t, { B: () => l }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198), u = n(9809); const l = (0, n(929).op)({ + minimum_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "minimum"), l = (0, o.YT)(t, "b", "minimum");[n, l] = (0, a.makeTypesMatch)(n, l), "bool" === n.dtype && (n = (0, u.w)(n, "int32"), l = (0, u.w)(l, "int32")), (0, s.assertAndGetBroadcastShape)(n.shape, l.shape); const c = { a: n, b: l }; return r.T2.runKernel(i.LG0, c) } + }) + }, 6567: (e, t, n) => { + "use strict"; n.d(t, { F: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + mirrorPad_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { o.vA("reflect" === n || "symmetric" === n, (() => `Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`)); const s = (0, a.YT)(e, "x", "mirrorPad"); if (0 === s.rank) throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad"); o.vA(t.length === s.rank, (() => `Padding doesn't match input. Must be ${s.rank}. Got ${t.length}.`)); const u = "reflect" === n ? 1 : 0; for (let e = 0; e < s.rank; e++)o.vA(2 === t[e].length, (() => "Invalid number of paddings. Must be length of 2 each.")), o.vA(t[e][0] >= 0 && t[e][0] <= s.shape[e] - u && t[e][1] >= 0 && t[e][1] <= s.shape[e] - u, (() => `Padding in dimension ${e} cannot be greater than or equal to ${s.shape[e] - u} or less than 0 for input of shape ${s.shape}`)); const l = { paddings: t, mode: n }, c = { x: s }; return r.T2.runKernel(i.x7F, c, l) } + }) + }, 152: (e, t, n) => { + "use strict"; n.d(t, { z: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + mod_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "mod"), s = (0, o.YT)(t, "b", "mod");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.BLA, u) } + }) + }, 9258: (e, t, n) => { + "use strict"; n.d(t, { l: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + mul_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "mul"), s = (0, o.YT)(t, "b", "mul");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.xu7, u) } + }) + }, 6522: (e, t, n) => { + "use strict"; n.d(t, { H: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + neg_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "neg") }; return r.T2.runKernel(i.l0G, t) } + }) + }, 2596: (e, t, n) => { + "use strict"; n.d(t, { x: () => y }); var r = n(8189), i = n(5119), a = n(4888), o = n(1078), s = n(1938), u = n(7436), l = n(929), c = n(8990), h = n(2302), d = n(5702), f = n(9348), p = n(5793), m = n(3791); function g(e, t, n = null) { if (0 === e.rank) return (0, a.t)(e); if (1 !== e.rank && null === n) return g((0, h.t)(e, [-1]), t, n); if (1 === e.rank || "number" == typeof n || Array.isArray(n) && 1 === n.length) { if (1 === t) return (0, m.c)((0, a.t)(e), n); if (t === 1 / 0) return (0, s.T)((0, a.t)(e), n); if (t === -1 / 0) return (0, u.j)((0, a.t)(e), n); if ("euclidean" === t || 2 === t) return (0, f.R)((0, m.c)((0, c.n)((0, a.t)(e), (0, d.d)(2, "int32")), n)); throw new Error(`Error in norm: invalid ord value: ${t}`) } if (Array.isArray(n) && 2 === n.length) { if (1 === t) return (0, s.T)((0, m.c)((0, a.t)(e), n[0]), n[1] - 1); if (t === 1 / 0) return (0, s.T)((0, m.c)((0, a.t)(e), n[1]), n[0]); if (t === -1 / 0) return (0, u.j)((0, m.c)((0, a.t)(e), n[1]), n[0]); if ("fro" === t || "euclidean" === t) return (0, f.R)((0, m.c)((0, p.E)(e), n)); throw new Error(`Error in norm: invalid ord value: ${t}`) } throw new Error(`Error in norm: invalid axis: ${n}`) } const y = (0, l.op)({ + norm_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = "euclidean", n = null, a = !1) { const s = g(e = (0, r.YT)(e, "x", "norm"), t, n); let u = s.shape; if (a) { const t = (0, i.Y6)(n, e.shape); u = o.SM(s.shape, t) } return (0, h.t)(s, u) } + }) + }, 2118: (e, t, n) => { + "use strict"; n.d(t, { E: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + notEqual_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "notEqual", "string_or_numeric"), u = (0, o.YT)(t, "b", "notEqual", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.ylV, l) } + }) + }, 1760: (e, t, n) => { + "use strict"; n.d(t, { M: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + oneHot_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = 1, o = 0, s = "int32") { if (t < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`); const u = { indices: (0, a.YT)(e, "indices", "oneHot", "int32") }, l = { dtype: s, depth: t, onValue: n, offValue: o }; return r.T2.runKernel(i.urI, u, l) } + }) + }, 1411: (e, t, n) => { + "use strict"; n.d(t, { S: () => s }); var r = n(1585), i = n(5119), a = n(7148), o = n(2855); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function s(e, t = "float32") { if ((0, i.SA)(e), "complex64" === t) { const t = s(e, "float32"), n = (0, o.U)(e, "float32"); return (0, a.f)(t, n) } const n = (0, i.FZ)((0, i.Ze)(e), t); return r.T2.makeTensor(n, e, t) } + }, 9885: (e, t, n) => { + "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + onesLike_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "onesLike") }; return r.T2.runKernel(i.LWX, t) } + }) + }, 929: (e, t, n) => { + "use strict"; n.d(t, { B: () => a, op: () => o }); var r = n(1585), i = n(5119); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const a = "__op"; function o(e) { const t = Object.keys(e); if (1 !== t.length) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`); let n = t[0]; const o = e[n]; n.endsWith("_") && (n = n.substring(0, n.length - 1)), n += a; const s = (...e) => { r.T2.startScope(n); try { const t = o(...e); return (0, i.yL)(t) && console.error("Cannot return a Promise inside of tidy."), r.T2.endScope(t), t } catch (e) { throw r.T2.endScope(null), e } }; return Object.defineProperty(s, "name", { value: n, configurable: !0 }), s } + }, 7270: (e, t, n) => { + "use strict"; n.d(t, { BTT: () => d.B, tnl: () => i.t, HQu: () => a.H, FqL: () => o.F, WQq: () => s.W, QiD: () => f, Q7R: () => p.Q, bzn: () => m.b, FLi: () => g.F, XRg: () => y.X, qRo: () => b.q, yHs: () => v.y, rYl: () => x.r, FPz: () => w.F, rfv: () => k.r, $jT: () => S.$, sub: () => T, lZX: () => $, $v7: () => O.$, BFc: () => z, kSi: () => P, T5N: () => B, GTe: () => R.G, HbZ: () => L, vjT: () => j, ftb: () => nr, ROE: () => U, hOW: () => W.h, ra8: () => V.r, wgE: () => _.w, mkO: () => G.m, zQh: () => H.z, o8B: () => q.o, faB: () => Y.f, xWs: () => E.x, I1m: () => X, RPU: () => K, O5O: () => Z, P1l: () => J, kA9: () => Q.k, Xtf: () => ee.X, wX9: () => te.w, IPL: () => ne, jIJ: () => ie, gnS: () => ae.g, yIG: () => oe.y, _jP: () => dr, Lp0: () => se.L, rCv: () => ue.r, aOp: () => le, Rj8: () => ce.R, Gl3: () => he.G, smy: () => de, X7t: () => fe.X, y4m: () => pe.y, ek5: () => me.e, Omf: () => ge.O, EZY: () => cr, _3C: () => ye, Pqc: () => be.P, FJY: () => hr, QP2: () => ve, LCg: () => xe.L, Y12: () => we.Y, p4S: () => ke.p, oNF: () => Se.o, UG6: () => _e.U, IYd: () => Ce.I, y5U: () => Te, hVP: () => wn.h, GSj: () => Ee.G, RIf: () => Ne.R, wh_: () => Ie.w, cZk: () => r, kgh: () => Me.k, SY9: () => lr, rhj: () => Fe.r, DQN: () => De.D, KGM: () => kn.K, ngS: () => $e.n, Slp: () => gi, U4u: () => fr, ggX: () => Sn.g, MIs: () => Re.M, EN4: () => Oe.E, yrW: () => ze.y, H8d: () => Pe.H, M7h: () => Be.M, InN: () => Le.I, mPL: () => yi, mT8: () => je, Kgs: () => Ue.K, Rm2: () => We.R, Kko: () => Ve.K, nqI: () => Ge.n, HPB: () => He.H, VZ: () => qe.V, n76: () => Ye.n, NSZ: () => Xe.N, ztW: () => Ke.z, rxB: () => Ze.r, YYh: () => bi, yzS: () => et, NoW: () => N.N, T9B: () => tt.T, jgi: () => nt.j, NYV: () => rt, RO: () => it, PhQ: () => at.P, i2o: () => ot.i, OYQ: () => lt, jkA: () => ct.j, BpO: () => ht.B, FFZ: () => dt.F, ziu: () => ft.z, Clk: () => yt, CRk: () => or, lKK: () => I.l, YDF: () => bt, OjQ: () => vt, HZy: () => xt.H, xbf: () => ir.x, Ec: () => wt.E, Mw0: () => kt.M, SaS: () => st.S, P61: () => St.P, op: () => d.op, X4o: () => _t, eVF: () => Ct.e, BZs: () => At, grY: () => Tt, XHu: () => Et, WLX: () => Nt, dzn: () => It.d, n7C: () => Mt.n, NsG: () => Ft.N, yyV: () => Dt.y, _eU: () => $t._, whe: () => Rt, iyU: () => Ot, Q0_: () => zt, _9M: () => Pt, pR9: () => Wt, FE$: () => Vt, m0H: () => Gt, YeY: () => Ht, HYA: () => qt, y17: () => Yt, xav: () => Xt.x, VOZ: () => Kt.V, VVh: () => Zt.V, j__: () => Jt.j, tQQ: () => A.t, BEg: () => Qt.B, QD2: () => en, LMr: () => tn, I2l: () => nn, JYU: () => rn, z8$: () => _n.z, LIG: () => an.L, Z$r: () => on.Z, d_2: () => sn.d, NFr: () => sr, sZg: () => Qe, WfX: () => un.W, wdz: () => ln.w, F12: () => cn, ry7: () => M.r, _SZ: () => hn._, vPA: () => mi, F8e: () => dn.F, L0l: () => fn.L, dik: () => F.d, Q$M: () => pn, zAd: () => mn, wck: () => gn, R0O: () => yn, Vs9: () => bn.V, lw0: () => vn.l, eDJ: () => xn.e, lMo: () => vi, Zhr: () => ur, lOn: () => pi, lDo: () => Cn.l, RZD: () => An.R, EwI: () => mt.E, Pbu: () => Tn.P, r2V: () => En.r, t$z: () => Nn.t, PMw: () => In.P, Ym9: () => Mn.Y, YjP: () => xi, jbE: () => gt.j, czq: () => Fn.c, Mlm: () => Dn.M, ymU: () => D.y, OEK: () => $n.O, tGX: () => On, KtR: () => zn, $_$: () => Pn.$, g9W: () => Bn, Lpo: () => Ln, yxw: () => jn, NNh: () => Wn, Vsq: () => Ae.V, rfw: () => Vn.r, mgz: () => rr.m, efE: () => Gn, AmM: () => Hn.A, zAU: () => qn.z, K$i: () => Yn.K, rni: () => Xn, bvq: () => Kn, _M9: () => Zn._, YJN: () => Qn, Ul9: () => er.U, POl: () => tr.P }); var r = {}; n.r(r), n.d(r, { conv2d: () => vr, depthwiseConv2d: () => kr, matMul: () => Sr }); var i = n(4888), a = n(2804), o = n(7558), s = n(7523), u = n(1585), l = n(5441), c = n(8189), h = n(5119), d = n(929); const f = (0, d.op)({ + addN_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { h.vA(Array.isArray(e), (() => "The argument passed to tf.addN() must be a list of tensors")), h.vA(e.length >= 1, (() => `Must pass at least one tensor to tf.addN(), but got ${e.length}`)); const t = e.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "addN"))), n = t[0]; t.forEach((e => { if (e.dtype !== n.dtype) throw new Error("All tensors passed to tf.addN() must have the same dtype") })), t.forEach((e => { if (!h.r1(e.shape, n.shape)) throw new Error("All tensors passed to tf.addN() must have the same shape") })); const r = t; return u.T2.runKernel(l.EkD, r) } + }); var p = n(2307), m = n(9326), g = n(897), y = n(4339), b = n(6841), v = n(269), x = n(9580), w = n(1404), k = n(3774), S = n(3909), _ = n(9809), C = n(7195), A = n(2302); const T = (0, d.op)({ + avgPool3d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i, a = "NDHWC") { const o = (0, c.YT)(e, "x", "avgPool3d", "float32"); let s = o, d = !1; 4 === o.rank && (d = !0, s = (0, A.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]])), h.vA(5 === s.rank, (() => `Error in avgPool3d: x must be rank 5 but got rank ${s.rank}.`)), h.vA("NDHWC" === a, (() => `Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`)), h.vA("number" == typeof n && n > 0 || Array.isArray(n) && n[0] > 0 && n[1] > 0 && n[2] > 0, (() => `Error in avgPool3d: Stride must be > 0, but got '${n}'`)), (0, C.s_)("avgPool3d", r, i); const f = { x: s }, p = { filterSize: t, strides: n, pad: r, dimRoundingMode: i, dataFormat: a }; let m = u.T2.runKernel(l.cS, f, p); return m = (0, _.w)(m, s.dtype), d ? (0, A.t)(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m } + }); var E = n(5030), N = n(5703), I = n(9258), M = n(8968), F = n(7986), D = n(7311); const $ = (0, d.op)({ + basicLSTMCell_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "forgetBias", "basicLSTMCell"), u = (0, c.YT)(t, "lstmKernel", "basicLSTMCell"), l = (0, c.YT)(n, "lstmBias", "basicLSTMCell"), h = (0, c.YT)(r, "data", "basicLSTMCell"), d = (0, c.YT)(i, "c", "basicLSTMCell"), f = (0, c.YT)(a, "h", "basicLSTMCell"), p = (0, E.x)([h, f], 1), m = (0, N.N)(p, u), g = (0, s.W)(m, l), y = g.shape[0], b = g.shape[1] / 4, v = [y, b], x = (0, F.d)(g, [0, 0], v), w = (0, F.d)(g, [0, b], v), k = (0, F.d)(g, [0, 2 * b], v), S = (0, F.d)(g, [0, 3 * b], v), _ = (0, s.W)((0, I.l)((0, M.r)(x), (0, D.y)(w)), (0, I.l)(d, (0, M.r)((0, s.W)(o, k)))); return [_, (0, I.l)((0, D.y)(_), (0, M.r)(S))] } + }); var R = n(9772), O = n(9160); const z = (0, d.op)({ batchNorm2d_: function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "x", "batchNorm"), s = (0, c.YT)(t, "mean", "batchNorm"), u = (0, c.YT)(n, "variance", "batchNorm"); let l, d; return null != i && (l = (0, c.YT)(i, "scale", "batchNorm")), null != r && (d = (0, c.YT)(r, "offset", "batchNorm")), h.vA(2 === o.rank, (() => `Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`)), h.vA(2 === s.rank || 1 === s.rank, (() => `Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${s.rank}.`)), h.vA(2 === u.rank || 1 === u.rank, (() => `Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)), null != l && h.vA(2 === l.rank || 1 === l.rank, (() => `Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)), null != d && h.vA(2 === d.rank || 1 === d.rank, (() => `Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${d.rank}.`)), (0, O.$)(o, s, u, d, l, a) } }); const P = (0, d.op)({ batchNorm3d_: function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "x", "batchNorm"), s = (0, c.YT)(t, "mean", "batchNorm"), u = (0, c.YT)(n, "variance", "batchNorm"); let l, d; return null != i && (l = (0, c.YT)(i, "scale", "batchNorm")), null != r && (d = (0, c.YT)(r, "offset", "batchNorm")), h.vA(3 === o.rank, (() => `Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`)), h.vA(3 === s.rank || 1 === s.rank, (() => `Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${s.rank}.`)), h.vA(3 === u.rank || 1 === u.rank, (() => `Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)), null != l && h.vA(3 === l.rank || 1 === l.rank, (() => `Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)), null != d && h.vA(3 === d.rank || 1 === d.rank, (() => `Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${d.rank}.`)), (0, O.$)(o, s, u, d, l, a) } }); const B = (0, d.op)({ batchNorm4d_: function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "x", "batchNorm"), s = (0, c.YT)(t, "mean", "batchNorm"), u = (0, c.YT)(n, "variance", "batchNorm"); let l, d; return null != i && (l = (0, c.YT)(i, "scale", "batchNorm")), null != r && (d = (0, c.YT)(r, "offset", "batchNorm")), h.vA(4 === o.rank, (() => `Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`)), h.vA(4 === s.rank || 1 === s.rank, (() => `Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${s.rank}.`)), h.vA(4 === u.rank || 1 === u.rank, (() => `Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)), null != l && h.vA(4 === l.rank || 1 === l.rank, (() => `Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)), null != d && h.vA(4 === d.rank || 1 === d.rank, (() => `Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${d.rank}.`)), (0, O.$)(o, s, u, d, l, a) } }); const L = (0, d.op)({ + bincount_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "x", "bincount"), i = (0, c.YT)(t, "weights", "bincount"); h.vA("int32" === r.dtype, (() => `Error in bincount: input dtype must be int32, but got ${r.dtype}`)), h.vA(n >= 0, (() => `size must be non-negative, but got ${n}.`)), h.vA(i.size === r.size || 0 === i.size, (() => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${i.shape}.`)); const a = { x: r, weights: i }, o = { size: n }; return u.T2.runKernel(l.N4F, a, o) } + }); const j = (0, d.op)({ + bitwiseAnd_: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "x", "bitwiseAnd"), r = (0, c.YT)(t, "y", "bitwiseAnd"); if (!(0, h.r1)(n.shape, r.shape)) throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${n.shape}, y: ${r.shape}`); if ("int32" !== n.dtype || "int32" !== r.dtype) throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${n.dtype} and type of y: ${r.dtype}`); const i = { a: n, b: r }; return u.T2.runKernel(l.HNs, i) } + }); const U = (0, d.op)({ + broadcastArgs_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "s0", "broadcastArgs", "int32"), r = (0, c.YT)(t, "s1", "broadcastArgs", "int32"); if (1 !== n.rank) throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`); if (1 !== r.rank) throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`); const i = { s0: n, s1: r }; return u.T2.runKernel(l.vj7, i) } + }); var W = n(3567), V = n(448), G = n(855), H = n(6928), q = n(125), Y = n(7148); const X = (0, d.op)({ concat1d_: function (e) { return (0, E.x)(e, 0) } }); const K = (0, d.op)({ concat2d_: function (e, t) { return (0, E.x)(e, t) } }); const Z = (0, d.op)({ concat3d_: function (e, t) { return (0, E.x)(e, t) } }); const J = (0, d.op)({ concat4d_: function (e, t) { return (0, E.x)(e, t) } }); var Q = n(3701), ee = n(8794), te = n(1106); const ne = (0, d.op)({ + conv3d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i = "NDHWC", a = [1, 1, 1]) { const o = (0, c.YT)(e, "x", "conv3d"), s = (0, c.YT)(t, "filter", "conv3d"); let d = o, f = !1; 4 === o.rank && (f = !0, d = (0, A.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]])), h.vA(5 === d.rank, (() => `Error in conv3d: input must be rank 5, but got rank ${d.rank}.`)), h.vA(5 === s.rank, (() => `Error in conv3d: filter must be rank 5, but got rank ${s.rank}.`)), h.vA(d.shape[4] === s.shape[3], (() => `Error in conv3d: depth of input (${d.shape[4]}) must match input depth for filter ${s.shape[3]}.`)), h.vA((0, C.G0)(n, a), (() => `Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`)), h.vA("NDHWC" === i, (() => `Error in conv3d: got dataFormat of ${i} but only NDHWC is currently supported.`)), h.vA((0, C.qk)(a), (() => "Error in conv3D: Dilated rates should be larger than 0.")), h.vA((0, C.qk)(n), (() => "Error in conv3D: Strides should be larger than 0.")); const p = { x: d, filter: s }, m = { strides: n, pad: r, dataFormat: i, dilations: a }, g = u.T2.runKernel(l.A1h, p, m); return f ? (0, A.t)(g, [g.shape[1], g.shape[2], g.shape[3], g.shape[4]]) : g } + }); var re = n(1895); const ie = (0, d.op)({ conv3dTranspose_: function (e, t, n, r, i) { const a = (0, c.YT)(e, "x", "conv3dTranspose"), o = (0, c.YT)(t, "filter", "conv3dTranspose"); return (0, re.c)(n, a, o, r, i) } }); var ae = n(9907), oe = n(7451), se = n(302), ue = n(6808); const le = (0, d.op)({ + denseBincount_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = !1) { const i = (0, c.YT)(e, "x", "denseBincount"), a = (0, c.YT)(t, "weights", "denseBincount"); h.vA("int32" === i.dtype, (() => `Error in denseBincount: input dtype must be int32, but got ${i.dtype}`)), h.vA(i.rank <= 2, (() => `Error in denseBincount: input must be at most rank 2, but got rank ${i.rank}.`)), h.vA(n >= 0, (() => `size must be non-negative, but got ${n}.`)), h.vA(a.size === i.size || 0 === a.size, (() => `Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${i.shape}, weights shape: ${a.shape}.`)); const o = { x: i, weights: a }, s = { size: n, binaryOutput: r }; return u.T2.runKernel(l.wNW, o, s) } + }); var ce = n(1216), he = n(676); const de = (0, d.op)({ + diag_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, c.YT)(e, "x", "diag") }; return u.T2.runKernel(l.ORI, t) } + }); var fe = n(3002), pe = n(9359), me = n(919), ge = n(9759); const ye = (0, d.op)({ + einsum_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, ...t) { const n = t.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "einsum"))), r = { equation: e }; return u.T2.runKernel(l.Qgm, n, r) } + }); var be = n(3416); const ve = (0, d.op)({ + ensureShape_: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "x", "ensureShape", "string_or_numeric"); if (!(0, h.e_)(n.shape, t)) throw new Error(`EnsureShape: Shape of tensor ${n.shape} is not compatible with expected shape ${t}`); return e } + }); var xe = n(3020), we = n(5207), ke = n(4881), Se = n(8631), _e = n(8710), Ce = n(517), Ae = n(4826); const Te = (0, d.op)({ + eye_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = "float32") { null == t && (t = e); const i = (0, V.r)([e, t], r), a = e <= t ? e : t; for (let e = 0; e < a; ++e)i.set(1, e, e); const o = (0, A.t)(i.toTensor(), [e, t]); if (null == n) return o; if (1 === n.length) return (0, Ae.V)((0, _e.U)(o, 0), [n[0], 1, 1]); if (2 === n.length) return (0, Ae.V)((0, _e.U)((0, _e.U)(o, 0), 0), [n[0], n[1], 1, 1]); if (3 === n.length) return (0, Ae.V)((0, _e.U)((0, _e.U)((0, _e.U)(o, 0), 0), 0), [n[0], n[1], n[2], 1, 1]); throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`) } + }); var Ee = n(6111), Ne = n(5606), Ie = n(8991), Me = n(8229), Fe = n(2058), De = n(3337), $e = n(5040), Re = n(8318), Oe = n(3454), ze = n(6300), Pe = n(6919), Be = n(1303), Le = n(6508); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function je(e, t, n) { if (n <= 0) throw new Error("The number of values should be positive."); const r = { start: e, stop: t, num: n }; return u.T2.runKernel(l.mnI, {}, r) } var Ue = n(3531), We = n(4010), Ve = n(2015), Ge = n(5645), He = n(7991), qe = n(3330), Ye = n(3789), Xe = n(9881), Ke = n(9879), Ze = n(9925); + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Je = 2147483648; const Qe = (0, d.op)({ searchSorted_: function (e, t, n = "left") { const r = (0, c.YT)(e, "sortedSequence", "searchSorted"), i = (0, c.YT)(t, "values", "searchSorted"), a = r.shape[r.shape.length - 1], o = i.shape[i.shape.length - 1], s = (0, A.t)(r, [-1, a]), d = (0, A.t)(i, [-1, o]); if (s.rank < 2) throw new Error("Sorted input argument must be at least 2-dimensional"); if (s.shape[0] !== d.shape[0]) throw new Error("Leading dimension of 'sortedSequence' and 'values' must match."); if ((0, h.Ze)(d.shape) >= Je) throw new Error("values tensor size must less than 2147483648"); if (s.shape[1] >= Je) throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${s.shape[1]}`); const f = { sortedSequence: s, values: d }, p = { side: n }; return u.T2.runKernel(l.uWl, f, p) } }); + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function et(e, t) { return Qe(e, t, "left") } var tt = n(1938), nt = n(6999); const rt = (0, d.op)({ + maxPool3d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = [1, 1, 1], n, r, i, a = "NDHWC") { const o = (0, c.YT)(e, "x", "maxPool3d"); let s = o, d = !1; 4 === o.rank && (d = !0, s = (0, A.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]])), h.vA(5 === s.rank, (() => `Error in maxPool3d: x must be rank 5 but got rank ${s.rank}.`)), h.vA("NDHWC" === a, (() => `Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`)), (0, C.s_)("maxPool3d", r, i); const f = { x: s }, p = { filterSize: t, strides: n, pad: r, dimRoundingMode: i, dataFormat: a }, m = u.T2.runKernel(l.ySp, f, p); return d ? (0, A.t)(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m } + }); const it = (0, d.op)({ + maxPoolWithArgmax_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i = !1) { const a = { x: (0, c.YT)(e, "x", "maxPoolWithArgmax") }, o = { filterSize: t, strides: n, pad: r, includeBatchInIndex: i }, s = u.T2.runKernel(l.TL8, a, o); return { result: s[0], indexes: s[1] } } + }); var at = n(178), ot = n(2611), st = n(1411), ut = n(259); + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function lt(e, t, { indexing: n = "xy" } = {}) { if ("xy" !== n && "ij" !== n) throw new TypeError(`${n} is not a valid third argument to meshgrid`); if (void 0 === e) return []; let r = (0, c.YT)(e, "x", "meshgrid", e instanceof ut.qY ? e.dtype : "float32"); if (void 0 === t) return [r]; let i = (0, c.YT)(t, "y", "meshgrid", t instanceof ut.qY ? t.dtype : "float32"); const a = (0, h.Ze)(r.shape), o = (0, h.Ze)(i.shape); return "xy" === n ? (r = (0, A.t)(r, [1, -1]), i = (0, A.t)(i, [-1, 1]), [(0, N.N)((0, st.S)([o, 1], r.dtype), r), (0, N.N)(i, (0, st.S)([1, a], i.dtype))]) : (r = (0, A.t)(r, [-1, 1]), i = (0, A.t)(i, [1, -1]), [(0, N.N)(r, (0, st.S)([1, o], r.dtype)), (0, N.N)((0, st.S)([a, 1], i.dtype), i)]) } var ct = n(7436), ht = n(2644), dt = n(6567), ft = n(152), pt = n(1078), mt = n(5793), gt = n(7126); const yt = (0, d.op)({ + moments_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { e = (0, c.YT)(e, "x", "moments"); const r = (0, h.Y6)(t, e.shape), i = (0, ot.i)(e, r, n); let a = i.shape; n || (a = (0, pt.SM)(i.shape, r)); const o = (0, mt.E)((0, gt.j)((0, _.w)(e, "float32"), (0, A.t)(i, a))); return { mean: i, variance: (0, ot.i)(o, r, n) } } + }); const bt = (0, d.op)({ multiRNNCell_: function (e, t, n, r) { const i = (0, c.YT)(t, "data", "multiRNNCell"), a = (0, c.j1)(n, "c", "multiRNNCell"), o = (0, c.j1)(r, "h", "multiRNNCell"); let s = i; const u = []; for (let t = 0; t < e.length; t++) { const n = e[t](s, a[t], o[t]); u.push(n[0]), u.push(n[1]), s = n[1] } const l = [], h = []; for (let e = 0; e < u.length; e += 2)l.push(u[e]), h.push(u[e + 1]); return [l, h] } }); const vt = (0, d.op)({ + multinomial_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = !1) { const i = (0, c.YT)(e, "logits", "multinomial"), a = i.size, o = i.rank; if (a < 2) throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${a}.`); if (o > 2) throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`); n = n || Math.random(); const s = { logits: 1 === o ? (0, A.t)(i, [1, -1]) : i }, h = { numSamples: t, seed: n, normalized: r }, d = u.T2.runKernel(l.WT3, s, h); return 1 === o ? (0, A.t)(d, [d.size]) : d } + }); var xt = n(6522), wt = n(2118), kt = n(1760), St = n(9885); const _t = (0, d.op)({ outerProduct_: function (e, t) { const n = (0, c.YT)(e, "v1", "outerProduct"), r = (0, c.YT)(t, "v2", "outerProduct"); h.vA(1 === n.rank && 1 === r.rank, (() => `Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`)); const i = (0, A.t)(n, [-1, 1]), a = (0, A.t)(r, [1, -1]); return (0, N.N)(i, a) } }); var Ct = n(5661); const At = (0, d.op)({ pad1d_: function (e, t, n = 0) { return (0, h.vA)(2 === t.length, (() => "Invalid number of paddings. Must be length of 2.")), (0, Ct.e)(e, [t], n) } }); const Tt = (0, d.op)({ pad2d_: function (e, t, n = 0) { return (0, h.vA)(2 === t.length && 2 === t[0].length && 2 === t[1].length, (() => "Invalid number of paddings. Must be length of 2 each.")), (0, Ct.e)(e, t, n) } }); const Et = (0, d.op)({ pad3d_: function (e, t, n = 0) { return (0, h.vA)(3 === t.length && 2 === t[0].length && 2 === t[1].length && 2 === t[2].length, (() => "Invalid number of paddings. Must be length of 2 each.")), (0, Ct.e)(e, t, n) } }); const Nt = (0, d.op)({ pad4d_: function (e, t, n = 0) { return (0, h.vA)(4 === t.length && 2 === t[0].length && 2 === t[1].length && 2 === t[2].length && 2 === t[3].length, (() => "Invalid number of paddings. Must be length of 2 each.")), (0, Ct.e)(e, t, n) } }); var It = n(7872), Mt = n(8990), Ft = n(4394), Dt = n(5295), $t = n(7771); const Rt = (0, d.op)({ + raggedGather_: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { const i = { paramsNestedSplits: e.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "raggedGather", "int32"))), paramsDenseValues: (0, c.YT)(t, "paramsDenseValues", "raggedGather"), indices: (0, c.YT)(n, "indices", "raggedGather", "int32") }, a = { outputRaggedRank: r }, o = u.T2.runKernel(l.oJ2, i, a); return { outputNestedSplits: o.slice(0, o.length - 1), outputDenseValues: o[o.length - 1] } } + }); const Ot = (0, d.op)({ + raggedRange_: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "starts", "raggedRange"), i = { starts: r, limits: (0, c.YT)(t, "limits", "raggedRange", r.dtype), deltas: (0, c.YT)(n, "deltas", "raggedRange", r.dtype) }, a = u.T2.runKernel(l.CQC, i); return { rtNestedSplits: a[0], rtDenseValues: a[1] } } + }); const zt = (0, d.op)({ + raggedTensorToTensor_: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i) { const a = (0, c.YT)(e, "shape", "raggedTensorToTensor", "int32"), o = (0, c.YT)(t, "values", "raggedTensorToTensor"), s = { shape: a, values: o, defaultValue: (0, c.YT)(n, "defaultValue", "raggedTensorToTensor", o.dtype), rowPartitionTensors: r.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "raggedTensorToTensor", "int32"))) }, h = { rowPartitionTypes: i }; return u.T2.runKernel(l.mH5, s, h) } + }); const Pt = (0, d.op)({ + rand_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { (0, h.SA)(e); const r = (0, h.Ze)(e); let i = null; if (null == n || "float32" === n) i = new Float32Array(r); else if ("int32" === n) i = new Int32Array(r); else { if ("bool" !== n) throw new Error(`Unknown data type ${n}`); i = new Uint8Array(r) } for (let e = 0; e < r; e++)i[e] = t(); return u.T2.makeTensor(i, e, n) } + }); var Bt = n(7391); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Lt { constructor(e, t, n, r, i) { this.mean = e, this.stdDev = t, this.dtype = n, this.nextVal = NaN, this.truncated = r, this.truncated && (this.upper = this.mean + 2 * this.stdDev, this.lower = this.mean - 2 * this.stdDev); const a = i || Math.random(); this.random = Bt.alea(a.toString()) } nextValue() { if (!isNaN(this.nextVal)) { const e = this.nextVal; return this.nextVal = NaN, e } let e, t, n = !1; for (; !n;) { let r, i, a; do { r = 2 * this.random() - 1, i = 2 * this.random() - 1, a = r * r + i * i } while (a >= 1 || 0 === a); const o = Math.sqrt(-2 * Math.log(a) / a); e = this.mean + this.stdDev * r * o, t = this.mean + this.stdDev * i * o, this.truncated && !this.isValidTruncated(e) || (n = !0) } return this.truncated && !this.isValidTruncated(t) || (this.nextVal = this.convertValue(t)), this.convertValue(e) } convertValue(e) { return null == this.dtype || "float32" === this.dtype ? e : Math.round(e) } isValidTruncated(e) { return e <= this.upper && e >= this.lower } } class jt { constructor(e, t, n, r) { this.alpha = e, this.beta = 1 / t, this.dtype = n; const i = r || Math.random(); this.randu = Bt.alea(i.toString()), this.randn = new Lt(0, 1, n, !1, this.randu()), this.d = e < 1 ? e + 2 / 3 : e - 1 / 3, this.c = 1 / Math.sqrt(9 * this.d) } nextValue() { let e, t, n, r, i, a; for (; ;) { do { r = this.randn.nextValue(), a = 1 + this.c * r } while (a <= 0); if (a *= a * a, e = r * r, t = 1 - .331 * e * e, n = .5 * e + this.d * (1 - a + Math.log(a)), i = this.randu(), i < t || Math.log(i) < n) break } return a = 1 / this.beta * this.d * a, this.alpha < 1 && (a *= Math.pow(this.randu(), 1 / this.alpha)), this.convertValue(a) } convertValue(e) { return "float32" === this.dtype ? e : Math.round(e) } } class Ut { constructor(e = 0, t = 1, n, r) { if (this.canReturnFloat = () => null == this.dtype || "float32" === this.dtype, this.min = e, this.range = t - e, this.dtype = n, null == r && (r = Math.random()), "number" == typeof r && (r = r.toString()), !this.canReturnFloat() && this.range <= 1) throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`); this.random = Bt.alea(r) } convertValue(e) { return this.canReturnFloat() ? e : Math.round(e) } nextValue() { return this.convertValue(this.min + this.range * this.random()) } } const Wt = (0, d.op)({ + randomGamma_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = 1, r = "float32", i) { if ((0, h.SA)(e), null == n && (n = 1), null == r && (r = "float32"), "float32" !== r && "int32" !== r) throw new Error(`Unsupported data type ${r}`); const a = new jt(t, n, r, i), o = (0, V.r)(e, r); for (let e = 0; e < o.values.length; e++)o.values[e] = a.nextValue(); return o.toTensor() } + }); const Vt = (0, d.op)({ + randomNormal_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0, n = 1, r, i) { if ((0, h.SA)(e), null != r && "bool" === r) throw new Error(`Unsupported data type ${r}`); const a = new Lt(t, n, r, !1, i), o = (0, V.r)(e, r); for (let e = 0; e < o.values.length; e++)o.values[e] = a.nextValue(); return o.toTensor() } + }); const Gt = (0, d.op)({ + randomStandardNormal_: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { if (null != t && "bool" === t) throw new Error(`Unsupported data type ${t}`); return Vt(e, 0, 1, t, n) } + }); const Ht = (0, d.op)({ + randomUniform_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0, n = 1, r = "float32", i) { (0, h.SA)(e); const a = (0, V.r)(e, r), o = new Ut(t, n, null, i); for (let e = 0; e < a.values.length; e++)a.values[e] = o.nextValue(); return a.toTensor() } + }); const qt = (0, d.op)({ + randomUniformInt_: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { return Ht(e, t, n, "int32", r) } + }); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Yt(e, t, n = 1, r = "float32") { if (0 === n) throw new Error("Cannot have a step of zero"); const i = { start: e, stop: t, step: n, dtype: r }; return u.T2.runKernel(l.Q6t, {}, i) } var Xt = n(1902), Kt = n(9870), Zt = n(112), Jt = n(3732), Qt = n(3262); const en = (0, d.op)({ + reverse1d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, c.YT)(e, "x", "reverse"); return h.vA(1 === t.rank, (() => `Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)), (0, Qt.B)(t, 0) } + }); const tn = (0, d.op)({ + reverse2d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "x", "reverse"); return h.vA(2 === n.rank, (() => `Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)), (0, Qt.B)(n, t) } + }); const nn = (0, d.op)({ + reverse3d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "x", "reverse"); return h.vA(3 === n.rank, (() => `Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)), (0, Qt.B)(n, t) } + }); const rn = (0, d.op)({ + reverse4d_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "x", "reverse"); return h.vA(4 === n.rank, (() => `Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)), (0, Qt.B)(n, t) } + }); var an = n(5912), on = n(7820), sn = n(5702), un = n(6325), ln = n(9986); const cn = + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e, t) { const n = (0, c.YT)(e, "x", "setdiff1d"), r = (0, c.YT)(t, "y", "setdiff1d"); h.vA(n.dtype === r.dtype, (() => `x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)), h.vA(1 === n.rank, (() => `x should be 1D tensor, but got x (${n.shape}).`)), h.vA(1 === r.rank, (() => `y should be 1D tensor, but got y (${r.shape}).`)); const i = await n.data(), a = await r.data(), o = new Set(a); let s = 0; for (let e = 0; e < i.length; e++)o.has(i[e]) || s++; const u = new ut.yl([s], n.dtype), l = new ut.yl([s], "int32"); for (let e = 0, t = 0; e < i.length; e++)o.has(i[e]) || (u.values[t] = i[e], l.values[t] = e, t++); return [u.toTensor(), l.toTensor()] }; var hn = n(1115), dn = n(3726), fn = n(8276); const pn = (0, d.op)({ + slice1d_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "x", "slice1d"); return h.vA(1 === r.rank, (() => `slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, [t], [n]) } + }); const mn = (0, d.op)({ + slice2d_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "x", "slice2d"); return h.vA(2 === r.rank, (() => `slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, t, n) } + }); const gn = (0, d.op)({ + slice3d_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "x", "slice3d"); return h.vA(3 === r.rank, (() => `slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, t, n) } + }); const yn = (0, d.op)({ + slice4d_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "x", "slice4d"); return h.vA(4 === r.rank, (() => `slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, t, n) } + }); var bn = n(6346), vn = n(6030), xn = n(776), wn = n(1361), kn = n(3108), Sn = n(2292), _n = n(8775), Cn = n(6512), An = n(9348), Tn = n(3427), En = n(5932), Nn = n(4268), In = n(700), Mn = n(5894), Fn = n(3791), Dn = n(7823), $n = n(4027), Rn = n(9171); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function On(e, t) { (0, h.HO)(e); const n = (0, c.MZ)(e, t); if (1 !== n.length) throw new Error("tensor1d() requires values to be a flat/TypedArray"); return (0, Rn.Q)(e, null, n, t) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function zn(e, t, n) { if ((0, h.HO)(e), null != t && 2 !== t.length) throw new Error("tensor2d() requires shape to have two numbers"); const r = (0, c.MZ)(e, n); if (2 !== r.length && 1 !== r.length) throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray"); return (0, Rn.Q)(e, t, r, n) } var Pn = n(2768); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Bn(e, t, n) { if ((0, h.HO)(e), null != t && 4 !== t.length) throw new Error("tensor4d() requires shape to have four numbers"); const r = (0, c.MZ)(e, n); if (4 !== r.length && 1 !== r.length) throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor4d() requires shape to be provided when `values` are a flat array"); return (0, Rn.Q)(e, t, r, n) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Ln(e, t, n) { if ((0, h.HO)(e), null != t && 5 !== t.length) throw new Error("tensor5d() requires shape to have five numbers"); const r = (0, c.MZ)(e, n); if (5 !== r.length && 1 !== r.length) throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor5d() requires shape to be provided when `values` are a flat array"); return (0, Rn.Q)(e, t, r, n) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function jn(e, t, n) { if ((0, h.HO)(e), null != t && 6 !== t.length) throw new Error("tensor6d() requires shape to have six numbers"); const r = (0, c.MZ)(e, n); if (6 !== r.length && 1 !== r.length) throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor6d() requires shape to be provided when `values` are a flat array"); return t = t || r, (0, Rn.Q)(e, t, r, n) } var Un = n(6170); const Wn = (0, d.op)({ + tensorScatterUpdate_: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "tensor", "tensorScatterupdate"), i = (0, c.YT)(t, "indices", "tensorScatterupdate", "int32"), a = (0, c.YT)(n, "updates", "tensorScatterupdate"); if (Un.validateInput(a, i, r.shape), r.dtype !== a.dtype) throw new Error(`tensor and updates must have the same dtype, instead they are ${r.dtype} and ${a.dtype}.`); const o = { tensor: r, indices: i, updates: a }; return u.T2.runKernel(l.X4r, o, {}) } + }); var Vn = n(1190); const Gn = (0, d.op)({ + truncatedNormal_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0, n = 1, r, i) { if ((0, h.SA)(e), null != r && "bool" === r) throw new Error("Unsupported data type $ { dtype }"); const a = new Lt(t, n, r, !0, i), o = (0, V.r)(e, r); for (let e = 0; e < o.values.length; e++)o.values[e] = a.nextValue(); return o.toTensor() } + }); var Hn = n(3937), qn = n(7706), Yn = n(7261); + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Xn(e, t) { return Qe(e, t, "right") } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Kn(e, t = !0, n, r) { return u.T2.makeVariable(e, t, n, r) } var Zn = n(2151), Jn = n(4411); const Qn = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e) { const t = (0, c.YT)(e, "condition", "whereAsync", "bool"), n = await t.data(), r = (0, Jn.Y)(t.shape, n); return e !== t && t.dispose(), r }; var er = n(2855), tr = n(5537); const nr = + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e, t, n) { const r = (0, c.YT)(e, "tensor", "boolMask"), i = (0, c.YT)(t, "mask", "boolMask", "bool"), a = null == n ? 0 : n, o = i.rank, s = r.shape; h.vA(o > 0, (() => "mask cannot be scalar")), h.O3(s.slice(a, a + o), i.shape, "mask's shape must match the first K dimensions of tensor's shape,"); let u = 1; for (let e = a; e < a + o; e++)u *= s[e]; const l = s.slice(0, a).concat([u], s.slice(a + o)), d = (0, A.t)(r, l), f = (0, A.t)(i, [-1]), p = await Qn(f), m = (0, En.r)(p, [1]), g = (0, Me.k)(d, m, a); return e !== r && r.dispose(), t !== i && i.dispose(), m.dispose(), d.dispose(), f.dispose(), p.dispose(), g }; var rr = n(7703), ir = n(2596), ar = n(565); const or = (0, d.op)({ + movingAverage_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i = !0) { const a = (0, c.YT)(e, "v", "movingAverage"), o = (0, c.YT)(t, "x", "movingAverage"), u = (0, c.YT)(n, "decay", "movingAverage"); (0, ar.assertTypesMatch)(a, o), h.vA(h.r1(a.shape, o.shape), (() => "Shape mismatch in v and x")); const l = (0, sn.d)(1), d = (0, gt.j)(l, u); let f = (0, I.l)((0, gt.j)(o, a), d); if (i) { h.vA(null != r, (() => "When using zeroDebias: true, step is required.")); const e = (0, c.YT)(r, "step", "movingAverage"); f = (0, pe.y)(f, (0, gt.j)(l, (0, Mt.n)(u, e))) } return (0, s.W)(a, f) } + }); const sr = (0, d.op)({ + scatterND_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { (0, h.SA)(n); const r = (0, c.YT)(e, "indices", "scatterND", "int32"), i = (0, c.YT)(t, "updates", "scatterND"); Un.validateInput(i, r, n); const a = { indices: r, updates: i }, o = { shape: n }; return u.T2.runKernel(l.pJc, a, o) } + }); const ur = (0, d.op)({ + sparseToDense_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = 0) { (0, h.SA)(n); const i = (0, c.YT)(e, "sparseIndices", "sparseToDense", "int32"), a = (0, c.YT)(t, "sparseValues", "sparseToDense", "string_or_numeric"), o = (0, c.YT)(r, "defaultValue", "sparseToDense", a.dtype); !function (e, t, n, r) { if ("int32" !== e.dtype) throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`); if (e.rank > 2) throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`); const i = e.rank > 0 ? e.shape[0] : 1, a = e.rank > 1 ? e.shape[1] : 1; if (n.length !== a) throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${a}.`); const o = t.size; if (0 !== t.rank && (1 !== t.rank || o !== i)) throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${i}]`); if (t.dtype !== r.dtype) throw new Error("sparseValues.dtype must match defaultValues.dtype") }(i, a, n, o); const s = { sparseIndices: i, sparseValues: a, defaultValue: o }, d = { outputShape: n }; return u.T2.runKernel(l.jgd, s, d) } + }); const lr = (0, d.op)({ + gatherND_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(t, "indices", "gatherND", "int32"), r = { params: (0, c.YT)(e, "x", "gatherND", "string_or_numeric"), indices: n }; return u.T2.runKernel(l.O4G, r) } + }); const cr = (0, d.op)({ + dropout_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { + const i = (0, c.YT)(e, "x", "dropout"); if (h.vA("float32" === i.dtype, (() => `x has to be a floating point tensor since it's going to be scaled, but got a ${i.dtype} tensor instead.`)), h.vA(t >= 0 && t < 1, (() => `rate must be a float in the range [0, 1), but got ${t}.`)), 0 === t) return e instanceof ut.qY ? i.clone() : i; const a = + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { if (null == t) return e.shape.slice(); if (h.r1(e.shape, t)) return t; if (e.shape.length === t.length) { const n = []; for (let r = 0; r < e.shape.length; r++)null == t[r] && null != e.shape[r] ? n.push(e.shape[r]) : n.push(t[r]); return n } return t }(i, n), o = 1 - t, u = (0, pe.y)((0, Ne.R)((0, s.W)(Ht(a, 0, 1, "float32", r), o)), o); return (0, I.l)(i, u) + } + }); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function hr(e) { return Math.floor(Math.pow(2, Math.ceil(Math.log(e) / Math.log(2)))) } function dr(e, t, n) { const r = 1 - e % 2, i = new Float32Array(e); for (let a = 0; a < e; ++a) { const o = 2 * Math.PI * a / (e + r - 1); i[a] = t - n * Math.cos(o) } return On(i, "float32") } const fr = + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e, t, n = 1) { const r = (0, c.YT)(e, "predictions", "inTopK"), i = (0, c.YT)(t, "targets", "inTopK"); (0, h.vA)(r.rank > 1, (() => `inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)), (0, h.vA)(r.rank - 1 === i.rank, (() => `predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${i.rank}`)), (0, h.O3)(r.shape.slice(0, r.shape.length - 1), i.shape, "predictions's shape should be align with the targets' shape, except the last dimension."); const a = r.shape[r.shape.length - 1]; (0, h.vA)(n > 0 && n <= a, (() => `'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${a}), but got ${n}`)); const o = await r.data(), s = await i.data(), [u, l] = [o.length / a, a], d = (0, h.ce)("bool", u); for (let e = 0; e < u; e++) { const t = e * l, r = o.subarray(t, t + l), i = []; for (let e = 0; e < r.length; e++)i.push({ value: r[e], index: e }); i.sort(((e, t) => t.value - e.value)), d[e] = 0; for (let t = 0; t < n; t++)if (i[t].index === s[e]) { d[e] = 1; break } } return e !== r && r.dispose(), t !== i && i.dispose(), (0, $n.O)(d, i.shape, "bool") }; var pr = n(1830), mr = n(2198), gr = n(5248), yr = n(252), br = n(8646); const vr = (0, d.op)({ + fusedConv2d_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ({ x: e, filter: t, strides: n, pad: r, dataFormat: i = "NHWC", dilations: a = [1, 1], dimRoundingMode: o, bias: d, activation: f = "linear", preluActivationWeights: p, leakyreluAlpha: m }) { if (f = f || "linear", !1 === (0, br.zE)(u.T2.state.gradientDepth, f)) { h.vA("NHWC" === i, (() => `Error in fused conv2d: got dataFormat of ${i} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`)); let u = (0, ee.X)(e, t, n, r, i, a, o); return null != d && (u = (0, s.W)(u, d)), (0, br.f2)(u, f, p, m) } const g = (0, c.YT)(e, "x", "conv2d", "float32"), y = (0, c.YT)(t, "filter", "conv2d", "float32"); let b = g, v = !1; 3 === g.rank && (v = !0, b = (0, A.t)(g, [1, g.shape[0], g.shape[1], g.shape[2]])), h.vA(4 === b.rank, (() => `Error in fused conv2d: input must be rank 4, but got rank ${b.rank}.`)), h.vA(4 === y.rank, (() => `Error in fused conv2d: filter must be rank 4, but got rank ${y.rank}.`)), C.s_("fused conv2d", r, o); const x = "NHWC" === i ? b.shape[3] : b.shape[1]; h.vA(y.shape[2] === x, (() => `Error in conv2d: depth of input (${x}) must match input depth for filter ${y.shape[2]}.`)), h.vA(C.G0(n, a), (() => `Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`)); const w = C.uf(b.shape, y.shape, n, a, r, o); let k, S; if (null != d && (k = (0, c.YT)(d, "bias", "fused conv2d"), [k] = (0, ar.makeTypesMatch)(k, g), "NHWC" === i ? mr.assertAndGetBroadcastShape(w.outShape, k.shape) : (h.vA(k.shape.length <= 1, (() => `Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${k.shape.length}.`)), h.vA(0 === k.shape.length || k.shape[0] === w.outChannels || 1 === k.shape[0], (() => `Error in fused conv2d: bias shape (${k.shape}) is not compatible with the number of output channels (${w.outChannels})`)))), null != p) { const e = p.shape; if (h.vA(e.length <= 1 || 3 === e.length, (() => `Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)), 1 === e.length) h.vA(1 === e[0] || e[0] === w.outChannels, (() => `Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${w.outChannels}).`)); else if (3 === e.length) try { mr.assertAndGetBroadcastShape(e, w.outShape) } catch (t) { const n = `Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${w.outShape}).`; throw Error(n) } S = (0, c.YT)(p, "prelu weights", "fused conv2d") } const _ = (e, t) => { h.vA("NHWC" === i, (() => `Error in gradient of fused conv2D: got dataFormat of ${i} but only NHWC is currently supported.`)); const [o, s, u, l] = t, c = (0, br.XB)(e, u, f); h.vA(C.Dh(a), (() => `Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`)); const d = [(0, yr.v)(s.shape, c, o, n, r), (0, gr.H)(s, c, o.shape, n, r)]; if (null != l) { const e = (0, br.Do)(l, c); d.push(e) } return d }, T = { x: b, filter: y, bias: k, preluActivationWeights: S }, E = { strides: n, pad: r, dataFormat: i, dilations: a, dimRoundingMode: o, activation: f, leakyreluAlpha: m }; if (null == d) { const e = (0, pr._X)(((e, t, n) => { let r = u.T2.runKernel(l.aAr, T, E); return n([t, e, r]), v && (r = (0, A.t)(r, [r.shape[1], r.shape[2], r.shape[3]])), { value: r, gradFunc: _ } })); return e(b, y) } { const e = (0, pr._X)(((e, t, n, r) => { let i = u.T2.runKernel(l.aAr, T, E); return r([t, e, i, n]), v && (i = (0, A.t)(i, [i.shape[1], i.shape[2], i.shape[3]])), { value: i, gradFunc: _ } })); return e(b, y, k) } } + }); var xr = n(1890), wr = n(3134); const kr = (0, d.op)({ + fusedDepthwiseConv2d_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ({ x: e, filter: t, strides: n, pad: r, dataFormat: i = "NHWC", dilations: a = [1, 1], dimRoundingMode: o, bias: d, activation: f = "linear", preluActivationWeights: p, leakyreluAlpha: m }) { if (!1 === (0, br.zE)(u.T2.state.gradientDepth, f)) { let u = (0, he.G)(e, t, n, r, i, a, o); return null != d && (u = (0, s.W)(u, d)), (0, br.f2)(u, f, p, m) } const g = (0, c.YT)(e, "x", "depthwiseConv2d", "float32"), y = (0, c.YT)(t, "filter", "depthwiseConv2d", "float32"); let b = g, v = !1; 3 === g.rank && (v = !0, b = (0, A.t)(g, [1, g.shape[0], g.shape[1], g.shape[2]])), h.vA(4 === b.rank, (() => `Error in fused depthwiseConv2d: input must be rank 4, but got rank ${b.rank}.`)), h.vA(4 === y.rank, (() => `Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${y.rank}.`)), h.vA(b.shape[3] === y.shape[2], (() => `Error in fused depthwiseConv2d: number of input channels (${b.shape[3]}) must match the inChannels dimension in filter ${y.shape[2]}.`)), null == a && (a = [1, 1]), h.vA(C.G0(n, a), (() => `Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`)), C.s_("fused depthwiseConv2d", r, o); const x = C.uf(b.shape, y.shape, n, a, r, o, !0); let w, k; null != d && (w = (0, c.YT)(d, "bias", "fused conv2d"), [w] = (0, ar.makeTypesMatch)(w, g), mr.assertAndGetBroadcastShape(x.outShape, w.shape)), null != p && (k = (0, c.YT)(p, "prelu weights", "fused depthwiseConv2d")); const S = (e, t) => { h.vA(C.Dh(a), (() => `Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`)); const [i, s, u, l] = t, c = (0, br.XB)(e, u, f), d = (0, wr.l)(s.shape, c, i, n, r, a, o), p = (0, xr.x)(s, c, i.shape, n, r, a, o); if (null != l) { return [d, p, (0, br.Do)(w, c)] } return [d, p] }, _ = { x: b, filter: y, bias: w, preluActivationWeights: k }, T = { strides: n, pad: r, dataFormat: i, dilations: a, dimRoundingMode: o, activation: f, leakyreluAlpha: m }; if (null == d) { const e = (0, pr._X)(((e, t, n) => { let r = u.T2.runKernel(l.T7M, _, T); return n([t, e, r]), v && (r = (0, A.t)(r, [r.shape[1], r.shape[2], r.shape[3]])), { value: r, gradFunc: S } })); return e(b, y) } { const e = (0, pr._X)(((e, t, n, r) => { let i = u.T2.runKernel(l.T7M, _, T); return r([t, e, i, n]), v && (i = (0, A.t)(i, [i.shape[1], i.shape[2], i.shape[3]])), { value: i, gradFunc: S } })); return e(b, y, w) } } + }); const Sr = (0, d.op)({ + fusedMatMul_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ({ a: e, b: t, transposeA: n = !1, transposeB: r = !1, bias: i, activation: a = "linear", preluActivationWeights: o, leakyreluAlpha: d = .2 }) { if (!1 === (0, br.zE)(u.T2.state.gradientDepth, a)) { let u = (0, N.N)(e, t, n, r); return null != i && (u = (0, s.W)(u, i)), (0, br.f2)(u, a, o, d) } let f = (0, c.YT)(e, "a", "fused matMul"), p = (0, c.YT)(t, "b", "fused matMul");[f, p] = (0, ar.makeTypesMatch)(f, p); const m = n ? f.shape[f.rank - 2] : f.shape[f.rank - 1], g = r ? p.shape[p.rank - 1] : p.shape[p.rank - 2], y = n ? f.shape[f.rank - 1] : f.shape[f.rank - 2], b = r ? p.shape[p.rank - 2] : p.shape[p.rank - 1], v = f.shape.slice(0, -2), x = p.shape.slice(0, -2), w = h.Ze(v), k = h.Ze(x); h.vA(m === g, (() => `Error in fused matMul: inner shapes (${m}) and (${g}) of Tensors with shapes ${f.shape} and ${p.shape} and transposeA=${n} and transposeB=${r} must match.`)); const S = mr.assertAndGetBroadcastShape(f.shape.slice(0, -2), p.shape.slice(0, -2)).concat([y, b]), _ = n ? (0, A.t)(f, [w, m, y]) : (0, A.t)(f, [w, y, m]), C = r ? (0, A.t)(p, [k, b, g]) : (0, A.t)(p, [k, g, b]); let T, E; null != i && (T = (0, c.YT)(i, "bias", "fused matMul"), [T] = (0, ar.makeTypesMatch)(T, f), mr.assertAndGetBroadcastShape(S, T.shape)), null != o && (E = (0, c.YT)(o, "prelu weights", "fused matMul")); const I = (e, t) => { const [o, s, u, l] = t, c = (0, br.XB)((0, A.t)(e, u.shape), u, a); let h, d; if (n || r ? !n && r ? (h = (0, N.N)(c, s, !1, !1), d = (0, N.N)(c, o, !0, !1)) : n && !r ? (h = (0, N.N)(s, c, !1, !0), d = (0, N.N)(o, c, !1, !1)) : (h = (0, N.N)(s, c, !0, !0), d = (0, N.N)(c, o, !0, !0)) : (h = (0, N.N)(c, s, !1, !0), d = (0, N.N)(o, c, !0, !1)), null != i) { return [h, d, (0, br.Do)(l, c)] } return [h, d] }, M = { a: _, b: C, bias: T, preluActivationWeights: E }, F = { transposeA: n, transposeB: r, activation: a, leakyreluAlpha: d }; if (null == i) { const e = (0, pr._X)(((e, t, n) => { const r = u.T2.runKernel(l.Dr, M, F); return n([e, t, r]), { value: (0, A.t)(r, S), gradFunc: I } })); return e(_, C) } { const e = (0, pr._X)(((e, t, n, r) => { const i = u.T2.runKernel(l.Dr, M, F); return r([e, t, i, n]), { value: (0, A.t)(i, S), gradFunc: I } })); return e(_, C, T) } } + }); const _r = (0, d.op)({ + hammingWindow_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { return dr(e, .54, .46) } + }); const Cr = (0, d.op)({ + hannWindow_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { return dr(e, .5, .5) } + }); const Ar = (0, d.op)({ + frame_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = !1, i = 0) { let a = 0; const o = []; for (; a + t <= e.size;)o.push((0, F.d)(e, a, t)), a += n; if (r) for (; a < e.size;) { const r = a + t - e.size, s = (0, E.x)([(0, F.d)(e, a, t - r), (0, Ee.G)([r], i)]); o.push(s), a += n } return 0 === o.length ? zn([], [0, t]) : (0, A.t)((0, E.x)(o), [o.length, t]) } + }); const Tr = (0, d.op)({ + stft_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i = Cr) { null == r && (r = hr(t)); const a = Ar(e, t, n), o = (0, I.l)(a, i(t)); return (0, _n.z)(o, r) } + }); const Er = (0, d.op)({ + cropAndResize_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i = "bilinear", a = 0) { const o = (0, c.YT)(e, "image", "cropAndResize"), s = (0, c.YT)(t, "boxes", "cropAndResize", "float32"), d = (0, c.YT)(n, "boxInd", "cropAndResize", "int32"), f = s.shape[0]; h.vA(4 === o.rank, (() => `Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`)), h.vA(2 === s.rank && 4 === s.shape[1], (() => `Error in cropAndResize: boxes must be have size [${f},4] but had shape ${s.shape}.`)), h.vA(1 === d.rank && d.shape[0] === f, (() => `Error in cropAndResize: boxInd must be have size [${f}] but had shape ${s.shape}.`)), h.vA(2 === r.length, (() => `Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)), h.vA(r[0] >= 1 && r[1] >= 1, (() => `cropSize must be atleast [1,1], but was ${r}`)), h.vA("bilinear" === i || "nearest" === i, (() => `method must be bilinear or nearest, but was ${i}`)); const p = { image: o, boxes: s, boxInd: d }, m = { method: i, extrapolationValue: a, cropSize: r }; return u.T2.runKernel(l.MRQ, p, m) } + }); const Nr = (0, d.op)({ + flipLeftRight_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, c.YT)(e, "image", "flipLeftRight", "float32"); h.vA(4 === t.rank, (() => `Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`)); const n = { image: t }; return u.T2.runKernel(l.BxF, n, {}) } + }); const Ir = (0, d.op)({ + grayscaleToRGB_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, c.YT)(e, "image", "grayscaleToRGB"), n = t.rank - 1, r = t.shape[n]; h.vA(t.rank >= 2, (() => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)), h.vA(1 === r, (() => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`)); const i = new Array(t.rank); return i.fill(1, 0, n), i[n] = 3, (0, Ae.V)(t, i) } + }); const Mr = (0, d.op)({ + rgbToGrayscale_: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, c.YT)(e, "image", "RGBToGrayscale"), n = t.rank - 1, r = t.shape[n]; h.vA(t.rank >= 2, (() => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${t.rank}.`)), h.vA(3 === r, (() => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`)); const i = t.dtype, a = (0, _.w)(t, "float32"), o = On([.2989, .587, .114]); let s; switch (t.rank) { case 2: s = ye("ij,j->i", a, o); break; case 3: s = ye("ijk,k->ij", a, o); break; case 4: s = ye("ijkl,l->ijk", a, o); break; case 5: s = ye("ijklm,m->ijkl", a, o); break; case 6: s = ye("ijklmn,n->ijklm", a, o); break; default: throw new Error("Not a valid tensor rank.") }return s = (0, _e.U)(s, -1), (0, _.w)(s, i) } + }); const Fr = (0, d.op)({ + rotateWithOffset_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = 0, r = .5) { const i = (0, c.YT)(e, "image", "rotateWithOffset", "float32"); h.vA(4 === i.rank, (() => `Error in rotateWithOffset: image must be rank 4,but got rank ${i.rank}.`)); const a = { image: i }, o = { radians: t, fillValue: n, center: r }; return u.T2.runKernel(l.BK4, a, o) } + }); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Dr(e, t, n, r, i, a) { null == r && (r = .5), null == i && (i = Number.NEGATIVE_INFINITY), null == a && (a = 0); const o = e.shape[0]; return n = Math.min(n, o), h.vA(0 <= r && r <= 1, (() => `iouThreshold must be in [0, 1], but was '${r}'`)), h.vA(2 === e.rank, (() => `boxes must be a 2D tensor, but was of rank '${e.rank}'`)), h.vA(4 === e.shape[1], (() => `boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)), h.vA(1 === t.rank, (() => "scores must be a 1D tensor")), h.vA(t.shape[0] === o, (() => `scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`)), h.vA(0 <= a && a <= 1, (() => `softNmsSigma must be in [0, 1], but was '${a}'`)), { maxOutputSize: n, iouThreshold: r, scoreThreshold: i, softNmsSigma: a } } const $r = (0, d.op)({ + nonMaxSuppression_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY) { const a = (0, c.YT)(e, "boxes", "nonMaxSuppression", "float32"), o = (0, c.YT)(t, "scores", "nonMaxSuppression", "float32"), s = Dr(a, o, n, r, i), h = { maxOutputSize: n = s.maxOutputSize, iouThreshold: r = s.iouThreshold, scoreThreshold: i = s.scoreThreshold }; return u.T2.runKernel(l.SDM, { boxes: a, scores: o }, h) } + }); var Rr = n(8360); const Or = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY) { const a = (0, c.YT)(e, "boxes", "nonMaxSuppressionAsync"), o = (0, c.YT)(t, "scores", "nonMaxSuppressionAsync"), s = Dr(a, o, n, r, i); n = s.maxOutputSize, r = s.iouThreshold, i = s.scoreThreshold; const u = await Promise.all([a.data(), o.data()]), l = u[0], h = u[1], { selectedIndices: d } = (0, Rr.c7)(l, h, n, r, i); return a !== e && a.dispose(), o !== t && o.dispose(), On(d, "int32") }; const zr = (0, d.op)({ + nonMaxSuppressionWithScore_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = 0) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppression"), s = (0, c.YT)(t, "scores", "nonMaxSuppression"), h = Dr(o, s, n, r, i, a), d = { boxes: o, scores: s }, f = { maxOutputSize: n = h.maxOutputSize, iouThreshold: r = h.iouThreshold, scoreThreshold: i = h.scoreThreshold, softNmsSigma: a = h.softNmsSigma }, p = u.T2.runKernel(l.e0f, d, f); return { selectedIndices: p[0], selectedScores: p[1] } } + }); const Pr = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = 0) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppressionAsync"), s = (0, c.YT)(t, "scores", "nonMaxSuppressionAsync"), u = Dr(o, s, n, r, i, a); n = u.maxOutputSize, r = u.iouThreshold, i = u.scoreThreshold, a = u.softNmsSigma; const l = await Promise.all([o.data(), s.data()]), h = l[0], d = l[1], { selectedIndices: f, selectedScores: p } = (0, Rr.ut)(h, d, n, r, i, a); return o !== e && o.dispose(), s !== t && s.dispose(), { selectedIndices: On(f, "int32"), selectedScores: On(p) } }; const Br = (0, d.op)({ + nonMaxSuppressionPadded_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = !1) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppression"), s = (0, c.YT)(t, "scores", "nonMaxSuppression"), h = Dr(o, s, n, r, i, null), d = { boxes: o, scores: s }, f = { maxOutputSize: h.maxOutputSize, iouThreshold: h.iouThreshold, scoreThreshold: h.scoreThreshold, padToMaxOutputSize: a }, p = u.T2.runKernel(l.Zl4, d, f); return { selectedIndices: p[0], validOutputs: p[1] } } + }); const Lr = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + async function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = !1) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppressionAsync"), s = (0, c.YT)(t, "scores", "nonMaxSuppressionAsync"), u = Dr(o, s, n, r, i, null), l = u.maxOutputSize, h = u.iouThreshold, d = u.scoreThreshold, [f, p] = await Promise.all([o.data(), s.data()]), { selectedIndices: m, validOutputs: g } = (0, Rr.ZS)(f, p, l, h, d, a); return o !== e && o.dispose(), s !== t && s.dispose(), { selectedIndices: On(m, "int32"), validOutputs: (0, sn.d)(g, "int32") } }; var jr = n(4711), Ur = n(2954); const Wr = (0, d.op)({ + threshold_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = "binary", n = !1, r = .5) { const i = (0, c.YT)(e, "image", "threshold"), a = i.shape[0] * i.shape[1]; let o, u, l, d, f = (0, I.l)(On([r]), 255); if (h.vA(3 === i.rank, (() => `Error in threshold: image must be rank 3,but got rank ${i.rank}.`)), h.vA(3 === i.shape[2] || 1 === i.shape[2], (() => `Error in threshold: image color channel must be equal to 3 or 1but got ${i.shape[2]}.`)), h.vA("int32" === i.dtype || "float32" === i.dtype, (() => `Error in dtype: image dtype must be int32 or float32,but got dtype ${i.dtype}.`)), h.vA("otsu" === t || "binary" === t, (() => `Method must be binary or otsu, but was ${t}`)), 3 === i.shape[2]) { [o, u, l] = (0, Cn.l)(i, [1, 1, 1], -1); const e = (0, I.l)(o, .2989), t = (0, I.l)(u, .587), n = (0, I.l)(l, .114); d = (0, s.W)((0, s.W)(e, t), n) } else d = e; if ("otsu" === t) { f = function (e, t) { let n, r, i, a, o, u, l = On([-1]), c = On([0]), h = On([0]); for (let d = 0; d < e.size - 1; d++) { n = (0, F.d)(e, 0, d + 1), r = (0, F.d)(e, d + 1), o = (0, pe.y)((0, Fn.c)(n), t), u = (0, pe.y)((0, Fn.c)(r), t); const f = (0, Fn.c)((0, I.l)(n, Yt(0, n.size))); i = (0, pe.y)(f, (0, Fn.c)(n)); const p = (0, Ee.G)(r.shape, n.size), m = (0, s.W)(Yt(0, r.size), p), g = (0, I.l)(r, m); a = (0, pe.y)((0, Fn.c)(g), (0, Fn.c)(r)); const y = (0, gt.j)(i, a), b = (0, gt.j)(i, a), v = (0, I.l)(o, u); h = (0, I.l)((0, I.l)(v, y), b); const x = (0, Fe.r)(h, c); c = (0, Zn._)(x, h, c), l = (0, Zn._)(x, On([d]), l) } return l }(L((0, _.w)((0, an.L)(d), "int32"), (0, $n.O)([]), 256), a) } const p = n ? (0, Le.I)(d, f) : (0, Fe.r)(d, f); return (0, _.w)((0, I.l)(p, 255), "int32") } + }); const Vr = (0, d.op)({ + transform_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = "nearest", r = "constant", i = 0, a) { const o = (0, c.YT)(e, "image", "transform", "float32"), s = (0, c.YT)(t, "transforms", "transform", "float32"); h.vA(4 === o.rank, (() => `Error in transform: image must be rank 4,but got rank ${o.rank}.`)), h.vA(2 === s.rank && (s.shape[0] === o.shape[0] || 1 === s.shape[0]) && 8 === s.shape[1], (() => "Error in transform: Input transform should be batch x 8 or 1 x 8")), h.vA(null == a || 2 === a.length, (() => `Error in transform: outputShape must be [height, width] or null, but got ${a}.`)); const d = { image: o, transforms: s }, f = { interpolation: n, fillMode: r, fillValue: i, outputShape: a }; return u.T2.runKernel(l.dLy, d, f) } + }); const Gr = (0, d.op)({ + bandPart_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "a", "bandPart"); (0, h.vA)(r.rank >= 2, (() => `bandPart(): Rank must be at least 2, got ${r.rank}.`)); const i = r.shape, [a, o] = r.shape.slice(-2); let s, u; "number" == typeof t ? ((0, h.vA)(t % 1 == 0, (() => `bandPart(): numLower must be an integer, got ${t}.`)), (0, h.vA)(t <= a, (() => `bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`)), s = (0, c.YT)(t < 0 ? a : t, "numLower", "bandPart")) : ((0, h.vA)("int32" === t.dtype, (() => "bandPart(): numLower's dtype must be an int32.")), s = (0, Zn._)((0, Be.M)(t, 0), a, (0, ht.B)(t, a))), "number" == typeof n ? ((0, h.vA)(n % 1 == 0, (() => `bandPart(): numUpper must be an integer, got ${n}.`)), (0, h.vA)(n <= o, (() => `bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`)), u = (0, c.YT)(n < 0 ? o : n, "numUpper", "bandPart")) : ((0, h.vA)("int32" === n.dtype, (() => "bandPart(): numUpper's dtype must be an int32.")), u = (0, Zn._)((0, Be.M)(n, 0), o, (0, ht.B)(n, o))); const l = (0, A.t)(Yt(0, a, 1, "int32"), [-1, 1]), d = Yt(0, o, 1, "int32"), f = (0, gt.j)(l, d), p = (0, Ye.n)((0, Le.I)(f, s), (0, De.D)(f, (0, xt.H)(u))), m = (0, er.U)([a, o], r.dtype); return (0, A.t)((0, Nn.t)((0, Yn.K)((0, A.t)(r, [-1, a, o])).map((e => (0, Zn._)(p, e, m)))), i) } + }); const Hr = (0, d.op)({ + gramSchmidt_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { let t; if (Array.isArray(e)) { t = !1, (0, h.vA)(null != e && e.length > 0, (() => "Gram-Schmidt process: input must not be null, undefined, or empty")); const n = e[0].shape[0]; for (let t = 1; t < e.length; ++t)(0, h.vA)(e[t].shape[0] === n, (() => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`)) } else t = !0, e = (0, Cn.l)(e, e.shape[0], 0).map((e => (0, En.r)(e, [0]))); (0, h.vA)(e.length <= e[0].shape[0], (() => `Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`)); const n = [], r = e; for (let t = 0; t < e.length; ++t)n.push(u.T2.tidy((() => { let e = r[t]; if (t > 0) for (let r = 0; r < t; ++r) { const t = (0, I.l)((0, Fn.c)((0, I.l)(n[r], e)), n[r]); e = (0, gt.j)(e, t) } return (0, pe.y)(e, (0, ir.x)(e, "euclidean")) }))); return t ? (0, Nn.t)(n, 0) : n } + }); var qr = n(5287); function Yr(e, t = !1) { return u.T2.tidy((() => { (0, h.vA)(2 === e.shape.length, (() => `qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`)); const n = e.shape[0], r = e.shape[1]; let i = Te(n), a = (0, q.o)(e); const o = zn([[1]], [1, 1]); let s = (0, q.o)(o); const l = n >= r ? r : n; for (let e = 0; e < l; ++e) { const t = a, l = s, c = i;[s, a, i] = u.T2.tidy((() => { const t = (0, F.d)(a, [e, e], [n - e, 1]), u = (0, ir.x)(t), l = (0, F.d)(a, [e, e], [1, 1]), c = (0, Zn._)((0, Fe.r)(l, 0), zn([[-1]]), zn([[1]])), h = (0, gt.j)(l, (0, I.l)(c, u)), d = (0, pe.y)(t, h); s = 1 === d.shape[0] ? (0, q.o)(o) : (0, E.x)([o, (0, F.d)(d, [1, 0], [d.shape[0] - 1, d.shape[1]])], 0); const f = (0, xt.H)((0, pe.y)((0, N.N)(c, h), u)), p = (0, F.d)(a, [e, 0], [n - e, r]), m = (0, I.l)(f, s), g = (0, rr.m)(s); if (0 === e) a = (0, gt.j)(p, (0, N.N)(m, (0, N.N)(g, p))); else { const t = (0, gt.j)(p, (0, N.N)(m, (0, N.N)(g, p))); a = (0, E.x)([(0, F.d)(a, [0, 0], [e, r]), t], 0) } const y = (0, rr.m)(m), b = (0, F.d)(i, [0, e], [n, i.shape[1] - e]); if (0 === e) i = (0, gt.j)(b, (0, N.N)((0, N.N)(b, s), y)); else { const t = (0, gt.j)(b, (0, N.N)((0, N.N)(b, s), y)); i = (0, E.x)([(0, F.d)(i, [0, 0], [n, e]), t], 1) } return [s, a, i] })), (0, qr.AS)([t, l, c]) } return !t && n > r && (i = (0, F.d)(i, [0, 0], [n, r]), a = (0, F.d)(a, [0, 0], [r, r])), [i, a] })) } const Xr = (0, d.op)({ + qr_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = !1) { if ((0, h.vA)(e.rank >= 2, (() => `qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)), 2 === e.rank) return Yr(e, t); { const n = e.shape.slice(0, e.shape.length - 2).reduce(((e, t) => e * t)), r = (0, Yn.K)((0, A.t)(e, [n, e.shape[e.shape.length - 2], e.shape[e.shape.length - 1]]), 0), i = [], a = []; r.forEach((e => { const [n, r] = Yr(e, t); i.push(n), a.push(r) })); return [(0, A.t)((0, Nn.t)(i, 0), e.shape), (0, A.t)((0, Nn.t)(a, 0), e.shape)] } } + }); var Kr = n(4703); const Zr = (0, d.op)({ computeWeightedLoss_: function (e, t, n = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const r = (0, c.YT)(e, "losses", "computeWeightedLoss"); let i = null; null != t && (i = (0, c.YT)(t, "weights", "computeWeightedLoss")); const a = null == i ? r : (0, I.l)(r, i); if (n === Kr.i.NONE) return a; if (n === Kr.i.SUM) return (0, Fn.c)(a); if (n === Kr.i.MEAN) { if (null == i) return (0, ot.i)(a); { const e = r.size / i.size, t = (0, pe.y)((0, Fn.c)(a), (0, Fn.c)(i)); return e > 1 ? (0, pe.y)(t, (0, sn.d)(e)) : t } } if (n === Kr.i.SUM_BY_NONZERO_WEIGHTS) { if (null == i) return (0, pe.y)((0, Fn.c)(a), (0, sn.d)(r.size)); { const e = (0, I.l)(i, (0, st.S)(r.shape)), t = (0, _.w)((0, Fn.c)((0, wt.E)(e, (0, sn.d)(0))), "float32"); return (0, pe.y)((0, Fn.c)(a), t) } } throw Error(`Unknown reduction: ${n}`) } }); const Jr = (0, d.op)({ + absoluteDifference_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const a = (0, c.YT)(e, "labels", "absoluteDifference"), o = (0, c.YT)(t, "predictions", "absoluteDifference"); let s = null; null != n && (s = (0, c.YT)(n, "weights", "absoluteDifference")), (0, h.O3)(a.shape, o.shape, "Error in absoluteDifference: "); const u = (0, i.t)((0, gt.j)(a, o)); return Zr(u, s, r) } + }); const Qr = (0, d.op)({ cosineDistance_: function (e, t, n, r, i = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const a = (0, c.YT)(e, "labels", "cosineDistance"), o = (0, c.YT)(t, "predictions", "cosineDistance"); let s = null; null != r && (s = (0, c.YT)(r, "weights", "cosineDistance")), (0, h.O3)(a.shape, o.shape, "Error in cosineDistance: "); const u = (0, sn.d)(1), l = (0, gt.j)(u, (0, Fn.c)((0, I.l)(a, o), n, !0)); return Zr(l, s, i) } }); const ei = (0, d.op)({ hingeLoss_: function (e, t, n, r = Kr.i.SUM_BY_NONZERO_WEIGHTS) { let i = (0, c.YT)(e, "labels", "hingeLoss"); const a = (0, c.YT)(t, "predictions", "hingeLoss"); let o = null; null != n && (o = (0, c.YT)(n, "weights", "hingeLoss")), (0, h.O3)(i.shape, a.shape, "Error in hingeLoss: "); const s = (0, sn.d)(1); i = (0, gt.j)((0, I.l)((0, sn.d)(2), i), s); const u = (0, Zt.V)((0, gt.j)(s, (0, I.l)(i, a))); return Zr(u, o, r) } }); const ti = (0, d.op)({ + huberLoss_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = 1, a = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const o = (0, c.YT)(e, "labels", "huberLoss"), u = (0, c.YT)(t, "predictions", "huberLoss"); let l = null; null != n && (l = (0, c.YT)(n, "weights", "huberLoss")), (0, h.O3)(o.shape, u.shape, "Error in huberLoss: "); const d = (0, sn.d)(r), f = (0, i.t)((0, gt.j)(u, o)), p = (0, ht.B)(f, d), m = (0, gt.j)(f, p), g = (0, s.W)((0, I.l)((0, sn.d)(.5), (0, mt.E)(p)), (0, I.l)(d, m)); return Zr(g, l, a) } + }); const ni = (0, d.op)({ + logLoss_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = 1e-7, i = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const a = (0, c.YT)(e, "labels", "logLoss"), o = (0, c.YT)(t, "predictions", "logLoss"); let u = null; null != n && (u = (0, c.YT)(n, "weights", "logLoss")), (0, h.O3)(a.shape, o.shape, "Error in logLoss: "); const l = (0, sn.d)(1), d = (0, sn.d)(r), f = (0, xt.H)((0, I.l)(a, (0, We.R)((0, s.W)(o, d)))), p = (0, I.l)((0, gt.j)(l, a), (0, We.R)((0, s.W)((0, gt.j)(l, o), d))), m = (0, gt.j)(f, p); return Zr(m, u, i) } + }); const ri = (0, d.op)({ + meanSquaredError_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const i = (0, c.YT)(e, "labels", "meanSquaredError"), a = (0, c.YT)(t, "predictions", "meanSquaredError"); let o = null; null != n && (o = (0, c.YT)(n, "weights", "meanSquaredError")), (0, h.O3)(i.shape, a.shape, "Error in meanSquaredError: "); const s = (0, Tn.P)(i, a); return Zr(s, o, r) } + }); const ii = (0, d.op)({ + sigmoidCrossEntropy_: function (e, t, n, r = 0, a = Kr.i.SUM_BY_NONZERO_WEIGHTS) { + let o = (0, c.YT)(e, "multiClassLabels", "sigmoidCrossEntropy"); const u = (0, c.YT)(t, "logits", "sigmoidCrossEntropy"); let l = null; if (null != n && (l = (0, c.YT)(n, "weights", "sigmoidCrossEntropy")), (0, h.O3)(o.shape, u.shape, "Error in sigmoidCrossEntropy: "), r > 0) { const e = (0, sn.d)(r), t = (0, sn.d)(1), n = (0, sn.d)(.5); o = (0, s.W)((0, I.l)(o, (0, gt.j)(t, e)), (0, I.l)(n, e)) } const d = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "labels", "sigmoidCrossEntropyWithLogits"), r = (0, c.YT)(t, "logits", "sigmoidCrossEntropyWithLogits"); (0, h.O3)(n.shape, r.shape, "Error in sigmoidCrossEntropyWithLogits: "); const a = (0, Zt.V)(r), o = (0, I.l)(r, n), u = (0, Ve.K)((0, Se.o)((0, xt.H)((0, i.t)(r)))); return (0, s.W)((0, gt.j)(a, o), u) }(o, u); return Zr(d, l, a) + } + }); const ai = (0, d.op)({ + softmaxCrossEntropy_: function (e, t, n, r = 0, i = Kr.i.SUM_BY_NONZERO_WEIGHTS) { + let a = (0, c.YT)(e, "onehotLabels", "softmaxCrossEntropy"); const o = (0, c.YT)(t, "logits", "softmaxCrossEntropy"); let u = null; if (null != n && (u = (0, c.YT)(n, "weights", "softmaxCrossEntropy")), (0, h.O3)(a.shape, o.shape, "Error in softmaxCrossEntropy: "), r > 0) { const e = (0, sn.d)(r), t = (0, sn.d)(1), n = (0, sn.d)(a.shape[1]); a = (0, s.W)((0, I.l)(a, (0, gt.j)(t, e)), (0, pe.y)(e, n)) } const l = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = -1) { if (-1 === n && (n = t.rank - 1), n !== t.rank - 1) throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`); const r = (0, pr._X)(((e, t, r) => { const i = (0, qe.V)(t, [n], !0), a = (0, gt.j)((0, _.w)(t, "float32"), i); r([e, a]); const o = (0, xt.H)((0, I.l)(a, e)); return { value: (0, Fn.c)(o, [n]), gradFunc: (e, t) => { const [r, i] = t, a = (0, pt.SM)(e.shape, [n]); return [(0, I.l)((0, A.t)(e, a), (0, gt.j)((0, _.w)(r, "float32"), (0, Se.o)(i))), (0, I.l)((0, A.t)(e, a), (0, gt.j)((0, Se.o)(i), (0, _.w)(r, "float32")))] } } })); return r(e, t) }(a, o); return Zr(l, u, i) + } + }); const oi = (0, d.op)({ + sparseFillEmptyRows_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { const i = (0, c.YT)(e, "indices", "sparseFillEmptyRows", "int32"), a = (0, c.YT)(t, "values", "sparseFillEmptyRows"), o = (0, c.YT)(n, "denseShape", "sparseFillEmptyRows", "int32"), s = (0, c.YT)(r, "defaultValue", "sparseFillEmptyRows", a.dtype); if (2 !== i.rank) throw new Error(`Indices should be Tensor2D but received shape\n ${i.shape}`); if (1 !== a.rank) throw new Error(`Values should be Tensor1D but received shape ${a.shape}`); if (1 !== o.rank) throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`); if (0 !== s.rank) throw new Error(`Default value should be a scalar but received shape ${s.shape}`); const h = { indices: i, values: a, denseShape: o, defaultValue: s }, d = u.T2.runKernel(l.C8s, h); return { outputIndices: d[0], outputValues: d[1], emptyRowIndicator: d[2], reverseIndexMap: d[3] } } + }); const si = (0, d.op)({ + sparseReshape_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "inputIndices", "sparseReshape", "int32"), i = (0, c.YT)(t, "inputShape", "sparseReshape", "int32"), a = (0, c.YT)(n, "newShape", "sparseReshape", "int32"); if (2 !== r.rank) throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`); if (1 !== i.rank) throw new Error(`Input shape should be Tensor1D but received shape ${i.shape}`); if (1 !== a.rank) throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`); const o = { inputIndices: r, inputShape: i, newShape: a }, s = u.T2.runKernel(l.BoJ, o); return { outputIndices: s[0], outputShape: s[1] } } + }); const ui = (0, d.op)({ + sparseSegmentMean_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "data", "sparseSegmentMean"), i = (0, c.YT)(t, "indices", "sparseSegmentMean", "int32"), a = (0, c.YT)(n, "segmentIds", "sparseSegmentMean", "int32"); if (r.rank < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.rank) throw new Error(`Indices should be Tensor1D but received shape\n ${i.shape}`); if (1 !== a.rank) throw new Error(`Segment ids should be Tensor1D but received shape\n ${a.shape}`); const o = { data: r, indices: i, segmentIds: a }; return u.T2.runKernel(l.L6G, o) } + }); const li = (0, d.op)({ + sparseSegmentSum_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = (0, c.YT)(e, "data", "sparseSegmentSum"), i = (0, c.YT)(t, "indices", "sparseSegmentSum", "int32"), a = (0, c.YT)(n, "segmentIds", "sparseSegmentSum", "int32"); if (r.rank < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.rank) throw new Error(`Indices should be Tensor1D but received shape\n ${i.shape}`); if (1 !== a.rank) throw new Error(`Segment ids should be Tensor1D but received shape\n ${a.shape}`); const o = { data: r, indices: i, segmentIds: a }; return u.T2.runKernel(l.DvZ, o) } + }); const ci = (0, d.op)({ + stringNGrams_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i, a, o, s) { const h = (0, c.YT)(e, "data", "stringNGrams", "string"); if ("string" !== h.dtype) throw new Error("Data must be of datatype string"); if (1 !== h.shape.length) throw new Error(`Data must be a vector, saw: ${h.shape}`); const d = (0, c.YT)(t, "dataSplits", "stringNGrams"); if ("int32" !== d.dtype) throw new Error("Data splits must be of datatype int32"); const f = { separator: n, nGramWidths: r, leftPad: i, rightPad: a, padWidth: o, preserveShortSequences: s }, p = { data: h, dataSplits: d }, m = u.T2.runKernel(l.YAb, p, f); return { nGrams: m[0], nGramsSplits: m[1] } } + }); const hi = (0, d.op)({ + stringSplit_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = !0) { const r = (0, c.YT)(e, "input", "stringSplit", "string"), i = (0, c.YT)(t, "delimiter", "stringSplit", "string"); if (1 !== r.rank) throw new Error(`Input should be Tensor1D but received shape ${r.shape}`); if (0 !== i.rank) throw new Error(`Delimiter should be a scalar but received shape ${i.shape}`); const a = { skipEmpty: n }, o = { input: r, delimiter: i }, s = u.T2.runKernel(l.iW0, o, a); return { indices: s[0], values: s[1], shape: s[2] } } + }); const di = (0, d.op)({ + stringToHashBucketFast_: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, c.YT)(e, "input", "stringToHashBucketFast", "string"), r = { numBuckets: t }; if (t <= 0) throw new Error("Number of buckets must be at least 1"); const i = { input: n }; return u.T2.runKernel(l.$jE, i, r) } + }); const fi = (0, d.op)({ + staticRegexReplace_: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = !0) { const i = (0, c.YT)(e, "input", "staticRegexReplace", "string"), a = { pattern: t, rewrite: n, replaceGlobal: r }; return u.T2.runKernel(l.GZp, { x: i }, a) } + }), pi = { fft: wn.h, ifft: kn.K, rfft: _n.z, irfft: Sn.g }, mi = { hammingWindow: _r, hannWindow: Cr, frame: Ar, stft: Tr }, gi = { flipLeftRight: Nr, grayscaleToRGB: Ir, resizeNearestNeighbor: Ur.b, resizeBilinear: jr.v, rgbToGrayscale: Mr, rotateWithOffset: Fr, cropAndResize: Er, nonMaxSuppression: $r, nonMaxSuppressionAsync: Or, nonMaxSuppressionWithScore: zr, nonMaxSuppressionWithScoreAsync: Pr, nonMaxSuppressionPadded: Br, nonMaxSuppressionPaddedAsync: Lr, threshold: Wr, transform: Vr }, yi = { bandPart: Gr, gramSchmidt: Hr, qr: Xr }, bi = { absoluteDifference: Jr, computeWeightedLoss: Zr, cosineDistance: Qr, hingeLoss: ei, huberLoss: ti, logLoss: ni, meanSquaredError: ri, sigmoidCrossEntropy: ii, softmaxCrossEntropy: ai }, vi = { sparseFillEmptyRows: oi, sparseReshape: si, sparseSegmentMean: ui, sparseSegmentSum: li }, xi = { stringNGrams: ci, stringSplit: hi, stringToHashBucketFast: di, staticRegexReplace: fi } + }, 5661: (e, t, n) => { + "use strict"; n.d(t, { e: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + pad_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = 0) { const o = (0, a.YT)(e, "x", "pad"); if (0 === o.rank) throw new Error("pad(scalar) is not defined. Pass non-scalar to pad"); const s = { paddings: t, constantValue: n }, u = { x: o }; return r.T2.runKernel(i.ODT, u, s) } + }) + }, 7872: (e, t, n) => { + "use strict"; n.d(t, { d: () => d }); var r = n(8189), i = n(5119), a = n(3909), o = n(9772), s = n(7195), u = n(6999), l = n(929), c = n(2302), h = n(776); const d = (0, l.op)({ + pool_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, l, d, f, p) { null == d && (d = [1, 1]), null == f && (f = 1), 0 === l && (l = "valid"); const m = (0, r.YT)(e, "x", "maxPool"); let g = m, y = !1; 3 === m.rank && (y = !0, g = (0, c.t)(m, [1, m.shape[0], m.shape[1], m.shape[2]])), i.vA(s.G0(f, d), (() => `Error in pool: Either strides or dilations must be 1. Got strides ${f} and dilations '${d}'`)); const b = s.E6(g.shape, t, f, d, l), v = [b.dilationHeight, b.dilationWidth]; let x; x = "same" === l ? function (e, t) { const n = e.map(((e, n) => e + (e - 1) * (t[n] - 1))), r = n.map((e => e - 1)), i = r.map((e => Math.floor(e / 2))), a = r.map(((e, t) => e - i[t])); return r.map(((e, t) => [i[t], a[t]])) }([b.filterHeight, b.filterWidth], v) : [[0, 0], [0, 0]]; const w = 1 === v[0] && 1 === v[1], [k, S] = function (e, t, n) { const r = n.map((e => e[0])), i = n.map((e => e[1])), a = e.concat(r, i), o = t.map(((e, t) => (e - a[t] % e) % e)), s = i.map(((e, t) => e + o[t])), u = t.map(((e, t) => [r[t], s[t]])), l = t.map(((e, t) => [0, o[t]])); return [u, l] }([b.inHeight, b.inWidth], v, x), _ = w ? l : "valid", C = w ? g : (0, h.e)(g, v, k), A = ("avg" === n ? () => (0, a.$)(C, t, f, _, p) : () => (0, u.j)(C, t, f, _, p))(), T = w ? A : (0, o.G)(A, v, S); return y ? (0, c.t)(T, [T.shape[1], T.shape[2], T.shape[3]]) : T } + }) + }, 8990: (e, t, n) => { + "use strict"; n.d(t, { n: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + pow_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "base", "pow"), s = (0, o.YT)(t, "exp", "pow");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.pyJ, u) } + }) + }, 4394: (e, t, n) => { + "use strict"; n.d(t, { N: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + prelu_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = { x: (0, a.YT)(e, "x", "prelu"), alpha: (0, a.YT)(t, "alpha", "prelu") }; return r.T2.runKernel(i.Ncv, n) } + }) + }, 5295: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function r(e, t = !1) { console.log(e.toString(t)) } n.d(t, { y: () => r }) + }, 7771: (e, t, n) => { + "use strict"; n.d(t, { _: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(9809); const s = (0, n(929).op)({ + prod_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { let s = (0, a.YT)(e, "x", "prod"); "bool" === s.dtype && (s = (0, o.w)(s, "int32")); const u = { x: s }, l = { axis: t, keepDims: n }; return r.T2.runKernel(i.kdj, u, l) } + }) + }, 1902: (e, t, n) => { + "use strict"; n.d(t, { x: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + real_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { input: (0, a.YT)(e, "input", "real") }; return r.T2.runKernel(i.LRy, t) } + }) + }, 9870: (e, t, n) => { + "use strict"; n.d(t, { V: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + reciprocal_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "reciprocal") }; return r.T2.runKernel(i.huO, t) } + }) + }, 112: (e, t, n) => { + "use strict"; n.d(t, { V: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + relu_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "relu") }; return r.T2.runKernel(i.fUj, t) } + }) + }, 3732: (e, t, n) => { + "use strict"; n.d(t, { j: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + relu6_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "relu6") }; return r.T2.runKernel(i.P_L, t) } + }) + }, 2302: (e, t, n) => { + "use strict"; n.d(t, { t: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + reshape_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = { x: (0, a.YT)(e, "x", "reshape", "string_or_numeric") }, o = { shape: t }; return r.T2.runKernel(i.R23, n, o) } + }) + }, 3262: (e, t, n) => { + "use strict"; n.d(t, { B: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + reverse_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = { x: (0, a.YT)(e, "x", "reverse") }, o = { dims: t }; return r.T2.runKernel(i.D7i, n, o) } + }) + }, 5912: (e, t, n) => { + "use strict"; n.d(t, { L: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + round_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "round") }; return r.T2.runKernel(i.hVg, t) } + }) + }, 7820: (e, t, n) => { + "use strict"; n.d(t, { Z: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + rsqrt_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "rsqrt", "float32") }; return r.T2.runKernel(i.TOR, t) } + }) + }, 5702: (e, t, n) => { + "use strict"; n.d(t, { d: () => a }); var r = n(3879), i = n(9171); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function a(e, t) { if (((0, r.isTypedArray)(e) && "string" !== t || Array.isArray(e)) && "complex64" !== t) throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)"); if ("string" === t && (0, r.isTypedArray)(e) && !(e instanceof Uint8Array)) throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`."); return (0, i.Q)(e, [], [], t) } + }, 6170: (e, t, n) => { "use strict"; n.r(t), n.d(t, { calculateShapes: () => o, validateInput: () => a, validateUpdateShape: () => i }); var r = n(5119); function i(e, t, n) { const r = t.rank > 1 ? t.shape[t.rank - 1] : 1, i = t.rank > 1 ? t.rank - 1 : 1, a = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${i}.`; if (n.rank < i) throw new Error(a + ` update.rank < ${i}. `); if (e.length < r + (n.rank - i)) throw new Error(a + ` Output shape length < ${r + (n.rank - i)}`); if (n.rank !== i + e.length - r) throw new Error(a + " update.rank != " + (i + e.length - r)); for (let e = 0; e < i; ++e)if (n.shape[e] !== t.shape[e]) throw new Error(a + ` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`); for (let t = 0; t < n.rank - i; ++t)if (n.shape[t + i] !== e[t + r]) throw new Error(a + ` updates.shape[${t + i}] (${n.shape[t + i]}) != shape[${t + i}] (${e[t + i]})`) } function a(e, t, n) { if (t.rank < 1) throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`); if (e.rank < 1) throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`); if ("int32" !== t.dtype) throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`); if (n.length < 1) throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`); if (0 === n.length) { if (0 === t.size) throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`); if (0 === e.size) throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`) } i(n, t, e) } function o(e, t, n) { const i = t.shape.length, a = i > 1 ? t.shape[i - 1] : 1, o = n.length; let s = 1; for (let e = a; e < o; ++e)s *= n[e]; const u = a < 1 ? 1 : a; return { sliceRank: a, numUpdates: (0, r.Ze)(t.shape) / u, sliceSize: s, strides: [...(0, r.Ur)(n.slice(0, a)), 1], outputSize: (0, r.Ze)(n) } } }, 6325: (e, t, n) => { + "use strict"; n.d(t, { W: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + selu_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "selu") }; return r.T2.runKernel(i.u$b, t) } + }) + }, 8576: (e, t, n) => { + "use strict"; n.d(t, { X: () => i, j: () => r }); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const r = 1.7580993408473768, i = 1.0507009873554805 + }, 9986: (e, t, n) => { "use strict"; n.d(t, { w: () => l }); var r = n(8189), i = n(5119), a = n(8794), o = n(676), s = n(929), u = n(2302); const l = (0, s.op)({ separableConv2d_: function (e, t, n, s, l, c = [1, 1], h = "NHWC") { const d = (0, r.YT)(e, "x", "separableConv2d"), f = (0, r.YT)(t, "depthwiseFilter", "separableConv2d"), p = (0, r.YT)(n, "pointwiseFilter", "separableConv2d"); let m = d, g = !1; if (3 === d.rank && (g = !0, m = (0, u.t)(d, [1, d.shape[0], d.shape[1], d.shape[2]])), "NCHW" === h) throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported"); i.vA(4 === m.rank, (() => `Error in separableConv2d: input must be rank 4, but got rank ${m.rank}.`)), i.vA(4 === f.rank, (() => `Error in separableConv2d: depthwise filter must be rank 4, but got rank ${f.rank}.`)), i.vA(4 === p.rank, (() => `Error in separableConv2d: pointwise filter must be rank 4, but got rank ${f.rank}.`)), i.vA(1 === p.shape[0], (() => `Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${p.shape[0]}.`)), i.vA(1 === p.shape[1], (() => `Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${p.shape[1]}.`)); const y = f.shape[2], b = f.shape[3]; i.vA(p.shape[2] === y * b, (() => `Error in separableConv2d: the third dimension of pointwise filter must be ${y * b}, but got ${p.shape[2]}.`)); const v = (0, o.G)(m, f, s, l, h, c), x = (0, a.X)(v, p, 1, "valid", h); return g ? (0, u.t)(x, [x.shape[1], x.shape[2], x.shape[3]]) : x } }) }, 8968: (e, t, n) => { + "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + sigmoid_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "sigmoid", "float32") }; return r.T2.runKernel(i.vI1, t) } + }) + }, 1115: (e, t, n) => { + "use strict"; n.d(t, { _: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + sign_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "sign") }; return r.T2.runKernel(i.YVe, t) } + }) + }, 3726: (e, t, n) => { + "use strict"; n.d(t, { F: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + sin_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "sin", "float32") }; return r.T2.runKernel(i.hql, t) } + }) + }, 8276: (e, t, n) => { + "use strict"; n.d(t, { L: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + sinh_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "sinh") }; return r.T2.runKernel(i.J3C, t) } + }) + }, 7986: (e, t, n) => { + "use strict"; n.d(t, { d: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + slice_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const o = (0, a.YT)(e, "x", "slice", "string_or_numeric"); if (0 === o.rank) throw new Error("Slicing scalar is not possible"); const s = { x: o }, u = { begin: t, size: n }; return r.T2.runKernel(i.JiE, s, u) } + }) + }, 4969: (e, t, n) => { + "use strict"; n.r(t), n.d(t, { assertParamsValid: () => o, computeFlatOffset: () => v, computeOutShape: () => u, getNormalizedAxes: () => d, isSliceContinous: () => b, maskToAxes: () => s, parseSliceParams: () => x, sliceInfo: () => w, startForAxis: () => g, startIndicesWithElidedDims: () => f, stopForAxis: () => y, stopIndicesWithElidedDims: () => p, stridesForAxis: () => m, stridesWithElidedDims: () => l }); var r = n(5119); +/** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */const i = -2, a = -1; function o(e, t, n) { const i = e.shape.length; r.vA(i === t.length, (() => `Error in slice${i}D: Length of begin ${t} must match the rank of the array (${i}).`)), r.vA(i === n.length, (() => `Error in slice${i}D: Length of size ${n} must match the rank of the array (${i}).`)); for (let a = 0; a < i; ++a)r.vA(t[a] + n[a] <= e.shape[a], (() => `Error in slice${i}D: begin[${a}] + size[${a}] (${t[a] + n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`)) } function s(e) { const t = []; let n = 0; for (; e > 0;)1 & e && t.push(n), e /= 2, n++; return t } function u(e, t, n) { const r = []; for (let i = 0; i < e.length; i++)r[i] = Math.ceil((t[i] - e[i]) / n[i]); return r } function l(e, t, n, r) { const i = [...e]; for (let e = i.length; e < r.length; e++)i.push(1); for (let e = 0; e < n; e++)0 === e ? i[t] = 1 : (i.splice(t, 0, 1), i.pop()); return i } function c(e, t, n) { return n <= e ? n : n - (t - 1) } function h(e, t) { const n = []; for (let r = 0; r < e; r++)n.push(t + r); return n } function d(e, t, n, r, i, a, o, s, u) { const c = e.length; let h = new Array(c), d = new Array(c), b = new Array(c); if (t.length && n > 0) { const u = t[0], c = n + 1; h = f(o, u, c, r, e), d = p(s, u, c, i, e), b = l(a, u, c, e) } else for (let t = 0; t < c; t++)h[t] = g(o, r, a, e, t, u), d[t] = y(s, i, a, e, t, u), b[t] = m(a, t, u); return { begin: h, end: d, strides: b } } function f(e, t, n, r, i) { const a = [...i], o = h(n, t); for (let i = 0; i < a.length; i++)if (o.indexOf(i) > -1) a[i] = 0; else { const o = c(t, n, i); let s = r[o]; e & 1 << o && (s = 0), a[i] = s } return a } function p(e, t, n, i, a) { const o = [...a], s = h(n, t); for (let r = 0; r < o.length; r++)if (s.indexOf(r) > -1) o[r] = Number.MAX_SAFE_INTEGER; else { const a = c(t, n, r); let s = i[a]; e & 1 << a && (s = Number.MAX_SAFE_INTEGER), o[r] = s } for (let e = 0; e < o.length; e++) { const t = a[e]; o[e] < 0 && (o[e] += t), o[e] = r.qE(0, o[e], a[e]) } return o } function m(e, t, n) { let r = e[t]; return (n & 1 << t || null == r) && (r = 1), r } function g(e, t, n, i, a, o) { let s = t[a]; const u = n[a] || 1; (e & 1 << a || o & 1 << a || null == s) && (s = u > 0 ? Number.MIN_SAFE_INTEGER : Number.MAX_SAFE_INTEGER); const l = i[a]; return s < 0 && (s += l), s = r.qE(0, s, l - 1), s } function y(e, t, n, i, a, o) { let s = t[a]; const u = n[a] || 1; (e & 1 << a || o & 1 << a || null == s) && (s = u > 0 ? Number.MAX_SAFE_INTEGER : Number.MIN_SAFE_INTEGER); const l = i[a]; return s < 0 && (s += l), s = u > 0 ? r.qE(0, s, l) : r.qE(-1, s, l - 1), s } function b(e, t, n) { let r = n.length; for (let e = 0; e < n.length; e++)if (n[e] > 1) { r = e; break } for (let i = r + 1; i < n.length; i++)if (t[i] > 0 || n[i] !== e[i]) return !1; return !0 } function v(e, t) { let n = e.length > 0 ? e[e.length - 1] : 1; for (let r = 0; r < e.length - 1; r++)n += e[r] * t[r]; return n } function x(e, t, n) { let i; const a = e.shape.length; let o; return i = "number" == typeof t ? [t, ...new Array(a - 1).fill(0)] : t.length < a ? t.concat(new Array(a - t.length).fill(0)) : t.slice(), i.forEach((e => { r.vA(-1 !== e, (() => "slice() does not support negative begin indexing.")) })), o = null == n ? new Array(a).fill(-1) : "number" == typeof n ? [n, ...new Array(a - 1).fill(-1)] : n.length < a ? n.concat(new Array(a - n.length).fill(-1)) : n, o = o.map(((t, n) => t >= 0 ? t : (r.vA(-1 === t, (() => `Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)), e.shape[n] - i[n]))), [i, o] } function w(e, t, n, r, o, s, u, l, c) { let h; if (null == r ? (h = new Array(t.length), h.fill(1)) : h = r, null != u && u & u - 1) throw new Error("Multiple ellipses in slice is not allowed."); let d = !1; const f = { dims: h.length, numAddAxisAfterEllipsis: 0, begin: t.slice(), end: n.slice(), strides: h.slice(), beginMask: o, endMask: s, ellipsisMask: u, newAxisMask: l, shrinkAxisMask: c }; for (let e = 0; e < f.dims; e++)d && 1 << e & l && f.numAddAxisAfterEllipsis++, 1 << e & u && (d = !0); d || (f.ellipsisMask |= 1 << f.dims, f.dims++); const p = { dims: e.length, beginMask: 0, endMask: 0, beginValid: !1, endValid: !1 }; !function (e, t) { t.beginMask = 0, t.endMask = 0, t.shrinkAxisMask = 0; let n = 0; t.beginValid = null != e.begin, t.endValid = null != e.end, t.begin = new Array(t.dims), t.end = new Array(t.dims), t.strides = new Array(t.dims), t.finalShapeGatherIndices = [], t.finalShapeGatherIndicesSparse = [], t.inputShapeGatherIndicesSparse = new Array(t.dims); for (let r = 0; r < e.dims; r++)if (1 << r & e.ellipsisMask) { const i = Math.min(t.dims - (e.dims - r) + 1 + e.numAddAxisAfterEllipsis, t.dims); for (; n < i; n++)t.begin[n] = 0, t.end[n] = 0, t.strides[n] = 1, t.beginMask |= 1 << n, t.endMask |= 1 << n, t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(-1), t.inputShapeGatherIndicesSparse[n] = r } else if (1 << r & e.newAxisMask) t.finalShapeGatherIndices.push(i), t.finalShapeGatherIndicesSparse.push(-1); else { if (n === t.begin.length) throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`); null != e.begin && (t.begin[n] = e.begin[r]), null != e.end && (t.end[n] = e.end[r]), t.strides[n] = e.strides[r], e.beginMask & 1 << r && (t.beginMask |= 1 << n), e.endMask & 1 << r && (t.endMask |= 1 << n), e.shrinkAxisMask & 1 << r ? (t.finalShapeGatherIndices.push(a), t.finalShapeGatherIndicesSparse.push(-1), t.shrinkAxisMask |= 1 << n) : (t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(r)), t.inputShapeGatherIndicesSparse[n] = r, n++ } }(f, p); let m = !0, g = !0, y = !0; const b = [], v = []; for (let t = 0; t < e.length; ++t) { if (0 === p.strides[t]) throw Error(`strides[${t}] must be non-zero`); const n = !!(p.shrinkAxisMask & 1 << t), r = e[t]; if (-1 === r) { b.push(n ? 1 : -1); continue } const i = [p.beginMask & 1 << t, p.endMask & 1 << t], a = [p.strides[t] > 0 ? 0 : -1, p.strides[t] > 0 ? r : r - 1]; if (n && p.strides[t] <= 0) throw Error("only stride 1 allowed on non-range indexing."); y = y && 1 === p.strides[t]; const o = !!(p.beginMask & 1 << t && p.endMask & 1 << t); if (p.beginValid && p.endValid) { if (n) { const e = p.begin[t] < 0 ? r + p.begin[t] : p.begin[t]; if (p.begin[t] = e, p.end[t] = p.begin[t] + 1, e < 0 || e >= r) throw Error(`slice index ${p.begin[t]} of dimension ${t} out of bounds.`) } else p.begin[t] = k(p.begin[t], 0, p.strides[t], r, i, a), p.end[t] = k(p.end[t], 1, p.strides[t], r, i, a); const e = 1 === p.strides[t] && 0 === p.begin[t] && p.end[t] === r; m = m && e, g = g && (0 === t && 1 === p.strides[t] || e) } else m = m && 1 === p.strides[t] && o, g = g && (0 === t && 1 === p.strides[t] || o); let s, u = !1; if (p.beginValid && p.endValid ? (s = p.end[t] - p.begin[t], u = !0) : n ? (s = 1, u = !0) : o && r >= 0 && (s = p.strides[t] < 0 ? -r : r, u = !0), u) { let e; e = 0 === s || s < 0 != p.strides[t] < 0 ? 0 : Math.trunc(s / p.strides[t]) + (s % p.strides[t] != 0 ? 1 : 0), b.push(e) } else b.push(-1) } for (let e = 0; e < p.finalShapeGatherIndices.length; ++e) { const t = p.finalShapeGatherIndices[e]; t >= 0 ? v.push(b[t]) : t === i && v.push(1) } return { finalShapeSparse: v.filter(((e, t) => p.finalShapeGatherIndices[t] !== i)), finalShape: v, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: p.begin, end: p.end, strides: p.strides } } function k(e, t, n, r, i, a) { if (i[t]) return n > 0 ? a[t] : a[t + 1 & 1]; { const t = e < 0 ? r + e : e; return t < a[0] ? a[0] : t > a[1] ? a[1] : t } } + }, 6346: (e, t, n) => { + "use strict"; n.d(t, { V: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + softmax_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = -1) { const n = (0, a.YT)(e, "logits", "softmax", "float32"); if (-1 === t && (t = n.rank - 1), t !== n.rank - 1) throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`); const o = { logits: n }, s = { dim: t }; return r.T2.runKernel(i.rFG, o, s) } + }) + }, 6030: (e, t, n) => { + "use strict"; n.d(t, { l: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + softplus_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "softplus") }; return r.T2.runKernel(i.Fin, t) } + }) + }, 776: (e, t, n) => { + "use strict"; n.d(t, { e: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + spaceToBatchND_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const s = (0, a.YT)(e, "x", "spaceToBatchND"); o.vA(s.rank >= 1 + t.length, (() => `input rank ${s.rank} should be > than [blockShape] ${t.length}`)), o.vA(n.length === t.length, (() => `paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)), o.vA(s.shape.reduce(((e, r, i) => i > 0 && i <= t.length ? e && (r + n[i - 1][0] + n[i - 1][1]) % t[i - 1] == 0 : e), !0), (() => `input spatial dimensions ${s.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`)); const u = { x: s }, l = { blockShape: t, paddings: n }; return r.T2.runKernel(i.A8B, u, l) } + }) + }, 1361: (e, t, n) => { + "use strict"; n.d(t, { h: () => o }); var r = n(1585), i = n(5441), a = n(5119); const o = (0, n(929).op)({ + fft_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { (0, a.vA)("complex64" === e.dtype, (() => `The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`)); const t = { input: e }; return r.T2.runKernel(i.rGP, t) } + }) + }, 3108: (e, t, n) => { + "use strict"; n.d(t, { K: () => o }); var r = n(1585), i = n(5441), a = n(5119); const o = (0, n(929).op)({ + ifft_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { (0, a.vA)("complex64" === e.dtype, (() => `The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`)); const t = { input: e }; return r.T2.runKernel(i.OAQ, t) } + }) + }, 2292: (e, t, n) => { + "use strict"; n.d(t, { g: () => p }); var r = n(7148), i = n(5030), a = n(5040), o = n(9258), s = n(929), u = n(1902), l = n(2302), c = n(3262), h = n(5702), d = n(7986), f = n(3108); const p = (0, s.op)({ + irfft_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = e.shape[e.shape.length - 1], n = e.size / t; let s; if (t <= 2) { const r = (0, l.t)(e, [n, t]); s = (0, f.K)(r) } else { const p = [n, 2 * (t - 1)], m = (0, l.t)((0, u.x)(e), [n, t]), g = (0, l.t)((0, a.n)(e), [n, t]), y = (0, c.B)((0, d.d)(m, [0, 1], [n, t - 2]), 1), b = (0, o.l)((0, c.B)((0, d.d)(g, [0, 1], [n, t - 2]), 1), (0, h.d)(-1)), v = (0, i.x)([m, y], 1), x = (0, i.x)([g, b], 1), w = (0, l.t)((0, r.f)(v, x), [p[0], p[1]]); s = (0, f.K)(w) } if (s = (0, u.x)(s), 3 === e.rank && 0 !== e.shape[0]) { const t = s, n = e.shape[0]; s = (0, l.t)(s, [n, s.shape[0] / n, s.shape[1]]), t.dispose() } return s } + }) + }, 8775: (e, t, n) => { + "use strict"; n.d(t, { z: () => m }); var r = n(5119), i = n(7148), a = n(5030), o = n(5040), s = n(929), u = n(1902), l = n(2302), c = n(7986), h = n(6512), d = n(2855), f = n(5537), p = n(1361); const m = (0, s.op)({ + rfft_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { (0, r.vA)("float32" === e.dtype, (() => `The dtype for rfft() must be real value but got ${e.dtype}`)); let n = e.shape[e.shape.length - 1]; const s = e.size / n; let m; if (null != t && t < n) { const r = e.shape.map((e => 0)), i = e.shape.map((e => e)); i[e.shape.length - 1] = t, m = (0, c.d)(e, r, i), n = t } else if (null != t && t > n) { const r = e.shape.map((e => e)); r[e.shape.length - 1] = t - n, m = (0, a.x)([e, (0, d.U)(r)], e.shape.length - 1), n = t } else m = e; const g = (0, f.P)(m), y = (0, l.t)((0, i.f)(m, g), [s, n]), b = (0, p.h)(y), v = Math.floor(n / 2) + 1, x = (0, u.x)(b), w = (0, o.n)(b), k = (0, h.l)(x, [v, n - v], x.shape.length - 1), S = (0, h.l)(w, [v, n - v], w.shape.length - 1), _ = m.shape.slice(); return _[m.shape.length - 1] = v, (0, l.t)((0, i.f)(k[0], S[0]), _) } + }) + }, 6512: (e, t, n) => { + "use strict"; n.d(t, { l: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + split_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n = 0) { const o = { x: (0, a.YT)(e, "x", "split") }, s = { numOrSizeSplits: t, axis: n }; return r.T2.runKernel(i.Blb, o, s) } + }) + }, 9348: (e, t, n) => { + "use strict"; n.d(t, { R: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + sqrt_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "sqrt", "float32") }; return r.T2.runKernel(i.dFH, t) } + }) + }, 5793: (e, t, n) => { + "use strict"; n.d(t, { E: () => a }); var r = n(1585), i = n(8189); const a = (0, n(929).op)({ + square_: + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = (0, i.YT)(e, "x", "square"); return r.T2.runKernel("Square", { x: t }, {}) } + }) + }, 3427: (e, t, n) => { + "use strict"; n.d(t, { P: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ + squaredDifference_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "squaredDifference"), u = (0, o.YT)(t, "b", "squaredDifference");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.Ddj, l, {}) } + }) + }, 5932: (e, t, n) => { + "use strict"; n.d(t, { r: () => s }); var r = n(8189), i = n(5119), a = n(929), o = n(2302); const s = (0, a.op)({ + squeeze_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, r.YT)(e, "x", "squeeze", "string_or_numeric"); return (0, o.t)(n, (0, i.gx)(n.shape, t).newShape) } + }) + }, 4268: (e, t, n) => { + "use strict"; n.d(t, { t: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + stack_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = (0, a.j1)(e, "tensors", "stack", "string_or_numeric"); o.vA(n.length >= 1, (() => "Pass at least one tensor to tf.stack")), n.length > 0 && o.vA(t <= n[0].rank, (() => "Axis must be <= rank of the tensor")); const s = n, u = { axis: t }; return r.T2.runKernel(i.mM$, s, u) } + }) + }, 700: (e, t, n) => { + "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + step_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = { x: (0, a.YT)(e, "x", "step") }, o = { alpha: t }; return r.T2.runKernel(i.pnw, n, o) } + }) + }, 5894: (e, t, n) => { + "use strict"; n.d(t, { Y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + stridedSlice_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, o, s = 0, u = 0, l = 0, c = 0, h = 0) { const d = { x: (0, a.YT)(e, "x", "stridedSlice", "string_or_numeric") }, f = { begin: t, end: n, strides: o, beginMask: s, endMask: u, ellipsisMask: l, newAxisMask: c, shrinkAxisMask: h }; return r.T2.runKernel(i.UcO, d, f) } + }) + }, 7126: (e, t, n) => { + "use strict"; n.d(t, { j: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ + sub_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { let n = (0, o.YT)(e, "a", "sub"), s = (0, o.YT)(t, "b", "sub");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.PbM, u) } + }) + }, 3791: (e, t, n) => { + "use strict"; n.d(t, { c: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(9809); const s = (0, n(929).op)({ + sum_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = null, n = !1) { let s = (0, a.YT)(e, "x", "sum"); "bool" === s.dtype && (s = (0, o.w)(s, "int32")); const u = { x: s }, l = { axis: t, keepDims: n }; return r.T2.runKernel(i.WuN, u, l) } + }) + }, 7823: (e, t, n) => { + "use strict"; n.d(t, { M: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + tan_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "tan", "float32") }; return r.T2.runKernel(i.oFs, t) } + }) + }, 7311: (e, t, n) => { + "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + tanh_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "tanh", "float32") }; return r.T2.runKernel(i.iuW, t) } + }) + }, 4027: (e, t, n) => { + "use strict"; n.d(t, { O: () => a }); var r = n(8189), i = n(9171); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function a(e, t, n) { const a = (0, r.MZ)(e, n); return (0, i.Q)(e, t, a, n) } + }, 2768: (e, t, n) => { + "use strict"; n.d(t, { $: () => o }); var r = n(8189), i = n(5119), a = n(9171); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function o(e, t, n) { if ((0, i.HO)(e), null != t && 3 !== t.length) throw new Error("tensor3d() requires shape to have three numbers"); const o = (0, r.MZ)(e, n); if (3 !== o.length && 1 !== o.length) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (1 === o.length && null == t) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); return (0, a.Q)(e, t, o, n) } + }, 9171: (e, t, n) => { + "use strict"; n.d(t, { Q: () => s }); var r = n(1585), i = n(2046), a = n(5119), o = n(3879); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function s(e, t, n, s) { if (null == s) s = (0, a.X$)(e); else if ("complex64" === s) throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if ((0, i.Nw)(e) || (0, i.Oj)(e)) { if ("float32" !== s && "int32" !== s) throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`); return r.T2.backend.createTensorFromGPUData(e, t || n, s) } if (!(0, o.isTypedArray)(e) && !Array.isArray(e) && "number" != typeof e && "boolean" != typeof e && "string" != typeof e) throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray"); if (null != t) { (0, a.SA)(t); const e = (0, a.Ze)(t), r = (0, a.Ze)(n); (0, a.vA)(e === r, (() => `Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`)); for (let e = 0; e < n.length; ++e) { const r = n[e], i = e !== n.length - 1 || r !== (0, a.Ze)(t.slice(e)); (0, a.vA)(n[e] === t[e] || !i, (() => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)) } } return (0, o.isTypedArray)(e) || Array.isArray(e) || (e = [e]), t = t || n, e = "string" !== s ? (0, o.toTypedArray)(e, s) : (0, o.flatten)(e, [], !0), r.T2.makeTensor(e, t, s) } + }, 4826: (e, t, n) => { + "use strict"; n.d(t, { V: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + tile_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t) { const n = (0, a.YT)(e, "x", "tile", "string_or_numeric"); o.vA(n.rank === t.length, (() => `Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`)); const s = { x: n }, u = { reps: t }; return r.T2.runKernel(i.FAs, s, u) } + }) + }, 1190: (e, t, n) => { + "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + topk_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 1, n = !0) { const o = (0, a.YT)(e, "x", "topk"); if (0 === o.rank) throw new Error("topk() expects the input to be of rank 1 or higher"); const s = o.shape[o.shape.length - 1]; if (t < 0) throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`); if (t > s) throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${t}`); const u = { x: o }, l = { k: t, sorted: n }, [c, h] = r.T2.runKernel(i.TBb, u, l); return { values: c, indices: h } } + }) + }, 7703: (e, t, n) => { + "use strict"; n.d(t, { m: () => f }); var r = n(1585), i = n(5287), a = n(5441), o = n(8189), s = n(5119), u = n(7148), l = n(5040), c = n(6522), h = n(929), d = n(1902); const f = (0, h.op)({ + transpose_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const h = (0, o.YT)(e, "x", "transpose"); if (null == t && (t = h.shape.map(((e, t) => t)).reverse()), s.vA(h.rank === t.length, (() => `Error in transpose: rank of input ${h.rank} must match length of perm ${t}.`)), t.forEach((e => { s.vA(e >= 0 && e < h.rank, (() => "All entries in 'perm' must be between 0 and " + (h.rank - 1) + ` but got ${t}`)) })), h.rank <= 1) return h.clone(); const f = { x: h }, p = { perm: t }; return "complex64" === h.dtype ? (0, i.DZ)((() => { let e = (0, d.x)(h), t = (0, l.n)(h); return e = r.T2.runKernel(a.wx0, { x: e }, p), t = r.T2.runKernel(a.wx0, { x: t }, p), n && (t = (0, c.H)(t)), (0, u.f)(e, t) })) : r.T2.runKernel(a.wx0, f, p) } + }) + }, 3937: (e, t, n) => { + "use strict"; n.d(t, { A: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + unique_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = (0, a.YT)(e, "x", "unique", "string_or_numeric"); (0, o.vA)(n.rank > 0, (() => "The input tensor must be at least 1D")); const s = { x: n }, u = { axis: t }, [l, c] = r.T2.runKernel(i.EwU, s, u); return { values: l, indices: c } } + }) + }, 7706: (e, t, n) => { + "use strict"; n.d(t, { z: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + unsortedSegmentSum_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const s = (0, a.YT)(e, "x", "unsortedSegmentSum"), u = (0, a.YT)(t, "segmentIds", "unsortedSegmentSum", "int32"); (0, o.vA)((0, o.E6)(n), (() => "numSegments must be of dtype int")); const l = { x: s, segmentIds: u }, c = { numSegments: n }; return r.T2.runKernel(i.pPe, l, c) } + }) + }, 7261: (e, t, n) => { + "use strict"; n.d(t, { K: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ + unstack_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t = 0) { const n = (0, a.YT)(e, "x", "unstack", "string_or_numeric"); o.vA(t >= -n.shape.length && t < n.shape.length, (() => `Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`)); const s = { value: n }, u = { axis: t }; return r.T2.runKernel(i.dXR, s, u) } + }) + }, 2151: (e, t, n) => { + "use strict"; n.d(t, { _: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(3567), s = n(2198); const u = (0, n(929).op)({ + where_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const u = (0, a.YT)(t, "a", "where"), l = (0, a.YT)(n, "b", "where"), c = (0, a.YT)(e, "condition", "where", "bool"), h = (0, s.assertAndGetBroadcastShape)((0, s.assertAndGetBroadcastShape)(c.shape, u.shape), l.shape), d = { condition: (0, o.h)(c, h), t: (0, o.h)(u, h), e: (0, o.h)(l, h) }; return r.T2.runKernel(i.l6P, d) } + }) + }, 2855: (e, t, n) => { + "use strict"; n.d(t, { U: () => o }); var r = n(1585), i = n(5119), a = n(7148); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function o(e, t = "float32") { if ((0, i.SA)(e), "complex64" === t) { const t = o(e, "float32"), n = o(e, "float32"); return (0, a.f)(t, n) } const n = (0, i.Ty)((0, i.Ze)(e), t); return r.T2.makeTensor(n, e, t) } + }, 5537: (e, t, n) => { + "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ + zerosLike_: + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = { x: (0, a.YT)(e, "x", "zerosLike") }; return r.T2.runKernel(i.xJ3, t) } + }) + }, 6448: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function r(e) { return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray } n.d(t, { Y: () => r }) + }, 455: (e, t, n) => { + "use strict"; var r = n(4888), i = n(259); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.abs = function () { return this.throwIfDisposed(), (0, r.t)(this) }; var a = n(2804); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.acos = function () { return this.throwIfDisposed(), (0, a.H)(this) }; var o = n(7558); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.acosh = function () { return this.throwIfDisposed(), (0, o.F)(this) }; var s = n(7523); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.add = function (e) { return this.throwIfDisposed(), (0, s.W)(this, e) }; var u = n(2307); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.all = function (e, t) { return this.throwIfDisposed(), (0, u.Q)(this, e, t) }; var l = n(9326); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.any = function (e, t) { return this.throwIfDisposed(), (0, l.b)(this, e, t) }; var c = n(897); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.argMax = function (e) { return this.throwIfDisposed(), (0, c.F)(this, e) }; var h = n(4339); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.argMin = function (e) { return this.throwIfDisposed(), (0, h.X)(this, e) }; var d = n(2302), f = n(5119); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.asScalar = function () { return this.throwIfDisposed(), (0, f.vA)(1 === this.size, (() => "The array must have only 1 element.")), (0, d.t)(this, []) }; var p = n(9809); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.asType = function (e) { return this.throwIfDisposed(), (0, p.w)(this, e) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.as1D = function () { return this.throwIfDisposed(), (0, d.t)(this, [this.size]) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.as2D = function (e, t) { return this.throwIfDisposed(), (0, d.t)(this, [e, t]) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.as3D = function (e, t, n) { return this.throwIfDisposed(), (0, d.t)(this, [e, t, n]) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.as4D = function (e, t, n, r) { return this.throwIfDisposed(), (0, d.t)(this, [e, t, n, r]) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.as5D = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, d.t)(this, [e, t, n, r, i]) }; var m = n(6841); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.asin = function () { return this.throwIfDisposed(), (0, m.q)(this) }; var g = n(269); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.asinh = function () { return this.throwIfDisposed(), (0, g.y)(this) }; var y = n(9580); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.atan = function () { return this.throwIfDisposed(), (0, y.r)(this) }; var b = n(1404); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.atan2 = function (e) { return this.throwIfDisposed(), (0, b.F)(this, e) }; var v = n(3774); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.atanh = function () { return this.throwIfDisposed(), (0, v.r)(this) }; var x = n(3909); (0, i.tp)().prototype.avgPool = function (e, t, n, r) { return this.throwIfDisposed(), (0, x.$)(this, e, t, n, r) }; var w = n(9772); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.batchToSpaceND = function (e, t) { return this.throwIfDisposed(), (0, w.G)(this, e, t) }; var k = n(9160); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.batchNorm = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, k.$)(this, e, t, n, r, i) }; var S = n(3567); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.broadcastTo = function (e) { return this.throwIfDisposed(), (0, S.h)(this, e) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.cast = function (e) { return this.throwIfDisposed(), (0, p.w)(this, e) }; var _ = n(855); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.ceil = function () { return this.throwIfDisposed(), (0, _.m)(this) }; var C = n(6928); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.clipByValue = function (e, t) { return this.throwIfDisposed(), (0, C.z)(this, e, t) }; var A = n(5030); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.concat = function (e, t) { return this.throwIfDisposed(), e instanceof i.qY && (e = [e]), (0, A.x)([this, ...e], t) }; var T = n(3701); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.conv1d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, T.k)(this, e, t, n, r, i, a) }; var E = n(1106); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.conv2dTranspose = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, E.w)(this, e, t, n, r, i) }; var N = n(8794); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.conv2d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, N.X)(this, e, t, n, r, i, a) }; var I = n(9907); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.cos = function () { return this.throwIfDisposed(), (0, I.g)(this) }; var M = n(7451); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.cosh = function () { return this.throwIfDisposed(), (0, M.y)(this) }; var F = n(302); + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.cumprod = function (e, t, n) { return this.throwIfDisposed(), (0, F.L)(this, e, t, n) }; var D = n(6808); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.cumsum = function (e, t, n) { return this.throwIfDisposed(), (0, D.r)(this, e, t, n) }; var $ = n(1216); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.depthToSpace = function (e, t) { return this.throwIfDisposed(), (0, $.R)(this, e, t) }; var R = n(676); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.depthwiseConv2d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, R.G)(this, e, t, n, r, i, a) }; var O = n(3002); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.dilation2d = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, O.X)(this, e, t, n, r, i) }; var z = n(919); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.divNoNan = function (e) { return this.throwIfDisposed(), (0, z.e)(this, e) }; var P = n(9359); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.div = function (e) { return this.throwIfDisposed(), (0, P.y)(this, e) }; var B = n(9759); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.dot = function (e) { return this.throwIfDisposed(), (0, B.O)(this, e) }; var L = n(3416); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.elu = function () { return this.throwIfDisposed(), (0, L.P)(this) }; var j = n(3020); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.equal = function (e) { return this.throwIfDisposed(), (0, j.L)(this, e) }; var U = n(5207); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.erf = function () { return this.throwIfDisposed(), (0, U.Y)(this) }; var W = n(4881); + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.euclideanNorm = function (e, t) { return this.throwIfDisposed(), (0, W.p)(this, e, t) }; var V = n(8631); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.exp = function () { return this.throwIfDisposed(), (0, V.o)(this) }; var G = n(8710); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.expandDims = function (e) { return this.throwIfDisposed(), (0, G.U)(this, e) }; var H = n(517); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.expm1 = function () { return this.throwIfDisposed(), (0, H.I)(this) }; var q = n(1361); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.fft = function () { return this.throwIfDisposed(), (0, q.h)(this) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.flatten = function () { return this.throwIfDisposed(), (0, d.t)(this, [this.size]) }; var Y = n(5606); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.floor = function () { return this.throwIfDisposed(), (0, Y.R)(this) }; var X = n(8991); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.floorDiv = function (e) { return this.throwIfDisposed(), (0, X.w)(this, e) }; var K = n(8229); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.gather = function (e, t, n) { return this.throwIfDisposed(), (0, K.k)(this, e, t, n) }; var Z = n(3337); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.greaterEqual = function (e) { return this.throwIfDisposed(), (0, Z.D)(this, e) }; var J = n(2058); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.greater = function (e) { return this.throwIfDisposed(), (0, J.r)(this, e) }; var Q = n(3108); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.ifft = function () { return this.throwIfDisposed(), (0, Q.K)(this) }; var ee = n(2292); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.irfft = function () { return this.throwIfDisposed(), (0, ee.g)(this) }; var te = n(8318); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.isFinite = function () { return this.throwIfDisposed(), (0, te.M)(this) }; var ne = n(3454); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.isInf = function () { return this.throwIfDisposed(), (0, ne.E)(this) }; var re = n(6300); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.isNaN = function () { return this.throwIfDisposed(), (0, re.y)(this) }; var ie = n(6919); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.leakyRelu = function (e) { return this.throwIfDisposed(), (0, ie.H)(this, e) }; var ae = n(6508); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.lessEqual = function (e) { return this.throwIfDisposed(), (0, ae.I)(this, e) }; var oe = n(1303); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.less = function (e) { return this.throwIfDisposed(), (0, oe.M)(this, e) }; var se = n(3531); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.localResponseNormalization = function (e, t, n, r) { return this.throwIfDisposed(), (0, se.K)(this, e, t, n, r) }; var ue = n(5645); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logSigmoid = function () { return this.throwIfDisposed(), (0, ue.n)(this) }; var le = n(7991); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logSoftmax = function (e) { return this.throwIfDisposed(), (0, le.H)(this, e) }; var ce = n(3330); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logSumExp = function (e, t) { return this.throwIfDisposed(), (0, ce.V)(this, e, t) }; var he = n(4010); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.log = function () { return this.throwIfDisposed(), (0, he.R)(this) }; var de = n(2015); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.log1p = function () { return this.throwIfDisposed(), (0, de.K)(this) }; var fe = n(3789); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logicalAnd = function (e) { return this.throwIfDisposed(), (0, fe.n)(this, e) }; var pe = n(9881); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logicalNot = function () { return this.throwIfDisposed(), (0, pe.N)(this) }; var me = n(9879); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logicalOr = function (e) { return this.throwIfDisposed(), (0, me.z)(this, e) }; var ge = n(9925); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.logicalXor = function (e) { return this.throwIfDisposed(), (0, ge.r)(this, e) }; var ye = n(5703); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.matMul = function (e, t, n) { return this.throwIfDisposed(), (0, ye.N)(this, e, t, n) }; var be = n(6999); (0, i.tp)().prototype.maxPool = function (e, t, n, r) { return this.throwIfDisposed(), (0, be.j)(this, e, t, n, r) }; var ve = n(1938); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.max = function (e, t) { return this.throwIfDisposed(), (0, ve.T)(this, e, t) }; var xe = n(178); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.maximum = function (e) { return this.throwIfDisposed(), (0, xe.P)(this, e) }; var we = n(2611); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.mean = function (e, t) { return this.throwIfDisposed(), (0, we.i)(this, e, t) }; var ke = n(7436); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.min = function (e, t) { return this.throwIfDisposed(), (0, ke.j)(this, e, t) }; var Se = n(2644); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.minimum = function (e) { return this.throwIfDisposed(), (0, Se.B)(this, e) }; var _e = n(6567); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.mirrorPad = function (e, t) { return this.throwIfDisposed(), (0, _e.F)(this, e, t) }; var Ce = n(152); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.mod = function (e) { return this.throwIfDisposed(), (0, Ce.z)(this, e) }; var Ae = n(9258); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.mul = function (e) { return this.throwIfDisposed(), (0, Ae.l)(this, e) }; var Te = n(6522); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.neg = function () { return this.throwIfDisposed(), (0, Te.H)(this) }; var Ee = n(2596); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.norm = function (e, t, n) { return this.throwIfDisposed(), (0, Ee.x)(this, e, t, n) }; var Ne = n(2118); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.notEqual = function (e) { return this.throwIfDisposed(), (0, Ne.E)(this, e) }; var Ie = n(1760); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.oneHot = function (e, t = 1, n = 0) { return this.throwIfDisposed(), (0, Ie.M)(this, e, t, n) }; var Me = n(9885); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.onesLike = function () { return this.throwIfDisposed(), (0, Me.P)(this) }; var Fe = n(5661); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.pad = function (e, t) { return this.throwIfDisposed(), (0, Fe.e)(this, e, t) }; var De = n(7872); (0, i.tp)().prototype.pool = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, De.d)(this, e, t, n, r, i, a) }; var $e = n(8990); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.pow = function (e) { return this.throwIfDisposed(), (0, $e.n)(this, e) }; var Re = n(4394); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.prelu = function (e) { return this.throwIfDisposed(), (0, Re.N)(this, e) }; var Oe = n(7771); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.prod = function (e, t) { return this.throwIfDisposed(), (0, Oe._)(this, e, t) }; var ze = n(9870); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.reciprocal = function () { return this.throwIfDisposed(), (0, ze.V)(this) }; var Pe = n(112); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.relu = function () { return this.throwIfDisposed(), (0, Pe.V)(this) }; var Be = n(3732); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.relu6 = function () { return this.throwIfDisposed(), (0, Be.j)(this) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.reshapeAs = function (e) { return this.throwIfDisposed(), (0, d.t)(this, e.shape) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.reshape = function (e) { return this.throwIfDisposed(), (0, d.t)(this, e) }; var Le = n(4711); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.resizeBilinear = function (e, t, n) { return this.throwIfDisposed(), (0, Le.v)(this, e, t, n) }; var je = n(2954); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.resizeNearestNeighbor = function (e, t, n) { return this.throwIfDisposed(), (0, je.b)(this, e, t, n) }; var Ue = n(3262); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.reverse = function (e) { return this.throwIfDisposed(), (0, Ue.B)(this, e) }; var We = n(8775); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.rfft = function () { return this.throwIfDisposed(), (0, We.z)(this) }; var Ve = n(5912); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.round = function () { return this.throwIfDisposed(), (0, Ve.L)(this) }; var Ge = n(7820); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.rsqrt = function () { return this.throwIfDisposed(), (0, Ge.Z)(this) }; var He = n(6325); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.selu = function () { return this.throwIfDisposed(), (0, He.W)(this) }; var qe = n(9986); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.separableConv2d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, qe.w)(this, e, t, n, r, i, a) }; var Ye = n(8968); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sigmoid = function () { return this.throwIfDisposed(), (0, Ye.r)(this) }; var Xe = n(1115); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sign = function () { return this.throwIfDisposed(), (0, Xe._)(this) }; var Ke = n(3726); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sin = function () { return this.throwIfDisposed(), (0, Ke.F)(this) }; var Ze = n(8276); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sinh = function () { return this.throwIfDisposed(), (0, Ze.L)(this) }; var Je = n(7986); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.slice = function (e, t) { return this.throwIfDisposed(), (0, Je.d)(this, e, t) }; var Qe = n(6346); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.softmax = function (e) { return this.throwIfDisposed(), (0, Qe.V)(this, e) }; var et = n(6030); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.softplus = function () { return this.throwIfDisposed(), (0, et.l)(this) }; var tt = n(776); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.spaceToBatchND = function (e, t) { return this.throwIfDisposed(), (0, tt.e)(this, e, t) }; var nt = n(6512); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.split = function (e, t) { return this.throwIfDisposed(), (0, nt.l)(this, e, t) }; var rt = n(9348); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sqrt = function () { return this.throwIfDisposed(), (0, rt.R)(this) }; var it = n(5793); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.square = function () { return this.throwIfDisposed(), (0, it.E)(this) }; var at = n(3427); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.squaredDifference = function (e) { return this.throwIfDisposed(), (0, at.P)(this, e) }; var ot = n(5932); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.squeeze = function (e) { return this.throwIfDisposed(), (0, ot.r)(this, e) }; var st = n(4268); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.stack = function (e, t) { this.throwIfDisposed(); const n = e instanceof i.qY ? [this, e] : [this, ...e]; return (0, st.t)(n, t) }; var ut = n(700); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.step = function (e) { return this.throwIfDisposed(), (0, ut.P)(this, e) }; var lt = n(5894); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.stridedSlice = function (e, t, n, r, i, a, o, s) { return this.throwIfDisposed(), (0, lt.Y)(this, e, t, n, r, i, a, o, s) }; var ct = n(7126); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sub = function (e) { return this.throwIfDisposed(), (0, ct.j)(this, e) }; var ht = n(3791); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.sum = function (e, t) { return this.throwIfDisposed(), (0, ht.c)(this, e, t) }; var dt = n(7823); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.tan = function () { return this.throwIfDisposed(), (0, dt.M)(this) }; var ft = n(7311); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.tanh = function () { return this.throwIfDisposed(), (0, ft.y)(this) }; var pt = n(4826); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.tile = function (e) { return this.throwIfDisposed(), (0, pt.V)(this, e) }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.toBool = function () { return this.throwIfDisposed(), (0, p.w)(this, "bool") }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.toFloat = function () { return this.throwIfDisposed(), (0, p.w)(this, "float32") }, + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.toInt = function () { return this.throwIfDisposed(), (0, p.w)(this, "int32") }; var mt = n(1190); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.topk = function (e, t) { return this.throwIfDisposed(), (0, mt.r)(this, e, t) }; var gt = n(7703); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.transpose = function (e) { return this.throwIfDisposed(), (0, gt.m)(this, e) }; var yt = n(3937); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.unique = function (e) { return this.throwIfDisposed(), (0, yt.A)(this, e) }; var bt = n(7706); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.unsortedSegmentSum = function (e, t) { return this.throwIfDisposed(), (0, bt.z)(this, e, t) }; var vt = n(7261); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.unstack = function (e) { return this.throwIfDisposed(), (0, vt.K)(this, e) }; var xt = n(2151); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.where = function (e, t) { return this.throwIfDisposed(), (0, xt._)(e, this, t) }; var wt = n(5537); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, i.tp)().prototype.zerosLike = function () { return this.throwIfDisposed(), (0, wt.P)(this) } + } +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */, 259: (e, t, n) => { + "use strict"; n.d(t, { qY: () => b, yl: () => h, rT: () => x, tp: () => v, B4: () => y, Q5: () => g, qP: () => m }); var r = n(1743), i = n(5119); function a(e, t, n, r) { const a = (0, i.Ur)(t), s = function (e, t, n, r) { const a = (0, i.Ze)(t), s = r[r.length - 1], u = new Array(s).fill(0), c = t.length, h = "complex64" === n ? l(e) : e; if (c > 1) for (let e = 0; e < a / s; e++) { const t = e * s; for (let e = 0; e < s; e++)u[e] = Math.max(u[e], o(h[t + e], 0, n).length) } return u }(e, t, n, a), c = t.length, h = u(e, t, n, a, s), d = ["Tensor"]; return r && (d.push(` dtype: ${n}`), d.push(` rank: ${c}`), d.push(` shape: [${t}]`), d.push(" values:")), d.push(h.map((e => " " + e)).join("\n")), d.join("\n") } function o(e, t, n) { let r; return r = Array.isArray(e) ? `${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j` : (0, i.Kg)(e) ? `'${e}'` : "bool" === n ? s(e) : parseFloat(e.toFixed(7)).toString(), (0, i.av)(r, t) } function s(e) { return 0 === e ? "false" : "true" } function u(e, t, n, r, i, a = !0) { const c = "complex64" === n ? 2 : 1, h = t[0], d = t.length; if (0 === d) { if ("complex64" === n) { return [o(l(e)[0], 0, n)] } return "bool" === n ? [s(e[0])] : [e[0].toString()] } if (1 === d) { if (h > 20) { const t = 3 * c; let r = Array.from(e.slice(0, t)), a = Array.from(e.slice((h - 3) * c, h * c)); return "complex64" === n && (r = l(r), a = l(a)), ["[" + r.map(((e, t) => o(e, i[t], n))).join(", ") + ", ..., " + a.map(((e, t) => o(e, i[h - 3 + t], n))).join(", ") + "]"] } return ["[" + ("complex64" === n ? l(e) : Array.from(e)).map(((e, t) => o(e, i[t], n))).join(", ") + "]"] } const f = t.slice(1), p = r.slice(1), m = r[0] * c, g = []; if (h > 20) { for (let t = 0; t < 3; t++) { const r = t * m, a = r + m; g.push(...u(e.slice(r, a), f, n, p, i, !1)) } g.push("..."); for (let t = h - 3; t < h; t++) { const r = t * m, a = r + m; g.push(...u(e.slice(r, a), f, n, p, i, t === h - 1)) } } else for (let t = 0; t < h; t++) { const r = t * m, a = r + m; g.push(...u(e.slice(r, a), f, n, p, i, t === h - 1)) } const y = 2 === d ? "," : ""; g[0] = "[" + (h > 0 ? g[0] + y : ""); for (let e = 1; e < g.length - 1; e++)g[e] = " " + g[e] + y; let b = ",\n"; for (let e = 2; e < d; e++)b += "\n"; return g[g.length - 1] = " " + g[g.length - 1] + "]" + (a ? "" : b), g } function l(e) { const t = []; for (let n = 0; n < e.length; n += 2)t.push([e[n], e[n + 1]]); return t } var c = n(3879); + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class h { constructor(e, t, n) { if (this.dtype = t, this.shape = e.slice(), this.size = i.Ze(e), null != n) { const e = n.length; i.vA(e === this.size, (() => `Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`)) } if ("complex64" === t) throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag)."); this.values = n || i.Ab(t, this.size), this.strides = (0, i.Ur)(e) } set(e, ...t) { 0 === t.length && (t = [0]), i.vA(t.length === this.rank, (() => `The number of provided coordinates (${t.length}) must match the rank (${this.rank})`)); const n = this.locToIndex(t); this.values[n] = e } get(...e) { 0 === e.length && (e = [0]); let t = 0; for (const n of e) { if (n < 0 || n >= this.shape[t]) { const t = `Requested out of range element at ${e}. Buffer shape=${this.shape}`; throw new Error(t) } t++ } let n = e[e.length - 1]; for (let t = 0; t < e.length - 1; ++t)n += this.strides[t] * e[t]; return this.values[n] } locToIndex(e) { if (0 === this.rank) return 0; if (1 === this.rank) return e[0]; let t = e[e.length - 1]; for (let n = 0; n < e.length - 1; ++n)t += this.strides[n] * e[n]; return t } indexToLoc(e) { if (0 === this.rank) return []; if (1 === this.rank) return [e]; const t = new Array(this.shape.length); for (let n = 0; n < t.length - 1; ++n)t[n] = Math.floor(e / this.strides[n]), e -= t[n] * this.strides[n]; return t[t.length - 1] = e, t } get rank() { return this.shape.length } toTensor() { return d().makeTensor(this.values, this.shape, this.dtype) } } let d = null, f = null, p = null; function m(e) { d = e } function g(e) { f = e } function y(e) { p = e } class b { constructor(e, t, n, r) { this.kept = !1, this.isDisposedInternal = !1, this.shape = e.slice(), this.dtype = t || "float32", this.size = i.Ze(e), this.strides = (0, i.Ur)(e), this.dataId = n, this.id = r, this.rankType = this.rank < 5 ? this.rank.toString() : "higher" } get rank() { return this.shape.length } async buffer() { const e = await this.data(); return f.buffer(this.shape, this.dtype, e) } bufferSync() { return f.buffer(this.shape, this.dtype, this.dataSync()) } async array() { const e = await this.data(); return (0, i.yw)(this.shape, e, "complex64" === this.dtype) } arraySync() { return (0, i.yw)(this.shape, this.dataSync(), "complex64" === this.dtype) } async data() { this.throwIfDisposed(); const e = d().read(this.dataId); if ("string" === this.dtype) { const t = await e; try { return t.map((e => c.decodeString(e))) } catch (e) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().") } } return e } dataToGPU(e) { return this.throwIfDisposed(), d().readToGPU(this.dataId, e) } dataSync() { this.throwIfDisposed(); const e = d().readSync(this.dataId); if ("string" === this.dtype) try { return e.map((e => c.decodeString(e))) } catch (e) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().") } return e } async bytes() { this.throwIfDisposed(); const e = await d().read(this.dataId); return "string" === this.dtype ? e : new Uint8Array(e.buffer) } dispose() { this.isDisposed || (this.kerasMask && this.kerasMask.dispose(), d().disposeTensor(this), this.isDisposedInternal = !0) } get isDisposed() { return this.isDisposedInternal } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed.") } print(e = !1) { return f.print(this, e) } clone() { return this.throwIfDisposed(), f.clone(this) } toString(e = !1) { return a(this.dataSync(), this.shape, this.dtype, e) } cast(e) { return this.throwIfDisposed(), f.cast(this, e) } variable(e = !0, t, n) { return this.throwIfDisposed(), d().makeVariable(this, e, t, n) } } function v() { return (0, r.m)("Tensor", (() => b)) } Object.defineProperty(b, Symbol.hasInstance, { value: e => !!e && null != e.data && null != e.dataSync && null != e.throwIfDisposed }), v(); class x extends b { constructor(e, t, n, r) { super(e.shape, e.dtype, e.dataId, r), this.trainable = t, this.name = n } assign(e) { if (e.dtype !== this.dtype) throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`); if (!i.r1(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); d().disposeTensor(this), this.dataId = e.dataId, d().incRef(this, null) } dispose() { d().disposeVariable(this), this.isDisposedInternal = !0 } } Object.defineProperty(x, Symbol.hasInstance, { value: e => e instanceof b && null != e.assign && e.assign instanceof Function }) + }, 565: (e, t, n) => { + "use strict"; n.r(t), n.d(t, { assertTypesMatch: () => s, getTensorsInContainer: () => l, isTensorInList: () => u, makeTypesMatch: () => o }); var r = n(259), i = n(2046), a = n(5119); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function o(e, t) { if (e.dtype === t.dtype) return [e, t]; const n = (0, i.Tu)(e.dtype, t.dtype); return [e.cast(n), t.cast(n)] } function s(e, t) { (0, a.vA)(e.dtype === t.dtype, (() => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)) } function u(e, t) { return t.some((t => t.id === e.id)) } function l(e) { const t = []; return c(e, t, new Set), t } function c(e, t, n) { if (null == e) return; if (e instanceof r.qY) return void t.push(e); if (i = e, !Array.isArray(i) && "object" != typeof i) return; var i; const a = e; for (const e in a) { const r = a[e]; n.has(r) || (n.add(r), c(r, t, n)) } } + }, 8189: (e, t, n) => { + "use strict"; n.d(t, { MZ: () => l, YT: () => d, j1: () => f }); var r = n(1585), i = n(6574), a = n(259), o = n(2046), s = n(3879), u = n(5119); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function l(e, t) { let n = e; if ((0, s.isTypedArray)(e)) return "string" === t ? [] : [e.length]; if ((0, o.Oj)(e)) { const t = e.channels || "RGBA"; return [e.height, e.width * t.length] } if ((0, o.Nw)(e)) return [e.buffer.size / (null == t ? 4 : (0, u.jv)(t))]; if (!Array.isArray(e)) return []; const r = []; for (; Array.isArray(n) || (0, s.isTypedArray)(n) && "string" !== t;)r.push(n.length), n = n[0]; return Array.isArray(e) && (0, i._K)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && c(e, r, []), r } function c(e, t, n) { if (n = n || [], !Array.isArray(e) && !(0, s.isTypedArray)(e)) return void (0, u.vA)(0 === t.length, (() => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`)); (0, u.vA)(t.length > 0, (() => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)), (0, u.vA)(e.length === t[0], (() => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`)); const r = t.slice(1); for (let t = 0; t < e.length; ++t)c(e[t], r, n.concat(t)) } function h(e, t, n, r) { if ("string_or_numeric" !== e) { if (null == e) throw new Error("Expected dtype cannot be null."); if ("numeric" !== e && e !== t || "numeric" === e && "string" === t) throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`) } } function d(e, t, n, i = "numeric") { if (e instanceof (0, a.tp)()) return h(i, e.dtype, t, n), e; let o = (0, u.X$)(e); if ("string" !== o && ["bool", "int32", "float32"].indexOf(i) >= 0 && (o = i), h(i, o, t, n), null == e || !(0, s.isTypedArray)(e) && !Array.isArray(e) && "number" != typeof e && "boolean" != typeof e && "string" != typeof e) { const r = null == e ? "null" : e.constructor.name; throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`) } const c = l(e, o); (0, s.isTypedArray)(e) || Array.isArray(e) || (e = [e]); const d = "string" !== o ? (0, s.toTypedArray)(e, o) : (0, s.flatten)(e, [], !0); return r.T2.makeTensor(d, c, o) } function f(e, t, n, r = "numeric") { if (!Array.isArray(e)) throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``); return e.map(((e, i) => d(e, `${t}[${i}]`, n, r))) } + }, 2046: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var r, i, a, o, s; n.d(t, { Nw: () => d, Oj: () => h, Tu: () => l, ch: () => c, rg: () => r }), function (e) { e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6" }(r || (r = {})), function (e) { e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64" }(i || (i = {})), function (e) { e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64" }(a || (a = {})), function (e) { e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64" }(o || (o = {})), function (e) { e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64" }(s || (s = {})); const u = { float32: o, int32: i, bool: a, complex64: s }; function l(e, t) { if ("string" === e || "string" === t) { if ("string" === e && "string" === t) return "string"; throw new Error(`Can not upcast ${e} with ${t}`) } return u[e][t] } function c(e) { return l(e, "int32") } function h(e) { return null != e && "object" == typeof e && "texture" in e && e.texture instanceof WebGLTexture } function d(e) { return "undefined" != typeof GPUBuffer && null != e && "object" == typeof e && "buffer" in e && e.buffer instanceof GPUBuffer } + }, 3879: (e, t, n) => { + "use strict"; n.r(t), n.d(t, { arraysEqual: () => a.r1, arraysEqualWithNull: () => a.e_, assert: () => a.vA, assertNonNegativeIntegerDimensions: () => a.SA, assertNonNull: () => a.HO, assertShapesMatch: () => a.O3, bytesFromStringArray: () => a.SL, bytesPerElement: () => a.jv, checkConversionForErrors: () => a.nd, clamp: () => a.qE, computeStrides: () => a.Ur, convertBackendValuesAndArrayBuffer: () => a.o2, createScalarValue: () => x, createShuffledIndices: () => a.P8, decodeString: () => C, distSquared: () => a.oO, encodeString: () => _, fetch: () => S, fingerPrint64: () => v, flatten: () => T, getArrayFromDType: () => a.Ab, getTypedArrayFromDType: () => a.ce, hasEncodingLoss: () => a.BE, hexToLong: () => u, indexToLoc: () => a._k, inferDtype: () => a.X$, inferFromImplicitShape: () => a.XT, isBoolean: () => a.Lm, isFunction: () => a.Tn, isInt: () => a.E6, isNumber: () => a.Et, isPromise: () => a.yL, isScalarShape: () => a.Sf, isString: () => a.Kg, isTypedArray: () => A, isValidDtype: () => a.xn, locToIndex: () => a.sX, makeOnesTypedArray: () => a.FZ, makeZerosNestedTypedArray: () => a.c7, makeZerosTypedArray: () => a.Ty, nearestDivisor: () => a.lK, nearestLargerEven: () => a.eV, now: () => k, parseAxisParam: () => a.Y6, randUniform: () => a.so, repeatedTry: () => a._q, rightPad: () => a.av, shuffle: () => a.k4, shuffleCombo: () => a.a0, sizeFromShape: () => a.Ze, sizeToSquarishShape: () => a.gS, squeezeShape: () => a.gx, sum: () => a.cz, swap: () => a.wg, tanh: () => a.ym, toNestedArray: () => a.yw, toTypedArray: () => w }); var r = n(6574), i = n(6448), a = n(5119), o = n(8570); + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const s = n.n(o)() || o; function u(e) { return s.fromString(e, !0, 16) } const l = u("c3a5c85c97cb3127"), c = u("b492b66fbe98f273"), h = u("9ae16a3b2f90404f"); function d(e) { return e.xor(e.shru(47)) } function f(e, t, n) { const r = e.slice(t, t + n); return s.fromBytes(Array.from(r), !0, !0) } function p(e, t) { return f(e, t, 8) } function m(e, t) { return f(e, t, 4) } function g(e, t) { return 0 === t ? e : e.shru(t).or(e.shl(64 - t)) } function y(e, t, n = u("9ddfea08eb382d69")) { let r = e.xor(t).mul(n); r = r.xor(r.shru(47)); let i = t.xor(r).mul(n); return i = i.xor(i.shru(47)), i = i.mul(n), i } function b(e, t, n, r) { return function (e, t, n, r, i, a) { i = i.add(e), a = g(a.add(i).add(r), 21); const o = i; return i = (i = i.add(t)).add(n), a = a.add(g(i, 44)), [i.add(r), a.add(o)] }(p(e, t), p(e, t + 8), p(e, t + 16), p(e, t + 24), n, r) } function v(e, t = e.length) { const n = s.fromNumber(81, !0); if (t <= 32) return t <= 16 ? function (e, t = e.length) { if (t >= 8) { const n = h.add(2 * t), r = p(e, 0).add(h), i = p(e, t - 8); return y(g(i, 37).mul(n).add(r), g(r, 25).add(i).mul(n), n) } if (t >= 4) { const n = h.add(2 * t); return y(m(e, 0).shl(3).add(t), m(e, t - 4), n) } if (t > 0) { const n = e[0] + (e[t >> 1] << 8), r = t + (e[t - 1] << 2); return d(h.mul(n).xor(l.mul(r))).mul(h) } return h }(e, t) : function (e, t = e.length) { const n = h.add(2 * t), r = p(e, 0).mul(c), i = p(e, 8), a = p(e, t - 8).mul(n), o = p(e, t - 16).mul(h); return y(g(r.add(i), 43).add(g(a, 30)).add(o), r.add(g(i.add(h), 18)).add(a), n) }(e, t); if (t <= 64) return function (e, t = e.length) { const n = h.add(2 * t), r = p(e, 0).mul(h), i = p(e, 8), a = p(e, t - 8).mul(n), o = p(e, t - 16).mul(h), s = g(r.add(i), 43).add(g(a, 30)).add(o), u = y(s, r.add(g(i.add(h), 18)).add(a), n), l = p(e, 16).mul(n), c = p(e, 24), d = s.add(p(e, t - 32)).mul(n), f = u.add(p(e, t - 24)).mul(n); return y(g(l.add(c), 43).add(g(d, 30)).add(f), l.add(g(c.add(r), 18)).add(d), n) }(e, t); let r = n, i = n.mul(c).add(113), a = d(i.mul(h).add(113)).mul(h), o = [s.UZERO, s.UZERO], u = [s.UZERO, s.UZERO]; r = r.mul(h).add(p(e, 0)); let f = 0; const v = 64 * (t - 1 >> 6), x = v + (t - 1 & 63) - 63; do { r = g(r.add(i).add(o[0]).add(p(e, f + 8)), 37).mul(c), i = g(i.add(o[1]).add(p(e, f + 48)), 42).mul(c), r = r.xor(u[1]), i = i.add(o[0]).add(p(e, f + 40)), a = g(a.add(u[0]), 33).mul(c), o = b(e, f, o[1].mul(c), r.add(u[0])), u = b(e, f + 32, a.add(u[1]), i.add(p(e, f + 16))), [a, r] = [r, a], f += 64 } while (f !== v); const w = c.add(a.and(255).shl(1)); return f = x, u[0] = u[0].add(t - 1 & 63), o[0] = o[0].add(u[0]), u[0] = u[0].add(o[0]), r = g(r.add(i).add(o[0]).add(p(e, f + 8)), 37).mul(w), i = g(i.add(o[1]).add(p(e, f + 48)), 42).mul(w), r = r.xor(u[1].mul(9)), i = i.add(o[0].mul(9).add(p(e, f + 40))), a = g(a.add(u[0]), 33).mul(w), o = b(e, f, o[1].mul(w), r.add(u[0])), u = b(e, f + 32, a.add(u[1]), i.add(p(e, f + 16))), [a, r] = [r, a], y(y(o[0], u[0], w).add(d(i).mul(l)).add(a), y(o[1], u[1], w).add(r), w) } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function x(e, t) { return "string" === t ? _(e) : w([e], t) } function w(e, t) { if ("string" === t) throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(e) && (e = T(e)), (0, r._K)().getBool("DEBUG") && a.nd(e, t), function (e, t) { return e instanceof Float32Array && "float32" === t || e instanceof Int32Array && "int32" === t || e instanceof Uint8Array && "bool" === t }(e, t)) return e; if (null == t || "float32" === t || "complex64" === t) return new Float32Array(e); if ("int32" === t) return new Int32Array(e); if ("bool" === t) { const t = new Uint8Array(e.length); for (let n = 0; n < t.length; ++n)0 !== Math.round(e[n]) && (t[n] = 1); return t } throw new Error(`Unknown data type ${t}`) } function k() { return (0, r._K)().platform.now() } function S(e, t) { return (0, r._K)().platform.fetch(e, t) } function _(e, t = "utf-8") { return t = t || "utf-8", (0, r._K)().platform.encode(e, t) } function C(e, t = "utf-8") { return t = t || "utf-8", (0, r._K)().platform.decode(e, t) } function A(e) { return null != (0, r._K)().platform.isTypedArray ? (0, r._K)().platform.isTypedArray(e) : (0, i.Y)(e) } function T(e, t = [], n = !1) { if (null == t && (t = []), "boolean" == typeof e || "number" == typeof e || "string" == typeof e || a.yL(e) || null == e || A(e) && n) t.push(e); else if (Array.isArray(e) || A(e)) for (let r = 0; r < e.length; ++r)T(e[r], t, n); else { let r = -1; for (const t of Object.keys(e)) /^([1-9]+[0-9]*|0)$/.test(t) && (r = Math.max(r, Number(t))); for (let i = 0; i <= r; i++)T(e[i], t, n) } return t } + }, 5119: (e, t, n) => { + "use strict"; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function r(e) { let t = e.length, n = 0; for (; t > 0;)n = Math.random() * t | 0, t--, s(e, t, n) } function i(e, t) { if (e.length !== t.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`); let n = e.length, r = 0; for (; n > 0;)r = Math.random() * n | 0, n--, s(e, n, r), s(t, n, r) } function a(e, t, n) { return Math.max(e, Math.min(t, n)) } function o(e) { return e % 2 == 0 ? e : e + 1 } function s(e, t, n) { const r = e[t]; e[t] = e[n], e[n] = r } function u(e) { let t = 0; for (let n = 0; n < e.length; n++)t += e[n]; return t } function l(e, t) { const n = Math.random(); return t * n + (1 - n) * e } function c(e, t) { let n = 0; for (let r = 0; r < e.length; r++) { const i = Number(e[r]) - Number(t[r]); n += i * i } return n } function h(e, t) { if (!e) throw new Error("string" == typeof t ? t : t()) } function d(e, t, n = "") { h(y(e, t), (() => n + ` Shapes ${e} and ${t} must match`)) } function f(e) { h(null != e, (() => "The input to the tensor constructor must be a non-null value.")) } function p(e) { if (0 === e.length) return 1; let t = e[0]; for (let n = 1; n < e.length; n++)t *= e[n]; return t } function m(e) { return 0 === e.length } function g(e, t) { if (e === t) return !0; if (null == e || null == t) return !1; if (e.length !== t.length) return !1; for (let n = 0; n < e.length; n++)if (null !== e[n] && null !== t[n] && e[n] !== t[n]) return !1; return !0 } function y(e, t) { if (e === t) return !0; if (null == e || null == t) return !1; if (e.length !== t.length) return !1; for (let n = 0; n < e.length; n++)if (e[n] !== t[n]) return !1; return !0 } function b(e) { return e % 1 == 0 } function v(e) { if (null != Math.tanh) return Math.tanh(e); if (e === 1 / 0) return 1; if (e === -1 / 0) return -1; { const t = Math.exp(2 * e); return (t - 1) / (t + 1) } } function x(e) { const t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)] } function w(e) { const t = new Uint32Array(e); for (let n = 0; n < e; ++n)t[n] = n; return r(t), t } function k(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length) } function S(e, t = e => 0, n, r) { return new Promise(((i, a) => { let o = 0; const s = () => { if (e()) return void i(); o++; const u = t(o); null != n && o >= n ? a() : null != r ? r(s, u) : setTimeout(s, u) }; s() })) } function _(e, t) { let n = 1, r = -1; for (let t = 0; t < e.length; ++t)if (e[t] >= 0) n *= e[t]; else if (-1 === e[t]) { if (-1 !== r) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`); r = t } else if (e[t] < 0) throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`); if (-1 === r) { if (t > 0 && t !== n) throw Error(`Size(${t}) must match the product of shape ${e}`); return e } if (0 === n) throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`); if (t % n != 0) throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`); const i = e.slice(); return i[r] = t / n, i } function C(e, t) { const n = t.length; return h((e = null == e ? t.map(((e, t) => t)) : [].concat(e)).every((e => e >= -n && e < n)), (() => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)), h(e.every((e => b(e))), (() => `All values in axis param must be integers but got axis ${e}`)), e.map((e => e < 0 ? n + e : e)) } function A(e, t) { const n = [], r = [], i = null != t && Array.isArray(t) && 0 === t.length, a = null == t || i ? null : C(t, e).sort(); let o = 0; for (let t = 0; t < e.length; ++t) { if (null != a) { if (a[o] === t && 1 !== e[t]) throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`); (null == a[o] || a[o] > t) && 1 === e[t] && (n.push(e[t]), r.push(t)), a[o] <= t && o++ } 1 !== e[t] && (n.push(e[t]), r.push(t)) } return { newShape: n, keptDims: r } } function T(e, t) { return E(e, t) } function E(e, t) { let n = null; if (null == e || "float32" === e) n = new Float32Array(t); else if ("int32" === e) n = new Int32Array(t); else if ("bool" === e) n = new Uint8Array(t); else { if ("string" !== e) throw new Error(`Unknown data type ${e}`); n = new Array(t) } return n } function N(e, t) { for (let n = 0; n < e.length; n++) { const r = e[n]; if (isNaN(r) || !isFinite(r)) throw Error(`A tensor of type ${t} being uploaded contains ${r}.`) } } function I(e) { return "bool" === e || "complex64" === e || "float32" === e || "int32" === e || "string" === e } function M(e, t) { return "complex64" !== t && (("float32" !== t || "complex64" === e) && (("int32" !== t || "float32" === e || "complex64" === e) && ("bool" !== t || "bool" !== e))) } function F(e) { if ("float32" === e || "int32" === e) return 4; if ("complex64" === e) return 8; if ("bool" === e) return 1; throw new Error(`Unknown dtype ${e}`) } function D(e) { if (null == e) return 0; let t = 0; return e.forEach((e => t += e.length)), t } function $(e) { return "string" == typeof e || e instanceof String } function R(e) { return "boolean" == typeof e } function O(e) { return "number" == typeof e } function z(e) { return Array.isArray(e) ? z(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : O(e) ? "float32" : $(e) ? "string" : R(e) ? "bool" : "float32" } function P(e) { return !!(e && e.constructor && e.call && e.apply) } function B(e, t) { for (let n = t; n < e; ++n)if (e % n == 0) return n; return e } function L(e) { const t = e.length; if (t < 2) return []; const n = new Array(t - 1); n[t - 2] = e[t - 1]; for (let r = t - 3; r >= 0; --r)n[r] = n[r + 1] * e[r + 1]; return n } function j(e, t, n, r = !1) { const i = new Array; if (1 === t.length) { const a = t[0] * (r ? 2 : 1); for (let t = 0; t < a; t++)i[t] = n[e + t] } else { const a = t[0], o = t.slice(1), s = o.reduce(((e, t) => e * t)) * (r ? 2 : 1); for (let t = 0; t < a; t++)i[t] = j(e + t * s, o, n, r) } return i } function U(e, t, n = !1) { if (0 === e.length) return t[0]; const r = e.reduce(((e, t) => e * t)) * (n ? 2 : 1); if (0 === r) return []; if (r !== t.length) throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`); return j(0, e, t, n) } function W(e, t) { if (Array.isArray(e)) return e; if ("float32" === t) return e instanceof Float32Array ? e : new Float32Array(e); if ("int32" === t) return e instanceof Int32Array ? e : new Int32Array(e); if ("bool" === t || "string" === t) return Uint8Array.from(new Int32Array(e)); throw new Error(`Unknown dtype ${t}`) } function V(e, t) { const n = G(e, t); for (let e = 0; e < n.length; e++)n[e] = 1; return n } function G(e, t) { if (null == t || "float32" === t || "complex64" === t) return new Float32Array(e); if ("int32" === t) return new Int32Array(e); if ("bool" === t) return new Uint8Array(e); throw new Error(`Unknown data type ${t}`) } function H(e, t) { const n = e.reduce(((e, t) => e * t), 1); if (null == t || "float32" === t) return U(e, new Float32Array(n)); if ("int32" === t) return U(e, new Int32Array(n)); if ("bool" === t) return U(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`) } function q(e) { e.forEach((t => { h(Number.isInteger(t) && t >= 0, (() => `Tensor must have a shape comprised of positive integers but got shape [${e}].`)) })) } function Y(e, t, n) { if (0 === t) return 0; if (1 === t) return e[0]; let r = e[e.length - 1]; for (let t = 0; t < e.length - 1; ++t)r += n[t] * e[t]; return r } function X(e, t, n) { if (0 === t) return []; if (1 === t) return [e]; const r = new Array(t); for (let t = 0; t < r.length - 1; ++t)r[t] = Math.floor(e / n[t]), e -= r[t] * n[t]; return r[r.length - 1] = e, r } function K(e) { return e && e.then && "function" == typeof e.then } n.d(t, { Ab: () => E, BE: () => M, E6: () => b, Et: () => O, FZ: () => V, HO: () => f, Kg: () => $, Lm: () => R, O3: () => d, P8: () => w, SA: () => q, SL: () => D, Sf: () => m, Tn: () => P, Ty: () => G, Ur: () => L, X$: () => z, XT: () => _, Y6: () => C, Ze: () => p, _k: () => X, _q: () => S, a0: () => i, av: () => k, c7: () => H, ce: () => T, cz: () => u, eV: () => o, e_: () => g, gS: () => x, gx: () => A, jv: () => F, k4: () => r, lK: () => B, nd: () => N, o2: () => W, oO: () => c, qE: () => a, r1: () => y, sX: () => Y, so: () => l, vA: () => h, wg: () => s, xn: () => I, yL: () => K, ym: () => v, yw: () => U }) + }, 1936: (e, t, n) => { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5237), i = n(8205); class a extends r.Component { componentDidMount() { const { name: e, tab: t } = this.props; this.props.registerSurface(e, t, this) } componentDidUpdate() { return !1 } render() { const { name: e, visible: t, styles: n } = this.props, o = Object.assign({}, a.defaultStyles, n), { width: s, height: u } = o; let { maxHeight: l, maxWidth: c } = o; l = u === a.defaultStyles.height ? l : u, c = s === a.defaultStyles.width ? c : s; const h = i.css({ display: t ? "block" : "none", backgroundColor: "white", marginTop: "10px", marginBottom: "10px", boxShadow: "0 0 6px -3px #777", padding: "10px !important", height: u, width: s, maxHeight: l, maxWidth: c, overflow: "auto" }), d = i.css({ backgroundColor: "white", boxSizing: "border-box", borderBottom: "1px solid #357EDD", lineHeight: "2em", marginBottom: "20px", fontWeight: "600", textAlign: "center" }), f = i.css({ boxSizing: "border-box" }); return r.h("div", { className: `${h} tf-surface`, ref: e => this.container = e, "data-visible": t }, r.h("div", { className: `${d} tf-label`, ref: e => this.label = e }, e), r.h("div", { className: `${f} tf-draw-area`, ref: e => this.drawArea = e })) } } a.defaultStyles = { maxWidth: "550px", maxHeight: "580px", height: "auto", width: "auto" }, t.SurfaceComponent = a + }, 9779: (e, t, n) => { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5237), i = n(8205); class a extends r.Component { render() { const { tabNames: e, activeTab: t, handleClick: n } = this.props, a = e.length > 0 ? e.map((e => r.h(o, { key: e, id: e, handleClick: n, isActive: e === t }, e))) : null, s = i.css({ overflowX: "scroll", overflowY: "hidden", whiteSpace: "nowrap", borderBottomStyle: "solid", borderBottomWidth: "1px", borderColor: "#eee", paddingBottom: "1rem", marginTop: "1rem" }); return r.h("div", { className: `${s} visor-tabs` }, a) } } t.Tabs = a; class o extends r.Component { render() { const { children: e, isActive: t, handleClick: n, id: a } = this.props, o = i.css({ borderBottomColor: t ? "#357EDD" : "#AAAAAA", borderBottomWidth: "1px", borderBottomStyle: "solid", cursor: "pointer", ":hover": { color: "#357EDD" }, display: "inline-block", marginRight: "1rem", padding: ".5rem", fontSize: "1rem", fontWeight: "bold" }); return r.h("a", { className: `${o} tf-tab`, "data-isactive": t, onClick: () => n(a) }, e) } } + }, 5976: (e, t, n) => { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5237), i = n(8205), a = n(1936), o = n(9779); class s extends r.Component { static render(e, t, n) { return r.render(r.h(s, Object.assign({}, n)), e, t) } constructor(e) { super(e), this.surfaces = new Map; const t = null == e.startOpen || e.startOpen; this.state = { isOpen: t, isFullscreen: !1, activeTab: null, tabs: new Set }, this.keyHandler = this.keyHandler.bind(this) } close() { this.setState({ isOpen: !1 }) } open() { this.setState({ isOpen: !0 }) } toggle() { this.setState({ isOpen: !this.state.isOpen }) } toggleFullScreen() { this.setState({ isFullscreen: !this.state.isFullscreen }) } isOpen() { return this.state.isOpen } isFullscreen() { return this.state.isFullscreen } getSurface(e, t) { const n = this.surfaceId(e, t); let r; if (!this.surfaces.has(n)) throw Error(`Surface not found with id: ${n}`); return r = this.surfaces.get(n), { container: r.container, label: r.label, drawArea: r.drawArea } } bindKeys() { document.addEventListener("keydown", this.keyHandler, !1) } unbindKeys() { document.removeEventListener("keydown", this.keyHandler) } surfaceId(e, t) { return e + t } setTabs(e) { const t = e.map((e => e.tab)), n = this.state.tabs; let r; for (const e of t) n.has(e) || (n.add(e), r = e); null != r && this.setState({ tabs: n, activeTab: r }) } getTabs() { return this.state.tabs } registerSurface(e, t, n) { const r = this.surfaceId(e, t); this.surfaces.set(r, n) } keyHandler(e) { 192 === e.keyCode && (e.shiftKey ? this.toggleFullScreen() : this.toggle()) } setActiveTab(e) { this.setState({ activeTab: e }) } componentDidMount() { this.bindKeys() } componentWillMount() { this.setTabs(this.props.surfaceList) } componentWillReceiveProps(e) { this.setTabs(e.surfaceList) } render() { const { isOpen: e, isFullscreen: t, activeTab: n } = this.state, { surfaceList: s } = this.props, l = Array.from(this.getTabs().values()), c = t ? "90vw" : "550px", h = i.css({ width: c, height: "100%", backgroundColor: "#fafafa", boxSizing: "border-box", padding: "10px", position: "fixed", top: "0px", transition: "right 0.5s cubic-bezier(0.645, 0.045, 0.355, 1), width 0.5s cubic-bezier(0.645, 0.045, 0.355, 1)", boxShadow: "0 2px 5px rgba(0, 0, 0, 0.12), 0 2px 5px rgba(0, 0, 0, 0.24)", overflow: "auto", fontFamily: "sans-serif", fontSize: "14px", zIndex: 1e3 }), d = i.css({ right: "0" }), f = i.css({ right: `calc(-${c} - 10px)` }), p = e ? d : f, m = i.css({}); return r.h("div", { className: `${h} ${p} visor`, "data-isopen": e, "data-isfullscreen": t }, r.h(u, { fullScreenHandler: this.toggleFullScreen.bind(this), closeHandler: this.close.bind(this), isFullScreen: t }), r.h(o.Tabs, { tabNames: l, activeTab: n, handleClick: this.setActiveTab.bind(this) }), r.h("div", { className: `${m} visor-surfaces` }, s.map((e => r.h(a.SurfaceComponent, { key: e.name + e.tab, name: e.name, tab: e.tab, styles: e.styles, registerSurface: this.registerSurface.bind(this), visible: n === e.tab }))))) } } function u(e) { const { isFullScreen: t, fullScreenHandler: n, closeHandler: a } = e, o = i.css({ display: "flex", backgroundColor: "white", border: "1px solid white", padding: "6px", paddingTop: "10px", marginBottom: "10px", borderRadius: "6px", marginTop: "-16px" }), s = i.css({ fontSize: ".875rem", borderRadius: ".25rem", paddingLeft: "1rem", paddingRight: "1rem", paddingTop: ".5rem", paddingBottom: ".5rem", textDecoration: "none", transition: "color .15s ease-in", color: "#111" }), u = i.css({ marginLeft: "auto" }); return r.h("div", { className: `${o} visor-controls` }, r.h("button", { className: `${s}`, onClick: n }, t ? "Minimize" : "Maximize"), r.h("button", { className: `${s} ${u}`, onClick: a }, "Hide")) } t.VisorComponent = s + }, 9778: (e, t, n) => { + "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + n(5838), n(455); const r = n(2784), i = n(3739), a = n(7483), o = n(5877), s = n(4857), u = n(898), l = n(9827), c = n(62), h = n(3559), d = n(5727), f = n(4853), p = n(2729), m = n(454); t.version_vis = m.version; const g = { barchart: r.barchart, table: l.table, histogram: o.histogram, linechart: s.linechart, scatterplot: u.scatterplot, confusionMatrix: i.confusionMatrix, heatmap: a.heatmap }; t.render = g; const y = { accuracy: p.accuracy, perClassAccuracy: p.perClassAccuracy, confusionMatrix: p.confusionMatrix }; t.metrics = y; const b = { history: c.history, fitCallbacks: c.fitCallbacks, perClassAccuracy: d.perClassAccuracy, valuesDistribution: f.valuesDistribution, layer: h.layer, modelSummary: h.modelSummary }; t.show = b; var v = n(4701); t.visor = v.visor, function (e) { for (var n in e) t.hasOwnProperty(n) || (t[n] = e[n]) }(n(5759)) + }, 2784: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6857); t.barchart = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = s.getDrawArea(e), i = t, c = Object.assign({}, u, n); if (l.has(r)) { const e = l.get(r); if (s.shallowEquals(c, e.lastOptions)) { yield s.nextFrame(); const t = e.view, n = t.changeset().remove((() => !0)).insert(i); return void (yield t.change("values", n).runAsync()) } } const { xLabel: h, yLabel: d, xType: f, yType: p } = c; let m = null; null != h && (m = { title: h }); let g = null; null != d && (g = { title: d }); let y; y = null != c.color ? Array.isArray(c.color) ? { field: "index", type: "nominal", scale: { range: c.color } } : { value: c.color } : { value: "#4C78A0" }; const b = { width: c.width || o.getDefaultWidth(r), height: c.height || o.getDefaultHeight(r), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: c.fontSize, titleFontSize: c.fontSize }, text: { fontSize: c.fontSize }, legend: { labelFontSize: c.fontSize, titleFontSize: c.fontSize } }, data: { values: i, name: "values" }, mark: { type: "bar", tooltip: !0 }, encoding: { x: { field: "index", type: f, axis: m }, y: { field: "value", type: p, axis: g }, color: y } }; yield s.nextFrame(); const v = yield a.default(r, b, { actions: !1, mode: "vega-lite", defaultStyle: !1 }); l.set(r, { view: v.view, lastOptions: c }) })) }; const u = { xLabel: "", yLabel: "", xType: "ordinal", yType: "quantitative", fontSize: 11 }, l = new Map + }, 3739: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6857); t.confusionMatrix = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = Object.assign({}, u, n), i = s.getDrawArea(e), l = [], c = t.values, h = t.tickLabels || [], d = 0 === h.length; let f = !0; for (let e = 0; e < c.length; e++) { const t = d ? `Class ${e}` : h[e]; d && h.push(t); for (let n = 0; n < c[e].length; n++) { const i = d ? `Class ${n}` : h[n], a = c[e][n]; e !== n || r.shadeDiagonal ? (l.push({ label: t, prediction: i, count: a, scaleCount: a }), 0 !== a && (f = !1)) : l.push({ label: t, prediction: i, count: a, noFill: !0 }) } } if (!r.shadeDiagonal && f) for (const e of l) !0 === e.noFill && (e.noFill = !1, e.scaleCount = e.count); const p = { width: r.width || o.getDefaultWidth(i), height: r.height || o.getDefaultHeight(i), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: r.fontSize, titleFontSize: r.fontSize }, text: { fontSize: r.fontSize }, legend: { labelFontSize: r.fontSize, titleFontSize: r.fontSize } }, data: { values: l }, encoding: { x: { field: "prediction", type: "ordinal", title: r.xLabel || "prediction", scale: { domain: h } }, y: { field: "label", type: "ordinal", title: r.yLabel || "label", scale: { domain: h } } }, layer: [{ transform: [{ filter: "datum.noFill != true" }], mark: { type: "rect" }, encoding: { color: { field: "scaleCount", type: "quantitative", scale: { range: r.colorMap } }, tooltip: [{ field: "label", type: "nominal" }, { field: "prediction", type: "nominal" }, { field: "count", type: "quantitative" }] } }] }; !1 === r.shadeDiagonal && p.layer.push({ transform: [{ filter: "datum.noFill == true" }], mark: { type: "rect", fill: "white" }, encoding: { tooltip: [{ field: "label", type: "nominal" }, { field: "prediction", type: "nominal" }, { field: "count", type: "quantitative" }] } }), r.showTextOverlay && p.layer.push({ mark: { type: "text", baseline: "middle" }, encoding: { text: { field: "count", type: "nominal" } } }); const m = "string" == typeof r.colorMap ? { scheme: r.colorMap } : r.colorMap; p.layer[0].encoding.color.scale.range = m, yield a.default(i, p, { actions: !1, mode: "vega-lite", defaultStyle: !1 }) })) }; const u = { xLabel: null, yLabel: null, xType: "nominal", yType: "nominal", shadeDiagonal: !0, fontSize: 12, showTextOverlay: !0, height: 400, colorMap: ["#f7fbff", "#4292c6"] } + }, 7483: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importStar || function (e) { if (e && e.__esModule) return e; var t = {}; if (null != e) for (var n in e) Object.hasOwnProperty.call(e, n) && (t[n] = e[n]); return t.default = e, t }, a = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const o = i(n(5838)), s = a(n(8731)), u = n(8227), l = n(6286), c = n(6857); function h(e, t, n) { const r = e instanceof o.Tensor ? e.shape : [e.length, e[0].length]; 0 === n ? l.assert(r[0] === t.length, `Length of xTickLabels (${t.length}) must match number of rows (${r[0]})`) : 1 === n && l.assert(r[1] === t.length, `Length of yTickLabels (${t.length}) must match number of columns (${r[1]})`) } t.heatmap = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const i = Object.assign({}, d, n), a = c.getDrawArea(e); let f = t.values; i.rowMajor && (f = yield function (e) { return r(this, void 0, void 0, (function* () { let t, n; e instanceof o.Tensor ? (t = e.shape, n = e.transpose()) : (t = [e.length, e[0].length], n = o.tidy((() => o.tensor2d(e).transpose()))), l.assert(2 === n.rank, "Input to renderHeatmap must be a 2d array or Tensor2d"); const r = yield n.array(); n.dispose(); const i = [r.length, r[0].length]; return l.assert(t[0] === i[1] && t[1] === i[0], `Unexpected transposed shape. Original ${t} : Transposed ${i}`), r })) }(t.values)); const { xTickLabels: p, yTickLabels: m } = t; if (null != p) { h(f, p, 0) } if (null != m) { h(f, m, 1) } const g = "@tfidx@", y = []; if (f instanceof o.Tensor) { l.assert(2 === f.rank, "Input to renderHeatmap must be a 2d array or Tensor2d"); const e = yield f.data(), [t, n] = f.shape; for (let r = 0; r < t; r++) { const t = p ? `${p[r]}${g}${r}` : r; for (let i = 0; i < n; i++) { const a = m ? `${m[i]}${g}${i}` : i, o = e[r * n + i]; y.push({ x: t, y: a, value: o }) } } } else { const e = f; for (let t = 0; t < e.length; t++) { const n = p ? `${p[t]}${g}${t}` : t; for (let r = 0; r < e[t].length; r++) { const i = m ? `${m[r]}${g}${r}` : r, a = e[t][r]; y.push({ x: n, y: i, value: a }) } } } const b = { actions: !1, mode: "vega-lite", defaultStyle: !1 }, v = { width: i.width || u.getDefaultWidth(a), height: i.height || u.getDefaultHeight(a), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: i.fontSize, titleFontSize: i.fontSize }, text: { fontSize: i.fontSize }, legend: { labelFontSize: i.fontSize, titleFontSize: i.fontSize }, scale: { bandPaddingInner: 0, bandPaddingOuter: 0 } }, data: { values: y }, mark: { type: "rect", tooltip: !0 }, encoding: { x: { field: "x", type: i.xType, title: i.xLabel, sort: !1 }, y: { field: "y", type: i.yType, title: i.yLabel, sort: !1 }, fill: { field: "value", type: "quantitative" } } }, x = `${g}\\d+$`, w = new RegExp(x); let k; switch (p && (v.encoding.x.axis = { labelExpr: `replace(datum.value, regexp(/${x}/), '')` }), m && (v.encoding.y.axis = { labelExpr: `replace(datum.value, regexp(/${x}/), '')` }), (p || m) && (b.tooltip = { sanitize: e => String(e).replace(w, "") }), i.colorMap) { case "blues": k = ["#f7fbff", "#4292c6"]; break; case "greyscale": k = ["#000000", "#ffffff"]; break; default: k = "viridis" }if ("viridis" !== k) { v.encoding.fill.scale = { range: k } } if (i.domain) { const e = v.encoding.fill; null != e.scale ? e.scale = Object.assign({}, e.scale, { domain: i.domain }) : e.scale = { domain: i.domain } } yield s.default(a, v, b) })) }; const d = { xLabel: null, yLabel: null, xType: "ordinal", yType: "ordinal", colorMap: "viridis", fontSize: 12, domain: null, rowMajor: !1 } + }, 5877: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = n(1934), o = i(n(8731)), s = n(8227), u = n(2729), l = n(9827), c = { maxBins: 12, fontSize: 11 }; t.histogram = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = function (e) { if (null == e.length) throw new Error("input data must be an array"); if (0 === e.length) return []; if ("object" == typeof e[0]) { if (null == e[0].value) throw new Error("input data must have a value field"); return e } { const t = Array(e.length); for (let n = 0; n < e.length; n++)t[n] = { value: e[n] }; return t } }(t), i = Object.assign({}, c, n), h = s.subSurface(e, "histogram"); if (!1 !== n.stats) { const t = s.subSurface(e, "stats", { prepend: !0 }); let o; o = n.stats ? n.stats : u.arrayStats(r.map((e => e.value))), function (e, t, n) { const r = a.format(",.4~f"), i = a.format(".4~p"), o = [], s = []; null != e.numVals && (o.push("Num Vals"), s.push(r(e.numVals))); null != e.min && (o.push("Min"), s.push(r(e.min))); null != e.max && (o.push("Max"), s.push(r(e.max))); if (null != e.numZeros) { o.push("# Zeros"); let t = ""; e.numVals && (t = e.numZeros > 0 ? `(${i(e.numZeros / e.numVals)})` : ""), s.push(`${r(e.numZeros)} ${t}`) } if (null != e.numNans) { o.push("# NaNs"); let t = ""; e.numVals && (t = e.numNans > 0 ? `(${i(e.numNans / e.numVals)})` : ""), s.push(`${r(e.numNans)} ${t}`) } if (null != e.numInfs) { o.push("# Infinity"); let t = ""; e.numVals && (t = e.numInfs > 0 ? `(${i(e.numInfs / e.numVals)})` : ""), s.push(`${r(e.numInfs)} ${t}`) } l.table(t, { headers: o, values: [s] }, n) }(o, t, { fontSize: i.fontSize }) } if (0 === r.length) return; const d = []; for (let e = 0; e < r.length; e++) { const t = r[e].value; null != t && isFinite(t) && d.push(r[e]) } const f = { width: i.width || s.getDefaultWidth(h), height: i.height || s.getDefaultHeight(h), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, data: { values: d }, mark: { type: "bar", tooltip: !0 }, config: { axis: { labelFontSize: i.fontSize, titleFontSize: i.fontSize }, text: { fontSize: i.fontSize }, legend: { labelFontSize: i.fontSize, titleFontSize: i.fontSize } }, encoding: { x: { bin: { maxbins: i.maxBins }, field: "value", type: "quantitative" }, y: { aggregate: "count", type: "quantitative" }, color: { value: i.color || "#001B44" } } }; return o.default(h, f, { actions: !1, mode: "vega-lite", defaultStyle: !1 }) })) } + }, 4857: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6286), u = n(6857); t.linechart = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = Array.isArray(t.values[0]) ? t.values : [t.values], i = r[0].length, c = t.series ? t.series : r.map(((e, t) => `Series ${t + 1}`)); s.assert(c.length === r.length, "Must have an equal number of series labels as there are data series"), null != n.seriesColors && s.assert(n.seriesColors.length === r.length, "Must have an equal number of series colors as there are data series"); const h = []; for (let e = 0; e < i; e++) { const t = { x: e }; c.forEach(((n, i) => { const a = r[i][e].y; t[n] = a, t[`${n}-name`] = n })), h.push(t) } const d = Object.assign({}, l, n), f = { x: { field: "x", type: d.xType, title: d.xLabel }, tooltip: [{ field: "x", type: "quantitative" }, ...c.map((e => ({ field: e, type: "quantitative" })))] }, p = c.map((e => ({ data: void 0, mark: { type: "line", clip: !0 }, encoding: { y: { field: e, type: d.yType, title: d.yLabel, scale: d.zoomToFit ? { zero: !1 } : null != d.yAxisDomain ? { domain: d.yAxisDomain } : void 0 }, color: { field: `${e}-name`, type: "nominal", legend: { values: c, title: null }, scale: { range: d.seriesColors } } } }))), m = u.getDrawArea(e), g = { width: d.width || o.getDefaultWidth(m), height: d.height || o.getDefaultHeight(m), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: d.fontSize, titleFontSize: d.fontSize }, text: { fontSize: d.fontSize }, legend: { labelFontSize: d.fontSize, titleFontSize: d.fontSize } }, data: { values: h }, encoding: f, layer: [...p, { mark: "rule", selection: { hover: { type: "single", on: "mouseover", nearest: !0, clear: "mouseout" } }, encoding: { color: { value: "grey", condition: { selection: { not: "hover" }, value: "transparent" } } } }] }; return yield a.default(m, g, { actions: !1, mode: "vega-lite", defaultStyle: !1 }), Promise.resolve() })) }; const l = { xLabel: "x", yLabel: "y", xType: "quantitative", yType: "quantitative", zoomToFit: !1, fontSize: 11 } + }, 6857: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(5759), a = n(4701); t.getDrawArea = function (e) { if (e instanceof HTMLElement) return e; if (i.isSurface(e)) return e.drawArea; if (i.isSurfaceInfo(e)) { return a.visor().surface({ name: e.name, tab: e.tab, styles: e.styles }).drawArea } throw new Error("Not a drawable") }, t.shallowEquals = function (e, t) { const n = Object.getOwnPropertyNames(e), r = Object.getOwnPropertyNames(t); if (n.length !== r.length) return !1; for (let r = 0; r < n.length; r++) { const i = n[r]; if (e[i] !== t[i]) return !1 } return !0 }, t.nextFrame = function () { return r(this, void 0, void 0, (function* () { yield new Promise((e => requestAnimationFrame(e))) })) } + }, 898: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6286), u = n(6857); t.scatterplot = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { let r = t.values; const i = null == t.series ? [] : t.series; r = Array.isArray(r[0]) ? r : [r]; const c = []; r.forEach(((e, t) => { const n = null != i[t] ? i[t] : `Series ${t + 1}`, r = e.map((e => Object.assign({}, e, { series: n }))); c.push(...r) })), null != n.seriesColors && s.assert(n.seriesColors.length === r.length, "Must have an equal number of series colors as there are data series"); const h = u.getDrawArea(e), d = Object.assign({}, l, n), f = { width: d.width || o.getDefaultWidth(h), height: d.height || o.getDefaultHeight(h), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: d.fontSize, titleFontSize: d.fontSize }, text: { fontSize: d.fontSize }, legend: { labelFontSize: d.fontSize, titleFontSize: d.fontSize } }, data: { values: c }, mark: { type: "point", clip: !0, tooltip: { content: "data" } }, encoding: { x: { field: "x", type: d.xType, title: d.xLabel, scale: d.zoomToFit ? { zero: !1 } : null != d.xAxisDomain ? { domain: d.xAxisDomain } : void 0 }, y: { field: "y", type: d.yType, title: d.yLabel, scale: d.zoomToFit ? { zero: !1 } : null != d.yAxisDomain ? { domain: d.yAxisDomain } : void 0 }, color: { field: "series", type: "nominal", scale: { range: d.seriesColors } }, shape: { field: "series", type: "nominal" } } }; return yield a.default(h, f, { actions: !1, mode: "vega-lite", defaultStyle: !1 }), Promise.resolve() })) }; const l = { xLabel: "x", yLabel: "y", xType: "quantitative", yType: "quantitative", zoomToFit: !1, fontSize: 11 } + }, 9827: (e, t, n) => { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(1934), i = n(716), a = n(8205), o = n(6857); t.table = function (e, t, n = {}) { if (t && null == t.headers) throw new Error('Data to render must have a "headers" property'); if (t && null == t.values) throw new Error('Data to render must have a "values" property'); const u = o.getDrawArea(e), l = Object.assign({}, s, n); let c = i.select(u).select("table.tf-table"); const h = a.css({ fontSize: l.fontSize || ".875rem", width: "100%", maxWidth: "64rem", marginRight: "auto", marginLeft: "auto" }); if (0 === c.size() && (c = i.select(u).append("table"), c.attr("class", ` ${h} tf-table`), c.append("thead").append("tr"), c.append("tbody")), 1 !== c.size()) throw new Error("Error inserting table"); const d = a.css({ fontWeight: "600", borderBottomStyle: "solid", borderBottomWidth: "1px", borderColor: "rgba( 0, 0, 0, .2 )", textAlign: "left", paddingBottom: "1rem", paddingRight: "1rem", backgroundColor: "#fff" }), f = c.select("thead").select("tr").selectAll("th").data(t.headers), p = f.enter().append("th").attr("class", `${d}`); f.merge(p).html((e => e)), f.exit().remove(); const m = r.format(",.4~f"), g = c.select("tbody").selectAll("tr").data(t.values), y = g.enter().append("tr"), b = a.css({ padding: "0.25rem", borderBottomStyle: "solid", borderBottomWidth: "1px", borderColor: "rgba( 0, 0, 0, .2 )" }), v = g.merge(y).selectAll("td").data((e => e)), x = v.enter().append("td").attr("class", `${b}`); v.merge(x).html((e => "number" == typeof e ? m(e) : e)), v.exit().remove(), g.exit().remove() }; const s = { fontSize: 14 } + }, 62: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(4857), a = n(6857), o = n(8227); function s(e, t, n, s = {}) { return r(this, void 0, void 0, (function* () { const r = a.getDrawArea(e), c = {}; for (const e of n) if (/val_/.test(e)) { const r = e.replace("val_", ""); u(c, r); const i = l(t, e, n.indexOf(e)); c[r].series.push(e), c[r].values.push(i) } else { const r = l(t, e, n.indexOf(e)); u(c, e), c[e].series.push(e), c[e].values.push(r) } const h = Object.keys(c), d = Object.assign({}, { xLabel: "Iteration", yLabel: "Value" }, s), f = []; for (const e of h) { const t = o.subSurface(r, e), n = c[e].series, a = c[e].values; n.every((e => Boolean(e.match("acc")))) && (d.zoomToFitAccuracy ? d.zoomToFit = !0 : (d.yAxisDomain = [0, 1], delete d.zoomToFit)); const s = i.linechart(t, { values: a, series: n }, d); f.push(s) } yield Promise.all(f) })) } function u(e, t) { null == e[t] && (e[t] = { series: [], values: [] }) } function l(e, t, n) { if (Array.isArray(e)) { const r = Array.isArray(e[0]) ? e[n] : e, i = []; for (let e = 0; e < r.length; e++) { const n = r[e]; i.push({ x: e, y: n[t] }) } return i } return e.history[t].map(((e, t) => ({ x: t, y: e }))) } function c(e, t, n) { return null == e[t] && (e[t] = {}), null == e[t][n] && (e[t][n] = []), e[t][n] } t.history = s, t.fitCallbacks = function (e, t, n = {}) { const i = {}, u = n.callbacks || ["onEpochEnd", "onBatchEnd"], l = a.getDrawArea(e), h = Object.assign({}, n); delete h.callbacks; const d = {}; return u.forEach((e => { d[e] = function (e) { return (n, u) => r(this, void 0, void 0, (function* () { /batch/i.test(e) ? h.xLabel = "Batch" : /epoch/i.test(e) && (h.xLabel = "Epoch"); const n = [], r = []; for (const a of t) if (null != u[a]) { r.push(a); const t = c(i, e, a); t.push({ [a]: u[a] }), n.push(t) } s(o.subSurface(l, e, { title: e }), n, r, h), yield a.nextFrame() })) }(e) })), d } + }, 3559: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(5877), a = n(6857), o = n(9827), s = n(8227), u = n(2729); function l(e) { let t; if (Array.isArray(e.outputShape[0])) { t = `[${e.outputShape.map((e => c(e))).join(", ")}]` } else t = c(e.outputShape); return { name: e.name, trainable: e.trainable, parameters: e.countParams(), outputShape: t } } function c(e) { const t = e.slice(); return 0 === t.length ? "Scalar" : (null === t[0] && (t[0] = "batch"), `[${t.join(",")}]`) } t.modelSummary = function (e, t) { return r(this, void 0, void 0, (function* () { const n = a.getDrawArea(e), r = function (e) { return { layers: e.layers.map(l) } }(t), i = r.layers.map((e => [e.name, e.outputShape, e.parameters, e.trainable])); o.table(n, { headers: ["Layer Name", "Output Shape", "# Of Params", "Trainable"], values: i }) })) }, t.layer = function (e, t) { return r(this, void 0, void 0, (function* () { const n = a.getDrawArea(e), l = yield function (e) { return r(this, void 0, void 0, (function* () { const t = e.getWeights(), n = e.weights, r = t.map(u.tensorStats), i = yield Promise.all(r), a = t.map((e => e.shape)); return t.map(((e, t) => ({ name: n[t].name, stats: i[t], shape: c(a[t]), weight: e }))) })) }(t), h = s.subSurface(n, "layer-weights-info"), d = l.map((e => [e.name, e.shape, e.stats.min, e.stats.max, e.weight.size, e.stats.numZeros, e.stats.numNans, e.stats.numInfs])); o.table(h, { headers: ["Weight Name", "Shape", "Min", "Max", "# Params", "# Zeros", "# NaNs", "# Infinity"], values: d }); const f = s.subSurface(n, "select-layer"), p = s.subSurface(n, "param-distribution"); !function (e, t, n) { const r = `\n \n `, i = `
${r}
`; t.innerHTML = i; const a = t.querySelector("button"), o = t.querySelector("select"); a.addEventListener("click", (() => { n(o.selectedOptions[0].label) })) }(l.map((e => e.name)), f, (e => r(this, void 0, void 0, (function* () { const t = l.filter((t => t.name === e))[0], n = yield t.weight.data(); i.histogram(p, n, { height: 150, width: 460, stats: !1 }) })))) })) } + }, 5727: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(6857), a = n(9827); t.perClassAccuracy = function (e, t, n) { return r(this, void 0, void 0, (function* () { const r = i.getDrawArea(e), o = []; for (let e = 0; e < t.length; e++) { const r = n ? n[e] : e.toString(), i = t[e]; o.push([r, i.accuracy, i.count]) } return a.table(r, { headers: ["Class", "Accuracy", "# Samples"], values: o }) })) } + }, 4853: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(5877), a = n(6857), o = n(2729); t.valuesDistribution = function (e, t) { return r(this, void 0, void 0, (function* () { const n = a.getDrawArea(e), r = yield o.tensorStats(t), s = yield t.data(); i.histogram(n, s, { height: 150, stats: r }) })) } + }, 5759: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.isSurfaceInfo = function (e) { return null != e.name }, t.isSurface = function (e) { return e.drawArea instanceof HTMLElement } }, 8227: (e, t, n) => { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(8205), i = n(6857), a = { prepend: !1 }; t.subSurface = function (e, t, n = {}) { const o = i.getDrawArea(e), s = r.css({ "& canvas": { display: "block" }, marginTop: ".5rem", marginBottom: ".5rem" }), u = r.css({ backgroundColor: "white", display: "inline-block", boxSizing: "border-box", borderBottom: "1px solid #357EDD", lineHeight: "2em", padding: "0 10px 0 10px", marginBottom: "20px", fontWeight: "600", textAlign: "left" }), l = Object.assign({}, a, n); let c = o.querySelector(`div[data-name=${t}]`); if (!c) { if (c = document.createElement("div"), c.setAttribute("class", `${s}`), c.dataset.name = t, l.title) { const e = document.createElement("div"); e.setAttribute("class", `subsurface-title ${u}`), e.innerText = l.title, c.appendChild(e) } l.prepend ? o.insertBefore(c, o.firstChild) : o.appendChild(c) } return c }, t.getDefaultWidth = function (e) { let t = 0, n = e; for (; n && 0 === n.clientWidth;)n = n.parentElement, t = 50; return n.clientWidth - t }, t.getDefaultHeight = function (e) { return 0 === e.clientHeight ? 200 : e.clientHeight } + }, 2729: function (e, t, n) { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(5838), a = n(6286); t.arrayStats = function (e) { if (!Array.isArray(e)) throw new Error("input must be an array"); if (0 === e.length) return { numVals: 0, numNans: 0, numZeros: 0, max: void 0, min: void 0 }; const t = e.length; let n = -1 / 0, r = 1 / 0, i = 0, a = 0, o = 0; for (let s = 0; s < t; s++) { const t = e[s]; t > n && (n = t), t < r && (r = t), 0 === t && (i += 1), isNaN(t) ? a += 1 : isFinite(t) || (o += 1) } const s = { numVals: t, numZeros: i, numNans: a, max: n, min: r, numInfs: o }; return s.max === -1 / 0 && (s.max = NaN), s.min === 1 / 0 && (s.min = NaN), s }, t.tensorStats = function (e) { return r(this, void 0, void 0, (function* () { const [t, n, r] = i.tidy((() => { const t = i.scalar(0, e.dtype); return [e.min(), e.max(), e.equal(t).sum()] })); return Promise.all([e.data(), t.data(), n.data(), r.data()]).then((([e, t, n, r]) => { const i = e.length; let a = 0, o = 0; for (let t = 0; t < i; t++) { const n = e[t]; isNaN(n) ? a += 1 : isFinite(n) || (o += 1) } let s = t[0], u = n[0]; a === i && (s = NaN, u = NaN); return { numVals: i, numZeros: r[0], numNans: a, min: s, max: u, numInfs: o } })) })) }, t.confusionMatrix = function (e, t, n, o) { return r(this, void 0, void 0, (function* () { a.assert(1 === e.rank, "labels must be a 1D tensor"), a.assert(1 === t.rank, "predictions must be a 1D tensor"), a.assert(e.size === t.size, "labels and predictions must be the same length"), null != o && a.assert(o.size === t.size, "labels and predictions must be the same length"); const r = e.cast("int32"), s = t.cast("int32"); null == n && (n = i.tidy((() => i.maximum(r.max(), s.max()).cast("int32").dataSync()[0] + 1))); let u = Promise.resolve(null); return null != o && (u = o.data()), Promise.all([r.data(), s.data(), u]).then((([e, t, r]) => { const i = Array(n).fill(0); for (let e = 0; e < n; e++)i[e] = Array(n).fill(0); for (let n = 0; n < e.length; n++) { const a = e[n], o = t[n]; i[a][o] += null != r ? r[n] : 1 } return i })) })) }, t.accuracy = function (e, t) { return r(this, void 0, void 0, (function* () { a.assertShapesMatch(e.shape, t.shape, "Error computing accuracy."); const n = e.equal(t), r = n.mean(), o = (yield r.data())[0]; return i.dispose([n, r]), o })) }, t.perClassAccuracy = function (e, t, n) { return r(this, void 0, void 0, (function* () { return a.assert(1 === e.rank, "labels must be a 1D tensor"), a.assert(1 === t.rank, "predictions must be a 1D tensor"), a.assert(e.size === t.size, "labels and predictions must be the same length"), null == n && (n = i.tidy((() => i.maximum(e.max(), t.max()).dataSync()[0] + 1))), Promise.all([e.data(), t.data()]).then((([e, t]) => { const r = Array(n).fill(0), i = Array(n).fill(0); for (let n = 0; n < e.length; n++) { const a = e[n], o = t[n]; r[a] += 1, a === o && (i[a] += 1) } const a = []; for (let e = 0; e < r.length; e++)a.push({ count: r[e], accuracy: 0 === r[e] ? 0 : i[e] / r[e] }); return a })) })) } + }, 6286: (e, t) => { + "use strict"; + /* + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function n(e, t) { if (!e) throw new Error("string" == typeof t ? t : t()) } function r(e, t) { if (e.length !== t.length) return !1; for (let n = 0; n < e.length; n++)if (e[n] !== t[n]) return !1; return !0 } Object.defineProperty(t, "__esModule", { value: !0 }), t.assert = n, t.assertShapesMatch = function (e, t, i = "") { n(r(e, t), i + ` Shapes ${e} and ${t} must match`) }, t.arraysEqual = r, t.DECIMAL_PLACES_TO_CHECK = 4 + }, 454: (e, t) => { + "use strict"; +/** @license See the LICENSE file. */Object.defineProperty(t, "__esModule", { value: !0 }); t.version = "1.5.1" + }, 4701: (e, t, n) => { + "use strict"; +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5976); let i; const a = "tfjs-visor-container"; t.visor = function () { if ("undefined" == typeof document) throw new Error("No document defined. This library needs a browser/dom to work"); if (document.getElementById(a) && null != i) return i; let e, t = document.getElementById(a); function n(t, n) { let i = null; return e = r.VisorComponent.render(t, e, { ref: e => i = e, surfaceList: Array.from(n.values()) }), i } null == t && (t = document.createElement("div"), t.id = a, document.body.appendChild(t)); const s = new Map, u = n(t, s); return i = new o(u, t, s, n), i }; class o { constructor(e, t, n, r) { this.visorComponent = e, this.el = t, this.surfaceList = n, this.renderVisor = r } surface(e) { const { name: t } = e, n = null == e.tab ? "Visor" : e.tab; if (null == t || !("string" == typeof t || t instanceof String)) throw new Error("You must pass a config object with a 'name' property to create or retrieve a surface"); const r = Object.assign({}, e, { tab: n }), i = `${t}-${n}`; return this.surfaceList.has(i) || this.surfaceList.set(i, r), this.renderVisor(this.el, this.surfaceList), this.visorComponent.getSurface(t, n) } isFullscreen() { return this.visorComponent.isFullscreen() } isOpen() { return this.visorComponent.isOpen() } close() { return this.visorComponent.close() } open() { return this.visorComponent.open() } toggle() { return this.visorComponent.toggle() } toggleFullScreen() { return this.visorComponent.toggleFullScreen() } bindKeys() { return this.visorComponent.bindKeys() } unbindKeys() { return this.visorComponent.unbindKeys() } setActiveTab(e) { if (!this.visorComponent.state.tabs.has(e)) throw new Error(`Tab '${e}' does not exist`); this.visorComponent.setState({ activeTab: e }) } } t.Visor = o + }, 1934: (e, t, n) => { "use strict"; function r(e, t) { if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null; var n, r = e.slice(0, n); return [r.length > 1 ? r[0] + r.slice(2) : r, +e.slice(n + 1)] } function i(e) { return (e = r(Math.abs(e))) ? e[1] : NaN } n.r(t), n.d(t, { format: () => f, formatDefaultLocale: () => y, formatLocale: () => g, formatPrefix: () => p, formatSpecifier: () => s, precisionFixed: () => b, precisionPrefix: () => v, precisionRound: () => x }); var a, o = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; function s(e) { return new u(e) } function u(e) { if (!(t = o.exec(e))) throw new Error("invalid format: " + e); var t; this.fill = t[1] || " ", this.align = t[2] || ">", this.sign = t[3] || "-", this.symbol = t[4] || "", this.zero = !!t[5], this.width = t[6] && +t[6], this.comma = !!t[7], this.precision = t[8] && +t[8].slice(1), this.trim = !!t[9], this.type = t[10] || "" } function l(e, t) { var n = r(e, t); if (!n) return e + ""; var i = n[0], a = n[1]; return a < 0 ? "0." + new Array(-a).join("0") + i : i.length > a + 1 ? i.slice(0, a + 1) + "." + i.slice(a + 1) : i + new Array(a - i.length + 2).join("0") } s.prototype = u.prototype, u.prototype.toString = function () { return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (null == this.width ? "" : Math.max(1, 0 | this.width)) + (this.comma ? "," : "") + (null == this.precision ? "" : "." + Math.max(0, 0 | this.precision)) + (this.trim ? "~" : "") + this.type }; const c = { "%": function (e, t) { return (100 * e).toFixed(t) }, b: function (e) { return Math.round(e).toString(2) }, c: function (e) { return e + "" }, d: function (e) { return Math.round(e).toString(10) }, e: function (e, t) { return e.toExponential(t) }, f: function (e, t) { return e.toFixed(t) }, g: function (e, t) { return e.toPrecision(t) }, o: function (e) { return Math.round(e).toString(8) }, p: function (e, t) { return l(100 * e, t) }, r: l, s: function (e, t) { var n = r(e, t); if (!n) return e + ""; var i = n[0], o = n[1], s = o - (a = 3 * Math.max(-8, Math.min(8, Math.floor(o / 3)))) + 1, u = i.length; return s === u ? i : s > u ? i + new Array(s - u + 1).join("0") : s > 0 ? i.slice(0, s) + "." + i.slice(s) : "0." + new Array(1 - s).join("0") + r(e, Math.max(0, t + s - 1))[0] }, X: function (e) { return Math.round(e).toString(16).toUpperCase() }, x: function (e) { return Math.round(e).toString(16) } }; function h(e) { return e } var d, f, p, m = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; function g(e) { var t, n, r = e.grouping && e.thousands ? (t = e.grouping, n = e.thousands, function (e, r) { for (var i = e.length, a = [], o = 0, s = t[0], u = 0; i > 0 && s > 0 && (u + s + 1 > r && (s = Math.max(1, r - u)), a.push(e.substring(i -= s, i + s)), !((u += s + 1) > r));)s = t[o = (o + 1) % t.length]; return a.reverse().join(n) }) : h, o = e.currency, u = e.decimal, l = e.numerals ? function (e) { return function (t) { return t.replace(/[0-9]/g, (function (t) { return e[+t] })) } }(e.numerals) : h, d = e.percent || "%"; function f(e) { var t = (e = s(e)).fill, n = e.align, i = e.sign, h = e.symbol, f = e.zero, p = e.width, g = e.comma, y = e.precision, b = e.trim, v = e.type; "n" === v ? (g = !0, v = "g") : c[v] || (null == y && (y = 12), b = !0, v = "g"), (f || "0" === t && "=" === n) && (f = !0, t = "0", n = "="); var x = "$" === h ? o[0] : "#" === h && /[boxX]/.test(v) ? "0" + v.toLowerCase() : "", w = "$" === h ? o[1] : /[%p]/.test(v) ? d : "", k = c[v], S = /[defgprs%]/.test(v); function _(e) { var o, s, c, h = x, d = w; if ("c" === v) d = k(e) + d, e = ""; else { var _ = (e = +e) < 0; if (e = k(Math.abs(e), y), b && (e = function (e) { e: for (var t, n = e.length, r = 1, i = -1; r < n; ++r)switch (e[r]) { case ".": i = t = r; break; case "0": 0 === i && (i = r), t = r; break; default: if (i > 0) { if (!+e[r]) break e; i = 0 } }return i > 0 ? e.slice(0, i) + e.slice(t + 1) : e }(e)), _ && 0 == +e && (_ = !1), h = (_ ? "(" === i ? i : "-" : "-" === i || "(" === i ? "" : i) + h, d = ("s" === v ? m[8 + a / 3] : "") + d + (_ && "(" === i ? ")" : ""), S) for (o = -1, s = e.length; ++o < s;)if (48 > (c = e.charCodeAt(o)) || c > 57) { d = (46 === c ? u + e.slice(o + 1) : e.slice(o)) + d, e = e.slice(0, o); break } } g && !f && (e = r(e, 1 / 0)); var C = h.length + e.length + d.length, A = C < p ? new Array(p - C + 1).join(t) : ""; switch (g && f && (e = r(A + e, A.length ? p - d.length : 1 / 0), A = ""), n) { case "<": e = h + e + d + A; break; case "=": e = h + A + e + d; break; case "^": e = A.slice(0, C = A.length >> 1) + h + e + d + A.slice(C); break; default: e = A + h + e + d }return l(e) } return y = null == y ? 6 : /[gprs]/.test(v) ? Math.max(1, Math.min(21, y)) : Math.max(0, Math.min(20, y)), _.toString = function () { return e + "" }, _ } return { format: f, formatPrefix: function (e, t) { var n = f(((e = s(e)).type = "f", e)), r = 3 * Math.max(-8, Math.min(8, Math.floor(i(t) / 3))), a = Math.pow(10, -r), o = m[8 + r / 3]; return function (e) { return n(a * e) + o } } } } function y(e) { return d = g(e), f = d.format, p = d.formatPrefix, d } function b(e) { return Math.max(0, -i(Math.abs(e))) } function v(e, t) { return Math.max(0, 3 * Math.max(-8, Math.min(8, Math.floor(i(t) / 3))) - i(Math.abs(e))) } function x(e, t) { return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, i(t) - i(e)) + 1 } y({ decimal: ".", thousands: ",", grouping: [3], currency: ["$", ""] }) }, 1779: e => { var t = function () { "use strict"; function e(e, t) { return null != t && e instanceof t } var t, n, r; try { t = Map } catch (e) { t = function () { } } try { n = Set } catch (e) { n = function () { } } try { r = Promise } catch (e) { r = function () { } } function i(a, s, u, l, c) { "object" == typeof s && (u = s.depth, l = s.prototype, c = s.includeNonEnumerable, s = s.circular); var h = [], d = [], f = "undefined" != typeof Buffer; return void 0 === s && (s = !0), void 0 === u && (u = 1 / 0), function a(u, p) { if (null === u) return null; if (0 === p) return u; var m, g; if ("object" != typeof u) return u; if (e(u, t)) m = new t; else if (e(u, n)) m = new n; else if (e(u, r)) m = new r((function (e, t) { u.then((function (t) { e(a(t, p - 1)) }), (function (e) { t(a(e, p - 1)) })) })); else if (i.__isArray(u)) m = []; else if (i.__isRegExp(u)) m = new RegExp(u.source, o(u)), u.lastIndex && (m.lastIndex = u.lastIndex); else if (i.__isDate(u)) m = new Date(u.getTime()); else { if (f && Buffer.isBuffer(u)) return m = Buffer.allocUnsafe ? Buffer.allocUnsafe(u.length) : new Buffer(u.length), u.copy(m), m; e(u, Error) ? m = Object.create(u) : void 0 === l ? (g = Object.getPrototypeOf(u), m = Object.create(g)) : (m = Object.create(l), g = l) } if (s) { var y = h.indexOf(u); if (-1 != y) return d[y]; h.push(u), d.push(m) } for (var b in e(u, t) && u.forEach((function (e, t) { var n = a(t, p - 1), r = a(e, p - 1); m.set(n, r) })), e(u, n) && u.forEach((function (e) { var t = a(e, p - 1); m.add(t) })), u) { var v; g && (v = Object.getOwnPropertyDescriptor(g, b)), v && null == v.set || (m[b] = a(u[b], p - 1)) } if (Object.getOwnPropertySymbols) { var x = Object.getOwnPropertySymbols(u); for (b = 0; b < x.length; b++) { var w = x[b]; (!(S = Object.getOwnPropertyDescriptor(u, w)) || S.enumerable || c) && (m[w] = a(u[w], p - 1), S.enumerable || Object.defineProperty(m, w, { enumerable: !1 })) } } if (c) { var k = Object.getOwnPropertyNames(u); for (b = 0; b < k.length; b++) { var S, _ = k[b]; (S = Object.getOwnPropertyDescriptor(u, _)) && S.enumerable || (m[_] = a(u[_], p - 1), Object.defineProperty(m, _, { enumerable: !1 })) } } return m }(a, u) } function a(e) { return Object.prototype.toString.call(e) } function o(e) { var t = ""; return e.global && (t += "g"), e.ignoreCase && (t += "i"), e.multiline && (t += "m"), t } return i.clonePrototype = function (e) { if (null === e) return null; var t = function () { }; return t.prototype = e, new t }, i.__objToStr = a, i.__isDate = function (e) { return "object" == typeof e && "[object Date]" === a(e) }, i.__isArray = function (e) { return "object" == typeof e && "[object Array]" === a(e) }, i.__isRegExp = function (e) { return "object" == typeof e && "[object RegExp]" === a(e) }, i.__getRegExpFlags = o, i }(); e.exports && (e.exports = t) }, 5721: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e) { return (0, a.default)(e) }; var r, i = n(8066), a = (r = i) && r.__esModule ? r : { default: r }; e.exports = t.default }, 4014: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e) { return "string" == typeof e && n.test(e) }; var n = /-webkit-|-moz-|-ms-/; e.exports = t.default }, 716: (e, t, n) => { "use strict"; n.r(t), n.d(t, { clientPoint: () => ke, create: () => ye, creator: () => u, customEvent: () => ue, event: () => re, local: () => ve, matcher: () => g, mouse: () => Se, namespace: () => a, namespaces: () => i, select: () => ge, selectAll: () => _e, selection: () => me, selector: () => c, selectorAll: () => d, style: () => F, touch: () => Ce, touches: () => Ae, window: () => E }); var r = "http://www.w3.org/1999/xhtml"; const i = { svg: "http://www.w3.org/2000/svg", xhtml: r, xlink: "http://www.w3.org/1999/xlink", xml: "http://www.w3.org/XML/1998/namespace", xmlns: "http://www.w3.org/2000/xmlns/" }; function a(e) { var t = e += "", n = t.indexOf(":"); return n >= 0 && "xmlns" !== (t = e.slice(0, n)) && (e = e.slice(n + 1)), i.hasOwnProperty(t) ? { space: i[t], local: e } : e } function o(e) { return function () { var t = this.ownerDocument, n = this.namespaceURI; return n === r && t.documentElement.namespaceURI === r ? t.createElement(e) : t.createElementNS(n, e) } } function s(e) { return function () { return this.ownerDocument.createElementNS(e.space, e.local) } } function u(e) { var t = a(e); return (t.local ? s : o)(t) } function l() { } function c(e) { return null == e ? l : function () { return this.querySelector(e) } } function h() { return [] } function d(e) { return null == e ? h : function () { return this.querySelectorAll(e) } } var f = function (e) { return function () { return this.matches(e) } }; if ("undefined" != typeof document) { var p = document.documentElement; if (!p.matches) { var m = p.webkitMatchesSelector || p.msMatchesSelector || p.mozMatchesSelector || p.oMatchesSelector; f = function (e) { return function () { return m.call(this, e) } } } } const g = f; function y(e) { return new Array(e.length) } function b(e, t) { this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t } b.prototype = { constructor: b, appendChild: function (e) { return this._parent.insertBefore(e, this._next) }, insertBefore: function (e, t) { return this._parent.insertBefore(e, t) }, querySelector: function (e) { return this._parent.querySelector(e) }, querySelectorAll: function (e) { return this._parent.querySelectorAll(e) } }; function v(e, t, n, r, i, a) { for (var o, s = 0, u = t.length, l = a.length; s < l; ++s)(o = t[s]) ? (o.__data__ = a[s], r[s] = o) : n[s] = new b(e, a[s]); for (; s < u; ++s)(o = t[s]) && (i[s] = o) } function x(e, t, n, r, i, a, o) { var s, u, l, c = {}, h = t.length, d = a.length, f = new Array(h); for (s = 0; s < h; ++s)(u = t[s]) && (f[s] = l = "$" + o.call(u, u.__data__, s, t), l in c ? i[s] = u : c[l] = u); for (s = 0; s < d; ++s)(u = c[l = "$" + o.call(e, a[s], s, a)]) ? (r[s] = u, u.__data__ = a[s], c[l] = null) : n[s] = new b(e, a[s]); for (s = 0; s < h; ++s)(u = t[s]) && c[f[s]] === u && (i[s] = u) } function w(e, t) { return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function k(e) { return function () { this.removeAttribute(e) } } function S(e) { return function () { this.removeAttributeNS(e.space, e.local) } } function _(e, t) { return function () { this.setAttribute(e, t) } } function C(e, t) { return function () { this.setAttributeNS(e.space, e.local, t) } } function A(e, t) { return function () { var n = t.apply(this, arguments); null == n ? this.removeAttribute(e) : this.setAttribute(e, n) } } function T(e, t) { return function () { var n = t.apply(this, arguments); null == n ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, n) } } function E(e) { return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView } function N(e) { return function () { this.style.removeProperty(e) } } function I(e, t, n) { return function () { this.style.setProperty(e, t, n) } } function M(e, t, n) { return function () { var r = t.apply(this, arguments); null == r ? this.style.removeProperty(e) : this.style.setProperty(e, r, n) } } function F(e, t) { return e.style.getPropertyValue(t) || E(e).getComputedStyle(e, null).getPropertyValue(t) } function D(e) { return function () { delete this[e] } } function $(e, t) { return function () { this[e] = t } } function R(e, t) { return function () { var n = t.apply(this, arguments); null == n ? delete this[e] : this[e] = n } } function O(e) { return e.trim().split(/^|\s+/) } function z(e) { return e.classList || new P(e) } function P(e) { this._node = e, this._names = O(e.getAttribute("class") || "") } function B(e, t) { for (var n = z(e), r = -1, i = t.length; ++r < i;)n.add(t[r]) } function L(e, t) { for (var n = z(e), r = -1, i = t.length; ++r < i;)n.remove(t[r]) } function j(e) { return function () { B(this, e) } } function U(e) { return function () { L(this, e) } } function W(e, t) { return function () { (t.apply(this, arguments) ? B : L)(this, e) } } function V() { this.textContent = "" } function G(e) { return function () { this.textContent = e } } function H(e) { return function () { var t = e.apply(this, arguments); this.textContent = null == t ? "" : t } } function q() { this.innerHTML = "" } function Y(e) { return function () { this.innerHTML = e } } function X(e) { return function () { var t = e.apply(this, arguments); this.innerHTML = null == t ? "" : t } } function K() { this.nextSibling && this.parentNode.appendChild(this) } function Z() { this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild) } function J() { return null } function Q() { var e = this.parentNode; e && e.removeChild(this) } function ee() { return this.parentNode.insertBefore(this.cloneNode(!1), this.nextSibling) } function te() { return this.parentNode.insertBefore(this.cloneNode(!0), this.nextSibling) } P.prototype = { add: function (e) { this._names.indexOf(e) < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" "))) }, remove: function (e) { var t = this._names.indexOf(e); t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" "))) }, contains: function (e) { return this._names.indexOf(e) >= 0 } }; var ne = {}, re = null; "undefined" != typeof document && ("onmouseenter" in document.documentElement || (ne = { mouseenter: "mouseover", mouseleave: "mouseout" })); function ie(e, t, n) { return e = ae(e, t, n), function (t) { var n = t.relatedTarget; n && (n === this || 8 & n.compareDocumentPosition(this)) || e.call(this, t) } } function ae(e, t, n) { return function (r) { var i = re; re = r; try { e.call(this, this.__data__, t, n) } finally { re = i } } } function oe(e) { return function () { var t = this.__on; if (t) { for (var n, r = 0, i = -1, a = t.length; r < a; ++r)n = t[r], e.type && n.type !== e.type || n.name !== e.name ? t[++i] = n : this.removeEventListener(n.type, n.listener, n.capture); ++i ? t.length = i : delete this.__on } } } function se(e, t, n) { var r = ne.hasOwnProperty(e.type) ? ie : ae; return function (i, a, o) { var s, u = this.__on, l = r(t, a, o); if (u) for (var c = 0, h = u.length; c < h; ++c)if ((s = u[c]).type === e.type && s.name === e.name) return this.removeEventListener(s.type, s.listener, s.capture), this.addEventListener(s.type, s.listener = l, s.capture = n), void (s.value = t); this.addEventListener(e.type, l, n), s = { type: e.type, name: e.name, value: t, listener: l, capture: n }, u ? u.push(s) : this.__on = [s] } } function ue(e, t, n, r) { var i = re; e.sourceEvent = re, re = e; try { return t.apply(n, r) } finally { re = i } } function le(e, t, n) { var r = E(e), i = r.CustomEvent; "function" == typeof i ? i = new i(t, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(t, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(t, !1, !1)), e.dispatchEvent(i) } function ce(e, t) { return function () { return le(this, e, t) } } function he(e, t) { return function () { return le(this, e, t.apply(this, arguments)) } } var de = [null]; function fe(e, t) { this._groups = e, this._parents = t } function pe() { return new fe([[document.documentElement]], de) } fe.prototype = pe.prototype = { constructor: fe, select: function (e) { "function" != typeof e && (e = c(e)); for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)for (var a, o, s = t[i], u = s.length, l = r[i] = new Array(u), h = 0; h < u; ++h)(a = s[h]) && (o = e.call(a, a.__data__, h, s)) && ("__data__" in a && (o.__data__ = a.__data__), l[h] = o); return new fe(r, this._parents) }, selectAll: function (e) { "function" != typeof e && (e = d(e)); for (var t = this._groups, n = t.length, r = [], i = [], a = 0; a < n; ++a)for (var o, s = t[a], u = s.length, l = 0; l < u; ++l)(o = s[l]) && (r.push(e.call(o, o.__data__, l, s)), i.push(o)); return new fe(r, i) }, filter: function (e) { "function" != typeof e && (e = g(e)); for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)for (var a, o = t[i], s = o.length, u = r[i] = [], l = 0; l < s; ++l)(a = o[l]) && e.call(a, a.__data__, l, o) && u.push(a); return new fe(r, this._parents) }, data: function (e, t) { if (!e) return p = new Array(this.size()), c = -1, this.each((function (e) { p[++c] = e })), p; var n, r = t ? x : v, i = this._parents, a = this._groups; "function" != typeof e && (n = e, e = function () { return n }); for (var o = a.length, s = new Array(o), u = new Array(o), l = new Array(o), c = 0; c < o; ++c) { var h = i[c], d = a[c], f = d.length, p = e.call(h, h && h.__data__, c, i), m = p.length, g = u[c] = new Array(m), y = s[c] = new Array(m); r(h, d, g, y, l[c] = new Array(f), p, t); for (var b, w, k = 0, S = 0; k < m; ++k)if (b = g[k]) { for (k >= S && (S = k + 1); !(w = y[S]) && ++S < m;); b._next = w || null } } return (s = new fe(s, i))._enter = u, s._exit = l, s }, enter: function () { return new fe(this._enter || this._groups.map(y), this._parents) }, exit: function () { return new fe(this._exit || this._groups.map(y), this._parents) }, merge: function (e) { for (var t = this._groups, n = e._groups, r = t.length, i = n.length, a = Math.min(r, i), o = new Array(r), s = 0; s < a; ++s)for (var u, l = t[s], c = n[s], h = l.length, d = o[s] = new Array(h), f = 0; f < h; ++f)(u = l[f] || c[f]) && (d[f] = u); for (; s < r; ++s)o[s] = t[s]; return new fe(o, this._parents) }, order: function () { for (var e = this._groups, t = -1, n = e.length; ++t < n;)for (var r, i = e[t], a = i.length - 1, o = i[a]; --a >= 0;)(r = i[a]) && (o && o !== r.nextSibling && o.parentNode.insertBefore(r, o), o = r); return this }, sort: function (e) { function t(t, n) { return t && n ? e(t.__data__, n.__data__) : !t - !n } e || (e = w); for (var n = this._groups, r = n.length, i = new Array(r), a = 0; a < r; ++a) { for (var o, s = n[a], u = s.length, l = i[a] = new Array(u), c = 0; c < u; ++c)(o = s[c]) && (l[c] = o); l.sort(t) } return new fe(i, this._parents).order() }, call: function () { var e = arguments[0]; return arguments[0] = this, e.apply(null, arguments), this }, nodes: function () { var e = new Array(this.size()), t = -1; return this.each((function () { e[++t] = this })), e }, node: function () { for (var e = this._groups, t = 0, n = e.length; t < n; ++t)for (var r = e[t], i = 0, a = r.length; i < a; ++i) { var o = r[i]; if (o) return o } return null }, size: function () { var e = 0; return this.each((function () { ++e })), e }, empty: function () { return !this.node() }, each: function (e) { for (var t = this._groups, n = 0, r = t.length; n < r; ++n)for (var i, a = t[n], o = 0, s = a.length; o < s; ++o)(i = a[o]) && e.call(i, i.__data__, o, a); return this }, attr: function (e, t) { var n = a(e); if (arguments.length < 2) { var r = this.node(); return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n) } return this.each((null == t ? n.local ? S : k : "function" == typeof t ? n.local ? T : A : n.local ? C : _)(n, t)) }, style: function (e, t, n) { return arguments.length > 1 ? this.each((null == t ? N : "function" == typeof t ? M : I)(e, t, null == n ? "" : n)) : F(this.node(), e) }, property: function (e, t) { return arguments.length > 1 ? this.each((null == t ? D : "function" == typeof t ? R : $)(e, t)) : this.node()[e] }, classed: function (e, t) { var n = O(e + ""); if (arguments.length < 2) { for (var r = z(this.node()), i = -1, a = n.length; ++i < a;)if (!r.contains(n[i])) return !1; return !0 } return this.each(("function" == typeof t ? W : t ? j : U)(n, t)) }, text: function (e) { return arguments.length ? this.each(null == e ? V : ("function" == typeof e ? H : G)(e)) : this.node().textContent }, html: function (e) { return arguments.length ? this.each(null == e ? q : ("function" == typeof e ? X : Y)(e)) : this.node().innerHTML }, raise: function () { return this.each(K) }, lower: function () { return this.each(Z) }, append: function (e) { var t = "function" == typeof e ? e : u(e); return this.select((function () { return this.appendChild(t.apply(this, arguments)) })) }, insert: function (e, t) { var n = "function" == typeof e ? e : u(e), r = null == t ? J : "function" == typeof t ? t : c(t); return this.select((function () { return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null) })) }, remove: function () { return this.each(Q) }, clone: function (e) { return this.select(e ? te : ee) }, datum: function (e) { return arguments.length ? this.property("__data__", e) : this.node().__data__ }, on: function (e, t, n) { var r, i, a = function (e) { return e.trim().split(/^|\s+/).map((function (e) { var t = "", n = e.indexOf("."); return n >= 0 && (t = e.slice(n + 1), e = e.slice(0, n)), { type: e, name: t } })) }(e + ""), o = a.length; if (!(arguments.length < 2)) { for (s = t ? se : oe, null == n && (n = !1), r = 0; r < o; ++r)this.each(s(a[r], t, n)); return this } var s = this.node().__on; if (s) for (var u, l = 0, c = s.length; l < c; ++l)for (r = 0, u = s[l]; r < o; ++r)if ((i = a[r]).type === u.type && i.name === u.name) return u.value }, dispatch: function (e, t) { return this.each(("function" == typeof t ? he : ce)(e, t)) } }; const me = pe; function ge(e) { return "string" == typeof e ? new fe([[document.querySelector(e)]], [document.documentElement]) : new fe([[e]], de) } function ye(e) { return ge(u(e).call(document.documentElement)) } var be = 0; function ve() { return new xe } function xe() { this._ = "@" + (++be).toString(36) } function we() { for (var e, t = re; e = t.sourceEvent;)t = e; return t } function ke(e, t) { var n = e.ownerSVGElement || e; if (n.createSVGPoint) { var r = n.createSVGPoint(); return r.x = t.clientX, r.y = t.clientY, [(r = r.matrixTransform(e.getScreenCTM().inverse())).x, r.y] } var i = e.getBoundingClientRect(); return [t.clientX - i.left - e.clientLeft, t.clientY - i.top - e.clientTop] } function Se(e) { var t = we(); return t.changedTouches && (t = t.changedTouches[0]), ke(e, t) } function _e(e) { return "string" == typeof e ? new fe([document.querySelectorAll(e)], [document.documentElement]) : new fe([null == e ? [] : e], de) } function Ce(e, t, n) { arguments.length < 3 && (n = t, t = we().changedTouches); for (var r, i = 0, a = t ? t.length : 0; i < a; ++i)if ((r = t[i]).identifier === n) return ke(e, r); return null } function Ae(e, t) { null == t && (t = we().touches); for (var n = 0, r = t ? t.length : 0, i = new Array(r); n < r; ++n)i[n] = ke(e, t[n]); return i } xe.prototype = ve.prototype = { constructor: xe, get: function (e) { for (var t = this._; !(t in e);)if (!(e = e.parentNode)) return; return e[t] }, set: function (e, t) { return e[this._] = t }, remove: function (e) { return this._ in e && delete e[this._] }, toString: function () { return this._ } } }, 2017: e => { "use strict"; e.exports = function e(t, n) { if (t === n) return !0; if (t && n && "object" == typeof t && "object" == typeof n) { if (t.constructor !== n.constructor) return !1; var r, i, a; if (Array.isArray(t)) { if ((r = t.length) != n.length) return !1; for (i = r; 0 != i--;)if (!e(t[i], n[i])) return !1; return !0 } if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags; if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf(); if (t.toString !== Object.prototype.toString) return t.toString() === n.toString(); if ((r = (a = Object.keys(t)).length) !== Object.keys(n).length) return !1; for (i = r; 0 != i--;)if (!Object.prototype.hasOwnProperty.call(n, a[i])) return !1; for (i = r; 0 != i--;) { var o = a[i]; if (!e(t[o], n[o])) return !1 } return !0 } return t != t && n != n } }, 2492: e => { "use strict"; e.exports = function (e, t) { t || (t = {}), "function" == typeof t && (t = { cmp: t }); var n, r = "boolean" == typeof t.cycles && t.cycles, i = t.cmp && (n = t.cmp, function (e) { return function (t, r) { var i = { key: t, value: e[t] }, a = { key: r, value: e[r] }; return n(i, a) } }), a = []; return function e(t) { if (t && t.toJSON && "function" == typeof t.toJSON && (t = t.toJSON()), void 0 !== t) { if ("number" == typeof t) return isFinite(t) ? "" + t : "null"; if ("object" != typeof t) return JSON.stringify(t); var n, o; if (Array.isArray(t)) { for (o = "[", n = 0; n < t.length; n++)n && (o += ","), o += e(t[n]) || "null"; return o + "]" } if (null === t) return "null"; if (-1 !== a.indexOf(t)) { if (r) return JSON.stringify("__cycle__"); throw new TypeError("Converting circular structure to JSON") } var s = a.push(t) - 1, u = Object.keys(t).sort(i && i(t)); for (o = "", n = 0; n < u.length; n++) { var l = u[n], c = e(t[l]); c && (o && (o += ","), o += JSON.stringify(l) + ":" + c) } return a.splice(s, 1), "{" + o + "}" } }(e) } }, 8748: e => { "use strict"; var t = /-(.)/g; e.exports = function (e) { return e.replace(t, (function (e, t) { return t.toUpperCase() })) } }, 480: (e, t, n) => { "use strict"; var r = n(8748), i = /^-ms-/; e.exports = function (e) { return r(e.replace(i, "ms-")) } }, 9395: e => { "use strict"; function t(e) { return function () { return e } } var n = function () { }; n.thatReturns = t, n.thatReturnsFalse = t(!1), n.thatReturnsTrue = t(!0), n.thatReturnsNull = t(null), n.thatReturnsThis = function () { return this }, n.thatReturnsArgument = function (e) { return e }, e.exports = n }, 3998: e => { "use strict"; var t = /([A-Z])/g; e.exports = function (e) { return e.replace(t, "-$1").toLowerCase() } }, 1254: (e, t, n) => { "use strict"; var r = n(3998), i = /^ms-/; e.exports = function (e) { return r(e).replace(i, "-ms-") } }, 4793: e => { "use strict"; e.exports = function (e) { var t = {}; return function (n) { return t.hasOwnProperty(n) || (t[n] = e.call(this, n)), t[n] } } }, 4594: (e, t, n) => { "use strict"; var r = n(9395); e.exports = r }, 2208: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }); var n = { animationIterationCount: !0, borderImageOutset: !0, borderImageSlice: !0, borderImageWidth: !0, boxFlex: !0, boxFlexGroup: !0, boxOrdinalGroup: !0, columnCount: !0, flex: !0, flexGrow: !0, flexPositive: !0, flexShrink: !0, flexNegative: !0, flexOrder: !0, gridRow: !0, gridRowStart: !0, gridRowEnd: !0, gridColumn: !0, gridColumnStart: !0, gridColumnEnd: !0, fontWeight: !0, lineClamp: !0, lineHeight: !0, opacity: !0, order: !0, orphans: !0, tabSize: !0, widows: !0, zIndex: !0, zoom: !0, fillOpacity: !0, floodOpacity: !0, stopOpacity: !0, strokeDasharray: !0, strokeDashoffset: !0, strokeMiterlimit: !0, strokeOpacity: !0, strokeWidth: !0 }; var r = ["Webkit", "ms", "Moz", "O"]; Object.keys(n).forEach((function (e) { r.forEach((function (t) { n[function (e, t) { return e + t.charAt(0).toUpperCase() + t.substring(1) }(t, e)] = n[e] })) })); var i = { isUnitlessNumber: n, shorthandPropertyExpansions: { background: { backgroundAttachment: !0, backgroundColor: !0, backgroundImage: !0, backgroundPositionX: !0, backgroundPositionY: !0, backgroundRepeat: !0 }, backgroundPosition: { backgroundPositionX: !0, backgroundPositionY: !0 }, border: { borderWidth: !0, borderStyle: !0, borderColor: !0 }, borderBottom: { borderBottomWidth: !0, borderBottomStyle: !0, borderBottomColor: !0 }, borderLeft: { borderLeftWidth: !0, borderLeftStyle: !0, borderLeftColor: !0 }, borderRight: { borderRightWidth: !0, borderRightStyle: !0, borderRightColor: !0 }, borderTop: { borderTopWidth: !0, borderTopStyle: !0, borderTopColor: !0 }, font: { fontStyle: !0, fontVariant: !0, fontWeight: !0, fontSize: !0, lineHeight: !0, fontFamily: !0 }, outline: { outlineWidth: !0, outlineStyle: !0, outlineColor: !0 } } }; t.default = i }, 1104: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }); var r = i(n(2208)); i(n(4594)); function i(e) { return e && e.__esModule ? e : { default: e } } var a = r.default.isUnitlessNumber; t.default = function (e, t, n) { return null == t || "boolean" == typeof t || "" === t ? "" : isNaN(t) || 0 === t || a.hasOwnProperty(e) && a[e] ? "" + t : ("string" == typeof t && (t = t.trim()), t + "px") } }, 6050: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.processStyleName = void 0, t.createMarkupForStyles = function (e, t) { var n = ""; for (var i in e) { var a = 0 === i.indexOf("--"); if (e.hasOwnProperty(i) && "label" !== i) { var o = e[i]; 0, null != o && (a ? n += i + ":" + o + ";" : (n += s(i) + ":", n += (0, r.default)(i, o, t) + ";")) } } return n || null }; o(n(480)); var r = o(n(1104)), i = o(n(1254)), a = o(n(4793)); o(n(4594)); function o(e) { return e && e.__esModule ? e : { default: e } } var s = t.processStyleName = (0, a.default)(i.default) }, 5960: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }); var n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) { return typeof e } : function (e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e }; function r(e) { if (function (e) { return null == e || !1 === e || "object" === (void 0 === e ? "undefined" : n(e)) && 0 === Object.keys(e).length }(e)) return null; if ("object" !== (void 0 === e ? "undefined" : n(e))) return e; for (var t = {}, r = Object.keys(e), a = !1, o = 0; o < r.length; o++) { var s = e[r[o]], u = i(s); null !== u && u === s || (a = !0), null !== u && (t[r[o]] = u) } return 0 === Object.keys(t).length ? null : a ? t : e } function i(e) { return Array.isArray(e) ? (n = !1, a = [], (t = e).forEach((function (e) { var t = i(e); null !== t && t === e || (n = !0), null !== t && a.push(t) })), 0 == a.length ? null : n ? a : t) : r(e); var t, n, a } t.default = i }, 2493: (e, t) => { "use strict"; function n(e, t) { return e.charCodeAt(t++) + (e.charCodeAt(t++) << 8) + (e.charCodeAt(t++) << 16) + (e.charCodeAt(t) << 24) } function r(e, t) { return e.charCodeAt(t++) + (e.charCodeAt(t++) << 8) } function i(e, t) { return (65535 & (e |= 0)) * (t |= 0) + (((e >>> 16) * t & 65535) << 16) | 0 } Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { var a = 1540483477, o = t ^ e.length, s = e.length, u = 0; for (; s >= 4;) { var l = n(e, u); l = i(l, a), l = i(l ^= l >>> 24, a), o = i(o, a), o ^= l, u += 4, s -= 4 } switch (s) { case 3: o ^= r(e, u), o = i(o ^= e.charCodeAt(u + 2) << 16, a); break; case 2: o = i(o ^= r(e, u), a); break; case 1: o = i(o ^= e.charCodeAt(u), a) }return o = i(o ^= o >>> 13, a), (o ^= o >>> 15) >>> 0 } }, 8205: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.compose = t.merge = t.$ = t.style = t.presets = t.keyframes = t.fontFace = t.insertGlobal = t.insertRule = t.plugins = t.styleSheet = void 0, t.speedy = function (e) { return h.speedy(e) }, t.simulations = function () { var e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; g = !!e }, t.simulate = function () { for (var e = arguments.length, t = Array(e), n = 0; n < e; n++)t[n] = arguments[n]; if (!(t = (0, o.default)(t))) return {}; if (!g) return y || (console.warn("can't simulate without once calling simulations(true)"), y = !0), f || p || b || (console.warn("don't use simulation outside dev"), b = !0), {}; return t.reduce((function (e, t) { return e["data-simulate-" + x(t)] = "", e }), {}) }, t.cssLabels = function (e) { v = !!e }, t.isLikeRule = k, t.idFor = S, t.css = H, t.rehydrate = function (e) { (0, r.default)(I, e.reduce((function (e, t) { return e[t] = !0, e }), {})) }, t.flush = function () { I = h.inserted = {}, M = h.registered = {}, D = {}, h.flush(), h.inject() }, t.select = Y, t.parent = function (e) { for (var t = arguments.length, n = Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return H(c({}, e + " &", n)) }, t.media = function (e) { for (var t = arguments.length, n = Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return H(c({}, "@media " + e, n)) }, t.pseudo = X, t.active = function (e) { return X(":active", e) }, t.any = function (e) { return X(":any", e) }, t.checked = function (e) { return X(":checked", e) }, t.disabled = function (e) { return X(":disabled", e) }, t.empty = function (e) { return X(":empty", e) }, t.enabled = function (e) { return X(":enabled", e) }, t._default = function (e) { return X(":default", e) }, t.first = function (e) { return X(":first", e) }, t.firstChild = function (e) { return X(":first-child", e) }, t.firstOfType = function (e) { return X(":first-of-type", e) }, t.fullscreen = function (e) { return X(":fullscreen", e) }, t.focus = function (e) { return X(":focus", e) }, t.hover = function (e) { return X(":hover", e) }, t.indeterminate = function (e) { return X(":indeterminate", e) }, t.inRange = function (e) { return X(":in-range", e) }, t.invalid = function (e) { return X(":invalid", e) }, t.lastChild = function (e) { return X(":last-child", e) }, t.lastOfType = function (e) { return X(":last-of-type", e) }, t.left = function (e) { return X(":left", e) }, t.link = function (e) { return X(":link", e) }, t.onlyChild = function (e) { return X(":only-child", e) }, t.onlyOfType = function (e) { return X(":only-of-type", e) }, t.optional = function (e) { return X(":optional", e) }, t.outOfRange = function (e) { return X(":out-of-range", e) }, t.readOnly = function (e) { return X(":read-only", e) }, t.readWrite = function (e) { return X(":read-write", e) }, t.required = function (e) { return X(":required", e) }, t.right = function (e) { return X(":right", e) }, t.root = function (e) { return X(":root", e) }, t.scope = function (e) { return X(":scope", e) }, t.target = function (e) { return X(":target", e) }, t.valid = function (e) { return X(":valid", e) }, t.visited = function (e) { return X(":visited", e) }, t.dir = function (e, t) { return X(":dir(" + e + ")", t) }, t.lang = function (e, t) { return X(":lang(" + e + ")", t) }, t.not = function (e, t) { var n = e.split(",").map((function (e) { return e.trim() })).map((function (e) { return ":not(" + e + ")" })); if (1 === n.length) return X(":not(" + e + ")", t); return Y(n.join(""), t) }, t.nthChild = function (e, t) { return X(":nth-child(" + e + ")", t) }, t.nthLastChild = function (e, t) { return X(":nth-last-child(" + e + ")", t) }, t.nthLastOfType = function (e, t) { return X(":nth-last-of-type(" + e + ")", t) }, t.nthOfType = function (e, t) { return X(":nth-of-type(" + e + ")", t) }, t.after = function (e) { return X("::after", e) }, t.before = function (e) { return X("::before", e) }, t.firstLetter = function (e) { return X("::first-letter", e) }, t.firstLine = function (e) { return X("::first-line", e) }, t.selection = function (e) { return X("::selection", e) }, t.backdrop = function (e) { return X("::backdrop", e) }, t.placeholder = function (e) { return H({ "::placeholder": e }) }, t.cssFor = function () { for (var e = arguments.length, t = Array(e), n = 0; n < e; n++)t[n] = arguments[n]; return (t = (0, o.default)(t)) ? t.map((function (e) { var t = { label: [] }; return B(t, { src: e }), N(w(t), E(t)).join("") })).join("") : "" }, t.attribsFor = function () { for (var e = arguments.length, t = Array(e), n = 0; n < e; n++)t[n] = arguments[n]; return (t = (0, o.default)(t)) ? t.map((function (e) { S(e); var t = Object.keys(e)[0]; return t + '="' + (e[t] || "") + '"' })).join(" ") : "" }; var r = l(n(5228)), i = n(6314), a = n(6050), o = l(n(5960)), s = n(7769), u = l(n(2493)); function l(e) { return e && e.__esModule ? e : { default: e } } function c(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var h = t.styleSheet = new i.StyleSheet; h.inject(); var d = t.plugins = h.plugins = new s.PluginSet([s.prefixes, s.contentWrap, s.fallbacks]); d.media = new s.PluginSet, d.fontFace = new s.PluginSet, d.keyframes = new s.PluginSet([s.prefixes, s.fallbacks]); var f = !1, p = !1, m = "undefined" != typeof window, g = f, y = !1, b = !1; var v = f; function x(e) { var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : ""; return e.toLowerCase().replace(/[^a-z0-9]/g, t) } function w(e) { var t = JSON.stringify(e), n = (0, u.default)(t).toString(36); return e.label && e.label.length > 0 && f ? x(e.label.join("."), "-") + "-" + n : n } function k(e) { var t = Object.keys(e).filter((function (e) { return "toString" !== e })); return 1 === t.length && !!/data\-css\-([a-zA-Z0-9\-_]+)/.exec(t[0]) } function S(e) { var t = Object.keys(e).filter((function (e) { return "toString" !== e })); if (1 !== t.length) throw new Error("not a rule"); var n = /data\-css\-([a-zA-Z0-9\-_]+)/.exec(t[0]); if (!n) throw new Error("not a rule"); return n[1] } var _ = /[(),]|"(?:\\.|[^"\n])*"|'(?:\\.|[^'\n])*'|\/\*[\s\S]*?\*\//g; function C(e) { if (-1 === e.indexOf(",")) return [e]; for (var t, n = [], r = [], i = 0; t = _.exec(e);)switch (t[0]) { case "(": i++; break; case ")": i--; break; case ",": if (i) break; n.push(t.index) }for (t = n.length; t--;)r.unshift(e.slice(n[t] + 1)), e = e.slice(0, n[t]); return r.unshift(e), r } function A(e, t) { if (!e) return t.replace(/\&/g, ""); if (!t) return ".css-" + e + ",[data-css-" + e + "]"; var n = C(t).map((function (t) { return t.indexOf("&") >= 0 ? [t.replace(/\&/gm, ".css-" + e), t.replace(/\&/gm, "[data-css-" + e + "]")].join(",") : ".css-" + e + t + ",[data-css-" + e + "]" + t })).join(","); return g && /^\&\:/.exec(t) && !/\s/.exec(t) && (n += ",.css-" + e + "[data-simulate-" + x(t) + "],[data-css-" + e + "][data-simulate-" + x(t) + "]"), n } function T(e) { var t = e.selector, n = e.style, r = d.transform({ selector: t, style: n }); return r.selector + "{" + (0, a.createMarkupForStyles)(r.style) + "}" } function E(e) { var t = void 0, n = void 0, r = void 0, i = void 0; return Object.keys(e).forEach((function (a) { a.indexOf("&") >= 0 ? (n = n || {})[a] = e[a] : 0 === a.indexOf("@media") ? (r = r || {})[a] = E(e[a]) : 0 === a.indexOf("@supports") ? (i = i || {})[a] = E(e[a]) : "label" === a ? e.label.length > 0 && ((t = t || {}).label = v ? e.label.join(".") : "") : (t = t || {})[a] = e[a] })), { plain: t, selects: n, medias: r, supports: i } } function N(e, t) { var n = [], r = t.plain, i = t.selects, a = t.medias, o = t.supports; return r && n.push(T({ style: r, selector: A(e) })), i && Object.keys(i).forEach((function (t) { return n.push(T({ style: i[t], selector: A(e, t) })) })), a && Object.keys(a).forEach((function (t) { return n.push(t + "{" + N(e, a[t]).join("") + "}") })), o && Object.keys(o).forEach((function (t) { return n.push(t + "{" + N(e, o[t]).join("") + "}") })), n } var I = h.inserted = {}; var M = h.registered = {}; function F(e) { M[e.id] || (M[e.id] = e) } var D = {}; function $(e) { if (F(e), function (e) { if (!I[e.id]) { I[e.id] = !0; var t = E(e.style), n = N(e.id, t); I[e.id] = !!m || n, n.forEach((function (e) { return h.insert(e) })) } }(e), D[e.id]) return D[e.id]; var t = c({}, "data-css-" + e.id, v && e.label || ""); return Object.defineProperty(t, "toString", { enumerable: !1, value: function () { return "css-" + e.id } }), D[e.id] = t, t } function R(e, t) { var n = C(e).map((function (e) { return e.indexOf("&") >= 0 ? e : "&" + e })), r = C(t).map((function (e) { return e.indexOf("&") >= 0 ? e : "&" + e })); return r.reduce((function (e, t) { return e.concat(n.map((function (e) { return t.replace(/\&/g, e) }))) }), []).join(",") } function O(e, t) { return e ? "@supports " + e.substring(9) + " and " + t.substring(9) : t } function z(e) { for (var t = [], n = 0; n < e.length; n++)t = Array.isArray(e[n]) ? t.concat(z(e[n])) : t.concat(e[n]); return t } var P = { "::placeholder": ["::-webkit-input-placeholder", "::-moz-placeholder", "::-ms-input-placeholder"], ":fullscreen": [":-webkit-full-screen", ":-moz-full-screen", ":-ms-fullscreen"] }; function B(e, t) { var n = t.selector, r = void 0 === n ? "" : n, i = t.mq, a = void 0 === i ? "" : i, s = t.supp, u = void 0 === s ? "" : s, l = t.src, c = void 0 === l ? {} : l; Array.isArray(c) || (c = [c]), (c = z(c)).forEach((function (t) { if (k(t)) { var n = function (e) { if (k(e)) { var t = M[S(e)]; if (null == t) throw new Error("[glamor] an unexpected rule cache miss occurred. This is probably a sign of multiple glamor instances in your app. See https://github.com/threepointone/glamor/issues/79"); return t } return e }(t); if ("css" !== n.type) throw new Error("cannot merge this rule"); t = n.style } (t = (0, o.default)(t)) && t.composes && B(e, { selector: r, mq: a, supp: u, src: t.composes }), Object.keys(t || {}).forEach((function (n) { if (function (e) { for (var t = [":", ".", "[", ">", " "], n = !1, r = e.charAt(0), i = 0; i < t.length; i++)if (r === t[i]) { n = !0; break } return n || e.indexOf("&") >= 0 }(n)) P[n] && P[n].forEach((function (i) { return B(e, { selector: R(r, i), mq: a, supp: u, src: t[n] }) })), B(e, { selector: R(r, n), mq: a, supp: u, src: t[n] }); else if (function (e) { return 0 === e.indexOf("@media") }(n)) B(e, { selector: r, mq: (o = a, s = n, o ? "@media " + o.substring(6) + " and " + s.substring(6) : s), supp: u, src: t[n] }); else if (function (e) { return 0 === e.indexOf("@supports") }(n)) B(e, { selector: r, mq: a, supp: O(u, n), src: t[n] }); else if ("composes" === n); else { var i = e; u && (i[u] = i[u] || {}, i = i[u]), a && (i[a] = i[a] || {}, i = i[a]), r && (i[r] = i[r] || {}, i = i[r]), "label" === n ? v && (e.label = e.label.concat(t.label)) : i[n] = t[n] } var o, s })) })) } function L(e) { var t = { label: [] }; return B(t, { src: e }), $({ id: w(t), style: t, label: v ? t.label.join(".") : "", type: "css" }) } var j = {}; Object.defineProperty(j, "toString", { enumerable: !1, value: function () { return "css-nil" } }); var U = "undefined" != typeof WeakMap ? [j, new WeakMap, new WeakMap, new WeakMap] : [j], W = !1; var V, G = "undefined" != typeof WeakMap ? (V = L, function (e) { if (U[e.length]) { for (var t = U[e.length], n = 0; n < e.length - 1;)t.has(e[n]) || t.set(e[n], new WeakMap), t = t.get(e[n]), n++; if (t.has(e[e.length - 1])) { var r = t.get(e[n]); if (M[r.toString().substring(4)]) return r } } var i = V(e); if (U[e.length]) { for (var a = 0, o = U[e.length]; a < e.length - 1;)o = o.get(e[a]), a++; try { o.set(e[a], i) } catch (t) { var s; f && !W && (W = !0, (s = console).warn.apply(s, ["failed setting the WeakMap cache for args:"].concat(function (e) { if (Array.isArray(e)) { for (var t = 0, n = Array(e.length); t < e.length; t++)n[t] = e[t]; return n } return Array.from(e) }(e))), console.warn("this should NOT happen, please file a bug on the github repo.")) } } return i }) : L; function H() { for (var e = arguments.length, t = Array(e), n = 0; n < e; n++)t[n] = arguments[n]; if (t[0] && t[0].length && t[0].raw) throw new Error("you forgot to include glamor/babel in your babel plugins."); return (t = (0, o.default)(t)) ? G(t) : j } H.insert = function (e) { var t = { id: w(e), css: e, type: "raw" }; F(t), I[t.id] || (h.insert(t.css), I[t.id] = !!m || [t.css]) }; t.insertRule = H.insert; H.global = function (e, t) { if (t = (0, o.default)(t)) return H.insert(T({ selector: e, style: t })) }; t.insertGlobal = H.global; H.keyframes = function (e, t) { t || (t = e, e = "animation"); var n = { id: w({ name: e, kfs: t = (0, o.default)(t) || {} }), type: "keyframes", name: e, keyframes: t }; return F(n), function (e) { if (!I[e.id]) { var t = Object.keys(e.keyframes).map((function (t) { var n = d.keyframes.transform({ id: e.id, name: t, style: e.keyframes[t] }); return n.name + "{" + (0, a.createMarkupForStyles)(n.style) + "}" })).join(""), n = ["-webkit-", "-moz-", "-o-", ""].map((function (n) { return "@" + n + "keyframes " + e.name + "_" + e.id + "{" + t + "}" })); n.forEach((function (e) { return h.insert(e) })), I[e.id] = !!m || n } }(n), e + "_" + n.id }, H.fontFace = function (e) { var t = { id: w(e = (0, o.default)(e)), type: "font-face", font: e }; return F(t), function (e) { if (!I[e.id]) { var t = "@font-face{" + (0, a.createMarkupForStyles)(e.font) + "}"; h.insert(t), I[e.id] = !!m || [t] } }(t), e.fontFamily }; t.fontFace = H.fontFace, t.keyframes = H.keyframes; t.presets = { mobile: "(min-width: 400px)", Mobile: "@media (min-width: 400px)", phablet: "(min-width: 550px)", Phablet: "@media (min-width: 550px)", tablet: "(min-width: 750px)", Tablet: "@media (min-width: 750px)", desktop: "(min-width: 1000px)", Desktop: "@media (min-width: 1000px)", hd: "(min-width: 1200px)", Hd: "@media (min-width: 1200px)" }; var q = t.style = H; function Y(e) { for (var t = arguments.length, n = Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return e ? H(c({}, e, n)) : q(n) } t.$ = Y; t.merge = H, t.compose = H; function X(e) { for (var t = arguments.length, n = Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return H(c({}, e, n)) } }, 7769: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }); var r = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }; t.PluginSet = u, t.fallbacks = function (e) { if (Object.keys(e.style).map((function (t) { return Array.isArray(e.style[t]) })).indexOf(!0) >= 0) { var t = e.style, n = Object.keys(t).reduce((function (e, n) { return e[n] = Array.isArray(t[n]) ? t[n].join("; " + (0, a.processStyleName)(n) + ": ") : t[n], e }), {}); return (0, i.default)({}, e, { style: n }) } return e }, t.contentWrap = function (e) { if (e.style.content) { var t = e.style.content; return l.indexOf(t) >= 0 || /^(attr|calc|counters?|url)\(/.test(t) ? e : t.charAt(0) !== t.charAt(t.length - 1) || '"' !== t.charAt(0) && "'" !== t.charAt(0) ? r({}, e, { style: r({}, e.style, { content: '"' + t + '"' }) }) : e } return e }, t.prefixes = function (e) { return (0, i.default)({}, e, { style: (0, o.default)(r({}, e.style)) }) }; var i = s(n(5228)), a = n(6050), o = s(n(9654)); function s(e) { return e && e.__esModule ? e : { default: e } } function u(e) { this.fns = e || [] } (0, i.default)(u.prototype, { add: function () { for (var e = this, t = arguments.length, n = Array(t), r = 0; r < t; r++)n[r] = arguments[r]; n.forEach((function (t) { e.fns.indexOf(t) >= 0 || (e.fns = [t].concat(e.fns)) })) }, remove: function (e) { this.fns = this.fns.filter((function (t) { return t !== e })) }, clear: function () { this.fns = [] }, transform: function (e) { return this.fns.reduce((function (e, t) { return t(e) }), e) } }); var l = ["normal", "none", "counter", "open-quote", "close-quote", "no-open-quote", "no-close-quote", "initial", "inherit"] }, 9654: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e) { for (var t in e) { var n = e[t], r = (0, a.default)(y, t, n, e, b); r && (e[t] = r), (0, i.default)(b, t, e) } return e }; var r = g(n(113)), i = g(n(4397)), a = g(n(6127)), o = g(n(1244)), s = g(n(3038)), u = g(n(436)), l = g(n(1421)), c = g(n(807)), h = g(n(5086)), d = g(n(7637)), f = g(n(8877)), p = g(n(4796)), m = g(n(5309)); function g(e) { return e && e.__esModule ? e : { default: e } } var y = [s.default, o.default, u.default, c.default, h.default, d.default, f.default, p.default, m.default, l.default], b = r.default.prefixMap }, 6314: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.StyleSheet = f; var r, i = n(5228), a = (r = i) && r.__esModule ? r : { default: r }; function o(e) { return e[e.length - 1] } function s(e) { if (e.sheet) return e.sheet; for (var t = 0; t < document.styleSheets.length; t++)if (document.styleSheets[t].ownerNode === e) return document.styleSheets[t] } var u = "undefined" != typeof window, l = !1, c = !1, h = function () { if (u) { var e = document.createElement("div"); return e.innerHTML = "\x3c!--[if lt IE 10]> 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = e.speedy, n = void 0 === t ? !l && !c : t, r = e.maxLength, i = void 0 === r ? u && h ? 4e3 : 65e3 : r; this.isSpeedy = n, this.sheet = void 0, this.tags = [], this.maxLength = i, this.ctr = 0 } (0, a.default)(f.prototype, { getSheet: function () { return s(o(this.tags)) }, inject: function () { var e = this; if (this.injected) throw new Error("already injected stylesheet!"); u ? this.tags[0] = d() : this.sheet = { cssRules: [], insertRule: function (t) { e.sheet.cssRules.push({ cssText: t }) } }, this.injected = !0 }, speedy: function (e) { if (0 !== this.ctr) throw new Error("cannot change speedy mode after inserting any rule to sheet. Either call speedy(" + e + ") earlier in your app, or call flush() before speedy(" + e + ")"); this.isSpeedy = !!e }, _insert: function (e) { try { var t = this.getSheet(); t.insertRule(e, -1 !== e.indexOf("@import") ? 0 : t.cssRules.length) } catch (t) { l && console.warn("whoops, illegal rule inserted", e) } }, insert: function (e) { if (u) if (this.isSpeedy && this.getSheet().insertRule) this._insert(e); else if (-1 !== e.indexOf("@import")) { var t = o(this.tags); t.insertBefore(document.createTextNode(e), t.firstChild) } else o(this.tags).appendChild(document.createTextNode(e)); else this.sheet.insertRule(e, -1 !== e.indexOf("@import") ? 0 : this.sheet.cssRules.length); return this.ctr++, u && this.ctr % this.maxLength == 0 && this.tags.push(d()), this.ctr - 1 }, delete: function (e) { return this.replace(e, "") }, flush: function () { u ? (this.tags.forEach((function (e) { return e.parentNode.removeChild(e) })), this.tags = [], this.sheet = null, this.ctr = 0) : this.sheet.cssRules = [], this.injected = !1 }, rules: function () { if (!u) return this.sheet.cssRules; var e = []; return this.tags.forEach((function (t) { return e.splice.apply(e, [e.length, 0].concat(function (e) { if (Array.isArray(e)) { for (var t = 0, n = Array(e.length); t < e.length; t++)n[t] = e[t]; return n } return Array.from(e) }(Array.from(s(t).cssRules)))) })), e } }) }, 8066: (e, t, n) => { "use strict"; n.r(t), n.d(t, { default: () => s }); var r = /[A-Z]/g, i = /^ms-/, a = {}; function o(e) { return "-" + e.toLowerCase() } const s = function (e) { if (a.hasOwnProperty(e)) return a[e]; var t = e.replace(r, o); return a[e] = i.test(t) ? "-" + t : t } }, 3038: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("string" == typeof t && !(0, a.default)(t) && t.indexOf("cross-fade(") > -1) return o.map((function (e) { return t.replace(/cross-fade\(/g, e + "cross-fade(") })) }; var r, i = n(4014), a = (r = i) && r.__esModule ? r : { default: r }; var o = ["-webkit-", ""]; e.exports = t.default }, 1244: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("cursor" === e && r.hasOwnProperty(t)) return n.map((function (e) { return e + t })) }; var n = ["-webkit-", "-moz-", ""], r = { "zoom-in": !0, "zoom-out": !0, grab: !0, grabbing: !0 }; e.exports = t.default }, 436: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("string" == typeof t && !(0, a.default)(t) && t.indexOf("filter(") > -1) return o.map((function (e) { return t.replace(/filter\(/g, e + "filter(") })) }; var r, i = n(4014), a = (r = i) && r.__esModule ? r : { default: r }; var o = ["-webkit-", ""]; e.exports = t.default }, 1421: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("display" === e && n.hasOwnProperty(t)) return n[t] }; var n = { flex: ["-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex", "flex"], "inline-flex": ["-webkit-inline-box", "-moz-inline-box", "-ms-inline-flexbox", "-webkit-inline-flex", "inline-flex"] }; e.exports = t.default }, 807: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t, i) { "flexDirection" === e && "string" == typeof t && (t.indexOf("column") > -1 ? i.WebkitBoxOrient = "vertical" : i.WebkitBoxOrient = "horizontal", t.indexOf("reverse") > -1 ? i.WebkitBoxDirection = "reverse" : i.WebkitBoxDirection = "normal"); r.hasOwnProperty(e) && (i[r[e]] = n[t] || t) }; var n = { "space-around": "justify", "space-between": "justify", "flex-start": "start", "flex-end": "end", "wrap-reverse": "multiple", wrap: "multiple" }, r = { alignItems: "WebkitBoxAlign", justifyContent: "WebkitBoxPack", flexWrap: "WebkitBoxLines" }; e.exports = t.default }, 5086: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("string" == typeof t && !(0, a.default)(t) && s.test(t)) return o.map((function (e) { return e + t })) }; var r, i = n(4014), a = (r = i) && r.__esModule ? r : { default: r }; var o = ["-webkit-", "-moz-", ""], s = /linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/; e.exports = t.default }, 7637: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("string" == typeof t && !(0, a.default)(t) && t.indexOf("image-set(") > -1) return o.map((function (e) { return t.replace(/image-set\(/g, e + "image-set(") })) }; var r, i = n(4014), a = (r = i) && r.__esModule ? r : { default: r }; var o = ["-webkit-", ""]; e.exports = t.default }, 8877: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if ("position" === e && "sticky" === t) return ["-webkit-sticky", "sticky"] }, e.exports = t.default }, 4796: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t) { if (r.hasOwnProperty(e) && i.hasOwnProperty(t)) return n.map((function (e) { return e + t })) }; var n = ["-webkit-", "-moz-", ""], r = { maxHeight: !0, maxWidth: !0, width: !0, height: !0, columnWidth: !0, minWidth: !0, minHeight: !0 }, i = { "min-content": !0, "max-content": !0, "fill-available": !0, "fit-content": !0, "contain-floats": !0 }; e.exports = t.default }, 5309: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t, n, o) { if ("string" == typeof t && s.hasOwnProperty(e)) { var l = function (e, t) { if ((0, i.default)(e)) return e; for (var n = e.split(/,(?![^()]*(?:\([^()]*\))?\))/g), a = 0, o = n.length; a < o; ++a) { var s = n[a], l = [s]; for (var c in t) { var h = (0, r.default)(c); if (s.indexOf(h) > -1 && "order" !== h) for (var d = t[c], f = 0, p = d.length; f < p; ++f)l.unshift(s.replace(h, u[d[f]] + h)) } n[a] = l.join(",") } return n.join(",") }(t, o), c = l.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter((function (e) { return !/-moz-|-ms-/.test(e) })).join(","); if (e.indexOf("Webkit") > -1) return c; var h = l.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter((function (e) { return !/-webkit-|-ms-/.test(e) })).join(","); return e.indexOf("Moz") > -1 ? h : (n["Webkit" + (0, a.default)(e)] = c, n["Moz" + (0, a.default)(e)] = h, l) } }; var r = o(n(5721)), i = o(n(4014)), a = o(n(7479)); function o(e) { return e && e.__esModule ? e : { default: e } } var s = { transition: !0, transitionProperty: !0, WebkitTransition: !0, WebkitTransitionProperty: !0, MozTransition: !0, MozTransitionProperty: !0 }, u = { Webkit: "-webkit-", Moz: "-moz-", ms: "-ms-" }; e.exports = t.default }, 113: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }); var n = ["Webkit"], r = ["Moz"], i = ["ms"], a = ["Webkit", "Moz"], o = ["Webkit", "ms"], s = ["Webkit", "Moz", "ms"]; t.default = { plugins: [], prefixMap: { appearance: a, userSelect: s, textEmphasisPosition: n, textEmphasis: n, textEmphasisStyle: n, textEmphasisColor: n, boxDecorationBreak: n, clipPath: n, maskImage: n, maskMode: n, maskRepeat: n, maskPosition: n, maskClip: n, maskOrigin: n, maskSize: n, maskComposite: n, mask: n, maskBorderSource: n, maskBorderMode: n, maskBorderSlice: n, maskBorderWidth: n, maskBorderOutset: n, maskBorderRepeat: n, maskBorder: n, maskType: n, textDecorationStyle: n, textDecorationSkip: n, textDecorationLine: n, textDecorationColor: n, filter: n, fontFeatureSettings: n, breakAfter: s, breakBefore: s, breakInside: s, columnCount: a, columnFill: a, columnGap: a, columnRule: a, columnRuleColor: a, columnRuleStyle: a, columnRuleWidth: a, columns: a, columnSpan: a, columnWidth: a, writingMode: o, flex: n, flexBasis: n, flexDirection: n, flexGrow: n, flexFlow: n, flexShrink: n, flexWrap: n, alignContent: n, alignItems: n, alignSelf: n, justifyContent: n, order: n, transform: n, transformOrigin: n, transformOriginX: n, transformOriginY: n, backfaceVisibility: n, perspective: n, perspectiveOrigin: n, transformStyle: n, transformOriginZ: n, animation: n, animationDelay: n, animationDirection: n, animationFillMode: n, animationDuration: n, animationIterationCount: n, animationName: n, animationPlayState: n, animationTimingFunction: n, backdropFilter: n, fontKerning: n, scrollSnapType: o, scrollSnapPointsX: o, scrollSnapPointsY: o, scrollSnapDestination: o, scrollSnapCoordinate: o, shapeImageThreshold: n, shapeImageMargin: n, shapeImageOutside: n, hyphens: s, flowInto: o, flowFrom: o, regionFragment: o, textAlignLast: r, tabSize: r, wrapFlow: i, wrapThrough: i, wrapMargin: i, gridTemplateColumns: i, gridTemplateRows: i, gridTemplateAreas: i, gridTemplate: i, gridAutoColumns: i, gridAutoRows: i, gridAutoFlow: i, grid: i, gridRowStart: i, gridColumnStart: i, gridRowEnd: i, gridRow: i, gridColumn: i, gridColumnEnd: i, gridColumnGap: i, gridRowGap: i, gridArea: i, gridGap: i, textSizeAdjust: o, borderImage: n, borderImageOutset: n, borderImageRepeat: n, borderImageSlice: n, borderImageSource: n, borderImageWidth: n, transitionDelay: n, transitionDuration: n, transitionProperty: n, transitionTimingFunction: n } }, e.exports = t.default }, 7479: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e) { return e.charAt(0).toUpperCase() + e.slice(1) }, e.exports = t.default }, 4397: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t, n) { if (e.hasOwnProperty(t)) for (var r = e[t], i = 0, o = r.length; i < o; ++i)n[r[i] + (0, a.default)(t)] = n[t] }; var r, i = n(7479), a = (r = i) && r.__esModule ? r : { default: r }; e.exports = t.default }, 6127: (e, t) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function (e, t, n, r, i) { for (var a = 0, o = e.length; a < o; ++a) { var s = e[a](t, n, r, i); if (s) return s } }, e.exports = t.default }, 8570: e => { e.exports = n; var t = null; try { t = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports } catch (e) { } function n(e, t, n) { this.low = 0 | e, this.high = 0 | t, this.unsigned = !!n } function r(e) { return !0 === (e && e.__isLong__) } n.prototype.__isLong__, Object.defineProperty(n.prototype, "__isLong__", { value: !0 }), n.isLong = r; var i = {}, a = {}; function o(e, t) { var n, r, o; return t ? (o = 0 <= (e >>>= 0) && e < 256) && (r = a[e]) ? r : (n = u(e, (0 | e) < 0 ? -1 : 0, !0), o && (a[e] = n), n) : (o = -128 <= (e |= 0) && e < 128) && (r = i[e]) ? r : (n = u(e, e < 0 ? -1 : 0, !1), o && (i[e] = n), n) } function s(e, t) { if (isNaN(e)) return t ? y : g; if (t) { if (e < 0) return y; if (e >= f) return k } else { if (e <= -p) return S; if (e + 1 >= p) return w } return e < 0 ? s(-e, t).neg() : u(e % d | 0, e / d | 0, t) } function u(e, t, r) { return new n(e, t, r) } n.fromInt = o, n.fromNumber = s, n.fromBits = u; var l = Math.pow; function c(e, t, n) { if (0 === e.length) throw Error("empty string"); if ("NaN" === e || "Infinity" === e || "+Infinity" === e || "-Infinity" === e) return g; if ("number" == typeof t ? (n = t, t = !1) : t = !!t, (n = n || 10) < 2 || 36 < n) throw RangeError("radix"); var r; if ((r = e.indexOf("-")) > 0) throw Error("interior hyphen"); if (0 === r) return c(e.substring(1), t, n).neg(); for (var i = s(l(n, 8)), a = g, o = 0; o < e.length; o += 8) { var u = Math.min(8, e.length - o), h = parseInt(e.substring(o, o + u), n); if (u < 8) { var d = s(l(n, u)); a = a.mul(d).add(s(h)) } else a = (a = a.mul(i)).add(s(h)) } return a.unsigned = t, a } function h(e, t) { return "number" == typeof e ? s(e, t) : "string" == typeof e ? c(e, t) : u(e.low, e.high, "boolean" == typeof t ? t : e.unsigned) } n.fromString = c, n.fromValue = h; var d = 4294967296, f = d * d, p = f / 2, m = o(1 << 24), g = o(0); n.ZERO = g; var y = o(0, !0); n.UZERO = y; var b = o(1); n.ONE = b; var v = o(1, !0); n.UONE = v; var x = o(-1); n.NEG_ONE = x; var w = u(-1, 2147483647, !1); n.MAX_VALUE = w; var k = u(-1, -1, !0); n.MAX_UNSIGNED_VALUE = k; var S = u(0, -2147483648, !1); n.MIN_VALUE = S; var _ = n.prototype; _.toInt = function () { return this.unsigned ? this.low >>> 0 : this.low }, _.toNumber = function () { return this.unsigned ? (this.high >>> 0) * d + (this.low >>> 0) : this.high * d + (this.low >>> 0) }, _.toString = function (e) { if ((e = e || 10) < 2 || 36 < e) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) { if (this.eq(S)) { var t = s(e), n = this.div(t), r = n.mul(t).sub(this); return n.toString(e) + r.toInt().toString(e) } return "-" + this.neg().toString(e) } for (var i = s(l(e, 6), this.unsigned), a = this, o = ""; ;) { var u = a.div(i), c = (a.sub(u.mul(i)).toInt() >>> 0).toString(e); if ((a = u).isZero()) return c + o; for (; c.length < 6;)c = "0" + c; o = "" + c + o } }, _.getHighBits = function () { return this.high }, _.getHighBitsUnsigned = function () { return this.high >>> 0 }, _.getLowBits = function () { return this.low }, _.getLowBitsUnsigned = function () { return this.low >>> 0 }, _.getNumBitsAbs = function () { if (this.isNegative()) return this.eq(S) ? 64 : this.neg().getNumBitsAbs(); for (var e = 0 != this.high ? this.high : this.low, t = 31; t > 0 && !(e & 1 << t); t--); return 0 != this.high ? t + 33 : t + 1 }, _.isZero = function () { return 0 === this.high && 0 === this.low }, _.eqz = _.isZero, _.isNegative = function () { return !this.unsigned && this.high < 0 }, _.isPositive = function () { return this.unsigned || this.high >= 0 }, _.isOdd = function () { return !(1 & ~this.low) }, _.isEven = function () { return !(1 & this.low) }, _.equals = function (e) { return r(e) || (e = h(e)), (this.unsigned === e.unsigned || this.high >>> 31 != 1 || e.high >>> 31 != 1) && (this.high === e.high && this.low === e.low) }, _.eq = _.equals, _.notEquals = function (e) { return !this.eq(e) }, _.neq = _.notEquals, _.ne = _.notEquals, _.lessThan = function (e) { return this.comp(e) < 0 }, _.lt = _.lessThan, _.lessThanOrEqual = function (e) { return this.comp(e) <= 0 }, _.lte = _.lessThanOrEqual, _.le = _.lessThanOrEqual, _.greaterThan = function (e) { return this.comp(e) > 0 }, _.gt = _.greaterThan, _.greaterThanOrEqual = function (e) { return this.comp(e) >= 0 }, _.gte = _.greaterThanOrEqual, _.ge = _.greaterThanOrEqual, _.compare = function (e) { if (r(e) || (e = h(e)), this.eq(e)) return 0; var t = this.isNegative(), n = e.isNegative(); return t && !n ? -1 : !t && n ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1 }, _.comp = _.compare, _.negate = function () { return !this.unsigned && this.eq(S) ? S : this.not().add(b) }, _.neg = _.negate, _.add = function (e) { r(e) || (e = h(e)); var t = this.high >>> 16, n = 65535 & this.high, i = this.low >>> 16, a = 65535 & this.low, o = e.high >>> 16, s = 65535 & e.high, l = e.low >>> 16, c = 0, d = 0, f = 0, p = 0; return f += (p += a + (65535 & e.low)) >>> 16, d += (f += i + l) >>> 16, c += (d += n + s) >>> 16, c += t + o, u((f &= 65535) << 16 | (p &= 65535), (c &= 65535) << 16 | (d &= 65535), this.unsigned) }, _.subtract = function (e) { return r(e) || (e = h(e)), this.add(e.neg()) }, _.sub = _.subtract, _.multiply = function (e) { if (this.isZero()) return g; if (r(e) || (e = h(e)), t) return u(t.mul(this.low, this.high, e.low, e.high), t.get_high(), this.unsigned); if (e.isZero()) return g; if (this.eq(S)) return e.isOdd() ? S : g; if (e.eq(S)) return this.isOdd() ? S : g; if (this.isNegative()) return e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg(); if (e.isNegative()) return this.mul(e.neg()).neg(); if (this.lt(m) && e.lt(m)) return s(this.toNumber() * e.toNumber(), this.unsigned); var n = this.high >>> 16, i = 65535 & this.high, a = this.low >>> 16, o = 65535 & this.low, l = e.high >>> 16, c = 65535 & e.high, d = e.low >>> 16, f = 65535 & e.low, p = 0, y = 0, b = 0, v = 0; return b += (v += o * f) >>> 16, y += (b += a * f) >>> 16, b &= 65535, y += (b += o * d) >>> 16, p += (y += i * f) >>> 16, y &= 65535, p += (y += a * d) >>> 16, y &= 65535, p += (y += o * c) >>> 16, p += n * f + i * d + a * c + o * l, u((b &= 65535) << 16 | (v &= 65535), (p &= 65535) << 16 | (y &= 65535), this.unsigned) }, _.mul = _.multiply, _.divide = function (e) { if (r(e) || (e = h(e)), e.isZero()) throw Error("division by zero"); var n, i, a; if (t) return this.unsigned || -2147483648 !== this.high || -1 !== e.low || -1 !== e.high ? u((this.unsigned ? t.div_u : t.div_s)(this.low, this.high, e.low, e.high), t.get_high(), this.unsigned) : this; if (this.isZero()) return this.unsigned ? y : g; if (this.unsigned) { if (e.unsigned || (e = e.toUnsigned()), e.gt(this)) return y; if (e.gt(this.shru(1))) return v; a = y } else { if (this.eq(S)) return e.eq(b) || e.eq(x) ? S : e.eq(S) ? b : (n = this.shr(1).div(e).shl(1)).eq(g) ? e.isNegative() ? b : x : (i = this.sub(e.mul(n)), a = n.add(i.div(e))); if (e.eq(S)) return this.unsigned ? y : g; if (this.isNegative()) return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg(); if (e.isNegative()) return this.div(e.neg()).neg(); a = g } for (i = this; i.gte(e);) { n = Math.max(1, Math.floor(i.toNumber() / e.toNumber())); for (var o = Math.ceil(Math.log(n) / Math.LN2), c = o <= 48 ? 1 : l(2, o - 48), d = s(n), f = d.mul(e); f.isNegative() || f.gt(i);)f = (d = s(n -= c, this.unsigned)).mul(e); d.isZero() && (d = b), a = a.add(d), i = i.sub(f) } return a }, _.div = _.divide, _.modulo = function (e) { return r(e) || (e = h(e)), t ? u((this.unsigned ? t.rem_u : t.rem_s)(this.low, this.high, e.low, e.high), t.get_high(), this.unsigned) : this.sub(this.div(e).mul(e)) }, _.mod = _.modulo, _.rem = _.modulo, _.not = function () { return u(~this.low, ~this.high, this.unsigned) }, _.and = function (e) { return r(e) || (e = h(e)), u(this.low & e.low, this.high & e.high, this.unsigned) }, _.or = function (e) { return r(e) || (e = h(e)), u(this.low | e.low, this.high | e.high, this.unsigned) }, _.xor = function (e) { return r(e) || (e = h(e)), u(this.low ^ e.low, this.high ^ e.high, this.unsigned) }, _.shiftLeft = function (e) { return r(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? u(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : u(0, this.low << e - 32, this.unsigned) }, _.shl = _.shiftLeft, _.shiftRight = function (e) { return r(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? u(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : u(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned) }, _.shr = _.shiftRight, _.shiftRightUnsigned = function (e) { if (r(e) && (e = e.toInt()), 0 === (e &= 63)) return this; var t = this.high; return e < 32 ? u(this.low >>> e | t << 32 - e, t >>> e, this.unsigned) : u(32 === e ? t : t >>> e - 32, 0, this.unsigned) }, _.shru = _.shiftRightUnsigned, _.shr_u = _.shiftRightUnsigned, _.toSigned = function () { return this.unsigned ? u(this.low, this.high, !1) : this }, _.toUnsigned = function () { return this.unsigned ? this : u(this.low, this.high, !0) }, _.toBytes = function (e) { return e ? this.toBytesLE() : this.toBytesBE() }, _.toBytesLE = function () { var e = this.high, t = this.low; return [255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, 255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24] }, _.toBytesBE = function () { var e = this.high, t = this.low; return [e >>> 24, e >>> 16 & 255, e >>> 8 & 255, 255 & e, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, 255 & t] }, n.fromBytes = function (e, t, r) { return r ? n.fromBytesLE(e, t) : n.fromBytesBE(e, t) }, n.fromBytesLE = function (e, t) { return new n(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t) }, n.fromBytesBE = function (e, t) { return new n(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t) } }, 5228: e => { + "use strict"; +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/var t = Object.getOwnPropertySymbols, n = Object.prototype.hasOwnProperty, r = Object.prototype.propertyIsEnumerable; e.exports = function () { try { if (!Object.assign) return !1; var e = new String("abc"); if (e[5] = "de", "5" === Object.getOwnPropertyNames(e)[0]) return !1; for (var t = {}, n = 0; n < 10; n++)t["_" + String.fromCharCode(n)] = n; if ("0123456789" !== Object.getOwnPropertyNames(t).map((function (e) { return t[e] })).join("")) return !1; var r = {}; return "abcdefghijklmnopqrst".split("").forEach((function (e) { r[e] = e })), "abcdefghijklmnopqrst" === Object.keys(Object.assign({}, r)).join("") } catch (e) { return !1 } }() ? Object.assign : function (e, i) { for (var a, o, s = function (e) { if (null == e) throw new TypeError("Object.assign cannot be called with null or undefined"); return Object(e) }(e), u = 1; u < arguments.length; u++) { for (var l in a = Object(arguments[u])) n.call(a, l) && (s[l] = a[l]); if (t) { o = t(a); for (var c = 0; c < o.length; c++)r.call(a, o[c]) && (s[o[c]] = a[o[c]]) } } return s } + }, 5237: (e, t, n) => { "use strict"; function r() { } n.r(t), n.d(t, { Component: () => O, cloneElement: () => c, createElement: () => s, default: () => P, h: () => s, options: () => i, render: () => z, rerender: () => p }); var i = {}, a = [], o = []; function s(e, t) { var n, s, u, l, c = o; for (l = arguments.length; l-- > 2;)a.push(arguments[l]); for (t && null != t.children && (a.length || a.push(t.children), delete t.children); a.length;)if ((s = a.pop()) && void 0 !== s.pop) for (l = s.length; l--;)a.push(s[l]); else "boolean" == typeof s && (s = null), (u = "function" != typeof e) && (null == s ? s = "" : "number" == typeof s ? s = String(s) : "string" != typeof s && (u = !1)), u && n ? c[c.length - 1] += s : c === o ? c = [s] : c.push(s), n = u; var h = new r; return h.nodeName = e, h.children = c, h.attributes = null == t ? void 0 : t, h.key = null == t ? void 0 : t.key, void 0 !== i.vnode && i.vnode(h), h } function u(e, t) { for (var n in t) e[n] = t[n]; return e } var l = "function" == typeof Promise ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; function c(e, t) { return s(e.nodeName, u(u({}, e.attributes), t), arguments.length > 2 ? [].slice.call(arguments, 2) : e.children) } var h = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i, d = []; function f(e) { !e._dirty && (e._dirty = !0) && 1 == d.push(e) && (i.debounceRendering || l)(p) } function p() { var e, t = d; for (d = []; e = t.pop();)e._dirty && $(e) } function m(e, t, n) { return "string" == typeof t || "number" == typeof t ? void 0 !== e.splitText : "string" == typeof t.nodeName ? !e._componentConstructor && g(e, t.nodeName) : n || e._componentConstructor === t.nodeName } function g(e, t) { return e.normalizedNodeName === t || e.nodeName.toLowerCase() === t.toLowerCase() } function y(e) { var t = u({}, e.attributes); t.children = e.children; var n = e.nodeName.defaultProps; if (void 0 !== n) for (var r in n) void 0 === t[r] && (t[r] = n[r]); return t } function b(e) { var t = e.parentNode; t && t.removeChild(e) } function v(e, t, n, r, i) { if ("className" === t && (t = "class"), "key" === t); else if ("ref" === t) n && n(null), r && r(e); else if ("class" !== t || i) if ("style" === t) { if (r && "string" != typeof r && "string" != typeof n || (e.style.cssText = r || ""), r && "object" == typeof r) { if ("string" != typeof n) for (var a in n) a in r || (e.style[a] = ""); for (var a in r) e.style[a] = "number" == typeof r[a] && !1 === h.test(a) ? r[a] + "px" : r[a] } } else if ("dangerouslySetInnerHTML" === t) r && (e.innerHTML = r.__html || ""); else if ("o" == t[0] && "n" == t[1]) { var o = t !== (t = t.replace(/Capture$/, "")); t = t.toLowerCase().substring(2), r ? n || e.addEventListener(t, x, o) : e.removeEventListener(t, x, o), (e._listeners || (e._listeners = {}))[t] = r } else if ("list" !== t && "type" !== t && !i && t in e) !function (e, t, n) { try { e[t] = n } catch (e) { } }(e, t, null == r ? "" : r), null != r && !1 !== r || e.removeAttribute(t); else { var s = i && t !== (t = t.replace(/^xlink:?/, "")); null == r || !1 === r ? s ? e.removeAttributeNS("http://www.w3.org/1999/xlink", t.toLowerCase()) : e.removeAttribute(t) : "function" != typeof r && (s ? e.setAttributeNS("http://www.w3.org/1999/xlink", t.toLowerCase(), r) : e.setAttribute(t, r)) } else e.className = r || "" } function x(e) { return this._listeners[e.type](i.event && i.event(e) || e) } var w = [], k = 0, S = !1, _ = !1; function C() { for (var e; e = w.pop();)i.afterMount && i.afterMount(e), e.componentDidMount && e.componentDidMount() } function A(e, t, n, r, i, a) { k++ || (S = null != i && void 0 !== i.ownerSVGElement, _ = null != e && !("__preactattr_" in e)); var o = T(e, t, n, r, a); return i && o.parentNode !== i && i.appendChild(o), --k || (_ = !1, a || C()), o } function T(e, t, n, r, i) { var a = e, o = S; if (null != t && "boolean" != typeof t || (t = ""), "string" == typeof t || "number" == typeof t) return e && void 0 !== e.splitText && e.parentNode && (!e._component || i) ? e.nodeValue != t && (e.nodeValue = t) : (a = document.createTextNode(t), e && (e.parentNode && e.parentNode.replaceChild(a, e), E(e, !0))), a.__preactattr_ = !0, a; var s, u, l = t.nodeName; if ("function" == typeof l) return function (e, t, n, r) { var i = e && e._component, a = i, o = e, s = i && e._componentConstructor === t.nodeName, u = s, l = y(t); for (; i && !u && (i = i._parentComponent);)u = i.constructor === t.nodeName; i && u && (!r || i._component) ? (D(i, l, 3, n, r), e = i.base) : (a && !s && (R(a), e = o = null), i = M(t.nodeName, l, n), e && !i.nextBase && (i.nextBase = e, o = null), D(i, l, 1, n, r), e = i.base, o && e !== o && (o._component = null, E(o, !1))); return e }(e, t, n, r); if (S = "svg" === l || "foreignObject" !== l && S, l = String(l), (!e || !g(e, l)) && (s = l, (u = S ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s)).normalizedNodeName = s, a = u, e)) { for (; e.firstChild;)a.appendChild(e.firstChild); e.parentNode && e.parentNode.replaceChild(a, e), E(e, !0) } var c = a.firstChild, h = a.__preactattr_, d = t.children; if (null == h) { h = a.__preactattr_ = {}; for (var f = a.attributes, p = f.length; p--;)h[f[p].name] = f[p].value } return !_ && d && 1 === d.length && "string" == typeof d[0] && null != c && void 0 !== c.splitText && null == c.nextSibling ? c.nodeValue != d[0] && (c.nodeValue = d[0]) : (d && d.length || null != c) && function (e, t, n, r, i) { var a, o, s, u, l, c = e.childNodes, h = [], d = {}, f = 0, p = 0, g = c.length, y = 0, v = t ? t.length : 0; if (0 !== g) for (var x = 0; x < g; x++) { var w = c[x], k = w.__preactattr_; null != (S = v && k ? w._component ? w._component.__key : k.key : null) ? (f++, d[S] = w) : (k || (void 0 !== w.splitText ? !i || w.nodeValue.trim() : i)) && (h[y++] = w) } if (0 !== v) for (x = 0; x < v; x++) { var S; if (l = null, null != (S = (u = t[x]).key)) f && void 0 !== d[S] && (l = d[S], d[S] = void 0, f--); else if (!l && p < y) for (a = p; a < y; a++)if (void 0 !== h[a] && m(o = h[a], u, i)) { l = o, h[a] = void 0, a === y - 1 && y--, a === p && p++; break } l = T(l, u, n, r), s = c[x], l && l !== e && l !== s && (null == s ? e.appendChild(l) : l === s.nextSibling ? b(s) : e.insertBefore(l, s)) } if (f) for (var x in d) void 0 !== d[x] && E(d[x], !1); for (; p <= y;)void 0 !== (l = h[y--]) && E(l, !1) }(a, d, n, r, _ || null != h.dangerouslySetInnerHTML), function (e, t, n) { var r; for (r in n) t && null != t[r] || null == n[r] || v(e, r, n[r], n[r] = void 0, S); for (r in t) "children" === r || "innerHTML" === r || r in n && t[r] === ("value" === r || "checked" === r ? e[r] : n[r]) || v(e, r, n[r], n[r] = t[r], S) }(a, t.attributes, h), S = o, a } function E(e, t) { var n = e._component; n ? R(n) : (null != e.__preactattr_ && e.__preactattr_.ref && e.__preactattr_.ref(null), !1 !== t && null != e.__preactattr_ || b(e), N(e)) } function N(e) { for (e = e.lastChild; e;) { var t = e.previousSibling; E(e, !0), e = t } } var I = {}; function M(e, t, n) { var r, i = I[e.name]; if (e.prototype && e.prototype.render ? (r = new e(t, n), O.call(r, t, n)) : ((r = new O(t, n)).constructor = e, r.render = F), i) for (var a = i.length; a--;)if (i[a].constructor === e) { r.nextBase = i[a].nextBase, i.splice(a, 1); break } return r } function F(e, t, n) { return this.constructor(e, n) } function D(e, t, n, r, a) { e._disable || (e._disable = !0, (e.__ref = t.ref) && delete t.ref, (e.__key = t.key) && delete t.key, !e.base || a ? e.componentWillMount && e.componentWillMount() : e.componentWillReceiveProps && e.componentWillReceiveProps(t, r), r && r !== e.context && (e.prevContext || (e.prevContext = e.context), e.context = r), e.prevProps || (e.prevProps = e.props), e.props = t, e._disable = !1, 0 !== n && (1 !== n && !1 === i.syncComponentUpdates && e.base ? f(e) : $(e, 1, a)), e.__ref && e.__ref(e)) } function $(e, t, n, r) { if (!e._disable) { var a, o, s, l = e.props, c = e.state, h = e.context, d = e.prevProps || l, f = e.prevState || c, p = e.prevContext || h, m = e.base, g = e.nextBase, b = m || g, v = e._component, x = !1; if (m && (e.props = d, e.state = f, e.context = p, 2 !== t && e.shouldComponentUpdate && !1 === e.shouldComponentUpdate(l, c, h) ? x = !0 : e.componentWillUpdate && e.componentWillUpdate(l, c, h), e.props = l, e.state = c, e.context = h), e.prevProps = e.prevState = e.prevContext = e.nextBase = null, e._dirty = !1, !x) { a = e.render(l, c, h), e.getChildContext && (h = u(u({}, h), e.getChildContext())); var S, _, T = a && a.nodeName; if ("function" == typeof T) { var N = y(a); (o = v) && o.constructor === T && N.key == o.__key ? D(o, N, 1, h, !1) : (S = o, e._component = o = M(T, N, h), o.nextBase = o.nextBase || g, o._parentComponent = e, D(o, N, 0, h, !1), $(o, 1, n, !0)), _ = o.base } else s = b, (S = v) && (s = e._component = null), (b || 1 === t) && (s && (s._component = null), _ = A(s, a, h, n || !m, b && b.parentNode, !0)); if (b && _ !== b && o !== v) { var I = b.parentNode; I && _ !== I && (I.replaceChild(_, b), S || (b._component = null, E(b, !1))) } if (S && R(S), e.base = _, _ && !r) { for (var F = e, O = e; O = O._parentComponent;)(F = O).base = _; _._component = F, _._componentConstructor = F.constructor } } if (!m || n ? w.unshift(e) : x || (e.componentDidUpdate && e.componentDidUpdate(d, f, p), i.afterUpdate && i.afterUpdate(e)), null != e._renderCallbacks) for (; e._renderCallbacks.length;)e._renderCallbacks.pop().call(e); k || r || C() } } function R(e) { i.beforeUnmount && i.beforeUnmount(e); var t = e.base; e._disable = !0, e.componentWillUnmount && e.componentWillUnmount(), e.base = null; var n = e._component; n ? R(n) : t && (t.__preactattr_ && t.__preactattr_.ref && t.__preactattr_.ref(null), e.nextBase = t, b(t), function (e) { var t = e.constructor.name; (I[t] || (I[t] = [])).push(e) }(e), N(t)), e.__ref && e.__ref(null) } function O(e, t) { this._dirty = !0, this.context = t, this.props = e, this.state = this.state || {} } function z(e, t, n) { return A(n, e, {}, !1, t, !1) } u(O.prototype, { setState: function (e, t) { var n = this.state; this.prevState || (this.prevState = u({}, n)), u(n, "function" == typeof e ? e(n, this.props) : e), t && (this._renderCallbacks = this._renderCallbacks || []).push(t), f(this) }, forceUpdate: function (e) { e && (this._renderCallbacks = this._renderCallbacks || []).push(e), $(this, 2) }, render: function () { } }); const P = { h: s, createElement: s, cloneElement: c, Component: O, render: z, rerender: p, options: i } }, 7391: (e, t, n) => { var r = n(7180), i = n(3181), a = n(3031), o = n(9067), s = n(6833), u = n(3717), l = n(4801); l.alea = r, l.xor128 = i, l.xorwow = a, l.xorshift7 = o, l.xor4096 = s, l.tychei = u, e.exports = l }, 7180: function (e, t, n) { var r; !function (e, i) { function a(e) { var t = this, n = function () { var e = 4022871197, t = function (t) { t = String(t); for (var n = 0; n < t.length; n++) { var r = .02519603282416938 * (e += t.charCodeAt(n)); r -= e = r >>> 0, e = (r *= e) >>> 0, e += 4294967296 * (r -= e) } return 2.3283064365386963e-10 * (e >>> 0) }; return t }(); t.next = function () { var e = 2091639 * t.s0 + 2.3283064365386963e-10 * t.c; return t.s0 = t.s1, t.s1 = t.s2, t.s2 = e - (t.c = 0 | e) }, t.c = 1, t.s0 = n(" "), t.s1 = n(" "), t.s2 = n(" "), t.s0 -= n(e), t.s0 < 0 && (t.s0 += 1), t.s1 -= n(e), t.s1 < 0 && (t.s1 += 1), t.s2 -= n(e), t.s2 < 0 && (t.s2 += 1), n = null } function o(e, t) { return t.c = e.c, t.s0 = e.s0, t.s1 = e.s1, t.s2 = e.s2, t } function s(e, t) { var n = new a(e), r = t && t.state, i = n.next; return i.int32 = function () { return 4294967296 * n.next() | 0 }, i.double = function () { return i() + 11102230246251565e-32 * (2097152 * i() | 0) }, i.quick = i, r && ("object" == typeof r && o(r, n), i.state = function () { return o(n, {}) }), i } i && i.exports ? i.exports = s : n.amdD && n.amdO ? void 0 === (r = function () { return s }.call(t, n, t, i)) || (i.exports = r) : this.alea = s }(0, e = n.nmd(e), n.amdD) }, 3717: function (e, t, n) { var r; !function (e, i) { function a(e) { var t = this, n = ""; t.next = function () { var e = t.b, n = t.c, r = t.d, i = t.a; return e = e << 25 ^ e >>> 7 ^ n, n = n - r | 0, r = r << 24 ^ r >>> 8 ^ i, i = i - e | 0, t.b = e = e << 20 ^ e >>> 12 ^ n, t.c = n = n - r | 0, t.d = r << 16 ^ n >>> 16 ^ i, t.a = i - e | 0 }, t.a = 0, t.b = 0, t.c = -1640531527, t.d = 1367130551, e === Math.floor(e) ? (t.a = e / 4294967296 | 0, t.b = 0 | e) : n += e; for (var r = 0; r < n.length + 20; r++)t.b ^= 0 | n.charCodeAt(r), t.next() } function o(e, t) { return t.a = e.a, t.b = e.b, t.c = e.c, t.d = e.d, t } function s(e, t) { var n = new a(e), r = t && t.state, i = function () { return (n.next() >>> 0) / 4294967296 }; return i.double = function () { do { var e = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21) } while (0 === e); return e }, i.int32 = n.next, i.quick = i, r && ("object" == typeof r && o(r, n), i.state = function () { return o(n, {}) }), i } i && i.exports ? i.exports = s : n.amdD && n.amdO ? void 0 === (r = function () { return s }.call(t, n, t, i)) || (i.exports = r) : this.tychei = s }(0, e = n.nmd(e), n.amdD) }, 3181: function (e, t, n) { var r; !function (e, i) { function a(e) { var t = this, n = ""; t.x = 0, t.y = 0, t.z = 0, t.w = 0, t.next = function () { var e = t.x ^ t.x << 11; return t.x = t.y, t.y = t.z, t.z = t.w, t.w ^= t.w >>> 19 ^ e ^ e >>> 8 }, e === (0 | e) ? t.x = e : n += e; for (var r = 0; r < n.length + 64; r++)t.x ^= 0 | n.charCodeAt(r), t.next() } function o(e, t) { return t.x = e.x, t.y = e.y, t.z = e.z, t.w = e.w, t } function s(e, t) { var n = new a(e), r = t && t.state, i = function () { return (n.next() >>> 0) / 4294967296 }; return i.double = function () { do { var e = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21) } while (0 === e); return e }, i.int32 = n.next, i.quick = i, r && ("object" == typeof r && o(r, n), i.state = function () { return o(n, {}) }), i } i && i.exports ? i.exports = s : n.amdD && n.amdO ? void 0 === (r = function () { return s }.call(t, n, t, i)) || (i.exports = r) : this.xor128 = s }(0, e = n.nmd(e), n.amdD) }, 6833: function (e, t, n) { var r; !function (e, i) { function a(e) { var t = this; t.next = function () { var e, n, r = t.w, i = t.X, a = t.i; return t.w = r = r + 1640531527 | 0, n = i[a + 34 & 127], e = i[a = a + 1 & 127], n ^= n << 13, e ^= e << 17, n ^= n >>> 15, e ^= e >>> 12, n = i[a] = n ^ e, t.i = a, n + (r ^ r >>> 16) | 0 }, function (e, t) { var n, r, i, a, o, s = [], u = 128; for (t === (0 | t) ? (r = t, t = null) : (t += "\0", r = 0, u = Math.max(u, t.length)), i = 0, a = -32; a < u; ++a)t && (r ^= t.charCodeAt((a + 32) % t.length)), 0 === a && (o = r), r ^= r << 10, r ^= r >>> 15, r ^= r << 4, r ^= r >>> 13, a >= 0 && (o = o + 1640531527 | 0, i = 0 == (n = s[127 & a] ^= r + o) ? i + 1 : 0); for (i >= 128 && (s[127 & (t && t.length || 0)] = -1), i = 127, a = 512; a > 0; --a)r = s[i + 34 & 127], n = s[i = i + 1 & 127], r ^= r << 13, n ^= n << 17, r ^= r >>> 15, n ^= n >>> 12, s[i] = r ^ n; e.w = o, e.X = s, e.i = i }(t, e) } function o(e, t) { return t.i = e.i, t.w = e.w, t.X = e.X.slice(), t } function s(e, t) { null == e && (e = +new Date); var n = new a(e), r = t && t.state, i = function () { return (n.next() >>> 0) / 4294967296 }; return i.double = function () { do { var e = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21) } while (0 === e); return e }, i.int32 = n.next, i.quick = i, r && (r.X && o(r, n), i.state = function () { return o(n, {}) }), i } i && i.exports ? i.exports = s : n.amdD && n.amdO ? void 0 === (r = function () { return s }.call(t, n, t, i)) || (i.exports = r) : this.xor4096 = s }(0, e = n.nmd(e), n.amdD) }, 9067: function (e, t, n) { var r; !function (e, i) { function a(e) { var t = this; t.next = function () { var e, n, r = t.x, i = t.i; return e = r[i], n = (e ^= e >>> 7) ^ e << 24, n ^= (e = r[i + 1 & 7]) ^ e >>> 10, n ^= (e = r[i + 3 & 7]) ^ e >>> 3, n ^= (e = r[i + 4 & 7]) ^ e << 7, e = r[i + 7 & 7], n ^= (e ^= e << 13) ^ e << 9, r[i] = n, t.i = i + 1 & 7, n }, function (e, t) { var n, r = []; if (t === (0 | t)) r[0] = t; else for (t = "" + t, n = 0; n < t.length; ++n)r[7 & n] = r[7 & n] << 15 ^ t.charCodeAt(n) + r[n + 1 & 7] << 13; for (; r.length < 8;)r.push(0); for (n = 0; n < 8 && 0 === r[n]; ++n); for (8 == n ? r[7] = -1 : r[n], e.x = r, e.i = 0, n = 256; n > 0; --n)e.next() }(t, e) } function o(e, t) { return t.x = e.x.slice(), t.i = e.i, t } function s(e, t) { null == e && (e = +new Date); var n = new a(e), r = t && t.state, i = function () { return (n.next() >>> 0) / 4294967296 }; return i.double = function () { do { var e = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21) } while (0 === e); return e }, i.int32 = n.next, i.quick = i, r && (r.x && o(r, n), i.state = function () { return o(n, {}) }), i } i && i.exports ? i.exports = s : n.amdD && n.amdO ? void 0 === (r = function () { return s }.call(t, n, t, i)) || (i.exports = r) : this.xorshift7 = s }(0, e = n.nmd(e), n.amdD) }, 3031: function (e, t, n) { var r; !function (e, i) { function a(e) { var t = this, n = ""; t.next = function () { var e = t.x ^ t.x >>> 2; return t.x = t.y, t.y = t.z, t.z = t.w, t.w = t.v, (t.d = t.d + 362437 | 0) + (t.v = t.v ^ t.v << 4 ^ e ^ e << 1) | 0 }, t.x = 0, t.y = 0, t.z = 0, t.w = 0, t.v = 0, e === (0 | e) ? t.x = e : n += e; for (var r = 0; r < n.length + 64; r++)t.x ^= 0 | n.charCodeAt(r), r == n.length && (t.d = t.x << 10 ^ t.x >>> 4), t.next() } function o(e, t) { return t.x = e.x, t.y = e.y, t.z = e.z, t.w = e.w, t.v = e.v, t.d = e.d, t } function s(e, t) { var n = new a(e), r = t && t.state, i = function () { return (n.next() >>> 0) / 4294967296 }; return i.double = function () { do { var e = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21) } while (0 === e); return e }, i.int32 = n.next, i.quick = i, r && ("object" == typeof r && o(r, n), i.state = function () { return o(n, {}) }), i } i && i.exports ? i.exports = s : n.amdD && n.amdO ? void 0 === (r = function () { return s }.call(t, n, t, i)) || (i.exports = r) : this.xorwow = s }(0, e = n.nmd(e), n.amdD) }, 4801: function (e, t, n) { var r; !function (i, a, o) { var s, u = 256, l = o.pow(u, 6), c = o.pow(2, 52), h = 2 * c, d = 255; function f(e, t, n) { var r = [], d = y(g((t = 1 == t ? { entropy: !0 } : t || {}).entropy ? [e, b(a)] : null == e ? function () { try { var e; return s && (e = s.randomBytes) ? e = e(u) : (e = new Uint8Array(u), (i.crypto || i.msCrypto).getRandomValues(e)), b(e) } catch (e) { var t = i.navigator, n = t && t.plugins; return [+new Date, i, n, i.screen, b(a)] } }() : e, 3), r), f = new p(r), v = function () { for (var e = f.g(6), t = l, n = 0; e < c;)e = (e + n) * u, t *= u, n = f.g(1); for (; e >= h;)e /= 2, t /= 2, n >>>= 1; return (e + n) / t }; return v.int32 = function () { return 0 | f.g(4) }, v.quick = function () { return f.g(4) / 4294967296 }, v.double = v, y(b(f.S), a), (t.pass || n || function (e, t, n, r) { return r && (r.S && m(r, f), e.state = function () { return m(f, {}) }), n ? (o.random = e, t) : e })(v, d, "global" in t ? t.global : this == o, t.state) } function p(e) { var t, n = e.length, r = this, i = 0, a = r.i = r.j = 0, o = r.S = []; for (n || (e = [n++]); i < u;)o[i] = i++; for (i = 0; i < u; i++)o[i] = o[a = d & a + e[i % n] + (t = o[i])], o[a] = t; (r.g = function (e) { for (var t, n = 0, i = r.i, a = r.j, o = r.S; e--;)t = o[i = d & i + 1], n = n * u + o[d & (o[i] = o[a = d & a + t]) + (o[a] = t)]; return r.i = i, r.j = a, n })(u) } function m(e, t) { return t.i = e.i, t.j = e.j, t.S = e.S.slice(), t } function g(e, t) { var n, r = [], i = typeof e; if (t && "object" == i) for (n in e) try { r.push(g(e[n], t - 1)) } catch (e) { } return r.length ? r : "string" == i ? e : e + "\0" } function y(e, t) { for (var n, r = e + "", i = 0; i < r.length;)t[d & i] = d & (n ^= 19 * t[d & i]) + r.charCodeAt(i++); return b(t) } function b(e) { return String.fromCharCode.apply(0, e) } if (y(o.random(), a), e.exports) { e.exports = f; try { s = n(1234) } catch (e) { } } else void 0 === (r = function () { return f }.call(t, n, t, e)) || (e.exports = r) }("undefined" != typeof self ? self : this, [], Math) }, 8731: (e, t, n) => { + "use strict"; n.r(t), n.d(t, { DEFAULT_ACTIONS: () => Yje, default: () => oUe, guessMode: () => nUe, vega: () => Gje, vegaLite: () => Hje }); var r = {}; n.r(r), n.d(r, { JsonPatchError: () => $, _areEquals: () => V, applyOperation: () => B, applyPatch: () => L, applyReducer: () => j, deepClone: () => R, getValueByPointer: () => P, validate: () => W, validator: () => U }); var i = {}; n.r(i), n.d(i, { compare: () => J, generate: () => K, observe: () => X, unobserve: () => Y }); var a = {}; n.r(a), n.d(a, { aggregate: () => Xl, bin: () => Kl, collect: () => Jl, compare: () => Ql, countpattern: () => tc, cross: () => nc, density: () => oc, dotbin: () => hc, expression: () => dc, extent: () => pc, facet: () => gc, field: () => yc, filter: () => vc, flatten: () => xc, fold: () => wc, formula: () => kc, generate: () => Sc, impute: () => Ac, joinaggregate: () => Tc, kde: () => Ec, key: () => Nc, load: () => Mc, lookup: () => Dc, multiextent: () => $c, multivalues: () => Oc, params: () => Pc, pivot: () => Bc, prefacet: () => Lc, project: () => jc, proxy: () => Uc, quantile: () => Wc, relay: () => Vc, sample: () => Gc, sequence: () => Hc, sieve: () => qc, subflow: () => mc, timeunit: () => Yc, tupleindex: () => Kc, values: () => Zc, window: () => nh }); var o = {}; n.r(o), n.d(o, { interpolate: () => Ag, interpolateArray: () => bg, interpolateBasis: () => ag, interpolateBasisClosed: () => og, interpolateCubehelix: () => _y, interpolateCubehelixLong: () => Cy, interpolateDate: () => xg, interpolateDiscrete: () => Eg, interpolateHcl: () => hy, interpolateHclLong: () => dy, interpolateHsl: () => jg, interpolateHslLong: () => Ug, interpolateHue: () => Ng, interpolateLab: () => ly, interpolateNumber: () => wg, interpolateNumberArray: () => gg, interpolateObject: () => kg, interpolateRgb: () => dg, interpolateRgbBasis: () => pg, interpolateRgbBasisClosed: () => mg, interpolateRound: () => Ig, interpolateString: () => Cg, interpolateTransformCss: () => Og, interpolateTransformSvg: () => zg, interpolateZoom: () => Bg, piecewise: () => Tg, quantize: () => Ay }); var s = {}; n.r(s), n.d(s, { bound: () => a_, identifier: () => u_, mark: () => l_, overlap: () => c_, render: () => y_, viewlayout: () => B_ }); var u = {}; n.r(u), n.d(u, { axisticks: () => WC, datajoin: () => VC, encode: () => HC, legendentries: () => qC, linkpath: () => JC, pie: () => rA, scale: () => oA, sortitems: () => cA, stack: () => mA }); var l = {}; n.r(l), n.d(l, { contour: () => OM, geojson: () => BM, geopath: () => LM, geopoint: () => jM, geoshape: () => UM, graticule: () => WM, heatmap: () => VM, isocontour: () => AM, kde2d: () => DM, projection: () => HM }); var c = {}; n.r(c), n.d(c, { force: () => jF }); var h = {}; n.r(h), n.d(h, { nest: () => jD, pack: () => qD, partition: () => XD, stratify: () => KD, tree: () => QD, treelinks: () => e$, treemap: () => r$ }); var d = {}; n.r(d), n.d(d, { label: () => S$ }); var f = {}; n.r(f), n.d(f, { loess: () => C$, regression: () => T$ }); var p = {}; n.r(p), n.d(p, { voronoi: () => K$ }); var m = {}; n.r(m), n.d(m, { wordcloud: () => dR }); var g = {}; n.r(g), n.d(g, { crossfilter: () => SR, resolvefilter: () => _R }); var y = {}; n.r(y), n.d(y, { interpolate: () => aV, interpolateArray: () => ZW, interpolateBasis: () => PW, interpolateBasisClosed: () => BW, interpolateCubehelix: () => rG, interpolateCubehelixLong: () => iG, interpolateDate: () => QW, interpolateDiscrete: () => sV, interpolateHcl: () => VV, interpolateHclLong: () => GV, interpolateHsl: () => xV, interpolateHslLong: () => wV, interpolateHue: () => uV, interpolateLab: () => UV, interpolateNumber: () => eV, interpolateNumberArray: () => XW, interpolateObject: () => tV, interpolateRgb: () => GW, interpolateRgbBasis: () => qW, interpolateRgbBasisClosed: () => YW, interpolateRound: () => lV, interpolateString: () => iV, interpolateTransformCss: () => mV, interpolateTransformSvg: () => gV, interpolateZoom: () => bV, piecewise: () => oV, quantize: () => aG }); var b = {}; n.r(b), n.d(b, { interpolate: () => UC, interpolateArray: () => $C, interpolateBasis: () => wC, interpolateBasisClosed: () => kC, interpolateCubehelix: () => X1, interpolateCubehelixLong: () => K1, interpolateDate: () => OC, interpolateDiscrete: () => e1, interpolateHcl: () => O1, interpolateHclLong: () => z1, interpolateHsl: () => d1, interpolateHslLong: () => f1, interpolateHue: () => t1, interpolateLab: () => $1, interpolateNumber: () => zC, interpolateNumberArray: () => FC, interpolateObject: () => PC, interpolateRgb: () => EC, interpolateRgbBasis: () => IC, interpolateRgbBasisClosed: () => MC, interpolateRound: () => j_, interpolateString: () => jC, interpolateTransformCss: () => s1, interpolateTransformSvg: () => u1, interpolateZoom: () => c1, piecewise: () => Z0, quantize: () => Z1 }); var v = {}; n.r(v), n.d(v, { interpolate: () => Iue, interpolateArray: () => kue, interpolateBasis: () => lue, interpolateBasisClosed: () => cue, interpolateCubehelix: () => Ele, interpolateCubehelixLong: () => Nle, interpolateDate: () => _ue, interpolateDiscrete: () => Fue, interpolateHcl: () => mle, interpolateHclLong: () => gle, interpolateHsl: () => Gue, interpolateHslLong: () => Hue, interpolateHue: () => Due, interpolateLab: () => fle, interpolateNumber: () => Cue, interpolateNumberArray: () => xue, interpolateObject: () => Aue, interpolateRgb: () => gue, interpolateRgbBasis: () => bue, interpolateRgbBasisClosed: () => vue, interpolateRound: () => $ue, interpolateString: () => Nue, interpolateTransformCss: () => Lue, interpolateTransformSvg: () => jue, interpolateZoom: () => Wue, piecewise: () => Mue, quantize: () => Ile }); var x = {}; n.r(x), n.d(x, { Bounds: () => QH, CanvasHandler: () => MX, CanvasRenderer: () => OX, DATE: () => Rz, DAY: () => Oz, DAYOFYEAR: () => zz, Dataflow: () => Au, Debug: () => ke, Error: () => ve, EventStream: () => hu, Gradient: () => oH, GroupItem: () => tq, HOURS: () => Pz, Handler: () => dX, Info: () => we, Item: () => eq, MILLISECONDS: () => jz, MINUTES: () => Bz, MONTH: () => Dz, Marks: () => KY, MultiPulse: () => wu, None: () => be, Operator: () => uu, Parameters: () => au, Pulse: () => yu, QUARTER: () => Fz, RenderType: () => AK, Renderer: () => pX, ResourceLoader: () => nq, SECONDS: () => Lz, SVGHandler: () => PX, SVGRenderer: () => lK, SVGStringRenderer: () => SK, Scenegraph: () => iX, TIME_UNITS: () => Uz, Transform: () => Eu, View: () => ine, WEEK: () => $z, Warn: () => xe, YEAR: () => Mz, accessor: () => ne, accessorFields: () => ie, accessorName: () => re, array: () => Xe, ascending: () => et, bandwidthNRD: () => ER, bin: () => NR, bootstrapCI: () => FR, boundClip: () => $K, boundContext: () => Sq, boundItem: () => ZY, boundMark: () => QY, boundStroke: () => aq, changeset: () => ru, clampRange: () => Ke, codegenExpression: () => WSe, compare: () => Qe, constant: () => it, cumulativeLogNormal: () => qR, cumulativeNormal: () => jR, cumulativeUniform: () => QR, dayofyear: () => Xz, debounce: () => at, defaultLocale: () => mae, definition: () => Iu, densityLogNormal: () => HR, densityNormal: () => LR, densityUniform: () => JR, domChild: () => uX, domClear: () => lX, domCreate: () => oX, domFind: () => sX, dotbin: () => DR, error: () => ue, expressionFunction: () => eye, extend: () => ot, extent: () => st, extentIndex: () => ut, falsy: () => ge, fastmap: () => dt, field: () => ce, flush: () => ft, font: () => UY, fontFamily: () => jY, fontSize: () => OY, format: () => fL, formatLocale: () => sae, formats: () => pL, hasOwnProperty: () => ct, id: () => he, identity: () => de, inferType: () => oL, inferTypes: () => sL, ingest: () => Zs, inherits: () => pt, inrange: () => mt, interpolate: () => B2, interpolateColors: () => z2, interpolateRange: () => O2, intersect: () => NK, intersectBoxLine: () => $q, intersectPath: () => Iq, intersectPoint: () => Mq, intersectRule: () => Dq, isArray: () => _e, isBoolean: () => gt, isDate: () => yt, isFunction: () => Ze, isIterable: () => bt, isNumber: () => vt, isObject: () => Ce, isRegExp: () => xt, isString: () => wt, isTuple: () => Ys, key: () => kt, lerp: () => St, lineHeight: () => zY, loader: () => yL, locale: () => pae, logger: () => Se, lruCache: () => Ct, markup: () => nK, merge: () => At, mergeConfig: () => Te, multiLineOffset: () => BY, one: () => pe, pad: () => Et, panLinear: () => Pe, panLog: () => Be, panPow: () => Le, panSymlog: () => je, parse: () => Mwe, parseExpression: () => LSe, parseSelector: () => r_e, pathCurves: () => uH, pathEqual: () => zK, pathParse: () => hH, pathRectangle: () => RH, pathRender: () => kH, pathSymbols: () => AH, pathTrail: () => OH, peek: () => Ie, point: () => hX, projection: () => C5, quantileLogNormal: () => YR, quantileNormal: () => UR, quantileUniform: () => eO, quantiles: () => AR, quantizeInterpolator: () => P2, quarter: () => qe, quartiles: () => TR, random: () => IR, randomInteger: () => RR, randomKDE: () => VR, randomLCG: () => $R, randomLogNormal: () => XR, randomMixture: () => KR, randomNormal: () => WR, randomUniform: () => tO, read: () => gL, regressionExp: () => uO, regressionLinear: () => oO, regressionLoess: () => mO, regressionLog: () => sO, regressionPoly: () => hO, regressionPow: () => lO, regressionQuad: () => cO, renderModule: () => EK, repeat: () => Tt, resetDefaultLocale: () => gae, resetSVGClipId: () => ZH, resetSVGDefIds: () => PK, responseType: () => mL, runtimeContext: () => Lwe, sampleCurve: () => vO, sampleLogNormal: () => GR, sampleNormal: () => BR, sampleUniform: () => ZR, scale: () => R2, sceneEqual: () => OK, sceneFromJSON: () => nX, scenePickVisit: () => Gq, sceneToJSON: () => tX, sceneVisit: () => Vq, sceneZOrder: () => Wq, scheme: () => W2, serializeXML: () => rK, setRandom: () => MR, span: () => Nt, splitAccessPath: () => le, stringValue: () => It, textMetrics: () => IY, timeBin: () => BP, timeFloor: () => hP, timeFormatLocale: () => dae, timeInterval: () => yP, timeOffset: () => xP, timeSequence: () => SP, timeUnitSpecifier: () => Hz, timeUnits: () => Vz, toBoolean: () => Mt, toDate: () => Dt, toNumber: () => Me, toSet: () => Rt, toString: () => $t, transform: () => Mu, transforms: () => Nu, truncate: () => Ot, truthy: () => me, tupleid: () => Xs, typeParsers: () => rL, utcFloor: () => pP, utcInterval: () => bP, utcOffset: () => wP, utcSequence: () => _P, utcdayofyear: () => tP, utcquarter: () => Ye, utcweek: () => nP, version: () => u_e, visitArray: () => zt, week: () => Kz, writeConfig: () => Ee, zero: () => fe, zoomLinear: () => We, zoomLog: () => Ve, zoomPow: () => Ge, zoomSymlog: () => He }); var w = {}; n.r(w), n.d(w, { compile: () => ALe, extractTransforms: () => ELe, normalize: () => fDe, version: () => NLe }); var k = {}; n.r(k), n.d(k, { carbong10: () => Ije, carbong100: () => Fje, carbong90: () => Mje, carbonwhite: () => Nje, dark: () => $Le, excel: () => OLe, fivethirtyeight: () => jLe, ggplot2: () => WLe, googlecharts: () => cje, latimes: () => XLe, powerbi: () => Sje, quartz: () => JLe, urbaninstitute: () => oje, version: () => Dje, vox: () => eje }); + /*! + * https://github.com/Starcounter-Jack/JSON-Patch + * (c) 2017-2022 Joachim Wester + * MIT licensed + */ + var S = function () { var e = function (t, n) { return e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (e, t) { e.__proto__ = t } || function (e, t) { for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]) }, e(t, n) }; return function (t, n) { function r() { this.constructor = t } e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, new r) } }(), _ = Object.prototype.hasOwnProperty; function C(e, t) { return _.call(e, t) } function A(e) { if (Array.isArray(e)) { for (var t = new Array(e.length), n = 0; n < t.length; n++)t[n] = "" + n; return t } if (Object.keys) return Object.keys(e); var r = []; for (var i in e) C(e, i) && r.push(i); return r } function T(e) { switch (typeof e) { case "object": return JSON.parse(JSON.stringify(e)); case "undefined": return null; default: return e } } function E(e) { for (var t, n = 0, r = e.length; n < r;) { if (!((t = e.charCodeAt(n)) >= 48 && t <= 57)) return !1; n++ } return !0 } function N(e) { return -1 === e.indexOf("/") && -1 === e.indexOf("~") ? e : e.replace(/~/g, "~0").replace(/\//g, "~1") } function I(e) { return e.replace(/~1/g, "/").replace(/~0/g, "~") } function M(e) { if (void 0 === e) return !0; if (e) if (Array.isArray(e)) { for (var t = 0, n = e.length; t < n; t++)if (M(e[t])) return !0 } else if ("object" == typeof e) for (var r = A(e), i = r.length, a = 0; a < i; a++)if (M(e[r[a]])) return !0; return !1 } function F(e, t) { var n = [e]; for (var r in t) { var i = "object" == typeof t[r] ? JSON.stringify(t[r], null, 2) : t[r]; void 0 !== i && n.push(r + ": " + i) } return n.join("\n") } var D = function (e) { function t(t, n, r, i, a) { var o = this.constructor, s = e.call(this, F(t, { name: n, index: r, operation: i, tree: a })) || this; return s.name = n, s.index = r, s.operation = i, s.tree = a, Object.setPrototypeOf(s, o.prototype), s.message = F(t, { name: n, index: r, operation: i, tree: a }), s } return S(t, e), t }(Error), $ = D, R = T, O = { add: function (e, t, n) { return e[t] = this.value, { newDocument: n } }, remove: function (e, t, n) { var r = e[t]; return delete e[t], { newDocument: n, removed: r } }, replace: function (e, t, n) { var r = e[t]; return e[t] = this.value, { newDocument: n, removed: r } }, move: function (e, t, n) { var r = P(n, this.path); r && (r = T(r)); var i = B(n, { op: "remove", path: this.from }).removed; return B(n, { op: "add", path: this.path, value: i }), { newDocument: n, removed: r } }, copy: function (e, t, n) { var r = P(n, this.from); return B(n, { op: "add", path: this.path, value: T(r) }), { newDocument: n } }, test: function (e, t, n) { return { newDocument: n, test: V(e[t], this.value) } }, _get: function (e, t, n) { return this.value = e[t], { newDocument: n } } }, z = { add: function (e, t, n) { return E(t) ? e.splice(t, 0, this.value) : e[t] = this.value, { newDocument: n, index: t } }, remove: function (e, t, n) { return { newDocument: n, removed: e.splice(t, 1)[0] } }, replace: function (e, t, n) { var r = e[t]; return e[t] = this.value, { newDocument: n, removed: r } }, move: O.move, copy: O.copy, test: O.test, _get: O._get }; function P(e, t) { if ("" == t) return e; var n = { op: "_get", path: t }; return B(e, n), n.value } function B(e, t, n, r, i, a) { if (void 0 === n && (n = !1), void 0 === r && (r = !0), void 0 === i && (i = !0), void 0 === a && (a = 0), n && ("function" == typeof n ? n(t, 0, e, t.path) : U(t, 0)), "" === t.path) { var o = { newDocument: e }; if ("add" === t.op) return o.newDocument = t.value, o; if ("replace" === t.op) return o.newDocument = t.value, o.removed = e, o; if ("move" === t.op || "copy" === t.op) return o.newDocument = P(e, t.from), "move" === t.op && (o.removed = e), o; if ("test" === t.op) { if (o.test = V(e, t.value), !1 === o.test) throw new $("Test operation failed", "TEST_OPERATION_FAILED", a, t, e); return o.newDocument = e, o } if ("remove" === t.op) return o.removed = e, o.newDocument = null, o; if ("_get" === t.op) return t.value = e, o; if (n) throw new $("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", a, t, e); return o } r || (e = T(e)); var s = (t.path || "").split("/"), u = e, l = 1, c = s.length, h = void 0, d = void 0, f = void 0; for (f = "function" == typeof n ? n : U; ;) { if ((d = s[l]) && -1 != d.indexOf("~") && (d = I(d)), i && ("__proto__" == d || "prototype" == d && l > 0 && "constructor" == s[l - 1])) throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README"); if (n && void 0 === h && (void 0 === u[d] ? h = s.slice(0, l).join("/") : l == c - 1 && (h = t.path), void 0 !== h && f(t, 0, e, h)), l++, Array.isArray(u)) { if ("-" === d) d = u.length; else { if (n && !E(d)) throw new $("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", a, t, e); E(d) && (d = ~~d) } if (l >= c) { if (n && "add" === t.op && d > u.length) throw new $("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", a, t, e); if (!1 === (o = z[t.op].call(t, u, d, e)).test) throw new $("Test operation failed", "TEST_OPERATION_FAILED", a, t, e); return o } } else if (l >= c) { if (!1 === (o = O[t.op].call(t, u, d, e)).test) throw new $("Test operation failed", "TEST_OPERATION_FAILED", a, t, e); return o } if (u = u[d], n && l < c && (!u || "object" != typeof u)) throw new $("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", a, t, e) } } function L(e, t, n, r, i) { if (void 0 === r && (r = !0), void 0 === i && (i = !0), n && !Array.isArray(t)) throw new $("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY"); r || (e = T(e)); for (var a = new Array(t.length), o = 0, s = t.length; o < s; o++)a[o] = B(e, t[o], n, !0, i, o), e = a[o].newDocument; return a.newDocument = e, a } function j(e, t, n) { var r = B(e, t); if (!1 === r.test) throw new $("Test operation failed", "TEST_OPERATION_FAILED", n, t, e); return r.newDocument } function U(e, t, n, r) { if ("object" != typeof e || null === e || Array.isArray(e)) throw new $("Operation is not an object", "OPERATION_NOT_AN_OBJECT", t, e, n); if (!O[e.op]) throw new $("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", t, e, n); if ("string" != typeof e.path) throw new $("Operation `path` property is not a string", "OPERATION_PATH_INVALID", t, e, n); if (0 !== e.path.indexOf("/") && e.path.length > 0) throw new $('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", t, e, n); if (("move" === e.op || "copy" === e.op) && "string" != typeof e.from) throw new $("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", t, e, n); if (("add" === e.op || "replace" === e.op || "test" === e.op) && void 0 === e.value) throw new $("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", t, e, n); if (("add" === e.op || "replace" === e.op || "test" === e.op) && M(e.value)) throw new $("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", t, e, n); if (n) if ("add" == e.op) { var i = e.path.split("/").length, a = r.split("/").length; if (i !== a + 1 && i !== a) throw new $("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", t, e, n) } else if ("replace" === e.op || "remove" === e.op || "_get" === e.op) { if (e.path !== r) throw new $("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", t, e, n) } else if ("move" === e.op || "copy" === e.op) { var o = W([{ op: "_get", path: e.from, value: void 0 }], n); if (o && "OPERATION_PATH_UNRESOLVABLE" === o.name) throw new $("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", t, e, n) } } function W(e, t, n) { try { if (!Array.isArray(e)) throw new $("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY"); if (t) L(T(t), T(e), n || !0); else { n = n || U; for (var r = 0; r < e.length; r++)n(e[r], r, t, void 0) } } catch (e) { if (e instanceof $) return e; throw e } } function V(e, t) { if (e === t) return !0; if (e && t && "object" == typeof e && "object" == typeof t) { var n, r, i, a = Array.isArray(e), o = Array.isArray(t); if (a && o) { if ((r = e.length) != t.length) return !1; for (n = r; 0 != n--;)if (!V(e[n], t[n])) return !1; return !0 } if (a != o) return !1; var s = Object.keys(e); if ((r = s.length) !== Object.keys(t).length) return !1; for (n = r; 0 != n--;)if (!t.hasOwnProperty(s[n])) return !1; for (n = r; 0 != n--;)if (!V(e[i = s[n]], t[i])) return !1; return !0 } return e != e && t != t } + /*! + * https://github.com/Starcounter-Jack/JSON-Patch + * (c) 2017-2021 Joachim Wester + * MIT license + */ + var G = new WeakMap, H = function (e) { this.observers = new Map, this.obj = e }, q = function (e, t) { this.callback = e, this.observer = t }; function Y(e, t) { t.unobserve() } function X(e, t) { var n, r = function (e) { return G.get(e) }(e); if (r) { var i = function (e, t) { return e.observers.get(t) }(r, t); n = i && i.observer } else r = new H(e), G.set(e, r); if (n) return n; if (n = {}, r.value = T(e), t) { n.callback = t, n.next = null; var a = function () { K(n) }, o = function () { clearTimeout(n.next), n.next = setTimeout(a) }; "undefined" != typeof window && (window.addEventListener("mouseup", o), window.addEventListener("keyup", o), window.addEventListener("mousedown", o), window.addEventListener("keydown", o), window.addEventListener("change", o)) } return n.patches = [], n.object = e, n.unobserve = function () { K(n), clearTimeout(n.next), function (e, t) { e.observers.delete(t.callback) }(r, n), "undefined" != typeof window && (window.removeEventListener("mouseup", o), window.removeEventListener("keyup", o), window.removeEventListener("mousedown", o), window.removeEventListener("keydown", o), window.removeEventListener("change", o)) }, r.observers.set(t, new q(t, n)), n } function K(e, t) { void 0 === t && (t = !1); var n = G.get(e.object); Z(n.value, e.object, e.patches, "", t), e.patches.length && L(n.value, e.patches); var r = e.patches; return r.length > 0 && (e.patches = [], e.callback && e.callback(r)), r } function Z(e, t, n, r, i) { if (t !== e) { "function" == typeof t.toJSON && (t = t.toJSON()); for (var a = A(t), o = A(e), s = !1, u = o.length - 1; u >= 0; u--) { var l = e[h = o[u]]; if (!C(t, h) || void 0 === t[h] && void 0 !== l && !1 === Array.isArray(t)) Array.isArray(e) === Array.isArray(t) ? (i && n.push({ op: "test", path: r + "/" + N(h), value: T(l) }), n.push({ op: "remove", path: r + "/" + N(h) }), s = !0) : (i && n.push({ op: "test", path: r, value: e }), n.push({ op: "replace", path: r, value: t }), !0); else { var c = t[h]; "object" == typeof l && null != l && "object" == typeof c && null != c && Array.isArray(l) === Array.isArray(c) ? Z(l, c, n, r + "/" + N(h), i) : l !== c && (i && n.push({ op: "test", path: r + "/" + N(h), value: T(l) }), n.push({ op: "replace", path: r + "/" + N(h), value: T(c) })) } } if (s || a.length != o.length) for (u = 0; u < a.length; u++) { var h; C(e, h = a[u]) || void 0 === t[h] || n.push({ op: "add", path: r + "/" + N(h), value: T(t[h]) }) } } } function J(e, t, n) { void 0 === n && (n = !1); var r = []; return Z(e, t, r, "", n), r } Object.assign({}, r, i, { JsonPatchError: D, deepClone: T, escapePathComponent: N, unescapePathComponent: I }); var Q = n(8487), ee = n.n(Q), te = n(6392); function ne(e, t, n) { return e.fields = t || [], e.fname = n, e } function re(e) { return null == e ? null : e.fname } function ie(e) { return null == e ? null : e.fields } function ae(e) { return 1 === e.length ? oe(e[0]) : se(e) } const oe = e => function (t) { return t[e] }, se = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function ue(e) { throw Error(e) } function le(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i), u += e.substring(++i, ++i), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || ue("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && ue("Access path missing closing bracket: " + e), o && ue("Access path missing closing quote: " + e), i > r && (i++, l()), t } function ce(e, t, n) { const r = le(e); return e = 1 === r.length ? r[0] : e, ne((n && n.get || ae)(r), [e], t || e) } const he = ce("id"), de = ne((e => e), [], "identity"), fe = ne((() => 0), [], "zero"), pe = ne((() => 1), [], "one"), me = ne((() => !0), [], "true"), ge = ne((() => !1), [], "false"); function ye(e, t, n) { const r = [t].concat([].slice.call(n)); console[e].apply(console, r) } const be = 0, ve = 1, xe = 2, we = 3, ke = 4; function Se(e, t) { let n = e || be; return { level(e) { return arguments.length ? (n = +e, this) : n }, error() { return n >= ve && ye(t || "error", "ERROR", arguments), this }, warn() { return n >= xe && ye(t || "warn", "WARN", arguments), this }, info() { return n >= we && ye(t || "log", "INFO", arguments), this }, debug() { return n >= ke && ye(t || "log", "DEBUG", arguments), this } } } var _e = Array.isArray; function Ce(e) { return e === Object(e) } const Ae = e => "__proto__" !== e; function Te(...e) { return e.reduce(((e, t) => { for (const n in t) if ("signals" === n) e.signals = Ne(e.signals, t.signals); else { const r = "legend" === n ? { layout: 1 } : "style" === n || null; Ee(e, n, t[n], r) } return e }), {}) } function Ee(e, t, n, r) { if (!Ae(t)) return; let i, a; if (Ce(n) && !_e(n)) for (i in a = Ce(e[t]) ? e[t] : e[t] = {}, n) r && (!0 === r || r[i]) ? Ee(a, i, n[i]) : Ae(i) && (a[i] = n[i]); else e[t] = n } function Ne(e, t) { if (null == e) return t; const n = {}, r = []; function i(e) { n[e.name] || (n[e.name] = 1, r.push(e)) } return t.forEach(i), e.forEach(i), r } function Ie(e) { return e[e.length - 1] } function Me(e) { return null == e || "" === e ? null : +e } const Fe = e => t => e * Math.exp(t), De = e => t => Math.log(e * t), $e = e => t => Math.sign(t) * Math.log1p(Math.abs(t / e)), Re = e => t => Math.sign(t) * Math.expm1(Math.abs(t)) * e, Oe = e => t => t < 0 ? -Math.pow(-t, e) : Math.pow(t, e); function ze(e, t, n, r) { const i = n(e[0]), a = n(Ie(e)), o = (a - i) * t; return [r(i - o), r(a - o)] } function Pe(e, t) { return ze(e, t, Me, de) } function Be(e, t) { var n = Math.sign(e[0]); return ze(e, t, De(n), Fe(n)) } function Le(e, t, n) { return ze(e, t, Oe(n), Oe(1 / n)) } function je(e, t, n) { return ze(e, t, $e(n), Re(n)) } function Ue(e, t, n, r, i) { const a = r(e[0]), o = r(Ie(e)), s = null != t ? r(t) : (a + o) / 2; return [i(s + (a - s) * n), i(s + (o - s) * n)] } function We(e, t, n) { return Ue(e, t, n, Me, de) } function Ve(e, t, n) { const r = Math.sign(e[0]); return Ue(e, t, n, De(r), Fe(r)) } function Ge(e, t, n, r) { return Ue(e, t, n, Oe(r), Oe(1 / r)) } function He(e, t, n, r) { return Ue(e, t, n, $e(r), Re(r)) } function qe(e) { return 1 + ~~(new Date(e).getMonth() / 3) } function Ye(e) { return 1 + ~~(new Date(e).getUTCMonth() / 3) } function Xe(e) { return null != e ? _e(e) ? e : [e] : [] } function Ke(e, t, n) { let r, i = e[0], a = e[1]; return a < i && (r = a, a = i, i = r), r = a - i, r >= n - t ? [t, n] : [i = Math.min(Math.max(i, t), n - r), i + r] } function Ze(e) { return "function" == typeof e } const Je = "descending"; function Qe(e, t, n) { n = n || {}, t = Xe(t) || []; const r = [], i = [], a = {}, o = n.comparator || tt; return Xe(e).forEach(((e, o) => { null != e && (r.push(t[o] === Je ? -1 : 1), i.push(e = Ze(e) ? e : ce(e, null, n)), (ie(e) || []).forEach((e => a[e] = 1))) })), 0 === i.length ? null : ne(o(i, r), Object.keys(a)) } const et = (e, t) => (e < t || null == e) && null != t ? -1 : (e > t || null == t) && null != e ? 1 : (t = t instanceof Date ? +t : t, (e = e instanceof Date ? +e : e) !== e && t == t ? -1 : t != t && e == e ? 1 : 0), tt = (e, t) => 1 === e.length ? nt(e[0], t[0]) : rt(e, t, e.length), nt = (e, t) => function (n, r) { return et(e(n), e(r)) * t }, rt = (e, t, n) => (t.push(0), function (r, i) { let a, o = 0, s = -1; for (; 0 === o && ++s < n;)a = e[s], o = et(a(r), a(i)); return o * t[s] }); function it(e) { return Ze(e) ? e : () => e } function at(e, t) { let n; return r => { n && clearTimeout(n), n = setTimeout((() => (t(r), n = null)), e) } } function ot(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } function st(e, t) { let n, r, i, a, o = 0; if (e && (n = e.length)) if (null == t) { for (r = e[o]; o < n && (null == r || r != r); r = e[++o]); for (i = a = r; o < n; ++o)r = e[o], null != r && (r < i && (i = r), r > a && (a = r)) } else { for (r = t(e[o]); o < n && (null == r || r != r); r = t(e[++o])); for (i = a = r; o < n; ++o)r = t(e[o]), null != r && (r < i && (i = r), r > a && (a = r)) } return [i, a] } function ut(e, t) { const n = e.length; let r, i, a, o, s, u = -1; if (null == t) { for (; ++u < n;)if (i = e[u], null != i && i >= i) { r = a = i; break } if (u === n) return [-1, -1]; for (o = s = u; ++u < n;)i = e[u], null != i && (r > i && (r = i, o = u), a < i && (a = i, s = u)) } else { for (; ++u < n;)if (i = t(e[u], u, e), null != i && i >= i) { r = a = i; break } if (u === n) return [-1, -1]; for (o = s = u; ++u < n;)i = t(e[u], u, e), null != i && (r > i && (r = i, o = u), a < i && (a = i, s = u)) } return [o, s] } const lt = Object.prototype.hasOwnProperty; function ct(e, t) { return lt.call(e, t) } const ht = {}; function dt(e) { let t, n = {}; function r(e) { return ct(n, e) && n[e] !== ht } const i = { size: 0, empty: 0, object: n, has: r, get: e => r(e) ? n[e] : void 0, set(e, t) { return r(e) || (++i.size, n[e] === ht && --i.empty), n[e] = t, this }, delete(e) { return r(e) && (--i.size, ++i.empty, n[e] = ht), this }, clear() { i.size = i.empty = 0, i.object = n = {} }, test(e) { return arguments.length ? (t = e, i) : t }, clean() { const e = {}; let r = 0; for (const i in n) { const a = n[i]; a === ht || t && t(a) || (e[i] = a, ++r) } i.size = r, i.empty = 0, i.object = n = e } }; return e && Object.keys(e).forEach((t => { i.set(t, e[t]) })), i } function ft(e, t, n, r, i, a) { if (!n && 0 !== n) return a; const o = +n; let s, u = e[0], l = Ie(e); l < u && (s = u, u = l, l = s), s = Math.abs(t - u); const c = Math.abs(l - t); return s < c && s <= o ? r : c <= o ? i : a } function pt(e, t, n) { const r = e.prototype = Object.create(t.prototype); return Object.defineProperty(r, "constructor", { value: e, writable: !0, enumerable: !0, configurable: !0 }), ot(r, n) } function mt(e, t, n, r) { let i, a = t[0], o = t[t.length - 1]; return a > o && (i = a, a = o, o = i), r = void 0 === r || r, ((n = void 0 === n || n) ? a <= e : a < e) && (r ? e <= o : e < o) } function gt(e) { return "boolean" == typeof e } function yt(e) { return "[object Date]" === Object.prototype.toString.call(e) } function bt(e) { return e && Ze(e[Symbol.iterator]) } function vt(e) { return "number" == typeof e } function xt(e) { return "[object RegExp]" === Object.prototype.toString.call(e) } function wt(e) { return "string" == typeof e } function kt(e, t, n) { e && (e = t ? Xe(e).map((e => e.replace(/\\(.)/g, "$1"))) : Xe(e)); const r = e && e.length, i = n && n.get || ae, a = e => i(t ? [e] : le(e)); let o; if (r) if (1 === r) { const t = a(e[0]); o = function (e) { return "" + t(e) } } else { const t = e.map(a); o = function (e) { let n = "" + t[0](e), i = 0; for (; ++i < r;)n += "|" + t[i](e); return n } } else o = function () { return "" }; return ne(o, e, "key") } function St(e, t) { const n = e[0], r = Ie(e), i = +t; return i ? 1 === i ? r : n + i * (r - n) : n } const _t = 1e4; function Ct(e) { let t, n, r; e = +e || _t; const i = () => { t = {}, n = {}, r = 0 }, a = (i, a) => (++r > e && (n = t, t = {}, r = 1), t[i] = a); return i(), { clear: i, has: e => ct(t, e) || ct(n, e), get: e => ct(t, e) ? t[e] : ct(n, e) ? a(e, n[e]) : void 0, set: (e, n) => ct(t, e) ? t[e] = n : a(e, n) } } function At(e, t, n, r) { const i = t.length, a = n.length; if (!a) return t; if (!i) return n; const o = r || new t.constructor(i + a); let s = 0, u = 0, l = 0; for (; s < i && u < a; ++l)o[l] = e(t[s], n[u]) > 0 ? n[u++] : t[s++]; for (; s < i; ++s, ++l)o[l] = t[s]; for (; u < a; ++u, ++l)o[l] = n[u]; return o } function Tt(e, t) { let n = ""; for (; --t >= 0;)n += e; return n } function Et(e, t, n, r) { const i = n || " ", a = e + "", o = t - a.length; return o <= 0 ? a : "left" === r ? Tt(i, o) + a : "center" === r ? Tt(i, ~~(o / 2)) + a + Tt(i, Math.ceil(o / 2)) : a + Tt(i, o) } function Nt(e) { return e && Ie(e) - e[0] || 0 } function It(e) { return _e(e) ? "[" + e.map(It) + "]" : Ce(e) || wt(e) ? JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029") : e } function Mt(e) { return null == e || "" === e ? null : !(!e || "false" === e || "0" === e) && !!e } const Ft = e => vt(e) || yt(e) ? e : Date.parse(e); function Dt(e, t) { return t = t || Ft, null == e || "" === e ? null : t(e) } function $t(e) { return null == e || "" === e ? null : e + "" } function Rt(e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t } function Ot(e, t, n, r) { const i = null != r ? r : "…", a = e + "", o = a.length, s = Math.max(0, t - i.length); return o <= t ? a : "left" === n ? i + a.slice(o - s) : "center" === n ? a.slice(0, Math.ceil(s / 2)) + i + a.slice(o - ~~(s / 2)) : a.slice(0, s) + i } function zt(e, t, n) { if (e) if (t) { const r = e.length; for (let i = 0; i < r; ++i) { const r = t(e[i]); r && n(r, i, e) } } else e.forEach(n) } function Pt(e, t, n) { return e.fields = t || [], e.fname = n, e } function Bt(e) { return null == e ? null : e.fname } function Lt(e) { return null == e ? null : e.fields } function jt(e) { return 1 === e.length ? Ut(e[0]) : Wt(e) } const Ut = e => function (t) { return t[e] }, Wt = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function Vt(e) { throw Error(e) } function Gt(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || Vt("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && Vt("Access path missing closing bracket: " + e), o && Vt("Access path missing closing quote: " + e), i > r && (i++, l()), t } function Ht(e, t, n) { const r = Gt(e); return e = 1 === r.length ? r[0] : e, Pt((n && n.get || jt)(r), [e], t || e) } const qt = Ht("id"), Yt = Pt((e => e), [], "identity"), Xt = Pt((() => 0), [], "zero"), Kt = Pt((() => 1), [], "one"), Zt = Pt((() => !0), [], "true"), Jt = Pt((() => !1), [], "false"); function Qt(e, t, n) { const r = [t].concat([].slice.call(n)); console[e].apply(console, r) } const en = 0, tn = 1, nn = 2, rn = 3, an = 4; var on = Array.isArray; function sn(e) { return e === Object(e) } const un = e => "__proto__" !== e; function ln(e, t, n, r) { if (!un(t)) return; let i, a; if (sn(n) && !on(n)) for (i in a = sn(e[t]) ? e[t] : e[t] = {}, n) r && (!0 === r || r[i]) ? ln(a, i, n[i]) : un(i) && (a[i] = n[i]); else e[t] = n } function cn(e, t) { if (null == e) return t; const n = {}, r = []; function i(e) { n[e.name] || (n[e.name] = 1, r.push(e)) } return t.forEach(i), e.forEach(i), r } function hn(e) { return e[e.length - 1] } function dn(e) { return null == e || "" === e ? null : +e } const fn = e => t => e * Math.exp(t), pn = e => t => Math.log(e * t), mn = e => t => Math.sign(t) * Math.log1p(Math.abs(t / e)), gn = e => t => Math.sign(t) * Math.expm1(Math.abs(t)) * e, yn = e => t => t < 0 ? -Math.pow(-t, e) : Math.pow(t, e); function bn(e, t, n, r) { const i = n(e[0]), a = n(hn(e)), o = (a - i) * t; return [r(i - o), r(a - o)] } function vn(e, t, n, r, i) { const a = r(e[0]), o = r(hn(e)), s = null != t ? r(t) : (a + o) / 2; return [i(s + (a - s) * n), i(s + (o - s) * n)] } function xn(e, t, n) { return vn(e, t, n, dn, Yt) } function wn(e, t, n) { const r = Math.sign(e[0]); return vn(e, t, n, pn(r), fn(r)) } function kn(e, t, n, r) { return vn(e, t, n, yn(r), yn(1 / r)) } function Sn(e, t, n, r) { return vn(e, t, n, mn(r), gn(r)) } function _n(e) { return null != e ? on(e) ? e : [e] : [] } function Cn(e) { return "function" == typeof e } const An = "descending"; function Tn(e, t, n) { n = n || {}, t = _n(t) || []; const r = [], i = [], a = {}, o = n.comparator || Nn; return _n(e).forEach(((e, o) => { null != e && (r.push(t[o] === An ? -1 : 1), i.push(e = Cn(e) ? e : Ht(e, null, n)), (Lt(e) || []).forEach((e => a[e] = 1))) })), 0 === i.length ? null : Pt(o(i, r), Object.keys(a)) } const En = (e, t) => (e < t || null == e) && null != t ? -1 : (e > t || null == t) && null != e ? 1 : (t = t instanceof Date ? +t : t, (e = e instanceof Date ? +e : e) !== e && t == t ? -1 : t != t && e == e ? 1 : 0), Nn = (e, t) => 1 === e.length ? In(e[0], t[0]) : Mn(e, t, e.length), In = (e, t) => function (n, r) { return En(e(n), e(r)) * t }, Mn = (e, t, n) => (t.push(0), function (r, i) { let a, o = 0, s = -1; for (; 0 === o && ++s < n;)a = e[s], o = En(a(r), a(i)); return o * t[s] }); function Fn(e) { return Cn(e) ? e : () => e } function Dn(e, t) { let n; return r => { n && clearTimeout(n), n = setTimeout((() => (t(r), n = null)), e) } } function $n(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } function Rn(e, t) { let n, r, i, a, o = 0; if (e && (n = e.length)) if (null == t) { for (r = e[o]; o < n && (null == r || r != r); r = e[++o]); for (i = a = r; o < n; ++o)r = e[o], null != r && (r < i && (i = r), r > a && (a = r)) } else { for (r = t(e[o]); o < n && (null == r || r != r); r = t(e[++o])); for (i = a = r; o < n; ++o)r = t(e[o]), null != r && (r < i && (i = r), r > a && (a = r)) } return [i, a] } const On = Object.prototype.hasOwnProperty; function zn(e, t) { return On.call(e, t) } const Pn = {}; function Bn(e) { let t, n = {}; function r(e) { return zn(n, e) && n[e] !== Pn } const i = { size: 0, empty: 0, object: n, has: r, get: e => r(e) ? n[e] : void 0, set(e, t) { return r(e) || (++i.size, n[e] === Pn && --i.empty), n[e] = t, this }, delete(e) { return r(e) && (--i.size, ++i.empty, n[e] = Pn), this }, clear() { i.size = i.empty = 0, i.object = n = {} }, test(e) { return arguments.length ? (t = e, i) : t }, clean() { const e = {}; let r = 0; for (const i in n) { const a = n[i]; a === Pn || t && t(a) || (e[i] = a, ++r) } i.size = r, i.empty = 0, i.object = n = e } }; return e && Object.keys(e).forEach((t => { i.set(t, e[t]) })), i } function Ln(e, t, n) { const r = e.prototype = Object.create(t.prototype); return Object.defineProperty(r, "constructor", { value: e, writable: !0, enumerable: !0, configurable: !0 }), $n(r, n) } function jn(e, t, n, r) { let i, a = t[0], o = t[t.length - 1]; return a > o && (i = a, a = o, o = i), r = void 0 === r || r, ((n = void 0 === n || n) ? a <= e : a < e) && (r ? e <= o : e < o) } function Un(e) { return "[object Date]" === Object.prototype.toString.call(e) } function Wn(e) { return "number" == typeof e } function Vn(e) { return "string" == typeof e } function Gn(e, t, n) { e && (e = t ? _n(e).map((e => e.replace(/\\(.)/g, "$1"))) : _n(e)); const r = e && e.length, i = n && n.get || jt, a = e => i(t ? [e] : Gt(e)); let o; if (r) if (1 === r) { const t = a(e[0]); o = function (e) { return "" + t(e) } } else { const t = e.map(a); o = function (e) { let n = "" + t[0](e), i = 0; for (; ++i < r;)n += "|" + t[i](e); return n } } else o = function () { return "" }; return Pt(o, e, "key") } function Hn(e, t) { let n = ""; for (; --t >= 0;)n += e; return n } function qn(e) { return e && hn(e) - e[0] || 0 } function Yn(e) { return on(e) ? "[" + e.map(Yn) + "]" : sn(e) || Vn(e) ? JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029") : e } function Xn(e) { return null == e || "" === e ? null : !(!e || "false" === e || "0" === e) && !!e } const Kn = e => Wn(e) || Un(e) ? e : Date.parse(e); function Zn(e, t) { return t = t || Kn, null == e || "" === e ? null : t(e) } function Jn(e) { return null == e || "" === e ? null : e + "" } function Qn(e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t } function er(e, t, n) { if (e) if (t) { const r = e.length; for (let i = 0; i < r; ++i) { const r = t(e[i]); r && n(r, i, e) } } else e.forEach(n) } var tr = {}, nr = {}; function rr(e) { return new Function("d", "return {" + e.map((function (e, t) { return JSON.stringify(e) + ": d[" + t + '] || ""' })).join(",") + "}") } function ir(e) { var t = Object.create(null), n = []; return e.forEach((function (e) { for (var r in e) r in t || n.push(t[r] = r) })), n } function ar(e, t) { var n = e + "", r = n.length; return r < t ? new Array(t - r + 1).join(0) + n : n } function or(e) { var t = e.getUTCHours(), n = e.getUTCMinutes(), r = e.getUTCSeconds(), i = e.getUTCMilliseconds(); return isNaN(e) ? "Invalid Date" : function (e) { return e < 0 ? "-" + ar(-e, 6) : e > 9999 ? "+" + ar(e, 6) : ar(e, 4) }(e.getUTCFullYear()) + "-" + ar(e.getUTCMonth() + 1, 2) + "-" + ar(e.getUTCDate(), 2) + (i ? "T" + ar(t, 2) + ":" + ar(n, 2) + ":" + ar(r, 2) + "." + ar(i, 3) + "Z" : r ? "T" + ar(t, 2) + ":" + ar(n, 2) + ":" + ar(r, 2) + "Z" : n || t ? "T" + ar(t, 2) + ":" + ar(n, 2) + "Z" : "") } function sr(e) { var t = new RegExp('["' + e + "\n\r]"), n = e.charCodeAt(0); function r(e, t) { var r, i = [], a = e.length, o = 0, s = 0, u = a <= 0, l = !1; function c() { if (u) return nr; if (l) return l = !1, tr; var t, r, i = o; if (34 === e.charCodeAt(i)) { for (; o++ < a && 34 !== e.charCodeAt(o) || 34 === e.charCodeAt(++o);); return (t = o) >= a ? u = !0 : 10 === (r = e.charCodeAt(o++)) ? l = !0 : 13 === r && (l = !0, 10 === e.charCodeAt(o) && ++o), e.slice(i + 1, t - 1).replace(/""/g, '"') } for (; o < a;) { if (10 === (r = e.charCodeAt(t = o++))) l = !0; else if (13 === r) l = !0, 10 === e.charCodeAt(o) && ++o; else if (r !== n) continue; return e.slice(i, t) } return u = !0, e.slice(i, a) } for (10 === e.charCodeAt(a - 1) && --a, 13 === e.charCodeAt(a - 1) && --a; (r = c()) !== nr;) { for (var h = []; r !== tr && r !== nr;)h.push(r), r = c(); t && null == (h = t(h, s++)) || i.push(h) } return i } function i(t, n) { return t.map((function (t) { return n.map((function (e) { return o(t[e]) })).join(e) })) } function a(t) { return t.map(o).join(e) } function o(e) { return null == e ? "" : e instanceof Date ? or(e) : t.test(e += "") ? '"' + e.replace(/"/g, '""') + '"' : e } return { parse: function (e, t) { var n, i, a = r(e, (function (e, r) { if (n) return n(e, r - 1); i = e, n = t ? function (e, t) { var n = rr(e); return function (r, i) { return t(n(r), i, e) } }(e, t) : rr(e) })); return a.columns = i || [], a }, parseRows: r, format: function (t, n) { return null == n && (n = ir(t)), [n.map(o).join(e)].concat(i(t, n)).join("\n") }, formatBody: function (e, t) { return null == t && (t = ir(e)), i(e, t).join("\n") }, formatRows: function (e) { return e.map(a).join("\n") }, formatRow: a, formatValue: o } } function ur(e) { return e } function lr(e, t) { return "string" == typeof t && (t = e.objects[t]), "GeometryCollection" === t.type ? { type: "FeatureCollection", features: t.geometries.map((function (t) { return cr(e, t) })) } : cr(e, t) } function cr(e, t) { var n = t.id, r = t.bbox, i = null == t.properties ? {} : t.properties, a = hr(e, t); return null == n && null == r ? { type: "Feature", properties: i, geometry: a } : null == r ? { type: "Feature", id: n, properties: i, geometry: a } : { type: "Feature", id: n, bbox: r, properties: i, geometry: a } } function hr(e, t) { var n = function (e) { if (null == e) return ur; var t, n, r = e.scale[0], i = e.scale[1], a = e.translate[0], o = e.translate[1]; return function (e, s) { s || (t = n = 0); var u = 2, l = e.length, c = new Array(l); for (c[0] = (t += e[0]) * r + a, c[1] = (n += e[1]) * i + o; u < l;)c[u] = e[u], ++u; return c } }(e.transform), r = e.arcs; function i(e, t) { t.length && t.pop(); for (var i = r[e < 0 ? ~e : e], a = 0, o = i.length; a < o; ++a)t.push(n(i[a], a)); e < 0 && function (e, t) { for (var n, r = e.length, i = r - t; i < --r;)n = e[i], e[i++] = e[r], e[r] = n }(t, o) } function a(e) { return n(e) } function o(e) { for (var t = [], n = 0, r = e.length; n < r; ++n)i(e[n], t); return t.length < 2 && t.push(t[0]), t } function s(e) { for (var t = o(e); t.length < 4;)t.push(t[0]); return t } function u(e) { return e.map(s) } return function e(t) { var n, r = t.type; switch (r) { case "GeometryCollection": return { type: r, geometries: t.geometries.map(e) }; case "Point": n = a(t.coordinates); break; case "MultiPoint": n = t.coordinates.map(a); break; case "LineString": n = o(t.arcs); break; case "MultiLineString": n = t.arcs.map(o); break; case "Polygon": n = u(t.arcs); break; case "MultiPolygon": n = t.arcs.map(u); break; default: return null }return { type: r, coordinates: n } }(t) } function dr(e, t) { var n = {}, r = {}, i = {}, a = [], o = -1; function s(e, t) { for (var r in e) { var i = e[r]; delete t[i.start], delete i.start, delete i.end, i.forEach((function (e) { n[e < 0 ? ~e : e] = 1 })), a.push(i) } } return t.forEach((function (n, r) { var i, a = e.arcs[n < 0 ? ~n : n]; a.length < 3 && !a[1][0] && !a[1][1] && (i = t[++o], t[o] = n, t[r] = i) })), t.forEach((function (t) { var n, a, o = function (t) { var n, r = e.arcs[t < 0 ? ~t : t], i = r[0]; e.transform ? (n = [0, 0], r.forEach((function (e) { n[0] += e[0], n[1] += e[1] }))) : n = r[r.length - 1]; return t < 0 ? [n, i] : [i, n] }(t), s = o[0], u = o[1]; if (n = i[s]) if (delete i[n.end], n.push(t), n.end = u, a = r[u]) { delete r[a.start]; var l = a === n ? n : n.concat(a); r[l.start = n.start] = i[l.end = a.end] = l } else r[n.start] = i[n.end] = n; else if (n = r[u]) if (delete r[n.start], n.unshift(t), n.start = s, a = i[s]) { delete i[a.end]; var c = a === n ? n : a.concat(n); r[c.start = a.start] = i[c.end = n.end] = c } else r[n.start] = i[n.end] = n; else r[(n = [t]).start = s] = i[n.end = u] = n })), s(i, r), s(r, i), t.forEach((function (e) { n[e < 0 ? ~e : e] || a.push([e]) })), a } function fr(e) { return hr(e, pr.apply(this, arguments)) } function pr(e, t, n) { var r, i, a; if (arguments.length > 1) r = function (e, t, n) { var r, i = [], a = []; function o(e) { var t = e < 0 ? ~e : e; (a[t] || (a[t] = [])).push({ i: e, g: r }) } function s(e) { e.forEach(o) } function u(e) { e.forEach(s) } function l(e) { e.forEach(u) } function c(e) { switch (r = e, e.type) { case "GeometryCollection": e.geometries.forEach(c); break; case "LineString": s(e.arcs); break; case "MultiLineString": case "Polygon": u(e.arcs); break; case "MultiPolygon": l(e.arcs) } } return c(t), a.forEach(null == n ? function (e) { i.push(e[0].i) } : function (e) { n(e[0].g, e[e.length - 1].g) && i.push(e[0].i) }), i }(0, t, n); else for (i = 0, r = new Array(a = e.arcs.length); i < a; ++i)r[i] = i; return { type: "MultiLineString", arcs: dr(e, r) } } const mr = Math.sqrt(50), gr = Math.sqrt(10), yr = Math.sqrt(2); function br(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= mr ? 10 : a >= gr ? 5 : a >= yr ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? br(e, t, 2 * n) : [s, u, l] } function vr(e, t, n) { return br(e = +e, t = +t, n = +n)[2] } var xr, wr = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; function kr(e) { if (!(t = wr.exec(e))) throw new Error("invalid format: " + e); var t; return new Sr({ fill: t[1], align: t[2], sign: t[3], symbol: t[4], zero: t[5], width: t[6], comma: t[7], precision: t[8] && t[8].slice(1), trim: t[9], type: t[10] }) } function Sr(e) { this.fill = void 0 === e.fill ? " " : e.fill + "", this.align = void 0 === e.align ? ">" : e.align + "", this.sign = void 0 === e.sign ? "-" : e.sign + "", this.symbol = void 0 === e.symbol ? "" : e.symbol + "", this.zero = !!e.zero, this.width = void 0 === e.width ? void 0 : +e.width, this.comma = !!e.comma, this.precision = void 0 === e.precision ? void 0 : +e.precision, this.trim = !!e.trim, this.type = void 0 === e.type ? "" : e.type + "" } function _r(e, t) { if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null; var n, r = e.slice(0, n); return [r.length > 1 ? r[0] + r.slice(2) : r, +e.slice(n + 1)] } function Cr(e) { return (e = _r(Math.abs(e))) ? e[1] : NaN } function Ar(e, t) { return Math.max(0, 3 * Math.max(-8, Math.min(8, Math.floor(Cr(t) / 3))) - Cr(Math.abs(e))) } function Tr(e, t) { return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Cr(t) - Cr(e)) + 1 } function Er(e) { return Math.max(0, -Cr(Math.abs(e))) } function Nr(e, t) { var n = _r(e, t); if (!n) return e + ""; var r = n[0], i = n[1]; return i < 0 ? "0." + new Array(-i).join("0") + r : r.length > i + 1 ? r.slice(0, i + 1) + "." + r.slice(i + 1) : r + new Array(i - r.length + 2).join("0") } kr.prototype = Sr.prototype, Sr.prototype.toString = function () { return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (void 0 === this.width ? "" : Math.max(1, 0 | this.width)) + (this.comma ? "," : "") + (void 0 === this.precision ? "" : "." + Math.max(0, 0 | this.precision)) + (this.trim ? "~" : "") + this.type }; const Ir = { "%": (e, t) => (100 * e).toFixed(t), b: e => Math.round(e).toString(2), c: e => e + "", d: function (e) { return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10) }, e: (e, t) => e.toExponential(t), f: (e, t) => e.toFixed(t), g: (e, t) => e.toPrecision(t), o: e => Math.round(e).toString(8), p: (e, t) => Nr(100 * e, t), r: Nr, s: function (e, t) { var n = _r(e, t); if (!n) return e + ""; var r = n[0], i = n[1], a = i - (xr = 3 * Math.max(-8, Math.min(8, Math.floor(i / 3)))) + 1, o = r.length; return a === o ? r : a > o ? r + new Array(a - o + 1).join("0") : a > 0 ? r.slice(0, a) + "." + r.slice(a) : "0." + new Array(1 - a).join("0") + _r(e, Math.max(0, t + a - 1))[0] }, X: e => Math.round(e).toString(16).toUpperCase(), x: e => Math.round(e).toString(16) }; function Mr(e) { return e } var Fr, Dr, $r, Rr = Array.prototype.map, Or = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; function zr(e) { var t, n, r = void 0 === e.grouping || void 0 === e.thousands ? Mr : (t = Rr.call(e.grouping, Number), n = e.thousands + "", function (e, r) { for (var i = e.length, a = [], o = 0, s = t[0], u = 0; i > 0 && s > 0 && (u + s + 1 > r && (s = Math.max(1, r - u)), a.push(e.substring(i -= s, i + s)), !((u += s + 1) > r));)s = t[o = (o + 1) % t.length]; return a.reverse().join(n) }), i = void 0 === e.currency ? "" : e.currency[0] + "", a = void 0 === e.currency ? "" : e.currency[1] + "", o = void 0 === e.decimal ? "." : e.decimal + "", s = void 0 === e.numerals ? Mr : function (e) { return function (t) { return t.replace(/[0-9]/g, (function (t) { return e[+t] })) } }(Rr.call(e.numerals, String)), u = void 0 === e.percent ? "%" : e.percent + "", l = void 0 === e.minus ? "−" : e.minus + "", c = void 0 === e.nan ? "NaN" : e.nan + ""; function h(e) { var t = (e = kr(e)).fill, n = e.align, h = e.sign, d = e.symbol, f = e.zero, p = e.width, m = e.comma, g = e.precision, y = e.trim, b = e.type; "n" === b ? (m = !0, b = "g") : Ir[b] || (void 0 === g && (g = 12), y = !0, b = "g"), (f || "0" === t && "=" === n) && (f = !0, t = "0", n = "="); var v = "$" === d ? i : "#" === d && /[boxX]/.test(b) ? "0" + b.toLowerCase() : "", x = "$" === d ? a : /[%p]/.test(b) ? u : "", w = Ir[b], k = /[defgprs%]/.test(b); function S(e) { var i, a, u, d = v, S = x; if ("c" === b) S = w(e) + S, e = ""; else { var _ = (e = +e) < 0 || 1 / e < 0; if (e = isNaN(e) ? c : w(Math.abs(e), g), y && (e = function (e) { e: for (var t, n = e.length, r = 1, i = -1; r < n; ++r)switch (e[r]) { case ".": i = t = r; break; case "0": 0 === i && (i = r), t = r; break; default: if (!+e[r]) break e; i > 0 && (i = 0) }return i > 0 ? e.slice(0, i) + e.slice(t + 1) : e }(e)), _ && 0 == +e && "+" !== h && (_ = !1), d = (_ ? "(" === h ? h : l : "-" === h || "(" === h ? "" : h) + d, S = ("s" === b ? Or[8 + xr / 3] : "") + S + (_ && "(" === h ? ")" : ""), k) for (i = -1, a = e.length; ++i < a;)if (48 > (u = e.charCodeAt(i)) || u > 57) { S = (46 === u ? o + e.slice(i + 1) : e.slice(i)) + S, e = e.slice(0, i); break } } m && !f && (e = r(e, 1 / 0)); var C = d.length + e.length + S.length, A = C < p ? new Array(p - C + 1).join(t) : ""; switch (m && f && (e = r(A + e, A.length ? p - S.length : 1 / 0), A = ""), n) { case "<": e = d + e + S + A; break; case "=": e = d + A + e + S; break; case "^": e = A.slice(0, C = A.length >> 1) + d + e + S + A.slice(C); break; default: e = A + d + e + S }return s(e) } return g = void 0 === g ? 6 : /[gprs]/.test(b) ? Math.max(1, Math.min(21, g)) : Math.max(0, Math.min(20, g)), S.toString = function () { return e + "" }, S } return { format: h, formatPrefix: function (e, t) { var n = h(((e = kr(e)).type = "f", e)), r = 3 * Math.max(-8, Math.min(8, Math.floor(Cr(t) / 3))), i = Math.pow(10, -r), a = Or[8 + r / 3]; return function (e) { return n(i * e) + a } } } } !function (e) { Fr = zr(e), Dr = Fr.format, $r = Fr.formatPrefix }({ thousands: ",", grouping: [3], currency: ["$", ""] }); const Pr = new Date, Br = new Date; function Lr(e, t, n, r) { function i(t) { return e(t = 0 === arguments.length ? new Date : new Date(+t)), t } return i.floor = t => (e(t = new Date(+t)), t), i.ceil = n => (e(n = new Date(n - 1)), t(n, 1), e(n), n), i.round = e => { const t = i(e), n = i.ceil(e); return e - t < n - e ? t : n }, i.offset = (e, n) => (t(e = new Date(+e), null == n ? 1 : Math.floor(n)), e), i.range = (n, r, a) => { const o = []; if (n = i.ceil(n), a = null == a ? 1 : Math.floor(a), !(n < r && a > 0)) return o; let s; do { o.push(s = new Date(+n)), t(n, a), e(n) } while (s < n && n < r); return o }, i.filter = n => Lr((t => { if (t >= t) for (; e(t), !n(t);)t.setTime(t - 1) }), ((e, r) => { if (e >= e) if (r < 0) for (; ++r <= 0;)for (; t(e, -1), !n(e);); else for (; --r >= 0;)for (; t(e, 1), !n(e);); })), n && (i.count = (t, r) => (Pr.setTime(+t), Br.setTime(+r), e(Pr), e(Br), Math.floor(n(Pr, Br))), i.every = e => (e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? i.filter(r ? t => r(t) % e == 0 : t => i.count(0, t) % e == 0) : i : null)), i } const jr = 1e3, Ur = 6e4, Wr = 36e5, Vr = 864e5, Gr = 6048e5, Hr = 2592e6, qr = 31536e6, Yr = Lr((e => e.setHours(0, 0, 0, 0)), ((e, t) => e.setDate(e.getDate() + t)), ((e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Ur) / Vr), (e => e.getDate() - 1)), Xr = (Yr.range, Lr((e => { e.setUTCHours(0, 0, 0, 0) }), ((e, t) => { e.setUTCDate(e.getUTCDate() + t) }), ((e, t) => (t - e) / Vr), (e => e.getUTCDate() - 1))), Kr = (Xr.range, Lr((e => { e.setUTCHours(0, 0, 0, 0) }), ((e, t) => { e.setUTCDate(e.getUTCDate() + t) }), ((e, t) => (t - e) / Vr), (e => Math.floor(e / Vr)))); Kr.range; function Zr(e) { return Lr((t => { t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0) }), ((e, t) => { e.setDate(e.getDate() + 7 * t) }), ((e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Ur) / Gr)) } const Jr = Zr(0), Qr = Zr(1), ei = Zr(2), ti = Zr(3), ni = Zr(4), ri = Zr(5), ii = Zr(6); Jr.range, Qr.range, ei.range, ti.range, ni.range, ri.range, ii.range; function ai(e) { return Lr((t => { t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0) }), ((e, t) => { e.setUTCDate(e.getUTCDate() + 7 * t) }), ((e, t) => (t - e) / Gr)) } const oi = ai(0), si = ai(1), ui = ai(2), li = ai(3), ci = ai(4), hi = ai(5), di = ai(6), fi = (oi.range, si.range, ui.range, li.range, ci.range, hi.range, di.range, Lr((e => { e.setMonth(0, 1), e.setHours(0, 0, 0, 0) }), ((e, t) => { e.setFullYear(e.getFullYear() + t) }), ((e, t) => t.getFullYear() - e.getFullYear()), (e => e.getFullYear()))); fi.every = e => isFinite(e = Math.floor(e)) && e > 0 ? Lr((t => { t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0) }), ((t, n) => { t.setFullYear(t.getFullYear() + n * e) })) : null; fi.range; const pi = Lr((e => { e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0) }), ((e, t) => { e.setUTCFullYear(e.getUTCFullYear() + t) }), ((e, t) => t.getUTCFullYear() - e.getUTCFullYear()), (e => e.getUTCFullYear())); pi.every = e => isFinite(e = Math.floor(e)) && e > 0 ? Lr((t => { t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0) }), ((t, n) => { t.setUTCFullYear(t.getUTCFullYear() + n * e) })) : null; pi.range; const mi = Lr((e => { e.setDate(1), e.setHours(0, 0, 0, 0) }), ((e, t) => { e.setMonth(e.getMonth() + t) }), ((e, t) => t.getMonth() - e.getMonth() + 12 * (t.getFullYear() - e.getFullYear())), (e => e.getMonth())), gi = (mi.range, Lr((e => { e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0) }), ((e, t) => { e.setUTCMonth(e.getUTCMonth() + t) }), ((e, t) => t.getUTCMonth() - e.getUTCMonth() + 12 * (t.getUTCFullYear() - e.getUTCFullYear())), (e => e.getUTCMonth()))), yi = (gi.range, Lr((e => { e.setTime(e - e.getMilliseconds() - e.getSeconds() * jr - e.getMinutes() * Ur) }), ((e, t) => { e.setTime(+e + t * Wr) }), ((e, t) => (t - e) / Wr), (e => e.getHours()))), bi = (yi.range, Lr((e => { e.setUTCMinutes(0, 0, 0) }), ((e, t) => { e.setTime(+e + t * Wr) }), ((e, t) => (t - e) / Wr), (e => e.getUTCHours()))), vi = (bi.range, Lr((e => { e.setTime(e - e.getMilliseconds() - e.getSeconds() * jr) }), ((e, t) => { e.setTime(+e + t * Ur) }), ((e, t) => (t - e) / Ur), (e => e.getMinutes()))), xi = (vi.range, Lr((e => { e.setUTCSeconds(0, 0) }), ((e, t) => { e.setTime(+e + t * Ur) }), ((e, t) => (t - e) / Ur), (e => e.getUTCMinutes()))), wi = (xi.range, Lr((e => { e.setTime(e - e.getMilliseconds()) }), ((e, t) => { e.setTime(+e + t * jr) }), ((e, t) => (t - e) / jr), (e => e.getUTCSeconds()))), ki = (wi.range, Lr((() => { }), ((e, t) => { e.setTime(+e + t) }), ((e, t) => t - e))); ki.every = e => (e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? Lr((t => { t.setTime(Math.floor(t / e) * e) }), ((t, n) => { t.setTime(+t + n * e) }), ((t, n) => (n - t) / e)) : ki : null); ki.range; function Si(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function _i(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function Ci() { return 0 } const Ai = Math.sqrt(50), Ti = Math.sqrt(10), Ei = Math.sqrt(2); function Ni(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= Ai ? 10 : a >= Ti ? 5 : a >= Ei ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? Ni(e, t, 2 * n) : [s, u, l] } function Ii(e, t, n) { return Ni(e = +e, t = +t, n = +n)[2] } function Mi(e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? Ii(t, e, n) : Ii(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) } const Fi = "year", Di = "quarter", $i = "month", Ri = "week", Oi = "date", zi = "day", Pi = "dayofyear", Bi = "hours", Li = "minutes", ji = "seconds", Ui = "milliseconds", Wi = [Fi, Di, $i, Ri, Oi, zi, Pi, Bi, Li, ji, Ui], Vi = Wi.reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); function Gi(e) { const t = _n(e).slice(), n = {}; t.length || Vt("Missing time unit."), t.forEach((e => { zn(Vi, e) ? n[e] = 1 : Vt(`Invalid time unit: ${e}.`) })); return (n[Ri] || n[zi] ? 1 : 0) + (n[Di] || n[$i] || n[Oi] ? 1 : 0) + (n[Pi] ? 1 : 0) > 1 && Vt(`Incompatible time units: ${e}`), t.sort(((e, t) => Vi[e] - Vi[t])), t } const Hi = { [Fi]: "%Y ", [Di]: "Q%q ", [$i]: "%b ", [Oi]: "%d ", [Ri]: "W%U ", [zi]: "%a ", [Pi]: "%j ", [Bi]: "%H:00", [Li]: "00:%M", [ji]: ":%S", [Ui]: ".%L", [`${Fi}-${$i}`]: "%Y-%m ", [`${Fi}-${$i}-${Oi}`]: "%Y-%m-%d ", [`${Bi}-${Li}`]: "%H:%M" }; const qi = new Date; function Yi(e) { return qi.setFullYear(e), qi.setMonth(0), qi.setDate(1), qi.setHours(0, 0, 0, 0), qi } function Xi(e) { return Yr.count(Yi(e.getFullYear()) - 1, e) } function Ki(e) { return Jr.count(Yi(e.getFullYear()) - 1, e) } function Zi(e) { return Yi(e).getDay() } function Ji(e, t, n, r, i, a, o) { if (0 <= e && e < 100) { const s = new Date(-1, t, n, r, i, a, o); return s.setFullYear(e), s } return new Date(e, t, n, r, i, a, o) } function Qi(e) { const t = Date.UTC(e.getUTCFullYear(), 0, 1); return Xr.count(t - 1, e) } function ea(e) { const t = Date.UTC(e.getUTCFullYear(), 0, 1); return oi.count(t - 1, e) } function ta(e) { return qi.setTime(Date.UTC(e, 0, 1)), qi.getUTCDay() } function na(e, t, n, r, i, a, o) { if (0 <= e && e < 100) { const e = new Date(Date.UTC(-1, t, n, r, i, a, o)); return e.setUTCFullYear(n.y), e } return new Date(Date.UTC(e, t, n, r, i, a, o)) } function ra(e, t, n, r, i) { const a = t || 1, o = hn(e), s = (e, t, i) => function (e, t, n, r) { const i = n <= 1 ? e : r ? (t, i) => r + n * Math.floor((e(t, i) - r) / n) : (t, r) => n * Math.floor(e(t, r) / n); return t ? (e, n) => t(i(e, n), n) : i }(n[i = i || e], r[i], e === o && a, t), u = new Date, l = Qn(e), c = l[Fi] ? s(Fi) : Fn(2012), h = l[$i] ? s($i) : l[Di] ? s(Di) : Xt, d = l[Ri] && l[zi] ? s(zi, 1, Ri + zi) : l[Ri] ? s(Ri, 1) : l[zi] ? s(zi, 1) : l[Oi] ? s(Oi, 1) : l[Pi] ? s(Pi, 1) : Kt, f = l[Bi] ? s(Bi) : Xt, p = l[Li] ? s(Li) : Xt, m = l[ji] ? s(ji) : Xt, g = l[Ui] ? s(Ui) : Xt; return function (e) { u.setTime(+e); const t = c(u); return i(t, h(u), d(u, t), f(u), p(u), m(u), g(u)) } } function ia(e, t, n) { return t + 7 * e - (n + 6) % 7 } const aa = { [Fi]: e => e.getFullYear(), [Di]: e => Math.floor(e.getMonth() / 3), [$i]: e => e.getMonth(), [Oi]: e => e.getDate(), [Bi]: e => e.getHours(), [Li]: e => e.getMinutes(), [ji]: e => e.getSeconds(), [Ui]: e => e.getMilliseconds(), [Pi]: e => Xi(e), [Ri]: e => Ki(e), [Ri + zi]: (e, t) => ia(Ki(e), e.getDay(), Zi(t)), [zi]: (e, t) => ia(1, e.getDay(), Zi(t)) }, oa = { [Di]: e => 3 * e, [Ri]: (e, t) => ia(e, 0, Zi(t)) }; function sa(e, t) { return ra(e, t || 1, aa, oa, Ji) } const ua = { [Fi]: e => e.getUTCFullYear(), [Di]: e => Math.floor(e.getUTCMonth() / 3), [$i]: e => e.getUTCMonth(), [Oi]: e => e.getUTCDate(), [Bi]: e => e.getUTCHours(), [Li]: e => e.getUTCMinutes(), [ji]: e => e.getUTCSeconds(), [Ui]: e => e.getUTCMilliseconds(), [Pi]: e => Qi(e), [Ri]: e => ea(e), [zi]: (e, t) => ia(1, e.getUTCDay(), ta(t)), [Ri + zi]: (e, t) => ia(ea(e), e.getUTCDay(), ta(t)) }, la = { [Di]: e => 3 * e, [Ri]: (e, t) => ia(e, 0, ta(t)) }; function ca(e, t) { return ra(e, t || 1, ua, la, na) } const ha = { [Fi]: fi, [Di]: mi.every(3), [$i]: mi, [Ri]: Jr, [Oi]: Yr, [zi]: Yr, [Pi]: Yr, [Bi]: yi, [Li]: vi, [ji]: wi, [Ui]: ki }, da = { [Fi]: pi, [Di]: gi.every(3), [$i]: gi, [Ri]: oi, [Oi]: Xr, [zi]: Xr, [Pi]: Xr, [Bi]: bi, [Li]: xi, [ji]: wi, [Ui]: ki }; function fa(e) { return ha[e] } function pa(e) { return da[e] } function ma(e, t, n) { return e ? e.offset(t, n) : void 0 } function ga(e, t, n, r) { return e ? e.range(t, n, r) : void 0 } const ya = 1e3, ba = 6e4, va = 36e5, xa = 864e5, wa = 2592e6, ka = 31536e6, Sa = [Fi, $i, Oi, Bi, Li, ji, Ui], _a = Sa.slice(0, -1), Ca = _a.slice(0, -1), Aa = Ca.slice(0, -1), Ta = Aa.slice(0, -1), Ea = [Fi, $i], Na = [Fi], Ia = [[_a, 1, ya], [_a, 5, 5e3], [_a, 15, 15e3], [_a, 30, 3e4], [Ca, 1, ba], [Ca, 5, 3e5], [Ca, 15, 9e5], [Ca, 30, 18e5], [Aa, 1, va], [Aa, 3, 108e5], [Aa, 6, 216e5], [Aa, 12, 432e5], [Ta, 1, xa], [[Fi, Ri], 1, 6048e5], [Ea, 1, wa], [Ea, 3, 7776e6], [Na, 1, ka]]; function Ma(e) { const t = e.extent, n = e.maxbins || 40, r = Math.abs(qn(t)) / n; let i, a, o = function (e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = Si, n = (t, n) => Si(e(t), n), r = (t, n) => e(t) - n) : (t = e === Si || e === _i ? e : Ci, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } }((e => e[2])).right(Ia, r); return o === Ia.length ? (i = Na, a = Mi(t[0] / ka, t[1] / ka, n)) : o ? (o = Ia[r / Ia[o - 1][2] < Ia[o][2] / r ? o - 1 : o], i = o[0], a = o[1]) : (i = Sa, a = Math.max(Mi(t[0], t[1], n), 1)), { units: i, step: a } } function Fa(e) { if (0 <= e.y && e.y < 100) { var t = new Date(-1, e.m, e.d, e.H, e.M, e.S, e.L); return t.setFullYear(e.y), t } return new Date(e.y, e.m, e.d, e.H, e.M, e.S, e.L) } function Da(e) { if (0 <= e.y && e.y < 100) { var t = new Date(Date.UTC(-1, e.m, e.d, e.H, e.M, e.S, e.L)); return t.setUTCFullYear(e.y), t } return new Date(Date.UTC(e.y, e.m, e.d, e.H, e.M, e.S, e.L)) } function $a(e, t, n) { return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 } } function Ra(e) { var t = e.dateTime, n = e.date, r = e.time, i = e.periods, a = e.days, o = e.shortDays, s = e.months, u = e.shortMonths, l = qa(i), c = Ya(i), h = qa(a), d = Ya(a), f = qa(o), p = Ya(o), m = qa(s), g = Ya(s), y = qa(u), b = Ya(u), v = { a: function (e) { return o[e.getDay()] }, A: function (e) { return a[e.getDay()] }, b: function (e) { return u[e.getMonth()] }, B: function (e) { return s[e.getMonth()] }, c: null, d: go, e: go, f: wo, g: Fo, G: $o, H: yo, I: bo, j: vo, L: xo, m: ko, M: So, p: function (e) { return i[+(e.getHours() >= 12)] }, q: function (e) { return 1 + ~~(e.getMonth() / 3) }, Q: rs, s: is, S: _o, u: Co, U: Ao, V: Eo, w: No, W: Io, x: null, X: null, y: Mo, Y: Do, Z: Ro, "%": ns }, x = { a: function (e) { return o[e.getUTCDay()] }, A: function (e) { return a[e.getUTCDay()] }, b: function (e) { return u[e.getUTCMonth()] }, B: function (e) { return s[e.getUTCMonth()] }, c: null, d: Oo, e: Oo, f: jo, g: Jo, G: es, H: zo, I: Po, j: Bo, L: Lo, m: Uo, M: Wo, p: function (e) { return i[+(e.getUTCHours() >= 12)] }, q: function (e) { return 1 + ~~(e.getUTCMonth() / 3) }, Q: rs, s: is, S: Vo, u: Go, U: Ho, V: Yo, w: Xo, W: Ko, x: null, X: null, y: Zo, Y: Qo, Z: ts, "%": ns }, w = { a: function (e, t, n) { var r = f.exec(t.slice(n)); return r ? (e.w = p.get(r[0].toLowerCase()), n + r[0].length) : -1 }, A: function (e, t, n) { var r = h.exec(t.slice(n)); return r ? (e.w = d.get(r[0].toLowerCase()), n + r[0].length) : -1 }, b: function (e, t, n) { var r = y.exec(t.slice(n)); return r ? (e.m = b.get(r[0].toLowerCase()), n + r[0].length) : -1 }, B: function (e, t, n) { var r = m.exec(t.slice(n)); return r ? (e.m = g.get(r[0].toLowerCase()), n + r[0].length) : -1 }, c: function (e, n, r) { return _(e, t, n, r) }, d: ao, e: ao, f: ho, g: to, G: eo, H: so, I: so, j: oo, L: co, m: io, M: uo, p: function (e, t, n) { var r = l.exec(t.slice(n)); return r ? (e.p = c.get(r[0].toLowerCase()), n + r[0].length) : -1 }, q: ro, Q: po, s: mo, S: lo, u: Ka, U: Za, V: Ja, w: Xa, W: Qa, x: function (e, t, r) { return _(e, n, t, r) }, X: function (e, t, n) { return _(e, r, t, n) }, y: to, Y: eo, Z: no, "%": fo }; function k(e, t) { return function (n) { var r, i, a, o = [], s = -1, u = 0, l = e.length; for (n instanceof Date || (n = new Date(+n)); ++s < l;)37 === e.charCodeAt(s) && (o.push(e.slice(u, s)), null != (i = ja[r = e.charAt(++s)]) ? r = e.charAt(++s) : i = "e" === r ? " " : "0", (a = t[r]) && (r = a(n, i)), o.push(r), u = s + 1); return o.push(e.slice(u, s)), o.join("") } } function S(e, t) { return function (n) { var r, i, a = $a(1900, void 0, 1); if (_(a, e, n += "", 0) != n.length) return null; if ("Q" in a) return new Date(a.Q); if ("s" in a) return new Date(1e3 * a.s + ("L" in a ? a.L : 0)); if (t && !("Z" in a) && (a.Z = 0), "p" in a && (a.H = a.H % 12 + 12 * a.p), void 0 === a.m && (a.m = "q" in a ? a.q : 0), "V" in a) { if (a.V < 1 || a.V > 53) return null; "w" in a || (a.w = 1), "Z" in a ? (i = (r = Da($a(a.y, 0, 1))).getUTCDay(), r = i > 4 || 0 === i ? si.ceil(r) : si(r), r = Xr.offset(r, 7 * (a.V - 1)), a.y = r.getUTCFullYear(), a.m = r.getUTCMonth(), a.d = r.getUTCDate() + (a.w + 6) % 7) : (i = (r = Fa($a(a.y, 0, 1))).getDay(), r = i > 4 || 0 === i ? Qr.ceil(r) : Qr(r), r = Yr.offset(r, 7 * (a.V - 1)), a.y = r.getFullYear(), a.m = r.getMonth(), a.d = r.getDate() + (a.w + 6) % 7) } else ("W" in a || "U" in a) && ("w" in a || (a.w = "u" in a ? a.u % 7 : "W" in a ? 1 : 0), i = "Z" in a ? Da($a(a.y, 0, 1)).getUTCDay() : Fa($a(a.y, 0, 1)).getDay(), a.m = 0, a.d = "W" in a ? (a.w + 6) % 7 + 7 * a.W - (i + 5) % 7 : a.w + 7 * a.U - (i + 6) % 7); return "Z" in a ? (a.H += a.Z / 100 | 0, a.M += a.Z % 100, Da(a)) : Fa(a) } } function _(e, t, n, r) { for (var i, a, o = 0, s = t.length, u = n.length; o < s;) { if (r >= u) return -1; if (37 === (i = t.charCodeAt(o++))) { if (i = t.charAt(o++), !(a = w[i in ja ? t.charAt(o++) : i]) || (r = a(e, n, r)) < 0) return -1 } else if (i != n.charCodeAt(r++)) return -1 } return r } return v.x = k(n, v), v.X = k(r, v), v.c = k(t, v), x.x = k(n, x), x.X = k(r, x), x.c = k(t, x), { format: function (e) { var t = k(e += "", v); return t.toString = function () { return e }, t }, parse: function (e) { var t = S(e += "", !1); return t.toString = function () { return e }, t }, utcFormat: function (e) { var t = k(e += "", x); return t.toString = function () { return e }, t }, utcParse: function (e) { var t = S(e += "", !0); return t.toString = function () { return e }, t } } } var Oa, za, Pa, Ba, La, ja = { "-": "", _: " ", 0: "0" }, Ua = /^\s*\d+/, Wa = /^%/, Va = /[\\^$*+?|[\]().{}]/g; function Ga(e, t, n) { var r = e < 0 ? "-" : "", i = (r ? -e : e) + "", a = i.length; return r + (a < n ? new Array(n - a + 1).join(t) + i : i) } function Ha(e) { return e.replace(Va, "\\$&") } function qa(e) { return new RegExp("^(?:" + e.map(Ha).join("|") + ")", "i") } function Ya(e) { return new Map(e.map(((e, t) => [e.toLowerCase(), t]))) } function Xa(e, t, n) { var r = Ua.exec(t.slice(n, n + 1)); return r ? (e.w = +r[0], n + r[0].length) : -1 } function Ka(e, t, n) { var r = Ua.exec(t.slice(n, n + 1)); return r ? (e.u = +r[0], n + r[0].length) : -1 } function Za(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.U = +r[0], n + r[0].length) : -1 } function Ja(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.V = +r[0], n + r[0].length) : -1 } function Qa(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.W = +r[0], n + r[0].length) : -1 } function eo(e, t, n) { var r = Ua.exec(t.slice(n, n + 4)); return r ? (e.y = +r[0], n + r[0].length) : -1 } function to(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1 } function no(e, t, n) { var r = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6)); return r ? (e.Z = r[1] ? 0 : -(r[2] + (r[3] || "00")), n + r[0].length) : -1 } function ro(e, t, n) { var r = Ua.exec(t.slice(n, n + 1)); return r ? (e.q = 3 * r[0] - 3, n + r[0].length) : -1 } function io(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.m = r[0] - 1, n + r[0].length) : -1 } function ao(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.d = +r[0], n + r[0].length) : -1 } function oo(e, t, n) { var r = Ua.exec(t.slice(n, n + 3)); return r ? (e.m = 0, e.d = +r[0], n + r[0].length) : -1 } function so(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.H = +r[0], n + r[0].length) : -1 } function uo(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.M = +r[0], n + r[0].length) : -1 } function lo(e, t, n) { var r = Ua.exec(t.slice(n, n + 2)); return r ? (e.S = +r[0], n + r[0].length) : -1 } function co(e, t, n) { var r = Ua.exec(t.slice(n, n + 3)); return r ? (e.L = +r[0], n + r[0].length) : -1 } function ho(e, t, n) { var r = Ua.exec(t.slice(n, n + 6)); return r ? (e.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1 } function fo(e, t, n) { var r = Wa.exec(t.slice(n, n + 1)); return r ? n + r[0].length : -1 } function po(e, t, n) { var r = Ua.exec(t.slice(n)); return r ? (e.Q = +r[0], n + r[0].length) : -1 } function mo(e, t, n) { var r = Ua.exec(t.slice(n)); return r ? (e.s = +r[0], n + r[0].length) : -1 } function go(e, t) { return Ga(e.getDate(), t, 2) } function yo(e, t) { return Ga(e.getHours(), t, 2) } function bo(e, t) { return Ga(e.getHours() % 12 || 12, t, 2) } function vo(e, t) { return Ga(1 + Yr.count(fi(e), e), t, 3) } function xo(e, t) { return Ga(e.getMilliseconds(), t, 3) } function wo(e, t) { return xo(e, t) + "000" } function ko(e, t) { return Ga(e.getMonth() + 1, t, 2) } function So(e, t) { return Ga(e.getMinutes(), t, 2) } function _o(e, t) { return Ga(e.getSeconds(), t, 2) } function Co(e) { var t = e.getDay(); return 0 === t ? 7 : t } function Ao(e, t) { return Ga(Jr.count(fi(e) - 1, e), t, 2) } function To(e) { var t = e.getDay(); return t >= 4 || 0 === t ? ni(e) : ni.ceil(e) } function Eo(e, t) { return e = To(e), Ga(ni.count(fi(e), e) + (4 === fi(e).getDay()), t, 2) } function No(e) { return e.getDay() } function Io(e, t) { return Ga(Qr.count(fi(e) - 1, e), t, 2) } function Mo(e, t) { return Ga(e.getFullYear() % 100, t, 2) } function Fo(e, t) { return Ga((e = To(e)).getFullYear() % 100, t, 2) } function Do(e, t) { return Ga(e.getFullYear() % 1e4, t, 4) } function $o(e, t) { var n = e.getDay(); return Ga((e = n >= 4 || 0 === n ? ni(e) : ni.ceil(e)).getFullYear() % 1e4, t, 4) } function Ro(e) { var t = e.getTimezoneOffset(); return (t > 0 ? "-" : (t *= -1, "+")) + Ga(t / 60 | 0, "0", 2) + Ga(t % 60, "0", 2) } function Oo(e, t) { return Ga(e.getUTCDate(), t, 2) } function zo(e, t) { return Ga(e.getUTCHours(), t, 2) } function Po(e, t) { return Ga(e.getUTCHours() % 12 || 12, t, 2) } function Bo(e, t) { return Ga(1 + Xr.count(pi(e), e), t, 3) } function Lo(e, t) { return Ga(e.getUTCMilliseconds(), t, 3) } function jo(e, t) { return Lo(e, t) + "000" } function Uo(e, t) { return Ga(e.getUTCMonth() + 1, t, 2) } function Wo(e, t) { return Ga(e.getUTCMinutes(), t, 2) } function Vo(e, t) { return Ga(e.getUTCSeconds(), t, 2) } function Go(e) { var t = e.getUTCDay(); return 0 === t ? 7 : t } function Ho(e, t) { return Ga(oi.count(pi(e) - 1, e), t, 2) } function qo(e) { var t = e.getUTCDay(); return t >= 4 || 0 === t ? ci(e) : ci.ceil(e) } function Yo(e, t) { return e = qo(e), Ga(ci.count(pi(e), e) + (4 === pi(e).getUTCDay()), t, 2) } function Xo(e) { return e.getUTCDay() } function Ko(e, t) { return Ga(si.count(pi(e) - 1, e), t, 2) } function Zo(e, t) { return Ga(e.getUTCFullYear() % 100, t, 2) } function Jo(e, t) { return Ga((e = qo(e)).getUTCFullYear() % 100, t, 2) } function Qo(e, t) { return Ga(e.getUTCFullYear() % 1e4, t, 4) } function es(e, t) { var n = e.getUTCDay(); return Ga((e = n >= 4 || 0 === n ? ci(e) : ci.ceil(e)).getUTCFullYear() % 1e4, t, 4) } function ts() { return "+0000" } function ns() { return "%" } function rs(e) { return +e } function is(e) { return Math.floor(+e / 1e3) } function as(e) { const t = {}; return n => t[n] || (t[n] = e(n)) } function os(e) { const t = as(e.format), n = e.formatPrefix; return { format: t, formatPrefix: n, formatFloat(e) { const n = kr(e || ","); if (null == n.precision) { switch (n.precision = 12, n.type) { case "%": n.precision -= 2; break; case "e": n.precision -= 1 }return function (e, t) { return n => { const r = e(n), i = r.indexOf(t); if (i < 0) return r; let a = function (e, t) { let n, r = e.lastIndexOf("e"); if (r > 0) return r; for (r = e.length; --r > t;)if (n = e.charCodeAt(r), n >= 48 && n <= 57) return r + 1 }(r, i); const o = a < r.length ? r.slice(a) : ""; for (; --a > i;)if ("0" !== r[a]) { ++a; break } return r.slice(0, a) + o } }(t(n), t(".1f")(1)[1]) } return t(n) }, formatSpan(e, r, i, a) { a = kr(null == a ? ",f" : a); const o = function (e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? vr(t, e, n) : vr(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) }(e, r, i), s = Math.max(Math.abs(e), Math.abs(r)); let u; if (null == a.precision) switch (a.type) { case "s": return isNaN(u = Ar(o, s)) || (a.precision = u), n(a, s); case "": case "e": case "g": case "p": case "r": isNaN(u = Tr(o, s)) || (a.precision = u - ("e" === a.type)); break; case "f": case "%": isNaN(u = Er(o)) || (a.precision = u - 2 * ("%" === a.type)) }return t(a) } } } let ss, us; function ls() { return ss = os({ format: Dr, formatPrefix: $r }) } function cs(e) { return os(zr(e)) } function hs(e) { return arguments.length ? ss = cs(e) : ss } function ds(e, t, n) { sn(n = n || {}) || Vt(`Invalid time multi-format specifier: ${n}`); const r = t(ji), i = t(Li), a = t(Bi), o = t(Oi), s = t(Ri), u = t($i), l = t(Di), c = t(Fi), h = e(n[Ui] || ".%L"), d = e(n[ji] || ":%S"), f = e(n[Li] || "%I:%M"), p = e(n[Bi] || "%I %p"), m = e(n[Oi] || n[zi] || "%a %d"), g = e(n[Ri] || "%b %d"), y = e(n[$i] || "%B"), b = e(n[Di] || "%B"), v = e(n[Fi] || "%Y"); return e => (r(e) < e ? h : i(e) < e ? d : a(e) < e ? f : o(e) < e ? p : u(e) < e ? s(e) < e ? m : g : c(e) < e ? l(e) < e ? y : b : v)(e) } function fs(e) { const t = as(e.format), n = as(e.utcFormat); return { timeFormat: e => Vn(e) ? t(e) : ds(t, fa, e), utcFormat: e => Vn(e) ? n(e) : ds(n, pa, e), timeParse: as(e.parse), utcParse: as(e.utcParse) } } function ps() { return us = fs({ format: za, parse: Pa, utcFormat: Ba, utcParse: La }) } function ms(e) { return fs(Ra(e)) } function gs(e) { return arguments.length ? us = ms(e) : us } !function (e) { Oa = Ra(e), za = Oa.format, Pa = Oa.parse, Ba = Oa.utcFormat, La = Oa.utcParse }({ dateTime: "%x, %X", date: "%-m/%-d/%Y", time: "%-I:%M:%S %p", periods: ["AM", "PM"], days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }), ls(), ps(); const ys = (e, t) => $n({}, e, t); function bs(e, t) { const n = arguments.length; return n && 2 !== n && Vt("defaultLocale expects either zero or two arguments."), n ? ys(hs(e), gs(t)) : ys(hs(), gs()) } const vs = /^(data:|([A-Za-z]+:)?\/\/)/, xs = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i, ws = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g, ks = "file://"; async function Ss(e, t) { const n = await this.sanitize(e, t), r = n.href; return n.localFile ? this.file(r) : this.http(r, t) } async function _s(e, t) { t = $n({}, this.options, t); const n = this.fileAccess, r = { href: null }; let i, a, o; const s = xs.test(e.replace(ws, "")); null != e && "string" == typeof e && s || Vt("Sanitize failure, invalid URI: " + Yn(e)); const u = vs.test(e); return (o = t.baseURL) && !u && (e.startsWith("/") || o.endsWith("/") || (e = "/" + e), e = o + e), a = (i = e.startsWith(ks)) || "file" === t.mode || "http" !== t.mode && !u && n, i ? e = e.slice(7) : e.startsWith("//") && ("file" === t.defaultProtocol ? (e = e.slice(2), a = !0) : e = (t.defaultProtocol || "http") + ":" + e), Object.defineProperty(r, "localFile", { value: !!a }), r.href = e, t.target && (r.target = t.target + ""), t.rel && (r.rel = t.rel + ""), "image" === t.context && t.crossOrigin && (r.crossOrigin = t.crossOrigin + ""), r } function Cs(e) { return e ? t => new Promise(((n, r) => { e.readFile(t, ((e, t) => { e ? r(e) : n(t) })) })) : As } async function As() { Vt("No file system access.") } function Ts(e) { return e ? async function (t, n) { const r = $n({}, this.options.http, n), i = n && n.response, a = await e(t, r); return a.ok ? Cn(a[i]) ? a[i]() : a.text() : Vt(a.status + "" + a.statusText) } : Es } async function Es() { Vt("No HTTP fetch method available.") } const Ns = e => !(Number.isNaN(+e) || e instanceof Date), Is = { boolean: Xn, integer: dn, number: dn, date: Zn, string: Jn, unknown: Yt }, Ms = [e => "true" === e || "false" === e || !0 === e || !1 === e, e => Ns(e) && Number.isInteger(+e), Ns, e => !Number.isNaN(Date.parse(e))], Fs = ["boolean", "integer", "number", "date"]; function Ds(e, t) { return t.reduce(((t, n) => (t[n] = function (e, t) { if (!e || !e.length) return "unknown"; const n = e.length, r = Ms.length, i = Ms.map(((e, t) => t + 1)); for (let o, s, u = 0, l = 0; u < n; ++u)for (s = t ? e[u][t] : e[u], o = 0; o < r; ++o)if (i[o] && null != (a = s) && a == a && !Ms[o](s) && (i[o] = 0, ++l, l === Ms.length)) return "string"; var a; return Fs[i.reduce(((e, t) => 0 === e ? t : e), 0) - 1] }(e, n), t)), {}) } function $s(e) { const t = function (t, n) { const r = { delimiter: e }; return Rs(t, n ? $n(n, r) : r) }; return t.responseType = "text", t } function Rs(e, t) { return t.header && (e = t.header.map(Yn).join(t.delimiter) + "\n" + e), sr(t.delimiter).parse(e + "") } function Os(e, t) { const n = t && t.property ? Ht(t.property) : Yt; return !sn(e) || (r = e, "function" == typeof Buffer && Cn(Buffer.isBuffer) && Buffer.isBuffer(r)) ? n(JSON.parse(e)) : function (e, t) { !on(e) && function (e) { return e && Cn(e[Symbol.iterator]) }(e) && (e = [...e]); return t && t.copy ? JSON.parse(JSON.stringify(e)) : e }(n(e), t); var r } Rs.responseType = "text", Os.responseType = "json"; const zs = { interior: (e, t) => e !== t, exterior: (e, t) => e === t }; function Ps(e, t) { let n, r, i, a; return e = Os(e, t), t && t.feature ? (n = lr, i = t.feature) : t && t.mesh ? (n = fr, i = t.mesh, a = zs[t.filter]) : Vt("Missing TopoJSON feature or mesh parameter."), r = (r = e.objects[i]) ? n(e, r, a) : Vt("Invalid TopoJSON object: " + i), r && r.features || [r] } Ps.responseType = "json"; const Bs = { dsv: Rs, csv: $s(","), tsv: $s("\t"), json: Os, topojson: Ps }; function Ls(e, t) { return arguments.length > 1 ? (Bs[e] = t, this) : zn(Bs, e) ? Bs[e] : null } function js(e) { const t = Ls(e); return t && t.responseType || "text" } function Us(e, t, n, r) { const i = Ls((t = t || {}).type || "json"); return i || Vt("Unknown data format type: " + t.type), e = i(e, t), t.parse && function (e, t, n, r) { if (!e.length) return; const i = gs(); n = n || i.timeParse, r = r || i.utcParse; let a, o, s, u, l, c, h = e.columns || Object.keys(e[0]); "auto" === t && (t = Ds(e, h)); h = Object.keys(t); const d = h.map((e => { const i = t[e]; let a, o; if (i && (i.startsWith("date:") || i.startsWith("utc:"))) { a = i.split(/:(.+)?/, 2), o = a[1], ("'" === o[0] && "'" === o[o.length - 1] || '"' === o[0] && '"' === o[o.length - 1]) && (o = o.slice(1, -1)); return ("utc" === a[0] ? r : n)(o) } if (!Is[i]) throw Error("Illegal format pattern: " + e + ":" + i); return Is[i] })); for (s = 0, l = e.length, c = h.length; s < l; ++s)for (a = e[s], u = 0; u < c; ++u)o = h[u], a[o] = d[u](a[o]) }(e, t.parse, n, r), zn(e, "columns") && delete e.columns, e } const Ws = function (e, t) { return n => ({ options: n || {}, sanitize: _s, load: Ss, fileAccess: !!t, file: Cs(t), http: Ts(e) }) }("undefined" != typeof fetch && fetch, null); function Vs(e) { const t = e || Yt, n = [], r = {}; return n.add = e => { const i = t(e); return r[i] || (r[i] = 1, n.push(e)), n }, n.remove = e => { const i = t(e); if (r[i]) { r[i] = 0; const t = n.indexOf(e); t >= 0 && n.splice(t, 1) } return n }, n } async function Gs(e, t) { try { await t(e) } catch (t) { e.error(t) } } const Hs = Symbol("vega_id"); let qs = 1; function Ys(e) { return !(!e || !Xs(e)) } function Xs(e) { return e[Hs] } function Ks(e, t) { return e[Hs] = t, e } function Zs(e) { const t = e === Object(e) ? e : { data: e }; return Xs(t) ? t : Ks(t, qs++) } function Js(e) { return Qs(e, Zs({})) } function Qs(e, t) { for (const n in e) t[n] = e[n]; return t } function eu(e, t) { return Ks(t, Xs(e)) } function tu(e, t) { return e ? t ? (n, r) => e(n, r) || Xs(t(n)) - Xs(t(r)) : (t, n) => e(t, n) || Xs(t) - Xs(n) : null } function nu(e) { return e && e.constructor === ru } function ru() { const e = [], t = [], n = [], r = [], i = []; let a = null, o = !1; return { constructor: ru, insert(t) { const n = _n(t), r = n.length; for (let t = 0; t < r; ++t)e.push(n[t]); return this }, remove(e) { const n = Cn(e) ? r : t, i = _n(e), a = i.length; for (let e = 0; e < a; ++e)n.push(i[e]); return this }, modify(e, t, r) { const a = { field: t, value: Fn(r) }; return Cn(e) ? (a.filter = e, i.push(a)) : (a.tuple = e, n.push(a)), this }, encode(e, t) { return Cn(e) ? i.push({ filter: e, field: t }) : n.push({ tuple: e, field: t }), this }, clean(e) { return a = e, this }, reflow() { return o = !0, this }, pulse(s, u) { const l = {}, c = {}; let h, d, f, p, m, g; for (h = 0, d = u.length; h < d; ++h)l[Xs(u[h])] = 1; for (h = 0, d = t.length; h < d; ++h)m = t[h], l[Xs(m)] = -1; for (h = 0, d = r.length; h < d; ++h)p = r[h], u.forEach((e => { p(e) && (l[Xs(e)] = -1) })); for (h = 0, d = e.length; h < d; ++h)m = e[h], g = Xs(m), l[g] ? l[g] = 1 : s.add.push(Zs(e[h])); for (h = 0, d = u.length; h < d; ++h)m = u[h], l[Xs(m)] < 0 && s.rem.push(m); function y(e, t, n) { n ? e[t] = n(e) : s.encode = t, o || (c[Xs(e)] = e) } for (h = 0, d = n.length; h < d; ++h)f = n[h], m = f.tuple, p = f.field, g = l[Xs(m)], g > 0 && (y(m, p, f.value), s.modifies(p)); for (h = 0, d = i.length; h < d; ++h)f = i[h], p = f.filter, u.forEach((e => { p(e) && l[Xs(e)] > 0 && y(e, f.field, f.value) })), s.modifies(f.field); if (o) s.mod = t.length || r.length ? u.filter((e => l[Xs(e)] > 0)) : u.slice(); else for (g in c) s.mod.push(c[g]); return (a || null == a && (t.length || r.length)) && s.clean(!0), s } } } const iu = "_:mod:_"; function au() { Object.defineProperty(this, iu, { writable: !0, value: {} }) } au.prototype = { set(e, t, n, r) { const i = this, a = i[e], o = i[iu]; return null != t && t >= 0 ? (a[t] !== n || r) && (a[t] = n, o[t + ":" + e] = -1, o[e] = -1) : (a !== n || r) && (i[e] = n, o[e] = on(n) ? 1 + n.length : -1), i }, modified(e, t) { const n = this[iu]; if (!arguments.length) { for (const e in n) if (n[e]) return !0; return !1 } if (on(e)) { for (let t = 0; t < e.length; ++t)if (n[e[t]]) return !0; return !1 } return null != t && t >= 0 ? t + 1 < n[e] || !!n[t + ":" + e] : !!n[e] }, clear() { return this[iu] = {}, this } }; let ou = 0; const su = new au; function uu(e, t, n, r) { this.id = ++ou, this.value = e, this.stamp = -1, this.rank = -1, this.qrank = -1, this.flags = 0, t && (this._update = t), n && this.parameters(n, r) } function lu(e) { return function (t) { const n = this.flags; return 0 === arguments.length ? !!(n & e) : (this.flags = t ? n | e : n & ~e, this) } } uu.prototype = { targets() { return this._targets || (this._targets = Vs(qt)) }, set(e) { return this.value !== e ? (this.value = e, 1) : 0 }, skip: lu(1), modified: lu(2), parameters(e, t, n) { t = !1 !== t; const r = this._argval = this._argval || new au, i = this._argops = this._argops || [], a = []; let o, s, u, l; const c = (e, n, o) => { o instanceof uu ? (o !== this && (t && o.targets().add(this), a.push(o)), i.push({ op: o, name: e, index: n })) : r.set(e, n, o) }; for (o in e) if (s = e[o], "pulse" === o) _n(s).forEach((e => { e instanceof uu ? e !== this && (e.targets().add(this), a.push(e)) : Vt("Pulse parameters must be operator instances.") })), this.source = s; else if (on(s)) for (r.set(o, -1, Array(u = s.length)), l = 0; l < u; ++l)c(o, l, s[l]); else c(o, -1, s); return this.marshall().clear(), n && (i.initonly = !0), a }, marshall(e) { const t = this._argval || su, n = this._argops; let r, i, a, o; if (n) { const s = n.length; for (i = 0; i < s; ++i)r = n[i], a = r.op, o = a.modified() && a.stamp === e, t.set(r.name, r.index, a.value, o); if (n.initonly) { for (i = 0; i < s; ++i)r = n[i], r.op.targets().remove(this); this._argops = null, this._update = null } } return t }, detach() { const e = this._argops; let t, n, r, i; if (e) for (t = 0, n = e.length; t < n; ++t)r = e[t], i = r.op, i._targets && i._targets.remove(this); this.pulse = null, this.source = null }, evaluate(e) { const t = this._update; if (t) { const n = this.marshall(e.stamp), r = t.call(this, n, e); if (n.clear(), r !== this.value) this.value = r; else if (!this.modified()) return e.StopPropagation } }, run(e) { if (e.stamp < this.stamp) return e.StopPropagation; let t; return this.skip() ? (this.skip(!1), t = 0) : t = this.evaluate(e), this.pulse = t || e } }; let cu = 0; function hu(e, t, n) { this.id = ++cu, this.value = null, n && (this.receive = n), e && (this._filter = e), t && (this._apply = t) } function du(e, t, n) { return new hu(e, t, n) } hu.prototype = { _filter: Zt, _apply: Yt, targets() { return this._targets || (this._targets = Vs(qt)) }, consume(e) { return arguments.length ? (this._consume = !!e, this) : !!this._consume }, receive(e) { if (this._filter(e)) { const t = this.value = this._apply(e), n = this._targets, r = n ? n.length : 0; for (let e = 0; e < r; ++e)n[e].receive(t); this._consume && (e.preventDefault(), e.stopPropagation()) } }, filter(e) { const t = du(e); return this.targets().add(t), t }, apply(e) { const t = du(null, e); return this.targets().add(t), t }, merge() { const e = du(); this.targets().add(e); for (let t = 0, n = arguments.length; t < n; ++t)arguments[t].targets().add(e); return e }, throttle(e) { let t = -1; return this.filter((() => { const n = Date.now(); return n - t > e ? (t = n, 1) : 0 })) }, debounce(e) { const t = du(); return this.targets().add(du(null, null, Dn(e, (e => { const n = e.dataflow; t.receive(e), n && n.run && n.run() })))), t }, between(e, t) { let n = !1; return e.targets().add(du(null, null, (() => n = !0))), t.targets().add(du(null, null, (() => n = !1))), this.filter((() => n)) }, detach() { this._filter = Zt, this._targets = null } }; const fu = { skip: !0 }; function pu(e, t, n, r, i, a) { const o = $n({}, a, fu); let s, u; Cn(n) || (n = Fn(n)), void 0 === r ? s = t => e.touch(n(t)) : Cn(r) ? (u = new uu(null, r, i, !1), s = t => { u.evaluate(t); const r = n(t), i = u.value; nu(i) ? e.pulse(r, i, a) : e.update(r, i, o) }) : s = t => e.update(n(t), r, o), t.apply(s) } function mu(e, t, n, r, i, a) { if (void 0 === r) t.targets().add(n); else { const o = a || {}, s = new uu(null, function (e, t) { return t = Cn(t) ? t : Fn(t), e ? function (n, r) { const i = t(n, r); return e.skip() || (e.skip(i !== this.value).value = i), i } : t }(n, r), i, !1); s.modified(o.force), s.rank = t.rank, t.targets().add(s), n && (s.skip(!0), s.value = n.value, s.targets().add(n), e.connect(n, [s])) } } const gu = {}; function yu(e, t, n) { this.dataflow = e, this.stamp = null == t ? -1 : t, this.add = [], this.rem = [], this.mod = [], this.fields = null, this.encode = n || null } function bu(e, t) { const n = []; return er(e, t, (e => n.push(e))), n } function vu(e, t) { const n = {}; return e.visit(t, (e => { n[Xs(e)] = 1 })), e => n[Xs(e)] ? null : e } function xu(e, t) { return e ? (n, r) => e(n, r) && t(n, r) : t } function wu(e, t, n, r) { const i = this; let a = 0; this.dataflow = e, this.stamp = t, this.fields = null, this.encode = r || null, this.pulses = n; for (const e of n) if (e.stamp === t) { if (e.fields) { const t = i.fields || (i.fields = {}); for (const n in e.fields) t[n] = 1 } e.changed(i.ADD) && (a |= i.ADD), e.changed(i.REM) && (a |= i.REM), e.changed(i.MOD) && (a |= i.MOD) } this.changes = a } function ku(e) { return e.error("Dataflow already running. Use runAsync() to chain invocations."), e } yu.prototype = { StopPropagation: gu, ADD: 1, REM: 2, MOD: 4, ADD_REM: 3, ADD_MOD: 5, ALL: 7, REFLOW: 8, SOURCE: 16, NO_SOURCE: 32, NO_FIELDS: 64, fork(e) { return new yu(this.dataflow).init(this, e) }, clone() { const e = this.fork(7); return e.add = e.add.slice(), e.rem = e.rem.slice(), e.mod = e.mod.slice(), e.source && (e.source = e.source.slice()), e.materialize(23) }, addAll() { let e = this; return !e.source || e.add === e.rem || !e.rem.length && e.source.length === e.add.length || (e = new yu(this.dataflow).init(this), e.add = e.source, e.rem = []), e }, init(e, t) { const n = this; return n.stamp = e.stamp, n.encode = e.encode, !e.fields || 64 & t || (n.fields = e.fields), 1 & t ? (n.addF = e.addF, n.add = e.add) : (n.addF = null, n.add = []), 2 & t ? (n.remF = e.remF, n.rem = e.rem) : (n.remF = null, n.rem = []), 4 & t ? (n.modF = e.modF, n.mod = e.mod) : (n.modF = null, n.mod = []), 32 & t ? (n.srcF = null, n.source = null) : (n.srcF = e.srcF, n.source = e.source, e.cleans && (n.cleans = e.cleans)), n }, runAfter(e) { this.dataflow.runAfter(e) }, changed(e) { const t = e || 7; return 1 & t && this.add.length || 2 & t && this.rem.length || 4 & t && this.mod.length }, reflow(e) { if (e) return this.fork(7).reflow(); const t = this.add.length, n = this.source && this.source.length; return n && n !== t && (this.mod = this.source, t && this.filter(4, vu(this, 1))), this }, clean(e) { return arguments.length ? (this.cleans = !!e, this) : this.cleans }, modifies(e) { const t = this.fields || (this.fields = {}); return on(e) ? e.forEach((e => t[e] = !0)) : t[e] = !0, this }, modified(e, t) { const n = this.fields; return !(!t && !this.mod.length || !n) && (arguments.length ? on(e) ? e.some((e => n[e])) : n[e] : !!n) }, filter(e, t) { const n = this; return 1 & e && (n.addF = xu(n.addF, t)), 2 & e && (n.remF = xu(n.remF, t)), 4 & e && (n.modF = xu(n.modF, t)), 16 & e && (n.srcF = xu(n.srcF, t)), n }, materialize(e) { const t = this; return 1 & (e = e || 7) && t.addF && (t.add = bu(t.add, t.addF), t.addF = null), 2 & e && t.remF && (t.rem = bu(t.rem, t.remF), t.remF = null), 4 & e && t.modF && (t.mod = bu(t.mod, t.modF), t.modF = null), 16 & e && t.srcF && (t.source = t.source.filter(t.srcF), t.srcF = null), t }, visit(e, t) { const n = this, r = t; if (16 & e) return er(n.source, n.srcF, r), n; 1 & e && er(n.add, n.addF, r), 2 & e && er(n.rem, n.remF, r), 4 & e && er(n.mod, n.modF, r); const i = n.source; if (8 & e && i) { const e = n.add.length + n.mod.length; e === i.length || er(i, e ? vu(n, 5) : n.srcF, r) } return n } }, Ln(wu, yu, { fork(e) { const t = new yu(this.dataflow).init(this, e & this.NO_FIELDS); return void 0 !== e && (e & t.ADD && this.visit(t.ADD, (e => t.add.push(e))), e & t.REM && this.visit(t.REM, (e => t.rem.push(e))), e & t.MOD && this.visit(t.MOD, (e => t.mod.push(e)))), t }, changed(e) { return this.changes & e }, modified(e) { const t = this, n = t.fields; return n && t.changes & t.MOD ? on(e) ? e.some((e => n[e])) : n[e] : 0 }, filter() { Vt("MultiPulse does not support filtering.") }, materialize() { Vt("MultiPulse does not support materialization.") }, visit(e, t) { const n = this, r = n.pulses, i = r.length; let a = 0; if (e & n.SOURCE) for (; a < i; ++a)r[a].visit(e, t); else for (; a < i; ++a)r[a].stamp === n.stamp && r[a].visit(e, t); return n } }); const Su = { skip: !1, force: !1 }; function _u(e) { let t = []; return { clear: () => t = [], size: () => t.length, peek: () => t[0], push: n => (t.push(n), Cu(t, 0, t.length - 1, e)), pop: () => { const n = t.pop(); let r; return t.length ? (r = t[0], t[0] = n, function (e, t, n) { const r = t, i = e.length, a = e[t]; let o, s = 1 + (t << 1); for (; s < i;)o = s + 1, o < i && n(e[s], e[o]) >= 0 && (s = o), e[t] = e[s], s = 1 + ((t = s) << 1); e[t] = a, Cu(e, r, t, n) }(t, 0, e)) : r = n, r } } } function Cu(e, t, n, r) { let i, a; const o = e[n]; for (; n > t && (a = n - 1 >> 1, i = e[a], r(o, i) < 0);)e[n] = i, n = a; return e[n] = o } function Au() { this.logger(function (e, t) { let n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : Qt, r = e || en; return { level(e) { return arguments.length ? (r = +e, this) : r }, error() { return r >= tn && n(t || "error", "ERROR", arguments), this }, warn() { return r >= nn && n(t || "warn", "WARN", arguments), this }, info() { return r >= rn && n(t || "log", "INFO", arguments), this }, debug() { return r >= an && n(t || "log", "DEBUG", arguments), this } } }()), this.logLevel(tn), this._clock = 0, this._rank = 0, this._locale = bs(); try { this._loader = Ws() } catch (e) { } this._touched = Vs(qt), this._input = {}, this._pulse = null, this._heap = _u(((e, t) => e.qrank - t.qrank)), this._postrun = [] } function Tu(e) { return function () { return this._log[e].apply(this, arguments) } } function Eu(e, t) { uu.call(this, e, null, t) } Au.prototype = { stamp() { return this._clock }, loader(e) { return arguments.length ? (this._loader = e, this) : this._loader }, locale(e) { return arguments.length ? (this._locale = e, this) : this._locale }, logger(e) { return arguments.length ? (this._log = e, this) : this._log }, error: Tu("error"), warn: Tu("warn"), info: Tu("info"), debug: Tu("debug"), logLevel: Tu("level"), cleanThreshold: 1e4, add: function (e, t, n, r) { let i, a = 1; return e instanceof uu ? i = e : e && e.prototype instanceof uu ? i = new e : Cn(e) ? i = new uu(null, e) : (a = 0, i = new uu(e, t)), this.rank(i), a && (r = n, n = t), n && this.connect(i, i.parameters(n, r)), this.touch(i), i }, connect: function (e, t) { const n = e.rank, r = t.length; for (let i = 0; i < r; ++i)if (n < t[i].rank) return void this.rerank(e) }, rank: function (e) { e.rank = ++this._rank }, rerank: function (e) { const t = [e]; let n, r, i; for (; t.length;)if (this.rank(n = t.pop()), r = n._targets) for (i = r.length; --i >= 0;)t.push(n = r[i]), n === e && Vt("Cycle detected in dataflow graph.") }, pulse: function (e, t, n) { this.touch(e, n || Su); const r = new yu(this, this._clock + (this._pulse ? 0 : 1)), i = e.pulse && e.pulse.source || []; return r.target = e, this._input[e.id] = t.pulse(r, i), this }, touch: function (e, t) { const n = t || Su; return this._pulse ? this._enqueue(e) : this._touched.add(e), n.skip && e.skip(!0), this }, update: function (e, t, n) { const r = n || Su; return (e.set(t) || r.force) && this.touch(e, r), this }, changeset: ru, ingest: function (e, t, n) { return t = this.parse(t, n), this.pulse(e, this.changeset().insert(t)) }, parse: function (e, t) { const n = this.locale(); return Us(e, t, n.timeParse, n.utcParse) }, preload: async function (e, t, n) { const r = this, i = r._pending || function (e) { let t; const n = new Promise((e => t = e)); return n.requests = 0, n.done = () => { 0 == --n.requests && (e._pending = null, t(e)) }, e._pending = n }(r); i.requests += 1; const a = await r.request(t, n); return r.pulse(e, r.changeset().remove(Zt).insert(a.data || [])), i.done(), a }, request: async function (e, t) { const n = this; let r, i = 0; try { r = await n.loader().load(e, { context: "dataflow", response: js(t && t.type) }); try { r = n.parse(r, t) } catch (t) { i = -2, n.warn("Data ingestion failed", e, t) } } catch (t) { i = -1, n.warn("Loading failed", e, t) } return { data: r, status: i } }, events: function (e, t, n, r) { const i = this, a = du(n, r), o = function (e) { e.dataflow = i; try { a.receive(e) } catch (e) { i.error(e) } finally { i.run() } }; let s; s = "string" == typeof e && "undefined" != typeof document ? document.querySelectorAll(e) : _n(e); const u = s.length; for (let e = 0; e < u; ++e)s[e].addEventListener(t, o); return a }, on: function (e, t, n, r, i) { return (e instanceof uu ? mu : pu)(this, e, t, n, r, i), this }, evaluate: async function (e, t, n) { const r = this, i = []; if (r._pulse) return ku(r); if (r._pending && await r._pending, t && await Gs(r, t), !r._touched.length) return r.debug("Dataflow invoked, but nothing to do."), r; const a = ++r._clock; r._pulse = new yu(r, a, e), r._touched.forEach((e => r._enqueue(e, !0))), r._touched = Vs(qt); let o, s, u, l = 0; try { for (; r._heap.size() > 0;)o = r._heap.pop(), o.rank === o.qrank ? (s = o.run(r._getPulse(o, e)), s.then ? s = await s : s.async && (i.push(s.async), s = gu), s !== gu && o._targets && o._targets.forEach((e => r._enqueue(e))), ++l) : r._enqueue(o, !0) } catch (e) { r._heap.clear(), u = e } if (r._input = {}, r._pulse = null, r.debug(`Pulse ${a}: ${l} operators`), u && (r._postrun = [], r.error(u)), r._postrun.length) { const e = r._postrun.sort(((e, t) => t.priority - e.priority)); r._postrun = []; for (let t = 0; t < e.length; ++t)await Gs(r, e[t].callback) } return n && await Gs(r, n), i.length && Promise.all(i).then((e => r.runAsync(null, (() => { e.forEach((e => { try { e(r) } catch (e) { r.error(e) } })) })))), r }, run: function (e, t, n) { return this._pulse ? ku(this) : (this.evaluate(e, t, n), this) }, runAsync: async function (e, t, n) { for (; this._running;)await this._running; const r = () => this._running = null; return (this._running = this.evaluate(e, t, n)).then(r, r), this._running }, runAfter: function (e, t, n) { if (this._pulse || t) this._postrun.push({ priority: n || 0, callback: e }); else try { e(this) } catch (e) { this.error(e) } }, _enqueue: function (e, t) { const n = e.stamp < this._clock; n && (e.stamp = this._clock), (n || t) && (e.qrank = e.rank, this._heap.push(e)) }, _getPulse: function (e, t) { const n = e.source, r = this._clock; return n && on(n) ? new wu(this, r, n.map((e => e.pulse)), t) : this._input[e.id] || function (e, t) { if (t && t.stamp === e.stamp) return t; e = e.fork(), t && t !== gu && (e.source = t.source); return e }(this._pulse, n && n.pulse) } }, Ln(Eu, uu, { run(e) { if (e.stamp < this.stamp) return e.StopPropagation; let t; return this.skip() ? this.skip(!1) : t = this.evaluate(e), t = t || e, t.then ? t = t.then((e => this.pulse = e)) : t !== e.StopPropagation && (this.pulse = t), t }, evaluate(e) { const t = this.marshall(e.stamp), n = this.transform(t, e); return t.clear(), n }, transform() { } }); const Nu = {}; function Iu(e) { const t = Mu(e); return t && t.Definition || null } function Mu(e) { return e = e && e.toLowerCase(), zn(Nu, e) ? Nu[e] : null } function Fu(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function Du(e, t) { let n; if (void 0 === t) for (const t of e) null != t && (n < t || void 0 === n && t >= t) && (n = t); else { let r = -1; for (let i of e) null != (i = t(i, ++r, e)) && (n < i || void 0 === n && i >= i) && (n = i) } return n } function $u(e, t) { let n; if (void 0 === t) for (const t of e) null != t && (n > t || void 0 === n && t >= t) && (n = t); else { let r = -1; for (let i of e) null != (i = t(i, ++r, e)) && (n > i || void 0 === n && i >= i) && (n = i) } return n } function Ru(e = Fu) { if (e === Fu) return Ou; if ("function" != typeof e) throw new TypeError("compare is not a function"); return (t, n) => { const r = e(t, n); return r || 0 === r ? r : (0 === e(n, n)) - (0 === e(t, t)) } } function Ou(e, t) { return (null == e || !(e >= e)) - (null == t || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0) } function zu(e, t, n = 0, r = 1 / 0, i) { if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), r = Math.floor(Math.min(e.length - 1, r)), !(n <= t && t <= r)) return e; for (i = void 0 === i ? Ou : Ru(i); r > n;) { if (r - n > 600) { const a = r - n + 1, o = t - n + 1, s = Math.log(a), u = .5 * Math.exp(2 * s / 3), l = .5 * Math.sqrt(s * u * (a - u) / a) * (o - a / 2 < 0 ? -1 : 1); zu(e, t, Math.max(n, Math.floor(t - o * u / a + l)), Math.min(r, Math.floor(t + (a - o) * u / a + l)), i) } const a = e[t]; let o = n, s = r; for (Pu(e, n, t), i(e[r], a) > 0 && Pu(e, n, r); o < s;) { for (Pu(e, o, s), ++o, --s; i(e[o], a) < 0;)++o; for (; i(e[s], a) > 0;)--s } 0 === i(e[n], a) ? Pu(e, n, s) : (++s, Pu(e, s, r)), s <= t && (n = s + 1), t <= s && (r = s - 1) } return e } function Pu(e, t, n) { const r = e[t]; e[t] = e[n], e[n] = r } function Bu(e) { return null === e ? NaN : +e } function Lu(e, t, n) { if (e = Float64Array.from(function* (e, t) { if (void 0 === t) for (let t of e) null != t && (t = +t) >= t && (yield t); else { let n = -1; for (let r of e) null != (r = t(r, ++n, e)) && (r = +r) >= r && (yield r) } }(e, n)), (r = e.length) && !isNaN(t = +t)) { if (t <= 0 || r < 2) return $u(e); if (t >= 1) return Du(e); var r, i = (r - 1) * t, a = Math.floor(i), o = Du(zu(e, a).subarray(0, a + 1)); return o + ($u(e.subarray(a + 1)) - o) * (i - a) } } function ju(e, t) { return Lu(e, .5, t) } function* Uu(e, t) { if (null == t) for (let t of e) null != t && "" !== t && (t = +t) >= t && (yield t); else { let n = -1; for (let r of e) r = t(r, ++n, e), null != r && "" !== r && (r = +r) >= r && (yield r) } } function Wu(e, t, n) { const r = Float64Array.from(Uu(e, n)); return r.sort(Fu), t.map((e => function (e, t, n = Bu) { if ((r = e.length) && !isNaN(t = +t)) { if (t <= 0 || r < 2) return +n(e[0], 0, e); if (t >= 1) return +n(e[r - 1], r - 1, e); var r, i = (r - 1) * t, a = Math.floor(i), o = +n(e[a], a, e); return o + (+n(e[a + 1], a + 1, e) - o) * (i - a) } }(r, e))) } function Vu(e, t) { return Wu(e, [.25, .5, .75], t) } function Gu(e, t) { const n = e.length, r = function (e, t) { const n = function (e, t) { let n, r = 0, i = 0, a = 0; if (void 0 === t) for (let t of e) null != t && (t = +t) >= t && (n = t - i, i += n / ++r, a += n * (t - i)); else { let o = -1; for (let s of e) null != (s = t(s, ++o, e)) && (s = +s) >= s && (n = s - i, i += n / ++r, a += n * (s - i)) } if (r > 1) return a / (r - 1) }(e, t); return n ? Math.sqrt(n) : n }(e, t), i = Vu(e, t), a = (i[2] - i[0]) / 1.34; return 1.06 * (Math.min(r, a) || r || Math.abs(i[0]) || 1) * Math.pow(n, -.2) } var Hu = Math.random; function qu(e, t, n, r) { r = r || (e => e); const i = e.length, a = new Float64Array(i); let o, s = 0, u = 1, l = r(e[0]), c = l, h = l + t; for (; u < i; ++u) { if (o = r(e[u]), o >= h) { for (c = (l + c) / 2; s < u; ++s)a[s] = c; h = o + t, l = o } c = o } for (c = (l + c) / 2; s < u; ++s)a[s] = c; return n ? function (e, t) { const n = e.length; let r, i, a = 0, o = 1; for (; e[a] === e[o];)++o; for (; o < n;) { for (r = o + 1; e[o] === e[r];)++r; if (e[o] - e[o - 1] < t) { for (i = o + (a + r - o - o >> 1); i < o;)e[i++] = e[o]; for (; i > o;)e[i--] = e[a] } a = o, o = r } return e }(a, t + t / 4) : a } const Yu = Math.sqrt(2 * Math.PI), Xu = Math.SQRT2; let Ku = NaN; function Zu(e, t) { e = e || 0, t = null == t ? 1 : t; let n, r, i = 0, a = 0; if (Ku == Ku) i = Ku, Ku = NaN; else { do { i = 2 * Hu() - 1, a = 2 * Hu() - 1, n = i * i + a * a } while (0 === n || n > 1); r = Math.sqrt(-2 * Math.log(n) / n), i *= r, Ku = a * r } return e + i * t } function Ju(e, t, n) { const r = (e - (t || 0)) / (n = null == n ? 1 : n); return Math.exp(-.5 * r * r) / (n * Yu) } function Qu(e, t, n) { const r = (e - (t = t || 0)) / (n = null == n ? 1 : n), i = Math.abs(r); let a; if (i > 37) a = 0; else { const e = Math.exp(-i * i / 2); let t; i < 7.07106781186547 ? (t = .0352624965998911 * i + .700383064443688, t = t * i + 6.37396220353165, t = t * i + 33.912866078383, t = t * i + 112.079291497871, t = t * i + 221.213596169931, t = t * i + 220.206867912376, a = e * t, t = .0883883476483184 * i + 1.75566716318264, t = t * i + 16.064177579207, t = t * i + 86.7807322029461, t = t * i + 296.564248779674, t = t * i + 637.333633378831, t = t * i + 793.826512519948, t = t * i + 440.413735824752, a /= t) : (t = i + .65, t = i + 4 / t, t = i + 3 / t, t = i + 2 / t, t = i + 1 / t, a = e / t / 2.506628274631) } return r > 0 ? 1 - a : a } function el(e, t, n) { return e < 0 || e > 1 ? NaN : (t || 0) + (null == n ? 1 : n) * Xu * function (e) { let t, n = -Math.log((1 - e) * (1 + e)); n < 6.25 ? (n -= 3.125, t = -364441206401782e-35, t = t * n - 16850591381820166e-35, t = 128584807152564e-32 + t * n, t = 11157877678025181e-33 + t * n, t = t * n - 1333171662854621e-31, t = 20972767875968562e-33 + t * n, t = 6637638134358324e-30 + t * n, t = t * n - 4054566272975207e-29, t = t * n - 8151934197605472e-29, t = 26335093153082323e-28 + t * n, t = t * n - 12975133253453532e-27, t = t * n - 5415412054294628e-26, t = 1.0512122733215323e-9 + t * n, t = t * n - 4.112633980346984e-9, t = t * n - 2.9070369957882005e-8, t = 4.2347877827932404e-7 + t * n, t = t * n - 13654692000834679e-22, t = t * n - 13882523362786469e-21, t = .00018673420803405714 + t * n, t = t * n - .000740702534166267, t = t * n - .006033670871430149, t = .24015818242558962 + t * n, t = 1.6536545626831027 + t * n) : n < 16 ? (n = Math.sqrt(n) - 3.25, t = 2.2137376921775787e-9, t = 9.075656193888539e-8 + t * n, t = t * n - 2.7517406297064545e-7, t = 1.8239629214389228e-8 + t * n, t = 15027403968909828e-22 + t * n, t = t * n - 4013867526981546e-21, t = 29234449089955446e-22 + t * n, t = 12475304481671779e-21 + t * n, t = t * n - 47318229009055734e-21, t = 6828485145957318e-20 + t * n, t = 24031110387097894e-21 + t * n, t = t * n - .0003550375203628475, t = .0009532893797373805 + t * n, t = t * n - .0016882755560235047, t = .002491442096107851 + t * n, t = t * n - .003751208507569241, t = .005370914553590064 + t * n, t = 1.0052589676941592 + t * n, t = 3.0838856104922208 + t * n) : Number.isFinite(n) ? (n = Math.sqrt(n) - 5, t = -27109920616438573e-27, t = t * n - 2.555641816996525e-10, t = 1.5076572693500548e-9 + t * n, t = t * n - 3.789465440126737e-9, t = 7.61570120807834e-9 + t * n, t = t * n - 1.496002662714924e-8, t = 2.914795345090108e-8 + t * n, t = t * n - 6.771199775845234e-8, t = 2.2900482228026655e-7 + t * n, t = t * n - 9.9298272942317e-7, t = 4526062597223154e-21 + t * n, t = t * n - 1968177810553167e-20, t = 7599527703001776e-20 + t * n, t = t * n - .00021503011930044477, t = t * n - .00013871931833623122, t = 1.0103004648645344 + t * n, t = 4.849906401408584 + t * n) : t = 1 / 0; return t * e }(2 * e - 1) } function tl(e, t) { let n, r; const i = { mean(e) { return arguments.length ? (n = e || 0, i) : n }, stdev(e) { return arguments.length ? (r = null == e ? 1 : e, i) : r }, sample: () => Zu(n, r), pdf: e => Ju(e, n, r), cdf: e => Qu(e, n, r), icdf: e => el(e, n, r) }; return i.mean(e).stdev(t) } function nl(e, t) { const n = tl(); let r = 0; const i = { data(n) { return arguments.length ? (e = n, r = n ? n.length : 0, i.bandwidth(t)) : e }, bandwidth(n) { return arguments.length ? (!(t = n) && e && (t = Gu(e)), i) : t }, sample: () => e[~~(Hu() * r)] + t * n.sample(), pdf(i) { let a = 0, o = 0; for (; o < r; ++o)a += n.pdf((i - e[o]) / t); return a / t / r }, cdf(i) { let a = 0, o = 0; for (; o < r; ++o)a += n.cdf((i - e[o]) / t); return a / r }, icdf() { throw Error("KDE icdf not supported.") } }; return i.data(e) } function rl(e, t) { return e = e || 0, t = null == t ? 1 : t, Math.exp(e + Zu() * t) } function il(e, t, n) { if (e <= 0) return 0; t = t || 0, n = null == n ? 1 : n; const r = (Math.log(e) - t) / n; return Math.exp(-.5 * r * r) / (n * Yu * e) } function al(e, t, n) { return Qu(Math.log(e), t, n) } function ol(e, t, n) { return Math.exp(el(e, t, n)) } function sl(e, t) { return null == t && (t = null == e ? 1 : e, e = 0), e + (t - e) * Hu() } function ul(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e >= t && e <= n ? 1 / (n - t) : 0 } function ll(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e < t ? 0 : e > n ? 1 : (e - t) / (n - t) } function cl(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e >= 0 && e <= 1 ? t + e * (n - t) : NaN } function hl(e, t, n, r) { const i = r - e * e, a = Math.abs(i) < 1e-24 ? 0 : (n - e * t) / i; return [t - a * e, a] } function dl(e, t, n, r) { e = e.filter((e => { let r = t(e), i = n(e); return null != r && (r = +r) >= r && null != i && (i = +i) >= i })), r && e.sort(((e, n) => t(e) - t(n))); const i = e.length, a = new Float64Array(i), o = new Float64Array(i); let s, u, l, c = 0, h = 0, d = 0; for (l of e) a[c] = s = +t(l), o[c] = u = +n(l), ++c, h += (s - h) / c, d += (u - d) / c; for (c = 0; c < i; ++c)a[c] -= h, o[c] -= d; return [a, o, h, d] } function fl(e, t, n, r) { let i, a, o = -1; for (const s of e) i = t(s), a = n(s), null != i && (i = +i) >= i && null != a && (a = +a) >= a && r(i, a, ++o) } function pl(e, t, n, r, i) { let a = 0, o = 0; return fl(e, t, n, ((e, t) => { const n = t - i(e), s = t - r; a += n * n, o += s * s })), 1 - a / o } function ml(e, t, n) { let r = 0, i = 0, a = 0, o = 0, s = 0; fl(e, t, n, ((e, t) => { ++s, r += (e - r) / s, i += (t - i) / s, a += (e * t - a) / s, o += (e * e - o) / s })); const u = hl(r, i, a, o), l = e => u[0] + u[1] * e; return { coef: u, predict: l, rSquared: pl(e, t, n, i, l) } } function gl(e, t, n) { const [r, i, a, o] = dl(e, t, n), s = r.length; let u, l, c, h, d = 0, f = 0, p = 0, m = 0, g = 0; for (u = 0; u < s;)l = r[u], c = i[u++], h = l * l, d += (h - d) / u, f += (h * l - f) / u, p += (h * h - p) / u, m += (l * c - m) / u, g += (h * c - g) / u; const y = p - d * d, b = d * y - f * f, v = (g * d - m * f) / b, x = (m * y - g * f) / b, w = -v * d, k = e => v * (e -= a) * e + x * e + w + o; return { coef: [w - x * a + v * a * a + o, x - 2 * v * a, v], predict: k, rSquared: pl(e, t, n, o, k) } } function yl(e, t, n, r) { const i = Array(e); let a, o, s, u; for (a = 0; a < e; ++a)i[a] = 0; for (a = e - 1; a >= 0; --a)for (s = t[a], u = 1, i[a] += s, o = 1; o <= a; ++o)u *= (a + 1 - o) / o, i[a - o] += s * Math.pow(n, o) * u; return i[0] += r, i } function bl(e) { return (e = 1 - e * e * e) * e * e } function vl(e, t, n) { const r = e[t]; let i = n[0], a = n[1] + 1; if (!(a >= e.length)) for (; t > i && e[a] - r <= r - e[i];)n[0] = ++i, n[1] = a, ++a } const xl = .5 * Math.PI / 180; function wl(e, t, n, r) { n = n || 25, r = Math.max(n, r || 200); const i = t => [t, e(t)], a = t[0], o = t[1], s = o - a, u = s / r, l = [i(a)], c = []; if (n === r) { for (let e = 1; e < r; ++e)l.push(i(a + e / n * s)); return l.push(i(o)), l } c.push(i(o)); for (let e = n; --e > 0;)c.push(i(a + e / n * s)); let h = l[0], d = c[c.length - 1]; const f = 1 / s, p = function (e, t) { let n = e, r = e; const i = t.length; for (let e = 0; e < i; ++e) { const i = t[e][1]; i < n && (n = i), i > r && (r = i) } return 1 / (r - n) }(h[1], c); for (; d;) { const e = i((h[0] + d[0]) / 2); e[0] - h[0] >= u && kl(h, e, d, f, p) > xl ? c.push(e) : (h = d, l.push(d), c.pop()), d = c[c.length - 1] } return l } function kl(e, t, n, r, i) { const a = Math.atan2(i * (n[1] - e[1]), r * (n[0] - e[0])), o = Math.atan2(i * (t[1] - e[1]), r * (t[0] - e[0])); return Math.abs(a - o) } function Sl(e, t) { let n; if (void 0 === t) for (const t of e) null != t && (n < t || void 0 === n && t >= t) && (n = t); else { let r = -1; for (let i of e) null != (i = t(i, ++r, e)) && (n < i || void 0 === n && i >= i) && (n = i) } return n } function _l(e, t) { let n; if (void 0 === t) for (const t of e) null != t && (n > t || void 0 === n && t >= t) && (n = t); else { let r = -1; for (let i of e) null != (i = t(i, ++r, e)) && (n > i || void 0 === n && i >= i) && (n = i) } return n } function Cl(e, t) { return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function Al(e, t, n = 0, r = e.length - 1, i = Cl) { for (; r > n;) { if (r - n > 600) { const a = r - n + 1, o = t - n + 1, s = Math.log(a), u = .5 * Math.exp(2 * s / 3), l = .5 * Math.sqrt(s * u * (a - u) / a) * (o - a / 2 < 0 ? -1 : 1); Al(e, t, Math.max(n, Math.floor(t - o * u / a + l)), Math.min(r, Math.floor(t + (a - o) * u / a + l)), i) } const a = e[t]; let o = n, s = r; for (Tl(e, n, t), i(e[r], a) > 0 && Tl(e, n, r); o < s;) { for (Tl(e, o, s), ++o, --s; i(e[o], a) < 0;)++o; for (; i(e[s], a) > 0;)--s } 0 === i(e[n], a) ? Tl(e, n, s) : (++s, Tl(e, s, r)), s <= t && (n = s + 1), t <= s && (r = s - 1) } return e } function Tl(e, t, n) { const r = e[t]; e[t] = e[n], e[n] = r } function El(e) { return null === e ? NaN : +e } function Nl(e, t, n) { if (e = Float64Array.from(function* (e, t) { if (void 0 === t) for (let t of e) null != t && (t = +t) >= t && (yield t); else { let n = -1; for (let r of e) null != (r = t(r, ++n, e)) && (r = +r) >= r && (yield r) } }(e, n)), r = e.length) { if ((t = +t) <= 0 || r < 2) return _l(e); if (t >= 1) return Sl(e); var r, i = (r - 1) * t, a = Math.floor(i), o = Sl(Al(e, a).subarray(0, a + 1)); return o + (_l(e.subarray(a + 1)) - o) * (i - a) } } function Il(e, t, n = El) { if (r = e.length) { if ((t = +t) <= 0 || r < 2) return +n(e[0], 0, e); if (t >= 1) return +n(e[r - 1], r - 1, e); var r, i = (r - 1) * t, a = Math.floor(i), o = +n(e[a], a, e); return o + (+n(e[a + 1], a + 1, e) - o) * (i - a) } } function Ml(e, t) { return Nl(e, .5, t) } function Fl(e, t, n) { e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n; for (var r = -1, i = 0 | Math.max(0, Math.ceil((t - e) / n)), a = new Array(i); ++r < i;)a[r] = e + r * n; return a } function Dl(e) { let t = e, n = e; function r(e, t, r, i) { for (null == r && (r = 0), null == i && (i = e.length); r < i;) { const a = r + i >>> 1; n(e[a], t) < 0 ? r = a + 1 : i = a } return r } return 1 === e.length && (t = (t, n) => e(t) - n, n = function (e) { return (t, n) => Cl(e(t), n) }(e)), { left: r, center: function (e, n, i, a) { null == i && (i = 0), null == a && (a = e.length); const o = r(e, n, i, a - 1); return o > i && t(e[o - 1], n) > -t(e[o], n) ? o - 1 : o }, right: function (e, t, r, i) { for (null == r && (r = 0), null == i && (i = e.length); r < i;) { const a = r + i >>> 1; n(e[a], t) > 0 ? i = a : r = a + 1 } return r } } } function $l(e) { return e && e.length ? 1 === e.length ? e[0] : (t = e, e => { const n = t.length; let r = 1, i = String(t[0](e)); for (; r < n; ++r)i += "|" + t[r](e); return i }) : function () { return "" }; var t } function Rl(e, t, n) { return n || e + (t ? "_" + t : "") } const Ol = () => { }, zl = { init: Ol, add: Ol, rem: Ol, idx: 0 }, Pl = { values: { init: e => e.cell.store = !0, value: e => e.cell.data.values(), idx: -1 }, count: { value: e => e.cell.num }, __count__: { value: e => e.missing + e.valid }, missing: { value: e => e.missing }, valid: { value: e => e.valid }, sum: { init: e => e.sum = 0, value: e => e.sum, add: (e, t) => e.sum += +t, rem: (e, t) => e.sum -= t }, product: { init: e => e.product = 1, value: e => e.valid ? e.product : void 0, add: (e, t) => e.product *= t, rem: (e, t) => e.product /= t }, mean: { init: e => e.mean = 0, value: e => e.valid ? e.mean : void 0, add: (e, t) => (e.mean_d = t - e.mean, e.mean += e.mean_d / e.valid), rem: (e, t) => (e.mean_d = t - e.mean, e.mean -= e.valid ? e.mean_d / e.valid : e.mean) }, average: { value: e => e.valid ? e.mean : void 0, req: ["mean"], idx: 1 }, variance: { init: e => e.dev = 0, value: e => e.valid > 1 ? e.dev / (e.valid - 1) : void 0, add: (e, t) => e.dev += e.mean_d * (t - e.mean), rem: (e, t) => e.dev -= e.mean_d * (t - e.mean), req: ["mean"], idx: 1 }, variancep: { value: e => e.valid > 1 ? e.dev / e.valid : void 0, req: ["variance"], idx: 2 }, stdev: { value: e => e.valid > 1 ? Math.sqrt(e.dev / (e.valid - 1)) : void 0, req: ["variance"], idx: 2 }, stdevp: { value: e => e.valid > 1 ? Math.sqrt(e.dev / e.valid) : void 0, req: ["variance"], idx: 2 }, stderr: { value: e => e.valid > 1 ? Math.sqrt(e.dev / (e.valid * (e.valid - 1))) : void 0, req: ["variance"], idx: 2 }, distinct: { value: e => e.cell.data.distinct(e.get), req: ["values"], idx: 3 }, ci0: { value: e => e.cell.data.ci0(e.get), req: ["values"], idx: 3 }, ci1: { value: e => e.cell.data.ci1(e.get), req: ["values"], idx: 3 }, median: { value: e => e.cell.data.q2(e.get), req: ["values"], idx: 3 }, q1: { value: e => e.cell.data.q1(e.get), req: ["values"], idx: 3 }, q3: { value: e => e.cell.data.q3(e.get), req: ["values"], idx: 3 }, min: { init: e => e.min = void 0, value: e => e.min = Number.isNaN(e.min) ? e.cell.data.min(e.get) : e.min, add: (e, t) => { (t < e.min || void 0 === e.min) && (e.min = t) }, rem: (e, t) => { t <= e.min && (e.min = NaN) }, req: ["values"], idx: 4 }, max: { init: e => e.max = void 0, value: e => e.max = Number.isNaN(e.max) ? e.cell.data.max(e.get) : e.max, add: (e, t) => { (t > e.max || void 0 === e.max) && (e.max = t) }, rem: (e, t) => { t >= e.max && (e.max = NaN) }, req: ["values"], idx: 4 }, argmin: { init: e => e.argmin = void 0, value: e => e.argmin || e.cell.data.argmin(e.get), add: (e, t, n) => { t < e.min && (e.argmin = n) }, rem: (e, t) => { t <= e.min && (e.argmin = void 0) }, req: ["min", "values"], idx: 3 }, argmax: { init: e => e.argmax = void 0, value: e => e.argmax || e.cell.data.argmax(e.get), add: (e, t, n) => { t > e.max && (e.argmax = n) }, rem: (e, t) => { t >= e.max && (e.argmax = void 0) }, req: ["max", "values"], idx: 3 } }, Bl = Object.keys(Pl); function Ll(e, t) { return Pl[e](t) } function jl(e, t) { return e.idx - t.idx } function Ul() { this.valid = 0, this.missing = 0, this._ops.forEach((e => e.init(this))) } function Wl(e, t) { null != e && "" !== e ? e == e && (++this.valid, this._ops.forEach((n => n.add(this, e, t)))) : ++this.missing } function Vl(e, t) { null != e && "" !== e ? e == e && (--this.valid, this._ops.forEach((n => n.rem(this, e, t)))) : --this.missing } function Gl(e) { return this._out.forEach((t => e[t.out] = t.value(this))), e } function Hl(e, t) { const n = t || Yt, r = function (e) { const t = {}; e.forEach((e => t[e.name] = e)); const n = e => { e.req && e.req.forEach((e => { t[e] || n(t[e] = Pl[e]()) })) }; return e.forEach(n), Object.values(t).sort(jl) }(e), i = e.slice().sort(jl); function a(e) { this._ops = r, this._out = i, this.cell = e, this.init() } return a.prototype.init = Ul, a.prototype.add = Wl, a.prototype.rem = Vl, a.prototype.set = Gl, a.prototype.get = n, a.fields = e.map((e => e.out)), a } function ql(e) { this._key = e ? Ht(e) : Xs, this.reset() } Bl.forEach((e => { Pl[e] = function (e, t) { return n => $n({ name: e, out: n || e }, zl, t) }(e, Pl[e]) })); const Yl = ql.prototype; function Xl(e) { Eu.call(this, null, e), this._adds = [], this._mods = [], this._alen = 0, this._mlen = 0, this._drop = !0, this._cross = !1, this._dims = [], this._dnames = [], this._measures = [], this._countOnly = !1, this._counts = null, this._prev = null, this._inputs = null, this._outputs = null } Yl.reset = function () { this._add = [], this._rem = [], this._ext = null, this._get = null, this._q = null }, Yl.add = function (e) { this._add.push(e) }, Yl.rem = function (e) { this._rem.push(e) }, Yl.values = function () { if (this._get = null, 0 === this._rem.length) return this._add; const e = this._add, t = this._rem, n = this._key, r = e.length, i = t.length, a = Array(r - i), o = {}; let s, u, l; for (s = 0; s < i; ++s)o[n(t[s])] = 1; for (s = 0, u = 0; s < r; ++s)o[n(l = e[s])] ? o[n(l)] = 0 : a[u++] = l; return this._rem = [], this._add = a }, Yl.distinct = function (e) { const t = this.values(), n = {}; let r, i = t.length, a = 0; for (; --i >= 0;)r = e(t[i]) + "", zn(n, r) || (n[r] = 1, ++a); return a }, Yl.extent = function (e) { if (this._get !== e || !this._ext) { const t = this.values(), n = function (e, t) { const n = e.length; let r, i, a, o, s, u = -1; if (null == t) { for (; ++u < n;)if (i = e[u], null != i && i >= i) { r = a = i; break } if (u === n) return [-1, -1]; for (o = s = u; ++u < n;)i = e[u], null != i && (r > i && (r = i, o = u), a < i && (a = i, s = u)) } else { for (; ++u < n;)if (i = t(e[u], u, e), null != i && i >= i) { r = a = i; break } if (u === n) return [-1, -1]; for (o = s = u; ++u < n;)i = t(e[u], u, e), null != i && (r > i && (r = i, o = u), a < i && (a = i, s = u)) } return [o, s] }(t, e); this._ext = [t[n[0]], t[n[1]]], this._get = e } return this._ext }, Yl.argmin = function (e) { return this.extent(e)[0] || {} }, Yl.argmax = function (e) { return this.extent(e)[1] || {} }, Yl.min = function (e) { const t = this.extent(e)[0]; return null != t ? e(t) : void 0 }, Yl.max = function (e) { const t = this.extent(e)[1]; return null != t ? e(t) : void 0 }, Yl.quartile = function (e) { return this._get === e && this._q || (this._q = Vu(this.values(), e), this._get = e), this._q }, Yl.q1 = function (e) { return this.quartile(e)[0] }, Yl.q2 = function (e) { return this.quartile(e)[1] }, Yl.q3 = function (e) { return this.quartile(e)[2] }, Yl.ci = function (e) { return this._get === e && this._ci || (this._ci = function (e, t, n, r) { if (!e.length) return [void 0, void 0]; const i = Float64Array.from(Uu(e, r)), a = i.length, o = t; let s, u, l, c; for (l = 0, c = Array(o); l < o; ++l) { for (s = 0, u = 0; u < a; ++u)s += i[~~(Hu() * a)]; c[l] = s / a } return c.sort(Fu), [Lu(c, n / 2), Lu(c, 1 - n / 2)] }(this.values(), 1e3, .05, e), this._get = e), this._ci }, Yl.ci0 = function (e) { return this.ci(e)[0] }, Yl.ci1 = function (e) { return this.ci(e)[1] }, Xl.Definition = { type: "Aggregate", metadata: { generates: !0, changes: !0 }, params: [{ name: "groupby", type: "field", array: !0 }, { name: "ops", type: "enum", array: !0, values: Bl }, { name: "fields", type: "field", null: !0, array: !0 }, { name: "as", type: "string", null: !0, array: !0 }, { name: "drop", type: "boolean", default: !0 }, { name: "cross", type: "boolean", default: !1 }, { name: "key", type: "field" }] }, Ln(Xl, Eu, { transform(e, t) { const n = this, r = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = e.modified(); return n.stamp = r.stamp, n.value && (i || t.modified(n._inputs, !0)) ? (n._prev = n.value, n.value = i ? n.init(e) : {}, t.visit(t.SOURCE, (e => n.add(e)))) : (n.value = n.value || n.init(e), t.visit(t.REM, (e => n.rem(e))), t.visit(t.ADD, (e => n.add(e)))), r.modifies(n._outputs), n._drop = !1 !== e.drop, e.cross && n._dims.length > 1 && (n._drop = !1, n.cross()), t.clean() && n._drop && r.clean(!0).runAfter((() => this.clean())), n.changes(r) }, cross() { const e = this, t = e.value, n = e._dnames, r = n.map((() => ({}))), i = n.length; function a(e) { let t, a, o, s; for (t in e) for (o = e[t].tuple, a = 0; a < i; ++a)r[a][s = o[n[a]]] = s } a(e._prev), a(t), function a(o, s, u) { const l = n[u], c = r[u++]; for (const n in c) { const r = o ? o + "|" + n : n; s[l] = c[n], u < i ? a(r, s, u) : t[r] || e.cell(r, s) } }("", {}, 0) }, init(e) { const t = this._inputs = [], n = this._outputs = [], r = {}; function i(e) { const n = _n(Lt(e)), i = n.length; let a, o = 0; for (; o < i; ++o)r[a = n[o]] || (r[a] = 1, t.push(a)) } this._dims = _n(e.groupby), this._dnames = this._dims.map((e => { const t = Bt(e); return i(e), n.push(t), t })), this.cellkey = e.key ? e.key : $l(this._dims), this._countOnly = !0, this._counts = [], this._measures = []; const a = e.fields || [null], o = e.ops || ["count"], s = e.as || [], u = a.length, l = {}; let c, h, d, f, p, m; for (u !== o.length && Vt("Unmatched number of fields and aggregate ops."), m = 0; m < u; ++m)c = a[m], h = o[m], null == c && "count" !== h && Vt("Null aggregate field specified."), f = Bt(c), p = Rl(h, f, s[m]), n.push(p), "count" !== h ? (d = l[f], d || (i(c), d = l[f] = [], d.field = c, this._measures.push(d)), "count" !== h && (this._countOnly = !1), d.push(Ll(h, p))) : this._counts.push(p); return this._measures = this._measures.map((e => Hl(e, e.field))), {} }, cellkey: $l(), cell(e, t) { let n = this.value[e]; return n ? 0 === n.num && this._drop && n.stamp < this.stamp ? (n.stamp = this.stamp, this._adds[this._alen++] = n) : n.stamp < this.stamp && (n.stamp = this.stamp, this._mods[this._mlen++] = n) : (n = this.value[e] = this.newcell(e, t), this._adds[this._alen++] = n), n }, newcell(e, t) { const n = { key: e, num: 0, agg: null, tuple: this.newtuple(t, this._prev && this._prev[e]), stamp: this.stamp, store: !1 }; if (!this._countOnly) { const e = this._measures, t = e.length; n.agg = Array(t); for (let r = 0; r < t; ++r)n.agg[r] = new e[r](n) } return n.store && (n.data = new ql), n }, newtuple(e, t) { const n = this._dnames, r = this._dims, i = r.length, a = {}; for (let t = 0; t < i; ++t)a[n[t]] = r[t](e); return t ? eu(t.tuple, a) : Zs(a) }, clean() { const e = this.value; for (const t in e) 0 === e[t].num && delete e[t] }, add(e) { const t = this.cellkey(e), n = this.cell(t, e); if (n.num += 1, this._countOnly) return; n.store && n.data.add(e); const r = n.agg; for (let t = 0, n = r.length; t < n; ++t)r[t].add(r[t].get(e), e) }, rem(e) { const t = this.cellkey(e), n = this.cell(t, e); if (n.num -= 1, this._countOnly) return; n.store && n.data.rem(e); const r = n.agg; for (let t = 0, n = r.length; t < n; ++t)r[t].rem(r[t].get(e), e) }, celltuple(e) { const t = e.tuple, n = this._counts; e.store && e.data.values(); for (let r = 0, i = n.length; r < i; ++r)t[n[r]] = e.num; if (!this._countOnly) { const n = e.agg; for (let e = 0, r = n.length; e < r; ++e)n[e].set(t) } return t }, changes(e) { const t = this._adds, n = this._mods, r = this._prev, i = this._drop, a = e.add, o = e.rem, s = e.mod; let u, l, c, h; if (r) for (l in r) u = r[l], i && !u.num || o.push(u.tuple); for (c = 0, h = this._alen; c < h; ++c)a.push(this.celltuple(t[c])), t[c] = null; for (c = 0, h = this._mlen; c < h; ++c)u = n[c], (0 === u.num && i ? o : s).push(this.celltuple(u)), n[c] = null; return this._alen = this._mlen = 0, this._prev = null, e } }); function Kl(e) { Eu.call(this, null, e) } function Zl(e, t, n) { const r = e; let i = t || [], a = n || [], o = {}, s = 0; return { add: e => a.push(e), remove: e => o[r(e)] = ++s, size: () => i.length, data: (e, t) => (s && (i = i.filter((e => !o[r(e)])), o = {}, s = 0), t && e && i.sort(e), a.length && (i = e ? function (e, t, n, r) { const i = t.length, a = n.length; if (!a) return t; if (!i) return n; const o = r || new t.constructor(i + a); let s = 0, u = 0, l = 0; for (; s < i && u < a; ++l)o[l] = e(t[s], n[u]) > 0 ? n[u++] : t[s++]; for (; s < i; ++s, ++l)o[l] = t[s]; for (; u < a; ++u, ++l)o[l] = n[u]; return o }(e, i, a.sort(e)) : i.concat(a), a = []), i) } } function Jl(e) { Eu.call(this, [], e) } function Ql(e) { uu.call(this, null, ec, e) } function ec(e) { return this.value && !e.modified() ? this.value : Tn(e.fields, e.orders) } function tc(e) { Eu.call(this, null, e) } function nc(e) { Eu.call(this, null, e) } Kl.Definition = { type: "Bin", metadata: { modifies: !0 }, params: [{ name: "field", type: "field", required: !0 }, { name: "interval", type: "boolean", default: !0 }, { name: "anchor", type: "number" }, { name: "maxbins", type: "number", default: 20 }, { name: "base", type: "number", default: 10 }, { name: "divide", type: "number", array: !0, default: [5, 2] }, { name: "extent", type: "number", array: !0, length: 2, required: !0 }, { name: "span", type: "number" }, { name: "step", type: "number" }, { name: "steps", type: "number", array: !0 }, { name: "minstep", type: "number", default: 0 }, { name: "nice", type: "boolean", default: !0 }, { name: "name", type: "string" }, { name: "as", type: "string", array: !0, length: 2, default: ["bin0", "bin1"] }] }, Ln(Kl, Eu, { transform(e, t) { const n = !1 !== e.interval, r = this._bins(e), i = r.start, a = r.step, o = e.as || ["bin0", "bin1"], s = o[0], u = o[1]; let l; return l = e.modified() ? (t = t.reflow(!0)).SOURCE : t.modified(Lt(e.field)) ? t.ADD_MOD : t.ADD, t.visit(l, n ? e => { const t = r(e); e[s] = t, e[u] = null == t ? null : i + a * (1 + (t - i) / a) } : e => e[s] = r(e)), t.modifies(n ? o : s) }, _bins(e) { if (this.value && !e.modified()) return this.value; const t = e.field, n = function (e) { const t = e.maxbins || 20, n = e.base || 10, r = Math.log(n), i = e.divide || [5, 2]; let a, o, s, u, l, c, h = e.extent[0], d = e.extent[1]; const f = e.span || d - h || Math.abs(h) || 1; if (e.step) a = e.step; else if (e.steps) { for (u = f / t, l = 0, c = e.steps.length; l < c && e.steps[l] < u; ++l); a = e.steps[Math.max(0, l - 1)] } else { for (o = Math.ceil(Math.log(t) / r), s = e.minstep || 0, a = Math.max(s, Math.pow(n, Math.round(Math.log(f) / r) - o)); Math.ceil(f / a) > t;)a *= n; for (l = 0, c = i.length; l < c; ++l)u = a / i[l], u >= s && f / u <= t && (a = u) } u = Math.log(a); const p = u >= 0 ? 0 : 1 + ~~(-u / r), m = Math.pow(n, -p - 1); return (e.nice || void 0 === e.nice) && (u = Math.floor(h / a + m) * a, h = h < u ? u - a : u, d = Math.ceil(d / a) * a), { start: h, stop: d === h ? h + a : d, step: a } }(e), r = n.step; let i, a, o = n.start, s = o + Math.ceil((n.stop - o) / r) * r; null != (i = e.anchor) && (a = i - (o + r * Math.floor((i - o) / r)), o += a, s += a); const u = function (e) { let n = dn(t(e)); return null == n ? null : n < o ? -1 / 0 : n > s ? 1 / 0 : (n = Math.max(o, Math.min(n, s - r)), o + r * Math.floor(1e-14 + (n - o) / r)) }; return u.start = o, u.stop = n.stop, u.step = r, this.value = Pt(u, Lt(t), e.name || "bin_" + Bt(t)) } }), Jl.Definition = { type: "Collect", metadata: { source: !0 }, params: [{ name: "sort", type: "compare" }] }, Ln(Jl, Eu, { transform(e, t) { const n = t.fork(t.ALL), r = Zl(Xs, this.value, n.materialize(n.ADD).add), i = e.sort, a = t.changed() || i && (e.modified("sort") || t.modified(i.fields)); return n.visit(n.REM, r.remove), this.modified(a), this.value = n.source = r.data(tu(i), a), t.source && t.source.root && (this.value.root = t.source.root), n } }), Ln(Ql, uu), tc.Definition = { type: "CountPattern", metadata: { generates: !0, changes: !0 }, params: [{ name: "field", type: "field", required: !0 }, { name: "case", type: "enum", values: ["upper", "lower", "mixed"], default: "mixed" }, { name: "pattern", type: "string", default: '[\\w"]+' }, { name: "stopwords", type: "string", default: "" }, { name: "as", type: "string", array: !0, length: 2, default: ["text", "count"] }] }, Ln(tc, Eu, { transform(e, t) { const n = t => n => { for (var r, i = function (e, t, n) { switch (t) { case "upper": e = e.toUpperCase(); break; case "lower": e = e.toLowerCase() }return e.match(n) }(s(n), e.case, a) || [], u = 0, l = i.length; u < l; ++u)o.test(r = i[u]) || t(r) }, r = this._parameterCheck(e, t), i = this._counts, a = this._match, o = this._stop, s = e.field, u = e.as || ["text", "count"], l = n((e => i[e] = 1 + (i[e] || 0))), c = n((e => i[e] -= 1)); return r ? t.visit(t.SOURCE, l) : (t.visit(t.ADD, l), t.visit(t.REM, c)), this._finish(t, u) }, _parameterCheck(e, t) { let n = !1; return !e.modified("stopwords") && this._stop || (this._stop = new RegExp("^" + (e.stopwords || "") + "$", "i"), n = !0), !e.modified("pattern") && this._match || (this._match = new RegExp(e.pattern || "[\\w']+", "g"), n = !0), (e.modified("field") || t.modified(e.field.fields)) && (n = !0), n && (this._counts = {}), n }, _finish(e, t) { const n = this._counts, r = this._tuples || (this._tuples = {}), i = t[0], a = t[1], o = e.fork(e.NO_SOURCE | e.NO_FIELDS); let s, u, l; for (s in n) u = r[s], l = n[s] || 0, !u && l ? (r[s] = u = Zs({}), u[i] = s, u[a] = l, o.add.push(u)) : 0 === l ? (u && o.rem.push(u), n[s] = null, r[s] = null) : u[a] !== l && (u[a] = l, o.mod.push(u)); return o.modifies(t) } }), nc.Definition = { type: "Cross", metadata: { generates: !0 }, params: [{ name: "filter", type: "expr" }, { name: "as", type: "string", array: !0, length: 2, default: ["a", "b"] }] }, Ln(nc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE), r = e.as || ["a", "b"], i = r[0], a = r[1], o = !this.value || t.changed(t.ADD_REM) || e.modified("as") || e.modified("filter"); let s = this.value; return o ? (s && (n.rem = s), s = t.materialize(t.SOURCE).source, n.add = this.value = function (e, t, n, r) { for (var i, a, o = [], s = {}, u = e.length, l = 0; l < u; ++l)for (s[t] = a = e[l], i = 0; i < u; ++i)s[n] = e[i], r(s) && (o.push(Zs(s)), (s = {})[t] = a); return o }(s, i, a, e.filter || Zt)) : n.mod = s, n.source = this.value, n.modifies(r) } }); const rc = { kde: nl, mixture: function (e, t) { let n, r = 0; const i = { weights(e) { return arguments.length ? (n = function (e) { const t = []; let n, i = 0; for (n = 0; n < r; ++n)i += t[n] = null == e[n] ? 1 : +e[n]; for (n = 0; n < r; ++n)t[n] /= i; return t }(t = e || []), i) : t }, distributions(n) { return arguments.length ? (n ? (r = n.length, e = n) : (r = 0, e = []), i.weights(t)) : e }, sample() { const t = Hu(); let i = e[r - 1], a = n[0], o = 0; for (; o < r - 1; a += n[++o])if (t < a) { i = e[o]; break } return i.sample() }, pdf(t) { let i = 0, a = 0; for (; a < r; ++a)i += n[a] * e[a].pdf(t); return i }, cdf(t) { let i = 0, a = 0; for (; a < r; ++a)i += n[a] * e[a].cdf(t); return i }, icdf() { throw Error("Mixture icdf not supported.") } }; return i.distributions(e).weights(t) }, normal: tl, lognormal: function (e, t) { let n, r; const i = { mean(e) { return arguments.length ? (n = e || 0, i) : n }, stdev(e) { return arguments.length ? (r = null == e ? 1 : e, i) : r }, sample: () => rl(n, r), pdf: e => il(e, n, r), cdf: e => al(e, n, r), icdf: e => ol(e, n, r) }; return i.mean(e).stdev(t) }, uniform: function (e, t) { let n, r; const i = { min(e) { return arguments.length ? (n = e || 0, i) : n }, max(e) { return arguments.length ? (r = null == e ? 1 : e, i) : r }, sample: () => sl(n, r), pdf: e => ul(e, n, r), cdf: e => ll(e, n, r), icdf: e => cl(e, n, r) }; return null == t && (t = null == e ? 1 : e, e = 0), i.min(e).max(t) } }, ic = "function"; function ac(e, t) { const n = e[ic]; zn(rc, n) || Vt("Unknown distribution function: " + n); const r = rc[n](); for (const n in e) "field" === n ? r.data((e.from || t()).map(e[n])) : "distributions" === n ? r[n](e[n].map((e => ac(e, t)))) : typeof r[n] === ic && r[n](e[n]); return r } function oc(e) { Eu.call(this, null, e) } const sc = [{ key: { function: "normal" }, params: [{ name: "mean", type: "number", default: 0 }, { name: "stdev", type: "number", default: 1 }] }, { key: { function: "lognormal" }, params: [{ name: "mean", type: "number", default: 0 }, { name: "stdev", type: "number", default: 1 }] }, { key: { function: "uniform" }, params: [{ name: "min", type: "number", default: 0 }, { name: "max", type: "number", default: 1 }] }, { key: { function: "kde" }, params: [{ name: "field", type: "field", required: !0 }, { name: "from", type: "data" }, { name: "bandwidth", type: "number", default: 0 }] }], uc = { key: { function: "mixture" }, params: [{ name: "distributions", type: "param", array: !0, params: sc }, { name: "weights", type: "number", array: !0 }] }; function lc(e, t) { return e ? e.map(((e, n) => t[n] || Bt(e))) : null } function cc(e, t, n) { const r = [], i = e => e(u); let a, o, s, u, l, c; if (null == t) r.push(e.map(n)); else for (a = {}, o = 0, s = e.length; o < s; ++o)u = e[o], l = t.map(i), c = a[l], c || (a[l] = c = [], c.dims = l, r.push(c)), c.push(n(u)); return r } oc.Definition = { type: "Density", metadata: { generates: !0 }, params: [{ name: "extent", type: "number", array: !0, length: 2 }, { name: "steps", type: "number" }, { name: "minsteps", type: "number", default: 25 }, { name: "maxsteps", type: "number", default: 200 }, { name: "method", type: "string", default: "pdf", values: ["pdf", "cdf"] }, { name: "distribution", type: "param", params: sc.concat(uc) }, { name: "as", type: "string", array: !0, default: ["value", "density"] }] }, Ln(oc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE | t.NO_FIELDS); if (!this.value || t.changed() || e.modified()) { const r = ac(e.distribution, function (e) { return () => e.materialize(e.SOURCE).source }(t)), i = e.steps || e.minsteps || 25, a = e.steps || e.maxsteps || 200; let o = e.method || "pdf"; "pdf" !== o && "cdf" !== o && Vt("Invalid density method: " + o), e.extent || r.data || Vt("Missing density extent parameter."), o = r[o]; const s = e.as || ["value", "density"], u = wl(o, e.extent || Rn(r.data()), i, a).map((e => { const t = {}; return t[s[0]] = e[0], t[s[1]] = e[1], Zs(t) })); this.value && (n.rem = this.value), this.value = n.add = n.source = u } return n } }); function hc(e) { Eu.call(this, null, e) } hc.Definition = { type: "DotBin", metadata: { modifies: !0 }, params: [{ name: "field", type: "field", required: !0 }, { name: "groupby", type: "field", array: !0 }, { name: "step", type: "number" }, { name: "smooth", type: "boolean", default: !1 }, { name: "as", type: "string", default: "bin" }] }; function dc(e) { uu.call(this, null, fc, e), this.modified(!0) } function fc(e) { const t = e.expr; return this.value && !e.modified("expr") ? this.value : Pt((n => t(n, e)), Lt(t), Bt(t)) } function pc(e) { Eu.call(this, [void 0, void 0], e) } function mc(e, t) { uu.call(this, e), this.parent = t, this.count = 0 } function gc(e) { Eu.call(this, {}, e), this._keys = Bn(); const t = this._targets = []; t.active = 0, t.forEach = e => { for (let n = 0, r = t.active; n < r; ++n)e(t[n], n, t) } } function yc(e) { uu.call(this, null, bc, e) } function bc(e) { return this.value && !e.modified() ? this.value : on(e.name) ? _n(e.name).map((e => Ht(e))) : Ht(e.name, e.as) } function vc(e) { Eu.call(this, Bn(), e) } function xc(e) { Eu.call(this, [], e) } function wc(e) { Eu.call(this, [], e) } function kc(e) { Eu.call(this, null, e) } function Sc(e) { Eu.call(this, [], e) } Ln(hc, Eu, { transform(e, t) { if (this.value && !e.modified() && !t.changed()) return t; const n = t.materialize(t.SOURCE).source, r = cc(t.source, e.groupby, Yt), i = e.smooth || !1, a = e.field, o = e.step || ((e, t) => qn(Rn(e, t)) / 30)(n, a), s = tu(((e, t) => a(e) - a(t))), u = e.as || "bin", l = r.length; let c, h = 1 / 0, d = -1 / 0, f = 0; for (; f < l; ++f) { const e = r[f].sort(s); c = -1; for (const t of qu(e, o, i, a)) t < h && (h = t), t > d && (d = t), e[++c][u] = t } return this.value = { start: h, stop: d, step: o }, t.reflow(!0).modifies(u) } }), Ln(dc, uu), pc.Definition = { type: "Extent", metadata: {}, params: [{ name: "field", type: "field", required: !0 }] }, Ln(pc, Eu, { transform(e, t) { const n = this.value, r = e.field, i = t.changed() || t.modified(r.fields) || e.modified("field"); let a = n[0], o = n[1]; if ((i || null == a) && (a = 1 / 0, o = -1 / 0), t.visit(i ? t.SOURCE : t.ADD, (e => { const t = dn(r(e)); null != t && (t < a && (a = t), t > o && (o = t)) })), !Number.isFinite(a) || !Number.isFinite(o)) { let e = Bt(r); e && (e = ` for field "${e}"`), t.dataflow.warn(`Infinite extent${e}: [${a}, ${o}]`), a = o = void 0 } this.value = [a, o] } }), Ln(mc, uu, { connect(e) { return this.detachSubflow = e.detachSubflow, this.targets().add(e), e.source = this }, add(e) { this.count += 1, this.value.add.push(e) }, rem(e) { this.count -= 1, this.value.rem.push(e) }, mod(e) { this.value.mod.push(e) }, init(e) { this.value.init(e, e.NO_SOURCE) }, evaluate() { return this.value } }), Ln(gc, Eu, { activate(e) { this._targets[this._targets.active++] = e }, subflow(e, t, n, r) { const i = this.value; let a, o, s = zn(i, e) && i[e]; return s ? s.value.stamp < n.stamp && (s.init(n), this.activate(s)) : (o = r || (o = this._group[e]) && o.tuple, a = n.dataflow, s = new mc(n.fork(n.NO_SOURCE), this), a.add(s).connect(t(a, e, o)), i[e] = s, this.activate(s)), s }, clean() { const e = this.value; let t = 0; for (const n in e) if (0 === e[n].count) { const r = e[n].detachSubflow; r && r(), delete e[n], ++t } if (t) { const e = this._targets.filter((e => e && e.count > 0)); this.initTargets(e) } }, initTargets(e) { const t = this._targets, n = t.length, r = e ? e.length : 0; let i = 0; for (; i < r; ++i)t[i] = e[i]; for (; i < n && null != t[i]; ++i)t[i] = null; t.active = r }, transform(e, t) { const n = t.dataflow, r = e.key, i = e.subflow, a = this._keys, o = e.modified("key"), s = e => this.subflow(e, i, t); return this._group = e.group || {}, this.initTargets(), t.visit(t.REM, (e => { const t = Xs(e), n = a.get(t); void 0 !== n && (a.delete(t), s(n).rem(e)) })), t.visit(t.ADD, (e => { const t = r(e); a.set(Xs(e), t), s(t).add(e) })), o || t.modified(r.fields) ? t.visit(t.MOD, (e => { const t = Xs(e), n = a.get(t), i = r(e); n === i ? s(i).mod(e) : (a.set(t, i), s(n).rem(e), s(i).add(e)) })) : t.changed(t.MOD) && t.visit(t.MOD, (e => { s(a.get(Xs(e))).mod(e) })), o && t.visit(t.REFLOW, (e => { const t = Xs(e), n = a.get(t), i = r(e); n !== i && (a.set(t, i), s(n).rem(e), s(i).add(e)) })), t.clean() ? n.runAfter((() => { this.clean(), a.clean() })) : a.empty > n.cleanThreshold && n.runAfter(a.clean), t } }), Ln(yc, uu), vc.Definition = { type: "Filter", metadata: { changes: !0 }, params: [{ name: "expr", type: "expr", required: !0 }] }, Ln(vc, Eu, { transform(e, t) { const n = t.dataflow, r = this.value, i = t.fork(), a = i.add, o = i.rem, s = i.mod, u = e.expr; let l = !0; function c(t) { const n = Xs(t), i = u(t, e), c = r.get(n); i && c ? (r.delete(n), a.push(t)) : i || c ? l && i && !c && s.push(t) : (r.set(n, 1), o.push(t)) } return t.visit(t.REM, (e => { const t = Xs(e); r.has(t) ? r.delete(t) : o.push(e) })), t.visit(t.ADD, (t => { u(t, e) ? a.push(t) : r.set(Xs(t), 1) })), t.visit(t.MOD, c), e.modified() && (l = !1, t.visit(t.REFLOW, c)), r.empty > n.cleanThreshold && n.runAfter(r.clean), i } }), xc.Definition = { type: "Flatten", metadata: { generates: !0 }, params: [{ name: "fields", type: "field", array: !0, required: !0 }, { name: "index", type: "string" }, { name: "as", type: "string", array: !0 }] }, Ln(xc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE), r = e.fields, i = lc(r, e.as || []), a = e.index || null, o = i.length; return n.rem = this.value, t.visit(t.SOURCE, (e => { const t = r.map((t => t(e))), s = t.reduce(((e, t) => Math.max(e, t.length)), 0); let u, l, c, h = 0; for (; h < s; ++h) { for (l = Js(e), u = 0; u < o; ++u)l[i[u]] = null == (c = t[u][h]) ? null : c; a && (l[a] = h), n.add.push(l) } })), this.value = n.source = n.add, a && n.modifies(a), n.modifies(i) } }), wc.Definition = { type: "Fold", metadata: { generates: !0 }, params: [{ name: "fields", type: "field", array: !0, required: !0 }, { name: "as", type: "string", array: !0, length: 2, default: ["key", "value"] }] }, Ln(wc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE), r = e.fields, i = r.map(Bt), a = e.as || ["key", "value"], o = a[0], s = a[1], u = r.length; return n.rem = this.value, t.visit(t.SOURCE, (e => { for (let t, a = 0; a < u; ++a)t = Js(e), t[o] = i[a], t[s] = r[a](e), n.add.push(t) })), this.value = n.source = n.add, n.modifies(a) } }), kc.Definition = { type: "Formula", metadata: { modifies: !0 }, params: [{ name: "expr", type: "expr", required: !0 }, { name: "as", type: "string", required: !0 }, { name: "initonly", type: "boolean" }] }, Ln(kc, Eu, { transform(e, t) { const n = e.expr, r = e.as, i = e.modified(), a = e.initonly ? t.ADD : i ? t.SOURCE : t.modified(n.fields) || t.modified(r) ? t.ADD_MOD : t.ADD; return i && (t = t.materialize().reflow(!0)), e.initonly || t.modifies(r), t.visit(a, (t => t[r] = n(t, e))) } }), Ln(Sc, Eu, { transform(e, t) { const n = t.fork(t.ALL), r = e.generator; let i, a, o, s = this.value, u = e.size - s.length; if (u > 0) { for (i = []; --u >= 0;)i.push(o = Zs(r(e))), s.push(o); n.add = n.add.length ? n.materialize(n.ADD).add.concat(i) : i } else a = s.slice(0, -u), n.rem = n.rem.length ? n.materialize(n.REM).rem.concat(a) : a, s = s.slice(-u); return n.source = this.value = s, n } }); const _c = { value: "value", median: Ml, mean: function (e, t) { let n = 0, r = 0; if (void 0 === t) for (let t of e) null != t && (t = +t) >= t && (++n, r += t); else { let i = -1; for (let a of e) null != (a = t(a, ++i, e)) && (a = +a) >= a && (++n, r += a) } if (n) return r / n }, min: _l, max: Sl }, Cc = []; function Ac(e) { Eu.call(this, [], e) } function Tc(e) { Xl.call(this, e) } function Ec(e) { Eu.call(this, null, e) } function Nc(e) { uu.call(this, null, Ic, e) } function Ic(e) { return this.value && !e.modified() ? this.value : Gn(e.fields, e.flat) } function Mc(e) { Eu.call(this, [], e), this._pending = null } function Fc(e, t, n) { n.forEach(Zs); const r = t.fork(t.NO_FIELDS & t.NO_SOURCE); return r.rem = e.value, e.value = r.source = r.add = n, e._pending = null, r.rem.length && r.clean(!0), r } function Dc(e) { Eu.call(this, {}, e) } function $c(e) { uu.call(this, null, Rc, e) } function Rc(e) { if (this.value && !e.modified()) return this.value; const t = e.extents, n = t.length; let r, i, a = 1 / 0, o = -1 / 0; for (r = 0; r < n; ++r)i = t[r], i[0] < a && (a = i[0]), i[1] > o && (o = i[1]); return [a, o] } function Oc(e) { uu.call(this, null, zc, e) } function zc(e) { return this.value && !e.modified() ? this.value : e.values.reduce(((e, t) => e.concat(t)), []) } function Pc(e) { Eu.call(this, null, e) } function Bc(e) { Xl.call(this, e) } function Lc(e) { gc.call(this, e) } function jc(e) { Eu.call(this, null, e) } function Uc(e) { Eu.call(this, null, e) } function Wc(e) { Eu.call(this, null, e) } Ac.Definition = { type: "Impute", metadata: { changes: !0 }, params: [{ name: "field", type: "field", required: !0 }, { name: "key", type: "field", required: !0 }, { name: "keyvals", array: !0 }, { name: "groupby", type: "field", array: !0 }, { name: "method", type: "enum", default: "value", values: ["value", "mean", "median", "max", "min"] }, { name: "value", default: 0 }] }, Ln(Ac, Eu, { transform(e, t) { var n, r, i, a, o, s, u, l, c, h, d = t.fork(t.ALL), f = function (e) { var t, n = e.method || _c.value; if (null != _c[n]) return n === _c.value ? (t = void 0 !== e.value ? e.value : 0, () => t) : _c[n]; Vt("Unrecognized imputation method: " + n) }(e), p = function (e) { const t = e.field; return e => e ? t(e) : NaN }(e), m = Bt(e.field), g = Bt(e.key), y = (e.groupby || []).map(Bt), b = function (e, t, n, r) { var i, a, o, s, u, l, c, h, d = e => e(h), f = [], p = r ? r.slice() : [], m = {}, g = {}; for (p.forEach(((e, t) => m[e] = t + 1)), s = 0, c = e.length; s < c; ++s)l = n(h = e[s]), u = m[l] || (m[l] = p.push(l)), (o = g[a = (i = t ? t.map(d) : Cc) + ""]) || (o = g[a] = [], f.push(o), o.values = i), o[u - 1] = h; return f.domain = p, f }(t.source, e.groupby, e.key, e.keyvals), v = [], x = this.value, w = b.domain.length; for (o = 0, l = b.length; o < l; ++o)for (i = (n = b[o]).values, r = NaN, u = 0; u < w; ++u)if (null == n[u]) { for (a = b.domain[u], h = { _impute: !0 }, s = 0, c = i.length; s < c; ++s)h[y[s]] = i[s]; h[g] = a, h[m] = Number.isNaN(r) ? r = f(n, p) : r, v.push(Zs(h)) } return v.length && (d.add = d.materialize(d.ADD).add.concat(v)), x.length && (d.rem = d.materialize(d.REM).rem.concat(x)), this.value = v, d } }), Tc.Definition = { type: "JoinAggregate", metadata: { modifies: !0 }, params: [{ name: "groupby", type: "field", array: !0 }, { name: "fields", type: "field", null: !0, array: !0 }, { name: "ops", type: "enum", array: !0, values: Bl }, { name: "as", type: "string", null: !0, array: !0 }, { name: "key", type: "field" }] }, Ln(Tc, Xl, { transform(e, t) { const n = this, r = e.modified(); let i; return n.value && (r || t.modified(n._inputs, !0)) ? (i = n.value = r ? n.init(e) : {}, t.visit(t.SOURCE, (e => n.add(e)))) : (i = n.value = n.value || this.init(e), t.visit(t.REM, (e => n.rem(e))), t.visit(t.ADD, (e => n.add(e)))), n.changes(), t.visit(t.SOURCE, (e => { $n(e, i[n.cellkey(e)].tuple) })), t.reflow(r).modifies(this._outputs) }, changes() { const e = this._adds, t = this._mods; let n, r; for (n = 0, r = this._alen; n < r; ++n)this.celltuple(e[n]), e[n] = null; for (n = 0, r = this._mlen; n < r; ++n)this.celltuple(t[n]), t[n] = null; this._alen = this._mlen = 0 } }), Ec.Definition = { type: "KDE", metadata: { generates: !0 }, params: [{ name: "groupby", type: "field", array: !0 }, { name: "field", type: "field", required: !0 }, { name: "cumulative", type: "boolean", default: !1 }, { name: "counts", type: "boolean", default: !1 }, { name: "bandwidth", type: "number", default: 0 }, { name: "extent", type: "number", array: !0, length: 2 }, { name: "resolve", type: "enum", values: ["shared", "independent"], default: "independent" }, { name: "steps", type: "number" }, { name: "minsteps", type: "number", default: 25 }, { name: "maxsteps", type: "number", default: 200 }, { name: "as", type: "string", array: !0, default: ["value", "density"] }] }, Ln(Ec, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE | t.NO_FIELDS); if (!this.value || t.changed() || e.modified()) { const r = t.materialize(t.SOURCE).source, i = cc(r, e.groupby, e.field), a = (e.groupby || []).map(Bt), o = e.bandwidth, s = e.cumulative ? "cdf" : "pdf", u = e.as || ["value", "density"], l = []; let c = e.extent, h = e.steps || e.minsteps || 25, d = e.steps || e.maxsteps || 200; "pdf" !== s && "cdf" !== s && Vt("Invalid density method: " + s), "shared" === e.resolve && (c || (c = Rn(r, e.field)), h = d = e.steps || d), i.forEach((t => { const n = nl(t, o)[s], r = e.counts ? t.length : 1; wl(n, c || Rn(t), h, d).forEach((e => { const n = {}; for (let e = 0; e < a.length; ++e)n[a[e]] = t.dims[e]; n[u[0]] = e[0], n[u[1]] = e[1] * r, l.push(Zs(n)) })) })), this.value && (n.rem = this.value), this.value = n.add = n.source = l } return n } }), Ln(Nc, uu), Ln(Mc, Eu, { transform(e, t) { const n = t.dataflow; if (this._pending) return Fc(this, t, this._pending); if (function (e) { return e.modified("async") && !(e.modified("values") || e.modified("url") || e.modified("format")) }(e)) return t.StopPropagation; if (e.values) return Fc(this, t, n.parse(e.values, e.format)); if (e.async) { const t = n.request(e.url, e.format).then((e => (this._pending = _n(e.data), e => e.touch(this)))); return { async: t } } return n.request(e.url, e.format).then((e => Fc(this, t, _n(e.data)))) } }), Dc.Definition = { type: "Lookup", metadata: { modifies: !0 }, params: [{ name: "index", type: "index", params: [{ name: "from", type: "data", required: !0 }, { name: "key", type: "field", required: !0 }] }, { name: "values", type: "field", array: !0 }, { name: "fields", type: "field", array: !0, required: !0 }, { name: "as", type: "string", array: !0 }, { name: "default", default: null }] }, Ln(Dc, Eu, { transform(e, t) { const n = e.fields, r = e.index, i = e.values, a = null == e.default ? null : e.default, o = e.modified(), s = n.length; let u, l, c, h = o ? t.SOURCE : t.ADD, d = t, f = e.as; return i ? (l = i.length, s > 1 && !f && Vt('Multi-field lookup requires explicit "as" parameter.'), f && f.length !== s * l && Vt('The "as" parameter has too few output field names.'), f = f || i.map(Bt), u = function (e) { for (var t, o, u = 0, c = 0; u < s; ++u)if (null == (o = r.get(n[u](e)))) for (t = 0; t < l; ++t, ++c)e[f[c]] = a; else for (t = 0; t < l; ++t, ++c)e[f[c]] = i[t](o) }) : (f || Vt("Missing output field names."), u = function (e) { for (var t, i = 0; i < s; ++i)t = r.get(n[i](e)), e[f[i]] = null == t ? a : t }), o ? d = t.reflow(!0) : (c = n.some((e => t.modified(e.fields))), h |= c ? t.MOD : 0), t.visit(h, u), d.modifies(f) } }), Ln($c, uu), Ln(Oc, uu), Ln(Pc, Eu, { transform(e, t) { return this.modified(e.modified()), this.value = e, t.fork(t.NO_SOURCE | t.NO_FIELDS) } }), Bc.Definition = { type: "Pivot", metadata: { generates: !0, changes: !0 }, params: [{ name: "groupby", type: "field", array: !0 }, { name: "field", type: "field", required: !0 }, { name: "value", type: "field", required: !0 }, { name: "op", type: "enum", values: Bl, default: "sum" }, { name: "limit", type: "number", default: 0 }, { name: "key", type: "field" }] }, Ln(Bc, Xl, { _transform: Xl.prototype.transform, transform(e, t) { return this._transform(function (e, t) { const n = e.field, r = e.value, i = ("count" === e.op ? "__count__" : e.op) || "sum", a = Lt(n).concat(Lt(r)), o = function (e, t, n) { const r = {}, i = []; return n.visit(n.SOURCE, (t => { const n = e(t); r[n] || (r[n] = 1, i.push(n)) })), i.sort(En), t ? i.slice(0, t) : i }(n, e.limit || 0, t); t.changed() && e.set("__pivot__", null, null, !0); return { key: e.key, groupby: e.groupby, ops: o.map((() => i)), fields: o.map((e => function (e, t, n, r) { return Pt((r => t(r) === e ? n(r) : NaN), r, e + "") }(e, n, r, a))), as: o.map((e => e + "")), modified: e.modified.bind(e) } }(e, t), t) } }), Ln(Lc, gc, { transform(e, t) { const n = e.subflow, r = e.field, i = e => this.subflow(Xs(e), n, t, e); return (e.modified("field") || r && t.modified(Lt(r))) && Vt("PreFacet does not support field modification."), this.initTargets(), r ? (t.visit(t.MOD, (e => { const t = i(e); r(e).forEach((e => t.mod(e))) })), t.visit(t.ADD, (e => { const t = i(e); r(e).forEach((e => t.add(Zs(e)))) })), t.visit(t.REM, (e => { const t = i(e); r(e).forEach((e => t.rem(e))) }))) : (t.visit(t.MOD, (e => i(e).mod(e))), t.visit(t.ADD, (e => i(e).add(e))), t.visit(t.REM, (e => i(e).rem(e)))), t.clean() && t.runAfter((() => this.clean())), t } }), jc.Definition = { type: "Project", metadata: { generates: !0, changes: !0 }, params: [{ name: "fields", type: "field", array: !0 }, { name: "as", type: "string", null: !0, array: !0 }] }, Ln(jc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE), r = e.fields, i = lc(e.fields, e.as || []), a = r ? (e, t) => function (e, t, n, r) { for (let i = 0, a = n.length; i < a; ++i)t[r[i]] = n[i](e); return t }(e, t, r, i) : Qs; let o; return this.value ? o = this.value : (t = t.addAll(), o = this.value = {}), t.visit(t.REM, (e => { const t = Xs(e); n.rem.push(o[t]), o[t] = null })), t.visit(t.ADD, (e => { const t = a(e, Zs({})); o[Xs(e)] = t, n.add.push(t) })), t.visit(t.MOD, (e => { n.mod.push(a(e, o[Xs(e)])) })), n } }), Ln(Uc, Eu, { transform(e, t) { return this.value = e.value, e.modified("value") ? t.fork(t.NO_SOURCE | t.NO_FIELDS) : t.StopPropagation } }), Wc.Definition = { type: "Quantile", metadata: { generates: !0, changes: !0 }, params: [{ name: "groupby", type: "field", array: !0 }, { name: "field", type: "field", required: !0 }, { name: "probs", type: "number", array: !0 }, { name: "step", type: "number", default: .01 }, { name: "as", type: "string", array: !0, default: ["prob", "value"] }] }; function Vc(e) { Eu.call(this, null, e) } function Gc(e) { Eu.call(this, [], e), this.count = 0 } function Hc(e) { Eu.call(this, null, e) } function qc(e) { Eu.call(this, null, e), this.modified(!0) } function Yc(e) { Eu.call(this, null, e) } Ln(Wc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE | t.NO_FIELDS), r = e.as || ["prob", "value"]; if (this.value && !e.modified() && !t.changed()) return n.source = this.value, n; const i = cc(t.materialize(t.SOURCE).source, e.groupby, e.field), a = (e.groupby || []).map(Bt), o = [], s = e.step || .01, u = e.probs || Fl(s / 2, 1 - 1e-14, s), l = u.length; return i.forEach((e => { const t = Wu(e, u); for (let n = 0; n < l; ++n) { const i = {}; for (let t = 0; t < a.length; ++t)i[a[t]] = e.dims[t]; i[r[0]] = u[n], i[r[1]] = t[n], o.push(Zs(i)) } })), this.value && (n.rem = this.value), this.value = n.add = n.source = o, n } }), Ln(Vc, Eu, { transform(e, t) { let n, r; return this.value ? r = this.value : (n = t = t.addAll(), r = this.value = {}), e.derive && (n = t.fork(t.NO_SOURCE), t.visit(t.REM, (e => { const t = Xs(e); n.rem.push(r[t]), r[t] = null })), t.visit(t.ADD, (e => { const t = Js(e); r[Xs(e)] = t, n.add.push(t) })), t.visit(t.MOD, (e => { const t = r[Xs(e)]; for (const r in e) t[r] = e[r], n.modifies(r); n.mod.push(t) }))), n } }), Gc.Definition = { type: "Sample", metadata: {}, params: [{ name: "size", type: "number", default: 1e3 }] }, Ln(Gc, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE), r = e.modified("size"), i = e.size, a = this.value.reduce(((e, t) => (e[Xs(t)] = 1, e)), {}); let o = this.value, s = this.count, u = 0; function l(e) { let t, r; o.length < i ? o.push(e) : (r = ~~((s + 1) * Hu()), r < o.length && r >= u && (t = o[r], a[Xs(t)] && n.rem.push(t), o[r] = e)), ++s } if (t.rem.length && (t.visit(t.REM, (e => { const t = Xs(e); a[t] && (a[t] = -1, n.rem.push(e)), --s })), o = o.filter((e => -1 !== a[Xs(e)]))), (t.rem.length || r) && o.length < i && t.source && (u = s = o.length, t.visit(t.SOURCE, (e => { a[Xs(e)] || l(e) })), u = -1), r && o.length > i) { const e = o.length - i; for (let t = 0; t < e; ++t)a[Xs(o[t])] = -1, n.rem.push(o[t]); o = o.slice(e) } return t.mod.length && t.visit(t.MOD, (e => { a[Xs(e)] && n.mod.push(e) })), t.add.length && t.visit(t.ADD, l), (t.add.length || u < 0) && (n.add = o.filter((e => !a[Xs(e)]))), this.count = s, this.value = n.source = o, n } }), Hc.Definition = { type: "Sequence", metadata: { generates: !0, changes: !0 }, params: [{ name: "start", type: "number", required: !0 }, { name: "stop", type: "number", required: !0 }, { name: "step", type: "number", default: 1 }, { name: "as", type: "string", default: "data" }] }, Ln(Hc, Eu, { transform(e, t) { if (this.value && !e.modified()) return; const n = t.materialize().fork(t.MOD), r = e.as || "data"; return n.rem = this.value ? t.rem.concat(this.value) : t.rem, this.value = Fl(e.start, e.stop, e.step || 1).map((e => { const t = {}; return t[r] = e, Zs(t) })), n.add = t.add.concat(this.value), n } }), Ln(qc, Eu, { transform(e, t) { return this.value = t.source, t.changed() ? t.fork(t.NO_SOURCE | t.NO_FIELDS) : t.StopPropagation } }); const Xc = ["unit0", "unit1"]; function Kc(e) { Eu.call(this, Bn(), e) } function Zc(e) { Eu.call(this, null, e) } Yc.Definition = { type: "TimeUnit", metadata: { modifies: !0 }, params: [{ name: "field", type: "field", required: !0 }, { name: "interval", type: "boolean", default: !0 }, { name: "units", type: "enum", values: Wi, array: !0 }, { name: "step", type: "number", default: 1 }, { name: "maxbins", type: "number", default: 40 }, { name: "extent", type: "date", array: !0 }, { name: "timezone", type: "enum", default: "local", values: ["local", "utc"] }, { name: "as", type: "string", array: !0, length: 2, default: Xc }] }, Ln(Yc, Eu, { transform(e, t) { const n = e.field, r = !1 !== e.interval, i = "utc" === e.timezone, a = this._floor(e, t), o = (i ? pa : fa)(a.unit).offset, s = e.as || Xc, u = s[0], l = s[1], c = a.step; let h = a.start || 1 / 0, d = a.stop || -1 / 0, f = t.ADD; return (e.modified() || t.modified(Lt(n))) && (f = (t = t.reflow(!0)).SOURCE, h = 1 / 0, d = -1 / 0), t.visit(f, (e => { const t = n(e); let i, s; null == t ? (e[u] = null, r && (e[l] = null)) : (e[u] = i = s = a(t), r && (e[l] = s = o(i, c)), i < h && (h = i), s > d && (d = s)) })), a.start = h, a.stop = d, t.modifies(r ? s : u) }, _floor(e, t) { const n = "utc" === e.timezone, { units: r, step: i } = e.units ? { units: e.units, step: e.step || 1 } : Ma({ extent: e.extent || Rn(t.materialize(t.SOURCE).source, e.field), maxbins: e.maxbins }), a = Gi(r), o = this.value || {}, s = (n ? ca : sa)(a, i); return s.unit = hn(a), s.units = a, s.step = i, s.start = o.start, s.stop = o.stop, this.value = s } }), Ln(Kc, Eu, { transform(e, t) { const n = t.dataflow, r = e.field, i = this.value, a = e => i.set(r(e), e); let o = !0; return e.modified("field") || t.modified(r.fields) ? (i.clear(), t.visit(t.SOURCE, a)) : t.changed() ? (t.visit(t.REM, (e => i.delete(r(e)))), t.visit(t.ADD, a)) : o = !1, this.modified(o), i.empty > n.cleanThreshold && n.runAfter(i.clean), t.fork() } }), Ln(Zc, Eu, { transform(e, t) { (!this.value || e.modified("field") || e.modified("sort") || t.changed() || e.sort && t.modified(e.sort.fields)) && (this.value = (e.sort ? t.source.slice().sort(tu(e.sort)) : t.source).map(e.field)) } }); const Jc = { row_number: function () { return { next: e => e.index + 1 } }, rank: function () { let e; return { init: () => e = 1, next: t => { const n = t.index, r = t.data; return n && t.compare(r[n - 1], r[n]) ? e = n + 1 : e } } }, dense_rank: function () { let e; return { init: () => e = 1, next: t => { const n = t.index, r = t.data; return n && t.compare(r[n - 1], r[n]) ? ++e : e } } }, percent_rank: function () { const e = Jc.rank(), t = e.next; return { init: e.init, next: e => (t(e) - 1) / (e.data.length - 1) } }, cume_dist: function () { let e; return { init: () => e = 0, next: t => { const n = t.data, r = t.compare; let i = t.index; if (e < i) { for (; i + 1 < n.length && !r(n[i], n[i + 1]);)++i; e = i } return (1 + e) / n.length } } }, ntile: function (e, t) { (t = +t) > 0 || Vt("ntile num must be greater than zero."); const n = Jc.cume_dist(), r = n.next; return { init: n.init, next: e => Math.ceil(t * r(e)) } }, lag: function (e, t) { return t = +t || 1, { next: n => { const r = n.index - t; return r >= 0 ? e(n.data[r]) : null } } }, lead: function (e, t) { return t = +t || 1, { next: n => { const r = n.index + t, i = n.data; return r < i.length ? e(i[r]) : null } } }, first_value: function (e) { return { next: t => e(t.data[t.i0]) } }, last_value: function (e) { return { next: t => e(t.data[t.i1 - 1]) } }, nth_value: function (e, t) { return (t = +t) > 0 || Vt("nth_value nth must be greater than zero."), { next: n => { const r = n.i0 + (t - 1); return r < n.i1 ? e(n.data[r]) : null } } }, prev_value: function (e) { let t; return { init: () => t = null, next: n => { const r = e(n.data[n.index]); return null != r ? t = r : t } } }, next_value: function (e) { let t, n; return { init: () => (t = null, n = -1), next: r => { const i = r.data; return r.index <= n ? t : (n = function (e, t, n) { for (let r = t.length; n < r; ++n) { if (null != e(t[n])) return n } return -1 }(e, i, r.index)) < 0 ? (n = i.length, t = null) : t = e(i[n]) } } } }; const Qc = Object.keys(Jc); function eh(e) { const t = _n(e.ops), n = _n(e.fields), r = _n(e.params), i = _n(e.as), a = this.outputs = [], o = this.windows = [], s = {}, u = {}, l = [], c = []; let h = !0; function d(e) { _n(Lt(e)).forEach((e => s[e] = 1)) } d(e.sort), t.forEach(((e, t) => { const s = n[t], f = Bt(s), p = Rl(e, f, i[t]); if (d(s), a.push(p), zn(Jc, e)) o.push(function (e, t, n, r) { const i = Jc[e](t, n); return { init: i.init || Xt, update: function (e, t) { t[r] = i.next(e) } } }(e, n[t], r[t], p)); else { if (null == s && "count" !== e && Vt("Null aggregate field specified."), "count" === e) return void l.push(p); h = !1; let t = u[f]; t || (t = u[f] = [], t.field = s, c.push(t)), t.push(Ll(e, p)) } })), (l.length || c.length) && (this.cell = function (e, t, n) { e = e.map((e => Hl(e, e.field))); const r = { num: 0, agg: null, store: !1, count: t }; if (!n) for (var i = e.length, a = r.agg = Array(i), o = 0; o < i; ++o)a[o] = new e[o](r); if (r.store) var s = r.data = new ql; return r.add = function (e) { if (r.num += 1, !n) { s && s.add(e); for (let t = 0; t < i; ++t)a[t].add(a[t].get(e), e) } }, r.rem = function (e) { if (r.num -= 1, !n) { s && s.rem(e); for (let t = 0; t < i; ++t)a[t].rem(a[t].get(e), e) } }, r.set = function (e) { let i, o; for (s && s.values(), i = 0, o = t.length; i < o; ++i)e[t[i]] = r.num; if (!n) for (i = 0, o = a.length; i < o; ++i)a[i].set(e) }, r.init = function () { r.num = 0, s && s.reset(); for (let e = 0; e < i; ++e)a[e].init() }, r }(c, l, h)), this.inputs = Object.keys(s) } const th = eh.prototype; function nh(e) { Eu.call(this, {}, e), this._mlen = 0, this._mods = [] } function rh(e, t, n, r) { const i = r.sort, a = i && !r.ignorePeers, o = r.frame || [null, 0], s = e.data(n), u = s.length, l = a ? Dl(i) : null, c = { i0: 0, i1: 0, p0: 0, p1: 0, index: 0, data: s, compare: i || Fn(-1) }; t.init(); for (let e = 0; e < u; ++e)ih(c, o, e, u), a && ah(c, l), t.update(c, s[e]) } function ih(e, t, n, r) { e.p0 = e.i0, e.p1 = e.i1, e.i0 = null == t[0] ? 0 : Math.max(0, n - Math.abs(t[0])), e.i1 = null == t[1] ? r : Math.min(r, n + Math.abs(t[1]) + 1), e.index = n } function ah(e, t) { const n = e.i0, r = e.i1 - 1, i = e.compare, a = e.data, o = a.length - 1; n > 0 && !i(a[n], a[n - 1]) && (e.i0 = t.left(a, a[n])), r < o && !i(a[r], a[r + 1]) && (e.i1 = t.right(a, a[r])) } function oh(e, t, n) { e._context.bezierCurveTo((2 * e._x0 + e._x1) / 3, (2 * e._y0 + e._y1) / 3, (e._x0 + 2 * e._x1) / 3, (e._y0 + 2 * e._y1) / 3, (e._x0 + 4 * e._x1 + t) / 6, (e._y0 + 4 * e._y1 + n) / 6) } function sh(e) { this._context = e } function uh(e) { return new sh(e) } function lh() { } function ch(e) { this._context = e } function hh(e) { return new ch(e) } function dh(e) { this._context = e } function fh(e) { return new dh(e) } function ph(e, t) { this._basis = new sh(e), this._beta = t } th.init = function () { this.windows.forEach((e => e.init())), this.cell && this.cell.init() }, th.update = function (e, t) { const n = this.cell, r = this.windows, i = e.data, a = r && r.length; let o; if (n) { for (o = e.p0; o < e.i0; ++o)n.rem(i[o]); for (o = e.p1; o < e.i1; ++o)n.add(i[o]); n.set(t) } for (o = 0; o < a; ++o)r[o].update(e, t) }, nh.Definition = { type: "Window", metadata: { modifies: !0 }, params: [{ name: "sort", type: "compare" }, { name: "groupby", type: "field", array: !0 }, { name: "ops", type: "enum", array: !0, values: Qc.concat(Bl) }, { name: "params", type: "number", null: !0, array: !0 }, { name: "fields", type: "field", null: !0, array: !0 }, { name: "as", type: "string", null: !0, array: !0 }, { name: "frame", type: "number", null: !0, array: !0, length: 2, default: [null, 0] }, { name: "ignorePeers", type: "boolean", default: !1 }] }, Ln(nh, Eu, { transform(e, t) { this.stamp = t.stamp; const n = e.modified(), r = tu(e.sort), i = $l(e.groupby), a = e => this.group(i(e)); let o = this.state; o && !n || (o = this.state = new eh(e)), n || t.modified(o.inputs) ? (this.value = {}, t.visit(t.SOURCE, (e => a(e).add(e)))) : (t.visit(t.REM, (e => a(e).remove(e))), t.visit(t.ADD, (e => a(e).add(e)))); for (let t = 0, n = this._mlen; t < n; ++t)rh(this._mods[t], o, r, e); return this._mlen = 0, this._mods = [], t.reflow(n).modifies(o.outputs) }, group(e) { let t = this.value[e]; return t || (t = this.value[e] = Zl(Xs), t.stamp = -1), t.stamp < this.stamp && (t.stamp = this.stamp, this._mods[this._mlen++] = t), t } }), sh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 3: oh(this, this._x1, this._y1); case 2: this._context.lineTo(this._x1, this._y1) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; break; case 2: this._point = 3, this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); default: oh(this, e, t) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t } }, ch.prototype = { areaStart: lh, areaEnd: lh, lineStart: function () { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 1: this._context.moveTo(this._x2, this._y2), this._context.closePath(); break; case 2: this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3), this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3), this._context.closePath(); break; case 3: this.point(this._x2, this._y2), this.point(this._x3, this._y3), this.point(this._x4, this._y4) } }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._x2 = e, this._y2 = t; break; case 1: this._point = 2, this._x3 = e, this._y3 = t; break; case 2: this._point = 3, this._x4 = e, this._y4 = t, this._context.moveTo((this._x0 + 4 * this._x1 + e) / 6, (this._y0 + 4 * this._y1 + t) / 6); break; default: oh(this, e, t) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t } }, dh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 3 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3; var n = (this._x0 + 4 * this._x1 + e) / 6, r = (this._y0 + 4 * this._y1 + t) / 6; this._line ? this._context.lineTo(n, r) : this._context.moveTo(n, r); break; case 3: this._point = 4; default: oh(this, e, t) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t } }, ph.prototype = { lineStart: function () { this._x = [], this._y = [], this._basis.lineStart() }, lineEnd: function () { var e = this._x, t = this._y, n = e.length - 1; if (n > 0) for (var r, i = e[0], a = t[0], o = e[n] - i, s = t[n] - a, u = -1; ++u <= n;)r = u / n, this._basis.point(this._beta * e[u] + (1 - this._beta) * (i + r * o), this._beta * t[u] + (1 - this._beta) * (a + r * s)); this._x = this._y = null, this._basis.lineEnd() }, point: function (e, t) { this._x.push(+e), this._y.push(+t) } }; const mh = function e(t) { function n(e) { return 1 === t ? new sh(e) : new ph(e, t) } return n.beta = function (t) { return e(+t) }, n }(.85); function gh(e, t, n) { e._context.bezierCurveTo(e._x1 + e._k * (e._x2 - e._x0), e._y1 + e._k * (e._y2 - e._y0), e._x2 + e._k * (e._x1 - t), e._y2 + e._k * (e._y1 - n), e._x2, e._y2) } function yh(e, t) { this._context = e, this._k = (1 - t) / 6 } yh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 2: this._context.lineTo(this._x2, this._y2); break; case 3: gh(this, this._x1, this._y1) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2, this._x1 = e, this._y1 = t; break; case 2: this._point = 3; default: gh(this, e, t) }this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const bh = function e(t) { function n(e) { return new yh(e, t) } return n.tension = function (t) { return e(+t) }, n }(0); function vh(e, t) { this._context = e, this._k = (1 - t) / 6 } vh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 3 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; case 3: this._point = 4; default: gh(this, e, t) }this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const xh = function e(t) { function n(e) { return new vh(e, t) } return n.tension = function (t) { return e(+t) }, n }(0); function wh(e, t) { this._context = e, this._k = (1 - t) / 6 } wh.prototype = { areaStart: lh, areaEnd: lh, lineStart: function () { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 1: this._context.moveTo(this._x3, this._y3), this._context.closePath(); break; case 2: this._context.lineTo(this._x3, this._y3), this._context.closePath(); break; case 3: this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5) } }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._x3 = e, this._y3 = t; break; case 1: this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t); break; case 2: this._point = 3, this._x5 = e, this._y5 = t; break; default: gh(this, e, t) }this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const kh = function e(t) { function n(e) { return new wh(e, t) } return n.tension = function (t) { return e(+t) }, n }(0), Sh = Math.abs, _h = Math.atan2, Ch = Math.cos, Ah = Math.max, Th = Math.min, Eh = Math.sin, Nh = Math.sqrt, Ih = 1e-12, Mh = Math.PI, Fh = Mh / 2, Dh = 2 * Mh; function $h(e) { return e >= 1 ? Fh : e <= -1 ? -Fh : Math.asin(e) } function Rh(e, t, n) { var r = e._x1, i = e._y1, a = e._x2, o = e._y2; if (e._l01_a > Ih) { var s = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, u = 3 * e._l01_a * (e._l01_a + e._l12_a); r = (r * s - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / u, i = (i * s - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / u } if (e._l23_a > Ih) { var l = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, c = 3 * e._l23_a * (e._l23_a + e._l12_a); a = (a * l + e._x1 * e._l23_2a - t * e._l12_2a) / c, o = (o * l + e._y1 * e._l23_2a - n * e._l12_2a) / c } e._context.bezierCurveTo(r, i, a, o, e._x2, e._y2) } function Oh(e, t) { this._context = e, this._alpha = t } Oh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0 }, lineEnd: function () { switch (this._point) { case 2: this._context.lineTo(this._x2, this._y2); break; case 3: this.point(this._x2, this._y2) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { if (e = +e, t = +t, this._point) { var n = this._x2 - e, r = this._y2 - t; this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, this._alpha)) } switch (this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; break; case 2: this._point = 3; default: Rh(this, e, t) }this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const zh = function e(t) { function n(e) { return t ? new Oh(e, t) : new yh(e, 0) } return n.alpha = function (t) { return e(+t) }, n }(.5); function Ph(e, t) { this._context = e, this._alpha = t } Ph.prototype = { areaStart: lh, areaEnd: lh, lineStart: function () { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0 }, lineEnd: function () { switch (this._point) { case 1: this._context.moveTo(this._x3, this._y3), this._context.closePath(); break; case 2: this._context.lineTo(this._x3, this._y3), this._context.closePath(); break; case 3: this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5) } }, point: function (e, t) { if (e = +e, t = +t, this._point) { var n = this._x2 - e, r = this._y2 - t; this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, this._alpha)) } switch (this._point) { case 0: this._point = 1, this._x3 = e, this._y3 = t; break; case 1: this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t); break; case 2: this._point = 3, this._x5 = e, this._y5 = t; break; default: Rh(this, e, t) }this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const Bh = function e(t) { function n(e) { return t ? new Ph(e, t) : new wh(e, 0) } return n.alpha = function (t) { return e(+t) }, n }(.5); function Lh(e, t) { this._context = e, this._alpha = t } Lh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 3 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { if (e = +e, t = +t, this._point) { var n = this._x2 - e, r = this._y2 - t; this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, this._alpha)) } switch (this._point) { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; case 3: this._point = 4; default: Rh(this, e, t) }this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const jh = function e(t) { function n(e) { return t ? new Lh(e, t) : new vh(e, 0) } return n.alpha = function (t) { return e(+t) }, n }(.5); function Uh(e) { this._context = e } function Wh(e) { return new Uh(e) } function Vh(e) { this._context = e } function Gh(e) { return new Vh(e) } function Hh(e) { return e < 0 ? -1 : 1 } function qh(e, t, n) { var r = e._x1 - e._x0, i = t - e._x1, a = (e._y1 - e._y0) / (r || i < 0 && -0), o = (n - e._y1) / (i || r < 0 && -0), s = (a * i + o * r) / (r + i); return (Hh(a) + Hh(o)) * Math.min(Math.abs(a), Math.abs(o), .5 * Math.abs(s)) || 0 } function Yh(e, t) { var n = e._x1 - e._x0; return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t } function Xh(e, t, n) { var r = e._x0, i = e._y0, a = e._x1, o = e._y1, s = (a - r) / 3; e._context.bezierCurveTo(r + s, i + s * t, a - s, o - s * n, a, o) } function Kh(e) { this._context = e } function Zh(e) { this._context = new Jh(e) } function Jh(e) { this._context = e } function Qh(e) { return new Kh(e) } function ed(e) { return new Zh(e) } function td(e) { this._context = e } function nd(e) { var t, n, r = e.length - 1, i = new Array(r), a = new Array(r), o = new Array(r); for (i[0] = 0, a[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < r - 1; ++t)i[t] = 1, a[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1]; for (i[r - 1] = 2, a[r - 1] = 7, o[r - 1] = 8 * e[r - 1] + e[r], t = 1; t < r; ++t)n = i[t] / a[t - 1], a[t] -= n, o[t] -= n * o[t - 1]; for (i[r - 1] = o[r - 1] / a[r - 1], t = r - 2; t >= 0; --t)i[t] = (o[t] - i[t + 1]) / a[t]; for (a[r - 1] = (e[r] + i[r - 1]) / 2, t = 0; t < r - 1; ++t)a[t] = 2 * e[t + 1] - i[t + 1]; return [i, a] } function rd(e) { return new td(e) } function id(e, t) { this._context = e, this._t = t } function ad(e) { return new id(e, .5) } function od(e) { return new id(e, 0) } function sd(e) { return new id(e, 1) } function ud(e) { return function () { return e } } Uh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; default: this._context.lineTo(e, t) } } }, Vh.prototype = { areaStart: lh, areaEnd: lh, lineStart: function () { this._point = 0 }, lineEnd: function () { this._point && this._context.closePath() }, point: function (e, t) { e = +e, t = +t, this._point ? this._context.lineTo(e, t) : (this._point = 1, this._context.moveTo(e, t)) } }, Kh.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 2: this._context.lineTo(this._x1, this._y1); break; case 3: Xh(this, this._t0, Yh(this, this._t0)) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { var n = NaN; if (t = +t, (e = +e) !== this._x1 || t !== this._y1) { switch (this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; break; case 2: this._point = 3, Xh(this, Yh(this, n = qh(this, e, t)), n); break; default: Xh(this, this._t0, n = qh(this, e, t)) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n } } }, (Zh.prototype = Object.create(Kh.prototype)).point = function (e, t) { Kh.prototype.point.call(this, t, e) }, Jh.prototype = { moveTo: function (e, t) { this._context.moveTo(t, e) }, closePath: function () { this._context.closePath() }, lineTo: function (e, t) { this._context.lineTo(t, e) }, bezierCurveTo: function (e, t, n, r, i, a) { this._context.bezierCurveTo(t, e, r, n, a, i) } }, td.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x = [], this._y = [] }, lineEnd: function () { var e = this._x, t = this._y, n = e.length; if (n) if (this._line ? this._context.lineTo(e[0], t[0]) : this._context.moveTo(e[0], t[0]), 2 === n) this._context.lineTo(e[1], t[1]); else for (var r = nd(e), i = nd(t), a = 0, o = 1; o < n; ++a, ++o)this._context.bezierCurveTo(r[0][a], i[0][a], r[1][a], i[1][a], e[o], t[o]); (this._line || 0 !== this._line && 1 === n) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null }, point: function (e, t) { this._x.push(+e), this._y.push(+t) } }, id.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x = this._y = NaN, this._point = 0 }, lineEnd: function () { 0 < this._t && this._t < 1 && 2 === this._point && this._context.lineTo(this._x, this._y), (this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line) }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; default: if (this._t <= 0) this._context.lineTo(this._x, t), this._context.lineTo(e, t); else { var n = this._x * (1 - this._t) + e * this._t; this._context.lineTo(n, this._y), this._context.lineTo(n, t) } }this._x = e, this._y = t } }; const ld = Math.PI, cd = 2 * ld, hd = 1e-6, dd = cd - hd; function fd(e) { this._ += e[0]; for (let t = 1, n = e.length; t < n; ++t)this._ += arguments[t] + e[t] } class pd { constructor(e) { this._x0 = this._y0 = this._x1 = this._y1 = null, this._ = "", this._append = null == e ? fd : function (e) { let t = Math.floor(e); if (!(t >= 0)) throw new Error(`invalid digits: ${e}`); if (t > 15) return fd; const n = 10 ** t; return function (e) { this._ += e[0]; for (let t = 1, r = e.length; t < r; ++t)this._ += Math.round(arguments[t] * n) / n + e[t] } }(e) } moveTo(e, t) { this._append`M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +t}` } closePath() { null !== this._x1 && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`) } lineTo(e, t) { this._append`L${this._x1 = +e},${this._y1 = +t}` } quadraticCurveTo(e, t, n, r) { this._append`Q${+e},${+t},${this._x1 = +n},${this._y1 = +r}` } bezierCurveTo(e, t, n, r, i, a) { this._append`C${+e},${+t},${+n},${+r},${this._x1 = +i},${this._y1 = +a}` } arcTo(e, t, n, r, i) { if (e = +e, t = +t, n = +n, r = +r, (i = +i) < 0) throw new Error(`negative radius: ${i}`); let a = this._x1, o = this._y1, s = n - e, u = r - t, l = a - e, c = o - t, h = l * l + c * c; if (null === this._x1) this._append`M${this._x1 = e},${this._y1 = t}`; else if (h > hd) if (Math.abs(c * s - u * l) > hd && i) { let d = n - a, f = r - o, p = s * s + u * u, m = d * d + f * f, g = Math.sqrt(p), y = Math.sqrt(h), b = i * Math.tan((ld - Math.acos((p + h - m) / (2 * g * y))) / 2), v = b / y, x = b / g; Math.abs(v - 1) > hd && this._append`L${e + v * l},${t + v * c}`, this._append`A${i},${i},0,0,${+(c * d > l * f)},${this._x1 = e + x * s},${this._y1 = t + x * u}` } else this._append`L${this._x1 = e},${this._y1 = t}`; else; } arc(e, t, n, r, i, a) { if (e = +e, t = +t, a = !!a, (n = +n) < 0) throw new Error(`negative radius: ${n}`); let o = n * Math.cos(r), s = n * Math.sin(r), u = e + o, l = t + s, c = 1 ^ a, h = a ? r - i : i - r; null === this._x1 ? this._append`M${u},${l}` : (Math.abs(this._x1 - u) > hd || Math.abs(this._y1 - l) > hd) && this._append`L${u},${l}`, n && (h < 0 && (h = h % cd + cd), h > dd ? this._append`A${n},${n},0,1,${c},${e - o},${t - s}A${n},${n},0,1,${c},${this._x1 = u},${this._y1 = l}` : h > hd && this._append`A${n},${n},0,${+(h >= ld)},${c},${this._x1 = e + n * Math.cos(i)},${this._y1 = t + n * Math.sin(i)}`) } rect(e, t, n, r) { this._append`M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +t}h${n = +n}v${+r}h${-n}Z` } toString() { return this._ } } function md() { return new pd } function gd(e) { let t = 3; return e.digits = function (n) { if (!arguments.length) return t; if (null == n) t = null; else { const e = Math.floor(n); if (!(e >= 0)) throw new RangeError(`invalid digits: ${n}`); t = e } return e }, () => new pd(t) } function yd(e) { return e.innerRadius } function bd(e) { return e.outerRadius } function vd(e) { return e.startAngle } function xd(e) { return e.endAngle } function wd(e) { return e && e.padAngle } function kd(e, t, n, r, i, a, o) { var s = e - n, u = t - r, l = (o ? a : -a) / Nh(s * s + u * u), c = l * u, h = -l * s, d = e + c, f = t + h, p = n + c, m = r + h, g = (d + p) / 2, y = (f + m) / 2, b = p - d, v = m - f, x = b * b + v * v, w = i - a, k = d * m - p * f, S = (v < 0 ? -1 : 1) * Nh(Ah(0, w * w * x - k * k)), _ = (k * v - b * S) / x, C = (-k * b - v * S) / x, A = (k * v + b * S) / x, T = (-k * b + v * S) / x, E = _ - g, N = C - y, I = A - g, M = T - y; return E * E + N * N > I * I + M * M && (_ = A, C = T), { cx: _, cy: C, x01: -c, y01: -h, x11: _ * (i / w - 1), y11: C * (i / w - 1) } } function Sd() { var e = yd, t = bd, n = ud(0), r = null, i = vd, a = xd, o = wd, s = null, u = gd(l); function l() { var l, c, h = +e.apply(this, arguments), d = +t.apply(this, arguments), f = i.apply(this, arguments) - Fh, p = a.apply(this, arguments) - Fh, m = Sh(p - f), g = p > f; if (s || (s = l = u()), d < h && (c = d, d = h, h = c), d > Ih) if (m > Dh - Ih) s.moveTo(d * Ch(f), d * Eh(f)), s.arc(0, 0, d, f, p, !g), h > Ih && (s.moveTo(h * Ch(p), h * Eh(p)), s.arc(0, 0, h, p, f, g)); else { var y, b, v = f, x = p, w = f, k = p, S = m, _ = m, C = o.apply(this, arguments) / 2, A = C > Ih && (r ? +r.apply(this, arguments) : Nh(h * h + d * d)), T = Th(Sh(d - h) / 2, +n.apply(this, arguments)), E = T, N = T; if (A > Ih) { var I = $h(A / h * Eh(C)), M = $h(A / d * Eh(C)); (S -= 2 * I) > Ih ? (w += I *= g ? 1 : -1, k -= I) : (S = 0, w = k = (f + p) / 2), (_ -= 2 * M) > Ih ? (v += M *= g ? 1 : -1, x -= M) : (_ = 0, v = x = (f + p) / 2) } var F = d * Ch(v), D = d * Eh(v), $ = h * Ch(k), R = h * Eh(k); if (T > Ih) { var O, z = d * Ch(x), P = d * Eh(x), B = h * Ch(w), L = h * Eh(w); if (m < Mh) if (O = function (e, t, n, r, i, a, o, s) { var u = n - e, l = r - t, c = o - i, h = s - a, d = h * u - c * l; if (!(d * d < Ih)) return [e + (d = (c * (t - a) - h * (e - i)) / d) * u, t + d * l] }(F, D, B, L, z, P, $, R)) { var j = F - O[0], U = D - O[1], W = z - O[0], V = P - O[1], G = 1 / Eh(function (e) { return e > 1 ? 0 : e < -1 ? Mh : Math.acos(e) }((j * W + U * V) / (Nh(j * j + U * U) * Nh(W * W + V * V))) / 2), H = Nh(O[0] * O[0] + O[1] * O[1]); E = Th(T, (h - H) / (G - 1)), N = Th(T, (d - H) / (G + 1)) } else E = N = 0 } _ > Ih ? N > Ih ? (y = kd(B, L, F, D, d, N, g), b = kd(z, P, $, R, d, N, g), s.moveTo(y.cx + y.x01, y.cy + y.y01), N < T ? s.arc(y.cx, y.cy, N, _h(y.y01, y.x01), _h(b.y01, b.x01), !g) : (s.arc(y.cx, y.cy, N, _h(y.y01, y.x01), _h(y.y11, y.x11), !g), s.arc(0, 0, d, _h(y.cy + y.y11, y.cx + y.x11), _h(b.cy + b.y11, b.cx + b.x11), !g), s.arc(b.cx, b.cy, N, _h(b.y11, b.x11), _h(b.y01, b.x01), !g))) : (s.moveTo(F, D), s.arc(0, 0, d, v, x, !g)) : s.moveTo(F, D), h > Ih && S > Ih ? E > Ih ? (y = kd($, R, z, P, h, -E, g), b = kd(F, D, B, L, h, -E, g), s.lineTo(y.cx + y.x01, y.cy + y.y01), E < T ? s.arc(y.cx, y.cy, E, _h(y.y01, y.x01), _h(b.y01, b.x01), !g) : (s.arc(y.cx, y.cy, E, _h(y.y01, y.x01), _h(y.y11, y.x11), !g), s.arc(0, 0, h, _h(y.cy + y.y11, y.cx + y.x11), _h(b.cy + b.y11, b.cx + b.x11), g), s.arc(b.cx, b.cy, E, _h(b.y11, b.x11), _h(b.y01, b.x01), !g))) : s.arc(0, 0, h, k, w, g) : s.lineTo($, R) } else s.moveTo(0, 0); if (s.closePath(), l) return s = null, l + "" || null } return l.centroid = function () { var n = (+e.apply(this, arguments) + +t.apply(this, arguments)) / 2, r = (+i.apply(this, arguments) + +a.apply(this, arguments)) / 2 - Mh / 2; return [Ch(r) * n, Eh(r) * n] }, l.innerRadius = function (t) { return arguments.length ? (e = "function" == typeof t ? t : ud(+t), l) : e }, l.outerRadius = function (e) { return arguments.length ? (t = "function" == typeof e ? e : ud(+e), l) : t }, l.cornerRadius = function (e) { return arguments.length ? (n = "function" == typeof e ? e : ud(+e), l) : n }, l.padRadius = function (e) { return arguments.length ? (r = null == e ? null : "function" == typeof e ? e : ud(+e), l) : r }, l.startAngle = function (e) { return arguments.length ? (i = "function" == typeof e ? e : ud(+e), l) : i }, l.endAngle = function (e) { return arguments.length ? (a = "function" == typeof e ? e : ud(+e), l) : a }, l.padAngle = function (e) { return arguments.length ? (o = "function" == typeof e ? e : ud(+e), l) : o }, l.context = function (e) { return arguments.length ? (s = null == e ? null : e, l) : s }, l } md.prototype = pd.prototype; Array.prototype.slice; function _d(e) { return "object" == typeof e && "length" in e ? e : Array.from(e) } function Cd(e) { return e[0] } function Ad(e) { return e[1] } function Td(e, t) { var n = ud(!0), r = null, i = Wh, a = null, o = gd(s); function s(s) { var u, l, c, h = (s = _d(s)).length, d = !1; for (null == r && (a = i(c = o())), u = 0; u <= h; ++u)!(u < h && n(l = s[u], u, s)) === d && ((d = !d) ? a.lineStart() : a.lineEnd()), d && a.point(+e(l, u, s), +t(l, u, s)); if (c) return a = null, c + "" || null } return e = "function" == typeof e ? e : void 0 === e ? Cd : ud(e), t = "function" == typeof t ? t : void 0 === t ? Ad : ud(t), s.x = function (t) { return arguments.length ? (e = "function" == typeof t ? t : ud(+t), s) : e }, s.y = function (e) { return arguments.length ? (t = "function" == typeof e ? e : ud(+e), s) : t }, s.defined = function (e) { return arguments.length ? (n = "function" == typeof e ? e : ud(!!e), s) : n }, s.curve = function (e) { return arguments.length ? (i = e, null != r && (a = i(r)), s) : i }, s.context = function (e) { return arguments.length ? (null == e ? r = a = null : a = i(r = e), s) : r }, s } function Ed(e, t, n) { var r = null, i = ud(!0), a = null, o = Wh, s = null, u = gd(l); function l(l) { var c, h, d, f, p, m = (l = _d(l)).length, g = !1, y = new Array(m), b = new Array(m); for (null == a && (s = o(p = u())), c = 0; c <= m; ++c) { if (!(c < m && i(f = l[c], c, l)) === g) if (g = !g) h = c, s.areaStart(), s.lineStart(); else { for (s.lineEnd(), s.lineStart(), d = c - 1; d >= h; --d)s.point(y[d], b[d]); s.lineEnd(), s.areaEnd() } g && (y[c] = +e(f, c, l), b[c] = +t(f, c, l), s.point(r ? +r(f, c, l) : y[c], n ? +n(f, c, l) : b[c])) } if (p) return s = null, p + "" || null } function c() { return Td().defined(i).curve(o).context(a) } return e = "function" == typeof e ? e : void 0 === e ? Cd : ud(+e), t = "function" == typeof t ? t : ud(void 0 === t ? 0 : +t), n = "function" == typeof n ? n : void 0 === n ? Ad : ud(+n), l.x = function (t) { return arguments.length ? (e = "function" == typeof t ? t : ud(+t), r = null, l) : e }, l.x0 = function (t) { return arguments.length ? (e = "function" == typeof t ? t : ud(+t), l) : e }, l.x1 = function (e) { return arguments.length ? (r = null == e ? null : "function" == typeof e ? e : ud(+e), l) : r }, l.y = function (e) { return arguments.length ? (t = "function" == typeof e ? e : ud(+e), n = null, l) : t }, l.y0 = function (e) { return arguments.length ? (t = "function" == typeof e ? e : ud(+e), l) : t }, l.y1 = function (e) { return arguments.length ? (n = null == e ? null : "function" == typeof e ? e : ud(+e), l) : n }, l.lineX0 = l.lineY0 = function () { return c().x(e).y(t) }, l.lineY1 = function () { return c().x(e).y(n) }, l.lineX1 = function () { return c().x(r).y(t) }, l.defined = function (e) { return arguments.length ? (i = "function" == typeof e ? e : ud(!!e), l) : i }, l.curve = function (e) { return arguments.length ? (o = e, null != a && (s = o(a)), l) : o }, l.context = function (e) { return arguments.length ? (null == e ? a = s = null : s = o(a = e), l) : a }, l } Nh(3); const Nd = { draw(e, t) { const n = Nh(t / Mh); e.moveTo(n, 0), e.arc(0, 0, n, 0, Dh) } }, Id = (Nh(1 / 3), Eh(Mh / 10) / Eh(7 * Mh / 10)); Eh(Dh / 10), Ch(Dh / 10), Nh(3), Nh(3), Nh(3), Nh(12); function Md(e, t) { let n = null, r = gd(i); function i() { let i; if (n || (n = i = r()), e.apply(this, arguments).draw(n, +t.apply(this, arguments)), i) return n = null, i + "" || null } return e = "function" == typeof e ? e : ud(e || Nd), t = "function" == typeof t ? t : ud(void 0 === t ? 64 : +t), i.type = function (t) { return arguments.length ? (e = "function" == typeof t ? t : ud(t), i) : e }, i.size = function (e) { return arguments.length ? (t = "function" == typeof e ? e : ud(+e), i) : t }, i.context = function (e) { return arguments.length ? (n = null == e ? null : e, i) : n }, i } function Fd(e, t) { if ("undefined" != typeof document && document.createElement) { const n = document.createElement("canvas"); if (n && n.getContext) return n.width = e, n.height = t, n } return null } const Dd = () => "undefined" != typeof Image ? Image : null; function $d(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function Rd(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function Od(e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = $d, n = (t, n) => $d(e(t), n), r = (t, n) => e(t) - n) : (t = e === $d || e === Rd ? e : zd, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } } function zd() { return 0 } const Pd = Od($d), Bd = Pd.right, Ld = (Pd.left, Od((function (e) { return null === e ? NaN : +e })).center, Bd), jd = Math.sqrt(50), Ud = Math.sqrt(10), Wd = Math.sqrt(2); function Vd(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= jd ? 10 : a >= Ud ? 5 : a >= Wd ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? Vd(e, t, 2 * n) : [s, u, l] } function Gd(e, t, n) { if (!((n = +n) > 0)) return []; if ((e = +e) === (t = +t)) return [e]; const r = t < e, [i, a, o] = r ? Vd(t, e, n) : Vd(e, t, n); if (!(a >= i)) return []; const s = a - i + 1, u = new Array(s); if (r) if (o < 0) for (let e = 0; e < s; ++e)u[e] = (a - e) / -o; else for (let e = 0; e < s; ++e)u[e] = (a - e) * o; else if (o < 0) for (let e = 0; e < s; ++e)u[e] = (i + e) / -o; else for (let e = 0; e < s; ++e)u[e] = (i + e) * o; return u } function Hd(e, t, n) { return Vd(e = +e, t = +t, n = +n)[2] } function qd(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function Yd(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function Xd(e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = qd, n = (t, n) => qd(e(t), n), r = (t, n) => e(t) - n) : (t = e === qd || e === Yd ? e : Kd, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } } function Kd() { return 0 } function Zd(e) { return null === e ? NaN : +e } const Jd = Xd(qd), Qd = Jd.right, ef = (Jd.left, Xd(Zd).center, Qd); function tf(e, t, n) { e.prototype = t.prototype = n, n.constructor = e } function nf(e, t) { var n = Object.create(e.prototype); for (var r in t) n[r] = t[r]; return n } function rf() { } var af = .7, of = 1 / af, sf = "\\s*([+-]?\\d+)\\s*", uf = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", lf = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", cf = /^#([0-9a-f]{3,8})$/, hf = new RegExp(`^rgb\\(${sf},${sf},${sf}\\)$`), df = new RegExp(`^rgb\\(${lf},${lf},${lf}\\)$`), ff = new RegExp(`^rgba\\(${sf},${sf},${sf},${uf}\\)$`), pf = new RegExp(`^rgba\\(${lf},${lf},${lf},${uf}\\)$`), mf = new RegExp(`^hsl\\(${uf},${lf},${lf}\\)$`), gf = new RegExp(`^hsla\\(${uf},${lf},${lf},${uf}\\)$`), yf = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; function bf() { return this.rgb().formatHex() } function vf() { return this.rgb().formatRgb() } function xf(e) { var t, n; return e = (e + "").trim().toLowerCase(), (t = cf.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), 6 === n ? wf(t) : 3 === n ? new _f(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, (15 & t) << 4 | 15 & t, 1) : 8 === n ? kf(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (255 & t) / 255) : 4 === n ? kf(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, ((15 & t) << 4 | 15 & t) / 255) : null) : (t = hf.exec(e)) ? new _f(t[1], t[2], t[3], 1) : (t = df.exec(e)) ? new _f(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, 1) : (t = ff.exec(e)) ? kf(t[1], t[2], t[3], t[4]) : (t = pf.exec(e)) ? kf(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, t[4]) : (t = mf.exec(e)) ? If(t[1], t[2] / 100, t[3] / 100, 1) : (t = gf.exec(e)) ? If(t[1], t[2] / 100, t[3] / 100, t[4]) : yf.hasOwnProperty(e) ? wf(yf[e]) : "transparent" === e ? new _f(NaN, NaN, NaN, 0) : null } function wf(e) { return new _f(e >> 16 & 255, e >> 8 & 255, 255 & e, 1) } function kf(e, t, n, r) { return r <= 0 && (e = t = n = NaN), new _f(e, t, n, r) } function Sf(e, t, n, r) { return 1 === arguments.length ? ((i = e) instanceof rf || (i = xf(i)), i ? new _f((i = i.rgb()).r, i.g, i.b, i.opacity) : new _f) : new _f(e, t, n, null == r ? 1 : r); var i } function _f(e, t, n, r) { this.r = +e, this.g = +t, this.b = +n, this.opacity = +r } function Cf() { return `#${Nf(this.r)}${Nf(this.g)}${Nf(this.b)}` } function Af() { const e = Tf(this.opacity); return `${1 === e ? "rgb(" : "rgba("}${Ef(this.r)}, ${Ef(this.g)}, ${Ef(this.b)}${1 === e ? ")" : `, ${e})`}` } function Tf(e) { return isNaN(e) ? 1 : Math.max(0, Math.min(1, e)) } function Ef(e) { return Math.max(0, Math.min(255, Math.round(e) || 0)) } function Nf(e) { return ((e = Ef(e)) < 16 ? "0" : "") + e.toString(16) } function If(e, t, n, r) { return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new Ff(e, t, n, r) } function Mf(e) { if (e instanceof Ff) return new Ff(e.h, e.s, e.l, e.opacity); if (e instanceof rf || (e = xf(e)), !e) return new Ff; if (e instanceof Ff) return e; var t = (e = e.rgb()).r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, u = (a + i) / 2; return s ? (o = t === a ? (n - r) / s + 6 * (n < r) : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= u < .5 ? a + i : 2 - a - i, o *= 60) : s = u > 0 && u < 1 ? 0 : o, new Ff(o, s, u, e.opacity) } function Ff(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function Df(e) { return (e = (e || 0) % 360) < 0 ? e + 360 : e } function $f(e) { return Math.max(0, Math.min(1, e || 0)) } function Rf(e, t, n) { return 255 * (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) } function Of(e, t, n, r, i) { var a = e * e, o = a * e; return ((1 - 3 * e + 3 * a - o) * t + (4 - 6 * a + 3 * o) * n + (1 + 3 * e + 3 * a - 3 * o) * r + o * i) / 6 } tf(rf, xf, { copy(e) { return Object.assign(new this.constructor, this, e) }, displayable() { return this.rgb().displayable() }, hex: bf, formatHex: bf, formatHex8: function () { return this.rgb().formatHex8() }, formatHsl: function () { return Mf(this).formatHsl() }, formatRgb: vf, toString: vf }), tf(_f, Sf, nf(rf, { brighter(e) { return e = null == e ? of : Math.pow(of, e), new _f(this.r * e, this.g * e, this.b * e, this.opacity) }, darker(e) { return e = null == e ? af : Math.pow(af, e), new _f(this.r * e, this.g * e, this.b * e, this.opacity) }, rgb() { return this }, clamp() { return new _f(Ef(this.r), Ef(this.g), Ef(this.b), Tf(this.opacity)) }, displayable() { return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1 }, hex: Cf, formatHex: Cf, formatHex8: function () { return `#${Nf(this.r)}${Nf(this.g)}${Nf(this.b)}${Nf(255 * (isNaN(this.opacity) ? 1 : this.opacity))}` }, formatRgb: Af, toString: Af })), tf(Ff, (function (e, t, n, r) { return 1 === arguments.length ? Mf(e) : new Ff(e, t, n, null == r ? 1 : r) }), nf(rf, { brighter(e) { return e = null == e ? of : Math.pow(of, e), new Ff(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? af : Math.pow(af, e), new Ff(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = this.h % 360 + 360 * (this.h < 0), t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r; return new _f(Rf(e >= 240 ? e - 240 : e + 120, i, r), Rf(e, i, r), Rf(e < 120 ? e + 240 : e - 120, i, r), this.opacity) }, clamp() { return new Ff(Df(this.h), $f(this.s), $f(this.l), Tf(this.opacity)) }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1 }, formatHsl() { const e = Tf(this.opacity); return `${1 === e ? "hsl(" : "hsla("}${Df(this.h)}, ${100 * $f(this.s)}%, ${100 * $f(this.l)}%${1 === e ? ")" : `, ${e})`}` } })); const zf = e => () => e; function Pf(e, t) { return function (n) { return e + n * t } } function Bf(e) { return 1 == (e = +e) ? Lf : function (t, n) { return n - t ? function (e, t, n) { return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function (r) { return Math.pow(e + r * t, n) } }(t, n, e) : zf(isNaN(t) ? n : t) } } function Lf(e, t) { var n = t - e; return n ? Pf(e, n) : zf(isNaN(e) ? t : e) } const jf = function e(t) { var n = Bf(t); function r(e, t) { var r = n((e = Sf(e)).r, (t = Sf(t)).r), i = n(e.g, t.g), a = n(e.b, t.b), o = Lf(e.opacity, t.opacity); return function (t) { return e.r = r(t), e.g = i(t), e.b = a(t), e.opacity = o(t), e + "" } } return r.gamma = e, r }(1); function Uf(e) { return function (t) { var n, r, i = t.length, a = new Array(i), o = new Array(i), s = new Array(i); for (n = 0; n < i; ++n)r = Sf(t[n]), a[n] = r.r || 0, o[n] = r.g || 0, s[n] = r.b || 0; return a = e(a), o = e(o), s = e(s), r.opacity = 1, function (e) { return r.r = a(e), r.g = o(e), r.b = s(e), r + "" } } } Uf((function (e) { var t = e.length - 1; return function (n) { var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], a = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - a, s = r < t - 1 ? e[r + 2] : 2 * a - i; return Of((n - r / t) * t, o, i, a, s) } })), Uf((function (e) { var t = e.length; return function (n) { var r = Math.floor(((n %= 1) < 0 ? ++n : n) * t), i = e[(r + t - 1) % t], a = e[r % t], o = e[(r + 1) % t], s = e[(r + 2) % t]; return Of((n - r / t) * t, i, a, o, s) } })); function Wf(e, t) { var n, r = t ? t.length : 0, i = e ? Math.min(r, e.length) : 0, a = new Array(i), o = new Array(r); for (n = 0; n < i; ++n)a[n] = Zf(e[n], t[n]); for (; n < r; ++n)o[n] = t[n]; return function (e) { for (n = 0; n < i; ++n)o[n] = a[n](e); return o } } function Vf(e, t) { var n = new Date; return e = +e, t = +t, function (r) { return n.setTime(e * (1 - r) + t * r), n } } function Gf(e, t) { return e = +e, t = +t, function (n) { return e * (1 - n) + t * n } } function Hf(e, t) { var n, r = {}, i = {}; for (n in null !== e && "object" == typeof e || (e = {}), null !== t && "object" == typeof t || (t = {}), t) n in e ? r[n] = Zf(e[n], t[n]) : i[n] = t[n]; return function (e) { for (n in r) i[n] = r[n](e); return i } } var qf = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Yf = new RegExp(qf.source, "g"); function Xf(e, t) { var n, r, i, a = qf.lastIndex = Yf.lastIndex = 0, o = -1, s = [], u = []; for (e += "", t += ""; (n = qf.exec(e)) && (r = Yf.exec(t));)(i = r.index) > a && (i = t.slice(a, i), s[o] ? s[o] += i : s[++o] = i), (n = n[0]) === (r = r[0]) ? s[o] ? s[o] += r : s[++o] = r : (s[++o] = null, u.push({ i: o, x: Gf(n, r) })), a = Yf.lastIndex; return a < t.length && (i = t.slice(a), s[o] ? s[o] += i : s[++o] = i), s.length < 2 ? u[0] ? function (e) { return function (t) { return e(t) + "" } }(u[0].x) : function (e) { return function () { return e } }(t) : (t = u.length, function (e) { for (var n, r = 0; r < t; ++r)s[(n = u[r]).i] = n.x(e); return s.join("") }) } function Kf(e, t) { t || (t = []); var n, r = e ? Math.min(t.length, e.length) : 0, i = t.slice(); return function (a) { for (n = 0; n < r; ++n)i[n] = e[n] * (1 - a) + t[n] * a; return i } } function Zf(e, t) { var n, r = typeof t; return null == t || "boolean" === r ? zf(t) : ("number" === r ? Gf : "string" === r ? (n = xf(t)) ? (t = n, jf) : Xf : t instanceof xf ? jf : t instanceof Date ? Vf : function (e) { return ArrayBuffer.isView(e) && !(e instanceof DataView) }(t) ? Kf : Array.isArray(t) ? Wf : "function" != typeof t.valueOf && "function" != typeof t.toString || isNaN(t) ? Hf : Gf)(e, t) } function Jf(e, t) { return e = +e, t = +t, function (n) { return Math.round(e * (1 - n) + t * n) } } function Qf(e) { return +e } var ep = [0, 1]; function tp(e) { return e } function np(e, t) { return (t -= e = +e) ? function (n) { return (n - e) / t } : function (e) { return function () { return e } }(isNaN(t) ? NaN : .5) } function rp(e, t, n) { var r = e[0], i = e[1], a = t[0], o = t[1]; return i < r ? (r = np(i, r), a = n(o, a)) : (r = np(r, i), a = n(a, o)), function (e) { return a(r(e)) } } function ip(e, t, n) { var r = Math.min(e.length, t.length) - 1, i = new Array(r), a = new Array(r), o = -1; for (e[r] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < r;)i[o] = np(e[o], e[o + 1]), a[o] = n(t[o], t[o + 1]); return function (t) { var n = ef(e, t, 1, r) - 1; return a[n](i[n](t)) } } function ap(e, t) { return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown()) } function op() { var e, t, n, r, i, a, o = ep, s = ep, u = Zf, l = tp; function c() { var e = Math.min(o.length, s.length); return l !== tp && (l = function (e, t) { var n; return e > t && (n = e, e = t, t = n), function (n) { return Math.max(e, Math.min(t, n)) } }(o[0], o[e - 1])), r = e > 2 ? ip : rp, i = a = null, h } function h(t) { return null == t || isNaN(t = +t) ? n : (i || (i = r(o.map(e), s, u)))(e(l(t))) } return h.invert = function (n) { return l(t((a || (a = r(s, o.map(e), Gf)))(n))) }, h.domain = function (e) { return arguments.length ? (o = Array.from(e, Qf), c()) : o.slice() }, h.range = function (e) { return arguments.length ? (s = Array.from(e), c()) : s.slice() }, h.rangeRound = function (e) { return s = Array.from(e), u = Jf, c() }, h.clamp = function (e) { return arguments.length ? (l = !!e || tp, c()) : l !== tp }, h.interpolate = function (e) { return arguments.length ? (u = e, c()) : u }, h.unknown = function (e) { return arguments.length ? (n = e, h) : n }, function (n, r) { return e = n, t = r, c() } } function sp() { return op()(tp, tp) } function up(e, t) { switch (arguments.length) { case 0: break; case 1: this.range(e); break; default: this.range(t).domain(e) }return this } function lp(e, t) { switch (arguments.length) { case 0: break; case 1: "function" == typeof e ? this.interpolator(e) : this.range(e); break; default: this.domain(e), "function" == typeof t ? this.interpolator(t) : this.range(t) }return this } function cp(e, t, n, r) { var i, a = function (e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? Hd(t, e, n) : Hd(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) }(e, t, n); switch ((r = kr(null == r ? ",f" : r)).type) { case "s": var o = Math.max(Math.abs(e), Math.abs(t)); return null != r.precision || isNaN(i = Ar(a, o)) || (r.precision = i), $r(r, o); case "": case "e": case "g": case "p": case "r": null != r.precision || isNaN(i = Tr(a, Math.max(Math.abs(e), Math.abs(t)))) || (r.precision = i - ("e" === r.type)); break; case "f": case "%": null != r.precision || isNaN(i = Er(a)) || (r.precision = i - 2 * ("%" === r.type)) }return Dr(r) } function hp(e) { var t = e.domain; return e.ticks = function (e) { var n = t(); return Gd(n[0], n[n.length - 1], null == e ? 10 : e) }, e.tickFormat = function (e, n) { var r = t(); return cp(r[0], r[r.length - 1], null == e ? 10 : e, n) }, e.nice = function (n) { null == n && (n = 10); var r, i, a = t(), o = 0, s = a.length - 1, u = a[o], l = a[s], c = 10; for (l < u && (i = u, u = l, l = i, i = o, o = s, s = i); c-- > 0;) { if ((i = Hd(u, l, n)) === r) return a[o] = u, a[s] = l, t(a); if (i > 0) u = Math.floor(u / i) * i, l = Math.ceil(l / i) * i; else { if (!(i < 0)) break; u = Math.ceil(u * i) / i, l = Math.floor(l * i) / i } r = i } return e }, e } function dp() { var e = sp(); return e.copy = function () { return ap(e, dp()) }, up.apply(e, arguments), hp(e) } function fp(e) { var t; function n(e) { return null == e || isNaN(e = +e) ? t : e } return n.invert = n, n.domain = n.range = function (t) { return arguments.length ? (e = Array.from(t, Qf), n) : e.slice() }, n.unknown = function (e) { return arguments.length ? (t = e, n) : t }, n.copy = function () { return fp(e).unknown(t) }, e = arguments.length ? Array.from(e, Qf) : [0, 1], hp(n) } function pp(e, t) { var n, r = 0, i = (e = e.slice()).length - 1, a = e[r], o = e[i]; return o < a && (n = r, r = i, i = n, n = a, a = o, o = n), e[r] = t.floor(a), e[i] = t.ceil(o), e } function mp(e) { return Math.log(e) } function gp(e) { return Math.exp(e) } function yp(e) { return -Math.log(-e) } function bp(e) { return -Math.exp(-e) } function vp(e) { return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e } function xp(e) { return (t, n) => -e(-t, n) } function wp(e) { const t = e(mp, gp), n = t.domain; let r, i, a = 10; function o() { return r = function (e) { return e === Math.E ? Math.log : 10 === e && Math.log10 || 2 === e && Math.log2 || (e = Math.log(e), t => Math.log(t) / e) }(a), i = function (e) { return 10 === e ? vp : e === Math.E ? Math.exp : t => Math.pow(e, t) }(a), n()[0] < 0 ? (r = xp(r), i = xp(i), e(yp, bp)) : e(mp, gp), t } return t.base = function (e) { return arguments.length ? (a = +e, o()) : a }, t.domain = function (e) { return arguments.length ? (n(e), o()) : n() }, t.ticks = e => { const t = n(); let o = t[0], s = t[t.length - 1]; const u = s < o; u && ([o, s] = [s, o]); let l, c, h = r(o), d = r(s); const f = null == e ? 10 : +e; let p = []; if (!(a % 1) && d - h < f) { if (h = Math.floor(h), d = Math.ceil(d), o > 0) { for (; h <= d; ++h)for (l = 1; l < a; ++l)if (c = h < 0 ? l / i(-h) : l * i(h), !(c < o)) { if (c > s) break; p.push(c) } } else for (; h <= d; ++h)for (l = a - 1; l >= 1; --l)if (c = h > 0 ? l / i(-h) : l * i(h), !(c < o)) { if (c > s) break; p.push(c) } 2 * p.length < f && (p = Gd(o, s, f)) } else p = Gd(h, d, Math.min(d - h, f)).map(i); return u ? p.reverse() : p }, t.tickFormat = (e, n) => { if (null == e && (e = 10), null == n && (n = 10 === a ? "s" : ","), "function" != typeof n && (a % 1 || null != (n = kr(n)).precision || (n.trim = !0), n = Dr(n)), e === 1 / 0) return n; const o = Math.max(1, a * e / t.ticks().length); return e => { let t = e / i(Math.round(r(e))); return t * a < a - .5 && (t *= a), t <= o ? n(e) : "" } }, t.nice = () => n(pp(n(), { floor: e => i(Math.floor(r(e))), ceil: e => i(Math.ceil(r(e))) })), t } function kp() { const e = wp(op()).domain([1, 10]); return e.copy = () => ap(e, kp()).base(e.base()), up.apply(e, arguments), e } function Sp(e) { return function (t) { return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e) } } function _p(e) { return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e) } function Cp(e) { return e < 0 ? -e * e : e * e } function Ap(e) { var t = e(tp, tp), n = 1; return t.exponent = function (t) { return arguments.length ? 1 === (n = +t) ? e(tp, tp) : .5 === n ? e(_p, Cp) : e(Sp(n), Sp(1 / n)) : n }, hp(t) } function Tp() { var e = Ap(op()); return e.copy = function () { return ap(e, Tp()).exponent(e.exponent()) }, up.apply(e, arguments), e } function Ep() { return Tp.apply(null, arguments).exponent(.5) } function Np(e) { return function (t) { return Math.sign(t) * Math.log1p(Math.abs(t / e)) } } function Ip(e) { return function (t) { return Math.sign(t) * Math.expm1(Math.abs(t)) * e } } function Mp(e) { var t = 1, n = e(Np(t), Ip(t)); return n.constant = function (n) { return arguments.length ? e(Np(t = +n), Ip(t)) : t }, hp(n) } function Fp() { var e = Mp(op()); return e.copy = function () { return ap(e, Fp()).constant(e.constant()) }, up.apply(e, arguments) } function Dp(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function $p(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function Rp() { return 0 } const Op = Math.sqrt(50), zp = Math.sqrt(10), Pp = Math.sqrt(2); function Bp(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= Op ? 10 : a >= zp ? 5 : a >= Pp ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? Bp(e, t, 2 * n) : [s, u, l] } function Lp(e, t, n) { return Bp(e = +e, t = +t, n = +n)[2] } function jp(e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? Lp(t, e, n) : Lp(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) } function Up(e, t, n, r, i, a) { const o = [[wi, 1, jr], [wi, 5, 5e3], [wi, 15, 15e3], [wi, 30, 3e4], [a, 1, Ur], [a, 5, 3e5], [a, 15, 9e5], [a, 30, 18e5], [i, 1, Wr], [i, 3, 108e5], [i, 6, 216e5], [i, 12, 432e5], [r, 1, Vr], [r, 2, 1728e5], [n, 1, Gr], [t, 1, Hr], [t, 3, 7776e6], [e, 1, qr]]; function s(t, n, r) { const i = Math.abs(n - t) / r, a = function (e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = Dp, n = (t, n) => Dp(e(t), n), r = (t, n) => e(t) - n) : (t = e === Dp || e === $p ? e : Rp, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } }((([, , e]) => e)).right(o, i); if (a === o.length) return e.every(jp(t / qr, n / qr, r)); if (0 === a) return ki.every(Math.max(jp(t, n, r), 1)); const [s, u] = o[i / o[a - 1][2] < o[a][2] / i ? a - 1 : a]; return s.every(u) } return [function (e, t, n) { const r = t < e; r && ([e, t] = [t, e]); const i = n && "function" == typeof n.range ? n : s(e, t, n), a = i ? i.range(e, +t + 1) : []; return r ? a.reverse() : a }, s] } const [Wp, Vp] = Up(pi, gi, oi, Kr, bi, xi), [Gp, Hp] = Up(fi, mi, Jr, Yr, yi, vi); function qp(e) { return new Date(e) } function Yp(e) { return e instanceof Date ? +e : +new Date(+e) } function Xp(e, t, n, r, i, a, o, s, u, l) { var c = sp(), h = c.invert, d = c.domain, f = l(".%L"), p = l(":%S"), m = l("%I:%M"), g = l("%I %p"), y = l("%a %d"), b = l("%b %d"), v = l("%B"), x = l("%Y"); function w(e) { return (u(e) < e ? f : s(e) < e ? p : o(e) < e ? m : a(e) < e ? g : r(e) < e ? i(e) < e ? y : b : n(e) < e ? v : x)(e) } return c.invert = function (e) { return new Date(h(e)) }, c.domain = function (e) { return arguments.length ? d(Array.from(e, Yp)) : d().map(qp) }, c.ticks = function (t) { var n = d(); return e(n[0], n[n.length - 1], null == t ? 10 : t) }, c.tickFormat = function (e, t) { return null == t ? w : l(t) }, c.nice = function (e) { var n = d(); return e && "function" == typeof e.range || (e = t(n[0], n[n.length - 1], null == e ? 10 : e)), e ? d(pp(n, e)) : c }, c.copy = function () { return ap(c, Xp(e, t, n, r, i, a, o, s, u, l)) }, c } function Kp() { return up.apply(Xp(Gp, Hp, fi, mi, Jr, Yr, yi, vi, wi, za).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments) } function Zp() { return up.apply(Xp(Wp, Vp, pi, gi, oi, Xr, bi, xi, wi, Ba).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments) } function Jp() { var e, t, n, r, i, a = 0, o = 1, s = tp, u = !1; function l(t) { return null == t || isNaN(t = +t) ? i : s(0 === n ? .5 : (t = (r(t) - e) * n, u ? Math.max(0, Math.min(1, t)) : t)) } function c(e) { return function (t) { var n, r; return arguments.length ? ([n, r] = t, s = e(n, r), l) : [s(0), s(1)] } } return l.domain = function (i) { return arguments.length ? ([a, o] = i, e = r(a = +a), t = r(o = +o), n = e === t ? 0 : 1 / (t - e), l) : [a, o] }, l.clamp = function (e) { return arguments.length ? (u = !!e, l) : u }, l.interpolator = function (e) { return arguments.length ? (s = e, l) : s }, l.range = c(Zf), l.rangeRound = c(Jf), l.unknown = function (e) { return arguments.length ? (i = e, l) : i }, function (i) { return r = i, e = i(a), t = i(o), n = e === t ? 0 : 1 / (t - e), l } } function Qp(e, t) { return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown()) } function em() { var e = hp(Jp()(tp)); return e.copy = function () { return Qp(e, em()) }, lp.apply(e, arguments) } function tm() { var e = wp(Jp()).domain([1, 10]); return e.copy = function () { return Qp(e, tm()).base(e.base()) }, lp.apply(e, arguments) } function nm() { var e = Mp(Jp()); return e.copy = function () { return Qp(e, nm()).constant(e.constant()) }, lp.apply(e, arguments) } function rm() { var e = Ap(Jp()); return e.copy = function () { return Qp(e, rm()).exponent(e.exponent()) }, lp.apply(e, arguments) } function im() { return rm.apply(null, arguments).exponent(.5) } function am() { var e, t, n, r, i, a, o, s = 0, u = .5, l = 1, c = 1, h = tp, d = !1; function f(e) { return isNaN(e = +e) ? o : (e = .5 + ((e = +a(e)) - t) * (c * e < c * t ? r : i), h(d ? Math.max(0, Math.min(1, e)) : e)) } function p(e) { return function (t) { var n, r, i; return arguments.length ? ([n, r, i] = t, h = function (e, t) { void 0 === t && (t = e, e = Zf); for (var n = 0, r = t.length - 1, i = t[0], a = new Array(r < 0 ? 0 : r); n < r;)a[n] = e(i, i = t[++n]); return function (e) { var t = Math.max(0, Math.min(r - 1, Math.floor(e *= r))); return a[t](e - t) } }(e, [n, r, i]), f) : [h(0), h(.5), h(1)] } } return f.domain = function (o) { return arguments.length ? ([s, u, l] = o, e = a(s = +s), t = a(u = +u), n = a(l = +l), r = e === t ? 0 : .5 / (t - e), i = t === n ? 0 : .5 / (n - t), c = t < e ? -1 : 1, f) : [s, u, l] }, f.clamp = function (e) { return arguments.length ? (d = !!e, f) : d }, f.interpolator = function (e) { return arguments.length ? (h = e, f) : h }, f.range = p(Zf), f.rangeRound = p(Jf), f.unknown = function (e) { return arguments.length ? (o = e, f) : o }, function (o) { return a = o, e = o(s), t = o(u), n = o(l), r = e === t ? 0 : .5 / (t - e), i = t === n ? 0 : .5 / (n - t), c = t < e ? -1 : 1, f } } function om() { var e = hp(am()(tp)); return e.copy = function () { return Qp(e, om()) }, lp.apply(e, arguments) } function sm() { var e = wp(am()).domain([.1, 1, 10]); return e.copy = function () { return Qp(e, sm()).base(e.base()) }, lp.apply(e, arguments) } function um() { var e = Mp(am()); return e.copy = function () { return Qp(e, um()).constant(e.constant()) }, lp.apply(e, arguments) } function lm() { var e = Ap(am()); return e.copy = function () { return Qp(e, lm()).exponent(e.exponent()) }, lp.apply(e, arguments) } function cm() { return lm.apply(null, arguments).exponent(.5) } function hm(e, t, n = Zd) { if ((r = e.length) && !isNaN(t = +t)) { if (t <= 0 || r < 2) return +n(e[0], 0, e); if (t >= 1) return +n(e[r - 1], r - 1, e); var r, i = (r - 1) * t, a = Math.floor(i), o = +n(e[a], a, e); return o + (+n(e[a + 1], a + 1, e) - o) * (i - a) } } function dm() { var e, t = [], n = [], r = []; function i() { var e = 0, i = Math.max(1, n.length); for (r = new Array(i - 1); ++e < i;)r[e - 1] = hm(t, e / i); return a } function a(t) { return null == t || isNaN(t = +t) ? e : n[ef(r, t)] } return a.invertExtent = function (e) { var i = n.indexOf(e); return i < 0 ? [NaN, NaN] : [i > 0 ? r[i - 1] : t[0], i < r.length ? r[i] : t[t.length - 1]] }, a.domain = function (e) { if (!arguments.length) return t.slice(); t = []; for (let n of e) null == n || isNaN(n = +n) || t.push(n); return t.sort(qd), i() }, a.range = function (e) { return arguments.length ? (n = Array.from(e), i()) : n.slice() }, a.unknown = function (t) { return arguments.length ? (e = t, a) : e }, a.quantiles = function () { return r.slice() }, a.copy = function () { return dm().domain(t).range(n).unknown(e) }, up.apply(a, arguments) } function fm() { var e, t = 0, n = 1, r = 1, i = [.5], a = [0, 1]; function o(t) { return null != t && t <= t ? a[ef(i, t, 0, r)] : e } function s() { var e = -1; for (i = new Array(r); ++e < r;)i[e] = ((e + 1) * n - (e - r) * t) / (r + 1); return o } return o.domain = function (e) { return arguments.length ? ([t, n] = e, t = +t, n = +n, s()) : [t, n] }, o.range = function (e) { return arguments.length ? (r = (a = Array.from(e)).length - 1, s()) : a.slice() }, o.invertExtent = function (e) { var o = a.indexOf(e); return o < 0 ? [NaN, NaN] : o < 1 ? [t, i[0]] : o >= r ? [i[r - 1], n] : [i[o - 1], i[o]] }, o.unknown = function (t) { return arguments.length ? (e = t, o) : o }, o.thresholds = function () { return i.slice() }, o.copy = function () { return fm().domain([t, n]).range(a).unknown(e) }, up.apply(hp(o), arguments) } function pm() { var e, t = [.5], n = [0, 1], r = 1; function i(i) { return null != i && i <= i ? n[ef(t, i, 0, r)] : e } return i.domain = function (e) { return arguments.length ? (t = Array.from(e), r = Math.min(t.length, n.length - 1), i) : t.slice() }, i.range = function (e) { return arguments.length ? (n = Array.from(e), r = Math.min(t.length, n.length - 1), i) : n.slice() }, i.invertExtent = function (e) { var r = n.indexOf(e); return [t[r - 1], t[r]] }, i.unknown = function (t) { return arguments.length ? (e = t, i) : e }, i.copy = function () { return pm().domain(t).range(n).unknown(e) }, up.apply(i, arguments) } class mm extends Map { constructor(e, t = vm) { if (super(), Object.defineProperties(this, { _intern: { value: new Map }, _key: { value: t } }), null != e) for (const [t, n] of e) this.set(t, n) } get(e) { return super.get(gm(this, e)) } has(e) { return super.has(gm(this, e)) } set(e, t) { return super.set(ym(this, e), t) } delete(e) { return super.delete(bm(this, e)) } } Set; function gm({ _intern: e, _key: t }, n) { const r = t(n); return e.has(r) ? e.get(r) : n } function ym({ _intern: e, _key: t }, n) { const r = t(n); return e.has(r) ? e.get(r) : (e.set(r, n), n) } function bm({ _intern: e, _key: t }, n) { const r = t(n); return e.has(r) && (n = e.get(r), e.delete(r)), n } function vm(e) { return null !== e && "object" == typeof e ? e.valueOf() : e } const xm = Symbol("implicit"); function wm() { var e = new mm, t = [], n = [], r = xm; function i(i) { let a = e.get(i); if (void 0 === a) { if (r !== xm) return r; e.set(i, a = t.push(i) - 1) } return n[a % n.length] } return i.domain = function (n) { if (!arguments.length) return t.slice(); t = [], e = new mm; for (const r of n) e.has(r) || e.set(r, t.push(r) - 1); return i }, i.range = function (e) { return arguments.length ? (n = Array.from(e), i) : n.slice() }, i.unknown = function (e) { return arguments.length ? (r = e, i) : r }, i.copy = function () { return wm(t, n).unknown(r) }, up.apply(i, arguments), i } function km(e, t, n) { e.prototype = t.prototype = n, n.constructor = e } function Sm(e, t) { var n = Object.create(e.prototype); for (var r in t) n[r] = t[r]; return n } function _m() { } var Cm = .7, Am = 1 / Cm, Tm = "\\s*([+-]?\\d+)\\s*", Em = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Nm = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Im = /^#([0-9a-f]{3,8})$/, Mm = new RegExp(`^rgb\\(${Tm},${Tm},${Tm}\\)$`), Fm = new RegExp(`^rgb\\(${Nm},${Nm},${Nm}\\)$`), Dm = new RegExp(`^rgba\\(${Tm},${Tm},${Tm},${Em}\\)$`), $m = new RegExp(`^rgba\\(${Nm},${Nm},${Nm},${Em}\\)$`), Rm = new RegExp(`^hsl\\(${Em},${Nm},${Nm}\\)$`), Om = new RegExp(`^hsla\\(${Em},${Nm},${Nm},${Em}\\)$`), zm = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; function Pm() { return this.rgb().formatHex() } function Bm() { return this.rgb().formatRgb() } function Lm(e) { var t, n; return e = (e + "").trim().toLowerCase(), (t = Im.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), 6 === n ? jm(t) : 3 === n ? new Gm(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, (15 & t) << 4 | 15 & t, 1) : 8 === n ? Um(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (255 & t) / 255) : 4 === n ? Um(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, ((15 & t) << 4 | 15 & t) / 255) : null) : (t = Mm.exec(e)) ? new Gm(t[1], t[2], t[3], 1) : (t = Fm.exec(e)) ? new Gm(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, 1) : (t = Dm.exec(e)) ? Um(t[1], t[2], t[3], t[4]) : (t = $m.exec(e)) ? Um(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, t[4]) : (t = Rm.exec(e)) ? Zm(t[1], t[2] / 100, t[3] / 100, 1) : (t = Om.exec(e)) ? Zm(t[1], t[2] / 100, t[3] / 100, t[4]) : zm.hasOwnProperty(e) ? jm(zm[e]) : "transparent" === e ? new Gm(NaN, NaN, NaN, 0) : null } function jm(e) { return new Gm(e >> 16 & 255, e >> 8 & 255, 255 & e, 1) } function Um(e, t, n, r) { return r <= 0 && (e = t = n = NaN), new Gm(e, t, n, r) } function Wm(e) { return e instanceof _m || (e = Lm(e)), e ? new Gm((e = e.rgb()).r, e.g, e.b, e.opacity) : new Gm } function Vm(e, t, n, r) { return 1 === arguments.length ? Wm(e) : new Gm(e, t, n, null == r ? 1 : r) } function Gm(e, t, n, r) { this.r = +e, this.g = +t, this.b = +n, this.opacity = +r } function Hm() { return `#${Km(this.r)}${Km(this.g)}${Km(this.b)}` } function qm() { const e = Ym(this.opacity); return `${1 === e ? "rgb(" : "rgba("}${Xm(this.r)}, ${Xm(this.g)}, ${Xm(this.b)}${1 === e ? ")" : `, ${e})`}` } function Ym(e) { return isNaN(e) ? 1 : Math.max(0, Math.min(1, e)) } function Xm(e) { return Math.max(0, Math.min(255, Math.round(e) || 0)) } function Km(e) { return ((e = Xm(e)) < 16 ? "0" : "") + e.toString(16) } function Zm(e, t, n, r) { return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new eg(e, t, n, r) } function Jm(e) { if (e instanceof eg) return new eg(e.h, e.s, e.l, e.opacity); if (e instanceof _m || (e = Lm(e)), !e) return new eg; if (e instanceof eg) return e; var t = (e = e.rgb()).r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, u = (a + i) / 2; return s ? (o = t === a ? (n - r) / s + 6 * (n < r) : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= u < .5 ? a + i : 2 - a - i, o *= 60) : s = u > 0 && u < 1 ? 0 : o, new eg(o, s, u, e.opacity) } function Qm(e, t, n, r) { return 1 === arguments.length ? Jm(e) : new eg(e, t, n, null == r ? 1 : r) } function eg(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function tg(e) { return (e = (e || 0) % 360) < 0 ? e + 360 : e } function ng(e) { return Math.max(0, Math.min(1, e || 0)) } function rg(e, t, n) { return 255 * (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) } function ig(e, t, n, r, i) { var a = e * e, o = a * e; return ((1 - 3 * e + 3 * a - o) * t + (4 - 6 * a + 3 * o) * n + (1 + 3 * e + 3 * a - 3 * o) * r + o * i) / 6 } function ag(e) { var t = e.length - 1; return function (n) { var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], a = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - a, s = r < t - 1 ? e[r + 2] : 2 * a - i; return ig((n - r / t) * t, o, i, a, s) } } function og(e) { var t = e.length; return function (n) { var r = Math.floor(((n %= 1) < 0 ? ++n : n) * t), i = e[(r + t - 1) % t], a = e[r % t], o = e[(r + 1) % t], s = e[(r + 2) % t]; return ig((n - r / t) * t, i, a, o, s) } } km(_m, Lm, { copy(e) { return Object.assign(new this.constructor, this, e) }, displayable() { return this.rgb().displayable() }, hex: Pm, formatHex: Pm, formatHex8: function () { return this.rgb().formatHex8() }, formatHsl: function () { return Jm(this).formatHsl() }, formatRgb: Bm, toString: Bm }), km(Gm, Vm, Sm(_m, { brighter(e) { return e = null == e ? Am : Math.pow(Am, e), new Gm(this.r * e, this.g * e, this.b * e, this.opacity) }, darker(e) { return e = null == e ? Cm : Math.pow(Cm, e), new Gm(this.r * e, this.g * e, this.b * e, this.opacity) }, rgb() { return this }, clamp() { return new Gm(Xm(this.r), Xm(this.g), Xm(this.b), Ym(this.opacity)) }, displayable() { return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1 }, hex: Hm, formatHex: Hm, formatHex8: function () { return `#${Km(this.r)}${Km(this.g)}${Km(this.b)}${Km(255 * (isNaN(this.opacity) ? 1 : this.opacity))}` }, formatRgb: qm, toString: qm })), km(eg, Qm, Sm(_m, { brighter(e) { return e = null == e ? Am : Math.pow(Am, e), new eg(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? Cm : Math.pow(Cm, e), new eg(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = this.h % 360 + 360 * (this.h < 0), t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r; return new Gm(rg(e >= 240 ? e - 240 : e + 120, i, r), rg(e, i, r), rg(e < 120 ? e + 240 : e - 120, i, r), this.opacity) }, clamp() { return new eg(tg(this.h), ng(this.s), ng(this.l), Ym(this.opacity)) }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1 }, formatHsl() { const e = Ym(this.opacity); return `${1 === e ? "hsl(" : "hsla("}${tg(this.h)}, ${100 * ng(this.s)}%, ${100 * ng(this.l)}%${1 === e ? ")" : `, ${e})`}` } })); const sg = e => () => e; function ug(e, t) { return function (n) { return e + n * t } } function lg(e, t) { var n = t - e; return n ? ug(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : sg(isNaN(e) ? t : e) } function cg(e) { return 1 == (e = +e) ? hg : function (t, n) { return n - t ? function (e, t, n) { return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function (r) { return Math.pow(e + r * t, n) } }(t, n, e) : sg(isNaN(t) ? n : t) } } function hg(e, t) { var n = t - e; return n ? ug(e, n) : sg(isNaN(e) ? t : e) } const dg = function e(t) { var n = cg(t); function r(e, t) { var r = n((e = Vm(e)).r, (t = Vm(t)).r), i = n(e.g, t.g), a = n(e.b, t.b), o = hg(e.opacity, t.opacity); return function (t) { return e.r = r(t), e.g = i(t), e.b = a(t), e.opacity = o(t), e + "" } } return r.gamma = e, r }(1); function fg(e) { return function (t) { var n, r, i = t.length, a = new Array(i), o = new Array(i), s = new Array(i); for (n = 0; n < i; ++n)r = Vm(t[n]), a[n] = r.r || 0, o[n] = r.g || 0, s[n] = r.b || 0; return a = e(a), o = e(o), s = e(s), r.opacity = 1, function (e) { return r.r = a(e), r.g = o(e), r.b = s(e), r + "" } } } var pg = fg(ag), mg = fg(og); function gg(e, t) { t || (t = []); var n, r = e ? Math.min(t.length, e.length) : 0, i = t.slice(); return function (a) { for (n = 0; n < r; ++n)i[n] = e[n] * (1 - a) + t[n] * a; return i } } function yg(e) { return ArrayBuffer.isView(e) && !(e instanceof DataView) } function bg(e, t) { return (yg(t) ? gg : vg)(e, t) } function vg(e, t) { var n, r = t ? t.length : 0, i = e ? Math.min(r, e.length) : 0, a = new Array(i), o = new Array(r); for (n = 0; n < i; ++n)a[n] = Ag(e[n], t[n]); for (; n < r; ++n)o[n] = t[n]; return function (e) { for (n = 0; n < i; ++n)o[n] = a[n](e); return o } } function xg(e, t) { var n = new Date; return e = +e, t = +t, function (r) { return n.setTime(e * (1 - r) + t * r), n } } function wg(e, t) { return e = +e, t = +t, function (n) { return e * (1 - n) + t * n } } function kg(e, t) { var n, r = {}, i = {}; for (n in null !== e && "object" == typeof e || (e = {}), null !== t && "object" == typeof t || (t = {}), t) n in e ? r[n] = Ag(e[n], t[n]) : i[n] = t[n]; return function (e) { for (n in r) i[n] = r[n](e); return i } } var Sg = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, _g = new RegExp(Sg.source, "g"); function Cg(e, t) { var n, r, i, a = Sg.lastIndex = _g.lastIndex = 0, o = -1, s = [], u = []; for (e += "", t += ""; (n = Sg.exec(e)) && (r = _g.exec(t));)(i = r.index) > a && (i = t.slice(a, i), s[o] ? s[o] += i : s[++o] = i), (n = n[0]) === (r = r[0]) ? s[o] ? s[o] += r : s[++o] = r : (s[++o] = null, u.push({ i: o, x: wg(n, r) })), a = _g.lastIndex; return a < t.length && (i = t.slice(a), s[o] ? s[o] += i : s[++o] = i), s.length < 2 ? u[0] ? function (e) { return function (t) { return e(t) + "" } }(u[0].x) : function (e) { return function () { return e } }(t) : (t = u.length, function (e) { for (var n, r = 0; r < t; ++r)s[(n = u[r]).i] = n.x(e); return s.join("") }) } function Ag(e, t) { var n, r = typeof t; return null == t || "boolean" === r ? sg(t) : ("number" === r ? wg : "string" === r ? (n = Lm(t)) ? (t = n, dg) : Cg : t instanceof Lm ? dg : t instanceof Date ? xg : yg(t) ? gg : Array.isArray(t) ? vg : "function" != typeof t.valueOf && "function" != typeof t.toString || isNaN(t) ? kg : wg)(e, t) } function Tg(e, t) { void 0 === t && (t = e, e = Ag); for (var n = 0, r = t.length - 1, i = t[0], a = new Array(r < 0 ? 0 : r); n < r;)a[n] = e(i, i = t[++n]); return function (e) { var t = Math.max(0, Math.min(r - 1, Math.floor(e *= r))); return a[t](e - t) } } function Eg(e) { var t = e.length; return function (n) { return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))] } } function Ng(e, t) { var n = lg(+e, +t); return function (e) { var t = n(e); return t - 360 * Math.floor(t / 360) } } function Ig(e, t) { return e = +e, t = +t, function (n) { return Math.round(e * (1 - n) + t * n) } } var Mg, Fg = 180 / Math.PI, Dg = { translateX: 0, translateY: 0, rotate: 0, skewX: 0, scaleX: 1, scaleY: 1 }; function $g(e, t, n, r, i, a) { var o, s, u; return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (u = e * n + t * r) && (n -= e * u, r -= t * u), (s = Math.sqrt(n * n + r * r)) && (n /= s, r /= s, u /= s), e * r < t * n && (e = -e, t = -t, u = -u, o = -o), { translateX: i, translateY: a, rotate: Math.atan2(t, e) * Fg, skewX: Math.atan(u) * Fg, scaleX: o, scaleY: s } } function Rg(e, t, n, r) { function i(e) { return e.length ? e.pop() + " " : "" } return function (a, o) { var s = [], u = []; return a = e(a), o = e(o), function (e, r, i, a, o, s) { if (e !== i || r !== a) { var u = o.push("translate(", null, t, null, n); s.push({ i: u - 4, x: wg(e, i) }, { i: u - 2, x: wg(r, a) }) } else (i || a) && o.push("translate(" + i + t + a + n) }(a.translateX, a.translateY, o.translateX, o.translateY, s, u), function (e, t, n, a) { e !== t ? (e - t > 180 ? t += 360 : t - e > 180 && (e += 360), a.push({ i: n.push(i(n) + "rotate(", null, r) - 2, x: wg(e, t) })) : t && n.push(i(n) + "rotate(" + t + r) }(a.rotate, o.rotate, s, u), function (e, t, n, a) { e !== t ? a.push({ i: n.push(i(n) + "skewX(", null, r) - 2, x: wg(e, t) }) : t && n.push(i(n) + "skewX(" + t + r) }(a.skewX, o.skewX, s, u), function (e, t, n, r, a, o) { if (e !== n || t !== r) { var s = a.push(i(a) + "scale(", null, ",", null, ")"); o.push({ i: s - 4, x: wg(e, n) }, { i: s - 2, x: wg(t, r) }) } else 1 === n && 1 === r || a.push(i(a) + "scale(" + n + "," + r + ")") }(a.scaleX, a.scaleY, o.scaleX, o.scaleY, s, u), a = o = null, function (e) { for (var t, n = -1, r = u.length; ++n < r;)s[(t = u[n]).i] = t.x(e); return s.join("") } } } var Og = Rg((function (e) { const t = new ("function" == typeof DOMMatrix ? DOMMatrix : WebKitCSSMatrix)(e + ""); return t.isIdentity ? Dg : $g(t.a, t.b, t.c, t.d, t.e, t.f) }), "px, ", "px)", "deg)"), zg = Rg((function (e) { return null == e ? Dg : (Mg || (Mg = document.createElementNS("http://www.w3.org/2000/svg", "g")), Mg.setAttribute("transform", e), (e = Mg.transform.baseVal.consolidate()) ? $g((e = e.matrix).a, e.b, e.c, e.d, e.e, e.f) : Dg) }), ", ", ")", ")"); function Pg(e) { return ((e = Math.exp(e)) + 1 / e) / 2 } const Bg = function e(t, n, r) { function i(e, i) { var a, o, s = e[0], u = e[1], l = e[2], c = i[0], h = i[1], d = i[2], f = c - s, p = h - u, m = f * f + p * p; if (m < 1e-12) o = Math.log(d / l) / t, a = function (e) { return [s + e * f, u + e * p, l * Math.exp(t * e * o)] }; else { var g = Math.sqrt(m), y = (d * d - l * l + r * m) / (2 * l * n * g), b = (d * d - l * l - r * m) / (2 * d * n * g), v = Math.log(Math.sqrt(y * y + 1) - y), x = Math.log(Math.sqrt(b * b + 1) - b); o = (x - v) / t, a = function (e) { var r = e * o, i = Pg(v), a = l / (n * g) * (i * function (e) { return ((e = Math.exp(2 * e)) - 1) / (e + 1) }(t * r + v) - function (e) { return ((e = Math.exp(e)) - 1 / e) / 2 }(v)); return [s + a * f, u + a * p, l * i / Pg(t * r + v)] } } return a.duration = 1e3 * o * t / Math.SQRT2, a } return i.rho = function (t) { var n = Math.max(.001, +t), r = n * n; return e(n, r, r * r) }, i }(Math.SQRT2, 2, 4); function Lg(e) { return function (t, n) { var r = e((t = Qm(t)).h, (n = Qm(n)).h), i = hg(t.s, n.s), a = hg(t.l, n.l), o = hg(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.s = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } const jg = Lg(lg); var Ug = Lg(hg); const Wg = Math.PI / 180, Vg = 180 / Math.PI, Gg = .96422, Hg = 1, qg = .82521, Yg = 4 / 29, Xg = 6 / 29, Kg = 3 * Xg * Xg, Zg = .008856451679035631; function Jg(e) { if (e instanceof ey) return new ey(e.l, e.a, e.b, e.opacity); if (e instanceof sy) return uy(e); e instanceof Gm || (e = Wm(e)); var t, n, r = iy(e.r), i = iy(e.g), a = iy(e.b), o = ty((.2225045 * r + .7168786 * i + .0606169 * a) / Hg); return r === i && i === a ? t = n = o : (t = ty((.4360747 * r + .3850649 * i + .1430804 * a) / Gg), n = ty((.0139322 * r + .0971045 * i + .7141733 * a) / qg)), new ey(116 * o - 16, 500 * (t - o), 200 * (o - n), e.opacity) } function Qg(e, t, n, r) { return 1 === arguments.length ? Jg(e) : new ey(e, t, n, null == r ? 1 : r) } function ey(e, t, n, r) { this.l = +e, this.a = +t, this.b = +n, this.opacity = +r } function ty(e) { return e > Zg ? Math.pow(e, 1 / 3) : e / Kg + Yg } function ny(e) { return e > Xg ? e * e * e : Kg * (e - Yg) } function ry(e) { return 255 * (e <= .0031308 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - .055) } function iy(e) { return (e /= 255) <= .04045 ? e / 12.92 : Math.pow((e + .055) / 1.055, 2.4) } function ay(e) { if (e instanceof sy) return new sy(e.h, e.c, e.l, e.opacity); if (e instanceof ey || (e = Jg(e)), 0 === e.a && 0 === e.b) return new sy(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity); var t = Math.atan2(e.b, e.a) * Vg; return new sy(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity) } function oy(e, t, n, r) { return 1 === arguments.length ? ay(e) : new sy(e, t, n, null == r ? 1 : r) } function sy(e, t, n, r) { this.h = +e, this.c = +t, this.l = +n, this.opacity = +r } function uy(e) { if (isNaN(e.h)) return new ey(e.l, 0, 0, e.opacity); var t = e.h * Wg; return new ey(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity) } function ly(e, t) { var n = hg((e = Qg(e)).l, (t = Qg(t)).l), r = hg(e.a, t.a), i = hg(e.b, t.b), a = hg(e.opacity, t.opacity); return function (t) { return e.l = n(t), e.a = r(t), e.b = i(t), e.opacity = a(t), e + "" } } function cy(e) { return function (t, n) { var r = e((t = oy(t)).h, (n = oy(n)).h), i = hg(t.c, n.c), a = hg(t.l, n.l), o = hg(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.c = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } km(ey, Qg, Sm(_m, { brighter(e) { return new ey(this.l + 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, darker(e) { return new ey(this.l - 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, rgb() { var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200; return new Gm(ry(3.1338561 * (t = Gg * ny(t)) - 1.6168667 * (e = Hg * ny(e)) - .4906146 * (n = qg * ny(n))), ry(-.9787684 * t + 1.9161415 * e + .033454 * n), ry(.0719453 * t - .2289914 * e + 1.4052427 * n), this.opacity) } })), km(sy, oy, Sm(_m, { brighter(e) { return new sy(this.h, this.c, this.l + 18 * (null == e ? 1 : e), this.opacity) }, darker(e) { return new sy(this.h, this.c, this.l - 18 * (null == e ? 1 : e), this.opacity) }, rgb() { return uy(this).rgb() } })); const hy = cy(lg); var dy = cy(hg), fy = -.14861, py = 1.78277, my = -.29227, gy = -.90649, yy = 1.97294, by = yy * gy, vy = yy * py, xy = py * my - gy * fy; function wy(e, t, n, r) { return 1 === arguments.length ? function (e) { if (e instanceof ky) return new ky(e.h, e.s, e.l, e.opacity); e instanceof Gm || (e = Wm(e)); var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (xy * r + by * t - vy * n) / (xy + by - vy), a = r - i, o = (yy * (n - i) - my * a) / gy, s = Math.sqrt(o * o + a * a) / (yy * i * (1 - i)), u = s ? Math.atan2(o, a) * Vg - 120 : NaN; return new ky(u < 0 ? u + 360 : u, s, i, e.opacity) }(e) : new ky(e, t, n, null == r ? 1 : r) } function ky(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function Sy(e) { return function t(n) { function r(t, r) { var i = e((t = wy(t)).h, (r = wy(r)).h), a = hg(t.s, r.s), o = hg(t.l, r.l), s = hg(t.opacity, r.opacity); return function (e) { return t.h = i(e), t.s = a(e), t.l = o(Math.pow(e, n)), t.opacity = s(e), t + "" } } return n = +n, r.gamma = t, r }(1) } km(ky, wy, Sm(_m, { brighter(e) { return e = null == e ? Am : Math.pow(Am, e), new ky(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? Cm : Math.pow(Cm, e), new ky(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = isNaN(this.h) ? 0 : (this.h + 120) * Wg, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e); return new Gm(255 * (t + n * (fy * r + py * i)), 255 * (t + n * (my * r + gy * i)), 255 * (t + n * (yy * r)), this.opacity) } })); const _y = Sy(lg); var Cy = Sy(hg); function Ay(e, t) { for (var n = new Array(t), r = 0; r < t; ++r)n[r] = e(r / (t - 1)); return n } function Ty(e) { for (var t = e.length / 6 | 0, n = new Array(t), r = 0; r < t;)n[r] = "#" + e.slice(6 * r, 6 * ++r); return n } const Ey = Ty("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), Ny = Ty("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), Iy = Ty("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), My = Ty("4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0"), Fy = Ty("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), Dy = Ty("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), $y = Ty("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), Ry = Ty("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), Oy = Ty("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), zy = Ty("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"); function Py(e, t, n) { const r = e - t + 2 * n; return e ? r > 0 ? r : 1 : 0 } const By = "linear", Ly = "log", jy = "pow", Uy = "sqrt", Wy = "symlog", Vy = "time", Gy = "utc", Hy = "sequential", qy = "diverging", Yy = "quantile", Xy = "quantize", Ky = "threshold", Zy = "ordinal", Jy = "point", Qy = "band", eb = "bin-ordinal", tb = "continuous", nb = "discrete", rb = "discretizing", ib = "interpolating", ab = "temporal"; function ob() { const e = wm().unknown(void 0), t = e.domain, n = e.range; let r, i, a = [0, 1], o = !1, s = 0, u = 0, l = .5; function c() { const e = t().length, c = a[1] < a[0], h = a[1 - c], d = Py(e, s, u); let f = a[c - 0]; r = (h - f) / (d || 1), o && (r = Math.floor(r)), f += (h - f - r * (e - s)) * l, i = r * (1 - s), o && (f = Math.round(f), i = Math.round(i)); const p = function (e, t, n) { e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n; for (var r = -1, i = 0 | Math.max(0, Math.ceil((t - e) / n)), a = new Array(i); ++r < i;)a[r] = e + r * n; return a }(e).map((e => f + r * e)); return n(c ? p.reverse() : p) } return delete e.unknown, e.domain = function (e) { return arguments.length ? (t(e), c()) : t() }, e.range = function (e) { return arguments.length ? (a = [+e[0], +e[1]], c()) : a.slice() }, e.rangeRound = function (e) { return a = [+e[0], +e[1]], o = !0, c() }, e.bandwidth = function () { return i }, e.step = function () { return r }, e.round = function (e) { return arguments.length ? (o = !!e, c()) : o }, e.padding = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), s = u, c()) : s }, e.paddingInner = function (e) { return arguments.length ? (s = Math.max(0, Math.min(1, e)), c()) : s }, e.paddingOuter = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), c()) : u }, e.align = function (e) { return arguments.length ? (l = Math.max(0, Math.min(1, e)), c()) : l }, e.invertRange = function (e) { if (null == e[0] || null == e[1]) return; const r = a[1] < a[0], o = r ? n().reverse() : n(), s = o.length - 1; let u, l, c, h = +e[0], d = +e[1]; return h != h || d != d || (d < h && (c = h, h = d, d = c), d < o[0] || h > a[1 - r]) ? void 0 : (u = Math.max(0, Bd(o, h) - 1), l = h === d ? u : Bd(o, d) - 1, h - o[u] > i + 1e-10 && ++u, r && (c = u, u = s - l, l = s - c), u > l ? void 0 : t().slice(u, l + 1)) }, e.invert = function (t) { const n = e.invertRange([t, t]); return n ? n[0] : n }, e.copy = function () { return ob().domain(t()).range(a).round(o).paddingInner(s).paddingOuter(u).align(l) }, c() } function sb(e) { const t = e.copy; return e.padding = e.paddingOuter, delete e.paddingInner, e.copy = function () { return sb(t()) }, e } var ub = Array.prototype.map; const lb = Array.prototype.slice; const cb = new Map, hb = Symbol("vega_scale"); function db(e) { return e[hb] = !0, e } function fb(e, t, n) { return arguments.length > 1 ? (cb.set(e, function (e, t, n) { const r = function () { const n = t(); return n.invertRange || (n.invertRange = n.invert ? function (e) { return function (t) { let n, r = t[0], i = t[1]; return i < r && (n = r, r = i, i = n), [e.invert(r), e.invert(i)] } }(n) : n.invertExtent ? function (e) { return function (t) { const n = e.range(); let r, i, a, o, s = t[0], u = t[1], l = -1; for (u < s && (i = s, s = u, u = i), a = 0, o = n.length; a < o; ++a)n[a] >= s && n[a] <= u && (l < 0 && (l = a), r = a); if (!(l < 0)) return s = e.invertExtent(n[l]), u = e.invertExtent(n[r]), [void 0 === s[0] ? s[1] : s[0], void 0 === u[1] ? u[0] : u[1]] } }(n) : void 0), n.type = e, db(n) }; return r.metadata = Qn(_n(n)), r }(e, t, n)), this) : pb(e) ? cb.get(e) : void 0 } function pb(e) { return cb.has(e) } function mb(e, t) { const n = cb.get(e); return n && n.metadata[t] } function gb(e) { return mb(e, tb) } function yb(e) { return mb(e, nb) } function bb(e) { return mb(e, rb) } function vb(e) { return mb(e, Ly) } function xb(e) { return mb(e, ib) } function wb(e) { return mb(e, Yy) } fb("identity", fp), fb(By, dp, tb), fb(Ly, kp, [tb, Ly]), fb(jy, Tp, tb), fb(Uy, Ep, tb), fb(Wy, Fp, tb), fb(Vy, Kp, [tb, ab]), fb(Gy, Zp, [tb, ab]), fb(Hy, em, [tb, ib]), fb(`${Hy}-${By}`, em, [tb, ib]), fb(`${Hy}-${Ly}`, tm, [tb, ib, Ly]), fb(`${Hy}-${jy}`, rm, [tb, ib]), fb(`${Hy}-${Uy}`, im, [tb, ib]), fb(`${Hy}-${Wy}`, nm, [tb, ib]), fb(`${qy}-${By}`, om, [tb, ib]), fb(`${qy}-${Ly}`, sm, [tb, ib, Ly]), fb(`${qy}-${jy}`, lm, [tb, ib]), fb(`${qy}-${Uy}`, cm, [tb, ib]), fb(`${qy}-${Wy}`, um, [tb, ib]), fb(Yy, dm, [rb, Yy]), fb(Xy, fm, rb), fb(Ky, pm, rb), fb(eb, (function e() { let t = [], n = []; function r(e) { return null == e || e != e ? void 0 : n[(Ld(t, e) - 1) % n.length] } return r.domain = function (e) { return arguments.length ? (t = function (e) { return ub.call(e, dn) }(e), r) : t.slice() }, r.range = function (e) { return arguments.length ? (n = lb.call(e), r) : n.slice() }, r.tickFormat = function (e, n) { return cp(t[0], hn(t), null == e ? 10 : e, n) }, r.copy = function () { return e().domain(r.domain()).range(r.range()) }, r }), [nb, rb]), fb(Zy, wm, nb), fb(Qy, ob, nb), fb(Jy, (function () { return sb(ob().paddingInner(1)) }), nb); const kb = ["clamp", "base", "constant", "exponent"]; function Sb(e, t, n) { return Tg(Cb(t || "rgb", n), e) } function _b(e, t, n) { const r = n - t; let i, a, o; return r && Number.isFinite(r) ? (i = (a = e.type).indexOf("-"), a = i < 0 ? a : a.slice(i + 1), o = fb(a)().domain([t, n]).range([0, 1]), kb.forEach((t => e[t] ? o[t](e[t]()) : 0)), o) : Fn(.5) } function Cb(e, t) { const n = o[function (e) { return "interpolate" + e.toLowerCase().split("-").map((e => e[0].toUpperCase() + e.slice(1))).join("") }(e)]; return null != t && n && n.gamma ? n.gamma(t) : n } function Ab(e) { if (on(e)) return e; const t = e.length / 6 | 0, n = new Array(t); for (let r = 0; r < t;)n[r] = "#" + e.slice(6 * r, 6 * ++r); return n } function Tb(e, t) { for (const n in e) Nb(n, t(e[n])) } const Eb = {}; function Nb(e, t) { return e = e && e.toLowerCase(), arguments.length > 1 ? (Eb[e] = t, this) : Eb[e] } Tb({ accent: Ey, category10: Ny, category20: "1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5", category20b: "393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6", category20c: "3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9", dark2: Iy, observable10: My, paired: Fy, pastel1: Dy, pastel2: $y, set1: Ry, set2: Oy, set3: zy, tableau10: "4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac", tableau20: "4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5" }, Ab), Tb({ blues: "cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90", greens: "d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429", greys: "e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e", oranges: "fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303", purples: "e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c", reds: "fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13", blueGreen: "d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429", bluePurple: "ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71", greenBlue: "d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1", orangeRed: "fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403", purpleBlue: "dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281", purpleBlueGreen: "dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353", purpleRed: "dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a", redPurple: "fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174", yellowGreen: "e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034", yellowOrangeBrown: "feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204", yellowOrangeRed: "fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225", blueOrange: "134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07", brownBlueGreen: "704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147", purpleGreen: "5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29", purpleOrange: "4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07", redBlue: "8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85", redGrey: "8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434", yellowGreenBlue: "eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185", redYellowBlue: "a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695", redYellowGreen: "a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837", pinkYellowGreen: "8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419", spectral: "9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2", viridis: "440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725", magma: "0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf", inferno: "0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4", plasma: "0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921", cividis: "00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647", rainbow: "6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa", sinebow: "ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040", turbo: "23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00", browns: "eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632", tealBlues: "bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985", teals: "bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667", warmGreys: "dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e", goldGreen: "f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36", goldOrange: "f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26", goldRed: "f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e", lightGreyRed: "efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b", lightGreyTeal: "e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc", lightMulti: "e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c", lightOrange: "f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b", lightTealBlue: "e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988", darkBlue: "3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff", darkGold: "3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff", darkGreen: "3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa", darkMulti: "3737371f5287197d8c29a86995ce3fffe800ffffff", darkRed: "3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c" }, (e => Sb(Ab(e)))); const Ib = "symbol", Mb = e => on(e) ? e.map((e => String(e))) : String(e), Fb = (e, t) => e[1] - t[1], Db = (e, t) => t[1] - e[1]; function $b(e, t, n) { let r; return Wn(t) && (e.bins && (t = Math.max(t, e.bins.length)), null != n && (t = Math.min(t, Math.floor(qn(e.domain()) / n || 1) + 1))), sn(t) && (r = t.step, t = t.interval), Vn(t) && (t = e.type === Vy ? fa(t) : e.type == Gy ? pa(t) : Vt("Only time and utc scales accept interval strings."), r && (t = t.every(r))), t } function Rb(e, t, n) { let r = e.range(), i = r[0], a = hn(r), o = Fb; if (i > a && (r = a, a = i, i = r, o = Db), i = Math.floor(i), a = Math.ceil(a), t = t.map((t => [t, e(t)])).filter((e => i <= e[1] && e[1] <= a)).sort(o).map((e => e[0])), n > 0 && t.length > 1) { const e = [t[0], hn(t)]; for (; t.length > n && t.length >= 3;)t = t.filter(((e, t) => !(t % 2))); t.length < 3 && (t = e) } return t } function Ob(e, t) { return e.bins ? Rb(e, e.bins, t) : e.ticks ? e.ticks(t) : e.domain() } function zb(e, t, n, r, i, a) { const o = t.type; let s = Mb; if (o === Vy || i === Vy) s = e.timeFormat(r); else if (o === Gy || i === Gy) s = e.utcFormat(r); else if (vb(o)) { const i = e.formatFloat(r); if (a || t.bins) s = i; else { const e = Pb(t, n, !1); s = t => e(t) ? i(t) : "" } } else if (t.tickFormat) { const i = t.domain(); s = e.formatSpan(i[0], i[i.length - 1], n, r) } else r && (s = e.format(r)); return s } function Pb(e, t, n) { const r = Ob(e, t), i = e.base(), a = Math.log(i), o = Math.max(1, i * t / r.length), s = e => { let t = e / Math.pow(i, Math.round(Math.log(e) / a)); return t * i < i - .5 && (t *= i), t <= o }; return n ? r.filter(s) : s } const Bb = { [Yy]: "quantiles", [Xy]: "thresholds", [Ky]: "domain" }, Lb = { [Yy]: "quantiles", [Xy]: "domain" }; function jb(e, t) { return e.bins ? function (e) { const t = e.slice(0, -1); return t.max = hn(e), t }(e.bins) : e.type === Ly ? Pb(e, t, !0) : Bb[e.type] ? function (e) { const t = [-1 / 0].concat(e); return t.max = 1 / 0, t }(e[Bb[e.type]]()) : Ob(e, t) } function Ub(e, t, n, r, i, a, o) { const s = Lb[t.type] && a !== Vy && a !== Gy ? function (e, t, n) { const r = t[Lb[t.type]](), i = r.length; let a, o = i > 1 ? r[1] - r[0] : r[0]; for (a = 1; a < i; ++a)o = Math.min(o, r[a] - r[a - 1]); return e.formatSpan(0, o, 30, n) }(e, t, i) : zb(e, t, n, i, a, o); return r === Ib && (e => Bb[e.type] || e.bins)(t) ? Wb(s) : "discrete" === r ? Gb(s) : Hb(s) } const Wb = e => (t, n, r) => { const i = Vb(r[n + 1], Vb(r.max, 1 / 0)), a = qb(t, e), o = qb(i, e); return a && o ? a + " – " + o : o ? "< " + o : "≥ " + a }, Vb = (e, t) => null != e ? e : t, Gb = e => (t, n) => n ? e(t) : null, Hb = e => t => e(t), qb = (e, t) => Number.isFinite(e) ? t(e) : null; function Yb(e, t, n, r) { const i = r || t.type; return Vn(n) && function (e) { return mb(e, ab) }(i) && (n = n.replace(/%a/g, "%A").replace(/%b/g, "%B")), n || i !== Vy ? n || i !== Gy ? Ub(e, t, 5, null, n, r, !0) : e.utcFormat("%A, %d %B %Y, %X UTC") : e.timeFormat("%A, %d %B %Y, %X") } function Xb(e, t, n) { n = n || {}; const r = Math.max(3, n.maxlen || 7), i = Yb(e, t, n.format, n.formatType); if (bb(t.type)) { const e = jb(t).slice(1).map(i), n = e.length; return `${n} boundar${1 === n ? "y" : "ies"}: ${e.join(", ")}` } if (yb(t.type)) { const e = t.domain(), n = e.length; return `${n} value${1 === n ? "" : "s"}: ${n > r ? e.slice(0, r - 2).map(i).join(", ") + ", ending with " + e.slice(-1).map(i) : e.map(i).join(", ")}` } { const e = t.domain(); return `values from ${i(e[0])} to ${i(hn(e))}` } } let Kb = 0; const Zb = "p_"; function Jb(e) { return e && e.gradient } function Qb(e, t, n) { const r = e.gradient; let i = e.id, a = "radial" === r ? Zb : ""; return i || (i = e.id = "gradient_" + Kb++, "radial" === r ? (e.x1 = ev(e.x1, .5), e.y1 = ev(e.y1, .5), e.r1 = ev(e.r1, 0), e.x2 = ev(e.x2, .5), e.y2 = ev(e.y2, .5), e.r2 = ev(e.r2, .5), a = Zb) : (e.x1 = ev(e.x1, 0), e.y1 = ev(e.y1, 0), e.x2 = ev(e.x2, 1), e.y2 = ev(e.y2, 0))), t[i] = e, "url(" + (n || "") + "#" + a + i + ")" } function ev(e, t) { return null != e ? e : t } const tv = { basis: { curve: uh }, "basis-closed": { curve: hh }, "basis-open": { curve: fh }, bundle: { curve: mh, tension: "beta", value: .85 }, cardinal: { curve: bh, tension: "tension", value: 0 }, "cardinal-open": { curve: xh, tension: "tension", value: 0 }, "cardinal-closed": { curve: kh, tension: "tension", value: 0 }, "catmull-rom": { curve: zh, tension: "alpha", value: .5 }, "catmull-rom-closed": { curve: Bh, tension: "alpha", value: .5 }, "catmull-rom-open": { curve: jh, tension: "alpha", value: .5 }, linear: { curve: Wh }, "linear-closed": { curve: Gh }, monotone: { horizontal: ed, vertical: Qh }, natural: { curve: rd }, step: { curve: ad }, "step-after": { curve: sd }, "step-before": { curve: od } }; function nv(e, t, n) { var r = zn(tv, e) && tv[e], i = null; return r && (i = r.curve || r[t || "vertical"], r.tension && null != n && (i = i[r.tension](n))), i } const rv = { m: 2, l: 2, h: 1, v: 1, z: 0, c: 6, s: 4, q: 4, t: 2, a: 7 }, iv = /[mlhvzcsqta]([^mlhvzcsqta]+|$)/gi, av = /^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/, ov = /^((\s+,?\s*)|(,\s*))/, sv = /^[01]/; function uv(e) { const t = []; return (e.match(iv) || []).forEach((e => { let n = e[0]; const r = n.toLowerCase(), i = rv[r], a = function (e, t, n) { const r = []; for (let i = 0; t && i < n.length;)for (let a = 0; a < t; ++a) { const t = "a" !== e || 3 !== a && 4 !== a ? av : sv, o = n.slice(i).match(t); if (null === o) throw Error("Invalid SVG path, incorrect parameter type"); i += o[0].length, r.push(+o[0]); const s = n.slice(i).match(ov); null !== s && (i += s[0].length) } return r }(r, i, e.slice(1).trim()), o = a.length; if (o < i || o && o % i != 0) throw Error("Invalid SVG path, incorrect parameter count"); if (t.push([n, ...a.slice(0, i)]), o !== i) { "m" === r && (n = "M" === n ? "L" : "l"); for (let e = i; e < o; e += i)t.push([n, ...a.slice(e, e + i)]) } })), t } const lv = Math.PI / 180, cv = Math.PI / 2, hv = 2 * Math.PI, dv = Math.sqrt(3) / 2; var fv = {}, pv = {}, mv = [].join; function gv(e) { const t = mv.call(e); if (pv[t]) return pv[t]; var n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], u = e[6], l = e[7]; const c = l * o, h = -u * s, d = u * o, f = l * s, p = Math.cos(i), m = Math.sin(i), g = Math.cos(a), y = Math.sin(a), b = .5 * (a - i), v = Math.sin(.5 * b), x = 8 / 3 * v * v / Math.sin(b), w = n + p - x * m, k = r + m + x * p, S = n + g, _ = r + y, C = S + x * y, A = _ - x * g; return pv[t] = [c * w + h * k, d * w + f * k, c * C + h * A, d * C + f * A, c * S + h * _, d * S + f * _] } const yv = ["l", 0, 0, 0, 0, 0, 0, 0]; function bv(e, t, n) { const r = yv[0] = e[0]; if ("a" === r || "A" === r) yv[1] = t * e[1], yv[2] = n * e[2], yv[3] = e[3], yv[4] = e[4], yv[5] = e[5], yv[6] = t * e[6], yv[7] = n * e[7]; else if ("h" === r || "H" === r) yv[1] = t * e[1]; else if ("v" === r || "V" === r) yv[1] = n * e[1]; else for (var i = 1, a = e.length; i < a; ++i)yv[i] = (i % 2 == 1 ? t : n) * e[i]; return yv } function vv(e, t, n, r, i, a) { var o, s, u, l, c, h = null, d = 0, f = 0, p = 0, m = 0, g = 0, y = 0; null == n && (n = 0), null == r && (r = 0), null == i && (i = 1), null == a && (a = i), e.beginPath && e.beginPath(); for (var b = 0, v = t.length; b < v; ++b) { switch (o = t[b], 1 === i && 1 === a || (o = bv(o, i, a)), o[0]) { case "l": d += o[1], f += o[2], e.lineTo(d + n, f + r); break; case "L": d = o[1], f = o[2], e.lineTo(d + n, f + r); break; case "h": d += o[1], e.lineTo(d + n, f + r); break; case "H": d = o[1], e.lineTo(d + n, f + r); break; case "v": f += o[1], e.lineTo(d + n, f + r); break; case "V": f = o[1], e.lineTo(d + n, f + r); break; case "m": g = d += o[1], y = f += o[2], e.moveTo(d + n, f + r); break; case "M": g = d = o[1], y = f = o[2], e.moveTo(d + n, f + r); break; case "c": s = d + o[5], u = f + o[6], p = d + o[3], m = f + o[4], e.bezierCurveTo(d + o[1] + n, f + o[2] + r, p + n, m + r, s + n, u + r), d = s, f = u; break; case "C": d = o[5], f = o[6], p = o[3], m = o[4], e.bezierCurveTo(o[1] + n, o[2] + r, p + n, m + r, d + n, f + r); break; case "s": s = d + o[3], u = f + o[4], p = 2 * d - p, m = 2 * f - m, e.bezierCurveTo(p + n, m + r, d + o[1] + n, f + o[2] + r, s + n, u + r), p = d + o[1], m = f + o[2], d = s, f = u; break; case "S": s = o[3], u = o[4], p = 2 * d - p, m = 2 * f - m, e.bezierCurveTo(p + n, m + r, o[1] + n, o[2] + r, s + n, u + r), d = s, f = u, p = o[1], m = o[2]; break; case "q": s = d + o[3], u = f + o[4], p = d + o[1], m = f + o[2], e.quadraticCurveTo(p + n, m + r, s + n, u + r), d = s, f = u; break; case "Q": s = o[3], u = o[4], e.quadraticCurveTo(o[1] + n, o[2] + r, s + n, u + r), d = s, f = u, p = o[1], m = o[2]; break; case "t": s = d + o[1], u = f + o[2], null === h[0].match(/[QqTt]/) ? (p = d, m = f) : "t" === h[0] ? (p = 2 * d - l, m = 2 * f - c) : "q" === h[0] && (p = 2 * d - p, m = 2 * f - m), l = p, c = m, e.quadraticCurveTo(p + n, m + r, s + n, u + r), f = u, p = (d = s) + o[1], m = f + o[2]; break; case "T": s = o[1], u = o[2], p = 2 * d - p, m = 2 * f - m, e.quadraticCurveTo(p + n, m + r, s + n, u + r), d = s, f = u; break; case "a": xv(e, d + n, f + r, [o[1], o[2], o[3], o[4], o[5], o[6] + d + n, o[7] + f + r]), d += o[6], f += o[7]; break; case "A": xv(e, d + n, f + r, [o[1], o[2], o[3], o[4], o[5], o[6] + n, o[7] + r]), d = o[6], f = o[7]; break; case "z": case "Z": d = g, f = y, e.closePath() }h = o } } function xv(e, t, n, r) { const i = function (e, t, n, r, i, a, o, s, u) { const l = mv.call(arguments); if (fv[l]) return fv[l]; const c = o * lv, h = Math.sin(c), d = Math.cos(c), f = d * (s - e) * .5 + h * (u - t) * .5, p = d * (u - t) * .5 - h * (s - e) * .5; let m = f * f / ((n = Math.abs(n)) * n) + p * p / ((r = Math.abs(r)) * r); m > 1 && (m = Math.sqrt(m), n *= m, r *= m); const g = d / n, y = h / n, b = -h / r, v = d / r, x = g * s + y * u, w = b * s + v * u, k = g * e + y * t, S = b * e + v * t; let _ = 1 / ((k - x) * (k - x) + (S - w) * (S - w)) - .25; _ < 0 && (_ = 0); let C = Math.sqrt(_); a == i && (C = -C); const A = .5 * (x + k) - C * (S - w), T = .5 * (w + S) + C * (k - x), E = Math.atan2(w - T, x - A); let N = Math.atan2(S - T, k - A) - E; N < 0 && 1 === a ? N += hv : N > 0 && 0 === a && (N -= hv); const I = Math.ceil(Math.abs(N / (cv + .001))), M = []; for (let e = 0; e < I; ++e) { const t = E + e * N / I, i = E + (e + 1) * N / I; M[e] = [A, T, t, i, n, r, h, d] } return fv[l] = M }(r[5], r[6], r[0], r[1], r[3], r[4], r[2], t, n); for (let t = 0; t < i.length; ++t) { const n = gv(i[t]); e.bezierCurveTo(n[0], n[1], n[2], n[3], n[4], n[5]) } } const wv = .5773502691896257, kv = { circle: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(n, 0), e.arc(0, 0, n, 0, hv) } }, cross: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = n / 2.5; e.moveTo(-n, -r), e.lineTo(-n, r), e.lineTo(-r, r), e.lineTo(-r, n), e.lineTo(r, n), e.lineTo(r, r), e.lineTo(n, r), e.lineTo(n, -r), e.lineTo(r, -r), e.lineTo(r, -n), e.lineTo(-r, -n), e.lineTo(-r, -r), e.closePath() } }, diamond: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(-n, 0), e.lineTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.closePath() } }, square: { draw: function (e, t) { var n = Math.sqrt(t), r = -n / 2; e.rect(r, r, n, n) } }, arrow: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = n / 7, i = n / 2.5, a = n / 8; e.moveTo(-r, n), e.lineTo(r, n), e.lineTo(r, -a), e.lineTo(i, -a), e.lineTo(0, -n), e.lineTo(-i, -a), e.lineTo(-r, -a), e.closePath() } }, wedge: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = dv * n, i = r - n * wv, a = n / 4; e.moveTo(0, -r - i), e.lineTo(-a, r - i), e.lineTo(a, r - i), e.closePath() } }, triangle: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = dv * n, i = r - n * wv; e.moveTo(0, -r - i), e.lineTo(-n, r - i), e.lineTo(n, r - i), e.closePath() } }, "triangle-up": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = dv * n; e.moveTo(0, -r), e.lineTo(-n, r), e.lineTo(n, r), e.closePath() } }, "triangle-down": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = dv * n; e.moveTo(0, r), e.lineTo(-n, -r), e.lineTo(n, -r), e.closePath() } }, "triangle-right": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = dv * n; e.moveTo(r, 0), e.lineTo(-r, -n), e.lineTo(-r, n), e.closePath() } }, "triangle-left": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = dv * n; e.moveTo(-r, 0), e.lineTo(r, -n), e.lineTo(r, n), e.closePath() } }, stroke: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(-n, 0), e.lineTo(n, 0) } } }; function Sv(e) { return zn(kv, e) ? kv[e] : function (e) { if (!zn(_v, e)) { const t = uv(e); _v[e] = { draw: function (e, n) { vv(e, t, 0, 0, Math.sqrt(n) / 2) } } } return _v[e] }(e) } var _v = {}; const Cv = .448084975506; function Av(e) { return e.x } function Tv(e) { return e.y } function Ev(e) { return e.width } function Nv(e) { return e.height } function Iv(e) { return "function" == typeof e ? e : () => +e } function Mv(e, t, n) { return Math.max(t, Math.min(e, n)) } function Fv(e, t) { return null != e ? e : t } const Dv = e => e.x || 0, $v = e => e.y || 0, Rv = e => !(!1 === e.defined), Ov = Sd().startAngle((e => e.startAngle || 0)).endAngle((e => e.endAngle || 0)).padAngle((e => e.padAngle || 0)).innerRadius((e => e.innerRadius || 0)).outerRadius((e => e.outerRadius || 0)).cornerRadius((e => e.cornerRadius || 0)), zv = Ed().x(Dv).y1($v).y0((e => (e.y || 0) + (e.height || 0))).defined(Rv), Pv = Ed().y($v).x1(Dv).x0((e => (e.x || 0) + (e.width || 0))).defined(Rv), Bv = Td().x(Dv).y($v).defined(Rv), Lv = function () { var e = Av, t = Tv, n = Ev, r = Nv, i = Iv(0), a = i, o = i, s = i, u = null; function l(l, c, h) { var d, f = null != c ? c : +e.call(this, l), p = null != h ? h : +t.call(this, l), m = +n.call(this, l), g = +r.call(this, l), y = Math.min(m, g) / 2, b = Mv(+i.call(this, l), 0, y), v = Mv(+a.call(this, l), 0, y), x = Mv(+o.call(this, l), 0, y), w = Mv(+s.call(this, l), 0, y); if (u || (u = d = md()), b <= 0 && v <= 0 && x <= 0 && w <= 0) u.rect(f, p, m, g); else { var k = f + m, S = p + g; u.moveTo(f + b, p), u.lineTo(k - v, p), u.bezierCurveTo(k - Cv * v, p, k, p + Cv * v, k, p + v), u.lineTo(k, S - w), u.bezierCurveTo(k, S - Cv * w, k - Cv * w, S, k - w, S), u.lineTo(f + x, S), u.bezierCurveTo(f + Cv * x, S, f, S - Cv * x, f, S - x), u.lineTo(f, p + b), u.bezierCurveTo(f, p + Cv * b, f + Cv * b, p, f + b, p), u.closePath() } if (d) return u = null, d + "" || null } return l.x = function (t) { return arguments.length ? (e = Iv(t), l) : e }, l.y = function (e) { return arguments.length ? (t = Iv(e), l) : t }, l.width = function (e) { return arguments.length ? (n = Iv(e), l) : n }, l.height = function (e) { return arguments.length ? (r = Iv(e), l) : r }, l.cornerRadius = function (e, t, n, r) { return arguments.length ? (i = Iv(e), a = null != t ? Iv(t) : i, s = null != n ? Iv(n) : i, o = null != r ? Iv(r) : a, l) : i }, l.context = function (e) { return arguments.length ? (u = null == e ? null : e, l) : u }, l }().x(Dv).y($v).width((e => e.width || 0)).height((e => e.height || 0)).cornerRadius((e => Fv(e.cornerRadiusTopLeft, e.cornerRadius) || 0), (e => Fv(e.cornerRadiusTopRight, e.cornerRadius) || 0), (e => Fv(e.cornerRadiusBottomRight, e.cornerRadius) || 0), (e => Fv(e.cornerRadiusBottomLeft, e.cornerRadius) || 0)), jv = Md().type((e => Sv(e.shape || "circle"))).size((e => Fv(e.size, 64))), Uv = function () { var e, t, n, r, i, a, o, s, u = null; function l(e, t, n) { const r = n / 2; if (i) { var l = o - t, c = e - a; if (l || c) { var h = Math.hypot(l, c), d = (l /= h) * s, f = (c /= h) * s, p = Math.atan2(c, l); u.moveTo(a - d, o - f), u.lineTo(e - l * r, t - c * r), u.arc(e, t, r, p - Math.PI, p), u.lineTo(a + d, o + f), u.arc(a, o, s, p, p + Math.PI) } else u.arc(e, t, r, 0, hv); u.closePath() } else i = 1; a = e, o = t, s = r } function c(a) { var o, s, c, h = a.length, d = !1; for (null == u && (u = c = md()), o = 0; o <= h; ++o)!(o < h && r(s = a[o], o, a)) === d && (d = !d) && (i = 0), d && l(+e(s, o, a), +t(s, o, a), +n(s, o, a)); if (c) return u = null, c + "" || null } return c.x = function (t) { return arguments.length ? (e = t, c) : e }, c.y = function (e) { return arguments.length ? (t = e, c) : t }, c.size = function (e) { return arguments.length ? (n = e, c) : n }, c.defined = function (e) { return arguments.length ? (r = e, c) : r }, c.context = function (e) { return arguments.length ? (u = null == e ? null : e, c) : u }, c }().x(Dv).y($v).defined(Rv).size((e => e.size || 1)); function Wv(e) { return e.cornerRadius || e.cornerRadiusTopLeft || e.cornerRadiusTopRight || e.cornerRadiusBottomRight || e.cornerRadiusBottomLeft } function Vv(e, t, n, r) { return Lv.context(e)(t, n, r) } var Gv = 1; function Hv(e, t, n) { var r = t.clip, i = e._defs, a = t.clip_id || (t.clip_id = "clip" + Gv++), o = i.clipping[a] || (i.clipping[a] = { id: a }); return Cn(r) ? o.path = r(null) : Wv(n) ? o.path = Vv(null, n, 0, 0) : (o.width = n.width || 0, o.height = n.height || 0), "url(#" + a + ")" } function qv(e) { this.clear(), e && this.union(e) } function Yv(e) { this.mark = e, this.bounds = this.bounds || new qv } function Xv(e) { Yv.call(this, e), this.items = this.items || [] } qv.prototype = { clone() { return new qv(this) }, clear() { return this.x1 = +Number.MAX_VALUE, this.y1 = +Number.MAX_VALUE, this.x2 = -Number.MAX_VALUE, this.y2 = -Number.MAX_VALUE, this }, empty() { return this.x1 === +Number.MAX_VALUE && this.y1 === +Number.MAX_VALUE && this.x2 === -Number.MAX_VALUE && this.y2 === -Number.MAX_VALUE }, equals(e) { return this.x1 === e.x1 && this.y1 === e.y1 && this.x2 === e.x2 && this.y2 === e.y2 }, set(e, t, n, r) { return n < e ? (this.x2 = e, this.x1 = n) : (this.x1 = e, this.x2 = n), r < t ? (this.y2 = t, this.y1 = r) : (this.y1 = t, this.y2 = r), this }, add(e, t) { return e < this.x1 && (this.x1 = e), t < this.y1 && (this.y1 = t), e > this.x2 && (this.x2 = e), t > this.y2 && (this.y2 = t), this }, expand(e) { return this.x1 -= e, this.y1 -= e, this.x2 += e, this.y2 += e, this }, round() { return this.x1 = Math.floor(this.x1), this.y1 = Math.floor(this.y1), this.x2 = Math.ceil(this.x2), this.y2 = Math.ceil(this.y2), this }, scale(e) { return this.x1 *= e, this.y1 *= e, this.x2 *= e, this.y2 *= e, this }, translate(e, t) { return this.x1 += e, this.x2 += e, this.y1 += t, this.y2 += t, this }, rotate(e, t, n) { const r = this.rotatedPoints(e, t, n); return this.clear().add(r[0], r[1]).add(r[2], r[3]).add(r[4], r[5]).add(r[6], r[7]) }, rotatedPoints(e, t, n) { var { x1: r, y1: i, x2: a, y2: o } = this, s = Math.cos(e), u = Math.sin(e), l = t - t * s + n * u, c = n - t * u - n * s; return [s * r - u * i + l, u * r + s * i + c, s * r - u * o + l, u * r + s * o + c, s * a - u * i + l, u * a + s * i + c, s * a - u * o + l, u * a + s * o + c] }, union(e) { return e.x1 < this.x1 && (this.x1 = e.x1), e.y1 < this.y1 && (this.y1 = e.y1), e.x2 > this.x2 && (this.x2 = e.x2), e.y2 > this.y2 && (this.y2 = e.y2), this }, intersect(e) { return e.x1 > this.x1 && (this.x1 = e.x1), e.y1 > this.y1 && (this.y1 = e.y1), e.x2 < this.x2 && (this.x2 = e.x2), e.y2 < this.y2 && (this.y2 = e.y2), this }, encloses(e) { return e && this.x1 <= e.x1 && this.x2 >= e.x2 && this.y1 <= e.y1 && this.y2 >= e.y2 }, alignsWith(e) { return e && (this.x1 == e.x1 || this.x2 == e.x2 || this.y1 == e.y1 || this.y2 == e.y2) }, intersects(e) { return e && !(this.x2 < e.x1 || this.x1 > e.x2 || this.y2 < e.y1 || this.y1 > e.y2) }, contains(e, t) { return !(e < this.x1 || e > this.x2 || t < this.y1 || t > this.y2) }, width() { return this.x2 - this.x1 }, height() { return this.y2 - this.y1 } }, Ln(Xv, Yv); class Kv { constructor(e) { this._pending = 0, this._loader = e || Ws() } pending() { return this._pending } sanitizeURL(e) { const t = this; return Zv(t), t._loader.sanitize(e, { context: "href" }).then((e => (Jv(t), e))).catch((() => (Jv(t), null))) } loadImage(e) { const t = this, n = Dd(); return Zv(t), t._loader.sanitize(e, { context: "image" }).then((e => { const r = e.href; if (!r || !n) throw { url: r }; const i = new n, a = zn(e, "crossOrigin") ? e.crossOrigin : "anonymous"; return null != a && (i.crossOrigin = a), i.onload = () => Jv(t), i.onerror = () => Jv(t), i.src = r, i })).catch((e => (Jv(t), { complete: !1, width: 0, height: 0, src: e && e.url || "" }))) } ready() { const e = this; return new Promise((t => { !function n(r) { e.pending() ? setTimeout((() => { n(!0) }), 10) : t(r) }(!1) })) } } function Zv(e) { e._pending += 1 } function Jv(e) { e._pending -= 1 } function Qv(e, t, n) { if (t.stroke && 0 !== t.opacity && 0 !== t.strokeOpacity) { const r = null != t.strokeWidth ? +t.strokeWidth : 1; e.expand(r + (n ? function (e, t) { return e.strokeJoin && "miter" !== e.strokeJoin ? 0 : t }(t, r) : 0)) } return e } const ex = hv - 1e-8; let tx, nx, rx, ix, ax, ox, sx, ux; const lx = (e, t) => tx.add(e, t), cx = (e, t) => lx(nx = e, rx = t), hx = e => lx(e, tx.y1), dx = e => lx(tx.x1, e), fx = (e, t) => ax * e + sx * t, px = (e, t) => ox * e + ux * t, mx = (e, t) => lx(fx(e, t), px(e, t)), gx = (e, t) => cx(fx(e, t), px(e, t)); function yx(e, t) { return tx = e, t ? (ix = t * lv, ax = ux = Math.cos(ix), ox = Math.sin(ix), sx = -ox) : (ax = ux = 1, ix = ox = sx = 0), bx } const bx = { beginPath() { }, closePath() { }, moveTo: gx, lineTo: gx, rect(e, t, n, r) { ix ? (mx(e + n, t), mx(e + n, t + r), mx(e, t + r), gx(e, t)) : (lx(e + n, t + r), cx(e, t)) }, quadraticCurveTo(e, t, n, r) { const i = fx(e, t), a = px(e, t), o = fx(n, r), s = px(n, r); vx(nx, i, o, hx), vx(rx, a, s, dx), cx(o, s) }, bezierCurveTo(e, t, n, r, i, a) { const o = fx(e, t), s = px(e, t), u = fx(n, r), l = px(n, r), c = fx(i, a), h = px(i, a); xx(nx, o, u, c, hx), xx(rx, s, l, h, dx), cx(c, h) }, arc(e, t, n, r, i, a) { if (r += ix, i += ix, nx = n * Math.cos(i) + e, rx = n * Math.sin(i) + t, Math.abs(i - r) > ex) lx(e - n, t - n), lx(e + n, t + n); else { const o = r => lx(n * Math.cos(r) + e, n * Math.sin(r) + t); let s, u; if (o(r), o(i), i !== r) if ((r %= hv) < 0 && (r += hv), (i %= hv) < 0 && (i += hv), i < r && (a = !a, s = r, r = i, i = s), a) for (i -= hv, s = r - r % cv, u = 0; u < 4 && s > i; ++u, s -= cv)o(s); else for (s = r - r % cv + cv, u = 0; u < 4 && s < i; ++u, s += cv)o(s) } } }; function vx(e, t, n, r) { const i = (e - t) / (e + n - 2 * t); 0 < i && i < 1 && r(e + (t - e) * i) } function xx(e, t, n, r, i) { const a = r - e + 3 * t - 3 * n, o = e + n - 2 * t, s = e - t; let u, l = 0, c = 0; Math.abs(a) > 1e-14 ? (u = o * o + s * a, u >= 0 && (u = Math.sqrt(u), l = (-o + u) / a, c = (-o - u) / a)) : l = .5 * s / o, 0 < l && l < 1 && i(wx(l, e, t, n, r)), 0 < c && c < 1 && i(wx(c, e, t, n, r)) } function wx(e, t, n, r, i) { const a = 1 - e, o = a * a, s = e * e; return o * a * t + 3 * o * e * n + 3 * a * s * r + s * e * i } var kx = (kx = Fd(1, 1)) ? kx.getContext("2d") : null; const Sx = new qv; function _x(e) { return function (t, n) { if (!kx) return !0; e(kx, t), Sx.clear().union(t.bounds).intersect(n).round(); const { x1: r, y1: i, x2: a, y2: o } = Sx; for (let e = i; e <= o; ++e)for (let t = r; t <= a; ++t)if (kx.isPointInPath(t, e)) return !0; return !1 } } function Cx(e, t) { return t.contains(e.x || 0, e.y || 0) } function Ax(e, t) { const n = e.x || 0, r = e.y || 0, i = e.width || 0, a = e.height || 0; return t.intersects(Sx.set(n, r, n + i, r + a)) } function Tx(e, t, n, r, i) { const { x1: a, y1: o, x2: s, y2: u } = e, l = r - t, c = i - n; let h, d, f, p, m = 0, g = 1; for (p = 0; p < 4; ++p) { if (0 === p && (h = -l, d = -(a - t)), 1 === p && (h = l, d = s - t), 2 === p && (h = -c, d = -(o - n)), 3 === p && (h = c, d = u - n), Math.abs(h) < 1e-10 && d < 0) return !1; if (f = d / h, h < 0) { if (f > g) return !1; f > m && (m = f) } else if (h > 0) { if (f < m) return !1; f < g && (g = f) } } return !0 } function Ex(e, t) { e.globalCompositeOperation = t.blend || "source-over" } function Nx(e, t) { return null == e ? t : e } function Ix(e, t) { const n = t.length; for (let r = 0; r < n; ++r)e.addColorStop(t[r].offset, t[r].color); return e } function Mx(e, t, n) { return Jb(n) ? function (e, t, n) { const r = n.width(), i = n.height(); let a; if ("radial" === t.gradient) a = e.createRadialGradient(n.x1 + Nx(t.x1, .5) * r, n.y1 + Nx(t.y1, .5) * i, Math.max(r, i) * Nx(t.r1, 0), n.x1 + Nx(t.x2, .5) * r, n.y1 + Nx(t.y2, .5) * i, Math.max(r, i) * Nx(t.r2, .5)); else { const o = Nx(t.x1, 0), s = Nx(t.y1, 0), u = Nx(t.x2, 1), l = Nx(t.y2, 0); if (o !== u && s !== l && r !== i) { const n = Fd(Math.ceil(r), Math.ceil(i)), a = n.getContext("2d"); return a.scale(r, i), a.fillStyle = Ix(a.createLinearGradient(o, s, u, l), t.stops), a.fillRect(0, 0, r, i), e.createPattern(n, "no-repeat") } a = e.createLinearGradient(n.x1 + o * r, n.y1 + s * i, n.x1 + u * r, n.y1 + l * i) } return Ix(a, t.stops) }(e, n, t.bounds) : n } function Fx(e, t, n) { return (n *= null == t.fillOpacity ? 1 : t.fillOpacity) > 0 && (e.globalAlpha = n, e.fillStyle = Mx(e, t, t.fill), !0) } var Dx = []; function $x(e, t, n) { var r = null != (r = t.strokeWidth) ? r : 1; return !(r <= 0) && ((n *= null == t.strokeOpacity ? 1 : t.strokeOpacity) > 0 && (e.globalAlpha = n, e.strokeStyle = Mx(e, t, t.stroke), e.lineWidth = r, e.lineCap = t.strokeCap || "butt", e.lineJoin = t.strokeJoin || "miter", e.miterLimit = t.strokeMiterLimit || 10, e.setLineDash && (e.setLineDash(t.strokeDash || Dx), e.lineDashOffset = t.strokeDashOffset || 0), !0)) } function Rx(e, t) { return e.zindex - t.zindex || e.index - t.index } function Ox(e) { if (!e.zdirty) return e.zitems; var t, n, r, i = e.items, a = []; for (n = 0, r = i.length; n < r; ++n)(t = i[n]).index = n, t.zindex && a.push(t); return e.zdirty = !1, e.zitems = a.sort(Rx) } function zx(e, t) { var n, r, i = e.items; if (!i || !i.length) return; const a = Ox(e); if (a && a.length) { for (n = 0, r = i.length; n < r; ++n)i[n].zindex || t(i[n]); i = a } for (n = 0, r = i.length; n < r; ++n)t(i[n]) } function Px(e, t) { var n, r, i = e.items; if (!i || !i.length) return null; const a = Ox(e); for (a && a.length && (i = a), r = i.length; --r >= 0;)if (n = t(i[r])) return n; if (i === a) for (r = (i = e.items).length; --r >= 0;)if (!i[r].zindex && (n = t(i[r]))) return n; return null } function Bx(e) { return function (t, n, r) { zx(n, (n => { r && !r.intersects(n.bounds) || jx(e, t, n, n) })) } } function Lx(e) { return function (t, n, r) { !n.items.length || r && !r.intersects(n.bounds) || jx(e, t, n.items[0], n.items) } } function jx(e, t, n, r) { var i = null == n.opacity ? 1 : n.opacity; 0 !== i && (e(t, r) || (Ex(t, n), n.fill && Fx(t, n, i) && t.fill(), n.stroke && $x(t, n, i) && t.stroke())) } function Ux(e) { return e = e || Zt, function (t, n, r, i, a, o) { return r *= t.pixelRatio, i *= t.pixelRatio, Px(n, (n => { const s = n.bounds; if ((!s || s.contains(a, o)) && s) return e(t, n, r, i, a, o) ? n : void 0 })) } } function Wx(e, t) { return function (n, r, i, a) { var o, s, u = Array.isArray(r) ? r[0] : r, l = null == t ? u.fill : t, c = u.stroke && n.isPointInStroke; return c && (o = u.strokeWidth, s = u.strokeCap, n.lineWidth = null != o ? o : 1, n.lineCap = null != s ? s : "butt"), !e(n, r) && (l && n.isPointInPath(i, a) || c && n.isPointInStroke(i, a)) } } function Vx(e) { return Ux(Wx(e)) } function Gx(e, t) { return "translate(" + e + "," + t + ")" } function Hx(e) { return "rotate(" + e + ")" } function qx(e) { return Gx(e.x || 0, e.y || 0) } function Yx(e, t, n) { function r(e, n) { var r = n.x || 0, i = n.y || 0, a = n.angle || 0; e.translate(r, i), a && e.rotate(a *= lv), e.beginPath(), t(e, n), a && e.rotate(-a), e.translate(-r, -i) } return { type: e, tag: "path", nested: !1, attr: function (e, n) { e("transform", function (e) { return Gx(e.x || 0, e.y || 0) + (e.angle ? " " + Hx(e.angle) : "") }(n)), e("d", t(null, n)) }, bound: function (e, n) { return t(yx(e, n.angle), n), Qv(e, n).translate(n.x || 0, n.y || 0) }, draw: Bx(r), pick: Vx(r), isect: n || _x(r) } } var Xx = Yx("arc", (function (e, t) { return Ov.context(e)(t) })); function Kx(e, t, n) { function r(e, n) { e.beginPath(), t(e, n) } const i = Wx(r); return { type: e, tag: "path", nested: !0, attr: function (e, n) { var r = n.mark.items; r.length && e("d", t(null, r)) }, bound: function (e, n) { var r = n.items; return 0 === r.length ? e : (t(yx(e), r), Qv(e, r[0])) }, draw: Lx(r), pick: function (e, t, n, r, a, o) { var s = t.items, u = t.bounds; return !s || !s.length || u && !u.contains(a, o) ? null : (n *= e.pixelRatio, r *= e.pixelRatio, i(e, s, n, r) ? s[0] : null) }, isect: Cx, tip: n } } var Zx = Kx("area", (function (e, t) { const n = t[0], r = n.interpolate || "linear"; return ("horizontal" === n.orient ? Pv : zv).curve(nv(r, n.orient, n.tension)).context(e)(t) }), (function (e, t) { for (var n, r, i = "horizontal" === e[0].orient ? t[1] : t[0], a = "horizontal" === e[0].orient ? "y" : "x", o = e.length, s = 1 / 0; --o >= 0;)!1 !== e[o].defined && (r = Math.abs(e[o][a] - i)) < s && (s = r, n = e[o]); return n })); function Jx(e, t) { e.beginPath(), Wv(t) ? Vv(e, t, 0, 0) : e.rect(0, 0, t.width || 0, t.height || 0), e.clip() } function Qx(e) { const t = Nx(e.strokeWidth, 1); return null != e.strokeOffset ? e.strokeOffset : e.stroke && t > .5 && t < 1.5 ? .5 - Math.abs(t - 1) : 0 } function ew(e, t) { const n = Qx(t); e("d", Vv(null, t, n, n)) } function tw(e, t, n, r) { const i = Qx(t); e.beginPath(), Vv(e, t, (n || 0) + i, (r || 0) + i) } const nw = Wx(tw), rw = Wx(tw, !1), iw = Wx(tw, !0); var aw = { type: "group", tag: "g", nested: !1, attr: function (e, t) { e("transform", qx(t)) }, bound: function (e, t) { if (!t.clip && t.items) { const n = t.items, r = n.length; for (let t = 0; t < r; ++t)e.union(n[t].bounds) } return (t.clip || t.width || t.height) && !t.noBound && e.add(0, 0).add(t.width || 0, t.height || 0), Qv(e, t), e.translate(t.x || 0, t.y || 0) }, draw: function (e, t, n, r) { zx(t, (t => { const i = t.x || 0, a = t.y || 0, o = t.strokeForeground, s = null == t.opacity ? 1 : t.opacity; (t.stroke || t.fill) && s && (tw(e, t, i, a), Ex(e, t), t.fill && Fx(e, t, s) && e.fill(), t.stroke && !o && $x(e, t, s) && e.stroke()), e.save(), e.translate(i, a), t.clip && Jx(e, t), n && n.translate(-i, -a), zx(t, (t => { ("group" === t.marktype || null == r || r.includes(t.marktype)) && this.draw(e, t, n, r) })), n && n.translate(i, a), e.restore(), o && t.stroke && s && (tw(e, t, i, a), Ex(e, t), $x(e, t, s) && e.stroke()) })) }, pick: function (e, t, n, r, i, a) { if (t.bounds && !t.bounds.contains(i, a) || !t.items) return null; const o = n * e.pixelRatio, s = r * e.pixelRatio; return Px(t, (u => { let l, c, h; const d = u.bounds; if (d && !d.contains(i, a)) return; c = u.x || 0, h = u.y || 0; const f = c + (u.width || 0), p = h + (u.height || 0), m = u.clip; if (m && (i < c || i > f || a < h || a > p)) return; if (e.save(), e.translate(c, h), c = i - c, h = a - h, m && Wv(u) && !iw(e, u, o, s)) return e.restore(), null; const g = u.strokeForeground, y = !1 !== t.interactive; return y && g && u.stroke && rw(e, u, o, s) ? (e.restore(), u) : (l = Px(u, (e => function (e, t, n) { return (!1 !== e.interactive || "group" === e.marktype) && e.bounds && e.bounds.contains(t, n) }(e, c, h) ? this.pick(e, n, r, c, h) : null)), !l && y && (u.fill || !g && u.stroke) && nw(e, u, o, s) && (l = u), e.restore(), l || null) })) }, isect: Ax, content: function (e, t, n) { e("clip-path", t.clip ? Hv(n, t, t) : null) }, background: function (e, t) { e("class", "background"), e("aria-hidden", !0), ew(e, t) }, foreground: function (e, t) { e("class", "foreground"), e("aria-hidden", !0), t.strokeForeground ? ew(e, t) : e("d", "") } }, ow = { xmlns: "http://www.w3.org/2000/svg", "xmlns:xlink": "http://www.w3.org/1999/xlink", version: "1.1" }; function sw(e, t) { var n = e.image; return (!n || e.url && e.url !== n.url) && (n = { complete: !1, width: 0, height: 0 }, t.loadImage(e.url).then((t => { e.image = t, e.image.url = e.url }))), n } function uw(e, t) { return null != e.width ? e.width : t && t.width ? !1 !== e.aspect && e.height ? e.height * t.width / t.height : t.width : 0 } function lw(e, t) { return null != e.height ? e.height : t && t.height ? !1 !== e.aspect && e.width ? e.width * t.height / t.width : t.height : 0 } function cw(e, t) { return "center" === e ? t / 2 : "right" === e ? t : 0 } function hw(e, t) { return "middle" === e ? t / 2 : "bottom" === e ? t : 0 } var dw = { type: "image", tag: "image", nested: !1, attr: function (e, t, n) { const r = sw(t, n), i = uw(t, r), a = lw(t, r), o = (t.x || 0) - cw(t.align, i), s = (t.y || 0) - hw(t.baseline, a); e("href", !r.src && r.toDataURL ? r.toDataURL() : r.src || "", ow["xmlns:xlink"], "xlink:href"), e("transform", Gx(o, s)), e("width", i), e("height", a), e("preserveAspectRatio", !1 === t.aspect ? "none" : "xMidYMid") }, bound: function (e, t) { const n = t.image, r = uw(t, n), i = lw(t, n), a = (t.x || 0) - cw(t.align, r), o = (t.y || 0) - hw(t.baseline, i); return e.set(a, o, a + r, o + i) }, draw: function (e, t, n) { zx(t, (t => { if (n && !n.intersects(t.bounds)) return; const r = sw(t, this); let i = uw(t, r), a = lw(t, r); if (0 === i || 0 === a) return; let o, s, u, l, c = (t.x || 0) - cw(t.align, i), h = (t.y || 0) - hw(t.baseline, a); !1 !== t.aspect && (s = r.width / r.height, u = t.width / t.height, s == s && u == u && s !== u && (u < s ? (l = i / s, h += (a - l) / 2, a = l) : (l = a * s, c += (i - l) / 2, i = l))), (r.complete || r.toDataURL) && (Ex(e, t), e.globalAlpha = null != (o = t.opacity) ? o : 1, e.imageSmoothingEnabled = !1 !== t.smooth, e.drawImage(r, c, h, i, a)) })) }, pick: Ux(), isect: Zt, get: sw, xOffset: cw, yOffset: hw }, fw = Kx("line", (function (e, t) { const n = t[0], r = n.interpolate || "linear"; return Bv.curve(nv(r, n.orient, n.tension)).context(e)(t) }), (function (e, t) { for (var n, r, i = Math.pow(e[0].strokeWidth || 1, 2), a = e.length; --a >= 0;)if (!1 !== e[a].defined && (n = e[a].x - t[0]) * n + (r = e[a].y - t[1]) * r < i) return e[a]; return null })); function pw(e, t) { var n = t.path; if (null == n) return !0; var r = t.x || 0, i = t.y || 0, a = t.scaleX || 1, o = t.scaleY || 1, s = (t.angle || 0) * lv, u = t.pathCache; u && u.path === n || ((t.pathCache = u = uv(n)).path = n), s && e.rotate && e.translate ? (e.translate(r, i), e.rotate(s), vv(e, u, 0, 0, a, o), e.rotate(-s), e.translate(-r, -i)) : vv(e, u, r, i, a, o) } var mw = { type: "path", tag: "path", nested: !1, attr: function (e, t) { var n = t.scaleX || 1, r = t.scaleY || 1; 1 === n && 1 === r || e("vector-effect", "non-scaling-stroke"), e("transform", function (e) { return Gx(e.x || 0, e.y || 0) + (e.angle ? " " + Hx(e.angle) : "") + (e.scaleX || e.scaleY ? " " + function (e, t) { return "scale(" + e + "," + t + ")" }(e.scaleX || 1, e.scaleY || 1) : "") }(t)), e("d", t.path) }, bound: function (e, t) { return pw(yx(e, t.angle), t) ? e.set(0, 0, 0, 0) : Qv(e, t, !0) }, draw: Bx(pw), pick: Vx(pw), isect: _x(pw) }; function gw(e, t) { e.beginPath(), Vv(e, t) } var yw = { type: "rect", tag: "path", nested: !1, attr: function (e, t) { e("d", Vv(null, t)) }, bound: function (e, t) { var n, r; return Qv(e.set(n = t.x || 0, r = t.y || 0, n + t.width || 0, r + t.height || 0), t) }, draw: Bx(gw), pick: Vx(gw), isect: Ax }; function bw(e, t, n) { var r, i, a, o; return !(!t.stroke || !$x(e, t, n)) && (r = t.x || 0, i = t.y || 0, a = null != t.x2 ? t.x2 : r, o = null != t.y2 ? t.y2 : i, e.beginPath(), e.moveTo(r, i), e.lineTo(a, o), !0) } var vw = { type: "rule", tag: "line", nested: !1, attr: function (e, t) { e("transform", qx(t)), e("x2", null != t.x2 ? t.x2 - (t.x || 0) : 0), e("y2", null != t.y2 ? t.y2 - (t.y || 0) : 0) }, bound: function (e, t) { var n, r; return Qv(e.set(n = t.x || 0, r = t.y || 0, null != t.x2 ? t.x2 : n, null != t.y2 ? t.y2 : r), t) }, draw: function (e, t, n) { zx(t, (t => { if (!n || n.intersects(t.bounds)) { var r = null == t.opacity ? 1 : t.opacity; r && bw(e, t, r) && (Ex(e, t), e.stroke()) } })) }, pick: Ux((function (e, t, n, r) { return !!e.isPointInStroke && (bw(e, t, 1) && e.isPointInStroke(n, r)) })), isect: function (e, t) { const n = e.x || 0, r = e.y || 0; return Tx(t, n, r, null != e.x2 ? e.x2 : n, null != e.y2 ? e.y2 : r) } }, xw = Yx("shape", (function (e, t) { return (t.mark.shape || t.shape).context(e)(t) })), ww = Yx("symbol", (function (e, t) { return jv.context(e)(t) }), Cx); const kw = function (e) { let t, n, r; e = +e || 1e4; const i = () => { t = {}, n = {}, r = 0 }, a = (i, a) => (++r > e && (n = t, t = {}, r = 1), t[i] = a); return i(), { clear: i, has: e => zn(t, e) || zn(n, e), get: e => zn(t, e) ? t[e] : zn(n, e) ? a(e, n[e]) : void 0, set: (e, n) => zn(t, e) ? t[e] = n : a(e, n) } }(); var Sw = { height: Nw, measureWidth: Tw, estimateWidth: Cw, width: Cw, canvas: _w }; function _w(e) { Sw.width = e && kx ? Tw : Cw } function Cw(e, t) { return Aw(Dw(e, t), Nw(e)) } function Aw(e, t) { return ~~(.8 * e.length * t) } function Tw(e, t) { return Nw(e) <= 0 || !(t = Dw(e, t)) ? 0 : Ew(t, Rw(e)) } function Ew(e, t) { const n = `(${t}) ${e}`; let r = kw.get(n); return void 0 === r && (kx.font = t, r = kx.measureText(e).width, kw.set(n, r)), r } function Nw(e) { return null != e.fontSize ? +e.fontSize || 0 : 11 } function Iw(e) { return null != e.lineHeight ? e.lineHeight : Nw(e) + 2 } function Mw(e) { return t = e.lineBreak && e.text && !on(e.text) ? e.text.split(e.lineBreak) : e.text, on(t) ? t.length > 1 ? t : t[0] : t; var t } function Fw(e) { const t = Mw(e); return (on(t) ? t.length - 1 : 0) * Iw(e) } function Dw(e, t) { const n = null == t ? "" : (t + "").trim(); return e.limit > 0 && n.length ? function (e, t) { var n = +e.limit, r = function (e) { if (Sw.width === Tw) { const t = Rw(e); return e => Ew(e, t) } if (Sw.width === Cw) { const t = Nw(e); return e => Aw(e, t) } return t => Sw.width(e, t) }(e); if (r(t) < n) return t; var i, a = e.ellipsis || "…", o = "rtl" === e.dir, s = 0, u = t.length; if (n -= r(a), o) { for (; s < u;)i = s + u >>> 1, r(t.slice(i)) > n ? s = i + 1 : u = i; return a + t.slice(s) } for (; s < u;)i = 1 + (s + u >>> 1), r(t.slice(0, i)) < n ? s = i : u = i - 1; return t.slice(0, s) + a }(e, n) : n } function $w(e, t) { var n = e.font; return (t && n ? String(n).replace(/"/g, "'") : n) || "sans-serif" } function Rw(e, t) { return (e.fontStyle ? e.fontStyle + " " : "") + (e.fontVariant ? e.fontVariant + " " : "") + (e.fontWeight ? e.fontWeight + " " : "") + Nw(e) + "px " + $w(e, t) } function Ow(e) { var t = e.baseline, n = Nw(e); return Math.round("top" === t ? .79 * n : "middle" === t ? .3 * n : "bottom" === t ? -.21 * n : "line-top" === t ? .29 * n + .5 * Iw(e) : "line-bottom" === t ? .29 * n - .5 * Iw(e) : 0) } _w(!0); const zw = { left: "start", center: "middle", right: "end" }, Pw = new qv; function Bw(e) { var t, n = e.x || 0, r = e.y || 0, i = e.radius || 0; return i && (t = (e.theta || 0) - cv, n += i * Math.cos(t), r += i * Math.sin(t)), Pw.x1 = n, Pw.y1 = r, Pw } function Lw(e, t, n) { var r, i = Sw.height(t), a = t.align, o = Bw(t), s = o.x1, u = o.y1, l = t.dx || 0, c = (t.dy || 0) + Ow(t) - Math.round(.8 * i), h = Mw(t); if (on(h) ? (i += Iw(t) * (h.length - 1), r = h.reduce(((e, n) => Math.max(e, Sw.width(t, n))), 0)) : r = Sw.width(t, h), "center" === a ? l -= r / 2 : "right" === a && (l -= r), e.set(l += s, c += u, l + r, c + i), t.angle && !n) e.rotate(t.angle * lv, s, u); else if (2 === n) return e.rotatedPoints(t.angle * lv, s, u); return e } var jw = { type: "text", tag: "text", nested: !1, attr: function (e, t) { var n, r = t.dx || 0, i = (t.dy || 0) + Ow(t), a = Bw(t), o = a.x1, s = a.y1, u = t.angle || 0; e("text-anchor", zw[t.align] || "start"), u ? (n = Gx(o, s) + " " + Hx(u), (r || i) && (n += " " + Gx(r, i))) : n = Gx(o + r, s + i), e("transform", n) }, bound: Lw, draw: function (e, t, n) { zx(t, (t => { var r, i, a, o, s, u, l, c = null == t.opacity ? 1 : t.opacity; if (!(n && !n.intersects(t.bounds) || 0 === c || t.fontSize <= 0 || null == t.text || 0 === t.text.length)) { if (e.font = Rw(t), e.textAlign = t.align || "left", i = (r = Bw(t)).x1, a = r.y1, t.angle && (e.save(), e.translate(i, a), e.rotate(t.angle * lv), i = a = 0), i += t.dx || 0, a += (t.dy || 0) + Ow(t), u = Mw(t), Ex(e, t), on(u)) for (s = Iw(t), o = 0; o < u.length; ++o)l = Dw(t, u[o]), t.fill && Fx(e, t, c) && e.fillText(l, i, a), t.stroke && $x(e, t, c) && e.strokeText(l, i, a), a += s; else l = Dw(t, u), t.fill && Fx(e, t, c) && e.fillText(l, i, a), t.stroke && $x(e, t, c) && e.strokeText(l, i, a); t.angle && e.restore() } })) }, pick: Ux((function (e, t, n, r, i, a) { if (t.fontSize <= 0) return !1; if (!t.angle) return !0; var o = Bw(t), s = o.x1, u = o.y1, l = Lw(Pw, t, 1), c = -t.angle * lv, h = Math.cos(c), d = Math.sin(c), f = h * i - d * a + (s - h * s + d * u), p = d * i + h * a + (u - d * s - h * u); return l.contains(f, p) })), isect: function (e, t) { const n = Lw(Pw, e, 2); return Tx(t, n[0], n[1], n[2], n[3]) || Tx(t, n[0], n[1], n[4], n[5]) || Tx(t, n[4], n[5], n[6], n[7]) || Tx(t, n[2], n[3], n[6], n[7]) } }, Uw = Kx("trail", (function (e, t) { return Uv.context(e)(t) }), (function (e, t) { for (var n, r, i = e.length; --i >= 0;)if (!1 !== e[i].defined && (n = e[i].x - t[0]) * n + (r = e[i].y - t[1]) * r < (n = e[i].size || 1) * n) return e[i]; return null })), Ww = { arc: Xx, area: Zx, group: aw, image: dw, line: fw, path: mw, rect: yw, rule: vw, shape: xw, symbol: ww, text: jw, trail: Uw }; function Vw(e, t, n) { var r = Ww[e.mark.marktype], i = t || r.bound; return r.nested && (e = e.mark), i(e.bounds || (e.bounds = new qv), e, n) } var Gw = { mark: null }; const Hw = ["marktype", "name", "role", "interactive", "clip", "items", "zindex", "x", "y", "width", "height", "align", "baseline", "fill", "fillOpacity", "opacity", "blend", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeDash", "strokeDashOffset", "strokeForeground", "strokeOffset", "startAngle", "endAngle", "innerRadius", "outerRadius", "cornerRadius", "padAngle", "cornerRadiusTopLeft", "cornerRadiusTopRight", "cornerRadiusBottomLeft", "cornerRadiusBottomRight", "interpolate", "tension", "orient", "defined", "url", "aspect", "smooth", "path", "scaleX", "scaleY", "x2", "y2", "size", "shape", "text", "angle", "theta", "radius", "dir", "dx", "dy", "ellipsis", "limit", "lineBreak", "lineHeight", "font", "fontSize", "fontWeight", "fontStyle", "fontVariant", "description", "aria", "ariaRole", "ariaRoleDescription"]; function qw(e) { return Yw("string" == typeof e ? JSON.parse(e) : e) } function Yw(e) { var t, n, r, i = e.marktype, a = e.items; if (a) for (n = 0, r = a.length; n < r; ++n)t = i ? "mark" : "group", a[n][t] = e, a[n].zindex && (a[n][t].zdirty = !0), "group" === (i || t) && Yw(a[n]); return i && function (e, t, n) { var r, i, a, o, s = Ww[e.marktype], u = s.bound, l = e.items, c = l && l.length; if (s.nested) return c ? a = l[0] : (Gw.mark = e, a = Gw), o = Vw(a, u, n), t && t.union(o) || o; if (t = t || e.bounds && e.bounds.clear() || new qv, c) for (r = 0, i = l.length; r < i; ++r)t.union(Vw(l[r], u, n)); e.bounds = t }(e), e } class Xw { constructor(e) { arguments.length ? this.root = qw(e) : (this.root = Kw({ marktype: "group", name: "root", role: "frame" }), this.root.items = [new Xv(this.root)]) } toJSON(e) { return function (e, t) { return JSON.stringify(e, Hw, t) }(this.root, e || 0) } mark(e, t, n) { const r = Kw(e, t = t || this.root.items[0]); return t.items[n] = r, r.zindex && (r.group.zdirty = !0), r } } function Kw(e, t) { const n = { bounds: new qv, clip: !!e.clip, group: t, interactive: !1 !== e.interactive, items: [], marktype: e.marktype, name: e.name || void 0, role: e.role || void 0, zindex: e.zindex || 0 }; return null != e.aria && (n.aria = e.aria), e.description && (n.description = e.description), n } function Zw(e, t, n) { return !e && "undefined" != typeof document && document.createElement && (e = document), e ? n ? e.createElementNS(n, t) : e.createElement(t) : null } function Jw(e, t) { t = t.toLowerCase(); for (var n = e.childNodes, r = 0, i = n.length; r < i; ++r)if (n[r].tagName.toLowerCase() === t) return n[r] } function Qw(e, t, n, r) { var i, a = e.childNodes[t]; return a && a.tagName.toLowerCase() === n.toLowerCase() || (i = a || null, a = Zw(e.ownerDocument, n, r), e.insertBefore(a, i)), a } function ek(e, t) { for (var n = e.childNodes, r = n.length; r > t;)e.removeChild(n[--r]); return e } function tk(e) { return "mark-" + e.marktype + (e.role ? " role-" + e.role : "") + (e.name ? " " + e.name : "") } function nk(e, t) { const n = t.getBoundingClientRect(); return [e.clientX - n.left - (t.clientLeft || 0), e.clientY - n.top - (t.clientTop || 0)] } class rk { constructor(e, t) { this._active = null, this._handlers = {}, this._loader = e || Ws(), this._tooltip = t || ik } initialize(e, t, n) { return this._el = e, this._obj = n || null, this.origin(t) } element() { return this._el } canvas() { return this._el && this._el.firstChild } origin(e) { return arguments.length ? (this._origin = e || [0, 0], this) : this._origin.slice() } scene(e) { return arguments.length ? (this._scene = e, this) : this._scene } on() { } off() { } _handlerIndex(e, t, n) { for (let r = e ? e.length : 0; --r >= 0;)if (e[r].type === t && (!n || e[r].handler === n)) return r; return -1 } handlers(e) { const t = this._handlers, n = []; if (e) n.push(...t[this.eventName(e)]); else for (const e in t) n.push(...t[e]); return n } eventName(e) { const t = e.indexOf("."); return t < 0 ? e : e.slice(0, t) } handleHref(e, t, n) { this._loader.sanitize(n, { context: "href" }).then((t => { const n = new MouseEvent(e.type, e), r = Zw(null, "a"); for (const e in t) r.setAttribute(e, t[e]); r.dispatchEvent(n) })).catch((() => { })) } handleTooltip(e, t, n) { if (t && null != t.tooltip) { t = function (e, t, n, r) { var i, a, o = e && e.mark; if (o && (i = Ww[o.marktype]).tip) { for ((a = nk(t, n))[0] -= r[0], a[1] -= r[1]; e = e.mark.group;)a[0] -= e.x || 0, a[1] -= e.y || 0; e = i.tip(o.items, a) } return e }(t, e, this.canvas(), this._origin); const r = n && t && t.tooltip || null; this._tooltip.call(this._obj, this, e, t, r) } } getItemBoundingClientRect(e) { const t = this.canvas(); if (!t) return; const n = t.getBoundingClientRect(), r = this._origin, i = e.bounds, a = i.width(), o = i.height(); let s = i.x1 + r[0] + n.left, u = i.y1 + r[1] + n.top; for (; e.mark && (e = e.mark.group);)s += e.x || 0, u += e.y || 0; return { x: s, y: u, width: a, height: o, left: s, top: u, right: s + a, bottom: u + o } } } function ik(e, t, n, r) { e.element().setAttribute("title", r || "") } class ak { constructor(e) { this._el = null, this._bgcolor = null, this._loader = new Kv(e) } initialize(e, t, n, r, i) { return this._el = e, this.resize(t, n, r, i) } element() { return this._el } canvas() { return this._el && this._el.firstChild } background(e) { return 0 === arguments.length ? this._bgcolor : (this._bgcolor = e, this) } resize(e, t, n, r) { return this._width = e, this._height = t, this._origin = n || [0, 0], this._scale = r || 1, this } dirty() { } render(e, t) { const n = this; return n._call = function () { n._render(e, t) }, n._call(), n._call = null, n } _render() { } renderAsync(e, t) { const n = this.render(e, t); return this._ready ? this._ready.then((() => n)) : Promise.resolve(n) } _load(e, t) { var n = this, r = n._loader[e](t); if (!n._ready) { const e = n._call; n._ready = n._loader.ready().then((t => { t && e(), n._ready = null })) } return r } sanitizeURL(e) { return this._load("sanitizeURL", e) } loadImage(e) { return this._load("loadImage", e) } } const ok = "dragenter", sk = "dragleave", uk = "dragover", lk = "pointerdown", ck = "pointermove", hk = "pointerout", dk = "pointerover", fk = "mousedown", pk = "mousemove", mk = "mouseout", gk = "mouseover", yk = "click", bk = "mousewheel", vk = "touchstart", xk = "touchmove", wk = "touchend", kk = ["keydown", "keypress", "keyup", ok, sk, uk, lk, "pointerup", ck, hk, dk, fk, "mouseup", pk, mk, gk, yk, "dblclick", "wheel", bk, vk, xk, wk], Sk = ck, _k = mk, Ck = yk; class Ak extends rk { constructor(e, t) { super(e, t), this._down = null, this._touch = null, this._first = !0, this._events = {}, this.events = kk, this.pointermove = Ik([ck, pk], [dk, gk], [hk, mk]), this.dragover = Ik([uk], [ok], [sk]), this.pointerout = Mk([hk, mk]), this.dragleave = Mk([sk]) } initialize(e, t, n) { return this._canvas = e && Jw(e, "canvas"), [yk, fk, lk, ck, hk, sk].forEach((e => Ek(this, e))), super.initialize(e, t, n) } canvas() { return this._canvas } context() { return this._canvas.getContext("2d") } DOMMouseScroll(e) { this.fire(bk, e) } pointerdown(e) { this._down = this._active, this.fire(lk, e) } mousedown(e) { this._down = this._active, this.fire(fk, e) } click(e) { this._down === this._active && (this.fire(yk, e), this._down = null) } touchstart(e) { this._touch = this.pickEvent(e.changedTouches[0]), this._first && (this._active = this._touch, this._first = !1), this.fire(vk, e, !0) } touchmove(e) { this.fire(xk, e, !0) } touchend(e) { this.fire(wk, e, !0), this._touch = null } fire(e, t, n) { const r = n ? this._touch : this._active, i = this._handlers[e]; if (t.vegaType = e, e === Ck && r && r.href ? this.handleHref(t, r, r.href) : e !== Sk && e !== _k || this.handleTooltip(t, r, e !== _k), i) for (let e = 0, n = i.length; e < n; ++e)i[e].handler.call(this._obj, t, r) } on(e, t) { const n = this.eventName(e), r = this._handlers; return this._handlerIndex(r[n], e, t) < 0 && (Ek(this, e), (r[n] || (r[n] = [])).push({ type: e, handler: t })), this } off(e, t) { const n = this.eventName(e), r = this._handlers[n], i = this._handlerIndex(r, e, t); return i >= 0 && r.splice(i, 1), this } pickEvent(e) { const t = nk(e, this._canvas), n = this._origin; return this.pick(this._scene, t[0], t[1], t[0] - n[0], t[1] - n[1]) } pick(e, t, n, r, i) { const a = this.context(); return Ww[e.marktype].pick.call(this, a, e, t, n, r, i) } } const Tk = e => e === vk || e === xk || e === wk ? [vk, xk, wk] : [e]; function Ek(e, t) { Tk(t).forEach((t => function (e, t) { const n = e.canvas(); n && !e._events[t] && (e._events[t] = 1, n.addEventListener(t, e[t] ? n => e[t](n) : n => e.fire(t, n))) }(e, t))) } function Nk(e, t, n) { t.forEach((t => e.fire(t, n))) } function Ik(e, t, n) { return function (r) { const i = this._active, a = this.pickEvent(r); a === i || (i && i.exit || Nk(this, n, r), this._active = a, Nk(this, t, r)), Nk(this, e, r) } } function Mk(e) { return function (t) { Nk(this, e, t), this._active = null } } function Fk(e, t, n, r, i, a) { const o = "undefined" != typeof HTMLElement && e instanceof HTMLElement && null != e.parentNode, s = e.getContext("2d"), u = o ? "undefined" != typeof window && window.devicePixelRatio || 1 : i; e.width = t * u, e.height = n * u; for (const e in a) s[e] = a[e]; return o && 1 !== u && (e.style.width = t + "px", e.style.height = n + "px"), s.pixelRatio = u, s.setTransform(u, 0, 0, u, u * r[0], u * r[1]), e } class Dk extends ak { constructor(e) { super(e), this._options = {}, this._redraw = !1, this._dirty = new qv, this._tempb = new qv } initialize(e, t, n, r, i, a) { return this._options = a || {}, this._canvas = this._options.externalContext ? null : Fd(1, 1, this._options.type), e && this._canvas && (ek(e, 0).appendChild(this._canvas), this._canvas.setAttribute("class", "marks")), super.initialize(e, t, n, r, i) } resize(e, t, n, r) { if (super.resize(e, t, n, r), this._canvas) Fk(this._canvas, this._width, this._height, this._origin, this._scale, this._options.context); else { const e = this._options.externalContext; e || Vt("CanvasRenderer is missing a valid canvas or context"), e.scale(this._scale, this._scale), e.translate(this._origin[0], this._origin[1]) } return this._redraw = !0, this } canvas() { return this._canvas } context() { return this._options.externalContext || (this._canvas ? this._canvas.getContext("2d") : null) } dirty(e) { const t = this._tempb.clear().union(e.bounds); let n = e.mark.group; for (; n;)t.translate(n.x || 0, n.y || 0), n = n.mark.group; this._dirty.union(t) } _render(e, t) { const n = this.context(), r = this._origin, i = this._width, a = this._height, o = this._dirty, s = $k(r, i, a); n.save(); const u = this._redraw || o.empty() ? (this._redraw = !1, s.expand(1)) : function (e, t, n) { t.expand(1).round(), e.pixelRatio % 1 && t.scale(e.pixelRatio).round().scale(1 / e.pixelRatio); return t.translate(-n[0] % 1, -n[1] % 1), e.beginPath(), e.rect(t.x1, t.y1, t.width(), t.height()), e.clip(), t }(n, s.intersect(o), r); return this.clear(-r[0], -r[1], i, a), this.draw(n, e, u, t), n.restore(), o.clear(), this } draw(e, t, n, r) { if ("group" !== t.marktype && null != r && !r.includes(t.marktype)) return; const i = Ww[t.marktype]; t.clip && function (e, t) { var n = t.clip; e.save(), Cn(n) ? (e.beginPath(), n(e), e.clip()) : Jx(e, t.group) }(e, t), i.draw.call(this, e, t, n, r), t.clip && e.restore() } clear(e, t, n, r) { const i = this._options, a = this.context(); "pdf" === i.type || i.externalContext || a.clearRect(e, t, n, r), null != this._bgcolor && (a.fillStyle = this._bgcolor, a.fillRect(e, t, n, r)) } } const $k = (e, t, n) => (new qv).set(0, 0, t, n).translate(-e[0], -e[1]); const Rk = (e, t) => n => { let r = n.target.__data__; r = Array.isArray(r) ? r[0] : r, n.vegaType = n.type, t.call(e._obj, n, r) }, Ok = "aria-hidden", zk = "aria-label", Pk = "role", Bk = "aria-roledescription", Lk = "graphics-object", jk = "graphics-symbol", Uk = (e, t, n) => ({ [Pk]: e, [Bk]: t, [zk]: n || void 0 }), Wk = Qn(["axis-domain", "axis-grid", "axis-label", "axis-tick", "axis-title", "legend-band", "legend-entry", "legend-gradient", "legend-label", "legend-title", "legend-symbol", "title"]), Vk = { axis: { desc: "axis", caption: function (e) { const t = e.datum, n = e.orient, r = t.title ? Xk(e) : null, i = e.context, a = i.scales[t.scale].value, o = i.dataflow.locale(), s = a.type, u = "left" === n || "right" === n ? "Y" : "X"; return `${u}-axis` + (r ? ` titled '${r}'` : "") + ` for a ${yb(s) ? "discrete" : s} scale` + ` with ${Xb(o, a, e)}` } }, legend: { desc: "legend", caption: function (e) { const t = e.datum, n = t.title ? Xk(e) : null, r = `${t.type || ""} legend`.trim(), i = t.scales, a = Object.keys(i), o = e.context, s = o.scales[i[a[0]]].value, u = o.dataflow.locale(); return function (e) { return e.length ? e[0].toUpperCase() + e.slice(1) : e }(r) + (n ? ` titled '${n}'` : "") + ` for ${function (e) { return e = e.map((e => e + ("fill" === e || "stroke" === e ? " color" : ""))), e.length < 2 ? e[0] : e.slice(0, -1).join(", ") + " and " + hn(e) }(a)}` + ` with ${Xb(u, s, e)}` } }, "title-text": { desc: "title", caption: e => `Title text '${Yk(e)}'` }, "title-subtitle": { desc: "subtitle", caption: e => `Subtitle text '${Yk(e)}'` } }, Gk = { ariaRole: Pk, ariaRoleDescription: Bk, description: zk }; function Hk(e, t) { const n = !1 === t.aria; if (e(Ok, n || void 0), n || null == t.description) for (const t in Gk) e(Gk[t], void 0); else { const n = t.mark.marktype; e(zk, t.description), e(Pk, t.ariaRole || ("group" === n ? Lk : jk)), e(Bk, t.ariaRoleDescription || `${n} mark`) } } function qk(e) { return !1 === e.aria ? { [Ok]: !0 } : Wk[e.role] ? null : Vk[e.role] ? function (e, t) { try { const n = e.items[0], r = t.caption || (() => ""); return Uk(t.role || jk, t.desc, n.description || r(n)) } catch (e) { return null } }(e, Vk[e.role]) : function (e) { const t = e.marktype, n = "group" === t || "text" === t || e.items.some((e => null != e.description && !1 !== e.aria)); return Uk(n ? Lk : jk, `${t} mark container`, e.description) }(e) } function Yk(e) { return _n(e.text).join(" ") } function Xk(e) { try { return _n(hn(e.items).items[0].text).join(" ") } catch (e) { return null } } const Kk = e => (e + "").replace(/&/g, "&").replace(//g, ">"); function Zk() { let e = "", t = "", n = ""; const r = [], i = () => t = n = "", a = (e, n) => { var r; return null != n && (t += ` ${e}="${r = n, Kk(r).replace(/"/g, """).replace(/\t/g, " ").replace(/\n/g, " ").replace(/\r/g, " ")}"`), o }, o = { open(s) { (a => { t && (e += `${t}>${n}`, i()), r.push(a) })(s), t = "<" + s; for (var u = arguments.length, l = new Array(u > 1 ? u - 1 : 0), c = 1; c < u; c++)l[c - 1] = arguments[c]; for (const e of l) for (const t in e) a(t, e[t]); return o }, close() { const a = r.pop(); return e += t ? t + (n ? `>${n}` : "/>") : ``, i(), o }, attr: a, text: e => (n += Kk(e), o), toString: () => e }; return o } const Jk = e => Qk(Zk(), e) + ""; function Qk(e, t) { if (e.open(t.tagName), t.hasAttributes()) { const n = t.attributes, r = n.length; for (let t = 0; t < r; ++t)e.attr(n[t].name, n[t].value) } if (t.hasChildNodes()) { const n = t.childNodes; for (const t of n) 3 === t.nodeType ? e.text(t.nodeValue) : Qk(e, t) } return e.close() } const eS = { fill: "fill", fillOpacity: "fill-opacity", stroke: "stroke", strokeOpacity: "stroke-opacity", strokeWidth: "stroke-width", strokeCap: "stroke-linecap", strokeJoin: "stroke-linejoin", strokeDash: "stroke-dasharray", strokeDashOffset: "stroke-dashoffset", strokeMiterLimit: "stroke-miterlimit", opacity: "opacity" }, tS = { blend: "mix-blend-mode" }, nS = { fill: "none", "stroke-miterlimit": 10 }, rS = "http://www.w3.org/2000/xmlns/", iS = ow.xmlns; class aS extends ak { constructor(e) { super(e), this._dirtyID = 0, this._dirty = [], this._svg = null, this._root = null, this._defs = null } initialize(e, t, n, r, i) { return this._defs = {}, this._clearDefs(), e && (this._svg = Qw(e, 0, "svg", iS), this._svg.setAttributeNS(rS, "xmlns", iS), this._svg.setAttributeNS(rS, "xmlns:xlink", ow["xmlns:xlink"]), this._svg.setAttribute("version", ow.version), this._svg.setAttribute("class", "marks"), ek(e, 1), this._root = Qw(this._svg, 0, "g", iS), mS(this._root, nS), ek(this._svg, 1)), this.background(this._bgcolor), super.initialize(e, t, n, r, i) } background(e) { return arguments.length && this._svg && this._svg.style.setProperty("background-color", e), super.background(...arguments) } resize(e, t, n, r) { return super.resize(e, t, n, r), this._svg && (mS(this._svg, { width: this._width * this._scale, height: this._height * this._scale, viewBox: `0 0 ${this._width} ${this._height}` }), this._root.setAttribute("transform", `translate(${this._origin})`)), this._dirty = [], this } canvas() { return this._svg } svg() { const e = this._svg, t = this._bgcolor; if (!e) return null; let n; t && (e.removeAttribute("style"), n = Qw(e, 0, "rect", iS), mS(n, { width: this._width, height: this._height, fill: t })); const r = Jk(e); return t && (e.removeChild(n), this._svg.style.setProperty("background-color", t)), r } _render(e, t) { return this._dirtyCheck() && (this._dirtyAll && this._clearDefs(), this.mark(this._root, e, void 0, t), ek(this._root, 1)), this.defs(), this._dirty = [], ++this._dirtyID, this } dirty(e) { e.dirty !== this._dirtyID && (e.dirty = this._dirtyID, this._dirty.push(e)) } isDirty(e) { return this._dirtyAll || !e._svg || !e._svg.ownerSVGElement || e.dirty === this._dirtyID } _dirtyCheck() { this._dirtyAll = !0; const e = this._dirty; if (!e.length || !this._dirtyID) return !0; const t = ++this._dirtyID; let n, r, i, a, o, s, u; for (o = 0, s = e.length; o < s; ++o)n = e[o], r = n.mark, r.marktype !== i && (i = r.marktype, a = Ww[i]), r.zdirty && r.dirty !== t && (this._dirtyAll = !1, oS(n, t), r.items.forEach((e => { e.dirty = t }))), r.zdirty || (n.exit ? (a.nested && r.items.length ? (u = r.items[0], u._svg && this._update(a, u._svg, u)) : n._svg && (u = n._svg.parentNode, u && u.removeChild(n._svg)), n._svg = null) : (n = a.nested ? r.items[0] : n, n._update !== t && (n._svg && n._svg.ownerSVGElement ? this._update(a, n._svg, n) : (this._dirtyAll = !1, oS(n, t)), n._update = t))); return !this._dirtyAll } mark(e, t, n, r) { if (!this.isDirty(t)) return t._svg; const i = this._svg, a = t.marktype, o = Ww[a], s = !1 === t.interactive ? "none" : null, u = "g" === o.tag, l = lS(t, e, n, "g", i); if ("group" !== a && null != r && !r.includes(a)) return ek(l, 0), t._svg; l.setAttribute("class", tk(t)); const c = qk(t); for (const e in c) gS(l, e, c[e]); u || gS(l, "pointer-events", s), gS(l, "clip-path", t.clip ? Hv(this, t, t.group) : null); let h = null, d = 0; const f = e => { const t = this.isDirty(e), n = lS(e, l, h, o.tag, i); t && (this._update(o, n, e), u && function (e, t, n, r) { t = t.lastChild.previousSibling; let i, a = 0; zx(n, (n => { i = e.mark(t, n, i, r), ++a })), ek(t, 1 + a) }(this, n, e, r)), h = n, ++d }; return o.nested ? t.items.length && f(t.items[0]) : zx(t, f), ek(l, d), l } _update(e, t, n) { cS = t, hS = t.__values__, Hk(fS, n), e.attr(fS, n, this); const r = dS[e.type]; r && r.call(this, e, t, n), cS && this.style(cS, n) } style(e, t) { if (null != t) { for (const n in eS) { let r = "font" === n ? $w(t) : t[n]; if (r === hS[n]) continue; const i = eS[n]; null == r ? e.removeAttribute(i) : (Jb(r) && (r = Qb(r, this._defs.gradient, yS())), e.setAttribute(i, r + "")), hS[n] = r } for (const n in tS) pS(e, tS[n], t[n]) } } defs() { const e = this._svg, t = this._defs; let n = t.el, r = 0; for (const i in t.gradient) n || (t.el = n = Qw(e, 1, "defs", iS)), r = sS(n, t.gradient[i], r); for (const i in t.clipping) n || (t.el = n = Qw(e, 1, "defs", iS)), r = uS(n, t.clipping[i], r); n && (0 === r ? (e.removeChild(n), t.el = null) : ek(n, r)) } _clearDefs() { const e = this._defs; e.gradient = {}, e.clipping = {} } } function oS(e, t) { for (; e && e.dirty !== t; e = e.mark.group) { if (e.dirty = t, !e.mark || e.mark.dirty === t) return; e.mark.dirty = t } } function sS(e, t, n) { let r, i, a; if ("radial" === t.gradient) { let r = Qw(e, n++, "pattern", iS); mS(r, { id: Zb + t.id, viewBox: "0,0,1,1", width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }), r = Qw(r, 0, "rect", iS), mS(r, { width: 1, height: 1, fill: `url(${yS()}#${t.id})` }), mS(e = Qw(e, n++, "radialGradient", iS), { id: t.id, fx: t.x1, fy: t.y1, fr: t.r1, cx: t.x2, cy: t.y2, r: t.r2 }) } else mS(e = Qw(e, n++, "linearGradient", iS), { id: t.id, x1: t.x1, x2: t.x2, y1: t.y1, y2: t.y2 }); for (r = 0, i = t.stops.length; r < i; ++r)a = Qw(e, r, "stop", iS), a.setAttribute("offset", t.stops[r].offset), a.setAttribute("stop-color", t.stops[r].color); return ek(e, r), n } function uS(e, t, n) { let r; return (e = Qw(e, n, "clipPath", iS)).setAttribute("id", t.id), t.path ? (r = Qw(e, 0, "path", iS), r.setAttribute("d", t.path)) : (r = Qw(e, 0, "rect", iS), mS(r, { x: 0, y: 0, width: t.width, height: t.height })), ek(e, 1), n + 1 } function lS(e, t, n, r, i) { let a, o = e._svg; if (!o && (a = t.ownerDocument, o = Zw(a, r, iS), e._svg = o, e.mark && (o.__data__ = e, o.__values__ = { fill: "default" }, "g" === r))) { const t = Zw(a, "path", iS); o.appendChild(t), t.__data__ = e; const n = Zw(a, "g", iS); o.appendChild(n), n.__data__ = e; const r = Zw(a, "path", iS); o.appendChild(r), r.__data__ = e, r.__values__ = { fill: "default" } } return (o.ownerSVGElement !== i || function (e, t) { return e.parentNode && e.parentNode.childNodes.length > 1 && e.previousSibling != t }(o, n)) && t.insertBefore(o, n ? n.nextSibling : t.firstChild), o } let cS = null, hS = null; const dS = { group(e, t, n) { const r = cS = t.childNodes[2]; hS = r.__values__, e.foreground(fS, n, this), hS = t.__values__, cS = t.childNodes[1], e.content(fS, n, this); const i = cS = t.childNodes[0]; e.background(fS, n, this); const a = !1 === n.mark.interactive ? "none" : null; if (a !== hS.events && (gS(r, "pointer-events", a), gS(i, "pointer-events", a), hS.events = a), n.strokeForeground && n.stroke) { const e = n.fill; gS(r, "display", null), this.style(i, n), gS(i, "stroke", null), e && (n.fill = null), hS = r.__values__, this.style(r, n), e && (n.fill = e), cS = null } else gS(r, "display", "none") }, image(e, t, n) { !1 === n.smooth ? (pS(t, "image-rendering", "optimizeSpeed"), pS(t, "image-rendering", "pixelated")) : pS(t, "image-rendering", null) }, text(e, t, n) { const r = Mw(n); let i, a, o, s; on(r) ? (a = r.map((e => Dw(n, e))), i = a.join("\n"), i !== hS.text && (ek(t, 0), o = t.ownerDocument, s = Iw(n), a.forEach(((e, r) => { const i = Zw(o, "tspan", iS); i.__data__ = n, i.textContent = e, r && (i.setAttribute("x", 0), i.setAttribute("dy", s)), t.appendChild(i) })), hS.text = i)) : (a = Dw(n, r), a !== hS.text && (t.textContent = a, hS.text = a)), gS(t, "font-family", $w(n)), gS(t, "font-size", Nw(n) + "px"), gS(t, "font-style", n.fontStyle), gS(t, "font-variant", n.fontVariant), gS(t, "font-weight", n.fontWeight) } }; function fS(e, t, n) { t !== hS[e] && (n ? function (e, t, n, r) { null != n ? e.setAttributeNS(r, t, n) : e.removeAttributeNS(r, t) }(cS, e, t, n) : gS(cS, e, t), hS[e] = t) } function pS(e, t, n) { n !== hS[t] && (null == n ? e.style.removeProperty(t) : e.style.setProperty(t, n + ""), hS[t] = n) } function mS(e, t) { for (const n in t) gS(e, n, t[n]) } function gS(e, t, n) { null != n ? e.setAttribute(t, n) : e.removeAttribute(t) } function yS() { let e; return "undefined" == typeof window ? "" : (e = window.location).hash ? e.href.slice(0, -e.hash.length) : e.href } const bS = { svgMarkTypes: ["text"], svgOnTop: !0, debug: !1 }; class vS extends ak { constructor(e) { super(e), this._svgRenderer = new aS(e), this._canvasRenderer = new Dk(e) } initialize(e, t, n, r, i) { this._root_el = Qw(e, 0, "div"); const a = Qw(this._root_el, 0, "div"), o = Qw(this._root_el, 1, "div"); return this._root_el.style.position = "relative", bS.debug || (a.style.height = "100%", o.style.position = "absolute", o.style.top = "0", o.style.left = "0", o.style.height = "100%", o.style.width = "100%"), this._svgEl = bS.svgOnTop ? o : a, this._canvasEl = bS.svgOnTop ? a : o, this._svgEl.style.pointerEvents = "none", this._canvasRenderer.initialize(this._canvasEl, t, n, r, i), this._svgRenderer.initialize(this._svgEl, t, n, r, i), super.initialize(e, t, n, r, i) } dirty(e) { return bS.svgMarkTypes.includes(e.mark.marktype) ? this._svgRenderer.dirty(e) : this._canvasRenderer.dirty(e), this } _render(e, t) { const n = (t ?? ["arc", "area", "image", "line", "path", "rect", "rule", "shape", "symbol", "text", "trail"]).filter((e => !bS.svgMarkTypes.includes(e))); this._svgRenderer.render(e, bS.svgMarkTypes), this._canvasRenderer.render(e, n) } resize(e, t, n, r) { return super.resize(e, t, n, r), this._svgRenderer.resize(e, t, n, r), this._canvasRenderer.resize(e, t, n, r), this } background(e) { return bS.svgOnTop ? this._canvasRenderer.background(e) : this._svgRenderer.background(e), this } } const xS = "canvas", wS = "hybrid", kS = "none", SS = { Canvas: xS, PNG: "png", SVG: "svg", Hybrid: wS, None: kS }, _S = {}; function CS(e, t) { return e = String(e || "").toLowerCase(), arguments.length > 1 ? (_S[e] = t, this) : _S[e] } function AS(e, t, n, r) { if (function (e, t, n) { return e.bounds && t.intersects(e.bounds) && ("group" === e.marktype || !1 !== e.interactive && (!n || n(e))) }(e, t, n)) { const i = e.items, a = e.marktype, o = i.length; let s = 0; if ("group" === a) for (; s < o; ++s)TS(i[s], t, n, r); else for (const e = Ww[a].isect; s < o; ++s) { const n = i[s]; ES(n, t, e) && r.push(n) } } return r } function TS(e, t, n, r) { n && n(e.mark) && ES(e, t, Ww.group.isect) && r.push(e); const i = e.items, a = i && i.length; if (a) { const o = e.x || 0, s = e.y || 0; t.translate(-o, -s); for (let e = 0; e < a; ++e)AS(i[e], t, n, r); t.translate(o, s) } return r } function ES(e, t, n) { const r = e.bounds; return t.encloses(r) || t.intersects(r) && n(e, t) } _S[xS] = _S.png = { renderer: Dk, headless: Dk, handler: Ak }, _S.svg = { renderer: aS, headless: class extends ak { constructor(e) { super(e), this._text = null, this._defs = { gradient: {}, clipping: {} } } svg() { return this._text } _render(e) { const t = Zk(); t.open("svg", $n({}, ow, { class: "marks", width: this._width * this._scale, height: this._height * this._scale, viewBox: `0 0 ${this._width} ${this._height}` })); const n = this._bgcolor; return n && "transparent" !== n && "none" !== n && t.open("rect", { width: this._width, height: this._height, fill: n }).close(), t.open("g", nS, { transform: "translate(" + this._origin + ")" }), this.mark(t, e), t.close(), this.defs(t), this._text = t.close() + "", this } mark(e, t) { const n = Ww[t.marktype], r = n.tag, i = [Hk, n.attr]; e.open("g", { class: tk(t), "clip-path": t.clip ? Hv(this, t, t.group) : null }, qk(t), { "pointer-events": "g" !== r && !1 === t.interactive ? "none" : null }); const a = a => { const o = this.href(a); if (o && e.open("a", o), e.open(r, this.attr(t, a, i, "g" !== r ? r : null)), "text" === r) { const t = Mw(a); if (on(t)) { const n = { x: 0, dy: Iw(a) }; for (let r = 0; r < t.length; ++r)e.open("tspan", r ? n : null).text(Dw(a, t[r])).close() } else e.text(Dw(a, t)) } else if ("g" === r) { const r = a.strokeForeground, i = a.fill, o = a.stroke; r && o && (a.stroke = null), e.open("path", this.attr(t, a, n.background, "bgrect")).close(), e.open("g", this.attr(t, a, n.content)), zx(a, (t => this.mark(e, t))), e.close(), r && o ? (i && (a.fill = null), a.stroke = o, e.open("path", this.attr(t, a, n.foreground, "bgrect")).close(), i && (a.fill = i)) : e.open("path", this.attr(t, a, n.foreground, "bgfore")).close() } e.close(), o && e.close() }; return n.nested ? t.items && t.items.length && a(t.items[0]) : zx(t, a), e.close() } href(e) { const t = e.href; let n; if (t) { if (n = this._hrefs && this._hrefs[t]) return n; this.sanitizeURL(t).then((e => { e["xlink:href"] = e.href, e.href = null, (this._hrefs || (this._hrefs = {}))[t] = e })) } return null } attr(e, t, n, r) { const i = {}, a = (e, t, n, r) => { i[r || e] = t }; return Array.isArray(n) ? n.forEach((e => e(a, t, this))) : n(a, t, this), r && function (e, t, n, r, i) { let a; if (null == t) return e; "bgrect" === r && !1 === n.interactive && (e["pointer-events"] = "none"); if ("bgfore" === r && (!1 === n.interactive && (e["pointer-events"] = "none"), e.display = "none", null !== t.fill)) return e; "image" === r && !1 === t.smooth && (a = ["image-rendering: optimizeSpeed;", "image-rendering: pixelated;"]); "text" === r && (e["font-family"] = $w(t), e["font-size"] = Nw(t) + "px", e["font-style"] = t.fontStyle, e["font-variant"] = t.fontVariant, e["font-weight"] = t.fontWeight); for (const n in eS) { let r = t[n]; const a = eS[n]; ("transparent" !== r || "fill" !== a && "stroke" !== a) && null != r && (Jb(r) && (r = Qb(r, i.gradient, "")), e[a] = r) } for (const e in tS) { const n = t[e]; null != n && (a = a || [], a.push(`${tS[e]}: ${n};`)) } a && (e.style = a.join(" ")) }(i, t, e, r, this._defs), i } defs(e) { const t = this._defs.gradient, n = this._defs.clipping; if (0 !== Object.keys(t).length + Object.keys(n).length) { e.open("defs"); for (const n in t) { const r = t[n], i = r.stops; "radial" === r.gradient ? (e.open("pattern", { id: Zb + n, viewBox: "0,0,1,1", width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }), e.open("rect", { width: "1", height: "1", fill: "url(#" + n + ")" }).close(), e.close(), e.open("radialGradient", { id: n, fx: r.x1, fy: r.y1, fr: r.r1, cx: r.x2, cy: r.y2, r: r.r2 })) : e.open("linearGradient", { id: n, x1: r.x1, x2: r.x2, y1: r.y1, y2: r.y2 }); for (let t = 0; t < i.length; ++t)e.open("stop", { offset: i[t].offset, "stop-color": i[t].color }).close(); e.close() } for (const t in n) { const r = n[t]; e.open("clipPath", { id: t }), r.path ? e.open("path", { d: r.path }).close() : e.open("rect", { x: 0, y: 0, width: r.width, height: r.height }).close(), e.close() } e.close() } } }, handler: class extends rk { constructor(e, t) { super(e, t); const n = this; n._hrefHandler = Rk(n, ((e, t) => { t && t.href && n.handleHref(e, t, t.href) })), n._tooltipHandler = Rk(n, ((e, t) => { n.handleTooltip(e, t, e.type !== _k) })) } initialize(e, t, n) { let r = this._svg; return r && (r.removeEventListener(Ck, this._hrefHandler), r.removeEventListener(Sk, this._tooltipHandler), r.removeEventListener(_k, this._tooltipHandler)), this._svg = r = e && Jw(e, "svg"), r && (r.addEventListener(Ck, this._hrefHandler), r.addEventListener(Sk, this._tooltipHandler), r.addEventListener(_k, this._tooltipHandler)), super.initialize(e, t, n) } canvas() { return this._svg } on(e, t) { const n = this.eventName(e), r = this._handlers; if (this._handlerIndex(r[n], e, t) < 0) { const i = { type: e, handler: t, listener: Rk(this, t) }; (r[n] || (r[n] = [])).push(i), this._svg && this._svg.addEventListener(n, i.listener) } return this } off(e, t) { const n = this.eventName(e), r = this._handlers[n], i = this._handlerIndex(r, e, t); return i >= 0 && (this._svg && this._svg.removeEventListener(n, r[i].listener), r.splice(i, 1)), this } } }, _S[wS] = { renderer: vS, headless: vS, handler: class extends Ak { constructor(e, t) { super(e, t) } initialize(e, t, n) { const r = Qw(Qw(e, 0, "div"), bS.svgOnTop ? 0 : 1, "div"); return super.initialize(r, t, n) } } }, _S[kS] = {}; const NS = new qv; const IS = "top", MS = "left", FS = "right", DS = "bottom", $S = "start", RS = "middle", OS = "end", zS = "group", PS = "axis", BS = "title", LS = "frame", jS = "scope", US = "legend", WS = "row-header", VS = "row-footer", GS = "row-title", HS = "column-header", qS = "column-footer", YS = "column-title", XS = "padding", KS = "fit", ZS = "fit-x", JS = "fit-y", QS = "none", e_ = "all", t_ = "each", n_ = "flush", r_ = "column", i_ = "row"; function a_(e) { Eu.call(this, null, e) } function o_(e, t, n) { return t(e.bounds.clear(), e, n) } Ln(a_, Eu, { transform(e, t) { const n = t.dataflow, r = e.mark, i = r.marktype, a = Ww[i], o = a.bound; let s, u = r.bounds; if (a.nested) r.items.length && n.dirty(r.items[0]), u = o_(r, o), r.items.forEach((e => { e.bounds.clear().union(u) })); else if (i === zS || e.modified()) switch (t.visit(t.MOD, (e => n.dirty(e))), u.clear(), r.items.forEach((e => u.union(o_(e, o)))), r.role) { case PS: case US: case BS: t.reflow() } else s = t.changed(t.REM), t.visit(t.ADD, (e => { u.union(o_(e, o)) })), t.visit(t.MOD, (e => { s = s || u.alignsWith(e.bounds), n.dirty(e), u.union(o_(e, o)) })), s && (u.clear(), r.items.forEach((e => u.union(e.bounds)))); return function (e) { const t = e.clip; if (Cn(t)) t(yx(NS.clear())); else { if (!t) return; NS.set(0, 0, e.group.width, e.group.height) } e.bounds.intersect(NS) }(r), t.modifies("bounds") } }); const s_ = ":vega_identifier:"; function u_(e) { Eu.call(this, 0, e) } function l_(e) { Eu.call(this, null, e) } function c_(e) { Eu.call(this, null, e) } u_.Definition = { type: "Identifier", metadata: { modifies: !0 }, params: [{ name: "as", type: "string", required: !0 }] }, Ln(u_, Eu, { transform(e, t) { const n = (i = t.dataflow)._signals[s_] || (i._signals[s_] = i.add(0)), r = e.as; var i; let a = n.value; return t.visit(t.ADD, (e => e[r] = e[r] || ++a)), n.set(this.value = a), t } }), Ln(l_, Eu, { transform(e, t) { let n = this.value; n || (n = t.dataflow.scenegraph().mark(e.markdef, function (e) { const t = e.groups, n = e.parent; return t && 1 === t.size ? t.get(Object.keys(t.object)[0]) : t && n ? t.lookup(n) : null }(e), e.index), n.group.context = e.context, e.context.group || (e.context.group = n.group), n.source = this.source, n.clip = e.clip, n.interactive = e.interactive, this.value = n); const r = n.marktype === zS ? Xv : Yv; return t.visit(t.ADD, (e => r.call(e, n))), (e.modified("clip") || e.modified("interactive")) && (n.clip = e.clip, n.interactive = !!e.interactive, n.zdirty = !0, t.reflow()), n.items = t.source, t } }); const h_ = { parity: e => e.filter(((e, t) => t % 2 ? e.opacity = 0 : 1)), greedy: (e, t) => { let n; return e.filter(((e, r) => r && d_(n.bounds, e.bounds, t) ? e.opacity = 0 : (n = e, 1))) } }, d_ = (e, t, n) => n > Math.max(t.x1 - e.x2, e.x1 - t.x2, t.y1 - e.y2, e.y1 - t.y2), f_ = (e, t) => { for (var n, r = 1, i = e.length, a = e[0].bounds; r < i; a = n, ++r)if (d_(a, n = e[r].bounds, t)) return !0 }, p_ = e => { const t = e.bounds; return t.width() > 1 && t.height() > 1 }, m_ = e => (e.forEach((e => e.opacity = 1)), e), g_ = (e, t) => e.reflow(t.modified()).modifies("opacity"); function y_(e) { Eu.call(this, null, e) } Ln(c_, Eu, { transform(e, t) { const n = h_[e.method] || h_.parity, r = e.separation || 0; let i, a, o = t.materialize(t.SOURCE).source; if (!o || !o.length) return; if (!e.method) return e.modified("method") && (m_(o), t = g_(t, e)), t; if (o = o.filter(p_), !o.length) return; if (e.sort && (o = o.slice().sort(e.sort)), i = m_(o), t = g_(t, e), i.length >= 3 && f_(i, r)) { do { i = n(i, r) } while (i.length >= 3 && f_(i, r)); i.length < 3 && !hn(o).opacity && (i.length > 1 && (hn(i).opacity = 0), hn(o).opacity = 1) } e.boundScale && e.boundTolerance >= 0 && (a = ((e, t, n) => { var r = e.range(), i = new qv; return t === IS || t === DS ? i.set(r[0], -1 / 0, r[1], 1 / 0) : i.set(-1 / 0, r[0], 1 / 0, r[1]), i.expand(n || 1), e => i.encloses(e.bounds) })(e.boundScale, e.boundOrient, +e.boundTolerance), o.forEach((e => { a(e) || (e.opacity = 0) }))); const s = i[0].mark.bounds.clear(); return o.forEach((e => { e.opacity && s.union(e.bounds) })), t } }), Ln(y_, Eu, { transform(e, t) { const n = t.dataflow; if (t.visit(t.ALL, (e => n.dirty(e))), t.fields && t.fields.zindex) { const e = t.source && t.source[0]; e && (e.mark.zdirty = !0) } } }); const b_ = new qv; function v_(e, t, n) { return e[t] === n ? 0 : (e[t] = n, 1) } function x_(e) { var t = e.items[0].orient; return t === MS || t === FS } function w_(e, t, n, r) { var i, a, o = t.items[0], s = o.datum, u = null != o.translate ? o.translate : .5, l = o.orient, c = function (e) { let t = +e.grid; return [e.ticks ? t++ : -1, e.labels ? t++ : -1, t + +e.domain] }(s), h = o.range, d = o.offset, f = o.position, p = o.minExtent, m = o.maxExtent, g = s.title && o.items[c[2]].items[0], y = o.titlePadding, b = o.bounds, v = g && Fw(g), x = 0, w = 0; switch (b_.clear().union(b), b.clear(), (i = c[0]) > -1 && b.union(o.items[i].bounds), (i = c[1]) > -1 && b.union(o.items[i].bounds), l) { case IS: x = f || 0, w = -d, a = Math.max(p, Math.min(m, -b.y1)), b.add(0, -a).add(h, 0), g && k_(e, g, a, y, v, 0, -1, b); break; case MS: x = -d, w = f || 0, a = Math.max(p, Math.min(m, -b.x1)), b.add(-a, 0).add(0, h), g && k_(e, g, a, y, v, 1, -1, b); break; case FS: x = n + d, w = f || 0, a = Math.max(p, Math.min(m, b.x2)), b.add(0, 0).add(a, h), g && k_(e, g, a, y, v, 1, 1, b); break; case DS: x = f || 0, w = r + d, a = Math.max(p, Math.min(m, b.y2)), b.add(0, 0).add(h, a), g && k_(e, g, a, y, 0, 0, 1, b); break; default: x = o.x, w = o.y }return Qv(b.translate(x, w), o), v_(o, "x", x + u) | v_(o, "y", w + u) && (o.bounds = b_, e.dirty(o), o.bounds = b, e.dirty(o)), o.mark.bounds.clear().union(b) } function k_(e, t, n, r, i, a, o, s) { const u = t.bounds; if (t.auto) { const s = o * (n + i + r); let l = 0, c = 0; e.dirty(t), a ? l = (t.x || 0) - (t.x = s) : c = (t.y || 0) - (t.y = s), t.mark.bounds.clear().union(u.translate(-l, -c)), e.dirty(t) } s.union(u) } const S_ = (e, t) => Math.floor(Math.min(e, t)), __ = (e, t) => Math.ceil(Math.max(e, t)); function C_(e) { return (new qv).set(0, 0, e.width || 0, e.height || 0) } function A_(e) { const t = e.bounds.clone(); return t.empty() ? t.set(0, 0, 0, 0) : t.translate(-(e.x || 0), -(e.y || 0)) } function T_(e, t, n) { const r = sn(e) ? e[t] : e; return null != r ? r : void 0 !== n ? n : 0 } function E_(e) { return e < 0 ? Math.ceil(-e) : 0 } function N_(e, t, n) { var r, i, a, o, s, u, l, c, h, d, f, p = !n.nodirty, m = n.bounds === n_ ? C_ : A_, g = b_.set(0, 0, 0, 0), y = T_(n.align, r_), b = T_(n.align, i_), v = T_(n.padding, r_), x = T_(n.padding, i_), w = n.columns || t.length, k = w <= 0 ? 1 : Math.ceil(t.length / w), S = t.length, _ = Array(S), C = Array(w), A = 0, T = Array(S), E = Array(k), N = 0, I = Array(S), M = Array(S), F = Array(S); for (i = 0; i < w; ++i)C[i] = 0; for (i = 0; i < k; ++i)E[i] = 0; for (i = 0; i < S; ++i)u = t[i], s = F[i] = m(u), u.x = u.x || 0, I[i] = 0, u.y = u.y || 0, M[i] = 0, a = i % w, o = ~~(i / w), A = Math.max(A, l = Math.ceil(s.x2)), N = Math.max(N, c = Math.ceil(s.y2)), C[a] = Math.max(C[a], l), E[o] = Math.max(E[o], c), _[i] = v + E_(s.x1), T[i] = x + E_(s.y1), p && e.dirty(t[i]); for (i = 0; i < S; ++i)i % w == 0 && (_[i] = 0), i < w && (T[i] = 0); if (y === t_) for (a = 1; a < w; ++a) { for (f = 0, i = a; i < S; i += w)f < _[i] && (f = _[i]); for (i = a; i < S; i += w)_[i] = f + C[a - 1] } else if (y === e_) { for (f = 0, i = 0; i < S; ++i)i % w && f < _[i] && (f = _[i]); for (i = 0; i < S; ++i)i % w && (_[i] = f + A) } else for (y = !1, a = 1; a < w; ++a)for (i = a; i < S; i += w)_[i] += C[a - 1]; if (b === t_) for (o = 1; o < k; ++o) { for (f = 0, r = (i = o * w) + w; i < r; ++i)f < T[i] && (f = T[i]); for (i = o * w; i < r; ++i)T[i] = f + E[o - 1] } else if (b === e_) { for (f = 0, i = w; i < S; ++i)f < T[i] && (f = T[i]); for (i = w; i < S; ++i)T[i] = f + N } else for (b = !1, o = 1; o < k; ++o)for (r = (i = o * w) + w; i < r; ++i)T[i] += E[o - 1]; for (h = 0, i = 0; i < S; ++i)h = _[i] + (i % w ? h : 0), I[i] += h - t[i].x; for (a = 0; a < w; ++a)for (d = 0, i = a; i < S; i += w)d += T[i], M[i] += d - t[i].y; if (y && T_(n.center, r_) && k > 1) for (i = 0; i < S; ++i)(h = (s = y === e_ ? A : C[i % w]) - F[i].x2 - t[i].x - I[i]) > 0 && (I[i] += h / 2); if (b && T_(n.center, i_) && 1 !== w) for (i = 0; i < S; ++i)(d = (s = b === e_ ? N : E[~~(i / w)]) - F[i].y2 - t[i].y - M[i]) > 0 && (M[i] += d / 2); for (i = 0; i < S; ++i)g.union(F[i].translate(I[i], M[i])); switch (h = T_(n.anchor, "x"), d = T_(n.anchor, "y"), T_(n.anchor, r_)) { case OS: h -= g.width(); break; case RS: h -= g.width() / 2 }switch (T_(n.anchor, i_)) { case OS: d -= g.height(); break; case RS: d -= g.height() / 2 }for (h = Math.round(h), d = Math.round(d), g.clear(), i = 0; i < S; ++i)t[i].mark.bounds.clear(); for (i = 0; i < S; ++i)(u = t[i]).x += I[i] += h, u.y += M[i] += d, g.union(u.mark.bounds.union(u.bounds.translate(I[i], M[i]))), p && e.dirty(u); return g } function I_(e, t, n) { var r, i, a, o, s, u, l, c = function (e) { var t, n, r = e.items, i = r.length, a = 0; const o = { marks: [], rowheaders: [], rowfooters: [], colheaders: [], colfooters: [], rowtitle: null, coltitle: null }; for (; a < i; ++a)if (n = (t = r[a]).items, t.marktype === zS) switch (t.role) { case PS: case US: case BS: break; case WS: o.rowheaders.push(...n); break; case VS: o.rowfooters.push(...n); break; case HS: o.colheaders.push(...n); break; case qS: o.colfooters.push(...n); break; case GS: o.rowtitle = n[0]; break; case YS: o.coltitle = n[0]; break; default: o.marks.push(...n) }return o }(t), h = c.marks, d = n.bounds === n_ ? M_ : F_, f = n.offset, p = n.columns || h.length, m = p <= 0 ? 1 : Math.ceil(h.length / p), g = m * p; const y = N_(e, h, n); y.empty() && y.set(0, 0, 0, 0), c.rowheaders && (u = T_(n.headerBand, i_, null), r = D_(e, c.rowheaders, h, p, m, -T_(f, "rowHeader"), S_, 0, d, "x1", 0, p, 1, u)), c.colheaders && (u = T_(n.headerBand, r_, null), i = D_(e, c.colheaders, h, p, p, -T_(f, "columnHeader"), S_, 1, d, "y1", 0, 1, p, u)), c.rowfooters && (u = T_(n.footerBand, i_, null), a = D_(e, c.rowfooters, h, p, m, T_(f, "rowFooter"), __, 0, d, "x2", p - 1, p, 1, u)), c.colfooters && (u = T_(n.footerBand, r_, null), o = D_(e, c.colfooters, h, p, p, T_(f, "columnFooter"), __, 1, d, "y2", g - p, 1, p, u)), c.rowtitle && (s = T_(n.titleAnchor, i_), l = T_(f, "rowTitle"), l = s === OS ? a + l : r - l, u = T_(n.titleBand, i_, .5), $_(e, c.rowtitle, l, 0, y, u)), c.coltitle && (s = T_(n.titleAnchor, r_), l = T_(f, "columnTitle"), l = s === OS ? o + l : i - l, u = T_(n.titleBand, r_, .5), $_(e, c.coltitle, l, 1, y, u)) } function M_(e, t) { return "x1" === t ? e.x || 0 : "y1" === t ? e.y || 0 : "x2" === t ? (e.x || 0) + (e.width || 0) : "y2" === t ? (e.y || 0) + (e.height || 0) : void 0 } function F_(e, t) { return e.bounds[t] } function D_(e, t, n, r, i, a, o, s, u, l, c, h, d, f) { var p, m, g, y, b, v, x, w, k, S = n.length, _ = 0, C = 0; if (!S) return _; for (p = c; p < S; p += h)n[p] && (_ = o(_, u(n[p], l))); if (!t.length) return _; for (t.length > i && (e.warn("Grid headers exceed limit: " + i), t = t.slice(0, i)), _ += a, m = 0, y = t.length; m < y; ++m)e.dirty(t[m]), t[m].mark.bounds.clear(); for (p = c, m = 0, y = t.length; m < y; ++m, p += h) { for (b = (v = t[m]).mark.bounds, g = p; g >= 0 && null == (x = n[g]); g -= d); s ? (w = null == f ? x.x : Math.round(x.bounds.x1 + f * x.bounds.width()), k = _) : (w = _, k = null == f ? x.y : Math.round(x.bounds.y1 + f * x.bounds.height())), b.union(v.bounds.translate(w - (v.x || 0), k - (v.y || 0))), v.x = w, v.y = k, e.dirty(v), C = o(C, b[l]) } return C } function $_(e, t, n, r, i, a) { if (t) { e.dirty(t); var o = n, s = n; r ? o = Math.round(i.x1 + a * i.width()) : s = Math.round(i.y1 + a * i.height()), t.bounds.translate(o - (t.x || 0), s - (t.y || 0)), t.mark.bounds.clear().union(t.bounds), t.x = o, t.y = s, e.dirty(t) } } function R_(e, t, n, r, i, a, o) { const s = function (e, t) { const n = e[t] || {}; return (t, r) => null != n[t] ? n[t] : null != e[t] ? e[t] : r }(n, t), u = function (e, t) { let n = -1 / 0; return e.forEach((e => { null != e.offset && (n = Math.max(n, e.offset)) })), n > -1 / 0 ? n : t }(e, s("offset", 0)), l = s("anchor", $S), c = l === OS ? 1 : l === RS ? .5 : 0, h = { align: t_, bounds: s("bounds", n_), columns: "vertical" === s("direction") ? 1 : e.length, padding: s("margin", 8), center: s("center"), nodirty: !0 }; switch (t) { case MS: h.anchor = { x: Math.floor(r.x1) - u, column: OS, y: c * (o || r.height() + 2 * r.y1), row: l }; break; case FS: h.anchor = { x: Math.ceil(r.x2) + u, y: c * (o || r.height() + 2 * r.y1), row: l }; break; case IS: h.anchor = { y: Math.floor(i.y1) - u, row: OS, x: c * (a || i.width() + 2 * i.x1), column: l }; break; case DS: h.anchor = { y: Math.ceil(i.y2) + u, x: c * (a || i.width() + 2 * i.x1), column: l }; break; case "top-left": h.anchor = { x: u, y: u }; break; case "top-right": h.anchor = { x: a - u, y: u, column: OS }; break; case "bottom-left": h.anchor = { x: u, y: o - u, row: OS }; break; case "bottom-right": h.anchor = { x: a - u, y: o - u, column: OS, row: OS } }return h } function O_(e, t) { var n, r, i = t.items[0], a = i.datum, o = i.orient, s = i.bounds, u = i.x, l = i.y; return i._bounds ? i._bounds.clear().union(s) : i._bounds = s.clone(), s.clear(), function (e, t, n) { var r = t.padding, i = r - n.x, a = r - n.y; if (t.datum.title) { var o = t.items[1].items[0], s = o.anchor, u = t.titlePadding || 0, l = r - o.x, c = r - o.y; switch (o.orient) { case MS: i += Math.ceil(o.bounds.width()) + u; break; case FS: case DS: break; default: a += o.bounds.height() + u }switch ((i || a) && P_(e, n, i, a), o.orient) { case MS: c += z_(t, n, o, s, 1, 1); break; case FS: l += z_(t, n, o, OS, 0, 0) + u, c += z_(t, n, o, s, 1, 1); break; case DS: l += z_(t, n, o, s, 0, 0), c += z_(t, n, o, OS, -1, 0, 1) + u; break; default: l += z_(t, n, o, s, 0, 0) }(l || c) && P_(e, o, l, c), (l = Math.round(o.bounds.x1 - r)) < 0 && (P_(e, n, -l, 0), P_(e, o, -l, 0)) } else (i || a) && P_(e, n, i, a) }(e, i, i.items[0].items[0]), s = function (e, t) { return e.items.forEach((e => t.union(e.bounds))), t.x1 = e.padding, t.y1 = e.padding, t }(i, s), n = 2 * i.padding, r = 2 * i.padding, s.empty() || (n = Math.ceil(s.width() + n), r = Math.ceil(s.height() + r)), "symbol" === a.type && function (e) { const t = e.reduce(((e, t) => (e[t.column] = Math.max(t.bounds.x2 - t.x, e[t.column] || 0), e)), {}); e.forEach((e => { e.width = t[e.column], e.height = e.bounds.y2 - e.y })) }(i.items[0].items[0].items[0].items), o !== QS && (i.x = u = 0, i.y = l = 0), i.width = n, i.height = r, Qv(s.set(u, l, u + n, l + r), i), i.mark.bounds.clear().union(s), i } function z_(e, t, n, r, i, a, o) { const s = "symbol" !== e.datum.type, u = n.datum.vgrad, l = (!s || !a && u || o ? t : t.items[0]).bounds[i ? "y2" : "x2"] - e.padding, c = u && a ? l : 0, h = u && a ? 0 : l, d = i <= 0 ? 0 : Fw(n); return Math.round(r === $S ? c : r === OS ? h - d : .5 * (l - d)) } function P_(e, t, n, r) { t.x += n, t.y += r, t.bounds.translate(n, r), t.mark.bounds.translate(n, r), e.dirty(t) } function B_(e) { Eu.call(this, null, e) } function L_(e, t) { let n = 0; if (void 0 === t) for (let t of e) (t = +t) && (n += t); else { let r = -1; for (let i of e) (i = +t(i, ++r, e)) && (n += i) } return n } function j_(e, t) { return e = +e, t = +t, function (n) { return Math.round(e * (1 - n) + t * n) } } function U_(e, t, n) { e.prototype = t.prototype = n, n.constructor = e } function W_(e, t) { var n = Object.create(e.prototype); for (var r in t) n[r] = t[r]; return n } function V_() { } Ln(B_, Eu, { transform(e, t) { const n = t.dataflow; return e.mark.items.forEach((t => { e.layout && I_(n, t, e.layout), function (e, t, n) { var r, i, a, o, s, u = t.items, l = Math.max(0, t.width || 0), c = Math.max(0, t.height || 0), h = (new qv).set(0, 0, l, c), d = h.clone(), f = h.clone(), p = []; for (o = 0, s = u.length; o < s; ++o)switch ((i = u[o]).role) { case PS: (x_(i) ? d : f).union(w_(e, i, l, c)); break; case BS: r = i; break; case US: p.push(O_(e, i)); break; case LS: case jS: case WS: case VS: case GS: case HS: case qS: case YS: d.union(i.bounds), f.union(i.bounds); break; default: h.union(i.bounds) }if (p.length) { const t = {}; p.forEach((e => { (a = e.orient || FS) !== QS && (t[a] || (t[a] = [])).push(e) })); for (const r in t) { const i = t[r]; N_(e, i, R_(i, r, n.legends, d, f, l, c)) } p.forEach((t => { const r = t.bounds; if (r.equals(t._bounds) || (t.bounds = t._bounds, e.dirty(t), t.bounds = r, e.dirty(t)), !n.autosize || n.autosize.type !== KS && n.autosize.type !== ZS && n.autosize.type !== JS) h.union(r); else switch (t.orient) { case MS: case FS: h.add(r.x1, 0).add(r.x2, 0); break; case IS: case DS: h.add(0, r.y1).add(0, r.y2) } })) } h.union(d).union(f), r && h.union(function (e, t, n, r, i) { var a, o = t.items[0], s = o.frame, u = o.orient, l = o.anchor, c = o.offset, h = o.padding, d = o.items[0].items[0], f = o.items[1] && o.items[1].items[0], p = u === MS || u === FS ? r : n, m = 0, g = 0, y = 0, b = 0, v = 0; if (s !== zS ? u === MS ? (m = i.y2, p = i.y1) : u === FS ? (m = i.y1, p = i.y2) : (m = i.x1, p = i.x2) : u === MS && (m = r, p = 0), a = l === $S ? m : l === OS ? p : (m + p) / 2, f && f.text) { switch (u) { case IS: case DS: v = d.bounds.height() + h; break; case MS: b = d.bounds.width() + h; break; case FS: b = -d.bounds.width() - h }b_.clear().union(f.bounds), b_.translate(b - (f.x || 0), v - (f.y || 0)), v_(f, "x", b) | v_(f, "y", v) && (e.dirty(f), f.bounds.clear().union(b_), f.mark.bounds.clear().union(b_), e.dirty(f)), b_.clear().union(f.bounds) } else b_.clear(); switch (b_.union(d.bounds), u) { case IS: g = a, y = i.y1 - b_.height() - c; break; case MS: g = i.x1 - b_.width() - c, y = a; break; case FS: g = i.x2 + b_.width() + c, y = a; break; case DS: g = a, y = i.y2 + c; break; default: g = o.x, y = o.y }return v_(o, "x", g) | v_(o, "y", y) && (b_.translate(g, y), e.dirty(o), o.bounds.clear().union(b_), t.bounds.clear().union(b_), e.dirty(o)), o.bounds }(e, r, l, c, h)); t.clip && h.set(0, 0, t.width || 0, t.height || 0); !function (e, t, n, r) { const i = r.autosize || {}, a = i.type; if (e._autosize < 1 || !a) return; let o = e._width, s = e._height, u = Math.max(0, t.width || 0), l = Math.max(0, Math.ceil(-n.x1)), c = Math.max(0, t.height || 0), h = Math.max(0, Math.ceil(-n.y1)); const d = Math.max(0, Math.ceil(n.x2 - u)), f = Math.max(0, Math.ceil(n.y2 - c)); if (i.contains === XS) { const t = e.padding(); o -= t.left + t.right, s -= t.top + t.bottom } a === QS ? (l = 0, h = 0, u = o, c = s) : a === KS ? (u = Math.max(0, o - l - d), c = Math.max(0, s - h - f)) : a === ZS ? (u = Math.max(0, o - l - d), s = c + h + f) : a === JS ? (o = u + l + d, c = Math.max(0, s - h - f)) : "pad" === a && (o = u + l + d, s = c + h + f); e._resizeView(o, s, u, c, [l, h], i.resize) }(e, t, h, n) }(n, t, e) })), function (e) { return e && "legend-entry" !== e.mark.role }(e.mark.group) ? t.reflow() : t } }); var G_ = .7, H_ = 1.4285714285714286, q_ = "\\s*([+-]?\\d+)\\s*", Y_ = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*", X_ = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*", K_ = /^#([0-9a-f]{3,8})$/, Z_ = new RegExp("^rgb\\(" + [q_, q_, q_] + "\\)$"), J_ = new RegExp("^rgb\\(" + [X_, X_, X_] + "\\)$"), Q_ = new RegExp("^rgba\\(" + [q_, q_, q_, Y_] + "\\)$"), eC = new RegExp("^rgba\\(" + [X_, X_, X_, Y_] + "\\)$"), tC = new RegExp("^hsl\\(" + [Y_, X_, X_] + "\\)$"), nC = new RegExp("^hsla\\(" + [Y_, X_, X_, Y_] + "\\)$"), rC = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; function iC() { return this.rgb().formatHex() } function aC() { return this.rgb().formatRgb() } function oC(e) { var t, n; return e = (e + "").trim().toLowerCase(), (t = K_.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), 6 === n ? sC(t) : 3 === n ? new hC(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, (15 & t) << 4 | 15 & t, 1) : 8 === n ? uC(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (255 & t) / 255) : 4 === n ? uC(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, ((15 & t) << 4 | 15 & t) / 255) : null) : (t = Z_.exec(e)) ? new hC(t[1], t[2], t[3], 1) : (t = J_.exec(e)) ? new hC(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, 1) : (t = Q_.exec(e)) ? uC(t[1], t[2], t[3], t[4]) : (t = eC.exec(e)) ? uC(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, t[4]) : (t = tC.exec(e)) ? mC(t[1], t[2] / 100, t[3] / 100, 1) : (t = nC.exec(e)) ? mC(t[1], t[2] / 100, t[3] / 100, t[4]) : rC.hasOwnProperty(e) ? sC(rC[e]) : "transparent" === e ? new hC(NaN, NaN, NaN, 0) : null } function sC(e) { return new hC(e >> 16 & 255, e >> 8 & 255, 255 & e, 1) } function uC(e, t, n, r) { return r <= 0 && (e = t = n = NaN), new hC(e, t, n, r) } function lC(e) { return e instanceof V_ || (e = oC(e)), e ? new hC((e = e.rgb()).r, e.g, e.b, e.opacity) : new hC } function cC(e, t, n, r) { return 1 === arguments.length ? lC(e) : new hC(e, t, n, null == r ? 1 : r) } function hC(e, t, n, r) { this.r = +e, this.g = +t, this.b = +n, this.opacity = +r } function dC() { return "#" + pC(this.r) + pC(this.g) + pC(this.b) } function fC() { var e = this.opacity; return (1 === (e = isNaN(e) ? 1 : Math.max(0, Math.min(1, e))) ? "rgb(" : "rgba(") + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.b) || 0)) + (1 === e ? ")" : ", " + e + ")") } function pC(e) { return ((e = Math.max(0, Math.min(255, Math.round(e) || 0))) < 16 ? "0" : "") + e.toString(16) } function mC(e, t, n, r) { return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new bC(e, t, n, r) } function gC(e) { if (e instanceof bC) return new bC(e.h, e.s, e.l, e.opacity); if (e instanceof V_ || (e = oC(e)), !e) return new bC; if (e instanceof bC) return e; var t = (e = e.rgb()).r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, u = (a + i) / 2; return s ? (o = t === a ? (n - r) / s + 6 * (n < r) : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= u < .5 ? a + i : 2 - a - i, o *= 60) : s = u > 0 && u < 1 ? 0 : o, new bC(o, s, u, e.opacity) } function yC(e, t, n, r) { return 1 === arguments.length ? gC(e) : new bC(e, t, n, null == r ? 1 : r) } function bC(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function vC(e, t, n) { return 255 * (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) } function xC(e, t, n, r, i) { var a = e * e, o = a * e; return ((1 - 3 * e + 3 * a - o) * t + (4 - 6 * a + 3 * o) * n + (1 + 3 * e + 3 * a - 3 * o) * r + o * i) / 6 } function wC(e) { var t = e.length - 1; return function (n) { var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], a = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - a, s = r < t - 1 ? e[r + 2] : 2 * a - i; return xC((n - r / t) * t, o, i, a, s) } } function kC(e) { var t = e.length; return function (n) { var r = Math.floor(((n %= 1) < 0 ? ++n : n) * t), i = e[(r + t - 1) % t], a = e[r % t], o = e[(r + 1) % t], s = e[(r + 2) % t]; return xC((n - r / t) * t, i, a, o, s) } } U_(V_, oC, { copy: function (e) { return Object.assign(new this.constructor, this, e) }, displayable: function () { return this.rgb().displayable() }, hex: iC, formatHex: iC, formatHsl: function () { return gC(this).formatHsl() }, formatRgb: aC, toString: aC }), U_(hC, cC, W_(V_, { brighter: function (e) { return e = null == e ? H_ : Math.pow(H_, e), new hC(this.r * e, this.g * e, this.b * e, this.opacity) }, darker: function (e) { return e = null == e ? G_ : Math.pow(G_, e), new hC(this.r * e, this.g * e, this.b * e, this.opacity) }, rgb: function () { return this }, displayable: function () { return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1 }, hex: dC, formatHex: dC, formatRgb: fC, toString: fC })), U_(bC, yC, W_(V_, { brighter: function (e) { return e = null == e ? H_ : Math.pow(H_, e), new bC(this.h, this.s, this.l * e, this.opacity) }, darker: function (e) { return e = null == e ? G_ : Math.pow(G_, e), new bC(this.h, this.s, this.l * e, this.opacity) }, rgb: function () { var e = this.h % 360 + 360 * (this.h < 0), t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r; return new hC(vC(e >= 240 ? e - 240 : e + 120, i, r), vC(e, i, r), vC(e < 120 ? e + 240 : e - 120, i, r), this.opacity) }, displayable: function () { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1 }, formatHsl: function () { var e = this.opacity; return (1 === (e = isNaN(e) ? 1 : Math.max(0, Math.min(1, e))) ? "hsl(" : "hsla(") + (this.h || 0) + ", " + 100 * (this.s || 0) + "%, " + 100 * (this.l || 0) + "%" + (1 === e ? ")" : ", " + e + ")") } })); const SC = e => () => e; function _C(e, t) { return function (n) { return e + n * t } } function CC(e, t) { var n = t - e; return n ? _C(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : SC(isNaN(e) ? t : e) } function AC(e) { return 1 == (e = +e) ? TC : function (t, n) { return n - t ? function (e, t, n) { return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function (r) { return Math.pow(e + r * t, n) } }(t, n, e) : SC(isNaN(t) ? n : t) } } function TC(e, t) { var n = t - e; return n ? _C(e, n) : SC(isNaN(e) ? t : e) } const EC = function e(t) { var n = AC(t); function r(e, t) { var r = n((e = cC(e)).r, (t = cC(t)).r), i = n(e.g, t.g), a = n(e.b, t.b), o = TC(e.opacity, t.opacity); return function (t) { return e.r = r(t), e.g = i(t), e.b = a(t), e.opacity = o(t), e + "" } } return r.gamma = e, r }(1); function NC(e) { return function (t) { var n, r, i = t.length, a = new Array(i), o = new Array(i), s = new Array(i); for (n = 0; n < i; ++n)r = cC(t[n]), a[n] = r.r || 0, o[n] = r.g || 0, s[n] = r.b || 0; return a = e(a), o = e(o), s = e(s), r.opacity = 1, function (e) { return r.r = a(e), r.g = o(e), r.b = s(e), r + "" } } } var IC = NC(wC), MC = NC(kC); function FC(e, t) { t || (t = []); var n, r = e ? Math.min(t.length, e.length) : 0, i = t.slice(); return function (a) { for (n = 0; n < r; ++n)i[n] = e[n] * (1 - a) + t[n] * a; return i } } function DC(e) { return ArrayBuffer.isView(e) && !(e instanceof DataView) } function $C(e, t) { return (DC(t) ? FC : RC)(e, t) } function RC(e, t) { var n, r = t ? t.length : 0, i = e ? Math.min(r, e.length) : 0, a = new Array(i), o = new Array(r); for (n = 0; n < i; ++n)a[n] = UC(e[n], t[n]); for (; n < r; ++n)o[n] = t[n]; return function (e) { for (n = 0; n < i; ++n)o[n] = a[n](e); return o } } function OC(e, t) { var n = new Date; return e = +e, t = +t, function (r) { return n.setTime(e * (1 - r) + t * r), n } } function zC(e, t) { return e = +e, t = +t, function (n) { return e * (1 - n) + t * n } } function PC(e, t) { var n, r = {}, i = {}; for (n in null !== e && "object" == typeof e || (e = {}), null !== t && "object" == typeof t || (t = {}), t) n in e ? r[n] = UC(e[n], t[n]) : i[n] = t[n]; return function (e) { for (n in r) i[n] = r[n](e); return i } } var BC = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, LC = new RegExp(BC.source, "g"); function jC(e, t) { var n, r, i, a = BC.lastIndex = LC.lastIndex = 0, o = -1, s = [], u = []; for (e += "", t += ""; (n = BC.exec(e)) && (r = LC.exec(t));)(i = r.index) > a && (i = t.slice(a, i), s[o] ? s[o] += i : s[++o] = i), (n = n[0]) === (r = r[0]) ? s[o] ? s[o] += r : s[++o] = r : (s[++o] = null, u.push({ i: o, x: zC(n, r) })), a = LC.lastIndex; return a < t.length && (i = t.slice(a), s[o] ? s[o] += i : s[++o] = i), s.length < 2 ? u[0] ? function (e) { return function (t) { return e(t) + "" } }(u[0].x) : function (e) { return function () { return e } }(t) : (t = u.length, function (e) { for (var n, r = 0; r < t; ++r)s[(n = u[r]).i] = n.x(e); return s.join("") }) } function UC(e, t) { var n, r = typeof t; return null == t || "boolean" === r ? SC(t) : ("number" === r ? zC : "string" === r ? (n = oC(t)) ? (t = n, EC) : jC : t instanceof oC ? EC : t instanceof Date ? OC : DC(t) ? FC : Array.isArray(t) ? RC : "function" != typeof t.valueOf && "function" != typeof t.toString || isNaN(t) ? PC : zC)(e, t) } function WC(e) { Eu.call(this, null, e) } function VC(e) { Eu.call(this, null, e) } function GC() { return Zs({}) } function HC(e) { Eu.call(this, null, e) } function qC(e) { Eu.call(this, [], e) } Ln(WC, Eu, { transform(e, t) { if (this.value && !e.modified()) return t.StopPropagation; var n = t.dataflow.locale(), r = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = this.value, a = e.scale, o = $b(a, null == e.count ? e.values ? e.values.length : 10 : e.count, e.minstep), s = e.format || zb(n, a, o, e.formatSpecifier, e.formatType, !!e.values), u = e.values ? Rb(a, e.values, o) : Ob(a, o); return i && (r.rem = i), i = u.map(((e, t) => Zs({ index: t / (u.length - 1 || 1), value: e, label: s(e) }))), e.extra && i.length && i.push(Zs({ index: -1, extra: { value: i[0].value }, label: "" })), r.source = i, r.add = i, this.value = i, r } }), Ln(VC, Eu, { transform(e, t) { var n = t.dataflow, r = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = e.item || GC, a = e.key || Xs, o = this.value; return on(r.encode) && (r.encode = null), o && (e.modified("key") || t.modified(a)) && Vt("DataJoin does not support modified key function or fields."), o || (t = t.addAll(), this.value = o = function (e) { const t = Bn().test((e => e.exit)); return t.lookup = n => t.get(e(n)), t }(a)), t.visit(t.ADD, (e => { const t = a(e); let n = o.get(t); n ? n.exit ? (o.empty--, r.add.push(n)) : r.mod.push(n) : (n = i(e), o.set(t, n), r.add.push(n)), n.datum = e, n.exit = !1 })), t.visit(t.MOD, (e => { const t = a(e), n = o.get(t); n && (n.datum = e, r.mod.push(n)) })), t.visit(t.REM, (e => { const t = a(e), n = o.get(t); e !== n.datum || n.exit || (r.rem.push(n), n.exit = !0, ++o.empty) })), t.changed(t.ADD_MOD) && r.modifies("datum"), (t.clean() || e.clean && o.empty > n.cleanThreshold) && n.runAfter(o.clean), r } }), Ln(HC, Eu, { transform(e, t) { var n = t.fork(t.ADD_REM), r = e.mod || !1, i = e.encoders, a = t.encode; if (on(a)) { if (!n.changed() && !a.every((e => i[e]))) return t.StopPropagation; a = a[0], n.encode = null } var o = "enter" === a, s = i.update || Jt, u = i.enter || Jt, l = i.exit || Jt, c = (a && !o ? i[a] : s) || Jt; if (t.changed(t.ADD) && (t.visit(t.ADD, (t => { u(t, e), s(t, e) })), n.modifies(u.output), n.modifies(s.output), c !== Jt && c !== s && (t.visit(t.ADD, (t => { c(t, e) })), n.modifies(c.output))), t.changed(t.REM) && l !== Jt && (t.visit(t.REM, (t => { l(t, e) })), n.modifies(l.output)), o || c !== Jt) { const i = t.MOD | (e.modified() ? t.REFLOW : 0); o ? (t.visit(i, (t => { const i = u(t, e) || r; (c(t, e) || i) && n.mod.push(t) })), n.mod.length && n.modifies(u.output)) : t.visit(i, (t => { (c(t, e) || r) && n.mod.push(t) })), n.mod.length && n.modifies(c.output) } return n.changed() ? n : t.StopPropagation } }), Ln(qC, Eu, { transform(e, t) { if (null != this.value && !e.modified()) return t.StopPropagation; var n, r, i, a, o, s = t.dataflow.locale(), u = t.fork(t.NO_SOURCE | t.NO_FIELDS), l = this.value, c = e.type || Ib, h = e.scale, d = +e.limit, f = $b(h, null == e.count ? 5 : e.count, e.minstep), p = !!e.values || c === Ib, m = e.format || Ub(s, h, f, c, e.formatSpecifier, e.formatType, p), g = e.values || jb(h, f); return l && (u.rem = l), c === Ib ? (d && g.length > d ? (t.dataflow.warn("Symbol legend count exceeds limit, filtering items."), l = g.slice(0, d - 1), o = !0) : l = g, Cn(i = e.size) ? (e.values || 0 !== h(l[0]) || (l = l.slice(1)), a = l.reduce(((t, n) => Math.max(t, i(n, e))), 0)) : i = Fn(a = i || 8), l = l.map(((t, n) => Zs({ index: n, label: m(t, n, l), value: t, offset: a, size: i(t, e) }))), o && (o = g[l.length], l.push(Zs({ index: l.length, label: "…".concat(g.length - l.length, " entries"), value: o, offset: a, size: i(o, e) })))) : "gradient" === c ? (n = h.domain(), r = _b(h, n[0], hn(n)), g.length < 3 && !e.values && n[0] !== hn(n) && (g = [n[0], hn(n)]), l = g.map(((e, t) => Zs({ index: t, label: m(e, t, g), value: e, perc: r(e) })))) : (i = g.length - 1, r = function (e) { const t = e.domain(), n = t.length - 1; let r = +t[0], i = +hn(t), a = i - r; if (e.type === Ky) { const e = n ? a / n : .1; r -= e, i += e, a = i - r } return e => (e - r) / a }(h), l = g.map(((e, t) => Zs({ index: t, label: m(e, t, g), value: e, perc: t ? r(e) : 0, perc2: t === i ? 1 : r(g[t + 1]) })))), u.source = l, u.add = l, this.value = l, u } }); const YC = e => e.source.x, XC = e => e.source.y, KC = e => e.target.x, ZC = e => e.target.y; function JC(e) { Eu.call(this, {}, e) } JC.Definition = { type: "LinkPath", metadata: { modifies: !0 }, params: [{ name: "sourceX", type: "field", default: "source.x" }, { name: "sourceY", type: "field", default: "source.y" }, { name: "targetX", type: "field", default: "target.x" }, { name: "targetY", type: "field", default: "target.y" }, { name: "orient", type: "enum", default: "vertical", values: ["horizontal", "vertical", "radial"] }, { name: "shape", type: "enum", default: "line", values: ["line", "arc", "curve", "diagonal", "orthogonal"] }, { name: "require", type: "signal" }, { name: "as", type: "string", default: "path" }] }, Ln(JC, Eu, { transform(e, t) { var n = e.sourceX || YC, r = e.sourceY || XC, i = e.targetX || KC, a = e.targetY || ZC, o = e.as || "path", s = e.orient || "vertical", u = e.shape || "line", l = nA.get(u + "-" + s) || nA.get(u); return l || Vt("LinkPath unsupported type: " + e.shape + (e.orient ? "-" + e.orient : "")), t.visit(t.SOURCE, (e => { e[o] = l(n(e), r(e), i(e), a(e)) })), t.reflow(e.modified()).modifies(o) } }); const QC = (e, t, n, r) => "M" + e + "," + t + "L" + n + "," + r, eA = (e, t, n, r) => { var i = n - e, a = r - t, o = Math.sqrt(i * i + a * a) / 2; return "M" + e + "," + t + "A" + o + "," + o + " " + 180 * Math.atan2(a, i) / Math.PI + " 0 1 " + n + "," + r }, tA = (e, t, n, r) => { const i = n - e, a = r - t, o = .2 * (i + a), s = .2 * (a - i); return "M" + e + "," + t + "C" + (e + o) + "," + (t + s) + " " + (n + s) + "," + (r - o) + " " + n + "," + r }, nA = Bn({ line: QC, "line-radial": (e, t, n, r) => QC(t * Math.cos(e), t * Math.sin(e), r * Math.cos(n), r * Math.sin(n)), arc: eA, "arc-radial": (e, t, n, r) => eA(t * Math.cos(e), t * Math.sin(e), r * Math.cos(n), r * Math.sin(n)), curve: tA, "curve-radial": (e, t, n, r) => tA(t * Math.cos(e), t * Math.sin(e), r * Math.cos(n), r * Math.sin(n)), "orthogonal-horizontal": (e, t, n, r) => "M" + e + "," + t + "V" + r + "H" + n, "orthogonal-vertical": (e, t, n, r) => "M" + e + "," + t + "H" + n + "V" + r, "orthogonal-radial": (e, t, n, r) => { const i = Math.cos(e), a = Math.sin(e), o = Math.cos(n), s = Math.sin(n); return "M" + t * i + "," + t * a + "A" + t + "," + t + " 0 0," + ((Math.abs(n - e) > Math.PI ? n <= e : n > e) ? 1 : 0) + " " + t * o + "," + t * s + "L" + r * o + "," + r * s }, "diagonal-horizontal": (e, t, n, r) => { const i = (e + n) / 2; return "M" + e + "," + t + "C" + i + "," + t + " " + i + "," + r + " " + n + "," + r }, "diagonal-vertical": (e, t, n, r) => { const i = (t + r) / 2; return "M" + e + "," + t + "C" + e + "," + i + " " + n + "," + i + " " + n + "," + r }, "diagonal-radial": (e, t, n, r) => { const i = Math.cos(e), a = Math.sin(e), o = Math.cos(n), s = Math.sin(n), u = (t + r) / 2; return "M" + t * i + "," + t * a + "C" + u * i + "," + u * a + " " + u * o + "," + u * s + " " + r * o + "," + r * s } }); function rA(e) { Eu.call(this, null, e) } rA.Definition = { type: "Pie", metadata: { modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "startAngle", type: "number", default: 0 }, { name: "endAngle", type: "number", default: 6.283185307179586 }, { name: "sort", type: "boolean", default: !1 }, { name: "as", type: "string", array: !0, length: 2, default: ["startAngle", "endAngle"] }] }, Ln(rA, Eu, { transform(e, t) { var n, r, i, a = e.as || ["startAngle", "endAngle"], o = a[0], s = a[1], u = e.field || Kt, l = e.startAngle || 0, c = null != e.endAngle ? e.endAngle : 2 * Math.PI, h = t.source, d = h.map(u), f = d.length, p = l, m = (c - l) / L_(d), g = Fl(f); for (e.sort && g.sort(((e, t) => d[e] - d[t])), n = 0; n < f; ++n)i = d[g[n]], (r = h[g[n]])[o] = p, r[s] = p += i * m; return this.value = d, t.reflow(e.modified()).modifies(a) } }); function iA(e) { return gb(e) && e !== Hy } const aA = Qn(["set", "modified", "clear", "type", "scheme", "schemeExtent", "schemeCount", "domain", "domainMin", "domainMid", "domainMax", "domainRaw", "domainImplicit", "nice", "zero", "bins", "range", "rangeStep", "round", "reverse", "interpolate", "interpolateGamma"]); function oA(e) { Eu.call(this, null, e), this.modified(!0) } function sA(e, t, n) { vb(e) && (Math.abs(t.reduce(((e, t) => e + (t < 0 ? -1 : t > 0 ? 1 : 0)), 0)) !== t.length && n.warn("Log scale domain includes zero: " + Yn(t))); return t } function uA(e, t, n) { return Cn(e) && (t || n) ? function (e, t) { const n = t[0], r = hn(t) - n; return function (t) { return e(n + t * r) } }(e, lA(t || [0, 1], n)) : e } function lA(e, t) { return t ? e.slice().reverse() : e } function cA(e) { Eu.call(this, null, e) } Ln(oA, Eu, { transform(e, t) { var n = t.dataflow, r = this.value, i = function (e) { var t, n = e.type, r = ""; if (n === Hy) return Hy + "-" + By; (function (e) { const t = e.type; return gb(t) && t !== Vy && t !== Gy && (e.scheme || e.range && e.range.length && e.range.every(Vn)) })(e) && (r = 2 === (t = e.rawDomain ? e.rawDomain.length : e.domain ? e.domain.length + +(null != e.domainMid) : 0) ? Hy + "-" : 3 === t ? qy + "-" : ""); return (r + n || By).toLowerCase() }(e); for (i in r && i === r.type || (this.value = r = fb(i)()), e) if (!aA[i]) { if ("padding" === i && iA(r.type)) continue; Cn(r[i]) ? r[i](e[i]) : n.warn("Unsupported scale property: " + i) } return function (e, t, n) { var r = e.type, i = t.round || !1, a = t.range; if (null != t.rangeStep) a = function (e, t, n) { e !== Qy && e !== Jy && Vt("Only band and point scales support rangeStep."); var r = (null != t.paddingOuter ? t.paddingOuter : t.padding) || 0, i = e === Jy ? 1 : (null != t.paddingInner ? t.paddingInner : t.padding) || 0; return [0, t.rangeStep * Py(n, i, r)] }(r, t, n); else if (t.scheme && (a = function (e, t, n) { var r, i = t.schemeExtent; on(t.scheme) ? r = Sb(t.scheme, t.interpolate, t.interpolateGamma) : (r = Nb(t.scheme.toLowerCase())) || Vt("Unrecognized scheme name: ".concat(t.scheme)); return n = e === Ky ? n + 1 : e === eb ? n - 1 : e === Yy || e === Xy ? +t.schemeCount || 5 : n, xb(e) ? uA(r, i, t.reverse) : Cn(r) ? function (e, t) { const n = new Array(t), r = t + 1; for (let i = 0; i < t;)n[i] = e(++i / r); return n }(uA(r, i), n) : e === Zy ? r : r.slice(0, n) }(r, t, n), Cn(a))) { if (e.interpolator) return e.interpolator(a); Vt("Scale type ".concat(r, " does not support interpolating color schemes.")) } if (a && xb(r)) return e.interpolator(Sb(lA(a, t.reverse), t.interpolate, t.interpolateGamma)); a && t.interpolate && e.interpolate ? e.interpolate(Cb(t.interpolate, t.interpolateGamma)) : Cn(e.round) ? e.round(i) : Cn(e.rangeRound) && e.interpolate(i ? j_ : UC); a && e.range(lA(a, t.reverse)) }(r, e, function (e, t, n) { let r = t.bins; if (r && !on(r)) { const t = e.domain(), n = t[0], i = hn(t), a = r.step; let o = null == r.start ? n : r.start, s = null == r.stop ? i : r.stop; a || Vt("Scale bins parameter missing step property."), o < n && (o = a * Math.ceil(n / a)), s > i && (s = a * Math.floor(i / a)), r = Fl(o, s + a / 2, a) } r ? e.bins = r : e.bins && delete e.bins; e.type === eb && (r ? t.domain || t.domainRaw || (e.domain(r), n = r.length) : e.bins = e.domain()); return n }(r, e, function (e, t, n) { const r = function (e, t, n) { return t ? (e.domain(sA(e.type, t, n)), t.length) : -1 }(e, t.domainRaw, n); if (r > -1) return r; var i, a, o = t.domain, s = e.type, u = t.zero || void 0 === t.zero && function (e) { const t = e.type; return !e.bins && (t === By || t === jy || t === Uy) }(e); if (!o) return 0; iA(s) && t.padding && o[0] !== hn(o) && (o = function (e, t, n, r, i, a) { var o = Math.abs(hn(n) - n[0]), s = o / (o - 2 * r), u = e === Ly ? wn(t, null, s) : e === Uy ? kn(t, null, s, .5) : e === jy ? kn(t, null, s, i || 1) : e === Wy ? Sn(t, null, s, a || 1) : xn(t, null, s); return t = t.slice(), t[0] = u[0], t[t.length - 1] = u[1], t }(s, o, t.range, t.padding, t.exponent, t.constant)); if ((u || null != t.domainMin || null != t.domainMax || null != t.domainMid) && (i = (o = o.slice()).length - 1 || 1, u && (o[0] > 0 && (o[0] = 0), o[i] < 0 && (o[i] = 0)), null != t.domainMin && (o[0] = t.domainMin), null != t.domainMax && (o[i] = t.domainMax), null != t.domainMid)) { const e = (a = t.domainMid) > o[i] ? i + 1 : a < o[0] ? 0 : i; e !== i && n.warn("Scale domainMid exceeds domain min or max.", a), o.splice(e, 0, a) } e.domain(sA(s, o, n)), s === Zy && e.unknown(t.domainImplicit ? xm : void 0); t.nice && e.nice && e.nice(!0 !== t.nice && $b(e, t.nice) || null); return o.length }(r, e, n))), t.fork(t.NO_SOURCE | t.NO_FIELDS) } }), Ln(cA, Eu, { transform(e, t) { const n = e.modified("sort") || t.changed(t.ADD) || t.modified(e.sort.fields) || t.modified("datum"); return n && t.source.sort(tu(e.sort)), this.modified(n), t } }); const hA = "zero", dA = "center", fA = "normalize", pA = ["y0", "y1"]; function mA(e) { Eu.call(this, null, e) } function gA(e, t, n, r, i) { for (var a, o = (t - e.sum) / 2, s = e.length, u = 0; u < s; ++u)(a = e[u])[r] = o, a[i] = o += Math.abs(n(a)) } function yA(e, t, n, r, i) { for (var a, o = 1 / e.sum, s = 0, u = e.length, l = 0, c = 0; l < u; ++l)(a = e[l])[r] = s, a[i] = s = o * (c += Math.abs(n(a))) } function bA(e, t, n, r, i) { for (var a, o, s = 0, u = 0, l = e.length, c = 0; c < l; ++c)(a = +n(o = e[c])) < 0 ? (o[r] = u, o[i] = u += a) : (o[r] = s, o[i] = s += a) } mA.Definition = { type: "Stack", metadata: { modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "groupby", type: "field", array: !0 }, { name: "sort", type: "compare" }, { name: "offset", type: "enum", default: hA, values: [hA, dA, fA] }, { name: "as", type: "string", array: !0, length: 2, default: pA }] }, Ln(mA, Eu, { transform(e, t) { var n, r, i, a, o = e.as || pA, s = o[0], u = o[1], l = tu(e.sort), c = e.field || Kt, h = e.offset === dA ? gA : e.offset === fA ? yA : bA; for (n = function (e, t, n, r) { var i, a, o, s, u, l, c, h, d, f = [], p = e => e(u); if (null == t) f.push(e.slice()); else for (i = {}, a = 0, o = e.length; a < o; ++a)u = e[a], (c = i[l = t.map(p)]) || (i[l] = c = [], f.push(c)), c.push(u); for (l = 0, d = 0, s = f.length; l < s; ++l) { for (a = 0, h = 0, o = (c = f[l]).length; a < o; ++a)h += Math.abs(r(c[a])); c.sum = h, h > d && (d = h), n && c.sort(n) } return f.max = d, f }(t.source, e.groupby, l, c), r = 0, i = n.length, a = n.max; r < i; ++r)h(n[r], a, c, s, u); return t.reflow(e.modified()).modifies(o) } }); var vA = Math.sqrt(50), xA = Math.sqrt(10), wA = Math.sqrt(2); function kA(e, t, n) { var r, i, a, o, s = -1; if (n = +n, (e = +e) === (t = +t) && n > 0) return [e]; if ((r = t < e) && (i = e, e = t, t = i), 0 === (o = SA(e, t, n)) || !isFinite(o)) return []; if (o > 0) { let n = Math.round(e / o), r = Math.round(t / o); for (n * o < e && ++n, r * o > t && --r, a = new Array(i = r - n + 1); ++s < i;)a[s] = (n + s) * o } else { o = -o; let n = Math.round(e * o), r = Math.round(t * o); for (n / o < e && ++n, r / o > t && --r, a = new Array(i = r - n + 1); ++s < i;)a[s] = (n + s) / o } return r && a.reverse(), a } function SA(e, t, n) { var r = (t - e) / Math.max(0, n), i = Math.floor(Math.log(r) / Math.LN10), a = r / Math.pow(10, i); return i >= 0 ? (a >= vA ? 10 : a >= xA ? 5 : a >= wA ? 2 : 1) * Math.pow(10, i) : -Math.pow(10, -i) / (a >= vA ? 10 : a >= xA ? 5 : a >= wA ? 2 : 1) } function _A(e, t, n) { var r = Math.abs(t - e) / Math.max(0, n), i = Math.pow(10, Math.floor(Math.log(r) / Math.LN10)), a = r / i; return a >= vA ? i *= 10 : a >= xA ? i *= 5 : a >= wA && (i *= 2), t < e ? -i : i } const CA = e => e; function AA(e, t) { e && EA.hasOwnProperty(e.type) && EA[e.type](e, t) } var TA = { Feature: function (e, t) { AA(e.geometry, t) }, FeatureCollection: function (e, t) { for (var n = e.features, r = -1, i = n.length; ++r < i;)AA(n[r].geometry, t) } }, EA = { Sphere: function (e, t) { t.sphere() }, Point: function (e, t) { e = e.coordinates, t.point(e[0], e[1], e[2]) }, MultiPoint: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)e = n[r], t.point(e[0], e[1], e[2]) }, LineString: function (e, t) { NA(e.coordinates, t, 0) }, MultiLineString: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)NA(n[r], t, 0) }, Polygon: function (e, t) { IA(e.coordinates, t) }, MultiPolygon: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)IA(n[r], t) }, GeometryCollection: function (e, t) { for (var n = e.geometries, r = -1, i = n.length; ++r < i;)AA(n[r], t) } }; function NA(e, t, n) { var r, i = -1, a = e.length - n; for (t.lineStart(); ++i < a;)r = e[i], t.point(r[0], r[1], r[2]); t.lineEnd() } function IA(e, t) { var n = -1, r = e.length; for (t.polygonStart(); ++n < r;)NA(e[n], t, 1); t.polygonEnd() } function MA(e, t) { e && TA.hasOwnProperty(e.type) ? TA[e.type](e, t) : AA(e, t) } class FA { constructor() { this._partials = new Float64Array(32), this._n = 0 } add(e) { const t = this._partials; let n = 0; for (let r = 0; r < this._n && r < 32; r++) { const i = t[r], a = e + i, o = Math.abs(e) < Math.abs(i) ? e - (a - i) : i - (a - e); o && (t[n++] = o), e = a } return t[n] = e, this._n = n + 1, this } valueOf() { const e = this._partials; let t, n, r, i = this._n, a = 0; if (i > 0) { for (a = e[--i]; i > 0 && (t = a, n = e[--i], a = t + n, r = n - (a - t), !r);); i > 0 && (r < 0 && e[i - 1] < 0 || r > 0 && e[i - 1] > 0) && (n = 2 * r, t = a + n, n == t - a && (a = t)) } return a } } var DA = 1e-6, $A = Math.PI, RA = $A / 2, OA = $A / 4, zA = 2 * $A, PA = 180 / $A, BA = $A / 180, LA = Math.abs, jA = Math.atan, UA = Math.atan2, WA = Math.cos, VA = (Math.ceil, Math.exp), GA = (Math.floor, Math.hypot, Math.log), HA = Math.pow, qA = Math.sin, YA = Math.sign || function (e) { return e > 0 ? 1 : e < 0 ? -1 : 0 }, XA = Math.sqrt, KA = Math.tan; function ZA(e) { return e > 1 ? 0 : e < -1 ? $A : Math.acos(e) } function JA(e) { return e > 1 ? RA : e < -1 ? -RA : Math.asin(e) } function QA() { } var eT, tT, nT, rT, iT = new FA, aT = new FA, oT = { point: QA, lineStart: QA, lineEnd: QA, polygonStart: function () { oT.lineStart = sT, oT.lineEnd = cT }, polygonEnd: function () { oT.lineStart = oT.lineEnd = oT.point = QA, iT.add(LA(aT)), aT = new FA }, result: function () { var e = iT / 2; return iT = new FA, e } }; function sT() { oT.point = uT } function uT(e, t) { oT.point = lT, eT = nT = e, tT = rT = t } function lT(e, t) { aT.add(rT * e - nT * t), nT = e, rT = t } function cT() { lT(eT, tT) } const hT = oT; var dT = 1 / 0, fT = dT, pT = -dT, mT = pT, gT = { point: function (e, t) { e < dT && (dT = e); e > pT && (pT = e); t < fT && (fT = t); t > mT && (mT = t) }, lineStart: QA, lineEnd: QA, polygonStart: QA, polygonEnd: QA, result: function () { var e = [[dT, fT], [pT, mT]]; return pT = mT = -(fT = dT = 1 / 0), e } }; const yT = gT; var bT, vT, xT, wT, kT = 0, ST = 0, _T = 0, CT = 0, AT = 0, TT = 0, ET = 0, NT = 0, IT = 0, MT = { point: FT, lineStart: DT, lineEnd: OT, polygonStart: function () { MT.lineStart = zT, MT.lineEnd = PT }, polygonEnd: function () { MT.point = FT, MT.lineStart = DT, MT.lineEnd = OT }, result: function () { var e = IT ? [ET / IT, NT / IT] : TT ? [CT / TT, AT / TT] : _T ? [kT / _T, ST / _T] : [NaN, NaN]; return kT = ST = _T = CT = AT = TT = ET = NT = IT = 0, e } }; function FT(e, t) { kT += e, ST += t, ++_T } function DT() { MT.point = $T } function $T(e, t) { MT.point = RT, FT(xT = e, wT = t) } function RT(e, t) { var n = e - xT, r = t - wT, i = XA(n * n + r * r); CT += i * (xT + e) / 2, AT += i * (wT + t) / 2, TT += i, FT(xT = e, wT = t) } function OT() { MT.point = FT } function zT() { MT.point = BT } function PT() { LT(bT, vT) } function BT(e, t) { MT.point = LT, FT(bT = xT = e, vT = wT = t) } function LT(e, t) { var n = e - xT, r = t - wT, i = XA(n * n + r * r); CT += i * (xT + e) / 2, AT += i * (wT + t) / 2, TT += i, ET += (i = wT * e - xT * t) * (xT + e), NT += i * (wT + t), IT += 3 * i, FT(xT = e, wT = t) } const jT = MT; function UT(e) { this._context = e } UT.prototype = { _radius: 4.5, pointRadius: function (e) { return this._radius = e, this }, polygonStart: function () { this._line = 0 }, polygonEnd: function () { this._line = NaN }, lineStart: function () { this._point = 0 }, lineEnd: function () { 0 === this._line && this._context.closePath(), this._point = NaN }, point: function (e, t) { switch (this._point) { case 0: this._context.moveTo(e, t), this._point = 1; break; case 1: this._context.lineTo(e, t); break; default: this._context.moveTo(e + this._radius, t), this._context.arc(e, t, this._radius, 0, zA) } }, result: QA }; var WT, VT, GT, HT, qT, YT = new FA, XT = { point: QA, lineStart: function () { XT.point = KT }, lineEnd: function () { WT && ZT(VT, GT), XT.point = QA }, polygonStart: function () { WT = !0 }, polygonEnd: function () { WT = null }, result: function () { var e = +YT; return YT = new FA, e } }; function KT(e, t) { XT.point = ZT, VT = HT = e, GT = qT = t } function ZT(e, t) { HT -= e, qT -= t, YT.add(XA(HT * HT + qT * qT)), HT = e, qT = t } const JT = XT; let QT, eE, tE, nE; class rE { constructor(e) { this._append = null == e ? iE : function (e) { const t = Math.floor(e); if (!(t >= 0)) throw new RangeError(`invalid digits: ${e}`); if (t > 15) return iE; if (t !== QT) { const e = 10 ** t; QT = t, eE = function (t) { let n = 1; this._ += t[0]; for (const r = t.length; n < r; ++n)this._ += Math.round(arguments[n] * e) / e + t[n] } } return eE }(e), this._radius = 4.5, this._ = "" } pointRadius(e) { return this._radius = +e, this } polygonStart() { this._line = 0 } polygonEnd() { this._line = NaN } lineStart() { this._point = 0 } lineEnd() { 0 === this._line && (this._ += "Z"), this._point = NaN } point(e, t) { switch (this._point) { case 0: this._append`M${e},${t}`, this._point = 1; break; case 1: this._append`L${e},${t}`; break; default: if (this._append`M${e},${t}`, this._radius !== tE || this._append !== eE) { const e = this._radius, t = this._; this._ = "", this._append`m0,${e}a${e},${e} 0 1,1 0,${-2 * e}a${e},${e} 0 1,1 0,${2 * e}z`, tE = e, eE = this._append, nE = this._, this._ = t } this._ += nE } } result() { const e = this._; return this._ = "", e.length ? e : null } } function iE(e) { let t = 1; this._ += e[0]; for (const n = e.length; t < n; ++t)this._ += arguments[t] + e[t] } function aE(e, t) { let n, r, i = 3, a = 4.5; function o(e) { return e && ("function" == typeof a && r.pointRadius(+a.apply(this, arguments)), MA(e, n(r))), r.result() } return o.area = function (e) { return MA(e, n(hT)), hT.result() }, o.measure = function (e) { return MA(e, n(JT)), JT.result() }, o.bounds = function (e) { return MA(e, n(yT)), yT.result() }, o.centroid = function (e) { return MA(e, n(jT)), jT.result() }, o.projection = function (t) { return arguments.length ? (n = null == t ? (e = null, CA) : (e = t).stream, o) : e }, o.context = function (e) { return arguments.length ? (r = null == e ? (t = null, new rE(i)) : new UT(t = e), "function" != typeof a && r.pointRadius(a), o) : t }, o.pointRadius = function (e) { return arguments.length ? (a = "function" == typeof e ? e : (r.pointRadius(+e), +e), o) : a }, o.digits = function (e) { if (!arguments.length) return i; if (null == e) i = null; else { const t = Math.floor(e); if (!(t >= 0)) throw new RangeError(`invalid digits: ${e}`); i = t } return null === t && (r = new rE(i)), o }, o.projection(e).digits(i).context(t) } function oE() { var e, t = []; return { point: function (t, n, r) { e.push([t, n, r]) }, lineStart: function () { t.push(e = []) }, lineEnd: QA, rejoin: function () { t.length > 1 && t.push(t.pop().concat(t.shift())) }, result: function () { var n = t; return t = [], e = null, n } } } function sE(e, t) { return LA(e[0] - t[0]) < DA && LA(e[1] - t[1]) < DA } function uE(e, t, n, r) { this.x = e, this.z = t, this.o = n, this.e = r, this.v = !1, this.n = this.p = null } function lE(e, t, n, r, i) { var a, o, s = [], u = []; if (e.forEach((function (e) { if (!((t = e.length - 1) <= 0)) { var t, n, r = e[0], o = e[t]; if (sE(r, o)) { if (!r[2] && !o[2]) { for (i.lineStart(), a = 0; a < t; ++a)i.point((r = e[a])[0], r[1]); return void i.lineEnd() } o[0] += 2e-6 } s.push(n = new uE(r, e, null, !0)), u.push(n.o = new uE(r, null, n, !1)), s.push(n = new uE(o, e, null, !1)), u.push(n.o = new uE(o, null, n, !0)) } })), s.length) { for (u.sort(t), cE(s), cE(u), a = 0, o = u.length; a < o; ++a)u[a].e = n = !n; for (var l, c, h = s[0]; ;) { for (var d = h, f = !0; d.v;)if ((d = d.n) === h) return; l = d.z, i.lineStart(); do { if (d.v = d.o.v = !0, d.e) { if (f) for (a = 0, o = l.length; a < o; ++a)i.point((c = l[a])[0], c[1]); else r(d.x, d.n.x, 1, i); d = d.n } else { if (f) for (l = d.p.z, a = l.length - 1; a >= 0; --a)i.point((c = l[a])[0], c[1]); else r(d.x, d.p.x, -1, i); d = d.p } l = (d = d.o).z, f = !f } while (!d.v); i.lineEnd() } } } function cE(e) { if (t = e.length) { for (var t, n, r = 0, i = e[0]; ++r < t;)i.n = n = e[r], n.p = i, i = n; i.n = n = e[0], n.p = i } } function hE(e) { return [UA(e[1], e[0]), JA(e[2])] } function dE(e) { var t = e[0], n = e[1], r = WA(n); return [r * WA(t), r * qA(t), qA(n)] } function fE(e, t) { return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] } function pE(e, t) { return [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]] } function mE(e, t) { e[0] += t[0], e[1] += t[1], e[2] += t[2] } function gE(e, t) { return [e[0] * t, e[1] * t, e[2] * t] } function yE(e) { var t = XA(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]); e[0] /= t, e[1] /= t, e[2] /= t } function bE(e) { return LA(e[0]) <= $A ? e[0] : YA(e[0]) * ((LA(e[0]) + $A) % zA - $A) } function vE(e) { return Array.from(function* (e) { for (const t of e) yield* t }(e)) } function xE(e, t, n, r) { return function (i) { var a, o, s, u = t(i), l = oE(), c = t(l), h = !1, d = { point: f, lineStart: m, lineEnd: g, polygonStart: function () { d.point = y, d.lineStart = b, d.lineEnd = v, o = [], a = [] }, polygonEnd: function () { d.point = f, d.lineStart = m, d.lineEnd = g, o = vE(o); var e = function (e, t) { var n = bE(t), r = t[1], i = qA(r), a = [qA(n), -WA(n), 0], o = 0, s = 0, u = new FA; 1 === i ? r = RA + DA : -1 === i && (r = -RA - DA); for (var l = 0, c = e.length; l < c; ++l)if (d = (h = e[l]).length) for (var h, d, f = h[d - 1], p = bE(f), m = f[1] / 2 + OA, g = qA(m), y = WA(m), b = 0; b < d; ++b, p = x, g = k, y = S, f = v) { var v = h[b], x = bE(v), w = v[1] / 2 + OA, k = qA(w), S = WA(w), _ = x - p, C = _ >= 0 ? 1 : -1, A = C * _, T = A > $A, E = g * k; if (u.add(UA(E * C * qA(A), y * S + E * WA(A))), o += T ? _ + C * zA : _, T ^ p >= n ^ x >= n) { var N = pE(dE(f), dE(v)); yE(N); var I = pE(a, N); yE(I); var M = (T ^ _ >= 0 ? -1 : 1) * JA(I[2]); (r > M || r === M && (N[0] || N[1])) && (s += T ^ _ >= 0 ? 1 : -1) } } return (o < -1e-6 || o < DA && u < -1e-12) ^ 1 & s }(a, r); o.length ? (h || (i.polygonStart(), h = !0), lE(o, kE, e, n, i)) : e && (h || (i.polygonStart(), h = !0), i.lineStart(), n(null, null, 1, i), i.lineEnd()), h && (i.polygonEnd(), h = !1), o = a = null }, sphere: function () { i.polygonStart(), i.lineStart(), n(null, null, 1, i), i.lineEnd(), i.polygonEnd() } }; function f(t, n) { e(t, n) && i.point(t, n) } function p(e, t) { u.point(e, t) } function m() { d.point = p, u.lineStart() } function g() { d.point = f, u.lineEnd() } function y(e, t) { s.push([e, t]), c.point(e, t) } function b() { c.lineStart(), s = [] } function v() { y(s[0][0], s[0][1]), c.lineEnd(); var e, t, n, r, u = c.clean(), d = l.result(), f = d.length; if (s.pop(), a.push(s), s = null, f) if (1 & u) { if ((t = (n = d[0]).length - 1) > 0) { for (h || (i.polygonStart(), h = !0), i.lineStart(), e = 0; e < t; ++e)i.point((r = n[e])[0], r[1]); i.lineEnd() } } else f > 1 && 2 & u && d.push(d.pop().concat(d.shift())), o.push(d.filter(wE)) } return d } } function wE(e) { return e.length > 1 } function kE(e, t) { return ((e = e.x)[0] < 0 ? e[1] - RA - DA : RA - e[1]) - ((t = t.x)[0] < 0 ? t[1] - RA - DA : RA - t[1]) } const SE = xE((function () { return !0 }), (function (e) { var t, n = NaN, r = NaN, i = NaN; return { lineStart: function () { e.lineStart(), t = 1 }, point: function (a, o) { var s = a > 0 ? $A : -$A, u = LA(a - n); LA(u - $A) < DA ? (e.point(n, r = (r + o) / 2 > 0 ? RA : -RA), e.point(i, r), e.lineEnd(), e.lineStart(), e.point(s, r), e.point(a, r), t = 0) : i !== s && u >= $A && (LA(n - i) < DA && (n -= i * DA), LA(a - s) < DA && (a -= s * DA), r = function (e, t, n, r) { var i, a, o = qA(e - n); return LA(o) > DA ? jA((qA(t) * (a = WA(r)) * qA(n) - qA(r) * (i = WA(t)) * qA(e)) / (i * a * o)) : (t + r) / 2 }(n, r, a, o), e.point(i, r), e.lineEnd(), e.lineStart(), e.point(s, r), t = 0), e.point(n = a, r = o), i = s }, lineEnd: function () { e.lineEnd(), n = r = NaN }, clean: function () { return 2 - t } } }), (function (e, t, n, r) { var i; if (null == e) i = n * RA, r.point(-$A, i), r.point(0, i), r.point($A, i), r.point($A, 0), r.point($A, -i), r.point(0, -i), r.point(-$A, -i), r.point(-$A, 0), r.point(-$A, i); else if (LA(e[0] - t[0]) > DA) { var a = e[0] < t[0] ? $A : -$A; i = n * a / 2, r.point(-a, i), r.point(0, i), r.point(a, i) } else r.point(t[0], t[1]) }), [-$A, -RA]); function _E(e, t, n, r, i, a) { if (n) { var o = WA(t), s = qA(t), u = r * n; null == i ? (i = t + r * zA, a = t - u / 2) : (i = CE(o, i), a = CE(o, a), (r > 0 ? i < a : i > a) && (i += r * zA)); for (var l, c = i; r > 0 ? c > a : c < a; c -= u)l = hE([o, -s * WA(c), -s * qA(c)]), e.point(l[0], l[1]) } } function CE(e, t) { (t = dE(t))[0] -= e, yE(t); var n = ZA(-t[1]); return ((-t[2] < 0 ? -n : n) + zA - DA) % zA } var AE = 1e9, TE = -AE; function EE(e, t, n, r) { function i(i, a) { return e <= i && i <= n && t <= a && a <= r } function a(i, a, s, l) { var c = 0, h = 0; if (null == i || (c = o(i, s)) !== (h = o(a, s)) || u(i, a) < 0 ^ s > 0) do { l.point(0 === c || 3 === c ? e : n, c > 1 ? r : t) } while ((c = (c + s + 4) % 4) !== h); else l.point(a[0], a[1]) } function o(r, i) { return LA(r[0] - e) < DA ? i > 0 ? 0 : 3 : LA(r[0] - n) < DA ? i > 0 ? 2 : 1 : LA(r[1] - t) < DA ? i > 0 ? 1 : 0 : i > 0 ? 3 : 2 } function s(e, t) { return u(e.x, t.x) } function u(e, t) { var n = o(e, 1), r = o(t, 1); return n !== r ? n - r : 0 === n ? t[1] - e[1] : 1 === n ? e[0] - t[0] : 2 === n ? e[1] - t[1] : t[0] - e[0] } return function (o) { var u, l, c, h, d, f, p, m, g, y, b, v = o, x = oE(), w = { point: k, lineStart: function () { w.point = S, l && l.push(c = []); y = !0, g = !1, p = m = NaN }, lineEnd: function () { u && (S(h, d), f && g && x.rejoin(), u.push(x.result())); w.point = k, g && v.lineEnd() }, polygonStart: function () { v = x, u = [], l = [], b = !0 }, polygonEnd: function () { var t = function () { for (var t = 0, n = 0, i = l.length; n < i; ++n)for (var a, o, s = l[n], u = 1, c = s.length, h = s[0], d = h[0], f = h[1]; u < c; ++u)a = d, o = f, d = (h = s[u])[0], f = h[1], o <= r ? f > r && (d - a) * (r - o) > (f - o) * (e - a) && ++t : f <= r && (d - a) * (r - o) < (f - o) * (e - a) && --t; return t }(), n = b && t, i = (u = vE(u)).length; (n || i) && (o.polygonStart(), n && (o.lineStart(), a(null, null, 1, o), o.lineEnd()), i && lE(u, s, t, a, o), o.polygonEnd()); v = o, u = l = c = null } }; function k(e, t) { i(e, t) && v.point(e, t) } function S(a, o) { var s = i(a, o); if (l && c.push([a, o]), y) h = a, d = o, f = s, y = !1, s && (v.lineStart(), v.point(a, o)); else if (s && g) v.point(a, o); else { var u = [p = Math.max(TE, Math.min(AE, p)), m = Math.max(TE, Math.min(AE, m))], x = [a = Math.max(TE, Math.min(AE, a)), o = Math.max(TE, Math.min(AE, o))]; !function (e, t, n, r, i, a) { var o, s = e[0], u = e[1], l = 0, c = 1, h = t[0] - s, d = t[1] - u; if (o = n - s, h || !(o > 0)) { if (o /= h, h < 0) { if (o < l) return; o < c && (c = o) } else if (h > 0) { if (o > c) return; o > l && (l = o) } if (o = i - s, h || !(o < 0)) { if (o /= h, h < 0) { if (o > c) return; o > l && (l = o) } else if (h > 0) { if (o < l) return; o < c && (c = o) } if (o = r - u, d || !(o > 0)) { if (o /= d, d < 0) { if (o < l) return; o < c && (c = o) } else if (d > 0) { if (o > c) return; o > l && (l = o) } if (o = a - u, d || !(o < 0)) { if (o /= d, d < 0) { if (o > c) return; o > l && (l = o) } else if (d > 0) { if (o < l) return; o < c && (c = o) } return l > 0 && (e[0] = s + l * h, e[1] = u + l * d), c < 1 && (t[0] = s + c * h, t[1] = u + c * d), !0 } } } } }(u, x, e, t, n, r) ? s && (v.lineStart(), v.point(a, o), b = !1) : (g || (v.lineStart(), v.point(u[0], u[1])), v.point(x[0], x[1]), s || v.lineEnd(), b = !1) } p = a, m = o, g = s } return w } } function NE(e, t) { function n(n, r) { return n = e(n, r), t(n[0], n[1]) } return e.invert && t.invert && (n.invert = function (n, r) { return (n = t.invert(n, r)) && e.invert(n[0], n[1]) }), n } function IE(e, t) { return LA(e) > $A && (e -= Math.round(e / zA) * zA), [e, t] } function ME(e, t, n) { return (e %= zA) ? t || n ? NE(DE(e), $E(t, n)) : DE(e) : t || n ? $E(t, n) : IE } function FE(e) { return function (t, n) { return LA(t += e) > $A && (t -= Math.round(t / zA) * zA), [t, n] } } function DE(e) { var t = FE(e); return t.invert = FE(-e), t } function $E(e, t) { var n = WA(e), r = qA(e), i = WA(t), a = qA(t); function o(e, t) { var o = WA(t), s = WA(e) * o, u = qA(e) * o, l = qA(t), c = l * n + s * r; return [UA(u * i - c * a, s * n - l * r), JA(c * i + u * a)] } return o.invert = function (e, t) { var o = WA(t), s = WA(e) * o, u = qA(e) * o, l = qA(t), c = l * i - u * a; return [UA(u * i + l * a, s * n + c * r), JA(c * n - s * r)] }, o } function RE(e) { return function (t) { var n = new OE; for (var r in e) n[r] = e[r]; return n.stream = t, n } } function OE() { } function zE(e, t, n) { var r = e.clipExtent && e.clipExtent(); return e.scale(150).translate([0, 0]), null != r && e.clipExtent(null), MA(n, e.stream(yT)), t(yT.result()), null != r && e.clipExtent(r), e } function PE(e, t, n) { return zE(e, (function (n) { var r = t[1][0] - t[0][0], i = t[1][1] - t[0][1], a = Math.min(r / (n[1][0] - n[0][0]), i / (n[1][1] - n[0][1])), o = +t[0][0] + (r - a * (n[1][0] + n[0][0])) / 2, s = +t[0][1] + (i - a * (n[1][1] + n[0][1])) / 2; e.scale(150 * a).translate([o, s]) }), n) } function BE(e, t, n) { return PE(e, [[0, 0], t], n) } function LE(e, t, n) { return zE(e, (function (n) { var r = +t, i = r / (n[1][0] - n[0][0]), a = (r - i * (n[1][0] + n[0][0])) / 2, o = -i * n[0][1]; e.scale(150 * i).translate([a, o]) }), n) } function jE(e, t, n) { return zE(e, (function (n) { var r = +t, i = r / (n[1][1] - n[0][1]), a = -i * n[0][0], o = (r - i * (n[1][1] + n[0][1])) / 2; e.scale(150 * i).translate([a, o]) }), n) } IE.invert = IE, OE.prototype = { constructor: OE, point: function (e, t) { this.stream.point(e, t) }, sphere: function () { this.stream.sphere() }, lineStart: function () { this.stream.lineStart() }, lineEnd: function () { this.stream.lineEnd() }, polygonStart: function () { this.stream.polygonStart() }, polygonEnd: function () { this.stream.polygonEnd() } }; var UE = WA(30 * BA); function WE(e, t) { return +t ? function (e, t) { function n(r, i, a, o, s, u, l, c, h, d, f, p, m, g) { var y = l - r, b = c - i, v = y * y + b * b; if (v > 4 * t && m--) { var x = o + d, w = s + f, k = u + p, S = XA(x * x + w * w + k * k), _ = JA(k /= S), C = LA(LA(k) - 1) < DA || LA(a - h) < DA ? (a + h) / 2 : UA(w, x), A = e(C, _), T = A[0], E = A[1], N = T - r, I = E - i, M = b * N - y * I; (M * M / v > t || LA((y * N + b * I) / v - .5) > .3 || o * d + s * f + u * p < UE) && (n(r, i, a, o, s, u, T, E, C, x /= S, w /= S, k, m, g), g.point(T, E), n(T, E, C, x, w, k, l, c, h, d, f, p, m, g)) } } return function (t) { var r, i, a, o, s, u, l, c, h, d, f, p, m = { point: g, lineStart: y, lineEnd: v, polygonStart: function () { t.polygonStart(), m.lineStart = x }, polygonEnd: function () { t.polygonEnd(), m.lineStart = y } }; function g(n, r) { n = e(n, r), t.point(n[0], n[1]) } function y() { c = NaN, m.point = b, t.lineStart() } function b(r, i) { var a = dE([r, i]), o = e(r, i); n(c, h, l, d, f, p, c = o[0], h = o[1], l = r, d = a[0], f = a[1], p = a[2], 16, t), t.point(c, h) } function v() { m.point = g, t.lineEnd() } function x() { y(), m.point = w, m.lineEnd = k } function w(e, t) { b(r = e, t), i = c, a = h, o = d, s = f, u = p, m.point = b } function k() { n(c, h, l, d, f, p, i, a, r, o, s, u, 16, t), m.lineEnd = v, v() } return m } }(e, t) : function (e) { return RE({ point: function (t, n) { t = e(t, n), this.stream.point(t[0], t[1]) } }) }(e) } var VE = RE({ point: function (e, t) { this.stream.point(e * BA, t * BA) } }); function GE(e, t, n, r, i, a) { if (!a) return function (e, t, n, r, i) { function a(a, o) { return [t + e * (a *= r), n - e * (o *= i)] } return a.invert = function (a, o) { return [(a - t) / e * r, (n - o) / e * i] }, a }(e, t, n, r, i); var o = WA(a), s = qA(a), u = o * e, l = s * e, c = o / e, h = s / e, d = (s * n - o * t) / e, f = (s * t + o * n) / e; function p(e, a) { return [u * (e *= r) - l * (a *= i) + t, n - l * e - u * a] } return p.invert = function (e, t) { return [r * (c * e - h * t + d), i * (f - h * e - c * t)] }, p } function HE(e) { return qE((function () { return e }))() } function qE(e) { var t, n, r, i, a, o, s, u, l, c, h = 150, d = 480, f = 250, p = 0, m = 0, g = 0, y = 0, b = 0, v = 0, x = 1, w = 1, k = null, S = SE, _ = null, C = CA, A = .5; function T(e) { return u(e[0] * BA, e[1] * BA) } function E(e) { return (e = u.invert(e[0], e[1])) && [e[0] * PA, e[1] * PA] } function N() { var e = GE(h, 0, 0, x, w, v).apply(null, t(p, m)), r = GE(h, d - e[0], f - e[1], x, w, v); return n = ME(g, y, b), s = NE(t, r), u = NE(n, s), o = WE(s, A), I() } function I() { return l = c = null, T } return T.stream = function (e) { return l && c === e ? l : l = VE(function (e) { return RE({ point: function (t, n) { var r = e(t, n); return this.stream.point(r[0], r[1]) } }) }(n)(S(o(C(c = e))))) }, T.preclip = function (e) { return arguments.length ? (S = e, k = void 0, I()) : S }, T.postclip = function (e) { return arguments.length ? (C = e, _ = r = i = a = null, I()) : C }, T.clipAngle = function (e) { return arguments.length ? (S = +e ? function (e) { var t = WA(e), n = 2 * BA, r = t > 0, i = LA(t) > DA; function a(e, n) { return WA(e) * WA(n) > t } function o(e, n, r) { var i = [1, 0, 0], a = pE(dE(e), dE(n)), o = fE(a, a), s = a[0], u = o - s * s; if (!u) return !r && e; var l = t * o / u, c = -t * s / u, h = pE(i, a), d = gE(i, l); mE(d, gE(a, c)); var f = h, p = fE(d, f), m = fE(f, f), g = p * p - m * (fE(d, d) - 1); if (!(g < 0)) { var y = XA(g), b = gE(f, (-p - y) / m); if (mE(b, d), b = hE(b), !r) return b; var v, x = e[0], w = n[0], k = e[1], S = n[1]; w < x && (v = x, x = w, w = v); var _ = w - x, C = LA(_ - $A) < DA; if (!C && S < k && (v = k, k = S, S = v), C || _ < DA ? C ? k + S > 0 ^ b[1] < (LA(b[0] - x) < DA ? k : S) : k <= b[1] && b[1] <= S : _ > $A ^ (x <= b[0] && b[0] <= w)) { var A = gE(f, (-p + y) / m); return mE(A, d), [b, hE(A)] } } } function s(t, n) { var i = r ? e : $A - e, a = 0; return t < -i ? a |= 1 : t > i && (a |= 2), n < -i ? a |= 4 : n > i && (a |= 8), a } return xE(a, (function (e) { var t, n, u, l, c; return { lineStart: function () { l = u = !1, c = 1 }, point: function (h, d) { var f, p = [h, d], m = a(h, d), g = r ? m ? 0 : s(h, d) : m ? s(h + (h < 0 ? $A : -$A), d) : 0; if (!t && (l = u = m) && e.lineStart(), m !== u && (!(f = o(t, p)) || sE(t, f) || sE(p, f)) && (p[2] = 1), m !== u) c = 0, m ? (e.lineStart(), f = o(p, t), e.point(f[0], f[1])) : (f = o(t, p), e.point(f[0], f[1], 2), e.lineEnd()), t = f; else if (i && t && r ^ m) { var y; g & n || !(y = o(p, t, !0)) || (c = 0, r ? (e.lineStart(), e.point(y[0][0], y[0][1]), e.point(y[1][0], y[1][1]), e.lineEnd()) : (e.point(y[1][0], y[1][1]), e.lineEnd(), e.lineStart(), e.point(y[0][0], y[0][1], 3))) } !m || t && sE(t, p) || e.point(p[0], p[1]), t = p, u = m, n = g }, lineEnd: function () { u && e.lineEnd(), t = null }, clean: function () { return c | (l && u) << 1 } } }), (function (t, r, i, a) { _E(a, e, n, i, t, r) }), r ? [0, -e] : [-$A, e - $A]) }(k = e * BA) : (k = null, SE), I()) : k * PA }, T.clipExtent = function (e) { return arguments.length ? (C = null == e ? (_ = r = i = a = null, CA) : EE(_ = +e[0][0], r = +e[0][1], i = +e[1][0], a = +e[1][1]), I()) : null == _ ? null : [[_, r], [i, a]] }, T.scale = function (e) { return arguments.length ? (h = +e, N()) : h }, T.translate = function (e) { return arguments.length ? (d = +e[0], f = +e[1], N()) : [d, f] }, T.center = function (e) { return arguments.length ? (p = e[0] % 360 * BA, m = e[1] % 360 * BA, N()) : [p * PA, m * PA] }, T.rotate = function (e) { return arguments.length ? (g = e[0] % 360 * BA, y = e[1] % 360 * BA, b = e.length > 2 ? e[2] % 360 * BA : 0, N()) : [g * PA, y * PA, b * PA] }, T.angle = function (e) { return arguments.length ? (v = e % 360 * BA, N()) : v * PA }, T.reflectX = function (e) { return arguments.length ? (x = e ? -1 : 1, N()) : x < 0 }, T.reflectY = function (e) { return arguments.length ? (w = e ? -1 : 1, N()) : w < 0 }, T.precision = function (e) { return arguments.length ? (o = WE(s, A = e * e), I()) : XA(A) }, T.fitExtent = function (e, t) { return PE(T, e, t) }, T.fitSize = function (e, t) { return BE(T, e, t) }, T.fitWidth = function (e, t) { return LE(T, e, t) }, T.fitHeight = function (e, t) { return jE(T, e, t) }, function () { return t = e.apply(this, arguments), T.invert = t.invert && E, N() } } function YE(e) { var t = 0, n = $A / 3, r = qE(e), i = r(t, n); return i.parallels = function (e) { return arguments.length ? r(t = e[0] * BA, n = e[1] * BA) : [t * PA, n * PA] }, i } function XE(e, t) { var n = qA(e), r = (n + qA(t)) / 2; if (LA(r) < DA) return function (e) { var t = WA(e); function n(e, n) { return [e * t, qA(n) / t] } return n.invert = function (e, n) { return [e / t, JA(n * t)] }, n }(e); var i = 1 + n * (2 * r - n), a = XA(i) / r; function o(e, t) { var n = XA(i - 2 * r * qA(t)) / r; return [n * qA(e *= r), a - n * WA(e)] } return o.invert = function (e, t) { var n = a - t, o = UA(e, LA(n)) * YA(n); return n * r < 0 && (o -= $A * YA(e) * YA(n)), [o / r, JA((i - (e * e + n * n) * r * r) / (2 * r))] }, o } function KE() { return YE(XE).scale(155.424).center([0, 33.6442]) } function ZE() { return KE().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-.6, 38.7]) } function JE(e) { return function (t, n) { var r = WA(t), i = WA(n), a = e(r * i); return a === 1 / 0 ? [2, 0] : [a * i * qA(t), a * qA(n)] } } function QE(e) { return function (t, n) { var r = XA(t * t + n * n), i = e(r), a = qA(i), o = WA(i); return [UA(t * a, r * o), JA(r && n * a / r)] } } var eN = JE((function (e) { return XA(2 / (1 + e)) })); eN.invert = QE((function (e) { return 2 * JA(e / 2) })); var tN = JE((function (e) { return (e = ZA(e)) && e / qA(e) })); function nN(e, t) { return [e, GA(KA((RA + t) / 2))] } function rN(e) { var t, n, r, i = HE(e), a = i.center, o = i.scale, s = i.translate, u = i.clipExtent, l = null; function c() { var a = $A * o(), s = i(function (e) { function t(t) { return (t = e(t[0] * BA, t[1] * BA))[0] *= PA, t[1] *= PA, t } return e = ME(e[0] * BA, e[1] * BA, e.length > 2 ? e[2] * BA : 0), t.invert = function (t) { return (t = e.invert(t[0] * BA, t[1] * BA))[0] *= PA, t[1] *= PA, t }, t }(i.rotate()).invert([0, 0])); return u(null == l ? [[s[0] - a, s[1] - a], [s[0] + a, s[1] + a]] : e === nN ? [[Math.max(s[0] - a, l), t], [Math.min(s[0] + a, n), r]] : [[l, Math.max(s[1] - a, t)], [n, Math.min(s[1] + a, r)]]) } return i.scale = function (e) { return arguments.length ? (o(e), c()) : o() }, i.translate = function (e) { return arguments.length ? (s(e), c()) : s() }, i.center = function (e) { return arguments.length ? (a(e), c()) : a() }, i.clipExtent = function (e) { return arguments.length ? (null == e ? l = t = n = r = null : (l = +e[0][0], t = +e[0][1], n = +e[1][0], r = +e[1][1]), c()) : null == l ? null : [[l, t], [n, r]] }, c() } function iN(e) { return KA((RA + e) / 2) } function aN(e, t) { var n = WA(e), r = e === t ? qA(e) : GA(n / WA(t)) / GA(iN(t) / iN(e)), i = n * HA(iN(e), r) / r; if (!r) return nN; function a(e, t) { i > 0 ? t < -RA + DA && (t = -RA + DA) : t > RA - DA && (t = RA - DA); var n = i / HA(iN(t), r); return [n * qA(r * e), i - n * WA(r * e)] } return a.invert = function (e, t) { var n = i - t, a = YA(r) * XA(e * e + n * n), o = UA(e, LA(n)) * YA(n); return n * r < 0 && (o -= $A * YA(e) * YA(n)), [o / r, 2 * jA(HA(i / a, 1 / r)) - RA] }, a } function oN(e, t) { return [e, t] } function sN(e, t) { var n = WA(e), r = e === t ? qA(e) : (n - WA(t)) / (t - e), i = n / r + e; if (LA(r) < DA) return oN; function a(e, t) { var n = i - t, a = r * e; return [n * qA(a), i - n * WA(a)] } return a.invert = function (e, t) { var n = i - t, a = UA(e, LA(n)) * YA(n); return n * r < 0 && (a -= $A * YA(e) * YA(n)), [a / r, i - YA(r) * XA(e * e + n * n)] }, a } tN.invert = QE((function (e) { return e })), nN.invert = function (e, t) { return [e, 2 * jA(VA(t)) - RA] }, oN.invert = oN; var uN = 1.340264, lN = -.081106, cN = 893e-6, hN = .003796, dN = XA(3) / 2; function fN(e, t) { var n = JA(dN * qA(t)), r = n * n, i = r * r * r; return [e * WA(n) / (dN * (uN + 3 * lN * r + i * (7 * cN + 9 * hN * r))), n * (uN + lN * r + i * (cN + hN * r))] } function pN(e, t) { var n = WA(t), r = WA(e) * n; return [n * qA(e) / r, qA(t) / r] } function mN(e, t) { var n = t * t, r = n * n; return [e * (.8707 - .131979 * n + r * (r * (.003971 * n - .001529 * r) - .013791)), t * (1.007226 + n * (.015085 + r * (.028874 * n - .044475 - .005916 * r)))] } function gN(e, t) { return [WA(t) * qA(e), qA(t)] } function yN(e, t) { var n = WA(t), r = 1 + WA(e) * n; return [n * qA(e) / r, qA(t) / r] } function bN(e, t) { return [GA(KA((RA + t) / 2)), -e] } function vN() { } function xN() { var e, t = []; return { point: function (t, n, r) { e.push([t, n, r]) }, lineStart: function () { t.push(e = []) }, lineEnd: vN, rejoin: function () { t.length > 1 && t.push(t.pop().concat(t.shift())) }, result: function () { var n = t; return t = [], e = null, n } } } fN.invert = function (e, t) { for (var n, r = t, i = r * r, a = i * i * i, o = 0; o < 12 && (a = (i = (r -= n = (r * (uN + lN * i + a * (cN + hN * i)) - t) / (uN + 3 * lN * i + a * (7 * cN + 9 * hN * i))) * r) * i * i, !(LA(n) < 1e-12)); ++o); return [dN * e * (uN + 3 * lN * i + a * (7 * cN + 9 * hN * i)) / WA(r), JA(qA(r) / dN)] }, pN.invert = QE(jA), mN.invert = function (e, t) { var n, r = t, i = 25; do { var a = r * r, o = a * a; r -= n = (r * (1.007226 + a * (.015085 + o * (.028874 * a - .044475 - .005916 * o))) - t) / (1.007226 + a * (.045255 + o * (.259866 * a - .311325 - .005916 * 11 * o))) } while (LA(n) > DA && --i > 0); return [e / (.8707 + (a = r * r) * (a * (a * a * a * (.003971 - .001529 * a) - .013791) - .131979)), r] }, gN.invert = QE(JA), yN.invert = QE((function (e) { return 2 * jA(e) })), bN.invert = function (e, t) { return [-t, 2 * jA(VA(e)) - RA] }; var wN = 1e-6, kN = Math.PI, SN = kN / 2, _N = kN / 4, CN = 2 * kN, AN = 180 / kN, TN = kN / 180, EN = Math.abs, NN = Math.atan, IN = Math.atan2, MN = Math.cos, FN = (Math.ceil, Math.exp, Math.floor, Math.hypot, Math.log, Math.pow, Math.sin), DN = Math.sign || function (e) { return e > 0 ? 1 : e < 0 ? -1 : 0 }, $N = Math.sqrt; Math.tan; function RN(e) { return e > 1 ? SN : e < -1 ? -SN : Math.asin(e) } function ON(e, t) { return EN(e[0] - t[0]) < wN && EN(e[1] - t[1]) < wN } function zN(e, t, n, r) { this.x = e, this.z = t, this.o = n, this.e = r, this.v = !1, this.n = this.p = null } function PN(e, t, n, r, i) { var a, o, s = [], u = []; if (e.forEach((function (e) { if (!((t = e.length - 1) <= 0)) { var t, n, r = e[0], o = e[t]; if (ON(r, o)) { if (!r[2] && !o[2]) { for (i.lineStart(), a = 0; a < t; ++a)i.point((r = e[a])[0], r[1]); return void i.lineEnd() } o[0] += 2e-6 } s.push(n = new zN(r, e, null, !0)), u.push(n.o = new zN(r, null, n, !1)), s.push(n = new zN(o, e, null, !1)), u.push(n.o = new zN(o, null, n, !0)) } })), s.length) { for (u.sort(t), BN(s), BN(u), a = 0, o = u.length; a < o; ++a)u[a].e = n = !n; for (var l, c, h = s[0]; ;) { for (var d = h, f = !0; d.v;)if ((d = d.n) === h) return; l = d.z, i.lineStart(); do { if (d.v = d.o.v = !0, d.e) { if (f) for (a = 0, o = l.length; a < o; ++a)i.point((c = l[a])[0], c[1]); else r(d.x, d.n.x, 1, i); d = d.n } else { if (f) for (l = d.p.z, a = l.length - 1; a >= 0; --a)i.point((c = l[a])[0], c[1]); else r(d.x, d.p.x, -1, i); d = d.p } l = (d = d.o).z, f = !f } while (!d.v); i.lineEnd() } } } function BN(e) { if (t = e.length) { for (var t, n, r = 0, i = e[0]; ++r < t;)i.n = n = e[r], n.p = i, i = n; i.n = n = e[0], n.p = i } } class LN { constructor() { this._partials = new Float64Array(32), this._n = 0 } add(e) { const t = this._partials; let n = 0; for (let r = 0; r < this._n && r < 32; r++) { const i = t[r], a = e + i, o = Math.abs(e) < Math.abs(i) ? e - (a - i) : i - (a - e); o && (t[n++] = o), e = a } return t[n] = e, this._n = n + 1, this } valueOf() { const e = this._partials; let t, n, r, i = this._n, a = 0; if (i > 0) { for (a = e[--i]; i > 0 && (t = a, n = e[--i], a = t + n, r = n - (a - t), !r);); i > 0 && (r < 0 && e[i - 1] < 0 || r > 0 && e[i - 1] > 0) && (n = 2 * r, t = a + n, n == t - a && (a = t)) } return a } } function jN(e) { return [IN(e[1], e[0]), RN(e[2])] } function UN(e) { var t = e[0], n = e[1], r = MN(n); return [r * MN(t), r * FN(t), FN(n)] } function WN(e, t) { return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] } function VN(e, t) { return [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]] } function GN(e, t) { e[0] += t[0], e[1] += t[1], e[2] += t[2] } function HN(e, t) { return [e[0] * t, e[1] * t, e[2] * t] } function qN(e) { var t = $N(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]); e[0] /= t, e[1] /= t, e[2] /= t } function YN(e) { return EN(e[0]) <= kN ? e[0] : DN(e[0]) * ((EN(e[0]) + kN) % CN - kN) } function XN(e) { return Array.from(function* (e) { for (const t of e) yield* t }(e)) } function KN(e, t, n, r) { return function (i) { var a, o, s, u = t(i), l = xN(), c = t(l), h = !1, d = { point: f, lineStart: m, lineEnd: g, polygonStart: function () { d.point = y, d.lineStart = b, d.lineEnd = v, o = [], a = [] }, polygonEnd: function () { d.point = f, d.lineStart = m, d.lineEnd = g, o = XN(o); var e = function (e, t) { var n = YN(t), r = t[1], i = FN(r), a = [FN(n), -MN(n), 0], o = 0, s = 0, u = new LN; 1 === i ? r = SN + wN : -1 === i && (r = -SN - wN); for (var l = 0, c = e.length; l < c; ++l)if (d = (h = e[l]).length) for (var h, d, f = h[d - 1], p = YN(f), m = f[1] / 2 + _N, g = FN(m), y = MN(m), b = 0; b < d; ++b, p = x, g = k, y = S, f = v) { var v = h[b], x = YN(v), w = v[1] / 2 + _N, k = FN(w), S = MN(w), _ = x - p, C = _ >= 0 ? 1 : -1, A = C * _, T = A > kN, E = g * k; if (u.add(IN(E * C * FN(A), y * S + E * MN(A))), o += T ? _ + C * CN : _, T ^ p >= n ^ x >= n) { var N = VN(UN(f), UN(v)); qN(N); var I = VN(a, N); qN(I); var M = (T ^ _ >= 0 ? -1 : 1) * RN(I[2]); (r > M || r === M && (N[0] || N[1])) && (s += T ^ _ >= 0 ? 1 : -1) } } return (o < -1e-6 || o < wN && u < -1e-12) ^ 1 & s }(a, r); o.length ? (h || (i.polygonStart(), h = !0), PN(o, JN, e, n, i)) : e && (h || (i.polygonStart(), h = !0), i.lineStart(), n(null, null, 1, i), i.lineEnd()), h && (i.polygonEnd(), h = !1), o = a = null }, sphere: function () { i.polygonStart(), i.lineStart(), n(null, null, 1, i), i.lineEnd(), i.polygonEnd() } }; function f(t, n) { e(t, n) && i.point(t, n) } function p(e, t) { u.point(e, t) } function m() { d.point = p, u.lineStart() } function g() { d.point = f, u.lineEnd() } function y(e, t) { s.push([e, t]), c.point(e, t) } function b() { c.lineStart(), s = [] } function v() { y(s[0][0], s[0][1]), c.lineEnd(); var e, t, n, r, u = c.clean(), d = l.result(), f = d.length; if (s.pop(), a.push(s), s = null, f) if (1 & u) { if ((t = (n = d[0]).length - 1) > 0) { for (h || (i.polygonStart(), h = !0), i.lineStart(), e = 0; e < t; ++e)i.point((r = n[e])[0], r[1]); i.lineEnd() } } else f > 1 && 2 & u && d.push(d.pop().concat(d.shift())), o.push(d.filter(ZN)) } return d } } function ZN(e) { return e.length > 1 } function JN(e, t) { return ((e = e.x)[0] < 0 ? e[1] - SN - wN : SN - e[1]) - ((t = t.x)[0] < 0 ? t[1] - SN - wN : SN - t[1]) } const QN = KN((function () { return !0 }), (function (e) { var t, n = NaN, r = NaN, i = NaN; return { lineStart: function () { e.lineStart(), t = 1 }, point: function (a, o) { var s = a > 0 ? kN : -kN, u = EN(a - n); EN(u - kN) < wN ? (e.point(n, r = (r + o) / 2 > 0 ? SN : -SN), e.point(i, r), e.lineEnd(), e.lineStart(), e.point(s, r), e.point(a, r), t = 0) : i !== s && u >= kN && (EN(n - i) < wN && (n -= i * wN), EN(a - s) < wN && (a -= s * wN), r = function (e, t, n, r) { var i, a, o = FN(e - n); return EN(o) > wN ? NN((FN(t) * (a = MN(r)) * FN(n) - FN(r) * (i = MN(t)) * FN(e)) / (i * a * o)) : (t + r) / 2 }(n, r, a, o), e.point(i, r), e.lineEnd(), e.lineStart(), e.point(s, r), t = 0), e.point(n = a, r = o), i = s }, lineEnd: function () { e.lineEnd(), n = r = NaN }, clean: function () { return 2 - t } } }), (function (e, t, n, r) { var i; if (null == e) i = n * SN, r.point(-kN, i), r.point(0, i), r.point(kN, i), r.point(kN, 0), r.point(kN, -i), r.point(0, -i), r.point(-kN, -i), r.point(-kN, 0), r.point(-kN, i); else if (EN(e[0] - t[0]) > wN) { var a = e[0] < t[0] ? kN : -kN; i = n * a / 2, r.point(-a, i), r.point(0, i), r.point(a, i) } else r.point(t[0], t[1]) }), [-kN, -SN]); function eI(e, t, n, r, i, a) { if (n) { var o = MN(t), s = FN(t), u = r * n; null == i ? (i = t + r * CN, a = t - u / 2) : (i = tI(o, i), a = tI(o, a), (r > 0 ? i < a : i > a) && (i += r * CN)); for (var l, c = i; r > 0 ? c > a : c < a; c -= u)l = jN([o, -s * MN(c), -s * FN(c)]), e.point(l[0], l[1]) } } function tI(e, t) { (t = UN(t))[0] -= e, qN(t); var n = function (e) { return e > 1 ? 0 : e < -1 ? kN : Math.acos(e) }(-t[1]); return ((-t[2] < 0 ? -n : n) + CN - wN) % CN } var nI = 1e9, rI = -1e9; function iI(e, t, n, r) { function i(i, a) { return e <= i && i <= n && t <= a && a <= r } function a(i, a, s, l) { var c = 0, h = 0; if (null == i || (c = o(i, s)) !== (h = o(a, s)) || u(i, a) < 0 ^ s > 0) do { l.point(0 === c || 3 === c ? e : n, c > 1 ? r : t) } while ((c = (c + s + 4) % 4) !== h); else l.point(a[0], a[1]) } function o(r, i) { return EN(r[0] - e) < wN ? i > 0 ? 0 : 3 : EN(r[0] - n) < wN ? i > 0 ? 2 : 1 : EN(r[1] - t) < wN ? i > 0 ? 1 : 0 : i > 0 ? 3 : 2 } function s(e, t) { return u(e.x, t.x) } function u(e, t) { var n = o(e, 1), r = o(t, 1); return n !== r ? n - r : 0 === n ? t[1] - e[1] : 1 === n ? e[0] - t[0] : 2 === n ? e[1] - t[1] : t[0] - e[0] } return function (o) { var u, l, c, h, d, f, p, m, g, y, b, v = o, x = xN(), w = { point: k, lineStart: function () { w.point = S, l && l.push(c = []); y = !0, g = !1, p = m = NaN }, lineEnd: function () { u && (S(h, d), f && g && x.rejoin(), u.push(x.result())); w.point = k, g && v.lineEnd() }, polygonStart: function () { v = x, u = [], l = [], b = !0 }, polygonEnd: function () { var t = function () { for (var t = 0, n = 0, i = l.length; n < i; ++n)for (var a, o, s = l[n], u = 1, c = s.length, h = s[0], d = h[0], f = h[1]; u < c; ++u)a = d, o = f, d = (h = s[u])[0], f = h[1], o <= r ? f > r && (d - a) * (r - o) > (f - o) * (e - a) && ++t : f <= r && (d - a) * (r - o) < (f - o) * (e - a) && --t; return t }(), n = b && t, i = (u = XN(u)).length; (n || i) && (o.polygonStart(), n && (o.lineStart(), a(null, null, 1, o), o.lineEnd()), i && PN(u, s, t, a, o), o.polygonEnd()); v = o, u = l = c = null } }; function k(e, t) { i(e, t) && v.point(e, t) } function S(a, o) { var s = i(a, o); if (l && c.push([a, o]), y) h = a, d = o, f = s, y = !1, s && (v.lineStart(), v.point(a, o)); else if (s && g) v.point(a, o); else { var u = [p = Math.max(rI, Math.min(nI, p)), m = Math.max(rI, Math.min(nI, m))], x = [a = Math.max(rI, Math.min(nI, a)), o = Math.max(rI, Math.min(nI, o))]; !function (e, t, n, r, i, a) { var o, s = e[0], u = e[1], l = 0, c = 1, h = t[0] - s, d = t[1] - u; if (o = n - s, h || !(o > 0)) { if (o /= h, h < 0) { if (o < l) return; o < c && (c = o) } else if (h > 0) { if (o > c) return; o > l && (l = o) } if (o = i - s, h || !(o < 0)) { if (o /= h, h < 0) { if (o > c) return; o > l && (l = o) } else if (h > 0) { if (o < l) return; o < c && (c = o) } if (o = r - u, d || !(o > 0)) { if (o /= d, d < 0) { if (o < l) return; o < c && (c = o) } else if (d > 0) { if (o > c) return; o > l && (l = o) } if (o = a - u, d || !(o < 0)) { if (o /= d, d < 0) { if (o > c) return; o > l && (l = o) } else if (d > 0) { if (o < l) return; o < c && (c = o) } return l > 0 && (e[0] = s + l * h, e[1] = u + l * d), c < 1 && (t[0] = s + c * h, t[1] = u + c * d), !0 } } } } }(u, x, e, t, n, r) ? s && (v.lineStart(), v.point(a, o), b = !1) : (g || (v.lineStart(), v.point(u[0], u[1])), v.point(x[0], x[1]), s || v.lineEnd(), b = !1) } p = a, m = o, g = s } return w } } function aI(e, t) { function n(n, r) { return n = e(n, r), t(n[0], n[1]) } return e.invert && t.invert && (n.invert = function (n, r) { return (n = t.invert(n, r)) && e.invert(n[0], n[1]) }), n } const oI = e => e; function sI(e, t) { return EN(e) > kN && (e -= Math.round(e / CN) * CN), [e, t] } function uI(e, t, n) { return (e %= CN) ? t || n ? aI(cI(e), hI(t, n)) : cI(e) : t || n ? hI(t, n) : sI } function lI(e) { return function (t, n) { return EN(t += e) > kN && (t -= Math.round(t / CN) * CN), [t, n] } } function cI(e) { var t = lI(e); return t.invert = lI(-e), t } function hI(e, t) { var n = MN(e), r = FN(e), i = MN(t), a = FN(t); function o(e, t) { var o = MN(t), s = MN(e) * o, u = FN(e) * o, l = FN(t), c = l * n + s * r; return [IN(u * i - c * a, s * n - l * r), RN(c * i + u * a)] } return o.invert = function (e, t) { var o = MN(t), s = MN(e) * o, u = FN(e) * o, l = FN(t), c = l * i - u * a; return [IN(u * i + l * a, s * n + c * r), RN(c * n - s * r)] }, o } function dI(e) { return function (t) { var n = new fI; for (var r in e) n[r] = e[r]; return n.stream = t, n } } function fI() { } function pI(e, t) { e && gI.hasOwnProperty(e.type) && gI[e.type](e, t) } sI.invert = sI, fI.prototype = { constructor: fI, point: function (e, t) { this.stream.point(e, t) }, sphere: function () { this.stream.sphere() }, lineStart: function () { this.stream.lineStart() }, lineEnd: function () { this.stream.lineEnd() }, polygonStart: function () { this.stream.polygonStart() }, polygonEnd: function () { this.stream.polygonEnd() } }; var mI = { Feature: function (e, t) { pI(e.geometry, t) }, FeatureCollection: function (e, t) { for (var n = e.features, r = -1, i = n.length; ++r < i;)pI(n[r].geometry, t) } }, gI = { Sphere: function (e, t) { t.sphere() }, Point: function (e, t) { e = e.coordinates, t.point(e[0], e[1], e[2]) }, MultiPoint: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)e = n[r], t.point(e[0], e[1], e[2]) }, LineString: function (e, t) { yI(e.coordinates, t, 0) }, MultiLineString: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)yI(n[r], t, 0) }, Polygon: function (e, t) { bI(e.coordinates, t) }, MultiPolygon: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)bI(n[r], t) }, GeometryCollection: function (e, t) { for (var n = e.geometries, r = -1, i = n.length; ++r < i;)pI(n[r], t) } }; function yI(e, t, n) { var r, i = -1, a = e.length - n; for (t.lineStart(); ++i < a;)r = e[i], t.point(r[0], r[1], r[2]); t.lineEnd() } function bI(e, t) { var n = -1, r = e.length; for (t.polygonStart(); ++n < r;)yI(e[n], t, 1); t.polygonEnd() } var vI = 1 / 0, xI = vI, wI = -vI, kI = wI, SI = { point: function (e, t) { e < vI && (vI = e); e > wI && (wI = e); t < xI && (xI = t); t > kI && (kI = t) }, lineStart: vN, lineEnd: vN, polygonStart: vN, polygonEnd: vN, result: function () { var e = [[vI, xI], [wI, kI]]; return wI = kI = -(xI = vI = 1 / 0), e } }; const _I = SI; function CI(e, t, n) { var r = e.clipExtent && e.clipExtent(); return e.scale(150).translate([0, 0]), null != r && e.clipExtent(null), function (e, t) { e && mI.hasOwnProperty(e.type) ? mI[e.type](e, t) : pI(e, t) }(n, e.stream(_I)), t(_I.result()), null != r && e.clipExtent(r), e } function AI(e, t, n) { return CI(e, (function (n) { var r = t[1][0] - t[0][0], i = t[1][1] - t[0][1], a = Math.min(r / (n[1][0] - n[0][0]), i / (n[1][1] - n[0][1])), o = +t[0][0] + (r - a * (n[1][0] + n[0][0])) / 2, s = +t[0][1] + (i - a * (n[1][1] + n[0][1])) / 2; e.scale(150 * a).translate([o, s]) }), n) } var TI = MN(30 * TN); function EI(e, t) { return +t ? function (e, t) { function n(r, i, a, o, s, u, l, c, h, d, f, p, m, g) { var y = l - r, b = c - i, v = y * y + b * b; if (v > 4 * t && m--) { var x = o + d, w = s + f, k = u + p, S = $N(x * x + w * w + k * k), _ = RN(k /= S), C = EN(EN(k) - 1) < wN || EN(a - h) < wN ? (a + h) / 2 : IN(w, x), A = e(C, _), T = A[0], E = A[1], N = T - r, I = E - i, M = b * N - y * I; (M * M / v > t || EN((y * N + b * I) / v - .5) > .3 || o * d + s * f + u * p < TI) && (n(r, i, a, o, s, u, T, E, C, x /= S, w /= S, k, m, g), g.point(T, E), n(T, E, C, x, w, k, l, c, h, d, f, p, m, g)) } } return function (t) { var r, i, a, o, s, u, l, c, h, d, f, p, m = { point: g, lineStart: y, lineEnd: v, polygonStart: function () { t.polygonStart(), m.lineStart = x }, polygonEnd: function () { t.polygonEnd(), m.lineStart = y } }; function g(n, r) { n = e(n, r), t.point(n[0], n[1]) } function y() { c = NaN, m.point = b, t.lineStart() } function b(r, i) { var a = UN([r, i]), o = e(r, i); n(c, h, l, d, f, p, c = o[0], h = o[1], l = r, d = a[0], f = a[1], p = a[2], 16, t), t.point(c, h) } function v() { m.point = g, t.lineEnd() } function x() { y(), m.point = w, m.lineEnd = k } function w(e, t) { b(r = e, t), i = c, a = h, o = d, s = f, u = p, m.point = b } function k() { n(c, h, l, d, f, p, i, a, r, o, s, u, 16, t), m.lineEnd = v, v() } return m } }(e, t) : function (e) { return dI({ point: function (t, n) { t = e(t, n), this.stream.point(t[0], t[1]) } }) }(e) } var NI = dI({ point: function (e, t) { this.stream.point(e * TN, t * TN) } }); function II(e, t, n, r, i, a) { if (!a) return function (e, t, n, r, i) { function a(a, o) { return [t + e * (a *= r), n - e * (o *= i)] } return a.invert = function (a, o) { return [(a - t) / e * r, (n - o) / e * i] }, a }(e, t, n, r, i); var o = MN(a), s = FN(a), u = o * e, l = s * e, c = o / e, h = s / e, d = (s * n - o * t) / e, f = (s * t + o * n) / e; function p(e, a) { return [u * (e *= r) - l * (a *= i) + t, n - l * e - u * a] } return p.invert = function (e, t) { return [r * (c * e - h * t + d), i * (f - h * e - c * t)] }, p } function MI(e) { return function (e) { var t, n, r, i, a, o, s, u, l, c, h = 150, d = 480, f = 250, p = 0, m = 0, g = 0, y = 0, b = 0, v = 0, x = 1, w = 1, k = null, S = QN, _ = null, C = oI, A = .5; function T(e) { return u(e[0] * TN, e[1] * TN) } function E(e) { return (e = u.invert(e[0], e[1])) && [e[0] * AN, e[1] * AN] } function N() { var e = II(h, 0, 0, x, w, v).apply(null, t(p, m)), r = II(h, d - e[0], f - e[1], x, w, v); return n = uI(g, y, b), s = aI(t, r), u = aI(n, s), o = EI(s, A), I() } function I() { return l = c = null, T } return T.stream = function (e) { return l && c === e ? l : l = NI(function (e) { return dI({ point: function (t, n) { var r = e(t, n); return this.stream.point(r[0], r[1]) } }) }(n)(S(o(C(c = e))))) }, T.preclip = function (e) { return arguments.length ? (S = e, k = void 0, I()) : S }, T.postclip = function (e) { return arguments.length ? (C = e, _ = r = i = a = null, I()) : C }, T.clipAngle = function (e) { return arguments.length ? (S = +e ? function (e) { var t = MN(e), n = 2 * TN, r = t > 0, i = EN(t) > wN; function a(e, n) { return MN(e) * MN(n) > t } function o(e, n, r) { var i = [1, 0, 0], a = VN(UN(e), UN(n)), o = WN(a, a), s = a[0], u = o - s * s; if (!u) return !r && e; var l = t * o / u, c = -t * s / u, h = VN(i, a), d = HN(i, l); GN(d, HN(a, c)); var f = h, p = WN(d, f), m = WN(f, f), g = p * p - m * (WN(d, d) - 1); if (!(g < 0)) { var y = $N(g), b = HN(f, (-p - y) / m); if (GN(b, d), b = jN(b), !r) return b; var v, x = e[0], w = n[0], k = e[1], S = n[1]; w < x && (v = x, x = w, w = v); var _ = w - x, C = EN(_ - kN) < wN; if (!C && S < k && (v = k, k = S, S = v), C || _ < wN ? C ? k + S > 0 ^ b[1] < (EN(b[0] - x) < wN ? k : S) : k <= b[1] && b[1] <= S : _ > kN ^ (x <= b[0] && b[0] <= w)) { var A = HN(f, (-p + y) / m); return GN(A, d), [b, jN(A)] } } } function s(t, n) { var i = r ? e : kN - e, a = 0; return t < -i ? a |= 1 : t > i && (a |= 2), n < -i ? a |= 4 : n > i && (a |= 8), a } return KN(a, (function (e) { var t, n, u, l, c; return { lineStart: function () { l = u = !1, c = 1 }, point: function (h, d) { var f, p = [h, d], m = a(h, d), g = r ? m ? 0 : s(h, d) : m ? s(h + (h < 0 ? kN : -kN), d) : 0; if (!t && (l = u = m) && e.lineStart(), m !== u && (!(f = o(t, p)) || ON(t, f) || ON(p, f)) && (p[2] = 1), m !== u) c = 0, m ? (e.lineStart(), f = o(p, t), e.point(f[0], f[1])) : (f = o(t, p), e.point(f[0], f[1], 2), e.lineEnd()), t = f; else if (i && t && r ^ m) { var y; g & n || !(y = o(p, t, !0)) || (c = 0, r ? (e.lineStart(), e.point(y[0][0], y[0][1]), e.point(y[1][0], y[1][1]), e.lineEnd()) : (e.point(y[1][0], y[1][1]), e.lineEnd(), e.lineStart(), e.point(y[0][0], y[0][1], 3))) } !m || t && ON(t, p) || e.point(p[0], p[1]), t = p, u = m, n = g }, lineEnd: function () { u && e.lineEnd(), t = null }, clean: function () { return c | (l && u) << 1 } } }), (function (t, r, i, a) { eI(a, e, n, i, t, r) }), r ? [0, -e] : [-kN, e - kN]) }(k = e * TN) : (k = null, QN), I()) : k * AN }, T.clipExtent = function (e) { return arguments.length ? (C = null == e ? (_ = r = i = a = null, oI) : iI(_ = +e[0][0], r = +e[0][1], i = +e[1][0], a = +e[1][1]), I()) : null == _ ? null : [[_, r], [i, a]] }, T.scale = function (e) { return arguments.length ? (h = +e, N()) : h }, T.translate = function (e) { return arguments.length ? (d = +e[0], f = +e[1], N()) : [d, f] }, T.center = function (e) { return arguments.length ? (p = e[0] % 360 * TN, m = e[1] % 360 * TN, N()) : [p * AN, m * AN] }, T.rotate = function (e) { return arguments.length ? (g = e[0] % 360 * TN, y = e[1] % 360 * TN, b = e.length > 2 ? e[2] % 360 * TN : 0, N()) : [g * AN, y * AN, b * AN] }, T.angle = function (e) { return arguments.length ? (v = e % 360 * TN, N()) : v * AN }, T.reflectX = function (e) { return arguments.length ? (x = e ? -1 : 1, N()) : x < 0 }, T.reflectY = function (e) { return arguments.length ? (w = e ? -1 : 1, N()) : w < 0 }, T.precision = function (e) { return arguments.length ? (o = EI(s, A = e * e), I()) : $N(A) }, T.fitExtent = function (e, t) { return AI(T, e, t) }, T.fitSize = function (e, t) { return function (e, t, n) { return AI(e, [[0, 0], t], n) }(T, e, t) }, T.fitWidth = function (e, t) { return function (e, t, n) { return CI(e, (function (n) { var r = +t, i = r / (n[1][0] - n[0][0]), a = (r - i * (n[1][0] + n[0][0])) / 2, o = -i * n[0][1]; e.scale(150 * i).translate([a, o]) }), n) }(T, e, t) }, T.fitHeight = function (e, t) { return function (e, t, n) { return CI(e, (function (n) { var r = +t, i = r / (n[1][1] - n[0][1]), a = -i * n[0][0], o = (r - i * (n[1][1] + n[0][1])) / 2; e.scale(150 * i).translate([a, o]) }), n) }(T, e, t) }, function () { return t = e.apply(this, arguments), T.invert = t.invert && E, N() } }((function () { return e }))() } var FI = Math.abs, DI = (Math.atan, Math.atan2, Math.ceil, Math.cos), $I = (Math.exp, Math.floor, Math.log, Math.max, Math.min, Math.pow, Math.round, Math.sign, Math.sin), RI = (Math.tan, Math.PI), OI = RI / 2, zI = (Math.SQRT1_2, BI(2)); BI(RI); function PI(e) { return e > 1 ? OI : e < -1 ? -OI : Math.asin(e) } function BI(e) { return e > 0 ? Math.sqrt(e) : 0 } function LI(e, t) { var n, r = e * $I(t), i = 30; do { t -= n = (t + $I(t) - r) / (1 + DI(t)) } while (FI(n) > 1e-6 && --i > 0); return t / 2 } var jI = function (e, t, n) { function r(r, i) { return [e * r * DI(i = LI(n, i)), t * $I(i)] } return r.invert = function (r, i) { return i = PI(i / t), [r / (e * DI(i)), PI((2 * i + $I(2 * i)) / n)] }, r }(zI / OI, zI, RI); const UI = aE(), WI = ["clipAngle", "clipExtent", "scale", "translate", "center", "rotate", "parallels", "precision", "reflectX", "reflectY", "coefficient", "distance", "fraction", "lobes", "parallel", "radius", "ratio", "spacing", "tilt"]; function VI(e, t) { if (!e || "string" != typeof e) throw new Error("Projection type must be a name string."); return e = e.toLowerCase(), arguments.length > 1 ? (HI[e] = function (e, t) { return function n() { const r = t(); return r.type = e, r.path = aE().projection(r), r.copy = r.copy || function () { const e = n(); return WI.forEach((t => { r[t] && e[t](r[t]()) })), e.path.pointRadius(r.path.pointRadius()), e }, db(r) } }(e, t), this) : HI[e] || null } function GI(e) { return e && e.path || UI } const HI = { albers: ZE, albersusa: function () { var e, t, n, r, i, a, o = ZE(), s = KE().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), u = KE().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), l = { point: function (e, t) { a = [e, t] } }; function c(e) { var t = e[0], o = e[1]; return a = null, n.point(t, o), a || (r.point(t, o), a) || (i.point(t, o), a) } function h() { return e = t = null, c } return c.invert = function (e) { var t = o.scale(), n = o.translate(), r = (e[0] - n[0]) / t, i = (e[1] - n[1]) / t; return (i >= .12 && i < .234 && r >= -.425 && r < -.214 ? s : i >= .166 && i < .234 && r >= -.214 && r < -.115 ? u : o).invert(e) }, c.stream = function (n) { return e && t === n ? e : e = function (e) { var t = e.length; return { point: function (n, r) { for (var i = -1; ++i < t;)e[i].point(n, r) }, sphere: function () { for (var n = -1; ++n < t;)e[n].sphere() }, lineStart: function () { for (var n = -1; ++n < t;)e[n].lineStart() }, lineEnd: function () { for (var n = -1; ++n < t;)e[n].lineEnd() }, polygonStart: function () { for (var n = -1; ++n < t;)e[n].polygonStart() }, polygonEnd: function () { for (var n = -1; ++n < t;)e[n].polygonEnd() } } }([o.stream(t = n), s.stream(n), u.stream(n)]) }, c.precision = function (e) { return arguments.length ? (o.precision(e), s.precision(e), u.precision(e), h()) : o.precision() }, c.scale = function (e) { return arguments.length ? (o.scale(e), s.scale(.35 * e), u.scale(e), c.translate(o.translate())) : o.scale() }, c.translate = function (e) { if (!arguments.length) return o.translate(); var t = o.scale(), a = +e[0], c = +e[1]; return n = o.translate(e).clipExtent([[a - .455 * t, c - .238 * t], [a + .455 * t, c + .238 * t]]).stream(l), r = s.translate([a - .307 * t, c + .201 * t]).clipExtent([[a - .425 * t + DA, c + .12 * t + DA], [a - .214 * t - DA, c + .234 * t - DA]]).stream(l), i = u.translate([a - .205 * t, c + .212 * t]).clipExtent([[a - .214 * t + DA, c + .166 * t + DA], [a - .115 * t - DA, c + .234 * t - DA]]).stream(l), h() }, c.fitExtent = function (e, t) { return PE(c, e, t) }, c.fitSize = function (e, t) { return BE(c, e, t) }, c.fitWidth = function (e, t) { return LE(c, e, t) }, c.fitHeight = function (e, t) { return jE(c, e, t) }, c.scale(1070) }, azimuthalequalarea: function () { return HE(eN).scale(124.75).clipAngle(179.999) }, azimuthalequidistant: function () { return HE(tN).scale(79.4188).clipAngle(179.999) }, conicconformal: function () { return YE(aN).scale(109.5).parallels([30, 30]) }, conicequalarea: KE, conicequidistant: function () { return YE(sN).scale(131.154).center([0, 13.9389]) }, equalEarth: function () { return HE(fN).scale(177.158) }, equirectangular: function () { return HE(oN).scale(152.63) }, gnomonic: function () { return HE(pN).scale(144.049).clipAngle(60) }, identity: function () { var e, t, n, r, i, a, o, s = 1, u = 0, l = 0, c = 1, h = 1, d = 0, f = null, p = 1, m = 1, g = RE({ point: function (e, t) { var n = v([e, t]); this.stream.point(n[0], n[1]) } }), y = CA; function b() { return p = s * c, m = s * h, a = o = null, v } function v(n) { var r = n[0] * p, i = n[1] * m; if (d) { var a = i * e - r * t; r = r * e + i * t, i = a } return [r + u, i + l] } return v.invert = function (n) { var r = n[0] - u, i = n[1] - l; if (d) { var a = i * e + r * t; r = r * e - i * t, i = a } return [r / p, i / m] }, v.stream = function (e) { return a && o === e ? a : a = g(y(o = e)) }, v.postclip = function (e) { return arguments.length ? (y = e, f = n = r = i = null, b()) : y }, v.clipExtent = function (e) { return arguments.length ? (y = null == e ? (f = n = r = i = null, CA) : EE(f = +e[0][0], n = +e[0][1], r = +e[1][0], i = +e[1][1]), b()) : null == f ? null : [[f, n], [r, i]] }, v.scale = function (e) { return arguments.length ? (s = +e, b()) : s }, v.translate = function (e) { return arguments.length ? (u = +e[0], l = +e[1], b()) : [u, l] }, v.angle = function (n) { return arguments.length ? (t = qA(d = n % 360 * BA), e = WA(d), b()) : d * PA }, v.reflectX = function (e) { return arguments.length ? (c = e ? -1 : 1, b()) : c < 0 }, v.reflectY = function (e) { return arguments.length ? (h = e ? -1 : 1, b()) : h < 0 }, v.fitExtent = function (e, t) { return PE(v, e, t) }, v.fitSize = function (e, t) { return BE(v, e, t) }, v.fitWidth = function (e, t) { return LE(v, e, t) }, v.fitHeight = function (e, t) { return jE(v, e, t) }, v }, mercator: function () { return rN(nN).scale(961 / zA) }, mollweide: function () { return MI(jI).scale(169.529) }, naturalEarth1: function () { return HE(mN).scale(175.295) }, orthographic: function () { return HE(gN).scale(249.5).clipAngle(90.000001) }, stereographic: function () { return HE(yN).scale(250).clipAngle(142) }, transversemercator: function () { var e = rN(bN), t = e.center, n = e.rotate; return e.center = function (e) { return arguments.length ? t([-e[1], e[0]]) : [(e = t())[1], -e[0]] }, e.rotate = function (e) { return arguments.length ? n([e[0], e[1], e.length > 2 ? e[2] + 90 : 90]) : [(e = n())[0], e[1], e[2] - 90] }, n([0, 0, 90]).scale(159.155) } }; for (const e in HI) VI(e, HI[e]); var qI = 1e-6, YI = 1e-12, XI = Math.PI, KI = XI / 2, ZI = XI / 4, JI = 2 * XI, QI = 180 / XI, eM = XI / 180, tM = Math.abs, nM = Math.atan, rM = Math.atan2, iM = Math.cos, aM = Math.ceil, oM = Math.exp, sM = (Math.floor, Math.hypot), uM = Math.log, lM = Math.pow, cM = Math.sin, hM = Math.sign || function (e) { return e > 0 ? 1 : e < 0 ? -1 : 0 }, dM = Math.sqrt, fM = Math.tan; function pM(e) { return e > 1 ? 0 : e < -1 ? XI : Math.acos(e) } function mM(e) { return e > 1 ? KI : e < -1 ? -KI : Math.asin(e) } function gM(e, t, n) { var r = Fl(e, t - qI, n).concat(t); return function (e) { return r.map((function (t) { return [e, t] })) } } function yM(e, t, n) { var r = Fl(e, t - qI, n).concat(t); return function (e) { return r.map((function (t) { return [t, e] })) } } function bM() { var e, t, n, r, i, a, o, s, u, l, c, h, d = 10, f = d, p = 90, m = 360, g = 2.5; function y() { return { type: "MultiLineString", coordinates: b() } } function b() { return Fl(aM(r / p) * p, n, p).map(c).concat(Fl(aM(s / m) * m, o, m).map(h)).concat(Fl(aM(t / d) * d, e, d).filter((function (e) { return tM(e % p) > qI })).map(u)).concat(Fl(aM(a / f) * f, i, f).filter((function (e) { return tM(e % m) > qI })).map(l)) } return y.lines = function () { return b().map((function (e) { return { type: "LineString", coordinates: e } })) }, y.outline = function () { return { type: "Polygon", coordinates: [c(r).concat(h(o).slice(1), c(n).reverse().slice(1), h(s).reverse().slice(1))] } }, y.extent = function (e) { return arguments.length ? y.extentMajor(e).extentMinor(e) : y.extentMinor() }, y.extentMajor = function (e) { return arguments.length ? (r = +e[0][0], n = +e[1][0], s = +e[0][1], o = +e[1][1], r > n && (e = r, r = n, n = e), s > o && (e = s, s = o, o = e), y.precision(g)) : [[r, s], [n, o]] }, y.extentMinor = function (n) { return arguments.length ? (t = +n[0][0], e = +n[1][0], a = +n[0][1], i = +n[1][1], t > e && (n = t, t = e, e = n), a > i && (n = a, a = i, i = n), y.precision(g)) : [[t, a], [e, i]] }, y.step = function (e) { return arguments.length ? y.stepMajor(e).stepMinor(e) : y.stepMinor() }, y.stepMajor = function (e) { return arguments.length ? (p = +e[0], m = +e[1], y) : [p, m] }, y.stepMinor = function (e) { return arguments.length ? (d = +e[0], f = +e[1], y) : [d, f] }, y.precision = function (d) { return arguments.length ? (g = +d, u = gM(a, i, 90), l = yM(t, e, g), c = gM(s, o, 90), h = yM(r, n, g), y) : g }, y.extentMajor([[-180, -90 + qI], [180, 90 - qI]]).extentMinor([[-180, -80 - qI], [180, 80 + qI]]) } function vM() { } const xM = [[], [[[1, 1.5], [.5, 1]]], [[[1.5, 1], [1, 1.5]]], [[[1.5, 1], [.5, 1]]], [[[1, .5], [1.5, 1]]], [[[1, 1.5], [.5, 1]], [[1, .5], [1.5, 1]]], [[[1, .5], [1, 1.5]]], [[[1, .5], [.5, 1]]], [[[.5, 1], [1, .5]]], [[[1, 1.5], [1, .5]]], [[[.5, 1], [1, .5]], [[1.5, 1], [1, 1.5]]], [[[1.5, 1], [1, .5]]], [[[.5, 1], [1.5, 1]]], [[[1, 1.5], [1.5, 1]]], [[[.5, 1], [1, 1.5]]], []]; function wM() { var e = 1, t = 1, n = o; function r(e, t) { return t.map((t => i(e, t))) } function i(r, i) { var o = [], s = []; return function (n, r, i) { var o, s, u, l, c, h, d = new Array, f = new Array; o = s = -1, l = n[0] >= r, xM[l << 1].forEach(p); for (; ++o < e - 1;)u = l, l = n[o + 1] >= r, xM[u | l << 1].forEach(p); xM[l | 0].forEach(p); for (; ++s < t - 1;) { for (o = -1, l = n[s * e + e] >= r, c = n[s * e] >= r, xM[l << 1 | c << 2].forEach(p); ++o < e - 1;)u = l, l = n[s * e + e + o + 1] >= r, h = c, c = n[s * e + o + 1] >= r, xM[u | l << 1 | c << 2 | h << 3].forEach(p); xM[l | c << 3].forEach(p) } o = -1, c = n[s * e] >= r, xM[c << 2].forEach(p); for (; ++o < e - 1;)h = c, c = n[s * e + o + 1] >= r, xM[c << 2 | h << 3].forEach(p); function p(e) { var t, n, r = [e[0][0] + o, e[0][1] + s], u = [e[1][0] + o, e[1][1] + s], l = a(r), c = a(u); (t = f[l]) ? (n = d[c]) ? (delete f[t.end], delete d[n.start], t === n ? (t.ring.push(u), i(t.ring)) : d[t.start] = f[n.end] = { start: t.start, end: n.end, ring: t.ring.concat(n.ring) }) : (delete f[t.end], t.ring.push(u), f[t.end = c] = t) : (t = d[c]) ? (n = f[l]) ? (delete d[t.start], delete f[n.end], t === n ? (t.ring.push(u), i(t.ring)) : d[n.start] = f[t.end] = { start: n.start, end: t.end, ring: n.ring.concat(t.ring) }) : (delete d[t.start], t.ring.unshift(r), d[t.start = l] = t) : d[l] = f[c] = { start: l, end: c, ring: [r, u] } } xM[c << 3].forEach(p) }(r, i, (e => { n(e, r, i), function (e) { var t = 0, n = e.length, r = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; for (; ++t < n;)r += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1]; return r }(e) > 0 ? o.push([e]) : s.push(e) })), s.forEach((e => { for (var t, n = 0, r = o.length; n < r; ++n)if (-1 !== kM((t = o[n])[0], e)) return void t.push(e) })), { type: "MultiPolygon", value: i, coordinates: o } } function a(t) { return 2 * t[0] + t[1] * (e + 1) * 4 } function o(n, r, i) { n.forEach((n => { var a, o = n[0], s = n[1], u = 0 | o, l = 0 | s, c = r[l * e + u]; o > 0 && o < e && u === o && (a = r[l * e + u - 1], n[0] = o + (i - a) / (c - a) - .5), s > 0 && s < t && l === s && (a = r[(l - 1) * e + u], n[1] = s + (i - a) / (c - a) - .5) })) } return r.contour = i, r.size = function (n) { if (!arguments.length) return [e, t]; var i = Math.floor(n[0]), a = Math.floor(n[1]); return i >= 0 && a >= 0 || Vt("invalid size"), e = i, t = a, r }, r.smooth = function (e) { return arguments.length ? (n = e ? o : vM, r) : n === o }, r } function kM(e, t) { for (var n, r = -1, i = t.length; ++r < i;)if (n = SM(e, t[r])) return n; return 0 } function SM(e, t) { for (var n = t[0], r = t[1], i = -1, a = 0, o = e.length, s = o - 1; a < o; s = a++) { var u = e[a], l = u[0], c = u[1], h = e[s], d = h[0], f = h[1]; if (_M(u, h, t)) return 0; c > r != f > r && n < (d - l) * (r - c) / (f - c) + l && (i = -i) } return i } function _M(e, t, n) { var r, i, a, o; return function (e, t, n) { return (t[0] - e[0]) * (n[1] - e[1]) == (n[0] - e[0]) * (t[1] - e[1]) }(e, t, n) && (i = e[r = +(e[0] === t[0])], a = n[r], o = t[r], i <= a && a <= o || o <= a && a <= i) } function CM(e, t, n) { return function (r) { var i = Rn(r), a = n ? Math.min(i[0], 0) : i[0], o = i[1], s = o - a, u = t ? _A(a, o, e) : s / (e + 1); return Fl(a + u, o, u) } } function AM(e) { Eu.call(this, null, e) } function TM(e, t, n, r, i) { const a = e.x1 || 0, o = e.y1 || 0, s = t * n < 0; function u(e) { e.forEach(l) } function l(e) { s && e.reverse(), e.forEach(c) } function c(e) { e[0] = (e[0] - a) * t + r, e[1] = (e[1] - o) * n + i } return function (e) { return e.coordinates.forEach(u), e } } function EM(e, t, n) { const r = e >= 0 ? e : Gu(t, n); return Math.round((Math.sqrt(4 * r * r + 1) - 1) / 2) } function NM(e) { return Cn(e) ? e : Fn(+e) } function IM() { var e = e => e[0], t = e => e[1], n = Kt, r = [-1, -1], i = 960, a = 500, o = 2; function s(s, u) { const l = EM(r[0], s, e) >> o, c = EM(r[1], s, t) >> o, h = l ? l + 2 : 0, d = c ? c + 2 : 0, f = 2 * h + (i >> o), p = 2 * d + (a >> o), m = new Float32Array(f * p), g = new Float32Array(f * p); let y = m; s.forEach((r => { const i = h + (+e(r) >> o), a = d + (+t(r) >> o); i >= 0 && i < f && a >= 0 && a < p && (m[i + a * f] += +n(r)) })), l > 0 && c > 0 ? (MM(f, p, m, g, l), FM(f, p, g, m, c), MM(f, p, m, g, l), FM(f, p, g, m, c), MM(f, p, m, g, l), FM(f, p, g, m, c)) : l > 0 ? (MM(f, p, m, g, l), MM(f, p, g, m, l), MM(f, p, m, g, l), y = g) : c > 0 && (FM(f, p, m, g, c), FM(f, p, g, m, c), FM(f, p, m, g, c), y = g); const b = u ? Math.pow(2, -2 * o) : 1 / L_(y); for (let e = 0, t = f * p; e < t; ++e)y[e] *= b; return { values: y, scale: 1 << o, width: f, height: p, x1: h, y1: d, x2: h + (i >> o), y2: d + (a >> o) } } return s.x = function (t) { return arguments.length ? (e = NM(t), s) : e }, s.y = function (e) { return arguments.length ? (t = NM(e), s) : t }, s.weight = function (e) { return arguments.length ? (n = NM(e), s) : n }, s.size = function (e) { if (!arguments.length) return [i, a]; var t = +e[0], n = +e[1]; return t >= 0 && n >= 0 || Vt("invalid size"), i = t, a = n, s }, s.cellSize = function (e) { return arguments.length ? ((e = +e) >= 1 || Vt("invalid cell size"), o = Math.floor(Math.log(e) / Math.LN2), s) : 1 << o }, s.bandwidth = function (e) { return arguments.length ? (1 === (e = _n(e)).length && (e = [+e[0], +e[0]]), 2 !== e.length && Vt("invalid bandwidth"), r = e, s) : r }, s } function MM(e, t, n, r, i) { const a = 1 + (i << 1); for (let o = 0; o < t; ++o)for (let t = 0, s = 0; t < e + i; ++t)t < e && (s += n[t + o * e]), t >= i && (t >= a && (s -= n[t - a + o * e]), r[t - i + o * e] = s / Math.min(t + 1, e - 1 + a - t, a)) } function FM(e, t, n, r, i) { const a = 1 + (i << 1); for (let o = 0; o < e; ++o)for (let s = 0, u = 0; s < t + i; ++s)s < t && (u += n[o + s * e]), s >= i && (s >= a && (u -= n[o + (s - a) * e]), r[o + (s - i) * e] = u / Math.min(s + 1, t - 1 + a - s, a)) } function DM(e) { Eu.call(this, null, e) } AM.Definition = { type: "Isocontour", metadata: { generates: !0 }, params: [{ name: "field", type: "field" }, { name: "thresholds", type: "number", array: !0 }, { name: "levels", type: "number" }, { name: "nice", type: "boolean", default: !1 }, { name: "resolve", type: "enum", values: ["shared", "independent"], default: "independent" }, { name: "zero", type: "boolean", default: !0 }, { name: "smooth", type: "boolean", default: !0 }, { name: "scale", type: "number", expr: !0 }, { name: "translate", type: "number", array: !0, expr: !0 }, { name: "as", type: "string", null: !0, default: "contour" }] }, Ln(AM, Eu, { transform(e, t) { if (this.value && !t.changed() && !e.modified()) return t.StopPropagation; var n = t.fork(t.NO_SOURCE | t.NO_FIELDS), r = t.materialize(t.SOURCE).source, i = e.field || Yt, a = wM().smooth(!1 !== e.smooth), o = e.thresholds || function (e, t, n) { const r = CM(n.levels || 10, n.nice, !1 !== n.zero); return "shared" !== n.resolve ? r : r(e.map((e => Sl(t(e).values)))) }(r, i, e), s = null === e.as ? null : e.as || "contour", u = []; return r.forEach((t => { const n = i(t), r = a.size([n.width, n.height])(n.values, on(o) ? o : o(n.values)); !function (e, t, n, r) { let i = r.scale || t.scale, a = r.translate || t.translate; Cn(i) && (i = i(n, r)); Cn(a) && (a = a(n, r)); if ((1 === i || null == i) && !a) return; const o = (Wn(i) ? i : i[0]) || 1, s = (Wn(i) ? i : i[1]) || 1, u = a && a[0] || 0, l = a && a[1] || 0; e.forEach(TM(t, o, s, u, l)) }(r, n, t, e), r.forEach((e => { u.push(Qs(t, Zs(null != s ? { [s]: e } : e))) })) })), this.value && (n.rem = this.value), this.value = n.source = n.add = u, n } }), DM.Definition = { type: "KDE2D", metadata: { generates: !0 }, params: [{ name: "size", type: "number", array: !0, length: 2, required: !0 }, { name: "x", type: "field", required: !0 }, { name: "y", type: "field", required: !0 }, { name: "weight", type: "field" }, { name: "groupby", type: "field", array: !0 }, { name: "cellSize", type: "number" }, { name: "bandwidth", type: "number", array: !0, length: 2 }, { name: "counts", type: "boolean", default: !1 }, { name: "as", type: "string", default: "grid" }] }; const $M = ["x", "y", "weight", "size", "cellSize", "bandwidth"]; function RM(e, t) { return $M.forEach((n => null != t[n] ? e[n](t[n]) : 0)), e } function OM(e) { Eu.call(this, null, e) } Ln(DM, Eu, { transform(e, t) { if (this.value && !t.changed() && !e.modified()) return t.StopPropagation; var n, r = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = function (e, t) { var n, r, i, a, o, s, u = [], l = e => e(a); if (null == t) u.push(e); else for (n = {}, r = 0, i = e.length; r < i; ++r)a = e[r], (s = n[o = t.map(l)]) || (n[o] = s = [], s.dims = o, u.push(s)), s.push(a); return u }(t.materialize(t.SOURCE).source, e.groupby), a = (e.groupby || []).map(Bt), o = RM(IM(), e), s = e.as || "grid"; return n = i.map((t => Zs(function (e, t) { for (let n = 0; n < a.length; ++n)e[a[n]] = t[n]; return e }({ [s]: o(t, e.counts) }, t.dims)))), this.value && (r.rem = this.value), this.value = r.source = r.add = n, r } }), OM.Definition = { type: "Contour", metadata: { generates: !0 }, params: [{ name: "size", type: "number", array: !0, length: 2, required: !0 }, { name: "values", type: "number", array: !0 }, { name: "x", type: "field" }, { name: "y", type: "field" }, { name: "weight", type: "field" }, { name: "cellSize", type: "number" }, { name: "bandwidth", type: "number" }, { name: "count", type: "number" }, { name: "nice", type: "boolean", default: !1 }, { name: "thresholds", type: "number", array: !0 }, { name: "smooth", type: "boolean", default: !0 }] }, Ln(OM, Eu, { transform(e, t) { if (this.value && !t.changed() && !e.modified()) return t.StopPropagation; var n, r, i = t.fork(t.NO_SOURCE | t.NO_FIELDS), a = wM().smooth(!1 !== e.smooth), o = e.values, s = e.thresholds || CM(e.count || 10, e.nice, !!o), u = e.size; return o || (o = t.materialize(t.SOURCE).source, r = TM(n = RM(IM(), e)(o, !0), n.scale || 1, n.scale || 1, 0, 0), u = [n.width, n.height], o = n.values), s = on(s) ? s : s(o), o = a.size(u)(o, s), r && o.forEach(r), this.value && (i.rem = this.value), this.value = i.source = i.add = (o || []).map(Zs), i } }); const zM = "Feature", PM = "FeatureCollection"; function BM(e) { Eu.call(this, null, e) } function LM(e) { Eu.call(this, null, e) } function jM(e) { Eu.call(this, null, e) } function UM(e) { Eu.call(this, null, e) } function WM(e) { Eu.call(this, [], e), this.generator = bM() } function VM(e) { Eu.call(this, null, e) } function GM(e) { if (!Cn(e)) return !1; const t = Qn(Lt(e)); return t.$x || t.$y || t.$value || t.$max } function HM(e) { Eu.call(this, null, e), this.modified(!0) } function qM(e, t, n) { Cn(e[t]) && e[t](n) } function YM(e, t, n, r) { if (isNaN(t) || isNaN(n)) return e; var i, a, o, s, u, l, c, h, d, f = e._root, p = { data: r }, m = e._x0, g = e._y0, y = e._x1, b = e._y1; if (!f) return e._root = p, e; for (; f.length;)if ((l = t >= (a = (m + y) / 2)) ? m = a : y = a, (c = n >= (o = (g + b) / 2)) ? g = o : b = o, i = f, !(f = f[h = c << 1 | l])) return i[h] = p, e; if (s = +e._x.call(null, f.data), u = +e._y.call(null, f.data), t === s && n === u) return p.next = f, i ? i[h] = p : e._root = p, e; do { i = i ? i[h] = new Array(4) : e._root = new Array(4), (l = t >= (a = (m + y) / 2)) ? m = a : y = a, (c = n >= (o = (g + b) / 2)) ? g = o : b = o } while ((h = c << 1 | l) == (d = (u >= o) << 1 | s >= a)); return i[d] = f, i[h] = p, e } function XM(e, t, n, r, i) { this.node = e, this.x0 = t, this.y0 = n, this.x1 = r, this.y1 = i } function KM(e) { return e[0] } function ZM(e) { return e[1] } function JM(e, t, n) { var r = new QM(null == t ? KM : t, null == n ? ZM : n, NaN, NaN, NaN, NaN); return null == e ? r : r.addAll(e) } function QM(e, t, n, r, i, a) { this._x = e, this._y = t, this._x0 = n, this._y0 = r, this._x1 = i, this._y1 = a, this._root = void 0 } function eF(e) { for (var t = { data: e.data }, n = t; e = e.next;)n = n.next = { data: e.data }; return t } BM.Definition = { type: "GeoJSON", metadata: {}, params: [{ name: "fields", type: "field", array: !0, length: 2 }, { name: "geojson", type: "field" }] }, Ln(BM, Eu, { transform(e, t) { var n, r = this._features, i = this._points, a = e.fields, o = a && a[0], s = a && a[1], u = e.geojson || !a && Yt, l = t.ADD; n = e.modified() || t.changed(t.REM) || t.modified(Lt(u)) || o && t.modified(Lt(o)) || s && t.modified(Lt(s)), this.value && !n || (l = t.SOURCE, this._features = r = [], this._points = i = []), u && t.visit(l, (e => r.push(u(e)))), o && s && (t.visit(l, (e => { var t = o(e), n = s(e); null != t && null != n && (t = +t) === t && (n = +n) === n && i.push([t, n]) })), r = r.concat({ type: zM, geometry: { type: "MultiPoint", coordinates: i } })), this.value = { type: PM, features: r } } }), LM.Definition = { type: "GeoPath", metadata: { modifies: !0 }, params: [{ name: "projection", type: "projection" }, { name: "field", type: "field" }, { name: "pointRadius", type: "number", expr: !0 }, { name: "as", type: "string", default: "path" }] }, Ln(LM, Eu, { transform(e, t) { var n = t.fork(t.ALL), r = this.value, i = e.field || Yt, a = e.as || "path", o = n.SOURCE; !r || e.modified() ? (this.value = r = GI(e.projection), n.materialize().reflow()) : o = i === Yt || t.modified(i.fields) ? n.ADD_MOD : n.ADD; const s = function (e, t) { const n = e.pointRadius(); e.context(null), null != t && e.pointRadius(t); return n }(r, e.pointRadius); return n.visit(o, (e => e[a] = r(i(e)))), r.pointRadius(s), n.modifies(a) } }), jM.Definition = { type: "GeoPoint", metadata: { modifies: !0 }, params: [{ name: "projection", type: "projection", required: !0 }, { name: "fields", type: "field", array: !0, required: !0, length: 2 }, { name: "as", type: "string", array: !0, length: 2, default: ["x", "y"] }] }, Ln(jM, Eu, { transform(e, t) { var n, r = e.projection, i = e.fields[0], a = e.fields[1], o = e.as || ["x", "y"], s = o[0], u = o[1]; function l(e) { const t = r([i(e), a(e)]); t ? (e[s] = t[0], e[u] = t[1]) : (e[s] = void 0, e[u] = void 0) } return e.modified() ? t = t.materialize().reflow(!0).visit(t.SOURCE, l) : (n = t.modified(i.fields) || t.modified(a.fields), t.visit(n ? t.ADD_MOD : t.ADD, l)), t.modifies(o) } }), UM.Definition = { type: "GeoShape", metadata: { modifies: !0, nomod: !0 }, params: [{ name: "projection", type: "projection" }, { name: "field", type: "field", default: "datum" }, { name: "pointRadius", type: "number", expr: !0 }, { name: "as", type: "string", default: "shape" }] }, Ln(UM, Eu, { transform(e, t) { var n = t.fork(t.ALL), r = this.value, i = e.as || "shape", a = n.ADD; return r && !e.modified() || (this.value = r = function (e, t, n) { const r = null == n ? n => e(t(n)) : r => { var i = e.pointRadius(), a = e.pointRadius(n)(t(r)); return e.pointRadius(i), a }; return r.context = t => (e.context(t), r), r }(GI(e.projection), e.field || Ht("datum"), e.pointRadius), n.materialize().reflow(), a = n.SOURCE), n.visit(a, (e => e[i] = r)), n.modifies(i) } }), WM.Definition = { type: "Graticule", metadata: { changes: !0, generates: !0 }, params: [{ name: "extent", type: "array", array: !0, length: 2, content: { type: "number", array: !0, length: 2 } }, { name: "extentMajor", type: "array", array: !0, length: 2, content: { type: "number", array: !0, length: 2 } }, { name: "extentMinor", type: "array", array: !0, length: 2, content: { type: "number", array: !0, length: 2 } }, { name: "step", type: "number", array: !0, length: 2 }, { name: "stepMajor", type: "number", array: !0, length: 2, default: [90, 360] }, { name: "stepMinor", type: "number", array: !0, length: 2, default: [10, 10] }, { name: "precision", type: "number", default: 2.5 }] }, Ln(WM, Eu, { transform(e, t) { var n, r = this.value, i = this.generator; if (!r.length || e.modified()) for (const t in e) Cn(i[t]) && i[t](e[t]); return n = i(), r.length ? t.mod.push(eu(r[0], n)) : t.add.push(Zs(n)), r[0] = n, t } }), VM.Definition = { type: "heatmap", metadata: { modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "color", type: "string", expr: !0 }, { name: "opacity", type: "number", expr: !0 }, { name: "resolve", type: "enum", values: ["shared", "independent"], default: "independent" }, { name: "as", type: "string", default: "image" }] }, Ln(VM, Eu, { transform(e, t) { if (!t.changed() && !e.modified()) return t.StopPropagation; var n = t.materialize(t.SOURCE).source, r = "shared" === e.resolve, i = e.field || Yt, a = function (e, t) { let n; Cn(e) ? (n = n => e(n, t), n.dep = GM(e)) : e ? n = Fn(e) : (n = e => e.$value / e.$max || 0, n.dep = !0); return n }(e.opacity, e), o = function (e, t) { let n; Cn(e) ? (n = n => cC(e(n, t)), n.dep = GM(e)) : n = Fn(cC(e || "#888")); return n }(e.color, e), s = e.as || "image", u = { $x: 0, $y: 0, $value: 0, $max: r ? Sl(n.map((e => Sl(i(e).values)))) : 0 }; return n.forEach((e => { const t = i(e), n = $n({}, e, u); r || (n.$max = Sl(t.values || [])), e[s] = function (e, t, n, r) { const i = e.width, a = e.height, o = e.x1 || 0, s = e.y1 || 0, u = e.x2 || i, l = e.y2 || a, c = e.values, h = c ? e => c[e] : Xt, d = Fd(u - o, l - s), f = d.getContext("2d"), p = f.getImageData(0, 0, u - o, l - s), m = p.data; for (let e = s, a = 0; e < l; ++e) { t.$y = e - s; for (let s = o, l = e * i; s < u; ++s, a += 4) { t.$x = s - o, t.$value = h(s + l); const e = n(t); m[a + 0] = e.r, m[a + 1] = e.g, m[a + 2] = e.b, m[a + 3] = ~~(255 * r(t)) } } return f.putImageData(p, 0, 0), d }(t, n, o.dep ? o : Fn(o(n)), a.dep ? a : Fn(a(n))) })), t.reflow(!0).modifies(s) } }), Ln(HM, Eu, { transform(e, t) { let n = this.value; return !n || e.modified("type") ? (this.value = n = function (e) { const t = VI((e || "mercator").toLowerCase()); t || Vt("Unrecognized projection type: " + e); return t() }(e.type), WI.forEach((t => { null != e[t] && qM(n, t, e[t]) }))) : WI.forEach((t => { e.modified(t) && qM(n, t, e[t]) })), null != e.pointRadius && n.path.pointRadius(e.pointRadius), e.fit && function (e, t) { const n = function (e) { return e = _n(e), 1 === e.length ? e[0] : { type: PM, features: e.reduce(((e, t) => e.concat(function (e) { return e.type === PM ? e.features : _n(e).filter((e => null != e)).map((e => e.type === zM ? e : { type: zM, geometry: e })) }(t))), []) } }(t.fit); t.extent ? e.fitExtent(t.extent, n) : t.size && e.fitSize(t.size, n) }(n, e), t.fork(t.NO_SOURCE | t.NO_FIELDS) } }); var tF = JM.prototype = QM.prototype; function nF(e) { return function () { return e } } function rF(e) { return 1e-6 * (e() - .5) } function iF(e) { return e.x + e.vx } function aF(e) { return e.y + e.vy } tF.copy = function () { var e, t, n = new QM(this._x, this._y, this._x0, this._y0, this._x1, this._y1), r = this._root; if (!r) return n; if (!r.length) return n._root = eF(r), n; for (e = [{ source: r, target: n._root = new Array(4) }]; r = e.pop();)for (var i = 0; i < 4; ++i)(t = r.source[i]) && (t.length ? e.push({ source: t, target: r.target[i] = new Array(4) }) : r.target[i] = eF(t)); return n }, tF.add = function (e) { const t = +this._x.call(null, e), n = +this._y.call(null, e); return YM(this.cover(t, n), t, n, e) }, tF.addAll = function (e) { var t, n, r, i, a = e.length, o = new Array(a), s = new Array(a), u = 1 / 0, l = 1 / 0, c = -1 / 0, h = -1 / 0; for (n = 0; n < a; ++n)isNaN(r = +this._x.call(null, t = e[n])) || isNaN(i = +this._y.call(null, t)) || (o[n] = r, s[n] = i, r < u && (u = r), r > c && (c = r), i < l && (l = i), i > h && (h = i)); if (u > c || l > h) return this; for (this.cover(u, l).cover(c, h), n = 0; n < a; ++n)YM(this, o[n], s[n], e[n]); return this }, tF.cover = function (e, t) { if (isNaN(e = +e) || isNaN(t = +t)) return this; var n = this._x0, r = this._y0, i = this._x1, a = this._y1; if (isNaN(n)) i = (n = Math.floor(e)) + 1, a = (r = Math.floor(t)) + 1; else { for (var o, s, u = i - n || 1, l = this._root; n > e || e >= i || r > t || t >= a;)switch (s = (t < r) << 1 | e < n, (o = new Array(4))[s] = l, l = o, u *= 2, s) { case 0: i = n + u, a = r + u; break; case 1: n = i - u, a = r + u; break; case 2: i = n + u, r = a - u; break; case 3: n = i - u, r = a - u }this._root && this._root.length && (this._root = l) } return this._x0 = n, this._y0 = r, this._x1 = i, this._y1 = a, this }, tF.data = function () { var e = []; return this.visit((function (t) { if (!t.length) do { e.push(t.data) } while (t = t.next) })), e }, tF.extent = function (e) { return arguments.length ? this.cover(+e[0][0], +e[0][1]).cover(+e[1][0], +e[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]] }, tF.find = function (e, t, n) { var r, i, a, o, s, u, l, c = this._x0, h = this._y0, d = this._x1, f = this._y1, p = [], m = this._root; for (m && p.push(new XM(m, c, h, d, f)), null == n ? n = 1 / 0 : (c = e - n, h = t - n, d = e + n, f = t + n, n *= n); u = p.pop();)if (!(!(m = u.node) || (i = u.x0) > d || (a = u.y0) > f || (o = u.x1) < c || (s = u.y1) < h)) if (m.length) { var g = (i + o) / 2, y = (a + s) / 2; p.push(new XM(m[3], g, y, o, s), new XM(m[2], i, y, g, s), new XM(m[1], g, a, o, y), new XM(m[0], i, a, g, y)), (l = (t >= y) << 1 | e >= g) && (u = p[p.length - 1], p[p.length - 1] = p[p.length - 1 - l], p[p.length - 1 - l] = u) } else { var b = e - +this._x.call(null, m.data), v = t - +this._y.call(null, m.data), x = b * b + v * v; if (x < n) { var w = Math.sqrt(n = x); c = e - w, h = t - w, d = e + w, f = t + w, r = m.data } } return r }, tF.remove = function (e) { if (isNaN(a = +this._x.call(null, e)) || isNaN(o = +this._y.call(null, e))) return this; var t, n, r, i, a, o, s, u, l, c, h, d, f = this._root, p = this._x0, m = this._y0, g = this._x1, y = this._y1; if (!f) return this; if (f.length) for (; ;) { if ((l = a >= (s = (p + g) / 2)) ? p = s : g = s, (c = o >= (u = (m + y) / 2)) ? m = u : y = u, t = f, !(f = f[h = c << 1 | l])) return this; if (!f.length) break; (t[h + 1 & 3] || t[h + 2 & 3] || t[h + 3 & 3]) && (n = t, d = h) } for (; f.data !== e;)if (r = f, !(f = f.next)) return this; return (i = f.next) && delete f.next, r ? (i ? r.next = i : delete r.next, this) : t ? (i ? t[h] = i : delete t[h], (f = t[0] || t[1] || t[2] || t[3]) && f === (t[3] || t[2] || t[1] || t[0]) && !f.length && (n ? n[d] = f : this._root = f), this) : (this._root = i, this) }, tF.removeAll = function (e) { for (var t = 0, n = e.length; t < n; ++t)this.remove(e[t]); return this }, tF.root = function () { return this._root }, tF.size = function () { var e = 0; return this.visit((function (t) { if (!t.length) do { ++e } while (t = t.next) })), e }, tF.visit = function (e) { var t, n, r, i, a, o, s = [], u = this._root; for (u && s.push(new XM(u, this._x0, this._y0, this._x1, this._y1)); t = s.pop();)if (!e(u = t.node, r = t.x0, i = t.y0, a = t.x1, o = t.y1) && u.length) { var l = (r + a) / 2, c = (i + o) / 2; (n = u[3]) && s.push(new XM(n, l, c, a, o)), (n = u[2]) && s.push(new XM(n, r, c, l, o)), (n = u[1]) && s.push(new XM(n, l, i, a, c)), (n = u[0]) && s.push(new XM(n, r, i, l, c)) } return this }, tF.visitAfter = function (e) { var t, n = [], r = []; for (this._root && n.push(new XM(this._root, this._x0, this._y0, this._x1, this._y1)); t = n.pop();) { var i = t.node; if (i.length) { var a, o = t.x0, s = t.y0, u = t.x1, l = t.y1, c = (o + u) / 2, h = (s + l) / 2; (a = i[0]) && n.push(new XM(a, o, s, c, h)), (a = i[1]) && n.push(new XM(a, c, s, u, h)), (a = i[2]) && n.push(new XM(a, o, h, c, l)), (a = i[3]) && n.push(new XM(a, c, h, u, l)) } r.push(t) } for (; t = r.pop();)e(t.node, t.x0, t.y0, t.x1, t.y1); return this }, tF.x = function (e) { return arguments.length ? (this._x = e, this) : this._x }, tF.y = function (e) { return arguments.length ? (this._y = e, this) : this._y }; var oF = { value: () => { } }; function sF() { for (var e, t = 0, n = arguments.length, r = {}; t < n; ++t) { if (!(e = arguments[t] + "") || e in r || /[\s.]/.test(e)) throw new Error("illegal type: " + e); r[e] = [] } return new uF(r) } function uF(e) { this._ = e } function lF(e, t) { for (var n, r = 0, i = e.length; r < i; ++r)if ((n = e[r]).name === t) return n.value } function cF(e, t, n) { for (var r = 0, i = e.length; r < i; ++r)if (e[r].name === t) { e[r] = oF, e = e.slice(0, r).concat(e.slice(r + 1)); break } return null != n && e.push({ name: t, value: n }), e } uF.prototype = sF.prototype = { constructor: uF, on: function (e, t) { var n, r = this._, i = function (e, t) { return e.trim().split(/^|\s+/).map((function (e) { var n = "", r = e.indexOf("."); if (r >= 0 && (n = e.slice(r + 1), e = e.slice(0, r)), e && !t.hasOwnProperty(e)) throw new Error("unknown type: " + e); return { type: e, name: n } })) }(e + "", r), a = -1, o = i.length; if (!(arguments.length < 2)) { if (null != t && "function" != typeof t) throw new Error("invalid callback: " + t); for (; ++a < o;)if (n = (e = i[a]).type) r[n] = cF(r[n], e.name, t); else if (null == t) for (n in r) r[n] = cF(r[n], e.name, null); return this } for (; ++a < o;)if ((n = (e = i[a]).type) && (n = lF(r[n], e.name))) return n }, copy: function () { var e = {}, t = this._; for (var n in t) e[n] = t[n].slice(); return new uF(e) }, call: function (e, t) { if ((n = arguments.length - 2) > 0) for (var n, r, i = new Array(n), a = 0; a < n; ++a)i[a] = arguments[a + 2]; if (!this._.hasOwnProperty(e)) throw new Error("unknown type: " + e); for (a = 0, n = (r = this._[e]).length; a < n; ++a)r[a].value.apply(t, i) }, apply: function (e, t, n) { if (!this._.hasOwnProperty(e)) throw new Error("unknown type: " + e); for (var r = this._[e], i = 0, a = r.length; i < a; ++i)r[i].value.apply(t, n) } }; const hF = sF; var dF, fF, pF = 0, mF = 0, gF = 0, yF = 0, bF = 0, vF = 0, xF = "object" == typeof performance && performance.now ? performance : Date, wF = "object" == typeof window && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function (e) { setTimeout(e, 17) }; function kF() { return bF || (wF(SF), bF = xF.now() + vF) } function SF() { bF = 0 } function _F() { this._call = this._time = this._next = null } function CF(e, t, n) { var r = new _F; return r.restart(e, t, n), r } function AF() { bF = (yF = xF.now()) + vF, pF = mF = 0; try { !function () { kF(), ++pF; for (var e, t = dF; t;)(e = bF - t._time) >= 0 && t._call.call(null, e), t = t._next; --pF }() } finally { pF = 0, function () { var e, t, n = dF, r = 1 / 0; for (; n;)n._call ? (r > n._time && (r = n._time), e = n, n = n._next) : (t = n._next, n._next = null, n = e ? e._next = t : dF = t); fF = e, EF(r) }(), bF = 0 } } function TF() { var e = xF.now(), t = e - yF; t > 1e3 && (vF -= t, yF = e) } function EF(e) { pF || (mF && (mF = clearTimeout(mF)), e - bF > 24 ? (e < 1 / 0 && (mF = setTimeout(AF, e - xF.now() - vF)), gF && (gF = clearInterval(gF))) : (gF || (yF = xF.now(), gF = setInterval(TF, 1e3)), pF = 1, wF(AF))) } _F.prototype = CF.prototype = { constructor: _F, restart: function (e, t, n) { if ("function" != typeof e) throw new TypeError("callback is not a function"); n = (null == n ? kF() : +n) + (null == t ? 0 : +t), this._next || fF === this || (fF ? fF._next = this : dF = this, fF = this), this._call = e, this._time = n, EF() }, stop: function () { this._call && (this._call = null, this._time = 1 / 0, EF()) } }; const NF = 4294967296; function IF(e) { return e.x } function MF(e) { return e.y } var FF = Math.PI * (3 - Math.sqrt(5)); function DF(e) { var t, n = 1, r = .001, i = 1 - Math.pow(r, 1 / 300), a = 0, o = .6, s = new Map, u = CF(h), l = hF("tick", "end"), c = function () { let e = 1; return () => (e = (1664525 * e + 1013904223) % NF) / NF }(); function h() { d(), l.call("tick", t), n < r && (u.stop(), l.call("end", t)) } function d(r) { var u, l, c = e.length; void 0 === r && (r = 1); for (var h = 0; h < r; ++h)for (n += (a - n) * i, s.forEach((function (e) { e(n) })), u = 0; u < c; ++u)null == (l = e[u]).fx ? l.x += l.vx *= o : (l.x = l.fx, l.vx = 0), null == l.fy ? l.y += l.vy *= o : (l.y = l.fy, l.vy = 0); return t } function f() { for (var t, n = 0, r = e.length; n < r; ++n) { if ((t = e[n]).index = n, null != t.fx && (t.x = t.fx), null != t.fy && (t.y = t.fy), isNaN(t.x) || isNaN(t.y)) { var i = 10 * Math.sqrt(.5 + n), a = n * FF; t.x = i * Math.cos(a), t.y = i * Math.sin(a) } (isNaN(t.vx) || isNaN(t.vy)) && (t.vx = t.vy = 0) } } function p(t) { return t.initialize && t.initialize(e, c), t } return null == e && (e = []), f(), t = { tick: d, restart: function () { return u.restart(h), t }, stop: function () { return u.stop(), t }, nodes: function (n) { return arguments.length ? (e = n, f(), s.forEach(p), t) : e }, alpha: function (e) { return arguments.length ? (n = +e, t) : n }, alphaMin: function (e) { return arguments.length ? (r = +e, t) : r }, alphaDecay: function (e) { return arguments.length ? (i = +e, t) : +i }, alphaTarget: function (e) { return arguments.length ? (a = +e, t) : a }, velocityDecay: function (e) { return arguments.length ? (o = 1 - e, t) : 1 - o }, randomSource: function (e) { return arguments.length ? (c = e, s.forEach(p), t) : c }, force: function (e, n) { return arguments.length > 1 ? (null == n ? s.delete(e) : s.set(e, p(n)), t) : s.get(e) }, find: function (t, n, r) { var i, a, o, s, u, l = 0, c = e.length; for (null == r ? r = 1 / 0 : r *= r, l = 0; l < c; ++l)(o = (i = t - (s = e[l]).x) * i + (a = n - s.y) * a) < r && (u = s, r = o); return u }, on: function (e, n) { return arguments.length > 1 ? (l.on(e, n), t) : l.on(e) } } } function $F(e) { return e.index } function RF(e, t) { var n = e.get(t); if (!n) throw new Error("node not found: " + t); return n } const OF = { center: function (e, t) { var n, r = 1; function i() { var i, a, o = n.length, s = 0, u = 0; for (i = 0; i < o; ++i)s += (a = n[i]).x, u += a.y; for (s = (s / o - e) * r, u = (u / o - t) * r, i = 0; i < o; ++i)(a = n[i]).x -= s, a.y -= u } return null == e && (e = 0), null == t && (t = 0), i.initialize = function (e) { n = e }, i.x = function (t) { return arguments.length ? (e = +t, i) : e }, i.y = function (e) { return arguments.length ? (t = +e, i) : t }, i.strength = function (e) { return arguments.length ? (r = +e, i) : r }, i }, collide: function (e) { var t, n, r, i = 1, a = 1; function o() { for (var e, o, u, l, c, h, d, f = t.length, p = 0; p < a; ++p)for (o = JM(t, iF, aF).visitAfter(s), e = 0; e < f; ++e)u = t[e], h = n[u.index], d = h * h, l = u.x + u.vx, c = u.y + u.vy, o.visit(m); function m(e, t, n, a, o) { var s = e.data, f = e.r, p = h + f; if (!s) return t > l + p || a < l - p || n > c + p || o < c - p; if (s.index > u.index) { var m = l - s.x - s.vx, g = c - s.y - s.vy, y = m * m + g * g; y < p * p && (0 === m && (y += (m = rF(r)) * m), 0 === g && (y += (g = rF(r)) * g), y = (p - (y = Math.sqrt(y))) / y * i, u.vx += (m *= y) * (p = (f *= f) / (d + f)), u.vy += (g *= y) * p, s.vx -= m * (p = 1 - p), s.vy -= g * p) } } } function s(e) { if (e.data) return e.r = n[e.data.index]; for (var t = e.r = 0; t < 4; ++t)e[t] && e[t].r > e.r && (e.r = e[t].r) } function u() { if (t) { var r, i, a = t.length; for (n = new Array(a), r = 0; r < a; ++r)i = t[r], n[i.index] = +e(i, r, t) } } return "function" != typeof e && (e = nF(null == e ? 1 : +e)), o.initialize = function (e, n) { t = e, r = n, u() }, o.iterations = function (e) { return arguments.length ? (a = +e, o) : a }, o.strength = function (e) { return arguments.length ? (i = +e, o) : i }, o.radius = function (t) { return arguments.length ? (e = "function" == typeof t ? t : nF(+t), u(), o) : e }, o }, nbody: function () { var e, t, n, r, i, a = nF(-30), o = 1, s = 1 / 0, u = .81; function l(n) { var i, a = e.length, o = JM(e, IF, MF).visitAfter(h); for (r = n, i = 0; i < a; ++i)t = e[i], o.visit(d) } function c() { if (e) { var t, n, r = e.length; for (i = new Array(r), t = 0; t < r; ++t)n = e[t], i[n.index] = +a(n, t, e) } } function h(e) { var t, n, r, a, o, s = 0, u = 0; if (e.length) { for (r = a = o = 0; o < 4; ++o)(t = e[o]) && (n = Math.abs(t.value)) && (s += t.value, u += n, r += n * t.x, a += n * t.y); e.x = r / u, e.y = a / u } else { (t = e).x = t.data.x, t.y = t.data.y; do { s += i[t.data.index] } while (t = t.next) } e.value = s } function d(e, a, l, c) { if (!e.value) return !0; var h = e.x - t.x, d = e.y - t.y, f = c - a, p = h * h + d * d; if (f * f / u < p) return p < s && (0 === h && (p += (h = rF(n)) * h), 0 === d && (p += (d = rF(n)) * d), p < o && (p = Math.sqrt(o * p)), t.vx += h * e.value * r / p, t.vy += d * e.value * r / p), !0; if (!(e.length || p >= s)) { (e.data !== t || e.next) && (0 === h && (p += (h = rF(n)) * h), 0 === d && (p += (d = rF(n)) * d), p < o && (p = Math.sqrt(o * p))); do { e.data !== t && (f = i[e.data.index] * r / p, t.vx += h * f, t.vy += d * f) } while (e = e.next) } } return l.initialize = function (t, r) { e = t, n = r, c() }, l.strength = function (e) { return arguments.length ? (a = "function" == typeof e ? e : nF(+e), c(), l) : a }, l.distanceMin = function (e) { return arguments.length ? (o = e * e, l) : Math.sqrt(o) }, l.distanceMax = function (e) { return arguments.length ? (s = e * e, l) : Math.sqrt(s) }, l.theta = function (e) { return arguments.length ? (u = e * e, l) : Math.sqrt(u) }, l }, link: function (e) { var t, n, r, i, a, o, s = $F, u = function (e) { return 1 / Math.min(i[e.source.index], i[e.target.index]) }, l = nF(30), c = 1; function h(r) { for (var i = 0, s = e.length; i < c; ++i)for (var u, l, h, d, f, p, m, g = 0; g < s; ++g)l = (u = e[g]).source, d = (h = u.target).x + h.vx - l.x - l.vx || rF(o), f = h.y + h.vy - l.y - l.vy || rF(o), d *= p = ((p = Math.sqrt(d * d + f * f)) - n[g]) / p * r * t[g], f *= p, h.vx -= d * (m = a[g]), h.vy -= f * m, l.vx += d * (m = 1 - m), l.vy += f * m } function d() { if (r) { var o, u, l = r.length, c = e.length, h = new Map(r.map(((e, t) => [s(e, t, r), e]))); for (o = 0, i = new Array(l); o < c; ++o)(u = e[o]).index = o, "object" != typeof u.source && (u.source = RF(h, u.source)), "object" != typeof u.target && (u.target = RF(h, u.target)), i[u.source.index] = (i[u.source.index] || 0) + 1, i[u.target.index] = (i[u.target.index] || 0) + 1; for (o = 0, a = new Array(c); o < c; ++o)u = e[o], a[o] = i[u.source.index] / (i[u.source.index] + i[u.target.index]); t = new Array(c), f(), n = new Array(c), p() } } function f() { if (r) for (var n = 0, i = e.length; n < i; ++n)t[n] = +u(e[n], n, e) } function p() { if (r) for (var t = 0, i = e.length; t < i; ++t)n[t] = +l(e[t], t, e) } return null == e && (e = []), h.initialize = function (e, t) { r = e, o = t, d() }, h.links = function (t) { return arguments.length ? (e = t, d(), h) : e }, h.id = function (e) { return arguments.length ? (s = e, h) : s }, h.iterations = function (e) { return arguments.length ? (c = +e, h) : c }, h.strength = function (e) { return arguments.length ? (u = "function" == typeof e ? e : nF(+e), f(), h) : u }, h.distance = function (e) { return arguments.length ? (l = "function" == typeof e ? e : nF(+e), p(), h) : l }, h }, x: function (e) { var t, n, r, i = nF(.1); function a(e) { for (var i, a = 0, o = t.length; a < o; ++a)(i = t[a]).vx += (r[a] - i.x) * n[a] * e } function o() { if (t) { var a, o = t.length; for (n = new Array(o), r = new Array(o), a = 0; a < o; ++a)n[a] = isNaN(r[a] = +e(t[a], a, t)) ? 0 : +i(t[a], a, t) } } return "function" != typeof e && (e = nF(null == e ? 0 : +e)), a.initialize = function (e) { t = e, o() }, a.strength = function (e) { return arguments.length ? (i = "function" == typeof e ? e : nF(+e), o(), a) : i }, a.x = function (t) { return arguments.length ? (e = "function" == typeof t ? t : nF(+t), o(), a) : e }, a }, y: function (e) { var t, n, r, i = nF(.1); function a(e) { for (var i, a = 0, o = t.length; a < o; ++a)(i = t[a]).vy += (r[a] - i.y) * n[a] * e } function o() { if (t) { var a, o = t.length; for (n = new Array(o), r = new Array(o), a = 0; a < o; ++a)n[a] = isNaN(r[a] = +e(t[a], a, t)) ? 0 : +i(t[a], a, t) } } return "function" != typeof e && (e = nF(null == e ? 0 : +e)), a.initialize = function (e) { t = e, o() }, a.strength = function (e) { return arguments.length ? (i = "function" == typeof e ? e : nF(+e), o(), a) : i }, a.y = function (t) { return arguments.length ? (e = "function" == typeof t ? t : nF(+t), o(), a) : e }, a } }, zF = "forces", PF = ["alpha", "alphaMin", "alphaTarget", "velocityDecay", "forces"], BF = ["static", "iterations"], LF = ["x", "y", "vx", "vy"]; function jF(e) { Eu.call(this, null, e) } function UF(e, t, n, r) { var i, a, o, s, u = _n(t.forces); for (i = 0, a = PF.length; i < a; ++i)(o = PF[i]) !== zF && t.modified(o) && e[o](t[o]); for (i = 0, a = u.length; i < a; ++i)s = zF + i, (o = n || t.modified(zF, i) ? VF(u[i]) : r && WF(u[i], r) ? e.force(s) : null) && e.force(s, o); for (a = e.numForces || 0; i < a; ++i)e.force(zF + i, null); return e.numForces = u.length, e } function WF(e, t) { var n, r; for (n in e) if (Cn(r = e[n]) && t.modified(Lt(r))) return 1; return 0 } function VF(e) { var t, n; for (n in zn(OF, e.force) || Vt("Unrecognized force: " + e.force), t = OF[e.force](), e) Cn(t[n]) && GF(t[n], e[n], e); return t } function GF(e, t, n) { e(Cn(t) ? e => t(e, n) : t) } function HF(e) { var t = 0, n = e.children, r = n && n.length; if (r) for (; --r >= 0;)t += n[r].value; else t = 1; e.value = t } function qF(e, t) { e instanceof Map ? (e = [void 0, e], void 0 === t && (t = XF)) : void 0 === t && (t = YF); for (var n, r, i, a, o, s = new JF(e), u = [s]; n = u.pop();)if ((i = t(n.data)) && (o = (i = Array.from(i)).length)) for (n.children = i, a = o - 1; a >= 0; --a)u.push(r = i[a] = new JF(i[a])), r.parent = n, r.depth = n.depth + 1; return s.eachBefore(ZF) } function YF(e) { return e.children } function XF(e) { return Array.isArray(e) ? e[1] : null } function KF(e) { void 0 !== e.data.value && (e.value = e.data.value), e.data = e.data.data } function ZF(e) { var t = 0; do { e.height = t } while ((e = e.parent) && e.height < ++t) } function JF(e) { this.data = e, this.depth = this.height = 0, this.parent = null } function QF(e) { for (var t, n, r = 0, i = (e = function (e) { for (var t, n, r = e.length; r;)n = Math.random() * r-- | 0, t = e[r], e[r] = e[n], e[n] = t; return e }(Array.from(e))).length, a = []; r < i;)t = e[r], n && nD(n, t) ? ++r : (n = iD(a = eD(a, t)), r = 0); return n } function eD(e, t) { var n, r; if (rD(t, e)) return [t]; for (n = 0; n < e.length; ++n)if (tD(t, e[n]) && rD(aD(e[n], t), e)) return [e[n], t]; for (n = 0; n < e.length - 1; ++n)for (r = n + 1; r < e.length; ++r)if (tD(aD(e[n], e[r]), t) && tD(aD(e[n], t), e[r]) && tD(aD(e[r], t), e[n]) && rD(oD(e[n], e[r], t), e)) return [e[n], e[r], t]; throw new Error } function tD(e, t) { var n = e.r - t.r, r = t.x - e.x, i = t.y - e.y; return n < 0 || n * n < r * r + i * i } function nD(e, t) { var n = e.r - t.r + 1e-9 * Math.max(e.r, t.r, 1), r = t.x - e.x, i = t.y - e.y; return n > 0 && n * n > r * r + i * i } function rD(e, t) { for (var n = 0; n < t.length; ++n)if (!nD(e, t[n])) return !1; return !0 } function iD(e) { switch (e.length) { case 1: return function (e) { return { x: e.x, y: e.y, r: e.r } }(e[0]); case 2: return aD(e[0], e[1]); case 3: return oD(e[0], e[1], e[2]) } } function aD(e, t) { var n = e.x, r = e.y, i = e.r, a = t.x, o = t.y, s = t.r, u = a - n, l = o - r, c = s - i, h = Math.sqrt(u * u + l * l); return { x: (n + a + u / h * c) / 2, y: (r + o + l / h * c) / 2, r: (h + i + s) / 2 } } function oD(e, t, n) { var r = e.x, i = e.y, a = e.r, o = t.x, s = t.y, u = t.r, l = n.x, c = n.y, h = n.r, d = r - o, f = r - l, p = i - s, m = i - c, g = u - a, y = h - a, b = r * r + i * i - a * a, v = b - o * o - s * s + u * u, x = b - l * l - c * c + h * h, w = f * p - d * m, k = (p * x - m * v) / (2 * w) - r, S = (m * g - p * y) / w, _ = (f * v - d * x) / (2 * w) - i, C = (d * y - f * g) / w, A = S * S + C * C - 1, T = 2 * (a + k * S + _ * C), E = k * k + _ * _ - a * a, N = -(A ? (T + Math.sqrt(T * T - 4 * A * E)) / (2 * A) : E / T); return { x: r + k + S * N, y: i + _ + C * N, r: N } } function sD(e, t, n) { var r, i, a, o, s = e.x - t.x, u = e.y - t.y, l = s * s + u * u; l ? (i = t.r + n.r, i *= i, o = e.r + n.r, i > (o *= o) ? (r = (l + o - i) / (2 * l), a = Math.sqrt(Math.max(0, o / l - r * r)), n.x = e.x - r * s - a * u, n.y = e.y - r * u + a * s) : (r = (l + i - o) / (2 * l), a = Math.sqrt(Math.max(0, i / l - r * r)), n.x = t.x + r * s - a * u, n.y = t.y + r * u + a * s)) : (n.x = t.x + n.r, n.y = t.y) } function uD(e, t) { var n = e.r + t.r - 1e-6, r = t.x - e.x, i = t.y - e.y; return n > 0 && n * n > r * r + i * i } function lD(e) { var t = e._, n = e.next._, r = t.r + n.r, i = (t.x * n.r + n.x * t.r) / r, a = (t.y * n.r + n.y * t.r) / r; return i * i + a * a } function cD(e) { this._ = e, this.next = null, this.previous = null } function hD(e) { if (!(i = (e = function (e) { return "object" == typeof e && "length" in e ? e : Array.from(e) }(e)).length)) return 0; var t, n, r, i, a, o, s, u, l, c, h; if ((t = e[0]).x = 0, t.y = 0, !(i > 1)) return t.r; if (n = e[1], t.x = -n.r, n.x = t.r, n.y = 0, !(i > 2)) return t.r + n.r; sD(n, t, r = e[2]), t = new cD(t), n = new cD(n), r = new cD(r), t.next = r.previous = n, n.next = t.previous = r, r.next = n.previous = t; e: for (s = 3; s < i; ++s) { sD(t._, n._, r = e[s]), r = new cD(r), u = n.next, l = t.previous, c = n._.r, h = t._.r; do { if (c <= h) { if (uD(u._, r._)) { n = u, t.next = n, n.previous = t, --s; continue e } c += u._.r, u = u.next } else { if (uD(l._, r._)) { (t = l).next = n, n.previous = t, --s; continue e } h += l._.r, l = l.previous } } while (u !== l.next); for (r.previous = t, r.next = n, t.next = n.previous = n = r, a = lD(t); (r = r.next) !== n;)(o = lD(r)) < a && (t = r, a = o); n = t.next } for (t = [n._], r = n; (r = r.next) !== n;)t.push(r._); for (r = QF(t), s = 0; s < i; ++s)(t = e[s]).x -= r.x, t.y -= r.y; return r.r } function dD(e) { if ("function" != typeof e) throw new Error; return e } function fD() { return 0 } function pD(e) { return function () { return e } } function mD(e) { return Math.sqrt(e.value) } function gD(e) { return function (t) { t.children || (t.r = Math.max(0, +e(t) || 0)) } } function yD(e, t) { return function (n) { if (r = n.children) { var r, i, a, o = r.length, s = e(n) * t || 0; if (s) for (i = 0; i < o; ++i)r[i].r += s; if (a = hD(r), s) for (i = 0; i < o; ++i)r[i].r -= s; n.r = a + s } } } function bD(e) { return function (t) { var n = t.parent; t.r *= e, n && (t.x = n.x + e * t.x, t.y = n.y + e * t.y) } } function vD(e) { e.x0 = Math.round(e.x0), e.y0 = Math.round(e.y0), e.x1 = Math.round(e.x1), e.y1 = Math.round(e.y1) } function xD(e, t, n, r, i) { for (var a, o = e.children, s = -1, u = o.length, l = e.value && (r - t) / e.value; ++s < u;)(a = o[s]).y0 = n, a.y1 = i, a.x0 = t, a.x1 = t += a.value * l } jF.Definition = { type: "Force", metadata: { modifies: !0 }, params: [{ name: "static", type: "boolean", default: !1 }, { name: "restart", type: "boolean", default: !1 }, { name: "iterations", type: "number", default: 300 }, { name: "alpha", type: "number", default: 1 }, { name: "alphaMin", type: "number", default: .001 }, { name: "alphaTarget", type: "number", default: 0 }, { name: "velocityDecay", type: "number", default: .4 }, { name: "forces", type: "param", array: !0, params: [{ key: { force: "center" }, params: [{ name: "x", type: "number", default: 0 }, { name: "y", type: "number", default: 0 }] }, { key: { force: "collide" }, params: [{ name: "radius", type: "number", expr: !0 }, { name: "strength", type: "number", default: .7 }, { name: "iterations", type: "number", default: 1 }] }, { key: { force: "nbody" }, params: [{ name: "strength", type: "number", default: -30 }, { name: "theta", type: "number", default: .9 }, { name: "distanceMin", type: "number", default: 1 }, { name: "distanceMax", type: "number" }] }, { key: { force: "link" }, params: [{ name: "links", type: "data" }, { name: "id", type: "field" }, { name: "distance", type: "number", default: 30, expr: !0 }, { name: "strength", type: "number", expr: !0 }, { name: "iterations", type: "number", default: 1 }] }, { key: { force: "x" }, params: [{ name: "strength", type: "number", default: .1 }, { name: "x", type: "field" }] }, { key: { force: "y" }, params: [{ name: "strength", type: "number", default: .1 }, { name: "y", type: "field" }] }] }, { name: "as", type: "string", array: !0, modify: !1, default: LF }] }, Ln(jF, Eu, { transform(e, t) { var n, r, i = this.value, a = t.changed(t.ADD_REM), o = e.modified(PF), s = e.iterations || 300; if (i ? (a && (t.modifies("index"), i.nodes(t.source)), (o || t.changed(t.MOD)) && UF(i, e, 0, t)) : (this.value = i = function (e, t) { const n = DF(e), r = n.stop, i = n.restart; let a = !1; return n.stopped = () => a, n.restart = () => (a = !1, i()), n.stop = () => (a = !0, r()), UF(n, t, !0).on("end", (() => a = !0)) }(t.source, e), i.on("tick", (n = t.dataflow, r = this, () => n.touch(r).run())), e.static || (a = !0, i.tick()), t.modifies("index")), o || a || e.modified(BF) || t.changed() && e.restart) if (i.alpha(Math.max(i.alpha(), e.alpha || 1)).alphaDecay(1 - Math.pow(i.alphaMin(), 1 / s)), e.static) for (i.stop(); --s >= 0;)i.tick(); else if (i.stopped() && i.restart(), !a) return t.StopPropagation; return this.finish(e, t) }, finish(e, t) { const n = t.dataflow; for (let e, t = this._argops, s = 0, u = t.length; s < u; ++s)if (e = t[s], e.name === zF && "link" === e.op._argval.force) for (var r, i = e.op._argops, a = 0, o = i.length; a < o; ++a)if ("links" === i[a].name && (r = i[a].op.source)) { n.pulse(r, n.changeset().reflow()); break } return t.reflow(e.modified()).modifies(LF) } }), JF.prototype = qF.prototype = { constructor: JF, count: function () { return this.eachAfter(HF) }, each: function (e, t) { let n = -1; for (const r of this) e.call(t, r, ++n, this); return this }, eachAfter: function (e, t) { for (var n, r, i, a = this, o = [a], s = [], u = -1; a = o.pop();)if (s.push(a), n = a.children) for (r = 0, i = n.length; r < i; ++r)o.push(n[r]); for (; a = s.pop();)e.call(t, a, ++u, this); return this }, eachBefore: function (e, t) { for (var n, r, i = this, a = [i], o = -1; i = a.pop();)if (e.call(t, i, ++o, this), n = i.children) for (r = n.length - 1; r >= 0; --r)a.push(n[r]); return this }, find: function (e, t) { let n = -1; for (const r of this) if (e.call(t, r, ++n, this)) return r }, sum: function (e) { return this.eachAfter((function (t) { for (var n = +e(t.data) || 0, r = t.children, i = r && r.length; --i >= 0;)n += r[i].value; t.value = n })) }, sort: function (e) { return this.eachBefore((function (t) { t.children && t.children.sort(e) })) }, path: function (e) { for (var t = this, n = function (e, t) { if (e === t) return e; var n = e.ancestors(), r = t.ancestors(), i = null; e = n.pop(), t = r.pop(); for (; e === t;)i = e, e = n.pop(), t = r.pop(); return i }(t, e), r = [t]; t !== n;)t = t.parent, r.push(t); for (var i = r.length; e !== n;)r.splice(i, 0, e), e = e.parent; return r }, ancestors: function () { for (var e = this, t = [e]; e = e.parent;)t.push(e); return t }, descendants: function () { return Array.from(this) }, leaves: function () { var e = []; return this.eachBefore((function (t) { t.children || e.push(t) })), e }, links: function () { var e = this, t = []; return e.each((function (n) { n !== e && t.push({ source: n.parent, target: n }) })), t }, copy: function () { return qF(this).eachBefore(KF) }, [Symbol.iterator]: function* () { var e, t, n, r, i = this, a = [i]; do { for (e = a.reverse(), a = []; i = e.pop();)if (yield i, t = i.children) for (n = 0, r = t.length; n < r; ++n)a.push(t[n]) } while (a.length) } }; var wD = { depth: -1 }, kD = {}; function SD(e) { return e.id } function _D(e) { return e.parentId } function CD() { var e = SD, t = _D; function n(n) { var r, i, a, o, s, u, l, c = Array.from(n), h = c.length, d = new Map; for (i = 0; i < h; ++i)r = c[i], s = c[i] = new JF(r), null != (u = e(r, i, n)) && (u += "") && (l = s.id = u, d.set(l, d.has(l) ? kD : s)), null != (u = t(r, i, n)) && (u += "") && (s.parent = u); for (i = 0; i < h; ++i)if (u = (s = c[i]).parent) { if (!(o = d.get(u))) throw new Error("missing: " + u); if (o === kD) throw new Error("ambiguous: " + u); o.children ? o.children.push(s) : o.children = [s], s.parent = o } else { if (a) throw new Error("multiple roots"); a = s } if (!a) throw new Error("no root"); if (a.parent = wD, a.eachBefore((function (e) { e.depth = e.parent.depth + 1, --h })).eachBefore(ZF), a.parent = null, h > 0) throw new Error("cycle"); return a } return n.id = function (t) { return arguments.length ? (e = dD(t), n) : e }, n.parentId = function (e) { return arguments.length ? (t = dD(e), n) : t }, n } function AD(e, t) { return e.parent === t.parent ? 1 : 2 } function TD(e) { var t = e.children; return t ? t[0] : e.t } function ED(e) { var t = e.children; return t ? t[t.length - 1] : e.t } function ND(e, t, n) { var r = n / (t.i - e.i); t.c -= r, t.s += n, e.c += r, t.z += n, t.m += n } function ID(e, t, n) { return e.a.parent === t.parent ? e.a : n } function MD(e, t) { this._ = e, this.parent = null, this.children = null, this.A = null, this.a = this, this.z = 0, this.m = 0, this.c = 0, this.s = 0, this.t = null, this.i = t } function FD(e, t) { return e.parent === t.parent ? 1 : 2 } function DD(e, t) { return e + t.x } function $D(e, t) { return Math.max(e, t.y) } function RD(e, t, n, r, i) { for (var a, o = e.children, s = -1, u = o.length, l = e.value && (i - n) / e.value; ++s < u;)(a = o[s]).x0 = t, a.x1 = r, a.y0 = n, a.y1 = n += a.value * l } MD.prototype = Object.create(JF.prototype); var OD = (1 + Math.sqrt(5)) / 2; function zD(e, t, n, r, i, a) { for (var o, s, u, l, c, h, d, f, p, m, g, y = [], b = t.children, v = 0, x = 0, w = b.length, k = t.value; v < w;) { u = i - n, l = a - r; do { c = b[x++].value } while (!c && x < w); for (h = d = c, g = c * c * (m = Math.max(l / u, u / l) / (k * e)), p = Math.max(d / g, g / h); x < w; ++x) { if (c += s = b[x].value, s < h && (h = s), s > d && (d = s), g = c * c * m, (f = Math.max(d / g, g / h)) > p) { c -= s; break } p = f } y.push(o = { value: c, dice: u < l, children: b.slice(v, x) }), o.dice ? xD(o, n, r, i, k ? r += l * c / k : a) : RD(o, n, r, k ? n += u * c / k : i, a), k -= c, v = x } return y } const PD = function e(t) { function n(e, n, r, i, a) { zD(t, e, n, r, i, a) } return n.ratio = function (t) { return e((t = +t) > 1 ? t : 1) }, n }(OD), BD = function e(t) { function n(e, n, r, i, a) { if ((o = e._squarify) && o.ratio === t) for (var o, s, u, l, c, h = -1, d = o.length, f = e.value; ++h < d;) { for (u = (s = o[h]).children, l = s.value = 0, c = u.length; l < c; ++l)s.value += u[l].value; s.dice ? xD(s, n, r, i, f ? r += (a - r) * s.value / f : a) : RD(s, n, r, f ? n += (i - n) * s.value / f : i, a), f -= s.value } else e._squarify = o = zD(t, e, n, r, i, a), o.ratio = t } return n.ratio = function (t) { return e((t = +t) > 1 ? t : 1) }, n }(OD); function LD(e, t, n) { const r = {}; return e.each((e => { const i = e.data; n(i) && (r[t(i)] = e) })), e.lookup = r, e } function jD(e) { Eu.call(this, null, e) } jD.Definition = { type: "Nest", metadata: { treesource: !0, changes: !0 }, params: [{ name: "keys", type: "field", array: !0 }, { name: "generate", type: "boolean" }] }; const UD = e => e.values; function WD() { const e = [], t = { entries: e => r(n(e, 0), 0), key: n => (e.push(n), t) }; function n(t, r) { if (r >= e.length) return t; const i = t.length, a = e[r++], o = {}, s = {}; let u, l, c, h = -1; for (; ++h < i;)u = a(l = t[h]) + "", (c = o[u]) ? c.push(l) : o[u] = [l]; for (u in o) s[u] = n(o[u], r); return s } function r(t, n) { if (++n > e.length) return t; const i = []; for (const e in t) i.push({ key: e, values: r(t[e], n) }); return i } return t } function VD(e) { Eu.call(this, null, e) } Ln(jD, Eu, { transform(e, t) { t.source || Vt("Nest transform requires an upstream data source."); var n = e.generate, r = e.modified(), i = t.clone(), a = this.value; return (!a || r || t.changed()) && (a && a.each((e => { e.children && Ys(e.data) && i.rem.push(e.data) })), this.value = a = qF({ values: _n(e.keys).reduce(((e, t) => (e.key(t), e)), WD()).entries(i.source) }, UD), n && a.each((e => { e.children && (e = Zs(e.data), i.add.push(e), i.source.push(e)) })), LD(a, Xs, Xs)), i.source.root = a, i } }); const GD = (e, t) => e.parent === t.parent ? 1 : 2; Ln(VD, Eu, { transform(e, t) { t.source && t.source.root || Vt(this.constructor.name + " transform requires a backing tree data source."); const n = this.layout(e.method), r = this.fields, i = t.source.root, a = e.as || r; e.field ? i.sum(e.field) : i.count(), e.sort && i.sort(tu(e.sort, (e => e.data))), function (e, t, n) { for (let r, i = 0, a = t.length; i < a; ++i)r = t[i], r in n && e[r](n[r]) }(n, this.params, e), n.separation && n.separation(!1 !== e.separation ? GD : Kt); try { this.value = n(i) } catch (e) { Vt(e) } return i.each((e => function (e, t, n) { const r = e.data, i = t.length - 1; for (let a = 0; a < i; ++a)r[n[a]] = e[t[a]]; r[n[i]] = e.children ? e.children.length : 0 }(e, r, a))), t.reflow(e.modified()).modifies(a).modifies("leaf") } }); const HD = ["x", "y", "r", "depth", "children"]; function qD(e) { VD.call(this, e) } qD.Definition = { type: "Pack", metadata: { tree: !0, modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "sort", type: "compare" }, { name: "padding", type: "number", default: 0 }, { name: "radius", type: "field", default: null }, { name: "size", type: "number", array: !0, length: 2 }, { name: "as", type: "string", array: !0, length: HD.length, default: HD }] }, Ln(qD, VD, { layout: function () { var e = null, t = 1, n = 1, r = fD; function i(i) { return i.x = t / 2, i.y = n / 2, e ? i.eachBefore(gD(e)).eachAfter(yD(r, .5)).eachBefore(bD(1)) : i.eachBefore(gD(mD)).eachAfter(yD(fD, 1)).eachAfter(yD(r, i.r / Math.min(t, n))).eachBefore(bD(Math.min(t, n) / (2 * i.r))), i } return i.radius = function (t) { return arguments.length ? (e = null == (n = t) ? null : dD(n), i) : e; var n }, i.size = function (e) { return arguments.length ? (t = +e[0], n = +e[1], i) : [t, n] }, i.padding = function (e) { return arguments.length ? (r = "function" == typeof e ? e : pD(+e), i) : r }, i }, params: ["radius", "size", "padding"], fields: HD }); const YD = ["x0", "y0", "x1", "y1", "depth", "children"]; function XD(e) { VD.call(this, e) } function KD(e) { Eu.call(this, null, e) } XD.Definition = { type: "Partition", metadata: { tree: !0, modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "sort", type: "compare" }, { name: "padding", type: "number", default: 0 }, { name: "round", type: "boolean", default: !1 }, { name: "size", type: "number", array: !0, length: 2 }, { name: "as", type: "string", array: !0, length: YD.length, default: YD }] }, Ln(XD, VD, { layout: function () { var e = 1, t = 1, n = 0, r = !1; function i(i) { var a = i.height + 1; return i.x0 = i.y0 = n, i.x1 = e, i.y1 = t / a, i.eachBefore(function (e, t) { return function (r) { r.children && xD(r, r.x0, e * (r.depth + 1) / t, r.x1, e * (r.depth + 2) / t); var i = r.x0, a = r.y0, o = r.x1 - n, s = r.y1 - n; o < i && (i = o = (i + o) / 2), s < a && (a = s = (a + s) / 2), r.x0 = i, r.y0 = a, r.x1 = o, r.y1 = s } }(t, a)), r && i.eachBefore(vD), i } return i.round = function (e) { return arguments.length ? (r = !!e, i) : r }, i.size = function (n) { return arguments.length ? (e = +n[0], t = +n[1], i) : [e, t] }, i.padding = function (e) { return arguments.length ? (n = +e, i) : n }, i }, params: ["size", "round", "padding"], fields: YD }), KD.Definition = { type: "Stratify", metadata: { treesource: !0 }, params: [{ name: "key", type: "field", required: !0 }, { name: "parentKey", type: "field", required: !0 }] }, Ln(KD, Eu, { transform(e, t) { t.source || Vt("Stratify transform requires an upstream data source."); let n = this.value; const r = e.modified(), i = t.fork(t.ALL).materialize(t.SOURCE), a = !n || r || t.changed(t.ADD_REM) || t.modified(e.key.fields) || t.modified(e.parentKey.fields); return i.source = i.source.slice(), a && (n = i.source.length ? LD(CD().id(e.key).parentId(e.parentKey)(i.source), e.key, Zt) : LD(CD()([{}]), e.key, e.key)), i.source.root = this.value = n, i } }); const ZD = { tidy: function () { var e = AD, t = 1, n = 1, r = null; function i(i) { var u = function (e) { for (var t, n, r, i, a, o = new MD(e, 0), s = [o]; t = s.pop();)if (r = t._.children) for (t.children = new Array(a = r.length), i = a - 1; i >= 0; --i)s.push(n = t.children[i] = new MD(r[i], i)), n.parent = t; return (o.parent = new MD(null, 0)).children = [o], o }(i); if (u.eachAfter(a), u.parent.m = -u.z, u.eachBefore(o), r) i.eachBefore(s); else { var l = i, c = i, h = i; i.eachBefore((function (e) { e.x < l.x && (l = e), e.x > c.x && (c = e), e.depth > h.depth && (h = e) })); var d = l === c ? 1 : e(l, c) / 2, f = d - l.x, p = t / (c.x + d + f), m = n / (h.depth || 1); i.eachBefore((function (e) { e.x = (e.x + f) * p, e.y = e.depth * m })) } return i } function a(t) { var n = t.children, r = t.parent.children, i = t.i ? r[t.i - 1] : null; if (n) { !function (e) { for (var t, n = 0, r = 0, i = e.children, a = i.length; --a >= 0;)(t = i[a]).z += n, t.m += n, n += t.s + (r += t.c) }(t); var a = (n[0].z + n[n.length - 1].z) / 2; i ? (t.z = i.z + e(t._, i._), t.m = t.z - a) : t.z = a } else i && (t.z = i.z + e(t._, i._)); t.parent.A = function (t, n, r) { if (n) { for (var i, a = t, o = t, s = n, u = a.parent.children[0], l = a.m, c = o.m, h = s.m, d = u.m; s = ED(s), a = TD(a), s && a;)u = TD(u), (o = ED(o)).a = t, (i = s.z + h - a.z - l + e(s._, a._)) > 0 && (ND(ID(s, t, r), t, i), l += i, c += i), h += s.m, l += a.m, d += u.m, c += o.m; s && !ED(o) && (o.t = s, o.m += h - c), a && !TD(u) && (u.t = a, u.m += l - d, r = t) } return r }(t, i, t.parent.A || r[0]) } function o(e) { e._.x = e.z + e.parent.m, e.m += e.parent.m } function s(e) { e.x *= t, e.y = e.depth * n } return i.separation = function (t) { return arguments.length ? (e = t, i) : e }, i.size = function (e) { return arguments.length ? (r = !1, t = +e[0], n = +e[1], i) : r ? null : [t, n] }, i.nodeSize = function (e) { return arguments.length ? (r = !0, t = +e[0], n = +e[1], i) : r ? [t, n] : null }, i }, cluster: function () { var e = FD, t = 1, n = 1, r = !1; function i(i) { var a, o = 0; i.eachAfter((function (t) { var n = t.children; n ? (t.x = function (e) { return e.reduce(DD, 0) / e.length }(n), t.y = function (e) { return 1 + e.reduce($D, 0) }(n)) : (t.x = a ? o += e(t, a) : 0, t.y = 0, a = t) })); var s = function (e) { for (var t; t = e.children;)e = t[0]; return e }(i), u = function (e) { for (var t; t = e.children;)e = t[t.length - 1]; return e }(i), l = s.x - e(s, u) / 2, c = u.x + e(u, s) / 2; return i.eachAfter(r ? function (e) { e.x = (e.x - i.x) * t, e.y = (i.y - e.y) * n } : function (e) { e.x = (e.x - l) / (c - l) * t, e.y = (1 - (i.y ? e.y / i.y : 1)) * n }) } return i.separation = function (t) { return arguments.length ? (e = t, i) : e }, i.size = function (e) { return arguments.length ? (r = !1, t = +e[0], n = +e[1], i) : r ? null : [t, n] }, i.nodeSize = function (e) { return arguments.length ? (r = !0, t = +e[0], n = +e[1], i) : r ? [t, n] : null }, i } }, JD = ["x", "y", "depth", "children"]; function QD(e) { VD.call(this, e) } function e$(e) { Eu.call(this, [], e) } QD.Definition = { type: "Tree", metadata: { tree: !0, modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "sort", type: "compare" }, { name: "method", type: "enum", default: "tidy", values: ["tidy", "cluster"] }, { name: "size", type: "number", array: !0, length: 2 }, { name: "nodeSize", type: "number", array: !0, length: 2 }, { name: "separation", type: "boolean", default: !0 }, { name: "as", type: "string", array: !0, length: JD.length, default: JD }] }, Ln(QD, VD, { layout(e) { const t = e || "tidy"; if (zn(ZD, t)) return ZD[t](); Vt("Unrecognized Tree layout method: " + t) }, params: ["size", "nodeSize"], fields: JD }), e$.Definition = { type: "TreeLinks", metadata: { tree: !0, generates: !0, changes: !0 }, params: [] }, Ln(e$, Eu, { transform(e, t) { const n = this.value, r = t.source && t.source.root, i = t.fork(t.NO_SOURCE), a = {}; return r || Vt("TreeLinks transform requires a tree data source."), t.changed(t.ADD_REM) ? (i.rem = n, t.visit(t.SOURCE, (e => a[Xs(e)] = 1)), r.each((e => { const t = e.data, n = e.parent && e.parent.data; n && a[Xs(t)] && a[Xs(n)] && i.add.push(Zs({ source: n, target: t })) })), this.value = i.add) : t.changed(t.MOD) && (t.visit(t.MOD, (e => a[Xs(e)] = 1)), n.forEach((e => { (a[Xs(e.source)] || a[Xs(e.target)]) && i.mod.push(e) }))), i } }); const t$ = { binary: function (e, t, n, r, i) { var a, o, s = e.children, u = s.length, l = new Array(u + 1); for (l[0] = o = a = 0; a < u; ++a)l[a + 1] = o += s[a].value; !function e(t, n, r, i, a, o, u) { if (t >= n - 1) { var c = s[t]; return c.x0 = i, c.y0 = a, c.x1 = o, void (c.y1 = u) } var h = l[t], d = r / 2 + h, f = t + 1, p = n - 1; for (; f < p;) { var m = f + p >>> 1; l[m] < d ? f = m + 1 : p = m } d - l[f - 1] < l[f] - d && t + 1 < f && --f; var g = l[f] - h, y = r - g; if (o - i > u - a) { var b = r ? (i * y + o * g) / r : o; e(t, f, g, i, a, b, u), e(f, n, y, b, a, o, u) } else { var v = r ? (a * y + u * g) / r : u; e(t, f, g, i, a, o, v), e(f, n, y, i, v, o, u) } }(0, u, e.value, t, n, r, i) }, dice: xD, slice: RD, slicedice: function (e, t, n, r, i) { (1 & e.depth ? RD : xD)(e, t, n, r, i) }, squarify: PD, resquarify: BD }, n$ = ["x0", "y0", "x1", "y1", "depth", "children"]; function r$(e) { VD.call(this, e) } r$.Definition = { type: "Treemap", metadata: { tree: !0, modifies: !0 }, params: [{ name: "field", type: "field" }, { name: "sort", type: "compare" }, { name: "method", type: "enum", default: "squarify", values: ["squarify", "resquarify", "binary", "dice", "slice", "slicedice"] }, { name: "padding", type: "number", default: 0 }, { name: "paddingInner", type: "number", default: 0 }, { name: "paddingOuter", type: "number", default: 0 }, { name: "paddingTop", type: "number", default: 0 }, { name: "paddingRight", type: "number", default: 0 }, { name: "paddingBottom", type: "number", default: 0 }, { name: "paddingLeft", type: "number", default: 0 }, { name: "ratio", type: "number", default: 1.618033988749895 }, { name: "round", type: "boolean", default: !1 }, { name: "size", type: "number", array: !0, length: 2 }, { name: "as", type: "string", array: !0, length: n$.length, default: n$ }] }, Ln(r$, VD, { layout() { const e = function () { var e = PD, t = !1, n = 1, r = 1, i = [0], a = fD, o = fD, s = fD, u = fD, l = fD; function c(e) { return e.x0 = e.y0 = 0, e.x1 = n, e.y1 = r, e.eachBefore(h), i = [0], t && e.eachBefore(vD), e } function h(t) { var n = i[t.depth], r = t.x0 + n, c = t.y0 + n, h = t.x1 - n, d = t.y1 - n; h < r && (r = h = (r + h) / 2), d < c && (c = d = (c + d) / 2), t.x0 = r, t.y0 = c, t.x1 = h, t.y1 = d, t.children && (n = i[t.depth + 1] = a(t) / 2, r += l(t) - n, c += o(t) - n, (h -= s(t) - n) < r && (r = h = (r + h) / 2), (d -= u(t) - n) < c && (c = d = (c + d) / 2), e(t, r, c, h, d)) } return c.round = function (e) { return arguments.length ? (t = !!e, c) : t }, c.size = function (e) { return arguments.length ? (n = +e[0], r = +e[1], c) : [n, r] }, c.tile = function (t) { return arguments.length ? (e = dD(t), c) : e }, c.padding = function (e) { return arguments.length ? c.paddingInner(e).paddingOuter(e) : c.paddingInner() }, c.paddingInner = function (e) { return arguments.length ? (a = "function" == typeof e ? e : pD(+e), c) : a }, c.paddingOuter = function (e) { return arguments.length ? c.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e) : c.paddingTop() }, c.paddingTop = function (e) { return arguments.length ? (o = "function" == typeof e ? e : pD(+e), c) : o }, c.paddingRight = function (e) { return arguments.length ? (s = "function" == typeof e ? e : pD(+e), c) : s }, c.paddingBottom = function (e) { return arguments.length ? (u = "function" == typeof e ? e : pD(+e), c) : u }, c.paddingLeft = function (e) { return arguments.length ? (l = "function" == typeof e ? e : pD(+e), c) : l }, c }(); return e.ratio = t => { const n = e.tile(); n.ratio && e.tile(n.ratio(t)) }, e.method = t => { zn(t$, t) ? e.tile(t$[t]) : Vt("Unrecognized Treemap layout method: " + t) }, e }, params: ["method", "ratio", "size", "round", "padding", "paddingInner", "paddingOuter", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft"], fields: n$ }); function i$(e, t, n, r) { const i = e.width, a = e.height, o = n || r, s = Fd(i, a).getContext("2d"); t.forEach((e => a$(s, e, o))); const u = new Uint32Array(s.getImageData(0, 0, i, a).data.buffer), l = e.bitmap(), c = o && e.bitmap(); let h, d, f, p, m; for (d = 0; d < a; ++d)for (h = 0; h < i; ++h)m = 4278190080 & u[d * i + h], m && (f = e(h), p = e(d), r || l.set(f, p), o && 268435456 ^ m && c.set(f, p)); return [l, c] } function a$(e, t, n) { if (!t.length) return; const r = t[0].mark.marktype; "group" === r ? t.forEach((t => { t.items.forEach((t => a$(e, t.items, n))) })) : Ww[r].draw(e, { items: n ? t.map(o$) : t }) } function o$(e) { const t = Qs(e, {}); return t.stroke && (t.strokeOpacity = 1), t.fill && (t.fillOpacity = .0625, t.stroke = "#000", t.strokeOpacity = 1, t.strokeWidth = 2), t } const s$ = 31, u$ = new Uint32Array(33), l$ = new Uint32Array(33); l$[0] = 0, u$[0] = ~l$[0]; for (let e = 1; e <= 32; ++e)l$[e] = l$[e - 1] << 1 | 1, u$[e] = ~l$[e]; function c$(e, t, n) { const r = Math.max(1, Math.sqrt(e * t / 1e6)), i = ~~((e + 2 * n + r) / r), a = ~~((t + 2 * n + r) / r), o = e => ~~((e + n) / r); return o.invert = e => e * r - n, o.bitmap = () => function (e, t) { const n = new Uint32Array(~~((e * t + 32) / 32)); function r(e, t) { n[e] |= t } function i(e, t) { n[e] &= t } return { array: n, get: (t, r) => { const i = r * e + t; return n[i >>> 5] & 1 << (i & s$) }, set: (t, n) => { const i = n * e + t; r(i >>> 5, 1 << (i & s$)) }, clear: (t, n) => { const r = n * e + t; i(r >>> 5, ~(1 << (r & s$))) }, getRange: (t, r, i, a) => { let o, s, u, l, c = a; for (; c >= r; --c)if (o = c * e + t, s = c * e + i, u = o >>> 5, l = s >>> 5, u === l) { if (n[u] & u$[o & s$] & l$[1 + (s & s$)]) return !0 } else { if (n[u] & u$[o & s$]) return !0; if (n[l] & l$[1 + (s & s$)]) return !0; for (let e = u + 1; e < l; ++e)if (n[e]) return !0 } return !1 }, setRange: (t, n, i, a) => { let o, s, u, l, c; for (; n <= a; ++n)if (o = n * e + t, s = n * e + i, u = o >>> 5, l = s >>> 5, u === l) r(u, u$[o & s$] & l$[1 + (s & s$)]); else for (r(u, u$[o & s$]), r(l, l$[1 + (s & s$)]), c = u + 1; c < l; ++c)r(c, 4294967295) }, clearRange: (t, n, r, a) => { let o, s, u, l, c; for (; n <= a; ++n)if (o = n * e + t, s = n * e + r, u = o >>> 5, l = s >>> 5, u === l) i(u, l$[o & s$] | u$[1 + (s & s$)]); else for (i(u, l$[o & s$]), i(l, u$[1 + (s & s$)]), c = u + 1; c < l; ++c)i(c, 0) }, outOfBounds: (n, r, i, a) => n < 0 || r < 0 || a >= t || i >= e } }(i, a), o.ratio = r, o.padding = n, o.width = e, o.height = t, o } function h$(e, t, n, r, i, a) { let o = n / 2; return e - o < 0 || e + o > i || t - (o = r / 2) < 0 || t + o > a } function d$(e, t, n, r, i, a, o, s) { const u = i * a / (2 * r), l = e(t - u), c = e(t + u), h = e(n - (a /= 2)), d = e(n + a); return o.outOfBounds(l, h, c, d) || o.getRange(l, h, c, d) || s && s.getRange(l, h, c, d) } const f$ = [-1, -1, 1, 1], p$ = [-1, 1, -1, 1]; const m$ = ["right", "center", "left"], g$ = ["bottom", "middle", "top"]; function y$(e, t, n, r, i, a, o, s, u, l, c, h) { return !(i.outOfBounds(e, n, t, r) || (h && a ? a.getRange(e, n, t, r) || !function (e, t, n, r, i) { return i[0] <= e && n <= i[2] && i[3] <= t && r <= i[5] }(o, u, s, l, c) : i.getRange(e, n, t, r))) } const b$ = { "top-left": 0, top: 1, "top-right": 2, left: 4, middle: 5, right: 6, "bottom-left": 8, bottom: 9, "bottom-right": 10 }, v$ = { naive: function (e, t, n, r) { const i = e.width, a = e.height; return function (e) { const t = e.datum.datum.items[r].items, n = t.length, o = e.datum.fontSize, s = Sw.width(e.datum, e.datum.text); let u, l, c, h, d, f, p, m = 0; for (let r = 0; r < n; ++r)u = t[r].x, c = t[r].y, l = void 0 === t[r].x2 ? u : t[r].x2, h = void 0 === t[r].y2 ? c : t[r].y2, d = (u + l) / 2, f = (c + h) / 2, p = Math.abs(l - u + h - c), p >= m && (m = p, e.x = d, e.y = f); return d = s / 2, f = o / 2, u = e.x - d, l = e.x + d, c = e.y - f, h = e.y + f, e.align = "center", u < 0 && l <= i ? e.align = "left" : 0 <= u && i < l && (e.align = "right"), e.baseline = "middle", c < 0 && h <= a ? e.baseline = "top" : 0 <= c && a < h && (e.baseline = "bottom"), !0 } }, "reduced-search": function (e, t, n, r) { const i = e.width, a = e.height, o = t[0], s = t[1]; function u(t, n, r, u, l) { const c = e.invert(t), h = e.invert(n); let d, f = r, p = a; if (!h$(c, h, u, l, i, a) && !d$(e, c, h, l, u, f, o, s) && !d$(e, c, h, l, u, l, o, null)) { for (; p - f >= 1;)d = (f + p) / 2, d$(e, c, h, l, u, d, o, s) ? p = d : f = d; if (f > r) return [c, h, f, !0] } } return function (t) { const s = t.datum.datum.items[r].items, l = s.length, c = t.datum.fontSize, h = Sw.width(t.datum, t.datum.text); let d, f, p, m, g, y, b, v, x, w, k, S, _, C, A, T, E, N = n ? c : 0, I = !1, M = !1, F = 0; for (let r = 0; r < l; ++r) { for (d = s[r].x, p = s[r].y, f = void 0 === s[r].x2 ? d : s[r].x2, m = void 0 === s[r].y2 ? p : s[r].y2, d > f && (E = d, d = f, f = E), p > m && (E = p, p = m, m = E), x = e(d), k = e(f), w = ~~((x + k) / 2), S = e(p), C = e(m), _ = ~~((S + C) / 2), b = w; b >= x; --b)for (v = _; v >= S; --v)T = u(b, v, N, h, c), T && ([t.x, t.y, N, I] = T); for (b = w; b <= k; ++b)for (v = _; v <= C; ++v)T = u(b, v, N, h, c), T && ([t.x, t.y, N, I] = T); I || n || (A = Math.abs(f - d + m - p), g = (d + f) / 2, y = (p + m) / 2, A >= F && !h$(g, y, h, c, i, a) && !d$(e, g, y, c, h, c, o, null) && (F = A, t.x = g, t.y = y, M = !0)) } return !(!I && !M) && (g = h / 2, y = c / 2, o.setRange(e(t.x - g), e(t.y - y), e(t.x + g), e(t.y + y)), t.align = "center", t.baseline = "middle", !0) } }, floodfill: function (e, t, n, r) { const i = e.width, a = e.height, o = t[0], s = t[1], u = e.bitmap(); return function (t) { const l = t.datum.datum.items[r].items, c = l.length, h = t.datum.fontSize, d = Sw.width(t.datum, t.datum.text), f = []; let p, m, g, y, b, v, x, w, k, S, _, C, A = n ? h : 0, T = !1, E = !1, N = 0; for (let r = 0; r < c; ++r) { for (p = l[r].x, g = l[r].y, m = void 0 === l[r].x2 ? p : l[r].x2, y = void 0 === l[r].y2 ? g : l[r].y2, f.push([e((p + m) / 2), e((g + y) / 2)]); f.length;)if ([x, w] = f.pop(), !(o.get(x, w) || s.get(x, w) || u.get(x, w))) { u.set(x, w); for (let e = 0; e < 4; ++e)b = x + f$[e], v = w + p$[e], u.outOfBounds(b, v, b, v) || f.push([b, v]); if (b = e.invert(x), v = e.invert(w), k = A, S = a, !h$(b, v, d, h, i, a) && !d$(e, b, v, h, d, k, o, s) && !d$(e, b, v, h, d, h, o, null)) { for (; S - k >= 1;)_ = (k + S) / 2, d$(e, b, v, h, d, _, o, s) ? S = _ : k = _; k > A && (t.x = b, t.y = v, A = k, T = !0) } } T || n || (C = Math.abs(m - p + y - g), b = (p + m) / 2, v = (g + y) / 2, C >= N && !h$(b, v, d, h, i, a) && !d$(e, b, v, h, d, h, o, null) && (N = C, t.x = b, t.y = v, E = !0)) } return !(!T && !E) && (b = d / 2, v = h / 2, o.setRange(e(t.x - b), e(t.y - v), e(t.x + b), e(t.y + v)), t.align = "center", t.baseline = "middle", !0) } } }; function x$(e, t, n, r, i, a, o, s, u, l, c) { if (!e.length) return e; const h = Math.max(r.length, i.length), d = function (e, t) { const n = new Float64Array(t), r = e.length; for (let t = 0; t < r; ++t)n[t] = e[t] || 0; for (let e = r; e < t; ++e)n[e] = n[r - 1]; return n }(r, h), f = function (e, t) { const n = new Int8Array(t), r = e.length; for (let t = 0; t < r; ++t)n[t] |= b$[e[t]]; for (let e = r; e < t; ++e)n[e] = n[r - 1]; return n }(i, h), p = (x = e[0].datum) && x.mark && x.mark.marktype, m = "group" === p && e[0].datum.items[u].marktype, g = "area" === m, y = function (e, t, n, r) { const i = e => [e.x, e.x, e.x, e.y, e.y, e.y]; return e ? "line" === e || "area" === e ? e => i(e.datum) : "line" === t ? e => { const t = e.datum.items[r].items; return i(t.length ? t["start" === n ? 0 : t.length - 1] : { x: NaN, y: NaN }) } : e => { const t = e.datum.bounds; return [t.x1, (t.x1 + t.x2) / 2, t.x2, t.y1, (t.y1 + t.y2) / 2, t.y2] } : i }(p, m, s, u), b = c$(t[0], t[1], l), v = g && "naive" === c; var x; const w = e.map((e => ({ datum: e, opacity: 0, x: void 0, y: void 0, align: void 0, baseline: void 0, boundary: y(e) }))); let k; if (!v) { n && w.sort(((e, t) => n(e.datum, t.datum))); let t = !1; for (let e = 0; e < f.length && !t; ++e)t = 5 === f[e] || d[e] < 0; p && (o || g) && (a = [e.map((e => e.datum))].concat(a)), k = a.length ? i$(b, a, t, g) : function (e, t) { const n = e.bitmap(); return (t || []).forEach((t => n.set(e(t.boundary[0]), e(t.boundary[3])))), [n, void 0] }(b, o && w) } const S = g ? v$[c](b, k, o, u) : function (e, t, n, r) { const i = e.width, a = e.height, o = t[0], s = t[1], u = r.length; return function (t) { const l = t.boundary, c = t.datum.fontSize; if (l[2] < 0 || l[5] < 0 || l[0] > i || l[3] > a) return !1; let h, d, f, p, m, g, y, b, v, x, w, k, S, _, C, A = 0; for (let i = 0; i < u; ++i) { if (h = (3 & n[i]) - 1, d = (n[i] >>> 2 & 3) - 1, f = 0 === h && 0 === d || r[i] < 0, p = h && d ? Math.SQRT1_2 : 1, m = r[i] < 0 ? -1 : 1, g = l[1 + h] + r[i] * h * p, w = l[4 + d] + m * c * d / 2 + r[i] * d * p, b = w - c / 2, v = w + c / 2, k = e(g), _ = e(b), C = e(v), !A) { if (!y$(k, k, _, C, o, s, g, g, b, v, l, f)) continue; A = Sw.width(t.datum, t.datum.text) } if (x = g + m * A * h / 2, g = x - A / 2, y = x + A / 2, k = e(g), S = e(y), y$(k, S, _, C, o, s, g, y, b, v, l, f)) return t.x = h ? h * m < 0 ? y : g : x, t.y = d ? d * m < 0 ? v : b : w, t.align = m$[h * m + 1], t.baseline = g$[d * m + 1], o.setRange(k, _, S, C), !0 } return !1 } }(b, k, f, d); return w.forEach((e => e.opacity = +S(e))), w } const w$ = ["x", "y", "opacity", "align", "baseline"], k$ = ["top-left", "left", "bottom-left", "top", "bottom", "top-right", "right", "bottom-right"]; function S$(e) { Eu.call(this, null, e) } function _$(e, t) { var n, r, i, a, o, s, u = [], l = function (e) { return e(a) }; if (null == t) u.push(e); else for (n = {}, r = 0, i = e.length; r < i; ++r)a = e[r], (s = n[o = t.map(l)]) || (n[o] = s = [], s.dims = o, u.push(s)), s.push(a); return u } function C$(e) { Eu.call(this, null, e) } S$.Definition = { type: "Label", metadata: { modifies: !0 }, params: [{ name: "size", type: "number", array: !0, length: 2, required: !0 }, { name: "sort", type: "compare" }, { name: "anchor", type: "string", array: !0, default: k$ }, { name: "offset", type: "number", array: !0, default: [1] }, { name: "padding", type: "number", default: 0 }, { name: "lineAnchor", type: "string", values: ["start", "end"], default: "end" }, { name: "markIndex", type: "number", default: 0 }, { name: "avoidBaseMark", type: "boolean", default: !0 }, { name: "avoidMarks", type: "data", array: !0 }, { name: "method", type: "string", default: "naive" }, { name: "as", type: "string", array: !0, length: w$.length, default: w$ }] }, Ln(S$, Eu, { transform(e, t) { const n = e.modified(); if (!(n || t.changed(t.ADD_REM) || function (n) { const r = e[n]; return Cn(r) && t.modified(r.fields) }("sort"))) return; e.size && 2 === e.size.length || Vt("Size parameter should be specified as a [width, height] array."); const r = e.as || w$; return x$(t.materialize(t.SOURCE).source, e.size, e.sort, _n(e.offset || 1), _n(e.anchor || k$), e.avoidMarks || [], !1 !== e.avoidBaseMark, e.lineAnchor || "end", e.markIndex || 0, e.padding || 0, e.method || "naive").forEach((e => { const t = e.datum; t[r[0]] = e.x, t[r[1]] = e.y, t[r[2]] = e.opacity, t[r[3]] = e.align, t[r[4]] = e.baseline })), t.reflow(n).modifies(r) } }), C$.Definition = { type: "Loess", metadata: { generates: !0 }, params: [{ name: "x", type: "field", required: !0 }, { name: "y", type: "field", required: !0 }, { name: "groupby", type: "field", array: !0 }, { name: "bandwidth", type: "number", default: .3 }, { name: "as", type: "string", array: !0 }] }, Ln(C$, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE | t.NO_FIELDS); if (!this.value || t.changed() || e.modified()) { const r = _$(t.materialize(t.SOURCE).source, e.groupby), i = (e.groupby || []).map(Bt), a = i.length, o = e.as || [Bt(e.x), Bt(e.y)], s = []; r.forEach((t => { (function (e, t, n, r) { const [i, a, o, s] = dl(e, t, n, !0), u = i.length, l = Math.max(2, ~~(r * u)), c = new Float64Array(u), h = new Float64Array(u), d = new Float64Array(u).fill(1); for (let e = -1; ++e <= 2;) { const t = [0, l - 1]; for (let e = 0; e < u; ++e) { const n = i[e], r = t[0], o = t[1], s = n - i[r] > i[o] - n ? r : o; let u = 0, l = 0, f = 0, p = 0, m = 0; const g = 1 / Math.abs(i[s] - n || 1); for (let e = r; e <= o; ++e) { const t = i[e], r = a[e], o = bl(Math.abs(n - t) * g) * d[e], s = t * o; u += o, l += s, f += r * o, p += r * s, m += t * s } const [y, b] = hl(l / u, f / u, p / u, m / u); c[e] = y + b * n, h[e] = Math.abs(a[e] - c[e]), vl(i, e + 1, t) } if (2 === e) break; const n = ju(h); if (Math.abs(n) < 1e-12) break; for (let e, t, r = 0; r < u; ++r)e = h[r] / (6 * n), d[r] = e >= 1 ? 1e-12 : (t = 1 - e * e) * t } return function (e, t, n, r) { const i = e.length, a = []; let o, s = 0, u = 0, l = []; for (; s < i; ++s)o = e[s] + n, l[0] === o ? l[1] += (t[s] - l[1]) / ++u : (u = 0, l[1] += r, l = [o, t[s]], a.push(l)); return l[1] += r, a }(i, c, o, s) })(t, e.x, e.y, e.bandwidth || .3).forEach((e => { const n = {}; for (let e = 0; e < a; ++e)n[i[e]] = t.dims[e]; n[o[0]] = e[0], n[o[1]] = e[1], s.push(Zs(n)) })) })), this.value && (n.rem = this.value), this.value = n.add = n.source = s } return n } }); const A$ = { linear: ml, log: function (e, t, n) { let r = 0, i = 0, a = 0, o = 0, s = 0; fl(e, t, n, ((e, t) => { ++s, e = Math.log(e), r += (e - r) / s, i += (t - i) / s, a += (e * t - a) / s, o += (e * e - o) / s })); const u = hl(r, i, a, o), l = e => u[0] + u[1] * Math.log(e); return { coef: u, predict: l, rSquared: pl(e, t, n, i, l) } }, exp: function (e, t, n) { const [r, i, a, o] = dl(e, t, n); let s, u, l, c = 0, h = 0, d = 0, f = 0, p = 0; fl(e, t, n, ((e, t) => { s = r[p++], u = Math.log(t), l = s * t, c += (t * u - c) / p, h += (l - h) / p, d += (l * u - d) / p, f += (s * l - f) / p })); const [m, g] = hl(h / o, c / o, d / o, f / o), y = e => Math.exp(m + g * (e - a)); return { coef: [Math.exp(m - g * a), g], predict: y, rSquared: pl(e, t, n, o, y) } }, pow: function (e, t, n) { let r = 0, i = 0, a = 0, o = 0, s = 0, u = 0; fl(e, t, n, ((e, t) => { const n = Math.log(e), l = Math.log(t); ++u, r += (n - r) / u, i += (l - i) / u, a += (n * l - a) / u, o += (n * n - o) / u, s += (t - s) / u })); const l = hl(r, i, a, o), c = e => l[0] * Math.pow(e, l[1]); return l[0] = Math.exp(l[0]), { coef: l, predict: c, rSquared: pl(e, t, n, s, c) } }, quad: gl, poly: function (e, t, n, r) { if (0 === r) return function (e, t, n) { let r = 0, i = 0; for (const a of e) { const e = n(a); null == t(a) || null == e || isNaN(e) || (r += (e - r) / ++i) } return { coef: [r], predict: () => r, rSquared: 0 } }(e, t, n); if (1 === r) return ml(e, t, n); if (2 === r) return gl(e, t, n); const [i, a, o, s] = dl(e, t, n), u = i.length, l = [], c = [], h = r + 1; let d, f, p, m, g; for (d = 0; d < h; ++d) { for (p = 0, m = 0; p < u; ++p)m += Math.pow(i[p], d) * a[p]; for (l.push(m), g = new Float64Array(h), f = 0; f < h; ++f) { for (p = 0, m = 0; p < u; ++p)m += Math.pow(i[p], d + f); g[f] = m } c.push(g) } c.push(l); const y = function (e) { const t = e.length - 1, n = []; let r, i, a, o, s; for (r = 0; r < t; ++r) { for (o = r, i = r + 1; i < t; ++i)Math.abs(e[r][i]) > Math.abs(e[r][o]) && (o = i); for (a = r; a < t + 1; ++a)s = e[a][r], e[a][r] = e[a][o], e[a][o] = s; for (i = r + 1; i < t; ++i)for (a = t; a >= r; a--)e[a][i] -= e[a][r] * e[r][i] / e[r][r] } for (i = t - 1; i >= 0; --i) { for (s = 0, a = i + 1; a < t; ++a)s += e[a][i] * n[a]; n[i] = (e[t][i] - s) / e[i][i] } return n }(c), b = e => { e -= o; let t = s + y[0] + y[1] * e + y[2] * e * e; for (d = 3; d < h; ++d)t += y[d] * Math.pow(e, d); return t }; return { coef: yl(h, y, -o, s), predict: b, rSquared: pl(e, t, n, s, b) } } }; function T$(e) { Eu.call(this, null, e) } T$.Definition = { type: "Regression", metadata: { generates: !0 }, params: [{ name: "x", type: "field", required: !0 }, { name: "y", type: "field", required: !0 }, { name: "groupby", type: "field", array: !0 }, { name: "method", type: "string", default: "linear", values: Object.keys(A$) }, { name: "order", type: "number", default: 3 }, { name: "extent", type: "number", array: !0, length: 2 }, { name: "params", type: "boolean", default: !1 }, { name: "as", type: "string", array: !0 }] }, Ln(T$, Eu, { transform(e, t) { const n = t.fork(t.NO_SOURCE | t.NO_FIELDS); if (!this.value || t.changed() || e.modified()) { const r = _$(t.materialize(t.SOURCE).source, e.groupby), i = (e.groupby || []).map(Bt), a = e.method || "linear", o = e.order || 3, s = ((e, t) => "poly" === e ? t : "quad" === e ? 2 : 1)(a, o), u = e.as || [Bt(e.x), Bt(e.y)], l = A$[a], c = []; let h = e.extent; zn(A$, a) || Vt("Invalid regression method: " + a), null != h && "log" === a && h[0] <= 0 && (t.dataflow.warn("Ignoring extent with values <= 0 for log regression."), h = null), r.forEach((n => { if (n.length <= s) return void t.dataflow.warn("Skipping regression with more parameters than data points."); const r = l(n, e.x, e.y, o); if (e.params) return void c.push(Zs({ keys: n.dims, coef: r.coef, rSquared: r.rSquared })); const d = h || Rn(n, e.x), f = e => { const t = {}; for (let e = 0; e < i.length; ++e)t[i[e]] = n.dims[e]; t[u[0]] = e[0], t[u[1]] = e[1], c.push(Zs(t)) }; "linear" === a ? d.forEach((e => f([e, r.predict(e)]))) : wl(r.predict, d, 25, 200).forEach(f) })), this.value && (n.rem = this.value), this.value = n.add = n.source = c } return n } }); const E$ = Math.pow(2, -52), N$ = new Uint32Array(512); class I$ { static from(e, t = P$, n = B$) { const r = e.length, i = new Float64Array(2 * r); for (let a = 0; a < r; a++) { const r = e[a]; i[2 * a] = t(r), i[2 * a + 1] = n(r) } return new I$(i) } constructor(e) { const t = e.length >> 1; if (t > 0 && "number" != typeof e[0]) throw new Error("Expected coords to contain numbers."); this.coords = e; const n = Math.max(2 * t - 5, 0); this._triangles = new Uint32Array(3 * n), this._halfedges = new Int32Array(3 * n), this._hashSize = Math.ceil(Math.sqrt(t)), this._hullPrev = new Uint32Array(t), this._hullNext = new Uint32Array(t), this._hullTri = new Uint32Array(t), this._hullHash = new Int32Array(this._hashSize).fill(-1), this._ids = new Uint32Array(t), this._dists = new Float64Array(t), this.update() } update() { const { coords: e, _hullPrev: t, _hullNext: n, _hullTri: r, _hullHash: i } = this, a = e.length >> 1; let o = 1 / 0, s = 1 / 0, u = -1 / 0, l = -1 / 0; for (let t = 0; t < a; t++) { const n = e[2 * t], r = e[2 * t + 1]; n < o && (o = n), r < s && (s = r), n > u && (u = n), r > l && (l = r), this._ids[t] = t } const c = (o + u) / 2, h = (s + l) / 2; let d, f, p, m = 1 / 0; for (let t = 0; t < a; t++) { const n = M$(c, h, e[2 * t], e[2 * t + 1]); n < m && (d = t, m = n) } const g = e[2 * d], y = e[2 * d + 1]; m = 1 / 0; for (let t = 0; t < a; t++) { if (t === d) continue; const n = M$(g, y, e[2 * t], e[2 * t + 1]); n < m && n > 0 && (f = t, m = n) } let b = e[2 * f], v = e[2 * f + 1], x = 1 / 0; for (let t = 0; t < a; t++) { if (t === d || t === f) continue; const n = R$(g, y, b, v, e[2 * t], e[2 * t + 1]); n < x && (p = t, x = n) } let w = e[2 * p], k = e[2 * p + 1]; if (x === 1 / 0) { for (let t = 0; t < a; t++)this._dists[t] = e[2 * t] - e[0] || e[2 * t + 1] - e[1]; O$(this._ids, this._dists, 0, a - 1); const t = new Uint32Array(a); let n = 0; for (let e = 0, r = -1 / 0; e < a; e++) { const i = this._ids[e]; this._dists[i] > r && (t[n++] = i, r = this._dists[i]) } return this.hull = t.subarray(0, n), this.triangles = new Uint32Array(0), void (this.halfedges = new Uint32Array(0)) } if (D$(g, y, b, v, w, k)) { const e = f, t = b, n = v; f = p, b = w, v = k, p = e, w = t, k = n } const S = function (e, t, n, r, i, a) { const o = n - e, s = r - t, u = i - e, l = a - t, c = o * o + s * s, h = u * u + l * l, d = .5 / (o * l - s * u), f = e + (l * c - s * h) * d, p = t + (o * h - u * c) * d; return { x: f, y: p } }(g, y, b, v, w, k); this._cx = S.x, this._cy = S.y; for (let t = 0; t < a; t++)this._dists[t] = M$(e[2 * t], e[2 * t + 1], S.x, S.y); O$(this._ids, this._dists, 0, a - 1), this._hullStart = d; let _ = 3; n[d] = t[p] = f, n[f] = t[d] = p, n[p] = t[f] = d, r[d] = 0, r[f] = 1, r[p] = 2, i.fill(-1), i[this._hashKey(g, y)] = d, i[this._hashKey(b, v)] = f, i[this._hashKey(w, k)] = p, this.trianglesLen = 0, this._addTriangle(d, f, p, -1, -1, -1); for (let a, o, s = 0; s < this._ids.length; s++) { const u = this._ids[s], l = e[2 * u], c = e[2 * u + 1]; if (s > 0 && Math.abs(l - a) <= E$ && Math.abs(c - o) <= E$) continue; if (a = l, o = c, u === d || u === f || u === p) continue; let h = 0; for (let e = 0, t = this._hashKey(l, c); e < this._hashSize && (h = i[(t + e) % this._hashSize], -1 === h || h === n[h]); e++); h = t[h]; let m, g = h; for (; m = n[g], !D$(l, c, e[2 * g], e[2 * g + 1], e[2 * m], e[2 * m + 1]);)if (g = m, g === h) { g = -1; break } if (-1 === g) continue; let y = this._addTriangle(g, u, n[g], -1, -1, r[g]); r[u] = this._legalize(y + 2), r[g] = y, _++; let b = n[g]; for (; m = n[b], D$(l, c, e[2 * b], e[2 * b + 1], e[2 * m], e[2 * m + 1]);)y = this._addTriangle(b, u, m, r[u], -1, r[b]), r[u] = this._legalize(y + 2), n[b] = b, _--, b = m; if (g === h) for (; m = t[g], D$(l, c, e[2 * m], e[2 * m + 1], e[2 * g], e[2 * g + 1]);)y = this._addTriangle(m, u, g, -1, r[g], r[m]), this._legalize(y + 2), r[m] = y, n[g] = g, _--, g = m; this._hullStart = t[u] = g, n[g] = t[b] = u, n[u] = b, i[this._hashKey(l, c)] = u, i[this._hashKey(e[2 * g], e[2 * g + 1])] = g } this.hull = new Uint32Array(_); for (let e = 0, t = this._hullStart; e < _; e++)this.hull[e] = t, t = n[t]; this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen) } _hashKey(e, t) { return Math.floor(function (e, t) { const n = e / (Math.abs(e) + Math.abs(t)); return (t > 0 ? 3 - n : 1 + n) / 4 }(e - this._cx, t - this._cy) * this._hashSize) % this._hashSize } _legalize(e) { const { _triangles: t, _halfedges: n, coords: r } = this; let i = 0, a = 0; for (; ;) { const o = n[e], s = e - e % 3; if (a = s + (e + 2) % 3, -1 === o) { if (0 === i) break; e = N$[--i]; continue } const u = o - o % 3, l = s + (e + 1) % 3, c = u + (o + 2) % 3, h = t[a], d = t[e], f = t[l], p = t[c]; if ($$(r[2 * h], r[2 * h + 1], r[2 * d], r[2 * d + 1], r[2 * f], r[2 * f + 1], r[2 * p], r[2 * p + 1])) { t[e] = p, t[o] = h; const r = n[c]; if (-1 === r) { let t = this._hullStart; do { if (this._hullTri[t] === c) { this._hullTri[t] = e; break } t = this._hullPrev[t] } while (t !== this._hullStart) } this._link(e, r), this._link(o, n[a]), this._link(a, c); const s = u + (o + 1) % 3; i < N$.length && (N$[i++] = s) } else { if (0 === i) break; e = N$[--i] } } return a } _link(e, t) { this._halfedges[e] = t, -1 !== t && (this._halfedges[t] = e) } _addTriangle(e, t, n, r, i, a) { const o = this.trianglesLen; return this._triangles[o] = e, this._triangles[o + 1] = t, this._triangles[o + 2] = n, this._link(o, r), this._link(o + 1, i), this._link(o + 2, a), this.trianglesLen += 3, o } } function M$(e, t, n, r) { const i = e - n, a = t - r; return i * i + a * a } function F$(e, t, n, r, i, a) { const o = (r - t) * (i - e), s = (n - e) * (a - t); return Math.abs(o - s) >= 33306690738754716e-32 * Math.abs(o + s) ? o - s : 0 } function D$(e, t, n, r, i, a) { return (F$(i, a, e, t, n, r) || F$(e, t, n, r, i, a) || F$(n, r, i, a, e, t)) < 0 } function $$(e, t, n, r, i, a, o, s) { const u = e - o, l = t - s, c = n - o, h = r - s, d = i - o, f = a - s, p = c * c + h * h, m = d * d + f * f; return u * (h * m - p * f) - l * (c * m - p * d) + (u * u + l * l) * (c * f - h * d) < 0 } function R$(e, t, n, r, i, a) { const o = n - e, s = r - t, u = i - e, l = a - t, c = o * o + s * s, h = u * u + l * l, d = .5 / (o * l - s * u), f = (l * c - s * h) * d, p = (o * h - u * c) * d; return f * f + p * p } function O$(e, t, n, r) { if (r - n <= 20) for (let i = n + 1; i <= r; i++) { const r = e[i], a = t[r]; let o = i - 1; for (; o >= n && t[e[o]] > a;)e[o + 1] = e[o--]; e[o + 1] = r } else { let i = n + 1, a = r; z$(e, n + r >> 1, i), t[e[n]] > t[e[r]] && z$(e, n, r), t[e[i]] > t[e[r]] && z$(e, i, r), t[e[n]] > t[e[i]] && z$(e, n, i); const o = e[i], s = t[o]; for (; ;) { do { i++ } while (t[e[i]] < s); do { a-- } while (t[e[a]] > s); if (a < i) break; z$(e, i, a) } e[n + 1] = e[a], e[a] = o, r - i + 1 >= a - n ? (O$(e, t, i, r), O$(e, t, n, a - 1)) : (O$(e, t, n, a - 1), O$(e, t, i, r)) } } function z$(e, t, n) { const r = e[t]; e[t] = e[n], e[n] = r } function P$(e) { return e[0] } function B$(e) { return e[1] } const L$ = 1e-6; class j$ { constructor() { this._x0 = this._y0 = this._x1 = this._y1 = null, this._ = "" } moveTo(e, t) { this._ += `M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +t}` } closePath() { null !== this._x1 && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z") } lineTo(e, t) { this._ += `L${this._x1 = +e},${this._y1 = +t}` } arc(e, t, n) { const r = (e = +e) + (n = +n), i = t = +t; if (n < 0) throw new Error("negative radius"); null === this._x1 ? this._ += `M${r},${i}` : (Math.abs(this._x1 - r) > L$ || Math.abs(this._y1 - i) > L$) && (this._ += "L" + r + "," + i), n && (this._ += `A${n},${n},0,1,1,${e - n},${t}A${n},${n},0,1,1,${this._x1 = r},${this._y1 = i}`) } rect(e, t, n, r) { this._ += `M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +t}h${+n}v${+r}h${-n}Z` } value() { return this._ || null } } class U$ { constructor() { this._ = [] } moveTo(e, t) { this._.push([e, t]) } closePath() { this._.push(this._[0].slice()) } lineTo(e, t) { this._.push([e, t]) } value() { return this._.length ? this._ : null } } class W$ { constructor(e, [t, n, r, i] = [0, 0, 960, 500]) { if (!((r = +r) >= (t = +t) && (i = +i) >= (n = +n))) throw new Error("invalid bounds"); this.delaunay = e, this._circumcenters = new Float64Array(2 * e.points.length), this.vectors = new Float64Array(2 * e.points.length), this.xmax = r, this.xmin = t, this.ymax = i, this.ymin = n, this._init() } update() { return this.delaunay.update(), this._init(), this } _init() { const { delaunay: { points: e, hull: t, triangles: n }, vectors: r } = this, i = this.circumcenters = this._circumcenters.subarray(0, n.length / 3 * 2); for (let t, r, a = 0, o = 0, s = n.length; a < s; a += 3, o += 2) { const s = 2 * n[a], u = 2 * n[a + 1], l = 2 * n[a + 2], c = e[s], h = e[s + 1], d = e[u], f = e[u + 1], p = e[l], m = e[l + 1], g = d - c, y = f - h, b = p - c, v = m - h, x = g * g + y * y, w = b * b + v * v, k = 2 * (g * v - y * b); if (k) if (Math.abs(k) < 1e-8) t = (c + p) / 2, r = (h + m) / 2; else { const e = 1 / k; t = c + (v * x - y * w) * e, r = h + (g * w - b * x) * e } else t = (c + p) / 2 - 1e8 * v, r = (h + m) / 2 + 1e8 * b; i[o] = t, i[o + 1] = r } let a, o, s, u = t[t.length - 1], l = 4 * u, c = e[2 * u], h = e[2 * u + 1]; r.fill(0); for (let n = 0; n < t.length; ++n)u = t[n], a = l, o = c, s = h, l = 4 * u, c = e[2 * u], h = e[2 * u + 1], r[a + 2] = r[l] = s - h, r[a + 3] = r[l + 1] = c - o } render(e) { const t = null == e ? e = new j$ : void 0, { delaunay: { halfedges: n, inedges: r, hull: i }, circumcenters: a, vectors: o } = this; if (i.length <= 1) return null; for (let t = 0, r = n.length; t < r; ++t) { const r = n[t]; if (r < t) continue; const i = 2 * Math.floor(t / 3), o = 2 * Math.floor(r / 3), s = a[i], u = a[i + 1], l = a[o], c = a[o + 1]; this._renderSegment(s, u, l, c, e) } let s, u = i[i.length - 1]; for (let t = 0; t < i.length; ++t) { s = u, u = i[t]; const n = 2 * Math.floor(r[u] / 3), l = a[n], c = a[n + 1], h = 4 * s, d = this._project(l, c, o[h + 2], o[h + 3]); d && this._renderSegment(l, c, d[0], d[1], e) } return t && t.value() } renderBounds(e) { const t = null == e ? e = new j$ : void 0; return e.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), t && t.value() } renderCell(e, t) { const n = null == t ? t = new j$ : void 0, r = this._clip(e); if (null === r || !r.length) return; t.moveTo(r[0], r[1]); let i = r.length; for (; r[0] === r[i - 2] && r[1] === r[i - 1] && i > 1;)i -= 2; for (let e = 2; e < i; e += 2)r[e] === r[e - 2] && r[e + 1] === r[e - 1] || t.lineTo(r[e], r[e + 1]); return t.closePath(), n && n.value() } *cellPolygons() { const { delaunay: { points: e } } = this; for (let t = 0, n = e.length / 2; t < n; ++t) { const e = this.cellPolygon(t); e && (e.index = t, yield e) } } cellPolygon(e) { const t = new U$; return this.renderCell(e, t), t.value() } _renderSegment(e, t, n, r, i) { let a; const o = this._regioncode(e, t), s = this._regioncode(n, r); 0 === o && 0 === s ? (i.moveTo(e, t), i.lineTo(n, r)) : (a = this._clipSegment(e, t, n, r, o, s)) && (i.moveTo(a[0], a[1]), i.lineTo(a[2], a[3])) } contains(e, t, n) { return (t = +t) == t && (n = +n) == n && this.delaunay._step(e, t, n) === e } *neighbors(e) { const t = this._clip(e); if (t) for (const n of this.delaunay.neighbors(e)) { const e = this._clip(n); if (e) e: for (let r = 0, i = t.length; r < i; r += 2)for (let a = 0, o = e.length; a < o; a += 2)if (t[r] == e[a] && t[r + 1] == e[a + 1] && t[(r + 2) % i] == e[(a + o - 2) % o] && t[(r + 3) % i] == e[(a + o - 1) % o]) { yield n; break e } } } _cell(e) { const { circumcenters: t, delaunay: { inedges: n, halfedges: r, triangles: i } } = this, a = n[e]; if (-1 === a) return null; const o = []; let s = a; do { const n = Math.floor(s / 3); if (o.push(t[2 * n], t[2 * n + 1]), s = s % 3 == 2 ? s - 2 : s + 1, i[s] !== e) break; s = r[s] } while (s !== a && -1 !== s); return o } _clip(e) { if (0 === e && 1 === this.delaunay.hull.length) return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin]; const t = this._cell(e); if (null === t) return null; const { vectors: n } = this, r = 4 * e; return n[r] || n[r + 1] ? this._clipInfinite(e, t, n[r], n[r + 1], n[r + 2], n[r + 3]) : this._clipFinite(e, t) } _clipFinite(e, t) { const n = t.length; let r, i, a, o, s, u = null, l = t[n - 2], c = t[n - 1], h = this._regioncode(l, c); for (let d = 0; d < n; d += 2)if (r = l, i = c, l = t[d], c = t[d + 1], a = h, h = this._regioncode(l, c), 0 === a && 0 === h) o = s, s = 0, u ? u.push(l, c) : u = [l, c]; else { let t, n, d, f, p; if (0 === a) { if (null === (t = this._clipSegment(r, i, l, c, a, h))) continue;[n, d, f, p] = t } else { if (null === (t = this._clipSegment(l, c, r, i, h, a))) continue;[f, p, n, d] = t, o = s, s = this._edgecode(n, d), o && s && this._edge(e, o, s, u, u.length), u ? u.push(n, d) : u = [n, d] } o = s, s = this._edgecode(f, p), o && s && this._edge(e, o, s, u, u.length), u ? u.push(f, p) : u = [f, p] } if (u) o = s, s = this._edgecode(u[0], u[1]), o && s && this._edge(e, o, s, u, u.length); else if (this.contains(e, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin]; return u } _clipSegment(e, t, n, r, i, a) { for (; ;) { if (0 === i && 0 === a) return [e, t, n, r]; if (i & a) return null; let o, s, u = i || a; 8 & u ? (o = e + (n - e) * (this.ymax - t) / (r - t), s = this.ymax) : 4 & u ? (o = e + (n - e) * (this.ymin - t) / (r - t), s = this.ymin) : 2 & u ? (s = t + (r - t) * (this.xmax - e) / (n - e), o = this.xmax) : (s = t + (r - t) * (this.xmin - e) / (n - e), o = this.xmin), i ? (e = o, t = s, i = this._regioncode(e, t)) : (n = o, r = s, a = this._regioncode(n, r)) } } _clipInfinite(e, t, n, r, i, a) { let o, s = Array.from(t); if ((o = this._project(s[0], s[1], n, r)) && s.unshift(o[0], o[1]), (o = this._project(s[s.length - 2], s[s.length - 1], i, a)) && s.push(o[0], o[1]), s = this._clipFinite(e, s)) for (let t, n = 0, r = s.length, i = this._edgecode(s[r - 2], s[r - 1]); n < r; n += 2)t = i, i = this._edgecode(s[n], s[n + 1]), t && i && (n = this._edge(e, t, i, s, n), r = s.length); else this.contains(e, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2) && (s = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]); return s } _edge(e, t, n, r, i) { for (; t !== n;) { let n, a; switch (t) { case 5: t = 4; continue; case 4: t = 6, n = this.xmax, a = this.ymin; break; case 6: t = 2; continue; case 2: t = 10, n = this.xmax, a = this.ymax; break; case 10: t = 8; continue; case 8: t = 9, n = this.xmin, a = this.ymax; break; case 9: t = 1; continue; case 1: t = 5, n = this.xmin, a = this.ymin }r[i] === n && r[i + 1] === a || !this.contains(e, n, a) || (r.splice(i, 0, n, a), i += 2) } if (r.length > 4) for (let e = 0; e < r.length; e += 2) { const t = (e + 2) % r.length, n = (e + 4) % r.length; (r[e] === r[t] && r[t] === r[n] || r[e + 1] === r[t + 1] && r[t + 1] === r[n + 1]) && (r.splice(t, 2), e -= 2) } return i } _project(e, t, n, r) { let i, a, o, s = 1 / 0; if (r < 0) { if (t <= this.ymin) return null; (i = (this.ymin - t) / r) < s && (o = this.ymin, a = e + (s = i) * n) } else if (r > 0) { if (t >= this.ymax) return null; (i = (this.ymax - t) / r) < s && (o = this.ymax, a = e + (s = i) * n) } if (n > 0) { if (e >= this.xmax) return null; (i = (this.xmax - e) / n) < s && (a = this.xmax, o = t + (s = i) * r) } else if (n < 0) { if (e <= this.xmin) return null; (i = (this.xmin - e) / n) < s && (a = this.xmin, o = t + (s = i) * r) } return [a, o] } _edgecode(e, t) { return (e === this.xmin ? 1 : e === this.xmax ? 2 : 0) | (t === this.ymin ? 4 : t === this.ymax ? 8 : 0) } _regioncode(e, t) { return (e < this.xmin ? 1 : e > this.xmax ? 2 : 0) | (t < this.ymin ? 4 : t > this.ymax ? 8 : 0) } } const V$ = 2 * Math.PI, G$ = Math.pow; function H$(e) { return e[0] } function q$(e) { return e[1] } function Y$(e, t, n) { return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n] } class X$ { static from(e, t = H$, n = q$, r) { return new X$("length" in e ? function (e, t, n, r) { const i = e.length, a = new Float64Array(2 * i); for (let o = 0; o < i; ++o) { const i = e[o]; a[2 * o] = t.call(r, i, o, e), a[2 * o + 1] = n.call(r, i, o, e) } return a }(e, t, n, r) : Float64Array.from(function* (e, t, n, r) { let i = 0; for (const a of e) yield t.call(r, a, i, e), yield n.call(r, a, i, e), ++i }(e, t, n, r))) } constructor(e) { this._delaunator = new I$(e), this.inedges = new Int32Array(e.length / 2), this._hullIndex = new Int32Array(e.length / 2), this.points = this._delaunator.coords, this._init() } update() { return this._delaunator.update(), this._init(), this } _init() { const e = this._delaunator, t = this.points; if (e.hull && e.hull.length > 2 && function (e) { const { triangles: t, coords: n } = e; for (let e = 0; e < t.length; e += 3) { const r = 2 * t[e], i = 2 * t[e + 1], a = 2 * t[e + 2]; if ((n[a] - n[r]) * (n[i + 1] - n[r + 1]) - (n[i] - n[r]) * (n[a + 1] - n[r + 1]) > 1e-10) return !1 } return !0 }(e)) { this.collinear = Int32Array.from({ length: t.length / 2 }, ((e, t) => t)).sort(((e, n) => t[2 * e] - t[2 * n] || t[2 * e + 1] - t[2 * n + 1])); const e = this.collinear[0], n = this.collinear[this.collinear.length - 1], r = [t[2 * e], t[2 * e + 1], t[2 * n], t[2 * n + 1]], i = 1e-8 * Math.hypot(r[3] - r[1], r[2] - r[0]); for (let e = 0, n = t.length / 2; e < n; ++e) { const n = Y$(t[2 * e], t[2 * e + 1], i); t[2 * e] = n[0], t[2 * e + 1] = n[1] } this._delaunator = new I$(t) } else delete this.collinear; const n = this.halfedges = this._delaunator.halfedges, r = this.hull = this._delaunator.hull, i = this.triangles = this._delaunator.triangles, a = this.inedges.fill(-1), o = this._hullIndex.fill(-1); for (let e = 0, t = n.length; e < t; ++e) { const t = i[e % 3 == 2 ? e - 2 : e + 1]; -1 !== n[e] && -1 !== a[t] || (a[t] = e) } for (let e = 0, t = r.length; e < t; ++e)o[r[e]] = e; r.length <= 2 && r.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = r[0], this.triangles[1] = r[1], this.triangles[2] = r[1], a[r[0]] = 1, 2 === r.length && (a[r[1]] = 0)) } voronoi(e) { return new W$(this, e) } *neighbors(e) { const { inedges: t, hull: n, _hullIndex: r, halfedges: i, triangles: a, collinear: o } = this; if (o) { const t = o.indexOf(e); return t > 0 && (yield o[t - 1]), void (t < o.length - 1 && (yield o[t + 1])) } const s = t[e]; if (-1 === s) return; let u = s, l = -1; do { if (yield l = a[u], u = u % 3 == 2 ? u - 2 : u + 1, a[u] !== e) return; if (u = i[u], -1 === u) { const t = n[(r[e] + 1) % n.length]; return void (t !== l && (yield t)) } } while (u !== s) } find(e, t, n = 0) { if ((e = +e) != e || (t = +t) != t) return -1; const r = n; let i; for (; (i = this._step(n, e, t)) >= 0 && i !== n && i !== r;)n = i; return i } _step(e, t, n) { const { inedges: r, hull: i, _hullIndex: a, halfedges: o, triangles: s, points: u } = this; if (-1 === r[e] || !u.length) return (e + 1) % (u.length >> 1); let l = e, c = G$(t - u[2 * e], 2) + G$(n - u[2 * e + 1], 2); const h = r[e]; let d = h; do { let r = s[d]; const h = G$(t - u[2 * r], 2) + G$(n - u[2 * r + 1], 2); if (h < c && (c = h, l = r), d = d % 3 == 2 ? d - 2 : d + 1, s[d] !== e) break; if (d = o[d], -1 === d) { if (d = i[(a[e] + 1) % i.length], d !== r && G$(t - u[2 * d], 2) + G$(n - u[2 * d + 1], 2) < c) return d; break } } while (d !== h); return l } render(e) { const t = null == e ? e = new j$ : void 0, { points: n, halfedges: r, triangles: i } = this; for (let t = 0, a = r.length; t < a; ++t) { const a = r[t]; if (a < t) continue; const o = 2 * i[t], s = 2 * i[a]; e.moveTo(n[o], n[o + 1]), e.lineTo(n[s], n[s + 1]) } return this.renderHull(e), t && t.value() } renderPoints(e, t = 2) { const n = null == e ? e = new j$ : void 0, { points: r } = this; for (let n = 0, i = r.length; n < i; n += 2) { const i = r[n], a = r[n + 1]; e.moveTo(i + t, a), e.arc(i, a, t, 0, V$) } return n && n.value() } renderHull(e) { const t = null == e ? e = new j$ : void 0, { hull: n, points: r } = this, i = 2 * n[0], a = n.length; e.moveTo(r[i], r[i + 1]); for (let t = 1; t < a; ++t) { const i = 2 * n[t]; e.lineTo(r[i], r[i + 1]) } return e.closePath(), t && t.value() } hullPolygon() { const e = new U$; return this.renderHull(e), e.value() } renderTriangle(e, t) { const n = null == t ? t = new j$ : void 0, { points: r, triangles: i } = this, a = 2 * i[e *= 3], o = 2 * i[e + 1], s = 2 * i[e + 2]; return t.moveTo(r[a], r[a + 1]), t.lineTo(r[o], r[o + 1]), t.lineTo(r[s], r[s + 1]), t.closePath(), n && n.value() } *trianglePolygons() { const { triangles: e } = this; for (let t = 0, n = e.length / 3; t < n; ++t)yield this.trianglePolygon(t) } trianglePolygon(e) { const t = new U$; return this.renderTriangle(e, t), t.value() } } function K$(e) { Eu.call(this, null, e) } K$.Definition = { type: "Voronoi", metadata: { modifies: !0 }, params: [{ name: "x", type: "field", required: !0 }, { name: "y", type: "field", required: !0 }, { name: "size", type: "number", array: !0, length: 2 }, { name: "extent", type: "array", array: !0, length: 2, default: [[-1e5, -1e5], [1e5, 1e5]], content: { type: "number", array: !0, length: 2 } }, { name: "as", type: "string", default: "path" }] }; const Z$ = [-1e5, -1e5, 1e5, 1e5]; function J$(e) { const t = e[0][0], n = e[0][1]; let r = e.length - 1; for (; e[r][0] === t && e[r][1] === n; --r); return "M" + e.slice(0, r + 1).join("L") + "Z" } Ln(K$, Eu, { transform(e, t) { const n = e.as || "path", r = t.source; if (!r || !r.length) return t; let i = e.size; i = i ? [0, 0, i[0], i[1]] : (i = e.extent) ? [i[0][0], i[0][1], i[1][0], i[1][1]] : Z$; const a = this.value = X$.from(r, e.x, e.y).voronoi(i); for (let e = 0, t = r.length; e < t; ++e) { const t = a.cellPolygon(e); r[e][n] = t ? J$(t) : null } return t.reflow(e.modified()).modifies(n) } }); var Q$ = Math.PI / 180, eR = 64, tR = 2048; function nR() { var e, t, n, r, i, a, o, s = [256, 256], u = sR, l = [], c = Math.random, h = {}; function d(e, t, n) { for (var r, i, a, o = t.x, l = t.y, h = Math.hypot(s[0], s[1]), d = u(s), f = c() < .5 ? 1 : -1, p = -f; (r = d(p += f)) && (i = ~~r[0], a = ~~r[1], !(Math.min(Math.abs(i), Math.abs(a)) >= h));)if (t.x = o + i, t.y = l + a, !(t.x + t.x0 < 0 || t.y + t.y0 < 0 || t.x + t.x1 > s[0] || t.y + t.y1 > s[1]) && (!n || !iR(t, e, s[0])) && (!n || oR(t, n))) { for (var m, g = t.sprite, y = t.width >> 5, b = s[0] >> 5, v = t.x - (y << 4), x = 127 & v, w = 32 - x, k = t.y1 - t.y0, S = (t.y + t.y0) * b + (v >> 5), _ = 0; _ < k; _++) { m = 0; for (var C = 0; C <= y; C++)e[S + C] |= m << w | (C < y ? (m = g[_ * y + C]) >>> x : 0); S += b } return t.sprite = null, !0 } return !1 } return h.layout = function () { for (var u = function (e) { e.width = e.height = 1; var t = Math.sqrt(e.getContext("2d").getImageData(0, 0, 1, 1).data.length >> 2); e.width = (eR << 5) / t, e.height = tR / t; var n = e.getContext("2d"); return n.fillStyle = n.strokeStyle = "red", n.textAlign = "center", { context: n, ratio: t } }(Fd()), h = function (e) { var t = [], n = -1; for (; ++n < e;)t[n] = 0; return t }((s[0] >> 5) * s[1]), f = null, p = l.length, m = -1, g = [], y = l.map((s => ({ text: e(s), font: t(s), style: r(s), weight: i(s), rotate: a(s), size: ~~(n(s) + 1e-14), padding: o(s), xoff: 0, yoff: 0, x1: 0, y1: 0, x0: 0, y0: 0, hasText: !1, sprite: null, datum: s }))).sort(((e, t) => t.size - e.size)); ++m < p;) { var b = y[m]; b.x = s[0] * (c() + .5) >> 1, b.y = s[1] * (c() + .5) >> 1, rR(u, b, y, m), b.hasText && d(h, b, f) && (g.push(b), f ? aR(f, b) : f = [{ x: b.x + b.x0, y: b.y + b.y0 }, { x: b.x + b.x1, y: b.y + b.y1 }], b.x -= s[0] >> 1, b.y -= s[1] >> 1) } return g }, h.words = function (e) { return arguments.length ? (l = e, h) : l }, h.size = function (e) { return arguments.length ? (s = [+e[0], +e[1]], h) : s }, h.font = function (e) { return arguments.length ? (t = uR(e), h) : t }, h.fontStyle = function (e) { return arguments.length ? (r = uR(e), h) : r }, h.fontWeight = function (e) { return arguments.length ? (i = uR(e), h) : i }, h.rotate = function (e) { return arguments.length ? (a = uR(e), h) : a }, h.text = function (t) { return arguments.length ? (e = uR(t), h) : e }, h.spiral = function (e) { return arguments.length ? (u = lR[e] || e, h) : u }, h.fontSize = function (e) { return arguments.length ? (n = uR(e), h) : n }, h.padding = function (e) { return arguments.length ? (o = uR(e), h) : o }, h.random = function (e) { return arguments.length ? (c = e, h) : c }, h } function rR(e, t, n, r) { if (!t.sprite) { var i = e.context, a = e.ratio; i.clearRect(0, 0, (eR << 5) / a, tR / a); var o, s, u, l, c, h = 0, d = 0, f = 0, p = n.length; for (--r; ++r < p;) { if (t = n[r], i.save(), i.font = t.style + " " + t.weight + " " + ~~((t.size + 1) / a) + "px " + t.font, o = i.measureText(t.text + "m").width * a, u = t.size << 1, t.rotate) { var m = Math.sin(t.rotate * Q$), g = Math.cos(t.rotate * Q$), y = o * g, b = o * m, v = u * g, x = u * m; o = Math.max(Math.abs(y + x), Math.abs(y - x)) + 31 >> 5 << 5, u = ~~Math.max(Math.abs(b + v), Math.abs(b - v)) } else o = o + 31 >> 5 << 5; if (u > f && (f = u), h + o >= eR << 5 && (h = 0, d += f, f = 0), d + u >= tR) break; i.translate((h + (o >> 1)) / a, (d + (u >> 1)) / a), t.rotate && i.rotate(t.rotate * Q$), i.fillText(t.text, 0, 0), t.padding && (i.lineWidth = 2 * t.padding, i.strokeText(t.text, 0, 0)), i.restore(), t.width = o, t.height = u, t.xoff = h, t.yoff = d, t.x1 = o >> 1, t.y1 = u >> 1, t.x0 = -t.x1, t.y0 = -t.y1, t.hasText = !0, h += o } for (var w = i.getImageData(0, 0, (eR << 5) / a, tR / a).data, k = []; --r >= 0;)if ((t = n[r]).hasText) { for (s = (o = t.width) >> 5, u = t.y1 - t.y0, l = 0; l < u * s; l++)k[l] = 0; if (null == (h = t.xoff)) return; d = t.yoff; var S = 0, _ = -1; for (c = 0; c < u; c++) { for (l = 0; l < o; l++) { var C = s * c + (l >> 5), A = w[(d + c) * (eR << 5) + (h + l) << 2] ? 1 << 31 - l % 32 : 0; k[C] |= A, S |= A } S ? _ = c : (t.y0++, u--, c--, d++) } t.y1 = t.y0 + _, t.sprite = k.slice(0, (t.y1 - t.y0) * s) } } } function iR(e, t, n) { n >>= 5; for (var r, i = e.sprite, a = e.width >> 5, o = e.x - (a << 4), s = 127 & o, u = 32 - s, l = e.y1 - e.y0, c = (e.y + e.y0) * n + (o >> 5), h = 0; h < l; h++) { r = 0; for (var d = 0; d <= a; d++)if ((r << u | (d < a ? (r = i[h * a + d]) >>> s : 0)) & t[c + d]) return !0; c += n } return !1 } function aR(e, t) { var n = e[0], r = e[1]; t.x + t.x0 < n.x && (n.x = t.x + t.x0), t.y + t.y0 < n.y && (n.y = t.y + t.y0), t.x + t.x1 > r.x && (r.x = t.x + t.x1), t.y + t.y1 > r.y && (r.y = t.y + t.y1) } function oR(e, t) { return e.x + e.x1 > t[0].x && e.x + e.x0 < t[1].x && e.y + e.y1 > t[0].y && e.y + e.y0 < t[1].y } function sR(e) { var t = e[0] / e[1]; return function (e) { return [t * (e *= .1) * Math.cos(e), e * Math.sin(e)] } } function uR(e) { return "function" == typeof e ? e : function () { return e } } var lR = { archimedean: sR, rectangular: function (e) { var t = 4 * e[0] / e[1], n = 0, r = 0; return function (e) { var i = e < 0 ? -1 : 1; switch (Math.sqrt(1 + 4 * i * e) - i & 3) { case 0: n += t; break; case 1: r += 4; break; case 2: n -= t; break; default: r -= 4 }return [n, r] } } }; const cR = ["x", "y", "font", "fontSize", "fontStyle", "fontWeight", "angle"], hR = ["text", "font", "rotate", "fontSize", "fontStyle", "fontWeight"]; function dR(e) { Eu.call(this, nR(), e) } dR.Definition = { type: "Wordcloud", metadata: { modifies: !0 }, params: [{ name: "size", type: "number", array: !0, length: 2 }, { name: "font", type: "string", expr: !0, default: "sans-serif" }, { name: "fontStyle", type: "string", expr: !0, default: "normal" }, { name: "fontWeight", type: "string", expr: !0, default: "normal" }, { name: "fontSize", type: "number", expr: !0, default: 14 }, { name: "fontSizeRange", type: "number", array: "nullable", default: [10, 50] }, { name: "rotate", type: "number", expr: !0, default: 0 }, { name: "text", type: "field" }, { name: "spiral", type: "string", values: ["archimedean", "rectangular"] }, { name: "padding", type: "number", expr: !0 }, { name: "as", type: "string", array: !0, length: 7, default: cR }] }, Ln(dR, Eu, { transform(e, t) { !e.size || e.size[0] && e.size[1] || Vt("Wordcloud size dimensions must be non-zero."); const n = e.modified(); if (!(n || t.changed(t.ADD_REM) || hR.some((function (n) { const r = e[n]; return Cn(r) && t.modified(r.fields) })))) return; const r = t.materialize(t.SOURCE).source, i = this.value, a = e.as || cR; let o, s = e.fontSize || 14; if (Cn(s) ? o = e.fontSizeRange : s = Fn(s), o) { const e = s, t = fb("sqrt")().domain(Rn(r, e)).range(o); s = n => t(e(n)) } r.forEach((e => { e[a[0]] = NaN, e[a[1]] = NaN, e[a[3]] = 0 })); const u = i.words(r).text(e.text).size(e.size || [500, 500]).padding(e.padding || 1).spiral(e.spiral || "archimedean").rotate(e.rotate || 0).font(e.font || "sans-serif").fontStyle(e.fontStyle || "normal").fontWeight(e.fontWeight || "normal").fontSize(s).random(Hu).layout(), l = i.size(), c = l[0] >> 1, h = l[1] >> 1, d = u.length; for (let e, t, n = 0; n < d; ++n)e = u[n], t = e.datum, t[a[0]] = e.x + c, t[a[1]] = e.y + h, t[a[2]] = e.font, t[a[3]] = e.size, t[a[4]] = e.style, t[a[5]] = e.weight, t[a[6]] = e.rotate; return t.reflow(n).modifies(a) } }); const fR = Dl(Cl), pR = fR.right, mR = fR.left, gR = (Dl(El).center, pR); const yR = e => new Uint8Array(e), bR = e => new Uint16Array(e), vR = e => new Uint32Array(e); function xR(e, t, n) { const r = (t < 257 ? yR : t < 65537 ? bR : vR)(e); return n && r.set(n), r } function wR(e, t, n) { const r = 1 << t; return { one: r, zero: ~r, range: n.slice(), bisect: e.bisect, index: e.index, size: e.size, onAdd(e, t) { const n = this, i = n.bisect(n.range, e.value), a = e.index, o = i[0], s = i[1], u = a.length; let l; for (l = 0; l < o; ++l)t[a[l]] |= r; for (l = s; l < u; ++l)t[a[l]] |= r; return n } } } function kR() { let e = vR(0), t = [], n = 0; return { insert: function (r, i, a) { if (!i.length) return []; const o = n, s = i.length, u = vR(s); let l, c, h, d = Array(s); for (h = 0; h < s; ++h)d[h] = r(i[h]), u[h] = h; if (d = function (e, t) { return e.sort.call(t, ((t, n) => { const r = e[t], i = e[n]; return r < i ? -1 : r > i ? 1 : 0 })), function (e, t) { return Array.from(t, (t => e[t])) }(e, t) }(d, u), o) l = t, c = e, t = Array(o + s), e = vR(o + s), function (e, t, n, r, i, a, o, s, u) { let l, c = 0, h = 0; for (l = 0; c < r && h < o; ++l)t[c] < i[h] ? (s[l] = t[c], u[l] = n[c++]) : (s[l] = i[h], u[l] = a[h++] + e); for (; c < r; ++c, ++l)s[l] = t[c], u[l] = n[c]; for (; h < o; ++h, ++l)s[l] = i[h], u[l] = a[h] + e }(a, l, c, o, d, u, s, t, e); else { if (a > 0) for (h = 0; h < s; ++h)u[h] += a; t = d, e = u } return n = o + s, { index: u, value: d } }, remove: function (r, i) { const a = n; let o, s, u; for (s = 0; !i[e[s]] && s < a; ++s); for (u = s; s < a; ++s)i[o = e[s]] || (e[u] = o, t[u] = t[s], ++u); n = a - r }, bisect: function (e, r) { let i; return r ? i = r.length : (r = t, i = n), [mR(r, e[0], 0, i), pR(r, e[1], 0, i)] }, reindex: function (t) { for (let r = 0, i = n; r < i; ++r)e[r] = t[e[r]] }, index: () => e, size: () => n } } function SR(e) { Eu.call(this, function () { let e = 8, t = [], n = vR(0), r = xR(0, e), i = xR(0, e); return { data: () => t, seen: () => n = function (e, t, n) { return e.length >= t ? e : ((n = n || new e.constructor(t)).set(e), n) }(n, t.length), add(e) { for (let n, r = 0, i = t.length, a = e.length; r < a; ++r)n = e[r], n._index = i++, t.push(n) }, remove(e, n) { const a = t.length, o = Array(a - e), s = t; let u, l, c; for (l = 0; !n[l] && l < a; ++l)o[l] = t[l], s[l] = l; for (c = l; l < a; ++l)u = t[l], n[l] ? s[l] = -1 : (s[l] = c, r[c] = r[l], i[c] = i[l], o[c] = u, u._index = c++), r[l] = 0; return t = o, s }, size: () => t.length, curr: () => r, prev: () => i, reset: e => i[e] = r[e], all: () => e < 257 ? 255 : e < 65537 ? 65535 : 4294967295, set(e, t) { r[e] |= t }, clear(e, t) { r[e] &= ~t }, resize(t, n) { (t > r.length || n > e) && (e = Math.max(n, e), r = xR(t, e, r), i = xR(t, e)) } } }(), e), this._indices = null, this._dims = null } function _R(e) { Eu.call(this, null, e) } function* CR(e, t) { if (null == t) for (let t of e) null != t && "" !== t && (t = +t) >= t && (yield t); else { let n = -1; for (let r of e) r = t(r, ++n, e), null != r && "" !== r && (r = +r) >= r && (yield r) } } function AR(e, t, n) { const r = Float64Array.from(CR(e, n)); return r.sort(Cl), t.map((e => Il(r, e))) } function TR(e, t) { return AR(e, [.25, .5, .75], t) } function ER(e, t) { const n = e.length, r = function (e, t) { const n = function (e, t) { let n, r = 0, i = 0, a = 0; if (void 0 === t) for (let t of e) null != t && (t = +t) >= t && (n = t - i, i += n / ++r, a += n * (t - i)); else { let o = -1; for (let s of e) null != (s = t(s, ++o, e)) && (s = +s) >= s && (n = s - i, i += n / ++r, a += n * (s - i)) } if (r > 1) return a / (r - 1) }(e, t); return n ? Math.sqrt(n) : n }(e, t), i = TR(e, t), a = (i[2] - i[0]) / 1.34; return 1.06 * (Math.min(r, a) || r || Math.abs(i[0]) || 1) * Math.pow(n, -.2) } function NR(e) { const t = e.maxbins || 20, n = e.base || 10, r = Math.log(n), i = e.divide || [5, 2]; let a, o, s, u, l, c, h = e.extent[0], d = e.extent[1]; const f = e.span || d - h || Math.abs(h) || 1; if (e.step) a = e.step; else if (e.steps) { for (u = f / t, l = 0, c = e.steps.length; l < c && e.steps[l] < u; ++l); a = e.steps[Math.max(0, l - 1)] } else { for (o = Math.ceil(Math.log(t) / r), s = e.minstep || 0, a = Math.max(s, Math.pow(n, Math.round(Math.log(f) / r) - o)); Math.ceil(f / a) > t;)a *= n; for (l = 0, c = i.length; l < c; ++l)u = a / i[l], u >= s && f / u <= t && (a = u) } u = Math.log(a); const p = u >= 0 ? 0 : 1 + ~~(-u / r), m = Math.pow(n, -p - 1); return (e.nice || void 0 === e.nice) && (u = Math.floor(h / a + m) * a, h = h < u ? u - a : u, d = Math.ceil(d / a) * a), { start: h, stop: d === h ? h + a : d, step: a } } SR.Definition = { type: "CrossFilter", metadata: {}, params: [{ name: "fields", type: "field", array: !0, required: !0 }, { name: "query", type: "array", array: !0, required: !0, content: { type: "number", array: !0, length: 2 } }] }, Ln(SR, Eu, { transform(e, t) { return this._dims ? e.modified("fields") || e.fields.some((e => t.modified(e.fields))) ? this.reinit(e, t) : this.eval(e, t) : this.init(e, t) }, init(e, t) { const n = e.fields, r = e.query, i = this._indices = {}, a = this._dims = [], o = r.length; let s, u, l = 0; for (; l < o; ++l)s = n[l].fname, u = i[s] || (i[s] = kR()), a.push(wR(u, l, r[l])); return this.eval(e, t) }, reinit(e, t) { const n = t.materialize().fork(), r = e.fields, i = e.query, a = this._indices, o = this._dims, s = this.value, u = s.curr(), l = s.prev(), c = s.all(), h = n.rem = n.add, d = n.mod, f = i.length, p = {}; let m, g, y, b, v, x, w, k, S; if (l.set(u), t.rem.length && (v = this.remove(e, t, n)), t.add.length && s.add(t.add), t.mod.length) for (x = {}, b = t.mod, w = 0, k = b.length; w < k; ++w)x[b[w]._index] = 1; for (w = 0; w < f; ++w)S = r[w], (!o[w] || e.modified("fields", w) || t.modified(S.fields)) && (y = S.fname, (m = p[y]) || (a[y] = g = kR(), p[y] = m = g.insert(S, t.source, 0)), o[w] = wR(g, w, i[w]).onAdd(m, u)); for (w = 0, k = s.data().length; w < k; ++w)v[w] || (l[w] !== u[w] ? h.push(w) : x[w] && u[w] !== c && d.push(w)); return s.mask = (1 << f) - 1, n }, eval(e, t) { const n = t.materialize().fork(), r = this._dims.length; let i = 0; return t.rem.length && (this.remove(e, t, n), i |= (1 << r) - 1), e.modified("query") && !e.modified("fields") && (i |= this.update(e, t, n)), t.add.length && (this.insert(e, t, n), i |= (1 << r) - 1), t.mod.length && (this.modify(t, n), i |= (1 << r) - 1), this.value.mask = i, n }, insert(e, t, n) { const r = t.add, i = this.value, a = this._dims, o = this._indices, s = e.fields, u = {}, l = n.add, c = i.size() + r.length, h = a.length; let d, f, p, m = i.size(); i.resize(c, h), i.add(r); const g = i.curr(), y = i.prev(), b = i.all(); for (d = 0; d < h; ++d)f = s[d].fname, p = u[f] || (u[f] = o[f].insert(s[d], r, m)), a[d].onAdd(p, g); for (; m < c; ++m)y[m] = b, g[m] !== b && l.push(m) }, modify(e, t) { const n = t.mod, r = this.value, i = r.curr(), a = r.all(), o = e.mod; let s, u, l; for (s = 0, u = o.length; s < u; ++s)l = o[s]._index, i[l] !== a && n.push(l) }, remove(e, t, n) { const r = this._indices, i = this.value, a = i.curr(), o = i.prev(), s = i.all(), u = {}, l = n.rem, c = t.rem; let h, d, f, p; for (h = 0, d = c.length; h < d; ++h)f = c[h]._index, u[f] = 1, o[f] = p = a[f], a[f] = s, p !== s && l.push(f); for (f in r) r[f].remove(d, u); return this.reindex(t, d, u), u }, reindex(e, t, n) { const r = this._indices, i = this.value; e.runAfter((() => { const e = i.remove(t, n); for (const t in r) r[t].reindex(e) })) }, update(e, t, n) { const r = this._dims, i = e.query, a = t.stamp, o = r.length; let s, u, l = 0; for (n.filters = 0, u = 0; u < o; ++u)e.modified("query", u) && (s = u, ++l); if (1 === l) l = r[s].one, this.incrementOne(r[s], i[s], n.add, n.rem); else for (u = 0, l = 0; u < o; ++u)e.modified("query", u) && (l |= r[u].one, this.incrementAll(r[u], i[u], a, n.add), n.rem = n.add); return l }, incrementAll(e, t, n, r) { const i = this.value, a = i.seen(), o = i.curr(), s = i.prev(), u = e.index(), l = e.bisect(e.range), c = e.bisect(t), h = c[0], d = c[1], f = l[0], p = l[1], m = e.one; let g, y, b; if (h < f) for (g = h, y = Math.min(f, d); g < y; ++g)b = u[g], a[b] !== n && (s[b] = o[b], a[b] = n, r.push(b)), o[b] ^= m; else if (h > f) for (g = f, y = Math.min(h, p); g < y; ++g)b = u[g], a[b] !== n && (s[b] = o[b], a[b] = n, r.push(b)), o[b] ^= m; if (d > p) for (g = Math.max(h, p), y = d; g < y; ++g)b = u[g], a[b] !== n && (s[b] = o[b], a[b] = n, r.push(b)), o[b] ^= m; else if (d < p) for (g = Math.max(f, d), y = p; g < y; ++g)b = u[g], a[b] !== n && (s[b] = o[b], a[b] = n, r.push(b)), o[b] ^= m; e.range = t.slice() }, incrementOne(e, t, n, r) { const i = this.value.curr(), a = e.index(), o = e.bisect(e.range), s = e.bisect(t), u = s[0], l = s[1], c = o[0], h = o[1], d = e.one; let f, p, m; if (u < c) for (f = u, p = Math.min(c, l); f < p; ++f)m = a[f], i[m] ^= d, n.push(m); else if (u > c) for (f = c, p = Math.min(u, h); f < p; ++f)m = a[f], i[m] ^= d, r.push(m); if (l > h) for (f = Math.max(u, h), p = l; f < p; ++f)m = a[f], i[m] ^= d, n.push(m); else if (l < h) for (f = Math.max(c, l), p = h; f < p; ++f)m = a[f], i[m] ^= d, r.push(m); e.range = t.slice() } }), _R.Definition = { type: "ResolveFilter", metadata: {}, params: [{ name: "ignore", type: "number", required: !0, description: "A bit mask indicating which filters to ignore." }, { name: "filter", type: "object", required: !0, description: "Per-tuple filter bitmaps from a CrossFilter transform." }] }, Ln(_R, Eu, { transform(e, t) { const n = ~(e.ignore || 0), r = e.filter, i = r.mask; if (!(i & n)) return t.StopPropagation; const a = t.fork(t.ALL), o = r.data(), s = r.curr(), u = r.prev(), l = e => s[e] & n ? null : o[e]; return a.filter(a.MOD, l), i & i - 1 ? (a.filter(a.ADD, (e => { const t = s[e] & n; return !t && t ^ u[e] & n ? o[e] : null })), a.filter(a.REM, (e => { const t = s[e] & n; return t && !(0 ^ u[e] & n) ? o[e] : null }))) : (a.filter(a.ADD, l), a.filter(a.REM, (e => (s[e] & n) === i ? o[e] : null))), a.filter(a.SOURCE, (e => l(e._index))) } }); var IR = Math.random; function MR(e) { IR = e } function FR(e, t, n, r) { if (!e.length) return [void 0, void 0]; const i = Float64Array.from(CR(e, r)), a = i.length, o = t; let s, u, l, c; for (l = 0, c = Array(o); l < o; ++l) { for (s = 0, u = 0; u < a; ++u)s += i[~~(IR() * a)]; c[l] = s / a } return c.sort(Cl), [Nl(c, n / 2), Nl(c, 1 - n / 2)] } function DR(e, t, n, r) { r = r || (e => e); const i = e.length, a = new Float64Array(i); let o, s = 0, u = 1, l = r(e[0]), c = l, h = l + t; for (; u < i; ++u) { if (o = r(e[u]), o >= h) { for (c = (l + c) / 2; s < u; ++s)a[s] = c; h = o + t, l = o } c = o } for (c = (l + c) / 2; s < u; ++s)a[s] = c; return n ? function (e, t) { const n = e.length; let r, i, a = 0, o = 1; for (; e[a] === e[o];)++o; for (; o < n;) { for (r = o + 1; e[o] === e[r];)++r; if (e[o] - e[o - 1] < t) { for (i = o + (a + r - o - o >> 1); i < o;)e[i++] = e[o]; for (; i > o;)e[i--] = e[a] } a = o, o = r } return e }(a, t + t / 4) : a } function $R(e) { return function () { return (e = (1103515245 * e + 12345) % 2147483647) / 2147483647 } } function RR(e, t) { let n, r, i; null == t && (t = e, e = 0); const a = { min(e) { return arguments.length ? (n = e || 0, i = r - n, a) : n }, max(e) { return arguments.length ? (r = e || 0, i = r - n, a) : r }, sample: () => n + Math.floor(i * IR()), pdf: e => e === Math.floor(e) && e >= n && e < r ? 1 / i : 0, cdf(e) { const t = Math.floor(e); return t < n ? 0 : t >= r ? 1 : (t - n + 1) / i }, icdf: e => e >= 0 && e <= 1 ? n - 1 + Math.floor(e * i) : NaN }; return a.min(e).max(t) } const OR = Math.sqrt(2 * Math.PI), zR = Math.SQRT2; let PR = NaN; function BR(e, t) { e = e || 0, t = null == t ? 1 : t; let n, r, i = 0, a = 0; if (PR == PR) i = PR, PR = NaN; else { do { i = 2 * IR() - 1, a = 2 * IR() - 1, n = i * i + a * a } while (0 === n || n > 1); r = Math.sqrt(-2 * Math.log(n) / n), i *= r, PR = a * r } return e + i * t } function LR(e, t, n) { const r = (e - (t || 0)) / (n = null == n ? 1 : n); return Math.exp(-.5 * r * r) / (n * OR) } function jR(e, t, n) { const r = (e - (t = t || 0)) / (n = null == n ? 1 : n), i = Math.abs(r); let a; if (i > 37) a = 0; else { const e = Math.exp(-i * i / 2); let t; i < 7.07106781186547 ? (t = .0352624965998911 * i + .700383064443688, t = t * i + 6.37396220353165, t = t * i + 33.912866078383, t = t * i + 112.079291497871, t = t * i + 221.213596169931, t = t * i + 220.206867912376, a = e * t, t = .0883883476483184 * i + 1.75566716318264, t = t * i + 16.064177579207, t = t * i + 86.7807322029461, t = t * i + 296.564248779674, t = t * i + 637.333633378831, t = t * i + 793.826512519948, t = t * i + 440.413735824752, a /= t) : (t = i + .65, t = i + 4 / t, t = i + 3 / t, t = i + 2 / t, t = i + 1 / t, a = e / t / 2.506628274631) } return r > 0 ? 1 - a : a } function UR(e, t, n) { return e < 0 || e > 1 ? NaN : (t || 0) + (null == n ? 1 : n) * zR * function (e) { let t, n = -Math.log((1 - e) * (1 + e)); n < 6.25 ? (n -= 3.125, t = -364441206401782e-35, t = t * n - 16850591381820166e-35, t = 128584807152564e-32 + t * n, t = 11157877678025181e-33 + t * n, t = t * n - 1333171662854621e-31, t = 20972767875968562e-33 + t * n, t = 6637638134358324e-30 + t * n, t = t * n - 4054566272975207e-29, t = t * n - 8151934197605472e-29, t = 26335093153082323e-28 + t * n, t = t * n - 12975133253453532e-27, t = t * n - 5415412054294628e-26, t = 1.0512122733215323e-9 + t * n, t = t * n - 4.112633980346984e-9, t = t * n - 2.9070369957882005e-8, t = 4.2347877827932404e-7 + t * n, t = t * n - 13654692000834679e-22, t = t * n - 13882523362786469e-21, t = .00018673420803405714 + t * n, t = t * n - .000740702534166267, t = t * n - .006033670871430149, t = .24015818242558962 + t * n, t = 1.6536545626831027 + t * n) : n < 16 ? (n = Math.sqrt(n) - 3.25, t = 2.2137376921775787e-9, t = 9.075656193888539e-8 + t * n, t = t * n - 2.7517406297064545e-7, t = 1.8239629214389228e-8 + t * n, t = 15027403968909828e-22 + t * n, t = t * n - 4013867526981546e-21, t = 29234449089955446e-22 + t * n, t = 12475304481671779e-21 + t * n, t = t * n - 47318229009055734e-21, t = 6828485145957318e-20 + t * n, t = 24031110387097894e-21 + t * n, t = t * n - .0003550375203628475, t = .0009532893797373805 + t * n, t = t * n - .0016882755560235047, t = .002491442096107851 + t * n, t = t * n - .003751208507569241, t = .005370914553590064 + t * n, t = 1.0052589676941592 + t * n, t = 3.0838856104922208 + t * n) : Number.isFinite(n) ? (n = Math.sqrt(n) - 5, t = -27109920616438573e-27, t = t * n - 2.555641816996525e-10, t = 1.5076572693500548e-9 + t * n, t = t * n - 3.789465440126737e-9, t = 7.61570120807834e-9 + t * n, t = t * n - 1.496002662714924e-8, t = 2.914795345090108e-8 + t * n, t = t * n - 6.771199775845234e-8, t = 2.2900482228026655e-7 + t * n, t = t * n - 9.9298272942317e-7, t = 4526062597223154e-21 + t * n, t = t * n - 1968177810553167e-20, t = 7599527703001776e-20 + t * n, t = t * n - .00021503011930044477, t = t * n - .00013871931833623122, t = 1.0103004648645344 + t * n, t = 4.849906401408584 + t * n) : t = 1 / 0; return t * e }(2 * e - 1) } function WR(e, t) { let n, r; const i = { mean(e) { return arguments.length ? (n = e || 0, i) : n }, stdev(e) { return arguments.length ? (r = null == e ? 1 : e, i) : r }, sample: () => BR(n, r), pdf: e => LR(e, n, r), cdf: e => jR(e, n, r), icdf: e => UR(e, n, r) }; return i.mean(e).stdev(t) } function VR(e, t) { const n = WR(); let r = 0; const i = { data(n) { return arguments.length ? (e = n, r = n ? n.length : 0, i.bandwidth(t)) : e }, bandwidth(n) { return arguments.length ? (!(t = n) && e && (t = ER(e)), i) : t }, sample: () => e[~~(IR() * r)] + t * n.sample(), pdf(i) { let a = 0, o = 0; for (; o < r; ++o)a += n.pdf((i - e[o]) / t); return a / t / r }, cdf(i) { let a = 0, o = 0; for (; o < r; ++o)a += n.cdf((i - e[o]) / t); return a / r }, icdf() { throw Error("KDE icdf not supported.") } }; return i.data(e) } function GR(e, t) { return e = e || 0, t = null == t ? 1 : t, Math.exp(e + BR() * t) } function HR(e, t, n) { if (e <= 0) return 0; t = t || 0, n = null == n ? 1 : n; const r = (Math.log(e) - t) / n; return Math.exp(-.5 * r * r) / (n * OR * e) } function qR(e, t, n) { return jR(Math.log(e), t, n) } function YR(e, t, n) { return Math.exp(UR(e, t, n)) } function XR(e, t) { let n, r; const i = { mean(e) { return arguments.length ? (n = e || 0, i) : n }, stdev(e) { return arguments.length ? (r = null == e ? 1 : e, i) : r }, sample: () => GR(n, r), pdf: e => HR(e, n, r), cdf: e => qR(e, n, r), icdf: e => YR(e, n, r) }; return i.mean(e).stdev(t) } function KR(e, t) { let n, r = 0; const i = { weights(e) { return arguments.length ? (n = function (e) { const t = []; let n, i = 0; for (n = 0; n < r; ++n)i += t[n] = null == e[n] ? 1 : +e[n]; for (n = 0; n < r; ++n)t[n] /= i; return t }(t = e || []), i) : t }, distributions(n) { return arguments.length ? (n ? (r = n.length, e = n) : (r = 0, e = []), i.weights(t)) : e }, sample() { const t = IR(); let i = e[r - 1], a = n[0], o = 0; for (; o < r - 1; a += n[++o])if (t < a) { i = e[o]; break } return i.sample() }, pdf(t) { let i = 0, a = 0; for (; a < r; ++a)i += n[a] * e[a].pdf(t); return i }, cdf(t) { let i = 0, a = 0; for (; a < r; ++a)i += n[a] * e[a].cdf(t); return i }, icdf() { throw Error("Mixture icdf not supported.") } }; return i.distributions(e).weights(t) } function ZR(e, t) { return null == t && (t = null == e ? 1 : e, e = 0), e + (t - e) * IR() } function JR(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e >= t && e <= n ? 1 / (n - t) : 0 } function QR(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e < t ? 0 : e > n ? 1 : (e - t) / (n - t) } function eO(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e >= 0 && e <= 1 ? t + e * (n - t) : NaN } function tO(e, t) { let n, r; const i = { min(e) { return arguments.length ? (n = e || 0, i) : n }, max(e) { return arguments.length ? (r = null == e ? 1 : e, i) : r }, sample: () => ZR(n, r), pdf: e => JR(e, n, r), cdf: e => QR(e, n, r), icdf: e => eO(e, n, r) }; return null == t && (t = null == e ? 1 : e, e = 0), i.min(e).max(t) } function nO(e, t, n, r) { const i = r - e * e, a = Math.abs(i) < 1e-24 ? 0 : (n - e * t) / i; return [t - a * e, a] } function rO(e, t, n, r) { e = e.filter((e => { let r = t(e), i = n(e); return null != r && (r = +r) >= r && null != i && (i = +i) >= i })), r && e.sort(((e, n) => t(e) - t(n))); const i = e.length, a = new Float64Array(i), o = new Float64Array(i); let s, u, l, c = 0, h = 0, d = 0; for (l of e) a[c] = s = +t(l), o[c] = u = +n(l), ++c, h += (s - h) / c, d += (u - d) / c; for (c = 0; c < i; ++c)a[c] -= h, o[c] -= d; return [a, o, h, d] } function iO(e, t, n, r) { let i, a, o = -1; for (const s of e) i = t(s), a = n(s), null != i && (i = +i) >= i && null != a && (a = +a) >= a && r(i, a, ++o) } function aO(e, t, n, r, i) { let a = 0, o = 0; return iO(e, t, n, ((e, t) => { const n = t - i(e), s = t - r; a += n * n, o += s * s })), 1 - a / o } function oO(e, t, n) { let r = 0, i = 0, a = 0, o = 0, s = 0; iO(e, t, n, ((e, t) => { ++s, r += (e - r) / s, i += (t - i) / s, a += (e * t - a) / s, o += (e * e - o) / s })); const u = nO(r, i, a, o), l = e => u[0] + u[1] * e; return { coef: u, predict: l, rSquared: aO(e, t, n, i, l) } } function sO(e, t, n) { let r = 0, i = 0, a = 0, o = 0, s = 0; iO(e, t, n, ((e, t) => { ++s, e = Math.log(e), r += (e - r) / s, i += (t - i) / s, a += (e * t - a) / s, o += (e * e - o) / s })); const u = nO(r, i, a, o), l = e => u[0] + u[1] * Math.log(e); return { coef: u, predict: l, rSquared: aO(e, t, n, i, l) } } function uO(e, t, n) { const [r, i, a, o] = rO(e, t, n); let s, u, l, c = 0, h = 0, d = 0, f = 0, p = 0; iO(e, t, n, ((e, t) => { s = r[p++], u = Math.log(t), l = s * t, c += (t * u - c) / p, h += (l - h) / p, d += (l * u - d) / p, f += (s * l - f) / p })); const [m, g] = nO(h / o, c / o, d / o, f / o), y = e => Math.exp(m + g * (e - a)); return { coef: [Math.exp(m - g * a), g], predict: y, rSquared: aO(e, t, n, o, y) } } function lO(e, t, n) { let r = 0, i = 0, a = 0, o = 0, s = 0, u = 0; iO(e, t, n, ((e, t) => { const n = Math.log(e), l = Math.log(t); ++u, r += (n - r) / u, i += (l - i) / u, a += (n * l - a) / u, o += (n * n - o) / u, s += (t - s) / u })); const l = nO(r, i, a, o), c = e => l[0] * Math.pow(e, l[1]); return l[0] = Math.exp(l[0]), { coef: l, predict: c, rSquared: aO(e, t, n, s, c) } } function cO(e, t, n) { const [r, i, a, o] = rO(e, t, n), s = r.length; let u, l, c, h, d = 0, f = 0, p = 0, m = 0, g = 0; for (u = 0; u < s;)l = r[u], c = i[u++], h = l * l, d += (h - d) / u, f += (h * l - f) / u, p += (h * h - p) / u, m += (l * c - m) / u, g += (h * c - g) / u; const y = p - d * d, b = d * y - f * f, v = (g * d - m * f) / b, x = (m * y - g * f) / b, w = -v * d, k = e => v * (e -= a) * e + x * e + w + o; return { coef: [w - x * a + v * a * a + o, x - 2 * v * a, v], predict: k, rSquared: aO(e, t, n, o, k) } } function hO(e, t, n, r) { if (1 === r) return oO(e, t, n); if (2 === r) return cO(e, t, n); const [i, a, o, s] = rO(e, t, n), u = i.length, l = [], c = [], h = r + 1; let d, f, p, m, g; for (d = 0; d < h; ++d) { for (p = 0, m = 0; p < u; ++p)m += Math.pow(i[p], d) * a[p]; for (l.push(m), g = new Float64Array(h), f = 0; f < h; ++f) { for (p = 0, m = 0; p < u; ++p)m += Math.pow(i[p], d + f); g[f] = m } c.push(g) } c.push(l); const y = function (e) { const t = e.length - 1, n = []; let r, i, a, o, s; for (r = 0; r < t; ++r) { for (o = r, i = r + 1; i < t; ++i)Math.abs(e[r][i]) > Math.abs(e[r][o]) && (o = i); for (a = r; a < t + 1; ++a)s = e[a][r], e[a][r] = e[a][o], e[a][o] = s; for (i = r + 1; i < t; ++i)for (a = t; a >= r; a--)e[a][i] -= e[a][r] * e[r][i] / e[r][r] } for (i = t - 1; i >= 0; --i) { for (s = 0, a = i + 1; a < t; ++a)s += e[a][i] * n[a]; n[i] = (e[t][i] - s) / e[i][i] } return n }(c), b = e => { e -= o; let t = s + y[0] + y[1] * e + y[2] * e * e; for (d = 3; d < h; ++d)t += y[d] * Math.pow(e, d); return t }; return { coef: dO(h, y, -o, s), predict: b, rSquared: aO(e, t, n, s, b) } } function dO(e, t, n, r) { const i = Array(e); let a, o, s, u; for (a = 0; a < e; ++a)i[a] = 0; for (a = e - 1; a >= 0; --a)for (s = t[a], u = 1, i[a] += s, o = 1; o <= a; ++o)u *= (a + 1 - o) / o, i[a - o] += s * Math.pow(n, o) * u; return i[0] += r, i } const fO = 2, pO = 1e-12; function mO(e, t, n, r) { const [i, a, o, s] = rO(e, t, n, !0), u = i.length, l = Math.max(2, ~~(r * u)), c = new Float64Array(u), h = new Float64Array(u), d = new Float64Array(u).fill(1); for (let e = -1; ++e <= fO;) { const t = [0, l - 1]; for (let e = 0; e < u; ++e) { const n = i[e], r = t[0], o = t[1], s = n - i[r] > i[o] - n ? r : o; let u = 0, l = 0, f = 0, p = 0, m = 0; const g = 1 / Math.abs(i[s] - n || 1); for (let e = r; e <= o; ++e) { const t = i[e], r = a[e], o = gO(Math.abs(n - t) * g) * d[e], s = t * o; u += o, l += s, f += r * o, p += r * s, m += t * s } const [y, b] = nO(l / u, f / u, p / u, m / u); c[e] = y + b * n, h[e] = Math.abs(a[e] - c[e]), yO(i, e + 1, t) } if (e === fO) break; const n = Ml(h); if (Math.abs(n) < pO) break; for (let e, t, r = 0; r < u; ++r)e = h[r] / (6 * n), d[r] = e >= 1 ? pO : (t = 1 - e * e) * t } return function (e, t, n, r) { const i = e.length, a = []; let o, s = 0, u = 0, l = []; for (; s < i; ++s)o = e[s] + n, l[0] === o ? l[1] += (t[s] - l[1]) / ++u : (u = 0, l[1] += r, l = [o, t[s]], a.push(l)); return l[1] += r, a }(i, c, o, s) } function gO(e) { return (e = 1 - e * e * e) * e * e } function yO(e, t, n) { const r = e[t]; let i = n[0], a = n[1] + 1; if (!(a >= e.length)) for (; t > i && e[a] - r <= r - e[i];)n[0] = ++i, n[1] = a, ++a } const bO = .5 * Math.PI / 180; function vO(e, t, n, r) { n = n || 25, r = Math.max(n, r || 200); const i = t => [t, e(t)], a = t[0], o = t[1], s = o - a, u = s / r, l = [i(a)], c = []; if (n === r) { for (let e = 1; e < r; ++e)l.push(i(a + e / n * s)); return l.push(i(o)), l } c.push(i(o)); for (let e = n; --e > 0;)c.push(i(a + e / n * s)); let h = l[0], d = c[c.length - 1]; const f = 1 / s, p = function (e, t) { let n = e, r = e; const i = t.length; for (let e = 0; e < i; ++e) { const i = t[e][1]; i < n && (n = i), i > r && (r = i) } return 1 / (r - n) }(h[1], c); for (; d;) { const e = i((h[0] + d[0]) / 2); e[0] - h[0] >= u && xO(h, e, d, f, p) > bO ? c.push(e) : (h = d, l.push(d), c.pop()), d = c[c.length - 1] } return l } function xO(e, t, n, r, i) { const a = Math.atan2(i * (n[1] - e[1]), r * (n[0] - e[0])), o = Math.atan2(i * (t[1] - e[1]), r * (t[0] - e[0])); return Math.abs(a - o) } function wO(e, t, n) { return e.fields = t || [], e.fname = n, e } function kO(e) { return 1 === e.length ? SO(e[0]) : _O(e) } const SO = e => function (t) { return t[e] }, _O = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function CO(e) { throw Error(e) } function AO(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || CO("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && CO("Access path missing closing bracket: " + e), o && CO("Access path missing closing quote: " + e), i > r && (i++, l()), t } function TO(e, t, n) { const r = AO(e); return e = 1 === r.length ? r[0] : e, wO((n && n.get || kO)(r), [e], t || e) } TO("id"), wO((e => e), [], "identity"); const EO = wO((() => 0), [], "zero"), NO = wO((() => 1), [], "one"); wO((() => !0), [], "true"), wO((() => !1), [], "false"); var IO = Array.isArray; function MO(e) { return e[e.length - 1] } function FO(e) { return null != e ? IO(e) ? e : [e] : [] } function DO(e) { return "function" == typeof e } function $O(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } const RO = Object.prototype.hasOwnProperty; function OO(e, t) { return RO.call(e, t) } var zO = new Date, PO = new Date; function BO(e, t, n, r) { function i(t) { return e(t = 0 === arguments.length ? new Date : new Date(+t)), t } return i.floor = function (t) { return e(t = new Date(+t)), t }, i.ceil = function (n) { return e(n = new Date(n - 1)), t(n, 1), e(n), n }, i.round = function (e) { var t = i(e), n = i.ceil(e); return e - t < n - e ? t : n }, i.offset = function (e, n) { return t(e = new Date(+e), null == n ? 1 : Math.floor(n)), e }, i.range = function (n, r, a) { var o, s = []; if (n = i.ceil(n), a = null == a ? 1 : Math.floor(a), !(n < r && a > 0)) return s; do { s.push(o = new Date(+n)), t(n, a), e(n) } while (o < n && n < r); return s }, i.filter = function (n) { return BO((function (t) { if (t >= t) for (; e(t), !n(t);)t.setTime(t - 1) }), (function (e, r) { if (e >= e) if (r < 0) for (; ++r <= 0;)for (; t(e, -1), !n(e);); else for (; --r >= 0;)for (; t(e, 1), !n(e);); })) }, n && (i.count = function (t, r) { return zO.setTime(+t), PO.setTime(+r), e(zO), e(PO), Math.floor(n(zO, PO)) }, i.every = function (e) { return e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? i.filter(r ? function (t) { return r(t) % e == 0 } : function (t) { return i.count(0, t) % e == 0 }) : i : null }), i } const LO = 1e3, jO = 6e4, UO = 36e5, WO = 864e5, VO = 6048e5; var GO = BO((e => e.setHours(0, 0, 0, 0)), ((e, t) => e.setDate(e.getDate() + t)), ((e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * jO) / WO), (e => e.getDate() - 1)); const HO = GO; GO.range; function qO(e) { return BO((function (t) { t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0) }), (function (e, t) { e.setDate(e.getDate() + 7 * t) }), (function (e, t) { return (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * jO) / VO })) } var YO = qO(0), XO = qO(1), KO = qO(2), ZO = qO(3), JO = qO(4), QO = qO(5), ez = qO(6), tz = (YO.range, XO.range, KO.range, ZO.range, JO.range, QO.range, ez.range, BO((function (e) { e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + t) }), (function (e, t) { return (t - e) / WO }), (function (e) { return e.getUTCDate() - 1 }))); const nz = tz; tz.range; function rz(e) { return BO((function (t) { t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + 7 * t) }), (function (e, t) { return (t - e) / VO })) } var iz = rz(0), az = rz(1), oz = rz(2), sz = rz(3), uz = rz(4), lz = rz(5), cz = rz(6), hz = (iz.range, az.range, oz.range, sz.range, uz.range, lz.range, cz.range, BO((function (e) { e.setMonth(0, 1), e.setHours(0, 0, 0, 0) }), (function (e, t) { e.setFullYear(e.getFullYear() + t) }), (function (e, t) { return t.getFullYear() - e.getFullYear() }), (function (e) { return e.getFullYear() }))); hz.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? BO((function (t) { t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0) }), (function (t, n) { t.setFullYear(t.getFullYear() + n * e) })) : null }; const dz = hz; hz.range; var fz = BO((function (e) { e.setDate(1), e.setHours(0, 0, 0, 0) }), (function (e, t) { e.setMonth(e.getMonth() + t) }), (function (e, t) { return t.getMonth() - e.getMonth() + 12 * (t.getFullYear() - e.getFullYear()) }), (function (e) { return e.getMonth() })); const pz = fz; fz.range; var mz = BO((function (e) { e.setTime(e - e.getMilliseconds() - e.getSeconds() * LO - e.getMinutes() * jO) }), (function (e, t) { e.setTime(+e + t * UO) }), (function (e, t) { return (t - e) / UO }), (function (e) { return e.getHours() })); const gz = mz; mz.range; var yz = BO((function (e) { e.setTime(e - e.getMilliseconds() - e.getSeconds() * LO) }), (function (e, t) { e.setTime(+e + t * jO) }), (function (e, t) { return (t - e) / jO }), (function (e) { return e.getMinutes() })); const bz = yz; yz.range; var vz = BO((function (e) { e.setTime(e - e.getMilliseconds()) }), (function (e, t) { e.setTime(+e + t * LO) }), (function (e, t) { return (t - e) / LO }), (function (e) { return e.getUTCSeconds() })); const xz = vz; vz.range; var wz = BO((function () { }), (function (e, t) { e.setTime(+e + t) }), (function (e, t) { return t - e })); wz.every = function (e) { return e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? BO((function (t) { t.setTime(Math.floor(t / e) * e) }), (function (t, n) { t.setTime(+t + n * e) }), (function (t, n) { return (n - t) / e })) : wz : null }; const kz = wz; wz.range; var Sz = BO((function (e) { e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCFullYear(e.getUTCFullYear() + t) }), (function (e, t) { return t.getUTCFullYear() - e.getUTCFullYear() }), (function (e) { return e.getUTCFullYear() })); Sz.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? BO((function (t) { t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0) }), (function (t, n) { t.setUTCFullYear(t.getUTCFullYear() + n * e) })) : null }; const _z = Sz; Sz.range; var Cz = BO((function (e) { e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCMonth(e.getUTCMonth() + t) }), (function (e, t) { return t.getUTCMonth() - e.getUTCMonth() + 12 * (t.getUTCFullYear() - e.getUTCFullYear()) }), (function (e) { return e.getUTCMonth() })); const Az = Cz; Cz.range; var Tz = BO((function (e) { e.setUTCMinutes(0, 0, 0) }), (function (e, t) { e.setTime(+e + t * UO) }), (function (e, t) { return (t - e) / UO }), (function (e) { return e.getUTCHours() })); const Ez = Tz; Tz.range; var Nz = BO((function (e) { e.setUTCSeconds(0, 0) }), (function (e, t) { e.setTime(+e + t * jO) }), (function (e, t) { return (t - e) / jO }), (function (e) { return e.getUTCMinutes() })); const Iz = Nz; Nz.range; const Mz = "year", Fz = "quarter", Dz = "month", $z = "week", Rz = "date", Oz = "day", zz = "dayofyear", Pz = "hours", Bz = "minutes", Lz = "seconds", jz = "milliseconds", Uz = [Mz, Fz, Dz, $z, Rz, Oz, zz, Pz, Bz, Lz, jz], Wz = Uz.reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); function Vz(e) { const t = FO(e).slice(), n = {}; t.length || CO("Missing time unit."), t.forEach((e => { OO(Wz, e) ? n[e] = 1 : CO("Invalid time unit: ".concat(e, ".")) })); return (n[$z] || n[Oz] ? 1 : 0) + (n[Fz] || n[Dz] || n[Rz] ? 1 : 0) + (n[zz] ? 1 : 0) > 1 && CO("Incompatible time units: ".concat(e)), t.sort(((e, t) => Wz[e] - Wz[t])), t } const Gz = { [Mz]: "%Y ", [Fz]: "Q%q ", [Dz]: "%b ", [Rz]: "%d ", [$z]: "W%U ", [Oz]: "%a ", [zz]: "%j ", [Pz]: "%H:00", [Bz]: "00:%M", [Lz]: ":%S", [jz]: ".%L", ["".concat(Mz, "-").concat(Dz)]: "%Y-%m ", ["".concat(Mz, "-").concat(Dz, "-").concat(Rz)]: "%Y-%m-%d ", ["".concat(Pz, "-").concat(Bz)]: "%H:%M" }; function Hz(e, t) { const n = $O({}, Gz, t), r = Vz(e), i = r.length; let a, o, s = "", u = 0; for (u = 0; u < i;)for (a = r.length; a > u; --a)if (o = r.slice(u, a).join("-"), null != n[o]) { s += n[o], u = a; break } return s.trim() } const qz = new Date; function Yz(e) { return qz.setFullYear(e), qz.setMonth(0), qz.setDate(1), qz.setHours(0, 0, 0, 0), qz } function Xz(e) { return Zz(new Date(e)) } function Kz(e) { return Jz(new Date(e)) } function Zz(e) { return HO.count(Yz(e.getFullYear()) - 1, e) } function Jz(e) { return YO.count(Yz(e.getFullYear()) - 1, e) } function Qz(e) { return Yz(e).getDay() } function eP(e, t, n, r, i, a, o) { if (0 <= e && e < 100) { const s = new Date(-1, t, n, r, i, a, o); return s.setFullYear(e), s } return new Date(e, t, n, r, i, a, o) } function tP(e) { return rP(new Date(e)) } function nP(e) { return iP(new Date(e)) } function rP(e) { const t = Date.UTC(e.getUTCFullYear(), 0, 1); return nz.count(t - 1, e) } function iP(e) { const t = Date.UTC(e.getUTCFullYear(), 0, 1); return iz.count(t - 1, e) } function aP(e) { return qz.setTime(Date.UTC(e, 0, 1)), qz.getUTCDay() } function oP(e, t, n, r, i, a, o) { if (0 <= e && e < 100) { const e = new Date(Date.UTC(-1, t, n, r, i, a, o)); return e.setUTCFullYear(n.y), e } return new Date(Date.UTC(e, t, n, r, i, a, o)) } function sP(e, t, n, r, i) { const a = t || 1, o = MO(e), s = (e, t, i) => function (e, t, n, r) { const i = n <= 1 ? e : r ? (t, i) => r + n * Math.floor((e(t, i) - r) / n) : (t, r) => n * Math.floor(e(t, r) / n); return t ? (e, n) => t(i(e, n), n) : i }(n[i = i || e], r[i], e === o && a, t), u = new Date, l = function (e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t }(e), c = l[Mz] ? s(Mz) : function (e) { return DO(e) ? e : () => e }(2012), h = l[Dz] ? s(Dz) : l[Fz] ? s(Fz) : EO, d = l[$z] && l[Oz] ? s(Oz, 1, $z + Oz) : l[$z] ? s($z, 1) : l[Oz] ? s(Oz, 1) : l[Rz] ? s(Rz, 1) : l[zz] ? s(zz, 1) : NO, f = l[Pz] ? s(Pz) : EO, p = l[Bz] ? s(Bz) : EO, m = l[Lz] ? s(Lz) : EO, g = l[jz] ? s(jz) : EO; return function (e) { u.setTime(+e); const t = c(u); return i(t, h(u), d(u, t), f(u), p(u), m(u), g(u)) } } function uP(e, t, n) { return t + 7 * e - (n + 6) % 7 } const lP = { [Mz]: e => e.getFullYear(), [Fz]: e => Math.floor(e.getMonth() / 3), [Dz]: e => e.getMonth(), [Rz]: e => e.getDate(), [Pz]: e => e.getHours(), [Bz]: e => e.getMinutes(), [Lz]: e => e.getSeconds(), [jz]: e => e.getMilliseconds(), [zz]: e => Zz(e), [$z]: e => Jz(e), [$z + Oz]: (e, t) => uP(Jz(e), e.getDay(), Qz(t)), [Oz]: (e, t) => uP(1, e.getDay(), Qz(t)) }, cP = { [Fz]: e => 3 * e, [$z]: (e, t) => uP(e, 0, Qz(t)) }; function hP(e, t) { return sP(e, t || 1, lP, cP, eP) } const dP = { [Mz]: e => e.getUTCFullYear(), [Fz]: e => Math.floor(e.getUTCMonth() / 3), [Dz]: e => e.getUTCMonth(), [Rz]: e => e.getUTCDate(), [Pz]: e => e.getUTCHours(), [Bz]: e => e.getUTCMinutes(), [Lz]: e => e.getUTCSeconds(), [jz]: e => e.getUTCMilliseconds(), [zz]: e => rP(e), [$z]: e => iP(e), [Oz]: (e, t) => uP(1, e.getUTCDay(), aP(t)), [$z + Oz]: (e, t) => uP(iP(e), e.getUTCDay(), aP(t)) }, fP = { [Fz]: e => 3 * e, [$z]: (e, t) => uP(e, 0, aP(t)) }; function pP(e, t) { return sP(e, t || 1, dP, fP, oP) } const mP = { [Mz]: dz, [Fz]: pz.every(3), [Dz]: pz, [$z]: YO, [Rz]: HO, [Oz]: HO, [zz]: HO, [Pz]: gz, [Bz]: bz, [Lz]: xz, [jz]: kz }, gP = { [Mz]: _z, [Fz]: Az.every(3), [Dz]: Az, [$z]: iz, [Rz]: nz, [Oz]: nz, [zz]: nz, [Pz]: Ez, [Bz]: Iz, [Lz]: xz, [jz]: kz }; function yP(e) { return mP[e] } function bP(e) { return gP[e] } function vP(e, t, n) { return e ? e.offset(t, n) : void 0 } function xP(e, t, n) { return vP(yP(e), t, n) } function wP(e, t, n) { return vP(bP(e), t, n) } function kP(e, t, n, r) { return e ? e.range(t, n, r) : void 0 } function SP(e, t, n, r) { return kP(yP(e), t, n, r) } function _P(e, t, n, r) { return kP(bP(e), t, n, r) } const CP = 1e3, AP = 6e4, TP = 36e5, EP = 864e5, NP = 2592e6, IP = 31536e6, MP = [Mz, Dz, Rz, Pz, Bz, Lz, jz], FP = MP.slice(0, -1), DP = FP.slice(0, -1), $P = DP.slice(0, -1), RP = $P.slice(0, -1), OP = [Mz, Dz], zP = [Mz], PP = [[FP, 1, CP], [FP, 5, 5e3], [FP, 15, 15e3], [FP, 30, 3e4], [DP, 1, AP], [DP, 5, 3e5], [DP, 15, 9e5], [DP, 30, 18e5], [$P, 1, TP], [$P, 3, 108e5], [$P, 6, 216e5], [$P, 12, 432e5], [RP, 1, EP], [[Mz, $z], 1, 6048e5], [OP, 1, NP], [OP, 3, 7776e6], [zP, 1, IP]]; function BP(e) { const t = e.extent, n = e.maxbins || 40, r = Math.abs(function (e) { return e && MO(e) - e[0] || 0 }(t)) / n; let i, a, o = Dl((e => e[2])).right(PP, r); return o === PP.length ? (i = zP, a = _A(t[0] / IP, t[1] / IP, n)) : o ? (o = PP[r / PP[o - 1][2] < PP[o][2] / r ? o - 1 : o], i = o[0], a = o[1]) : (i = MP, a = Math.max(_A(t[0], t[1], n), 1)), { units: i, step: a } } function LP(e, t, n) { return e.fields = t || [], e.fname = n, e } function jP(e) { return 1 === e.length ? UP(e[0]) : WP(e) } const UP = e => function (t) { return t[e] }, WP = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function VP(e) { throw Error(e) } function GP(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || VP("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && VP("Access path missing closing bracket: " + e), o && VP("Access path missing closing quote: " + e), i > r && (i++, l()), t } function HP(e, t, n) { const r = GP(e); return e = 1 === r.length ? r[0] : e, LP((n && n.get || jP)(r), [e], t || e) } HP("id"); const qP = LP((e => e), [], "identity"); LP((() => 0), [], "zero"), LP((() => 1), [], "one"), LP((() => !0), [], "true"), LP((() => !1), [], "false"); var YP = Array.isArray; function XP(e) { return e === Object(e) } function KP(e) { return null == e || "" === e ? null : +e } function ZP(e) { return "function" == typeof e } function JP(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } const QP = Object.prototype.hasOwnProperty; function eB(e, t) { return QP.call(e, t) } function tB(e) { return "string" == typeof e } function nB(e) { return YP(e) ? "[" + e.map(nB) + "]" : XP(e) || tB(e) ? JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029") : e } const rB = e => function (e) { return "number" == typeof e }(e) || function (e) { return "[object Date]" === Object.prototype.toString.call(e) }(e) ? e : Date.parse(e); var iB = {}, aB = {}; function oB(e) { return new Function("d", "return {" + e.map((function (e, t) { return JSON.stringify(e) + ": d[" + t + '] || ""' })).join(",") + "}") } function sB(e) { var t = Object.create(null), n = []; return e.forEach((function (e) { for (var r in e) r in t || n.push(t[r] = r) })), n } function uB(e, t) { var n = e + "", r = n.length; return r < t ? new Array(t - r + 1).join(0) + n : n } function lB(e) { var t = e.getUTCHours(), n = e.getUTCMinutes(), r = e.getUTCSeconds(), i = e.getUTCMilliseconds(); return isNaN(e) ? "Invalid Date" : function (e) { return e < 0 ? "-" + uB(-e, 6) : e > 9999 ? "+" + uB(e, 6) : uB(e, 4) }(e.getUTCFullYear()) + "-" + uB(e.getUTCMonth() + 1, 2) + "-" + uB(e.getUTCDate(), 2) + (i ? "T" + uB(t, 2) + ":" + uB(n, 2) + ":" + uB(r, 2) + "." + uB(i, 3) + "Z" : r ? "T" + uB(t, 2) + ":" + uB(n, 2) + ":" + uB(r, 2) + "Z" : n || t ? "T" + uB(t, 2) + ":" + uB(n, 2) + "Z" : "") } function cB(e) { var t = new RegExp('["' + e + "\n\r]"), n = e.charCodeAt(0); function r(e, t) { var r, i = [], a = e.length, o = 0, s = 0, u = a <= 0, l = !1; function c() { if (u) return aB; if (l) return l = !1, iB; var t, r, i = o; if (34 === e.charCodeAt(i)) { for (; o++ < a && 34 !== e.charCodeAt(o) || 34 === e.charCodeAt(++o);); return (t = o) >= a ? u = !0 : 10 === (r = e.charCodeAt(o++)) ? l = !0 : 13 === r && (l = !0, 10 === e.charCodeAt(o) && ++o), e.slice(i + 1, t - 1).replace(/""/g, '"') } for (; o < a;) { if (10 === (r = e.charCodeAt(t = o++))) l = !0; else if (13 === r) l = !0, 10 === e.charCodeAt(o) && ++o; else if (r !== n) continue; return e.slice(i, t) } return u = !0, e.slice(i, a) } for (10 === e.charCodeAt(a - 1) && --a, 13 === e.charCodeAt(a - 1) && --a; (r = c()) !== aB;) { for (var h = []; r !== iB && r !== aB;)h.push(r), r = c(); t && null == (h = t(h, s++)) || i.push(h) } return i } function i(t, n) { return t.map((function (t) { return n.map((function (e) { return o(t[e]) })).join(e) })) } function a(t) { return t.map(o).join(e) } function o(e) { return null == e ? "" : e instanceof Date ? lB(e) : t.test(e += "") ? '"' + e.replace(/"/g, '""') + '"' : e } return { parse: function (e, t) { var n, i, a = r(e, (function (e, r) { if (n) return n(e, r - 1); i = e, n = t ? function (e, t) { var n = oB(e); return function (r, i) { return t(n(r), i, e) } }(e, t) : oB(e) })); return a.columns = i || [], a }, parseRows: r, format: function (t, n) { return null == n && (n = sB(t)), [n.map(o).join(e)].concat(i(t, n)).join("\n") }, formatBody: function (e, t) { return null == t && (t = sB(e)), i(e, t).join("\n") }, formatRows: function (e) { return e.map(a).join("\n") }, formatRow: a, formatValue: o } } const hB = Math.sqrt(50), dB = Math.sqrt(10), fB = Math.sqrt(2); function pB(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= hB ? 10 : a >= dB ? 5 : a >= fB ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? pB(e, t, 2 * n) : [s, u, l] } function mB(e, t, n) { return pB(e = +e, t = +t, n = +n)[2] } const gB = "year", yB = "quarter", bB = "month", vB = "week", xB = "date", wB = "day", kB = "dayofyear", SB = "hours", _B = "minutes", CB = "seconds", AB = "milliseconds";[gB, yB, bB, vB, xB, wB, kB, SB, _B, CB, AB].reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); new Date; const TB = { [gB]: fi, [yB]: mi.every(3), [bB]: mi, [vB]: Jr, [xB]: Yr, [wB]: Yr, [kB]: Yr, [SB]: yi, [_B]: vi, [CB]: wi, [AB]: ki }, EB = { [gB]: pi, [yB]: gi.every(3), [bB]: gi, [vB]: oi, [xB]: Xr, [wB]: Xr, [kB]: Xr, [SB]: bi, [_B]: xi, [CB]: wi, [AB]: ki }; function NB(e) { return TB[e] } function IB(e) { return EB[e] } const MB = [gB, bB, xB, SB, _B, CB, AB], FB = MB.slice(0, -1), DB = FB.slice(0, -1), $B = DB.slice(0, -1); $B.slice(0, -1); function RB(e) { const t = {}; return n => t[n] || (t[n] = e(n)) } function OB(e) { const t = RB(e.format), n = e.formatPrefix; return { format: t, formatPrefix: n, formatFloat(e) { const n = kr(e || ","); if (null == n.precision) { switch (n.precision = 12, n.type) { case "%": n.precision -= 2; break; case "e": n.precision -= 1 }return function (e, t) { return n => { const r = e(n), i = r.indexOf(t); if (i < 0) return r; let a = function (e, t) { let n, r = e.lastIndexOf("e"); if (r > 0) return r; for (r = e.length; --r > t;)if (n = e.charCodeAt(r), n >= 48 && n <= 57) return r + 1 }(r, i); const o = a < r.length ? r.slice(a) : ""; for (; --a > i;)if ("0" !== r[a]) { ++a; break } return r.slice(0, a) + o } }(t(n), t(".1f")(1)[1]) } return t(n) }, formatSpan(e, r, i, a) { a = kr(null == a ? ",f" : a); const o = function (e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? mB(t, e, n) : mB(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) }(e, r, i), s = Math.max(Math.abs(e), Math.abs(r)); let u; if (null == a.precision) switch (a.type) { case "s": return isNaN(u = Ar(o, s)) || (a.precision = u), n(a, s); case "": case "e": case "g": case "p": case "r": isNaN(u = Tr(o, s)) || (a.precision = u - ("e" === a.type)); break; case "f": case "%": isNaN(u = Er(o)) || (a.precision = u - 2 * ("%" === a.type)) }return t(a) } } } let zB, PB; function BB() { return zB = OB({ format: Dr, formatPrefix: $r }) } function LB(e, t, n) { XP(n = n || {}) || VP(`Invalid time multi-format specifier: ${n}`); const r = t(CB), i = t(_B), a = t(SB), o = t(xB), s = t(vB), u = t(bB), l = t(yB), c = t(gB), h = e(n[AB] || ".%L"), d = e(n[CB] || ":%S"), f = e(n[_B] || "%I:%M"), p = e(n[SB] || "%I %p"), m = e(n[xB] || n[wB] || "%a %d"), g = e(n[vB] || "%b %d"), y = e(n[bB] || "%B"), b = e(n[yB] || "%B"), v = e(n[gB] || "%Y"); return e => (r(e) < e ? h : i(e) < e ? d : a(e) < e ? f : o(e) < e ? p : u(e) < e ? s(e) < e ? m : g : c(e) < e ? l(e) < e ? y : b : v)(e) } function jB(e) { const t = RB(e.format), n = RB(e.utcFormat); return { timeFormat: e => tB(e) ? t(e) : LB(t, NB, e), utcFormat: e => tB(e) ? n(e) : LB(n, IB, e), timeParse: RB(e.parse), utcParse: RB(e.utcParse) } } function UB() { return PB = jB({ format: za, parse: Pa, utcFormat: Ba, utcParse: La }) } function WB(e) { return jB(Ra(e)) } function VB(e) { return arguments.length ? PB = WB(e) : PB } BB(), UB(); const GB = /^(data:|([A-Za-z]+:)?\/\/)/, HB = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i, qB = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g, YB = "file://"; async function XB(e, t) { const n = await this.sanitize(e, t), r = n.href; return n.localFile ? this.file(r) : this.http(r, t) } async function KB(e, t) { t = JP({}, this.options, t); const n = this.fileAccess, r = { href: null }; let i, a, o; const s = HB.test(e.replace(qB, "")); null != e && "string" == typeof e && s || VP("Sanitize failure, invalid URI: " + nB(e)); const u = GB.test(e); return (o = t.baseURL) && !u && (e.startsWith("/") || o.endsWith("/") || (e = "/" + e), e = o + e), a = (i = e.startsWith(YB)) || "file" === t.mode || "http" !== t.mode && !u && n, i ? e = e.slice(7) : e.startsWith("//") && ("file" === t.defaultProtocol ? (e = e.slice(2), a = !0) : e = (t.defaultProtocol || "http") + ":" + e), Object.defineProperty(r, "localFile", { value: !!a }), r.href = e, t.target && (r.target = t.target + ""), t.rel && (r.rel = t.rel + ""), "image" === t.context && t.crossOrigin && (r.crossOrigin = t.crossOrigin + ""), r } function ZB(e) { return e ? t => new Promise(((n, r) => { e.readFile(t, ((e, t) => { e ? r(e) : n(t) })) })) : JB } async function JB() { VP("No file system access.") } function QB(e) { return e ? async function (t, n) { const r = JP({}, this.options.http, n), i = n && n.response, a = await e(t, r); return a.ok ? ZP(a[i]) ? a[i]() : a.text() : VP(a.status + "" + a.statusText) } : eL } async function eL() { VP("No HTTP fetch method available.") } const tL = e => null != e && e == e, nL = e => !(Number.isNaN(+e) || e instanceof Date), rL = { boolean: function (e) { return null == e || "" === e ? null : !(!e || "false" === e || "0" === e) && !!e }, integer: KP, number: KP, date: function (e, t) { return t = t || rB, null == e || "" === e ? null : t(e) }, string: function (e) { return null == e || "" === e ? null : e + "" }, unknown: qP }, iL = [e => "true" === e || "false" === e || !0 === e || !1 === e, e => nL(e) && Number.isInteger(+e), nL, e => !Number.isNaN(Date.parse(e))], aL = ["boolean", "integer", "number", "date"]; function oL(e, t) { if (!e || !e.length) return "unknown"; const n = e.length, r = iL.length, i = iL.map(((e, t) => t + 1)); for (let a, o, s = 0, u = 0; s < n; ++s)for (o = t ? e[s][t] : e[s], a = 0; a < r; ++a)if (i[a] && tL(o) && !iL[a](o) && (i[a] = 0, ++u, u === iL.length)) return "string"; return aL[i.reduce(((e, t) => 0 === e ? t : e), 0) - 1] } function sL(e, t) { return t.reduce(((t, n) => (t[n] = oL(e, n), t)), {}) } function uL(e) { const t = function (t, n) { const r = { delimiter: e }; return lL(t, n ? JP(n, r) : r) }; return t.responseType = "text", t } function lL(e, t) { return t.header && (e = t.header.map(nB).join(t.delimiter) + "\n" + e), cB(t.delimiter).parse(e + "") } function cL(e, t) { const n = t && t.property ? HP(t.property) : qP; return !XP(e) || (r = e, "function" == typeof Buffer && ZP(Buffer.isBuffer) && Buffer.isBuffer(r)) ? n(JSON.parse(e)) : function (e, t) { !YP(e) && function (e) { return e && ZP(e[Symbol.iterator]) }(e) && (e = [...e]); return t && t.copy ? JSON.parse(JSON.stringify(e)) : e }(n(e), t); var r } lL.responseType = "text", cL.responseType = "json"; const hL = { interior: (e, t) => e !== t, exterior: (e, t) => e === t }; function dL(e, t) { let n, r, i, a; return e = cL(e, t), t && t.feature ? (n = lr, i = t.feature) : t && t.mesh ? (n = fr, i = t.mesh, a = hL[t.filter]) : VP("Missing TopoJSON feature or mesh parameter."), r = (r = e.objects[i]) ? n(e, r, a) : VP("Invalid TopoJSON object: " + i), r && r.features || [r] } dL.responseType = "json"; const fL = { dsv: lL, csv: uL(","), tsv: uL("\t"), json: cL, topojson: dL }; function pL(e, t) { return arguments.length > 1 ? (fL[e] = t, this) : eB(fL, e) ? fL[e] : null } function mL(e) { const t = pL(e); return t && t.responseType || "text" } function gL(e, t, n, r) { const i = pL((t = t || {}).type || "json"); return i || VP("Unknown data format type: " + t.type), e = i(e, t), t.parse && function (e, t, n, r) { if (!e.length) return; const i = VB(); n = n || i.timeParse, r = r || i.utcParse; let a, o, s, u, l, c, h = e.columns || Object.keys(e[0]); "auto" === t && (t = sL(e, h)); h = Object.keys(t); const d = h.map((e => { const i = t[e]; let a, o; if (i && (i.startsWith("date:") || i.startsWith("utc:"))) { a = i.split(/:(.+)?/, 2), o = a[1], ("'" === o[0] && "'" === o[o.length - 1] || '"' === o[0] && '"' === o[o.length - 1]) && (o = o.slice(1, -1)); return ("utc" === a[0] ? r : n)(o) } if (!rL[i]) throw Error("Illegal format pattern: " + e + ":" + i); return rL[i] })); for (s = 0, l = e.length, c = h.length; s < l; ++s)for (a = e[s], u = 0; u < c; ++u)o = h[u], a[o] = d[u](a[o]) }(e, t.parse, n, r), eB(e, "columns") && delete e.columns, e } const yL = function (e, t) { return n => ({ options: n || {}, sanitize: KB, load: XB, fileAccess: !!t, file: ZB(t), http: QB(e) }) }("undefined" != typeof fetch && fetch, null); function bL(e, t, n) { return e.fields = t || [], e.fname = n, e } function vL(e) { return 1 === e.length ? xL(e[0]) : wL(e) } const xL = e => function (t) { return t[e] }, wL = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function kL(e) { throw Error(e) } function SL(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || kL("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && kL("Access path missing closing bracket: " + e), o && kL("Access path missing closing quote: " + e), i > r && (i++, l()), t } function _L(e, t, n) { const r = SL(e); return e = 1 === r.length ? r[0] : e, bL((n && n.get || vL)(r), [e], t || e) } _L("id"); const CL = bL((e => e), [], "identity"), AL = (bL((() => 0), [], "zero"), bL((() => 1), [], "one"), bL((() => !0), [], "true")); bL((() => !1), [], "false"); var TL = Array.isArray; function EL(e) { return e === Object(e) } function NL(e) { return e[e.length - 1] } function IL(e) { return null == e || "" === e ? null : +e } function ML(e) { return null != e ? TL(e) ? e : [e] : [] } function FL(e) { return "function" == typeof e } function DL(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } const $L = Object.prototype.hasOwnProperty; function RL(e, t) { return $L.call(e, t) } function OL(e, t, n) { const r = e.prototype = Object.create(t.prototype); return Object.defineProperty(r, "constructor", { value: e, writable: !0, enumerable: !0, configurable: !0 }), DL(r, n) } function zL(e) { return "number" == typeof e } function PL(e) { return "string" == typeof e } function BL(e) { return TL(e) ? "[" + e.map(BL) + "]" : EL(e) || PL(e) ? JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029") : e } function LL(e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t } function jL(e, t, n) { e._context.bezierCurveTo((2 * e._x0 + e._x1) / 3, (2 * e._y0 + e._y1) / 3, (e._x0 + 2 * e._x1) / 3, (e._y0 + 2 * e._y1) / 3, (e._x0 + 4 * e._x1 + t) / 6, (e._y0 + 4 * e._y1 + n) / 6) } function UL(e) { this._context = e } function WL() { } function VL(e) { this._context = e } function GL(e) { this._context = e } function HL(e, t) { this._basis = new UL(e), this._beta = t } UL.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 3: jL(this, this._x1, this._y1); case 2: this._context.lineTo(this._x1, this._y1) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; break; case 2: this._point = 3, this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); default: jL(this, e, t) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t } }, VL.prototype = { areaStart: WL, areaEnd: WL, lineStart: function () { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 1: this._context.moveTo(this._x2, this._y2), this._context.closePath(); break; case 2: this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3), this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3), this._context.closePath(); break; case 3: this.point(this._x2, this._y2), this.point(this._x3, this._y3), this.point(this._x4, this._y4) } }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._x2 = e, this._y2 = t; break; case 1: this._point = 2, this._x3 = e, this._y3 = t; break; case 2: this._point = 3, this._x4 = e, this._y4 = t, this._context.moveTo((this._x0 + 4 * this._x1 + e) / 6, (this._y0 + 4 * this._y1 + t) / 6); break; default: jL(this, e, t) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t } }, GL.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 3 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3; var n = (this._x0 + 4 * this._x1 + e) / 6, r = (this._y0 + 4 * this._y1 + t) / 6; this._line ? this._context.lineTo(n, r) : this._context.moveTo(n, r); break; case 3: this._point = 4; default: jL(this, e, t) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t } }, HL.prototype = { lineStart: function () { this._x = [], this._y = [], this._basis.lineStart() }, lineEnd: function () { var e = this._x, t = this._y, n = e.length - 1; if (n > 0) for (var r, i = e[0], a = t[0], o = e[n] - i, s = t[n] - a, u = -1; ++u <= n;)r = u / n, this._basis.point(this._beta * e[u] + (1 - this._beta) * (i + r * o), this._beta * t[u] + (1 - this._beta) * (a + r * s)); this._x = this._y = null, this._basis.lineEnd() }, point: function (e, t) { this._x.push(+e), this._y.push(+t) } }; const qL = function e(t) { function n(e) { return 1 === t ? new UL(e) : new HL(e, t) } return n.beta = function (t) { return e(+t) }, n }(.85); function YL(e, t, n) { e._context.bezierCurveTo(e._x1 + e._k * (e._x2 - e._x0), e._y1 + e._k * (e._y2 - e._y0), e._x2 + e._k * (e._x1 - t), e._y2 + e._k * (e._y1 - n), e._x2, e._y2) } function XL(e, t) { this._context = e, this._k = (1 - t) / 6 } XL.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 2: this._context.lineTo(this._x2, this._y2); break; case 3: YL(this, this._x1, this._y1) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2, this._x1 = e, this._y1 = t; break; case 2: this._point = 3; default: YL(this, e, t) }this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const KL = function e(t) { function n(e) { return new XL(e, t) } return n.tension = function (t) { return e(+t) }, n }(0); function ZL(e, t) { this._context = e, this._k = (1 - t) / 6 } ZL.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 3 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; case 3: this._point = 4; default: YL(this, e, t) }this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const JL = function e(t) { function n(e) { return new ZL(e, t) } return n.tension = function (t) { return e(+t) }, n }(0); function QL(e, t) { this._context = e, this._k = (1 - t) / 6 } QL.prototype = { areaStart: WL, areaEnd: WL, lineStart: function () { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 1: this._context.moveTo(this._x3, this._y3), this._context.closePath(); break; case 2: this._context.lineTo(this._x3, this._y3), this._context.closePath(); break; case 3: this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5) } }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._x3 = e, this._y3 = t; break; case 1: this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t); break; case 2: this._point = 3, this._x5 = e, this._y5 = t; break; default: YL(this, e, t) }this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const ej = function e(t) { function n(e) { return new QL(e, t) } return n.tension = function (t) { return e(+t) }, n }(0); var tj = Math.abs, nj = Math.atan2, rj = Math.cos, ij = Math.max, aj = Math.min, oj = Math.sin, sj = Math.sqrt, uj = 1e-12, lj = Math.PI, cj = lj / 2, hj = 2 * lj; function dj(e) { return e >= 1 ? cj : e <= -1 ? -cj : Math.asin(e) } function fj(e, t, n) { var r = e._x1, i = e._y1, a = e._x2, o = e._y2; if (e._l01_a > uj) { var s = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, u = 3 * e._l01_a * (e._l01_a + e._l12_a); r = (r * s - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / u, i = (i * s - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / u } if (e._l23_a > uj) { var l = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, c = 3 * e._l23_a * (e._l23_a + e._l12_a); a = (a * l + e._x1 * e._l23_2a - t * e._l12_2a) / c, o = (o * l + e._y1 * e._l23_2a - n * e._l12_2a) / c } e._context.bezierCurveTo(r, i, a, o, e._x2, e._y2) } function pj(e, t) { this._context = e, this._alpha = t } pj.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0 }, lineEnd: function () { switch (this._point) { case 2: this._context.lineTo(this._x2, this._y2); break; case 3: this.point(this._x2, this._y2) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { if (e = +e, t = +t, this._point) { var n = this._x2 - e, r = this._y2 - t; this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, this._alpha)) } switch (this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; break; case 2: this._point = 3; default: fj(this, e, t) }this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const mj = function e(t) { function n(e) { return t ? new pj(e, t) : new XL(e, 0) } return n.alpha = function (t) { return e(+t) }, n }(.5); function gj(e, t) { this._context = e, this._alpha = t } gj.prototype = { areaStart: WL, areaEnd: WL, lineStart: function () { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0 }, lineEnd: function () { switch (this._point) { case 1: this._context.moveTo(this._x3, this._y3), this._context.closePath(); break; case 2: this._context.lineTo(this._x3, this._y3), this._context.closePath(); break; case 3: this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5) } }, point: function (e, t) { if (e = +e, t = +t, this._point) { var n = this._x2 - e, r = this._y2 - t; this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, this._alpha)) } switch (this._point) { case 0: this._point = 1, this._x3 = e, this._y3 = t; break; case 1: this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t); break; case 2: this._point = 3, this._x5 = e, this._y5 = t; break; default: fj(this, e, t) }this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const yj = function e(t) { function n(e) { return t ? new gj(e, t) : new QL(e, 0) } return n.alpha = function (t) { return e(+t) }, n }(.5); function bj(e, t) { this._context = e, this._alpha = t } bj.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 3 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { if (e = +e, t = +t, this._point) { var n = this._x2 - e, r = this._y2 - t; this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, this._alpha)) } switch (this._point) { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; case 3: this._point = 4; default: fj(this, e, t) }this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t } }; const vj = function e(t) { function n(e) { return t ? new bj(e, t) : new ZL(e, 0) } return n.alpha = function (t) { return e(+t) }, n }(.5); function xj(e) { this._context = e } function wj(e) { return new xj(e) } function kj(e) { this._context = e } function Sj(e) { return e < 0 ? -1 : 1 } function _j(e, t, n) { var r = e._x1 - e._x0, i = t - e._x1, a = (e._y1 - e._y0) / (r || i < 0 && -0), o = (n - e._y1) / (i || r < 0 && -0), s = (a * i + o * r) / (r + i); return (Sj(a) + Sj(o)) * Math.min(Math.abs(a), Math.abs(o), .5 * Math.abs(s)) || 0 } function Cj(e, t) { var n = e._x1 - e._x0; return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t } function Aj(e, t, n) { var r = e._x0, i = e._y0, a = e._x1, o = e._y1, s = (a - r) / 3; e._context.bezierCurveTo(r + s, i + s * t, a - s, o - s * n, a, o) } function Tj(e) { this._context = e } function Ej(e) { this._context = new Nj(e) } function Nj(e) { this._context = e } function Ij(e) { this._context = e } function Mj(e) { var t, n, r = e.length - 1, i = new Array(r), a = new Array(r), o = new Array(r); for (i[0] = 0, a[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < r - 1; ++t)i[t] = 1, a[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1]; for (i[r - 1] = 2, a[r - 1] = 7, o[r - 1] = 8 * e[r - 1] + e[r], t = 1; t < r; ++t)n = i[t] / a[t - 1], a[t] -= n, o[t] -= n * o[t - 1]; for (i[r - 1] = o[r - 1] / a[r - 1], t = r - 2; t >= 0; --t)i[t] = (o[t] - i[t + 1]) / a[t]; for (a[r - 1] = (e[r] + i[r - 1]) / 2, t = 0; t < r - 1; ++t)a[t] = 2 * e[t + 1] - i[t + 1]; return [i, a] } function Fj(e, t) { this._context = e, this._t = t } xj.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._point = 0 }, lineEnd: function () { (this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; default: this._context.lineTo(e, t) } } }, kj.prototype = { areaStart: WL, areaEnd: WL, lineStart: function () { this._point = 0 }, lineEnd: function () { this._point && this._context.closePath() }, point: function (e, t) { e = +e, t = +t, this._point ? this._context.lineTo(e, t) : (this._point = 1, this._context.moveTo(e, t)) } }, Tj.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0 }, lineEnd: function () { switch (this._point) { case 2: this._context.lineTo(this._x1, this._y1); break; case 3: Aj(this, this._t0, Cj(this, this._t0)) }(this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line = 1 - this._line }, point: function (e, t) { var n = NaN; if (t = +t, (e = +e) !== this._x1 || t !== this._y1) { switch (this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; break; case 2: this._point = 3, Aj(this, Cj(this, n = _j(this, e, t)), n); break; default: Aj(this, this._t0, n = _j(this, e, t)) }this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n } } }, (Ej.prototype = Object.create(Tj.prototype)).point = function (e, t) { Tj.prototype.point.call(this, t, e) }, Nj.prototype = { moveTo: function (e, t) { this._context.moveTo(t, e) }, closePath: function () { this._context.closePath() }, lineTo: function (e, t) { this._context.lineTo(t, e) }, bezierCurveTo: function (e, t, n, r, i, a) { this._context.bezierCurveTo(t, e, r, n, a, i) } }, Ij.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x = [], this._y = [] }, lineEnd: function () { var e = this._x, t = this._y, n = e.length; if (n) if (this._line ? this._context.lineTo(e[0], t[0]) : this._context.moveTo(e[0], t[0]), 2 === n) this._context.lineTo(e[1], t[1]); else for (var r = Mj(e), i = Mj(t), a = 0, o = 1; o < n; ++a, ++o)this._context.bezierCurveTo(r[0][a], i[0][a], r[1][a], i[1][a], e[o], t[o]); (this._line || 0 !== this._line && 1 === n) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null }, point: function (e, t) { this._x.push(+e), this._y.push(+t) } }, Fj.prototype = { areaStart: function () { this._line = 0 }, areaEnd: function () { this._line = NaN }, lineStart: function () { this._x = this._y = NaN, this._point = 0 }, lineEnd: function () { 0 < this._t && this._t < 1 && 2 === this._point && this._context.lineTo(this._x, this._y), (this._line || 0 !== this._line && 1 === this._point) && this._context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line) }, point: function (e, t) { switch (e = +e, t = +t, this._point) { case 0: this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t); break; case 1: this._point = 2; default: if (this._t <= 0) this._context.lineTo(this._x, t), this._context.lineTo(e, t); else { var n = this._x * (1 - this._t) + e * this._t; this._context.lineTo(n, this._y), this._context.lineTo(n, t) } }this._x = e, this._y = t } }; const Dj = Math.PI, $j = 2 * Dj, Rj = 1e-6, Oj = $j - Rj; function zj() { this._x0 = this._y0 = this._x1 = this._y1 = null, this._ = "" } function Pj() { return new zj } zj.prototype = Pj.prototype = { constructor: zj, moveTo: function (e, t) { this._ += "M" + (this._x0 = this._x1 = +e) + "," + (this._y0 = this._y1 = +t) }, closePath: function () { null !== this._x1 && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z") }, lineTo: function (e, t) { this._ += "L" + (this._x1 = +e) + "," + (this._y1 = +t) }, quadraticCurveTo: function (e, t, n, r) { this._ += "Q" + +e + "," + +t + "," + (this._x1 = +n) + "," + (this._y1 = +r) }, bezierCurveTo: function (e, t, n, r, i, a) { this._ += "C" + +e + "," + +t + "," + +n + "," + +r + "," + (this._x1 = +i) + "," + (this._y1 = +a) }, arcTo: function (e, t, n, r, i) { e = +e, t = +t, n = +n, r = +r, i = +i; var a = this._x1, o = this._y1, s = n - e, u = r - t, l = a - e, c = o - t, h = l * l + c * c; if (i < 0) throw new Error("negative radius: " + i); if (null === this._x1) this._ += "M" + (this._x1 = e) + "," + (this._y1 = t); else if (h > Rj) if (Math.abs(c * s - u * l) > Rj && i) { var d = n - a, f = r - o, p = s * s + u * u, m = d * d + f * f, g = Math.sqrt(p), y = Math.sqrt(h), b = i * Math.tan((Dj - Math.acos((p + h - m) / (2 * g * y))) / 2), v = b / y, x = b / g; Math.abs(v - 1) > Rj && (this._ += "L" + (e + v * l) + "," + (t + v * c)), this._ += "A" + i + "," + i + ",0,0," + +(c * d > l * f) + "," + (this._x1 = e + x * s) + "," + (this._y1 = t + x * u) } else this._ += "L" + (this._x1 = e) + "," + (this._y1 = t); else; }, arc: function (e, t, n, r, i, a) { e = +e, t = +t, a = !!a; var o = (n = +n) * Math.cos(r), s = n * Math.sin(r), u = e + o, l = t + s, c = 1 ^ a, h = a ? r - i : i - r; if (n < 0) throw new Error("negative radius: " + n); null === this._x1 ? this._ += "M" + u + "," + l : (Math.abs(this._x1 - u) > Rj || Math.abs(this._y1 - l) > Rj) && (this._ += "L" + u + "," + l), n && (h < 0 && (h = h % $j + $j), h > Oj ? this._ += "A" + n + "," + n + ",0,1," + c + "," + (e - o) + "," + (t - s) + "A" + n + "," + n + ",0,1," + c + "," + (this._x1 = u) + "," + (this._y1 = l) : h > Rj && (this._ += "A" + n + "," + n + ",0," + +(h >= Dj) + "," + c + "," + (this._x1 = e + n * Math.cos(i)) + "," + (this._y1 = t + n * Math.sin(i)))) }, rect: function (e, t, n, r) { this._ += "M" + (this._x0 = this._x1 = +e) + "," + (this._y0 = this._y1 = +t) + "h" + +n + "v" + +r + "h" + -n + "Z" }, toString: function () { return this._ } }; const Bj = Pj; function Lj(e) { return function () { return e } } function jj(e) { return e.innerRadius } function Uj(e) { return e.outerRadius } function Wj(e) { return e.startAngle } function Vj(e) { return e.endAngle } function Gj(e) { return e && e.padAngle } function Hj(e, t, n, r, i, a, o) { var s = e - n, u = t - r, l = (o ? a : -a) / sj(s * s + u * u), c = l * u, h = -l * s, d = e + c, f = t + h, p = n + c, m = r + h, g = (d + p) / 2, y = (f + m) / 2, b = p - d, v = m - f, x = b * b + v * v, w = i - a, k = d * m - p * f, S = (v < 0 ? -1 : 1) * sj(ij(0, w * w * x - k * k)), _ = (k * v - b * S) / x, C = (-k * b - v * S) / x, A = (k * v + b * S) / x, T = (-k * b + v * S) / x, E = _ - g, N = C - y, I = A - g, M = T - y; return E * E + N * N > I * I + M * M && (_ = A, C = T), { cx: _, cy: C, x01: -c, y01: -h, x11: _ * (i / w - 1), y11: C * (i / w - 1) } } Array.prototype.slice; function qj(e) { return "object" == typeof e && "length" in e ? e : Array.from(e) } function Yj(e) { return e[0] } function Xj(e) { return e[1] } function Kj(e, t) { var n = Lj(!0), r = null, i = wj, a = null; function o(o) { var s, u, l, c = (o = qj(o)).length, h = !1; for (null == r && (a = i(l = Bj())), s = 0; s <= c; ++s)!(s < c && n(u = o[s], s, o)) === h && ((h = !h) ? a.lineStart() : a.lineEnd()), h && a.point(+e(u, s, o), +t(u, s, o)); if (l) return a = null, l + "" || null } return e = "function" == typeof e ? e : void 0 === e ? Yj : Lj(e), t = "function" == typeof t ? t : void 0 === t ? Xj : Lj(t), o.x = function (t) { return arguments.length ? (e = "function" == typeof t ? t : Lj(+t), o) : e }, o.y = function (e) { return arguments.length ? (t = "function" == typeof e ? e : Lj(+e), o) : t }, o.defined = function (e) { return arguments.length ? (n = "function" == typeof e ? e : Lj(!!e), o) : n }, o.curve = function (e) { return arguments.length ? (i = e, null != r && (a = i(r)), o) : i }, o.context = function (e) { return arguments.length ? (null == e ? r = a = null : a = i(r = e), o) : r }, o } function Zj(e, t, n) { var r = null, i = Lj(!0), a = null, o = wj, s = null; function u(u) { var l, c, h, d, f, p = (u = qj(u)).length, m = !1, g = new Array(p), y = new Array(p); for (null == a && (s = o(f = Bj())), l = 0; l <= p; ++l) { if (!(l < p && i(d = u[l], l, u)) === m) if (m = !m) c = l, s.areaStart(), s.lineStart(); else { for (s.lineEnd(), s.lineStart(), h = l - 1; h >= c; --h)s.point(g[h], y[h]); s.lineEnd(), s.areaEnd() } m && (g[l] = +e(d, l, u), y[l] = +t(d, l, u), s.point(r ? +r(d, l, u) : g[l], n ? +n(d, l, u) : y[l])) } if (f) return s = null, f + "" || null } function l() { return Kj().defined(i).curve(o).context(a) } return e = "function" == typeof e ? e : void 0 === e ? Yj : Lj(+e), t = "function" == typeof t ? t : Lj(void 0 === t ? 0 : +t), n = "function" == typeof n ? n : void 0 === n ? Xj : Lj(+n), u.x = function (t) { return arguments.length ? (e = "function" == typeof t ? t : Lj(+t), r = null, u) : e }, u.x0 = function (t) { return arguments.length ? (e = "function" == typeof t ? t : Lj(+t), u) : e }, u.x1 = function (e) { return arguments.length ? (r = null == e ? null : "function" == typeof e ? e : Lj(+e), u) : r }, u.y = function (e) { return arguments.length ? (t = "function" == typeof e ? e : Lj(+e), n = null, u) : t }, u.y0 = function (e) { return arguments.length ? (t = "function" == typeof e ? e : Lj(+e), u) : t }, u.y1 = function (e) { return arguments.length ? (n = null == e ? null : "function" == typeof e ? e : Lj(+e), u) : n }, u.lineX0 = u.lineY0 = function () { return l().x(e).y(t) }, u.lineY1 = function () { return l().x(e).y(n) }, u.lineX1 = function () { return l().x(r).y(t) }, u.defined = function (e) { return arguments.length ? (i = "function" == typeof e ? e : Lj(!!e), u) : i }, u.curve = function (e) { return arguments.length ? (o = e, null != a && (s = o(a)), u) : o }, u.context = function (e) { return arguments.length ? (null == e ? a = s = null : s = o(a = e), u) : a }, u } const Jj = { draw: function (e, t) { var n = Math.sqrt(t / lj); e.moveTo(n, 0), e.arc(0, 0, n, 0, hj) } }; Math.sqrt(1 / 3); var Qj = Math.sin(lj / 10) / Math.sin(7 * lj / 10); Math.sin(hj / 10), Math.cos(hj / 10); Math.sqrt(3); Math.sqrt(3), Math.sqrt(12); const eU = Math.sqrt(50), tU = Math.sqrt(10), nU = Math.sqrt(2); function rU(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= eU ? 10 : a >= tU ? 5 : a >= nU ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? rU(e, t, 2 * n) : [s, u, l] } function iU(e, t, n) { return rU(e = +e, t = +t, n = +n)[2] } const aU = "year", oU = "quarter", sU = "month", uU = "week", lU = "date", cU = "day", hU = "dayofyear", dU = "hours", fU = "minutes", pU = "seconds", mU = "milliseconds";[aU, oU, sU, uU, lU, cU, hU, dU, fU, pU, mU].reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); new Date; const gU = { [aU]: fi, [oU]: mi.every(3), [sU]: mi, [uU]: Jr, [lU]: Yr, [cU]: Yr, [hU]: Yr, [dU]: yi, [fU]: vi, [pU]: wi, [mU]: ki }, yU = { [aU]: pi, [oU]: gi.every(3), [sU]: gi, [uU]: oi, [lU]: Xr, [cU]: Xr, [hU]: Xr, [dU]: bi, [fU]: xi, [pU]: wi, [mU]: ki }; function bU(e) { return gU[e] } function vU(e) { return yU[e] } const xU = [aU, sU, lU, dU, fU, pU, mU], wU = xU.slice(0, -1), kU = wU.slice(0, -1), SU = kU.slice(0, -1); SU.slice(0, -1); function _U(e) { const t = {}; return n => t[n] || (t[n] = e(n)) } function CU(e) { const t = _U(e.format), n = e.formatPrefix; return { format: t, formatPrefix: n, formatFloat(e) { const n = kr(e || ","); if (null == n.precision) { switch (n.precision = 12, n.type) { case "%": n.precision -= 2; break; case "e": n.precision -= 1 }return function (e, t) { return n => { const r = e(n), i = r.indexOf(t); if (i < 0) return r; let a = function (e, t) { let n, r = e.lastIndexOf("e"); if (r > 0) return r; for (r = e.length; --r > t;)if (n = e.charCodeAt(r), n >= 48 && n <= 57) return r + 1 }(r, i); const o = a < r.length ? r.slice(a) : ""; for (; --a > i;)if ("0" !== r[a]) { ++a; break } return r.slice(0, a) + o } }(t(n), t(".1f")(1)[1]) } return t(n) }, formatSpan(e, r, i, a) { a = kr(null == a ? ",f" : a); const o = function (e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? iU(t, e, n) : iU(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) }(e, r, i), s = Math.max(Math.abs(e), Math.abs(r)); let u; if (null == a.precision) switch (a.type) { case "s": return isNaN(u = Ar(o, s)) || (a.precision = u), n(a, s); case "": case "e": case "g": case "p": case "r": isNaN(u = Tr(o, s)) || (a.precision = u - ("e" === a.type)); break; case "f": case "%": isNaN(u = Er(o)) || (a.precision = u - 2 * ("%" === a.type)) }return t(a) } } } let AU, TU; function EU() { return AU = CU({ format: Dr, formatPrefix: $r }) } function NU(e, t, n) { EL(n = n || {}) || kL(`Invalid time multi-format specifier: ${n}`); const r = t(pU), i = t(fU), a = t(dU), o = t(lU), s = t(uU), u = t(sU), l = t(oU), c = t(aU), h = e(n[mU] || ".%L"), d = e(n[pU] || ":%S"), f = e(n[fU] || "%I:%M"), p = e(n[dU] || "%I %p"), m = e(n[lU] || n[cU] || "%a %d"), g = e(n[uU] || "%b %d"), y = e(n[sU] || "%B"), b = e(n[oU] || "%B"), v = e(n[aU] || "%Y"); return e => (r(e) < e ? h : i(e) < e ? d : a(e) < e ? f : o(e) < e ? p : u(e) < e ? s(e) < e ? m : g : c(e) < e ? l(e) < e ? y : b : v)(e) } function IU(e) { const t = _U(e.format), n = _U(e.utcFormat); return { timeFormat: e => PL(e) ? t(e) : NU(t, bU, e), utcFormat: e => PL(e) ? n(e) : NU(n, vU, e), timeParse: _U(e.parse), utcParse: _U(e.utcParse) } } function MU() { return TU = IU({ format: za, parse: Pa, utcFormat: Ba, utcParse: La }) } EU(), MU(); const FU = /^(data:|([A-Za-z]+:)?\/\/)/, DU = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i, $U = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g, RU = "file://"; async function OU(e, t) { const n = await this.sanitize(e, t), r = n.href; return n.localFile ? this.file(r) : this.http(r, t) } async function zU(e, t) { t = DL({}, this.options, t); const n = this.fileAccess, r = { href: null }; let i, a, o; const s = DU.test(e.replace($U, "")); null != e && "string" == typeof e && s || kL("Sanitize failure, invalid URI: " + BL(e)); const u = FU.test(e); return (o = t.baseURL) && !u && (e.startsWith("/") || o.endsWith("/") || (e = "/" + e), e = o + e), a = (i = e.startsWith(RU)) || "file" === t.mode || "http" !== t.mode && !u && n, i ? e = e.slice(7) : e.startsWith("//") && ("file" === t.defaultProtocol ? (e = e.slice(2), a = !0) : e = (t.defaultProtocol || "http") + ":" + e), Object.defineProperty(r, "localFile", { value: !!a }), r.href = e, t.target && (r.target = t.target + ""), t.rel && (r.rel = t.rel + ""), "image" === t.context && t.crossOrigin && (r.crossOrigin = t.crossOrigin + ""), r } function PU(e) { return e ? t => new Promise(((n, r) => { e.readFile(t, ((e, t) => { e ? r(e) : n(t) })) })) : BU } async function BU() { kL("No file system access.") } function LU(e) { return e ? async function (t, n) { const r = DL({}, this.options.http, n), i = n && n.response, a = await e(t, r); return a.ok ? FL(a[i]) ? a[i]() : a.text() : kL(a.status + "" + a.statusText) } : jU } async function jU() { kL("No HTTP fetch method available.") } function UU(e) { const t = function (t, n) { const r = { delimiter: e }; return WU(t, n ? DL(n, r) : r) }; return t.responseType = "text", t } function WU(e, t) { return t.header && (e = t.header.map(BL).join(t.delimiter) + "\n" + e), sr(t.delimiter).parse(e + "") } function VU(e, t) { const n = t && t.property ? _L(t.property) : CL; return !EL(e) || (r = e, "function" == typeof Buffer && FL(Buffer.isBuffer) && Buffer.isBuffer(r)) ? n(JSON.parse(e)) : function (e, t) { !TL(e) && function (e) { return e && FL(e[Symbol.iterator]) }(e) && (e = [...e]); return t && t.copy ? JSON.parse(JSON.stringify(e)) : e }(n(e), t); var r } WU.responseType = "text", VU.responseType = "json"; const GU = { interior: (e, t) => e !== t, exterior: (e, t) => e === t }; function HU(e, t) { let n, r, i, a; return e = VU(e, t), t && t.feature ? (n = lr, i = t.feature) : t && t.mesh ? (n = fr, i = t.mesh, a = GU[t.filter]) : kL("Missing TopoJSON feature or mesh parameter."), r = (r = e.objects[i]) ? n(e, r, a) : kL("Invalid TopoJSON object: " + i), r && r.features || [r] } HU.responseType = "json"; UU(","), UU("\t"); const qU = function (e, t) { return n => ({ options: n || {}, sanitize: zU, load: OU, fileAccess: !!t, file: PU(t), http: LU(e) }) }("undefined" != typeof fetch && fetch, null); function YU(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function XU(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function KU(e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = YU, n = (t, n) => YU(e(t), n), r = (t, n) => e(t) - n) : (t = e === YU || e === XU ? e : ZU, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } } function ZU() { return 0 } const JU = KU(YU), QU = JU.right, eW = (JU.left, KU((function (e) { return null === e ? NaN : +e })).center, QU); function tW(e, t, n) { e.prototype = t.prototype = n, n.constructor = e } function nW(e, t) { var n = Object.create(e.prototype); for (var r in t) n[r] = t[r]; return n } function rW() { } var iW = .7, aW = 1.4285714285714286, oW = "\\s*([+-]?\\d+)\\s*", sW = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", uW = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", lW = /^#([0-9a-f]{3,8})$/, cW = new RegExp(`^rgb\\(${oW},${oW},${oW}\\)$`), hW = new RegExp(`^rgb\\(${uW},${uW},${uW}\\)$`), dW = new RegExp(`^rgba\\(${oW},${oW},${oW},${sW}\\)$`), fW = new RegExp(`^rgba\\(${uW},${uW},${uW},${sW}\\)$`), pW = new RegExp(`^hsl\\(${sW},${uW},${uW}\\)$`), mW = new RegExp(`^hsla\\(${sW},${uW},${uW},${sW}\\)$`), gW = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; function yW() { return this.rgb().formatHex() } function bW() { return this.rgb().formatRgb() } function vW(e) { var t, n; return e = (e + "").trim().toLowerCase(), (t = lW.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), 6 === n ? xW(t) : 3 === n ? new _W(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, (15 & t) << 4 | 15 & t, 1) : 8 === n ? wW(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (255 & t) / 255) : 4 === n ? wW(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, ((15 & t) << 4 | 15 & t) / 255) : null) : (t = cW.exec(e)) ? new _W(t[1], t[2], t[3], 1) : (t = hW.exec(e)) ? new _W(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, 1) : (t = dW.exec(e)) ? wW(t[1], t[2], t[3], t[4]) : (t = fW.exec(e)) ? wW(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, t[4]) : (t = pW.exec(e)) ? IW(t[1], t[2] / 100, t[3] / 100, 1) : (t = mW.exec(e)) ? IW(t[1], t[2] / 100, t[3] / 100, t[4]) : gW.hasOwnProperty(e) ? xW(gW[e]) : "transparent" === e ? new _W(NaN, NaN, NaN, 0) : null } function xW(e) { return new _W(e >> 16 & 255, e >> 8 & 255, 255 & e, 1) } function wW(e, t, n, r) { return r <= 0 && (e = t = n = NaN), new _W(e, t, n, r) } function kW(e) { return e instanceof rW || (e = vW(e)), e ? new _W((e = e.rgb()).r, e.g, e.b, e.opacity) : new _W } function SW(e, t, n, r) { return 1 === arguments.length ? kW(e) : new _W(e, t, n, null == r ? 1 : r) } function _W(e, t, n, r) { this.r = +e, this.g = +t, this.b = +n, this.opacity = +r } function CW() { return `#${NW(this.r)}${NW(this.g)}${NW(this.b)}` } function AW() { const e = TW(this.opacity); return `${1 === e ? "rgb(" : "rgba("}${EW(this.r)}, ${EW(this.g)}, ${EW(this.b)}${1 === e ? ")" : `, ${e})`}` } function TW(e) { return isNaN(e) ? 1 : Math.max(0, Math.min(1, e)) } function EW(e) { return Math.max(0, Math.min(255, Math.round(e) || 0)) } function NW(e) { return ((e = EW(e)) < 16 ? "0" : "") + e.toString(16) } function IW(e, t, n, r) { return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new DW(e, t, n, r) } function MW(e) { if (e instanceof DW) return new DW(e.h, e.s, e.l, e.opacity); if (e instanceof rW || (e = vW(e)), !e) return new DW; if (e instanceof DW) return e; var t = (e = e.rgb()).r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, u = (a + i) / 2; return s ? (o = t === a ? (n - r) / s + 6 * (n < r) : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= u < .5 ? a + i : 2 - a - i, o *= 60) : s = u > 0 && u < 1 ? 0 : o, new DW(o, s, u, e.opacity) } function FW(e, t, n, r) { return 1 === arguments.length ? MW(e) : new DW(e, t, n, null == r ? 1 : r) } function DW(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function $W(e) { return (e = (e || 0) % 360) < 0 ? e + 360 : e } function RW(e) { return Math.max(0, Math.min(1, e || 0)) } function OW(e, t, n) { return 255 * (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) } function zW(e, t, n, r, i) { var a = e * e, o = a * e; return ((1 - 3 * e + 3 * a - o) * t + (4 - 6 * a + 3 * o) * n + (1 + 3 * e + 3 * a - 3 * o) * r + o * i) / 6 } function PW(e) { var t = e.length - 1; return function (n) { var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], a = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - a, s = r < t - 1 ? e[r + 2] : 2 * a - i; return zW((n - r / t) * t, o, i, a, s) } } function BW(e) { var t = e.length; return function (n) { var r = Math.floor(((n %= 1) < 0 ? ++n : n) * t), i = e[(r + t - 1) % t], a = e[r % t], o = e[(r + 1) % t], s = e[(r + 2) % t]; return zW((n - r / t) * t, i, a, o, s) } } tW(rW, vW, { copy(e) { return Object.assign(new this.constructor, this, e) }, displayable() { return this.rgb().displayable() }, hex: yW, formatHex: yW, formatHex8: function () { return this.rgb().formatHex8() }, formatHsl: function () { return MW(this).formatHsl() }, formatRgb: bW, toString: bW }), tW(_W, SW, nW(rW, { brighter(e) { return e = null == e ? aW : Math.pow(aW, e), new _W(this.r * e, this.g * e, this.b * e, this.opacity) }, darker(e) { return e = null == e ? iW : Math.pow(iW, e), new _W(this.r * e, this.g * e, this.b * e, this.opacity) }, rgb() { return this }, clamp() { return new _W(EW(this.r), EW(this.g), EW(this.b), TW(this.opacity)) }, displayable() { return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1 }, hex: CW, formatHex: CW, formatHex8: function () { return `#${NW(this.r)}${NW(this.g)}${NW(this.b)}${NW(255 * (isNaN(this.opacity) ? 1 : this.opacity))}` }, formatRgb: AW, toString: AW })), tW(DW, FW, nW(rW, { brighter(e) { return e = null == e ? aW : Math.pow(aW, e), new DW(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? iW : Math.pow(iW, e), new DW(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = this.h % 360 + 360 * (this.h < 0), t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r; return new _W(OW(e >= 240 ? e - 240 : e + 120, i, r), OW(e, i, r), OW(e < 120 ? e + 240 : e - 120, i, r), this.opacity) }, clamp() { return new DW($W(this.h), RW(this.s), RW(this.l), TW(this.opacity)) }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1 }, formatHsl() { const e = TW(this.opacity); return `${1 === e ? "hsl(" : "hsla("}${$W(this.h)}, ${100 * RW(this.s)}%, ${100 * RW(this.l)}%${1 === e ? ")" : `, ${e})`}` } })); const LW = e => () => e; function jW(e, t) { return function (n) { return e + n * t } } function UW(e, t) { var n = t - e; return n ? jW(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : LW(isNaN(e) ? t : e) } function WW(e) { return 1 == (e = +e) ? VW : function (t, n) { return n - t ? function (e, t, n) { return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function (r) { return Math.pow(e + r * t, n) } }(t, n, e) : LW(isNaN(t) ? n : t) } } function VW(e, t) { var n = t - e; return n ? jW(e, n) : LW(isNaN(e) ? t : e) } const GW = function e(t) { var n = WW(t); function r(e, t) { var r = n((e = SW(e)).r, (t = SW(t)).r), i = n(e.g, t.g), a = n(e.b, t.b), o = VW(e.opacity, t.opacity); return function (t) { return e.r = r(t), e.g = i(t), e.b = a(t), e.opacity = o(t), e + "" } } return r.gamma = e, r }(1); function HW(e) { return function (t) { var n, r, i = t.length, a = new Array(i), o = new Array(i), s = new Array(i); for (n = 0; n < i; ++n)r = SW(t[n]), a[n] = r.r || 0, o[n] = r.g || 0, s[n] = r.b || 0; return a = e(a), o = e(o), s = e(s), r.opacity = 1, function (e) { return r.r = a(e), r.g = o(e), r.b = s(e), r + "" } } } var qW = HW(PW), YW = HW(BW); function XW(e, t) { t || (t = []); var n, r = e ? Math.min(t.length, e.length) : 0, i = t.slice(); return function (a) { for (n = 0; n < r; ++n)i[n] = e[n] * (1 - a) + t[n] * a; return i } } function KW(e) { return ArrayBuffer.isView(e) && !(e instanceof DataView) } function ZW(e, t) { return (KW(t) ? XW : JW)(e, t) } function JW(e, t) { var n, r = t ? t.length : 0, i = e ? Math.min(r, e.length) : 0, a = new Array(i), o = new Array(r); for (n = 0; n < i; ++n)a[n] = aV(e[n], t[n]); for (; n < r; ++n)o[n] = t[n]; return function (e) { for (n = 0; n < i; ++n)o[n] = a[n](e); return o } } function QW(e, t) { var n = new Date; return e = +e, t = +t, function (r) { return n.setTime(e * (1 - r) + t * r), n } } function eV(e, t) { return e = +e, t = +t, function (n) { return e * (1 - n) + t * n } } function tV(e, t) { var n, r = {}, i = {}; for (n in null !== e && "object" == typeof e || (e = {}), null !== t && "object" == typeof t || (t = {}), t) n in e ? r[n] = aV(e[n], t[n]) : i[n] = t[n]; return function (e) { for (n in r) i[n] = r[n](e); return i } } var nV = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, rV = new RegExp(nV.source, "g"); function iV(e, t) { var n, r, i, a = nV.lastIndex = rV.lastIndex = 0, o = -1, s = [], u = []; for (e += "", t += ""; (n = nV.exec(e)) && (r = rV.exec(t));)(i = r.index) > a && (i = t.slice(a, i), s[o] ? s[o] += i : s[++o] = i), (n = n[0]) === (r = r[0]) ? s[o] ? s[o] += r : s[++o] = r : (s[++o] = null, u.push({ i: o, x: eV(n, r) })), a = rV.lastIndex; return a < t.length && (i = t.slice(a), s[o] ? s[o] += i : s[++o] = i), s.length < 2 ? u[0] ? function (e) { return function (t) { return e(t) + "" } }(u[0].x) : function (e) { return function () { return e } }(t) : (t = u.length, function (e) { for (var n, r = 0; r < t; ++r)s[(n = u[r]).i] = n.x(e); return s.join("") }) } function aV(e, t) { var n, r = typeof t; return null == t || "boolean" === r ? LW(t) : ("number" === r ? eV : "string" === r ? (n = vW(t)) ? (t = n, GW) : iV : t instanceof vW ? GW : t instanceof Date ? QW : KW(t) ? XW : Array.isArray(t) ? JW : "function" != typeof t.valueOf && "function" != typeof t.toString || isNaN(t) ? tV : eV)(e, t) } function oV(e, t) { void 0 === t && (t = e, e = aV); for (var n = 0, r = t.length - 1, i = t[0], a = new Array(r < 0 ? 0 : r); n < r;)a[n] = e(i, i = t[++n]); return function (e) { var t = Math.max(0, Math.min(r - 1, Math.floor(e *= r))); return a[t](e - t) } } function sV(e) { var t = e.length; return function (n) { return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))] } } function uV(e, t) { var n = UW(+e, +t); return function (e) { var t = n(e); return t - 360 * Math.floor(t / 360) } } function lV(e, t) { return e = +e, t = +t, function (n) { return Math.round(e * (1 - n) + t * n) } } var cV, hV = 180 / Math.PI, dV = { translateX: 0, translateY: 0, rotate: 0, skewX: 0, scaleX: 1, scaleY: 1 }; function fV(e, t, n, r, i, a) { var o, s, u; return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (u = e * n + t * r) && (n -= e * u, r -= t * u), (s = Math.sqrt(n * n + r * r)) && (n /= s, r /= s, u /= s), e * r < t * n && (e = -e, t = -t, u = -u, o = -o), { translateX: i, translateY: a, rotate: Math.atan2(t, e) * hV, skewX: Math.atan(u) * hV, scaleX: o, scaleY: s } } function pV(e, t, n, r) { function i(e) { return e.length ? e.pop() + " " : "" } return function (a, o) { var s = [], u = []; return a = e(a), o = e(o), function (e, r, i, a, o, s) { if (e !== i || r !== a) { var u = o.push("translate(", null, t, null, n); s.push({ i: u - 4, x: eV(e, i) }, { i: u - 2, x: eV(r, a) }) } else (i || a) && o.push("translate(" + i + t + a + n) }(a.translateX, a.translateY, o.translateX, o.translateY, s, u), function (e, t, n, a) { e !== t ? (e - t > 180 ? t += 360 : t - e > 180 && (e += 360), a.push({ i: n.push(i(n) + "rotate(", null, r) - 2, x: eV(e, t) })) : t && n.push(i(n) + "rotate(" + t + r) }(a.rotate, o.rotate, s, u), function (e, t, n, a) { e !== t ? a.push({ i: n.push(i(n) + "skewX(", null, r) - 2, x: eV(e, t) }) : t && n.push(i(n) + "skewX(" + t + r) }(a.skewX, o.skewX, s, u), function (e, t, n, r, a, o) { if (e !== n || t !== r) { var s = a.push(i(a) + "scale(", null, ",", null, ")"); o.push({ i: s - 4, x: eV(e, n) }, { i: s - 2, x: eV(t, r) }) } else 1 === n && 1 === r || a.push(i(a) + "scale(" + n + "," + r + ")") }(a.scaleX, a.scaleY, o.scaleX, o.scaleY, s, u), a = o = null, function (e) { for (var t, n = -1, r = u.length; ++n < r;)s[(t = u[n]).i] = t.x(e); return s.join("") } } } var mV = pV((function (e) { const t = new ("function" == typeof DOMMatrix ? DOMMatrix : WebKitCSSMatrix)(e + ""); return t.isIdentity ? dV : fV(t.a, t.b, t.c, t.d, t.e, t.f) }), "px, ", "px)", "deg)"), gV = pV((function (e) { return null == e ? dV : (cV || (cV = document.createElementNS("http://www.w3.org/2000/svg", "g")), cV.setAttribute("transform", e), (e = cV.transform.baseVal.consolidate()) ? fV((e = e.matrix).a, e.b, e.c, e.d, e.e, e.f) : dV) }), ", ", ")", ")"); function yV(e) { return ((e = Math.exp(e)) + 1 / e) / 2 } const bV = function e(t, n, r) { function i(e, i) { var a, o, s = e[0], u = e[1], l = e[2], c = i[0], h = i[1], d = i[2], f = c - s, p = h - u, m = f * f + p * p; if (m < 1e-12) o = Math.log(d / l) / t, a = function (e) { return [s + e * f, u + e * p, l * Math.exp(t * e * o)] }; else { var g = Math.sqrt(m), y = (d * d - l * l + r * m) / (2 * l * n * g), b = (d * d - l * l - r * m) / (2 * d * n * g), v = Math.log(Math.sqrt(y * y + 1) - y), x = Math.log(Math.sqrt(b * b + 1) - b); o = (x - v) / t, a = function (e) { var r = e * o, i = yV(v), a = l / (n * g) * (i * function (e) { return ((e = Math.exp(2 * e)) - 1) / (e + 1) }(t * r + v) - function (e) { return ((e = Math.exp(e)) - 1 / e) / 2 }(v)); return [s + a * f, u + a * p, l * i / yV(t * r + v)] } } return a.duration = 1e3 * o * t / Math.SQRT2, a } return i.rho = function (t) { var n = Math.max(.001, +t), r = n * n; return e(n, r, r * r) }, i }(Math.SQRT2, 2, 4); function vV(e) { return function (t, n) { var r = e((t = FW(t)).h, (n = FW(n)).h), i = VW(t.s, n.s), a = VW(t.l, n.l), o = VW(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.s = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } const xV = vV(UW); var wV = vV(VW); const kV = Math.PI / 180, SV = 180 / Math.PI, _V = .96422, CV = 1, AV = .82521, TV = 4 / 29, EV = 6 / 29, NV = .12841854934601665, IV = .008856451679035631; function MV(e) { if (e instanceof DV) return new DV(e.l, e.a, e.b, e.opacity); if (e instanceof LV) return jV(e); e instanceof _W || (e = kW(e)); var t, n, r = zV(e.r), i = zV(e.g), a = zV(e.b), o = $V((.2225045 * r + .7168786 * i + .0606169 * a) / CV); return r === i && i === a ? t = n = o : (t = $V((.4360747 * r + .3850649 * i + .1430804 * a) / _V), n = $V((.0139322 * r + .0971045 * i + .7141733 * a) / AV)), new DV(116 * o - 16, 500 * (t - o), 200 * (o - n), e.opacity) } function FV(e, t, n, r) { return 1 === arguments.length ? MV(e) : new DV(e, t, n, null == r ? 1 : r) } function DV(e, t, n, r) { this.l = +e, this.a = +t, this.b = +n, this.opacity = +r } function $V(e) { return e > IV ? Math.pow(e, 1 / 3) : e / NV + TV } function RV(e) { return e > EV ? e * e * e : NV * (e - TV) } function OV(e) { return 255 * (e <= .0031308 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - .055) } function zV(e) { return (e /= 255) <= .04045 ? e / 12.92 : Math.pow((e + .055) / 1.055, 2.4) } function PV(e) { if (e instanceof LV) return new LV(e.h, e.c, e.l, e.opacity); if (e instanceof DV || (e = MV(e)), 0 === e.a && 0 === e.b) return new LV(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity); var t = Math.atan2(e.b, e.a) * SV; return new LV(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity) } function BV(e, t, n, r) { return 1 === arguments.length ? PV(e) : new LV(e, t, n, null == r ? 1 : r) } function LV(e, t, n, r) { this.h = +e, this.c = +t, this.l = +n, this.opacity = +r } function jV(e) { if (isNaN(e.h)) return new DV(e.l, 0, 0, e.opacity); var t = e.h * kV; return new DV(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity) } function UV(e, t) { var n = VW((e = FV(e)).l, (t = FV(t)).l), r = VW(e.a, t.a), i = VW(e.b, t.b), a = VW(e.opacity, t.opacity); return function (t) { return e.l = n(t), e.a = r(t), e.b = i(t), e.opacity = a(t), e + "" } } function WV(e) { return function (t, n) { var r = e((t = BV(t)).h, (n = BV(n)).h), i = VW(t.c, n.c), a = VW(t.l, n.l), o = VW(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.c = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } tW(DV, FV, nW(rW, { brighter(e) { return new DV(this.l + 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, darker(e) { return new DV(this.l - 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, rgb() { var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200; return new _W(OV(3.1338561 * (t = _V * RV(t)) - 1.6168667 * (e = CV * RV(e)) - .4906146 * (n = AV * RV(n))), OV(-.9787684 * t + 1.9161415 * e + .033454 * n), OV(.0719453 * t - .2289914 * e + 1.4052427 * n), this.opacity) } })), tW(LV, BV, nW(rW, { brighter(e) { return new LV(this.h, this.c, this.l + 18 * (null == e ? 1 : e), this.opacity) }, darker(e) { return new LV(this.h, this.c, this.l - 18 * (null == e ? 1 : e), this.opacity) }, rgb() { return jV(this).rgb() } })); const VV = WV(UW); var GV = WV(VW), HV = -.14861, qV = 1.78277, YV = -.29227, XV = -.90649, KV = 1.97294, ZV = -1.7884503806, JV = 3.5172982438, QV = -.6557636667999999; function eG(e, t, n, r) { return 1 === arguments.length ? function (e) { if (e instanceof tG) return new tG(e.h, e.s, e.l, e.opacity); e instanceof _W || (e = kW(e)); var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (QV * r + ZV * t - JV * n) / -5.9615122912, a = r - i, o = (KV * (n - i) - YV * a) / XV, s = Math.sqrt(o * o + a * a) / (KV * i * (1 - i)), u = s ? Math.atan2(o, a) * SV - 120 : NaN; return new tG(u < 0 ? u + 360 : u, s, i, e.opacity) }(e) : new tG(e, t, n, null == r ? 1 : r) } function tG(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function nG(e) { return function t(n) { function r(t, r) { var i = e((t = eG(t)).h, (r = eG(r)).h), a = VW(t.s, r.s), o = VW(t.l, r.l), s = VW(t.opacity, r.opacity); return function (e) { return t.h = i(e), t.s = a(e), t.l = o(Math.pow(e, n)), t.opacity = s(e), t + "" } } return n = +n, r.gamma = t, r }(1) } tW(tG, eG, nW(rW, { brighter(e) { return e = null == e ? aW : Math.pow(aW, e), new tG(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? iW : Math.pow(iW, e), new tG(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = isNaN(this.h) ? 0 : (this.h + 120) * kV, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e); return new _W(255 * (t + n * (HV * r + qV * i)), 255 * (t + n * (YV * r + XV * i)), 255 * (t + n * (KV * r)), this.opacity) } })); const rG = nG(UW); var iG = nG(VW); function aG(e, t) { for (var n = new Array(t), r = 0; r < t; ++r)n[r] = e(r / (t - 1)); return n } const oG = "linear", sG = "log", uG = "pow", lG = "sqrt", cG = "symlog", hG = "time", dG = "utc", fG = "sequential", pG = "diverging", mG = "quantile", gG = "quantize", yG = "threshold", bG = "continuous", vG = "discrete", xG = "discretizing", wG = "interpolating", kG = "temporal"; function SG() { const e = wm().unknown(void 0), t = e.domain, n = e.range; let r, i, a = [0, 1], o = !1, s = 0, u = 0, l = .5; function c() { const e = t().length, c = a[1] < a[0], h = a[1 - c], d = function (e, t, n) { const r = e - t + 2 * n; return e ? r > 0 ? r : 1 : 0 }(e, s, u); let f = a[c - 0]; r = (h - f) / (d || 1), o && (r = Math.floor(r)), f += (h - f - r * (e - s)) * l, i = r * (1 - s), o && (f = Math.round(f), i = Math.round(i)); const p = function (e, t, n) { e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n; for (var r = -1, i = 0 | Math.max(0, Math.ceil((t - e) / n)), a = new Array(i); ++r < i;)a[r] = e + r * n; return a }(e).map((e => f + r * e)); return n(c ? p.reverse() : p) } return delete e.unknown, e.domain = function (e) { return arguments.length ? (t(e), c()) : t() }, e.range = function (e) { return arguments.length ? (a = [+e[0], +e[1]], c()) : a.slice() }, e.rangeRound = function (e) { return a = [+e[0], +e[1]], o = !0, c() }, e.bandwidth = function () { return i }, e.step = function () { return r }, e.round = function (e) { return arguments.length ? (o = !!e, c()) : o }, e.padding = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), s = u, c()) : s }, e.paddingInner = function (e) { return arguments.length ? (s = Math.max(0, Math.min(1, e)), c()) : s }, e.paddingOuter = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), c()) : u }, e.align = function (e) { return arguments.length ? (l = Math.max(0, Math.min(1, e)), c()) : l }, e.invertRange = function (e) { if (null == e[0] || null == e[1]) return; const r = a[1] < a[0], o = r ? n().reverse() : n(), s = o.length - 1; let u, l, c, h = +e[0], d = +e[1]; return h != h || d != d || (d < h && (c = h, h = d, d = c), d < o[0] || h > a[1 - r]) ? void 0 : (u = Math.max(0, QU(o, h) - 1), l = h === d ? u : QU(o, d) - 1, h - o[u] > i + 1e-10 && ++u, r && (c = u, u = s - l, l = s - c), u > l ? void 0 : t().slice(u, l + 1)) }, e.invert = function (t) { const n = e.invertRange([t, t]); return n ? n[0] : n }, e.copy = function () { return SG().domain(t()).range(a).round(o).paddingInner(s).paddingOuter(u).align(l) }, c() } function _G(e) { const t = e.copy; return e.padding = e.paddingOuter, delete e.paddingInner, e.copy = function () { return _G(t()) }, e } var CG = Array.prototype.map; const AG = Array.prototype.slice; const TG = new Map, EG = Symbol("vega_scale"); function NG(e, t, n) { const r = function () { const n = t(); return n.invertRange || (n.invertRange = n.invert ? function (e) { return function (t) { let n, r = t[0], i = t[1]; return i < r && (n = r, r = i, i = n), [e.invert(r), e.invert(i)] } }(n) : n.invertExtent ? function (e) { return function (t) { const n = e.range(); let r, i, a, o, s = t[0], u = t[1], l = -1; for (u < s && (i = s, s = u, u = i), a = 0, o = n.length; a < o; ++a)n[a] >= s && n[a] <= u && (l < 0 && (l = a), r = a); if (!(l < 0)) return s = e.invertExtent(n[l]), u = e.invertExtent(n[r]), [void 0 === s[0] ? s[1] : s[0], void 0 === u[1] ? u[0] : u[1]] } }(n) : void 0), n.type = e, function (e) { return e[EG] = !0, e }(n) }; return r.metadata = LL(ML(n)), r } function IG(e, t, n) { return arguments.length > 1 ? (TG.set(e, NG(e, t, n)), this) : function (e) { return TG.has(e) }(e) ? TG.get(e) : void 0 } function MG(e, t) { const n = TG.get(e); return n && n.metadata[t] } function FG(e) { return MG(e, vG) } IG("identity", fp), IG(oG, dp, bG), IG(sG, kp, [bG, sG]), IG(uG, Tp, bG), IG(lG, Ep, bG), IG(cG, Fp, bG), IG(hG, Kp, [bG, kG]), IG(dG, Zp, [bG, kG]), IG(fG, em, [bG, wG]), IG(`${fG}-${oG}`, em, [bG, wG]), IG(`${fG}-${sG}`, tm, [bG, wG, sG]), IG(`${fG}-${uG}`, rm, [bG, wG]), IG(`${fG}-${lG}`, im, [bG, wG]), IG(`${fG}-${cG}`, nm, [bG, wG]), IG(`${pG}-${oG}`, om, [bG, wG]), IG(`${pG}-${sG}`, sm, [bG, wG, sG]), IG(`${pG}-${uG}`, lm, [bG, wG]), IG(`${pG}-${lG}`, cm, [bG, wG]), IG(`${pG}-${cG}`, um, [bG, wG]), IG(mG, dm, [xG, mG]), IG(gG, fm, xG), IG(yG, pm, xG), IG("bin-ordinal", (function e() { let t = [], n = []; function r(e) { return null == e || e != e ? void 0 : n[(eW(t, e) - 1) % n.length] } return r.domain = function (e) { return arguments.length ? (t = function (e) { return CG.call(e, IL) }(e), r) : t.slice() }, r.range = function (e) { return arguments.length ? (n = AG.call(e), r) : n.slice() }, r.tickFormat = function (e, n) { return cp(t[0], NL(t), null == e ? 10 : e, n) }, r.copy = function () { return e().domain(r.domain()).range(r.range()) }, r }), [vG, xG]), IG("ordinal", wm, vG), IG("band", SG, vG), IG("point", (function () { return _G(SG().paddingInner(1)) }), vG); function DG(e, t, n) { return oV(function (e, t) { const n = y[function (e) { return "interpolate" + e.toLowerCase().split("-").map((e => e[0].toUpperCase() + e.slice(1))).join("") }(e)]; return null != t && n && n.gamma ? n.gamma(t) : n }(t || "rgb", n), e) } function $G(e) { if (TL(e)) return e; const t = e.length / 6 | 0, n = new Array(t); for (let r = 0; r < t;)n[r] = "#" + e.slice(6 * r, 6 * ++r); return n } function RG(e, t) { for (const n in e) zG(n, t(e[n])) } const OG = {}; function zG(e, t) { return e = e && e.toLowerCase(), arguments.length > 1 ? (OG[e] = t, this) : OG[e] } RG({ accent: Ey, category10: Ny, category20: "1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5", category20b: "393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6", category20c: "3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9", dark2: Iy, observable10: My, paired: Fy, pastel1: Dy, pastel2: $y, set1: Ry, set2: Oy, set3: zy, tableau10: "4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac", tableau20: "4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5" }, $G), RG({ blues: "cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90", greens: "d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429", greys: "e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e", oranges: "fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303", purples: "e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c", reds: "fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13", blueGreen: "d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429", bluePurple: "ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71", greenBlue: "d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1", orangeRed: "fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403", purpleBlue: "dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281", purpleBlueGreen: "dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353", purpleRed: "dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a", redPurple: "fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174", yellowGreen: "e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034", yellowOrangeBrown: "feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204", yellowOrangeRed: "fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225", blueOrange: "134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07", brownBlueGreen: "704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147", purpleGreen: "5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29", purpleOrange: "4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07", redBlue: "8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85", redGrey: "8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434", yellowGreenBlue: "eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185", redYellowBlue: "a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695", redYellowGreen: "a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837", pinkYellowGreen: "8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419", spectral: "9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2", viridis: "440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725", magma: "0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf", inferno: "0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4", plasma: "0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921", cividis: "00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647", rainbow: "6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa", sinebow: "ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040", turbo: "23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00", browns: "eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632", tealBlues: "bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985", teals: "bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667", warmGreys: "dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e", goldGreen: "f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36", goldOrange: "f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26", goldRed: "f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e", lightGreyRed: "efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b", lightGreyTeal: "e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc", lightMulti: "e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c", lightOrange: "f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b", lightTealBlue: "e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988", darkBlue: "3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff", darkGold: "3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff", darkGreen: "3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa", darkMulti: "3737371f5287197d8c29a86995ce3fffe800ffffff", darkRed: "3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c" }, (e => DG($G(e)))); const PG = e => TL(e) ? e.map((e => String(e))) : String(e), BG = (e, t) => e[1] - t[1], LG = (e, t) => t[1] - e[1]; function jG(e, t) { return e.bins ? function (e, t, n) { let r = e.range(), i = r[0], a = NL(r), o = BG; if (i > a && (r = a, a = i, i = r, o = LG), i = Math.floor(i), a = Math.ceil(a), t = t.map((t => [t, e(t)])).filter((e => i <= e[1] && e[1] <= a)).sort(o).map((e => e[0])), n > 0 && t.length > 1) { const e = [t[0], NL(t)]; for (; t.length > n && t.length >= 3;)t = t.filter(((e, t) => !(t % 2))); t.length < 3 && (t = e) } return t }(e, e.bins, t) : e.ticks ? e.ticks(t) : e.domain() } function UG(e, t, n, r, i, a) { const o = t.type; let s = PG; if (o === hG || i === hG) s = e.timeFormat(r); else if (o === dG || i === dG) s = e.utcFormat(r); else if (function (e) { return MG(e, sG) }(o)) { const i = e.formatFloat(r); if (a || t.bins) s = i; else { const e = WG(t, n, !1); s = t => e(t) ? i(t) : "" } } else if (t.tickFormat) { const i = t.domain(); s = e.formatSpan(i[0], i[i.length - 1], n, r) } else r && (s = e.format(r)); return s } function WG(e, t, n) { const r = jG(e, t), i = e.base(), a = Math.log(i), o = Math.max(1, i * t / r.length), s = e => { let t = e / Math.pow(i, Math.round(Math.log(e) / a)); return t * i < i - .5 && (t *= i), t <= o }; return n ? r.filter(s) : s } const VG = { [mG]: "quantiles", [gG]: "thresholds", [yG]: "domain" }, GG = { [mG]: "quantiles", [gG]: "domain" }; function HG(e, t) { return e.bins ? function (e) { const t = e.slice(0, -1); return t.max = NL(e), t }(e.bins) : e.type === sG ? WG(e, t, !0) : VG[e.type] ? function (e) { const t = [-1 / 0].concat(e); return t.max = 1 / 0, t }(e[VG[e.type]]()) : jG(e, t) } function qG(e, t, n, r, i, a, o) { const s = GG[t.type] && a !== hG && a !== dG ? function (e, t, n) { const r = t[GG[t.type]](), i = r.length; let a, o = i > 1 ? r[1] - r[0] : r[0]; for (a = 1; a < i; ++a)o = Math.min(o, r[a] - r[a - 1]); return e.formatSpan(0, o, 30, n) }(e, t, i) : UG(e, t, n, i, a, o); return "symbol" === r && (e => VG[e.type] || e.bins)(t) ? YG(s) : "discrete" === r ? KG(s) : ZG(s) } const YG = e => (t, n, r) => { const i = XG(r[n + 1], XG(r.max, 1 / 0)), a = JG(t, e), o = JG(i, e); return a && o ? a + " – " + o : o ? "< " + o : "≥ " + a }, XG = (e, t) => null != e ? e : t, KG = e => (t, n) => n ? e(t) : null, ZG = e => t => e(t), JG = (e, t) => Number.isFinite(e) ? t(e) : null; function QG(e, t, n, r) { const i = r || t.type; return PL(n) && function (e) { return MG(e, kG) }(i) && (n = n.replace(/%a/g, "%A").replace(/%b/g, "%B")), n || i !== hG ? n || i !== dG ? qG(e, t, 5, null, n, r, !0) : e.utcFormat("%A, %d %B %Y, %X UTC") : e.timeFormat("%A, %d %B %Y, %X") } function eH(e, t, n) { n = n || {}; const r = Math.max(3, n.maxlen || 7), i = QG(e, t, n.format, n.formatType); if (function (e) { return MG(e, xG) }(t.type)) { const e = HG(t).slice(1).map(i), n = e.length; return `${n} boundar${1 === n ? "y" : "ies"}: ${e.join(", ")}` } if (FG(t.type)) { const e = t.domain(), n = e.length; return `${n} value${1 === n ? "" : "s"}: ${n > r ? e.slice(0, r - 2).map(i).join(", ") + ", ending with " + e.slice(-1).map(i) : e.map(i).join(", ")}` } { const e = t.domain(); return `values from ${i(e[0])} to ${i(NL(e))}` } } let tH = 0; const nH = "p_"; function rH(e) { return e && e.gradient } function iH(e, t, n) { const r = e.gradient; let i = e.id, a = "radial" === r ? nH : ""; return i || (i = e.id = "gradient_" + tH++, "radial" === r ? (e.x1 = aH(e.x1, .5), e.y1 = aH(e.y1, .5), e.r1 = aH(e.r1, 0), e.x2 = aH(e.x2, .5), e.y2 = aH(e.y2, .5), e.r2 = aH(e.r2, .5), a = nH) : (e.x1 = aH(e.x1, 0), e.y1 = aH(e.y1, 0), e.x2 = aH(e.x2, 1), e.y2 = aH(e.y2, 0))), t[i] = e, "url(" + (n || "") + "#" + a + i + ")" } function aH(e, t) { return null != e ? e : t } function oH(e, t) { var n, r = []; return n = { gradient: "linear", x1: e ? e[0] : 0, y1: e ? e[1] : 0, x2: t ? t[0] : 1, y2: t ? t[1] : 0, stops: r, stop: function (e, t) { return r.push({ offset: e, color: t }), n } } } const sH = { basis: { curve: function (e) { return new UL(e) } }, "basis-closed": { curve: function (e) { return new VL(e) } }, "basis-open": { curve: function (e) { return new GL(e) } }, bundle: { curve: qL, tension: "beta", value: .85 }, cardinal: { curve: KL, tension: "tension", value: 0 }, "cardinal-open": { curve: JL, tension: "tension", value: 0 }, "cardinal-closed": { curve: ej, tension: "tension", value: 0 }, "catmull-rom": { curve: mj, tension: "alpha", value: .5 }, "catmull-rom-closed": { curve: yj, tension: "alpha", value: .5 }, "catmull-rom-open": { curve: vj, tension: "alpha", value: .5 }, linear: { curve: wj }, "linear-closed": { curve: function (e) { return new kj(e) } }, monotone: { horizontal: function (e) { return new Ej(e) }, vertical: function (e) { return new Tj(e) } }, natural: { curve: function (e) { return new Ij(e) } }, step: { curve: function (e) { return new Fj(e, .5) } }, "step-after": { curve: function (e) { return new Fj(e, 1) } }, "step-before": { curve: function (e) { return new Fj(e, 0) } } }; function uH(e, t, n) { var r = RL(sH, e) && sH[e], i = null; return r && (i = r.curve || r[t || "vertical"], r.tension && null != n && (i = i[r.tension](n))), i } const lH = { m: 2, l: 2, h: 1, v: 1, c: 6, s: 4, q: 4, t: 2, a: 7 }, cH = [/([MLHVCSQTAZmlhvcsqtaz])/g, /###/, /(\.\d+)(\.\d)/g, /(\d)([-+])/g, /\s|,|###/]; function hH(e) { const t = []; let n, r, i, a, o, s, u, l, c, h; const d = e.slice().replace(cH[0], "###$1").split(cH[1]).slice(1); for (u = 0, c = d.length; u < c; ++u) { for (n = d[u], r = n.slice(1).trim().replace(cH[2], "$1###$2").replace(cH[3], "$1###$2").split(cH[4]), o = n.charAt(0), i = [o], l = 0, h = r.length; l < h; ++l)(a = +r[l]) === a && i.push(a); if (s = lH[o.toLowerCase()], i.length - 1 > s) { const e = i.length; for (l = 1, t.push([o].concat(i.slice(l, l += s))), o = "M" === o ? "L" : "m" === o ? "l" : o; l < e; l += s)t.push([o].concat(i.slice(l, l + s))) } else t.push(i) } return t } const dH = Math.PI / 180, fH = Math.PI / 2, pH = 2 * Math.PI, mH = Math.sqrt(3) / 2; var gH = {}, yH = {}, bH = [].join; function vH(e) { const t = bH.call(e); if (yH[t]) return yH[t]; var n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], u = e[6], l = e[7]; const c = l * o, h = -u * s, d = u * o, f = l * s, p = Math.cos(i), m = Math.sin(i), g = Math.cos(a), y = Math.sin(a), b = .5 * (a - i), v = Math.sin(.5 * b), x = 8 / 3 * v * v / Math.sin(b), w = n + p - x * m, k = r + m + x * p, S = n + g, _ = r + y, C = S + x * y, A = _ - x * g; return yH[t] = [c * w + h * k, d * w + f * k, c * C + h * A, d * C + f * A, c * S + h * _, d * S + f * _] } const xH = ["l", 0, 0, 0, 0, 0, 0, 0]; function wH(e, t, n) { const r = xH[0] = e[0]; if ("a" === r || "A" === r) xH[1] = t * e[1], xH[2] = n * e[2], xH[3] = e[3], xH[4] = e[4], xH[5] = e[5], xH[6] = t * e[6], xH[7] = n * e[7]; else if ("h" === r || "H" === r) xH[1] = t * e[1]; else if ("v" === r || "V" === r) xH[1] = n * e[1]; else for (var i = 1, a = e.length; i < a; ++i)xH[i] = (i % 2 == 1 ? t : n) * e[i]; return xH } function kH(e, t, n, r, i, a) { var o, s, u, l, c, h = null, d = 0, f = 0, p = 0, m = 0; null == n && (n = 0), null == r && (r = 0), null == i && (i = 1), null == a && (a = i), e.beginPath && e.beginPath(); for (var g = 0, y = t.length; g < y; ++g) { switch (o = t[g], 1 === i && 1 === a || (o = wH(o, i, a)), o[0]) { case "l": d += o[1], f += o[2], e.lineTo(d + n, f + r); break; case "L": d = o[1], f = o[2], e.lineTo(d + n, f + r); break; case "h": d += o[1], e.lineTo(d + n, f + r); break; case "H": d = o[1], e.lineTo(d + n, f + r); break; case "v": f += o[1], e.lineTo(d + n, f + r); break; case "V": f = o[1], e.lineTo(d + n, f + r); break; case "m": d += o[1], f += o[2], e.moveTo(d + n, f + r); break; case "M": d = o[1], f = o[2], e.moveTo(d + n, f + r); break; case "c": s = d + o[5], u = f + o[6], p = d + o[3], m = f + o[4], e.bezierCurveTo(d + o[1] + n, f + o[2] + r, p + n, m + r, s + n, u + r), d = s, f = u; break; case "C": d = o[5], f = o[6], p = o[3], m = o[4], e.bezierCurveTo(o[1] + n, o[2] + r, p + n, m + r, d + n, f + r); break; case "s": s = d + o[3], u = f + o[4], p = 2 * d - p, m = 2 * f - m, e.bezierCurveTo(p + n, m + r, d + o[1] + n, f + o[2] + r, s + n, u + r), p = d + o[1], m = f + o[2], d = s, f = u; break; case "S": s = o[3], u = o[4], p = 2 * d - p, m = 2 * f - m, e.bezierCurveTo(p + n, m + r, o[1] + n, o[2] + r, s + n, u + r), d = s, f = u, p = o[1], m = o[2]; break; case "q": s = d + o[3], u = f + o[4], p = d + o[1], m = f + o[2], e.quadraticCurveTo(p + n, m + r, s + n, u + r), d = s, f = u; break; case "Q": s = o[3], u = o[4], e.quadraticCurveTo(o[1] + n, o[2] + r, s + n, u + r), d = s, f = u, p = o[1], m = o[2]; break; case "t": s = d + o[1], u = f + o[2], null === h[0].match(/[QqTt]/) ? (p = d, m = f) : "t" === h[0] ? (p = 2 * d - l, m = 2 * f - c) : "q" === h[0] && (p = 2 * d - p, m = 2 * f - m), l = p, c = m, e.quadraticCurveTo(p + n, m + r, s + n, u + r), f = u, p = (d = s) + o[1], m = f + o[2]; break; case "T": s = o[1], u = o[2], p = 2 * d - p, m = 2 * f - m, e.quadraticCurveTo(p + n, m + r, s + n, u + r), d = s, f = u; break; case "a": SH(e, d + n, f + r, [o[1], o[2], o[3], o[4], o[5], o[6] + d + n, o[7] + f + r]), d += o[6], f += o[7]; break; case "A": SH(e, d + n, f + r, [o[1], o[2], o[3], o[4], o[5], o[6] + n, o[7] + r]), d = o[6], f = o[7]; break; case "z": case "Z": e.closePath() }h = o } } function SH(e, t, n, r) { const i = function (e, t, n, r, i, a, o, s, u) { const l = bH.call(arguments); if (gH[l]) return gH[l]; const c = o * dH, h = Math.sin(c), d = Math.cos(c), f = d * (s - e) * .5 + h * (u - t) * .5, p = d * (u - t) * .5 - h * (s - e) * .5; let m = f * f / ((n = Math.abs(n)) * n) + p * p / ((r = Math.abs(r)) * r); m > 1 && (m = Math.sqrt(m), n *= m, r *= m); const g = d / n, y = h / n, b = -h / r, v = d / r, x = g * s + y * u, w = b * s + v * u, k = g * e + y * t, S = b * e + v * t; let _ = 1 / ((k - x) * (k - x) + (S - w) * (S - w)) - .25; _ < 0 && (_ = 0); let C = Math.sqrt(_); a == i && (C = -C); const A = .5 * (x + k) - C * (S - w), T = .5 * (w + S) + C * (k - x), E = Math.atan2(w - T, x - A); let N = Math.atan2(S - T, k - A) - E; N < 0 && 1 === a ? N += pH : N > 0 && 0 === a && (N -= pH); const I = Math.ceil(Math.abs(N / (fH + .001))), M = []; for (let e = 0; e < I; ++e) { const t = E + e * N / I, i = E + (e + 1) * N / I; M[e] = [A, T, t, i, n, r, h, d] } return gH[l] = M }(r[5], r[6], r[0], r[1], r[3], r[4], r[2], t, n); for (let t = 0; t < i.length; ++t) { const n = vH(i[t]); e.bezierCurveTo(n[0], n[1], n[2], n[3], n[4], n[5]) } } const _H = .5773502691896257, CH = { circle: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(n, 0), e.arc(0, 0, n, 0, pH) } }, cross: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = n / 2.5; e.moveTo(-n, -r), e.lineTo(-n, r), e.lineTo(-r, r), e.lineTo(-r, n), e.lineTo(r, n), e.lineTo(r, r), e.lineTo(n, r), e.lineTo(n, -r), e.lineTo(r, -r), e.lineTo(r, -n), e.lineTo(-r, -n), e.lineTo(-r, -r), e.closePath() } }, diamond: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(-n, 0), e.lineTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.closePath() } }, square: { draw: function (e, t) { var n = Math.sqrt(t), r = -n / 2; e.rect(r, r, n, n) } }, arrow: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = n / 7, i = n / 2.5, a = n / 8; e.moveTo(-r, n), e.lineTo(r, n), e.lineTo(r, -a), e.lineTo(i, -a), e.lineTo(0, -n), e.lineTo(-i, -a), e.lineTo(-r, -a), e.closePath() } }, wedge: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = mH * n, i = r - n * _H, a = n / 4; e.moveTo(0, -r - i), e.lineTo(-a, r - i), e.lineTo(a, r - i), e.closePath() } }, triangle: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = mH * n, i = r - n * _H; e.moveTo(0, -r - i), e.lineTo(-n, r - i), e.lineTo(n, r - i), e.closePath() } }, "triangle-up": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = mH * n; e.moveTo(0, -r), e.lineTo(-n, r), e.lineTo(n, r), e.closePath() } }, "triangle-down": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = mH * n; e.moveTo(0, r), e.lineTo(-n, -r), e.lineTo(n, -r), e.closePath() } }, "triangle-right": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = mH * n; e.moveTo(r, 0), e.lineTo(-r, -n), e.lineTo(-r, n), e.closePath() } }, "triangle-left": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = mH * n; e.moveTo(-r, 0), e.lineTo(r, -n), e.lineTo(r, n), e.closePath() } }, stroke: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(-n, 0), e.lineTo(n, 0) } } }; function AH(e) { return RL(CH, e) ? CH[e] : function (e) { if (!RL(TH, e)) { const t = hH(e); TH[e] = { draw: function (e, n) { kH(e, t, 0, 0, Math.sqrt(n) / 2) } } } return TH[e] }(e) } var TH = {}; const EH = .448084975506; function NH(e) { return e.x } function IH(e) { return e.y } function MH(e) { return e.width } function FH(e) { return e.height } function DH(e) { return "function" == typeof e ? e : () => +e } function $H(e, t, n) { return Math.max(t, Math.min(e, n)) } function RH() { var e = NH, t = IH, n = MH, r = FH, i = DH(0), a = i, o = i, s = i, u = null; function l(l, c, h) { var d, f = null != c ? c : +e.call(this, l), p = null != h ? h : +t.call(this, l), m = +n.call(this, l), g = +r.call(this, l), y = Math.min(m, g) / 2, b = $H(+i.call(this, l), 0, y), v = $H(+a.call(this, l), 0, y), x = $H(+o.call(this, l), 0, y), w = $H(+s.call(this, l), 0, y); if (u || (u = d = Bj()), b <= 0 && v <= 0 && x <= 0 && w <= 0) u.rect(f, p, m, g); else { var k = f + m, S = p + g; u.moveTo(f + b, p), u.lineTo(k - v, p), u.bezierCurveTo(k - EH * v, p, k, p + EH * v, k, p + v), u.lineTo(k, S - w), u.bezierCurveTo(k, S - EH * w, k - EH * w, S, k - w, S), u.lineTo(f + x, S), u.bezierCurveTo(f + EH * x, S, f, S - EH * x, f, S - x), u.lineTo(f, p + b), u.bezierCurveTo(f, p + EH * b, f + EH * b, p, f + b, p), u.closePath() } if (d) return u = null, d + "" || null } return l.x = function (t) { return arguments.length ? (e = DH(t), l) : e }, l.y = function (e) { return arguments.length ? (t = DH(e), l) : t }, l.width = function (e) { return arguments.length ? (n = DH(e), l) : n }, l.height = function (e) { return arguments.length ? (r = DH(e), l) : r }, l.cornerRadius = function (e, t, n, r) { return arguments.length ? (i = DH(e), a = null != t ? DH(t) : i, s = null != n ? DH(n) : i, o = null != r ? DH(r) : a, l) : i }, l.context = function (e) { return arguments.length ? (u = null == e ? null : e, l) : u }, l } function OH() { var e, t, n, r, i, a, o, s, u = null; function l(e, t, n) { const r = n / 2; if (i) { var l = o - t, c = e - a; if (l || c) { var h = Math.sqrt(l * l + c * c), d = (l /= h) * s, f = (c /= h) * s, p = Math.atan2(c, l); u.moveTo(a - d, o - f), u.lineTo(e - l * r, t - c * r), u.arc(e, t, r, p - Math.PI, p), u.lineTo(a + d, o + f), u.arc(a, o, s, p, p + Math.PI) } else u.arc(e, t, r, 0, pH); u.closePath() } else i = 1; a = e, o = t, s = r } function c(a) { var o, s, c, h = a.length, d = !1; for (null == u && (u = c = Bj()), o = 0; o <= h; ++o)!(o < h && r(s = a[o], o, a)) === d && (d = !d) && (i = 0), d && l(+e(s, o, a), +t(s, o, a), +n(s, o, a)); if (c) return u = null, c + "" || null } return c.x = function (t) { return arguments.length ? (e = t, c) : e }, c.y = function (e) { return arguments.length ? (t = e, c) : t }, c.size = function (e) { return arguments.length ? (n = e, c) : n }, c.defined = function (e) { return arguments.length ? (r = e, c) : r }, c.context = function (e) { return arguments.length ? (u = null == e ? null : e, c) : u }, c } function zH(e, t) { return null != e ? e : t } const PH = e => e.x || 0, BH = e => e.y || 0, LH = e => !(!1 === e.defined), jH = function () { var e = jj, t = Uj, n = Lj(0), r = null, i = Wj, a = Vj, o = Gj, s = null; function u() { var u, l, c = +e.apply(this, arguments), h = +t.apply(this, arguments), d = i.apply(this, arguments) - cj, f = a.apply(this, arguments) - cj, p = tj(f - d), m = f > d; if (s || (s = u = Bj()), h < c && (l = h, h = c, c = l), h > uj) if (p > hj - uj) s.moveTo(h * rj(d), h * oj(d)), s.arc(0, 0, h, d, f, !m), c > uj && (s.moveTo(c * rj(f), c * oj(f)), s.arc(0, 0, c, f, d, m)); else { var g, y, b = d, v = f, x = d, w = f, k = p, S = p, _ = o.apply(this, arguments) / 2, C = _ > uj && (r ? +r.apply(this, arguments) : sj(c * c + h * h)), A = aj(tj(h - c) / 2, +n.apply(this, arguments)), T = A, E = A; if (C > uj) { var N = dj(C / c * oj(_)), I = dj(C / h * oj(_)); (k -= 2 * N) > uj ? (x += N *= m ? 1 : -1, w -= N) : (k = 0, x = w = (d + f) / 2), (S -= 2 * I) > uj ? (b += I *= m ? 1 : -1, v -= I) : (S = 0, b = v = (d + f) / 2) } var M = h * rj(b), F = h * oj(b), D = c * rj(w), $ = c * oj(w); if (A > uj) { var R, O = h * rj(v), z = h * oj(v), P = c * rj(x), B = c * oj(x); if (p < lj && (R = function (e, t, n, r, i, a, o, s) { var u = n - e, l = r - t, c = o - i, h = s - a, d = h * u - c * l; if (!(d * d < uj)) return [e + (d = (c * (t - a) - h * (e - i)) / d) * u, t + d * l] }(M, F, P, B, O, z, D, $))) { var L = M - R[0], j = F - R[1], U = O - R[0], W = z - R[1], V = 1 / oj(function (e) { return e > 1 ? 0 : e < -1 ? lj : Math.acos(e) }((L * U + j * W) / (sj(L * L + j * j) * sj(U * U + W * W))) / 2), G = sj(R[0] * R[0] + R[1] * R[1]); T = aj(A, (c - G) / (V - 1)), E = aj(A, (h - G) / (V + 1)) } } S > uj ? E > uj ? (g = Hj(P, B, M, F, h, E, m), y = Hj(O, z, D, $, h, E, m), s.moveTo(g.cx + g.x01, g.cy + g.y01), E < A ? s.arc(g.cx, g.cy, E, nj(g.y01, g.x01), nj(y.y01, y.x01), !m) : (s.arc(g.cx, g.cy, E, nj(g.y01, g.x01), nj(g.y11, g.x11), !m), s.arc(0, 0, h, nj(g.cy + g.y11, g.cx + g.x11), nj(y.cy + y.y11, y.cx + y.x11), !m), s.arc(y.cx, y.cy, E, nj(y.y11, y.x11), nj(y.y01, y.x01), !m))) : (s.moveTo(M, F), s.arc(0, 0, h, b, v, !m)) : s.moveTo(M, F), c > uj && k > uj ? T > uj ? (g = Hj(D, $, O, z, c, -T, m), y = Hj(M, F, P, B, c, -T, m), s.lineTo(g.cx + g.x01, g.cy + g.y01), T < A ? s.arc(g.cx, g.cy, T, nj(g.y01, g.x01), nj(y.y01, y.x01), !m) : (s.arc(g.cx, g.cy, T, nj(g.y01, g.x01), nj(g.y11, g.x11), !m), s.arc(0, 0, c, nj(g.cy + g.y11, g.cx + g.x11), nj(y.cy + y.y11, y.cx + y.x11), m), s.arc(y.cx, y.cy, T, nj(y.y11, y.x11), nj(y.y01, y.x01), !m))) : s.arc(0, 0, c, w, x, m) : s.lineTo(D, $) } else s.moveTo(0, 0); if (s.closePath(), u) return s = null, u + "" || null } return u.centroid = function () { var n = (+e.apply(this, arguments) + +t.apply(this, arguments)) / 2, r = (+i.apply(this, arguments) + +a.apply(this, arguments)) / 2 - lj / 2; return [rj(r) * n, oj(r) * n] }, u.innerRadius = function (t) { return arguments.length ? (e = "function" == typeof t ? t : Lj(+t), u) : e }, u.outerRadius = function (e) { return arguments.length ? (t = "function" == typeof e ? e : Lj(+e), u) : t }, u.cornerRadius = function (e) { return arguments.length ? (n = "function" == typeof e ? e : Lj(+e), u) : n }, u.padRadius = function (e) { return arguments.length ? (r = null == e ? null : "function" == typeof e ? e : Lj(+e), u) : r }, u.startAngle = function (e) { return arguments.length ? (i = "function" == typeof e ? e : Lj(+e), u) : i }, u.endAngle = function (e) { return arguments.length ? (a = "function" == typeof e ? e : Lj(+e), u) : a }, u.padAngle = function (e) { return arguments.length ? (o = "function" == typeof e ? e : Lj(+e), u) : o }, u.context = function (e) { return arguments.length ? (s = null == e ? null : e, u) : s }, u }().startAngle((e => e.startAngle || 0)).endAngle((e => e.endAngle || 0)).padAngle((e => e.padAngle || 0)).innerRadius((e => e.innerRadius || 0)).outerRadius((e => e.outerRadius || 0)).cornerRadius((e => e.cornerRadius || 0)), UH = Zj().x(PH).y1(BH).y0((e => (e.y || 0) + (e.height || 0))).defined(LH), WH = Zj().y(BH).x1(PH).x0((e => (e.x || 0) + (e.width || 0))).defined(LH), VH = Kj().x(PH).y(BH).defined(LH), GH = RH().x(PH).y(BH).width((e => e.width || 0)).height((e => e.height || 0)).cornerRadius((e => zH(e.cornerRadiusTopLeft, e.cornerRadius) || 0), (e => zH(e.cornerRadiusTopRight, e.cornerRadius) || 0), (e => zH(e.cornerRadiusBottomRight, e.cornerRadius) || 0), (e => zH(e.cornerRadiusBottomLeft, e.cornerRadius) || 0)), HH = function (e, t) { var n = null; function r() { var r; if (n || (n = r = Bj()), e.apply(this, arguments).draw(n, +t.apply(this, arguments)), r) return n = null, r + "" || null } return e = "function" == typeof e ? e : Lj(e || Jj), t = "function" == typeof t ? t : Lj(void 0 === t ? 64 : +t), r.type = function (t) { return arguments.length ? (e = "function" == typeof t ? t : Lj(t), r) : e }, r.size = function (e) { return arguments.length ? (t = "function" == typeof e ? e : Lj(+e), r) : t }, r.context = function (e) { return arguments.length ? (n = null == e ? null : e, r) : n }, r }().type((e => AH(e.shape || "circle"))).size((e => zH(e.size, 64))), qH = OH().x(PH).y(BH).defined(LH).size((e => e.size || 1)); function YH(e) { return e.cornerRadius || e.cornerRadiusTopLeft || e.cornerRadiusTopRight || e.cornerRadiusBottomRight || e.cornerRadiusBottomLeft } function XH(e, t, n, r) { return GH.context(e)(t, n, r) } var KH = 1; function ZH() { KH = 1 } function JH(e, t, n) { var r = t.clip, i = e._defs, a = t.clip_id || (t.clip_id = "clip" + KH++), o = i.clipping[a] || (i.clipping[a] = { id: a }); return FL(r) ? o.path = r(null) : YH(n) ? o.path = XH(null, n, 0, 0) : (o.width = n.width || 0, o.height = n.height || 0), "url(#" + a + ")" } function QH(e) { this.clear(), e && this.union(e) } function eq(e) { this.mark = e, this.bounds = this.bounds || new QH } function tq(e) { eq.call(this, e), this.items = this.items || [] } function nq(e) { this._pending = 0, this._loader = e || qU() } function rq(e) { e._pending += 1 } function iq(e) { e._pending -= 1 } function aq(e, t, n) { if (t.stroke && 0 !== t.opacity && 0 !== t.strokeOpacity) { const r = null != t.strokeWidth ? +t.strokeWidth : 1; e.expand(r + (n ? function (e, t) { return e.strokeJoin && "miter" !== e.strokeJoin ? 0 : t }(t, r) : 0)) } return e } QH.prototype = { clone() { return new QH(this) }, clear() { return this.x1 = +Number.MAX_VALUE, this.y1 = +Number.MAX_VALUE, this.x2 = -Number.MAX_VALUE, this.y2 = -Number.MAX_VALUE, this }, empty() { return this.x1 === +Number.MAX_VALUE && this.y1 === +Number.MAX_VALUE && this.x2 === -Number.MAX_VALUE && this.y2 === -Number.MAX_VALUE }, equals(e) { return this.x1 === e.x1 && this.y1 === e.y1 && this.x2 === e.x2 && this.y2 === e.y2 }, set(e, t, n, r) { return n < e ? (this.x2 = e, this.x1 = n) : (this.x1 = e, this.x2 = n), r < t ? (this.y2 = t, this.y1 = r) : (this.y1 = t, this.y2 = r), this }, add(e, t) { return e < this.x1 && (this.x1 = e), t < this.y1 && (this.y1 = t), e > this.x2 && (this.x2 = e), t > this.y2 && (this.y2 = t), this }, expand(e) { return this.x1 -= e, this.y1 -= e, this.x2 += e, this.y2 += e, this }, round() { return this.x1 = Math.floor(this.x1), this.y1 = Math.floor(this.y1), this.x2 = Math.ceil(this.x2), this.y2 = Math.ceil(this.y2), this }, scale(e) { return this.x1 *= e, this.y1 *= e, this.x2 *= e, this.y2 *= e, this }, translate(e, t) { return this.x1 += e, this.x2 += e, this.y1 += t, this.y2 += t, this }, rotate(e, t, n) { const r = this.rotatedPoints(e, t, n); return this.clear().add(r[0], r[1]).add(r[2], r[3]).add(r[4], r[5]).add(r[6], r[7]) }, rotatedPoints(e, t, n) { var { x1: r, y1: i, x2: a, y2: o } = this, s = Math.cos(e), u = Math.sin(e), l = t - t * s + n * u, c = n - t * u - n * s; return [s * r - u * i + l, u * r + s * i + c, s * r - u * o + l, u * r + s * o + c, s * a - u * i + l, u * a + s * i + c, s * a - u * o + l, u * a + s * o + c] }, union(e) { return e.x1 < this.x1 && (this.x1 = e.x1), e.y1 < this.y1 && (this.y1 = e.y1), e.x2 > this.x2 && (this.x2 = e.x2), e.y2 > this.y2 && (this.y2 = e.y2), this }, intersect(e) { return e.x1 > this.x1 && (this.x1 = e.x1), e.y1 > this.y1 && (this.y1 = e.y1), e.x2 < this.x2 && (this.x2 = e.x2), e.y2 < this.y2 && (this.y2 = e.y2), this }, encloses(e) { return e && this.x1 <= e.x1 && this.x2 >= e.x2 && this.y1 <= e.y1 && this.y2 >= e.y2 }, alignsWith(e) { return e && (this.x1 == e.x1 || this.x2 == e.x2 || this.y1 == e.y1 || this.y2 == e.y2) }, intersects(e) { return e && !(this.x2 < e.x1 || this.x1 > e.x2 || this.y2 < e.y1 || this.y1 > e.y2) }, contains(e, t) { return !(e < this.x1 || e > this.x2 || t < this.y1 || t > this.y2) }, width() { return this.x2 - this.x1 }, height() { return this.y2 - this.y1 } }, OL(tq, eq), nq.prototype = { pending() { return this._pending }, sanitizeURL(e) { const t = this; return rq(t), t._loader.sanitize(e, { context: "href" }).then((e => (iq(t), e))).catch((() => (iq(t), null))) }, loadImage(e) { const t = this, n = Dd(); return rq(t), t._loader.sanitize(e, { context: "image" }).then((e => { const r = e.href; if (!r || !n) throw { url: r }; const i = new n, a = RL(e, "crossOrigin") ? e.crossOrigin : "anonymous"; return null != a && (i.crossOrigin = a), i.onload = () => iq(t), i.onerror = () => iq(t), i.src = r, i })).catch((e => (iq(t), { complete: !1, width: 0, height: 0, src: e && e.url || "" }))) }, ready() { const e = this; return new Promise((t => { !function n(r) { e.pending() ? setTimeout((() => { n(!0) }), 10) : t(r) }(!1) })) } }; const oq = pH - 1e-8; let sq, uq, lq, cq, hq, dq, fq, pq; const mq = (e, t) => sq.add(e, t), gq = (e, t) => mq(uq = e, lq = t), yq = e => mq(e, sq.y1), bq = e => mq(sq.x1, e), vq = (e, t) => hq * e + fq * t, xq = (e, t) => dq * e + pq * t, wq = (e, t) => mq(vq(e, t), xq(e, t)), kq = (e, t) => gq(vq(e, t), xq(e, t)); function Sq(e, t) { return sq = e, t ? (cq = t * dH, hq = pq = Math.cos(cq), dq = Math.sin(cq), fq = -dq) : (hq = pq = 1, cq = dq = fq = 0), _q } const _q = { beginPath() { }, closePath() { }, moveTo: kq, lineTo: kq, rect(e, t, n, r) { cq ? (wq(e + n, t), wq(e + n, t + r), wq(e, t + r), kq(e, t)) : (mq(e + n, t + r), gq(e, t)) }, quadraticCurveTo(e, t, n, r) { const i = vq(e, t), a = xq(e, t), o = vq(n, r), s = xq(n, r); Cq(uq, i, o, yq), Cq(lq, a, s, bq), gq(o, s) }, bezierCurveTo(e, t, n, r, i, a) { const o = vq(e, t), s = xq(e, t), u = vq(n, r), l = xq(n, r), c = vq(i, a), h = xq(i, a); Aq(uq, o, u, c, yq), Aq(lq, s, l, h, bq), gq(c, h) }, arc(e, t, n, r, i, a) { if (r += cq, i += cq, uq = n * Math.cos(i) + e, lq = n * Math.sin(i) + t, Math.abs(i - r) > oq) mq(e - n, t - n), mq(e + n, t + n); else { const o = r => mq(n * Math.cos(r) + e, n * Math.sin(r) + t); let s, u; if (o(r), o(i), i !== r) if ((r %= pH) < 0 && (r += pH), (i %= pH) < 0 && (i += pH), i < r && (a = !a, s = r, r = i, i = s), a) for (i -= pH, s = r - r % fH, u = 0; u < 4 && s > i; ++u, s -= fH)o(s); else for (s = r - r % fH + fH, u = 0; u < 4 && s < i; ++u, s += fH)o(s) } } }; function Cq(e, t, n, r) { const i = (e - t) / (e + n - 2 * t); 0 < i && i < 1 && r(e + (t - e) * i) } function Aq(e, t, n, r, i) { const a = r - e + 3 * t - 3 * n, o = e + n - 2 * t, s = e - t; let u, l = 0, c = 0; Math.abs(a) > 1e-14 ? (u = o * o + s * a, u >= 0 && (u = Math.sqrt(u), l = (-o + u) / a, c = (-o - u) / a)) : l = .5 * s / o, 0 < l && l < 1 && i(Tq(l, e, t, n, r)), 0 < c && c < 1 && i(Tq(c, e, t, n, r)) } function Tq(e, t, n, r, i) { const a = 1 - e, o = a * a, s = e * e; return o * a * t + 3 * o * e * n + 3 * a * s * r + s * e * i } var Eq = (Eq = Fd(1, 1)) ? Eq.getContext("2d") : null; const Nq = new QH; function Iq(e) { return function (t, n) { if (!Eq) return !0; e(Eq, t), Nq.clear().union(t.bounds).intersect(n).round(); const { x1: r, y1: i, x2: a, y2: o } = Nq; for (let e = i; e <= o; ++e)for (let t = r; t <= a; ++t)if (Eq.isPointInPath(t, e)) return !0; return !1 } } function Mq(e, t) { return t.contains(e.x || 0, e.y || 0) } function Fq(e, t) { const n = e.x || 0, r = e.y || 0, i = e.width || 0, a = e.height || 0; return t.intersects(Nq.set(n, r, n + i, r + a)) } function Dq(e, t) { const n = e.x || 0, r = e.y || 0; return $q(t, n, r, null != e.x2 ? e.x2 : n, null != e.y2 ? e.y2 : r) } function $q(e, t, n, r, i) { const { x1: a, y1: o, x2: s, y2: u } = e, l = r - t, c = i - n; let h, d, f, p, m = 0, g = 1; for (p = 0; p < 4; ++p) { if (0 === p && (h = -l, d = -(a - t)), 1 === p && (h = l, d = s - t), 2 === p && (h = -c, d = -(o - n)), 3 === p && (h = c, d = u - n), Math.abs(h) < 1e-10 && d < 0) return !1; if (f = d / h, h < 0) { if (f > g) return !1; f > m && (m = f) } else if (h > 0) { if (f < m) return !1; f < g && (g = f) } } return !0 } function Rq(e, t) { e.globalCompositeOperation = t.blend || "source-over" } function Oq(e, t) { return null == e ? t : e } function zq(e, t) { const n = t.length; for (let r = 0; r < n; ++r)e.addColorStop(t[r].offset, t[r].color); return e } function Pq(e, t, n) { return rH(n) ? function (e, t, n) { const r = n.width(), i = n.height(); let a; if ("radial" === t.gradient) a = e.createRadialGradient(n.x1 + Oq(t.x1, .5) * r, n.y1 + Oq(t.y1, .5) * i, Math.max(r, i) * Oq(t.r1, 0), n.x1 + Oq(t.x2, .5) * r, n.y1 + Oq(t.y2, .5) * i, Math.max(r, i) * Oq(t.r2, .5)); else { const o = Oq(t.x1, 0), s = Oq(t.y1, 0), u = Oq(t.x2, 1), l = Oq(t.y2, 0); if (o !== u && s !== l && r !== i) { const n = Fd(Math.ceil(r), Math.ceil(i)), a = n.getContext("2d"); return a.scale(r, i), a.fillStyle = zq(a.createLinearGradient(o, s, u, l), t.stops), a.fillRect(0, 0, r, i), e.createPattern(n, "no-repeat") } a = e.createLinearGradient(n.x1 + o * r, n.y1 + s * i, n.x1 + u * r, n.y1 + l * i) } return zq(a, t.stops) }(e, n, t.bounds) : n } function Bq(e, t, n) { return (n *= null == t.fillOpacity ? 1 : t.fillOpacity) > 0 && (e.globalAlpha = n, e.fillStyle = Pq(e, t, t.fill), !0) } var Lq = []; function jq(e, t, n) { var r = null != (r = t.strokeWidth) ? r : 1; return !(r <= 0) && ((n *= null == t.strokeOpacity ? 1 : t.strokeOpacity) > 0 && (e.globalAlpha = n, e.strokeStyle = Pq(e, t, t.stroke), e.lineWidth = r, e.lineCap = t.strokeCap || "butt", e.lineJoin = t.strokeJoin || "miter", e.miterLimit = t.strokeMiterLimit || 10, e.setLineDash && (e.setLineDash(t.strokeDash || Lq), e.lineDashOffset = t.strokeDashOffset || 0), !0)) } function Uq(e, t) { return e.zindex - t.zindex || e.index - t.index } function Wq(e) { if (!e.zdirty) return e.zitems; var t, n, r, i = e.items, a = []; for (n = 0, r = i.length; n < r; ++n)(t = i[n]).index = n, t.zindex && a.push(t); return e.zdirty = !1, e.zitems = a.sort(Uq) } function Vq(e, t) { var n, r, i = e.items; if (!i || !i.length) return; const a = Wq(e); if (a && a.length) { for (n = 0, r = i.length; n < r; ++n)i[n].zindex || t(i[n]); i = a } for (n = 0, r = i.length; n < r; ++n)t(i[n]) } function Gq(e, t) { var n, r, i = e.items; if (!i || !i.length) return null; const a = Wq(e); for (a && a.length && (i = a), r = i.length; --r >= 0;)if (n = t(i[r])) return n; if (i === a) for (r = (i = e.items).length; --r >= 0;)if (!i[r].zindex && (n = t(i[r]))) return n; return null } function Hq(e) { return function (t, n, r) { Vq(n, (n => { r && !r.intersects(n.bounds) || Yq(e, t, n, n) })) } } function qq(e) { return function (t, n, r) { !n.items.length || r && !r.intersects(n.bounds) || Yq(e, t, n.items[0], n.items) } } function Yq(e, t, n, r) { var i = null == n.opacity ? 1 : n.opacity; 0 !== i && (e(t, r) || (Rq(t, n), n.fill && Bq(t, n, i) && t.fill(), n.stroke && jq(t, n, i) && t.stroke())) } function Xq(e) { return e = e || AL, function (t, n, r, i, a, o) { return r *= t.pixelRatio, i *= t.pixelRatio, Gq(n, (n => { const s = n.bounds; if ((!s || s.contains(a, o)) && s) return e(t, n, r, i, a, o) ? n : void 0 })) } } function Kq(e, t) { return function (n, r, i, a) { var o, s, u = Array.isArray(r) ? r[0] : r, l = null == t ? u.fill : t, c = u.stroke && n.isPointInStroke; return c && (o = u.strokeWidth, s = u.strokeCap, n.lineWidth = null != o ? o : 1, n.lineCap = null != s ? s : "butt"), !e(n, r) && (l && n.isPointInPath(i, a) || c && n.isPointInStroke(i, a)) } } function Zq(e) { return Xq(Kq(e)) } function Jq(e, t) { return "translate(" + e + "," + t + ")" } function Qq(e) { return "rotate(" + e + ")" } function eY(e) { return Jq(e.x || 0, e.y || 0) } function tY(e, t, n) { function r(e, n) { var r = n.x || 0, i = n.y || 0, a = n.angle || 0; e.translate(r, i), a && e.rotate(a *= dH), e.beginPath(), t(e, n), a && e.rotate(-a), e.translate(-r, -i) } return { type: e, tag: "path", nested: !1, attr: function (e, n) { e("transform", function (e) { return Jq(e.x || 0, e.y || 0) + (e.angle ? " " + Qq(e.angle) : "") }(n)), e("d", t(null, n)) }, bound: function (e, n) { return t(Sq(e, n.angle), n), aq(e, n).translate(n.x || 0, n.y || 0) }, draw: Hq(r), pick: Zq(r), isect: n || Iq(r) } } var nY = tY("arc", (function (e, t) { return jH.context(e)(t) })); function rY(e, t, n) { function r(e, n) { e.beginPath(), t(e, n) } const i = Kq(r); return { type: e, tag: "path", nested: !0, attr: function (e, n) { var r = n.mark.items; r.length && e("d", t(null, r)) }, bound: function (e, n) { var r = n.items; return 0 === r.length ? e : (t(Sq(e), r), aq(e, r[0])) }, draw: qq(r), pick: function (e, t, n, r, a, o) { var s = t.items, u = t.bounds; return !s || !s.length || u && !u.contains(a, o) ? null : (n *= e.pixelRatio, r *= e.pixelRatio, i(e, s, n, r) ? s[0] : null) }, isect: Mq, tip: n } } var iY = rY("area", (function (e, t) { const n = t[0], r = n.interpolate || "linear"; return ("horizontal" === n.orient ? WH : UH).curve(uH(r, n.orient, n.tension)).context(e)(t) }), (function (e, t) { for (var n, r, i = "horizontal" === e[0].orient ? t[1] : t[0], a = "horizontal" === e[0].orient ? "y" : "x", o = e.length, s = 1 / 0; --o >= 0;)!1 !== e[o].defined && (r = Math.abs(e[o][a] - i)) < s && (s = r, n = e[o]); return n })); function aY(e, t) { e.beginPath(), YH(t) ? XH(e, t, 0, 0) : e.rect(0, 0, t.width || 0, t.height || 0), e.clip() } function oY(e) { const t = Oq(e.strokeWidth, 1); return null != e.strokeOffset ? e.strokeOffset : e.stroke && t > .5 && t < 1.5 ? .5 - Math.abs(t - 1) : 0 } function sY(e, t) { const n = oY(t); e("d", XH(null, t, n, n)) } function uY(e, t, n, r) { const i = oY(t); e.beginPath(), XH(e, t, (n || 0) + i, (r || 0) + i) } const lY = Kq(uY), cY = Kq(uY, !1), hY = Kq(uY, !0); var dY = { type: "group", tag: "g", nested: !1, attr: function (e, t) { e("transform", eY(t)) }, bound: function (e, t) { if (!t.clip && t.items) { const n = t.items, r = n.length; for (let t = 0; t < r; ++t)e.union(n[t].bounds) } return (t.clip || t.width || t.height) && !t.noBound && e.add(0, 0).add(t.width || 0, t.height || 0), aq(e, t), e.translate(t.x || 0, t.y || 0) }, draw: function (e, t, n) { Vq(t, (t => { const r = t.x || 0, i = t.y || 0, a = t.strokeForeground, o = null == t.opacity ? 1 : t.opacity; (t.stroke || t.fill) && o && (uY(e, t, r, i), Rq(e, t), t.fill && Bq(e, t, o) && e.fill(), t.stroke && !a && jq(e, t, o) && e.stroke()), e.save(), e.translate(r, i), t.clip && aY(e, t), n && n.translate(-r, -i), Vq(t, (t => { this.draw(e, t, n) })), n && n.translate(r, i), e.restore(), a && t.stroke && o && (uY(e, t, r, i), Rq(e, t), jq(e, t, o) && e.stroke()) })) }, pick: function (e, t, n, r, i, a) { if (t.bounds && !t.bounds.contains(i, a) || !t.items) return null; const o = n * e.pixelRatio, s = r * e.pixelRatio; return Gq(t, (u => { let l, c, h; const d = u.bounds; if (d && !d.contains(i, a)) return; c = u.x || 0, h = u.y || 0; const f = c + (u.width || 0), p = h + (u.height || 0), m = u.clip; if (m && (i < c || i > f || a < h || a > p)) return; if (e.save(), e.translate(c, h), c = i - c, h = a - h, m && YH(u) && !hY(e, u, o, s)) return e.restore(), null; const g = u.strokeForeground, y = !1 !== t.interactive; return y && g && u.stroke && cY(e, u, o, s) ? (e.restore(), u) : (l = Gq(u, (e => function (e, t, n) { return (!1 !== e.interactive || "group" === e.marktype) && e.bounds && e.bounds.contains(t, n) }(e, c, h) ? this.pick(e, n, r, c, h) : null)), !l && y && (u.fill || !g && u.stroke) && lY(e, u, o, s) && (l = u), e.restore(), l || null) })) }, isect: Fq, content: function (e, t, n) { e("clip-path", t.clip ? JH(n, t, t) : null) }, background: function (e, t) { e("class", "background"), e("aria-hidden", !0), sY(e, t) }, foreground: function (e, t) { e("class", "foreground"), e("aria-hidden", !0), t.strokeForeground ? sY(e, t) : e("d", "") } }, fY = { xmlns: "http://www.w3.org/2000/svg", "xmlns:xlink": "http://www.w3.org/1999/xlink", version: "1.1" }; function pY(e, t) { var n = e.image; return (!n || e.url && e.url !== n.url) && (n = { complete: !1, width: 0, height: 0 }, t.loadImage(e.url).then((t => { e.image = t, e.image.url = e.url }))), n } function mY(e, t) { return null != e.width ? e.width : t && t.width ? !1 !== e.aspect && e.height ? e.height * t.width / t.height : t.width : 0 } function gY(e, t) { return null != e.height ? e.height : t && t.height ? !1 !== e.aspect && e.width ? e.width * t.height / t.width : t.height : 0 } function yY(e, t) { return "center" === e ? t / 2 : "right" === e ? t : 0 } function bY(e, t) { return "middle" === e ? t / 2 : "bottom" === e ? t : 0 } var vY = { type: "image", tag: "image", nested: !1, attr: function (e, t, n) { const r = pY(t, n), i = mY(t, r), a = gY(t, r), o = (t.x || 0) - yY(t.align, i), s = (t.y || 0) - bY(t.baseline, a); e("href", !r.src && r.toDataURL ? r.toDataURL() : r.src || "", fY["xmlns:xlink"], "xlink:href"), e("transform", Jq(o, s)), e("width", i), e("height", a), e("preserveAspectRatio", !1 === t.aspect ? "none" : "xMidYMid") }, bound: function (e, t) { const n = t.image, r = mY(t, n), i = gY(t, n), a = (t.x || 0) - yY(t.align, r), o = (t.y || 0) - bY(t.baseline, i); return e.set(a, o, a + r, o + i) }, draw: function (e, t, n) { Vq(t, (t => { if (n && !n.intersects(t.bounds)) return; const r = pY(t, this); let i = mY(t, r), a = gY(t, r); if (0 === i || 0 === a) return; let o, s, u, l, c = (t.x || 0) - yY(t.align, i), h = (t.y || 0) - bY(t.baseline, a); !1 !== t.aspect && (s = r.width / r.height, u = t.width / t.height, s == s && u == u && s !== u && (u < s ? (l = i / s, h += (a - l) / 2, a = l) : (l = a * s, c += (i - l) / 2, i = l))), (r.complete || r.toDataURL) && (Rq(e, t), e.globalAlpha = null != (o = t.opacity) ? o : 1, e.imageSmoothingEnabled = !1 !== t.smooth, e.drawImage(r, c, h, i, a)) })) }, pick: Xq(), isect: AL, get: pY, xOffset: yY, yOffset: bY }, xY = rY("line", (function (e, t) { const n = t[0], r = n.interpolate || "linear"; return VH.curve(uH(r, n.orient, n.tension)).context(e)(t) }), (function (e, t) { for (var n, r, i = Math.pow(e[0].strokeWidth || 1, 2), a = e.length; --a >= 0;)if (!1 !== e[a].defined && (n = e[a].x - t[0]) * n + (r = e[a].y - t[1]) * r < i) return e[a]; return null })); function wY(e, t) { var n = t.path; if (null == n) return !0; var r = t.x || 0, i = t.y || 0, a = t.scaleX || 1, o = t.scaleY || 1, s = (t.angle || 0) * dH, u = t.pathCache; u && u.path === n || ((t.pathCache = u = hH(n)).path = n), s && e.rotate && e.translate ? (e.translate(r, i), e.rotate(s), kH(e, u, 0, 0, a, o), e.rotate(-s), e.translate(-r, -i)) : kH(e, u, r, i, a, o) } var kY = { type: "path", tag: "path", nested: !1, attr: function (e, t) { var n = t.scaleX || 1, r = t.scaleY || 1; 1 === n && 1 === r || e("vector-effect", "non-scaling-stroke"), e("transform", function (e) { return Jq(e.x || 0, e.y || 0) + (e.angle ? " " + Qq(e.angle) : "") + (e.scaleX || e.scaleY ? " " + function (e, t) { return "scale(" + e + "," + t + ")" }(e.scaleX || 1, e.scaleY || 1) : "") }(t)), e("d", t.path) }, bound: function (e, t) { return wY(Sq(e, t.angle), t) ? e.set(0, 0, 0, 0) : aq(e, t, !0) }, draw: Hq(wY), pick: Zq(wY), isect: Iq(wY) }; function SY(e, t) { e.beginPath(), XH(e, t) } var _Y = { type: "rect", tag: "path", nested: !1, attr: function (e, t) { e("d", XH(null, t)) }, bound: function (e, t) { var n, r; return aq(e.set(n = t.x || 0, r = t.y || 0, n + t.width || 0, r + t.height || 0), t) }, draw: Hq(SY), pick: Zq(SY), isect: Fq }; function CY(e, t, n) { var r, i, a, o; return !(!t.stroke || !jq(e, t, n)) && (r = t.x || 0, i = t.y || 0, a = null != t.x2 ? t.x2 : r, o = null != t.y2 ? t.y2 : i, e.beginPath(), e.moveTo(r, i), e.lineTo(a, o), !0) } var AY = { type: "rule", tag: "line", nested: !1, attr: function (e, t) { e("transform", eY(t)), e("x2", null != t.x2 ? t.x2 - (t.x || 0) : 0), e("y2", null != t.y2 ? t.y2 - (t.y || 0) : 0) }, bound: function (e, t) { var n, r; return aq(e.set(n = t.x || 0, r = t.y || 0, null != t.x2 ? t.x2 : n, null != t.y2 ? t.y2 : r), t) }, draw: function (e, t, n) { Vq(t, (t => { if (!n || n.intersects(t.bounds)) { var r = null == t.opacity ? 1 : t.opacity; r && CY(e, t, r) && (Rq(e, t), e.stroke()) } })) }, pick: Xq((function (e, t, n, r) { return !!e.isPointInStroke && (CY(e, t, 1) && e.isPointInStroke(n, r)) })), isect: Dq }, TY = tY("shape", (function (e, t) { return (t.mark.shape || t.shape).context(e)(t) })), EY = tY("symbol", (function (e, t) { return HH.context(e)(t) }), Mq); const NY = function (e) { let t, n, r; e = +e || 1e4; const i = () => { t = {}, n = {}, r = 0 }, a = (i, a) => (++r > e && (n = t, t = {}, r = 1), t[i] = a); return i(), { clear: i, has: e => RL(t, e) || RL(n, e), get: e => RL(t, e) ? t[e] : RL(n, e) ? a(e, n[e]) : void 0, set: (e, n) => RL(t, e) ? t[e] = n : a(e, n) } }(); var IY = { height: OY, measureWidth: $Y, estimateWidth: FY, width: FY, canvas: MY }; function MY(e) { IY.width = e && Eq ? $Y : FY } function FY(e, t) { return DY(LY(e, t), OY(e)) } function DY(e, t) { return ~~(.8 * e.length * t) } function $Y(e, t) { return OY(e) <= 0 || !(t = LY(e, t)) ? 0 : RY(t, UY(e)) } function RY(e, t) { const n = `(${t}) ${e}`; let r = NY.get(n); return void 0 === r && (Eq.font = t, r = Eq.measureText(e).width, NY.set(n, r)), r } function OY(e) { return null != e.fontSize ? +e.fontSize || 0 : 11 } function zY(e) { return null != e.lineHeight ? e.lineHeight : OY(e) + 2 } function PY(e) { return t = e.lineBreak && e.text && !TL(e.text) ? e.text.split(e.lineBreak) : e.text, TL(t) ? t.length > 1 ? t : t[0] : t; var t } function BY(e) { const t = PY(e); return (TL(t) ? t.length - 1 : 0) * zY(e) } function LY(e, t) { const n = null == t ? "" : (t + "").trim(); return e.limit > 0 && n.length ? function (e, t) { var n = +e.limit, r = function (e) { if (IY.width === $Y) { const t = UY(e); return e => RY(e, t) } { const t = OY(e); return e => DY(e, t) } }(e); if (r(t) < n) return t; var i, a = e.ellipsis || "…", o = "rtl" === e.dir, s = 0, u = t.length; if (n -= r(a), o) { for (; s < u;)i = s + u >>> 1, r(t.slice(i)) > n ? s = i + 1 : u = i; return a + t.slice(s) } for (; s < u;)i = 1 + (s + u >>> 1), r(t.slice(0, i)) < n ? s = i : u = i - 1; return t.slice(0, s) + a }(e, n) : n } function jY(e, t) { var n = e.font; return (t && n ? String(n).replace(/"/g, "'") : n) || "sans-serif" } function UY(e, t) { return (e.fontStyle ? e.fontStyle + " " : "") + (e.fontVariant ? e.fontVariant + " " : "") + (e.fontWeight ? e.fontWeight + " " : "") + OY(e) + "px " + jY(e, t) } function WY(e) { var t = e.baseline, n = OY(e); return Math.round("top" === t ? .79 * n : "middle" === t ? .3 * n : "bottom" === t ? -.21 * n : "line-top" === t ? .29 * n + .5 * zY(e) : "line-bottom" === t ? .29 * n - .5 * zY(e) : 0) } MY(!0); const VY = { left: "start", center: "middle", right: "end" }, GY = new QH; function HY(e) { var t, n = e.x || 0, r = e.y || 0, i = e.radius || 0; return i && (t = (e.theta || 0) - fH, n += i * Math.cos(t), r += i * Math.sin(t)), GY.x1 = n, GY.y1 = r, GY } function qY(e, t, n) { var r, i = IY.height(t), a = t.align, o = HY(t), s = o.x1, u = o.y1, l = t.dx || 0, c = (t.dy || 0) + WY(t) - Math.round(.8 * i), h = PY(t); if (TL(h) ? (i += zY(t) * (h.length - 1), r = h.reduce(((e, n) => Math.max(e, IY.width(t, n))), 0)) : r = IY.width(t, h), "center" === a ? l -= r / 2 : "right" === a && (l -= r), e.set(l += s, c += u, l + r, c + i), t.angle && !n) e.rotate(t.angle * dH, s, u); else if (2 === n) return e.rotatedPoints(t.angle * dH, s, u); return e } var YY = { type: "text", tag: "text", nested: !1, attr: function (e, t) { var n, r = t.dx || 0, i = (t.dy || 0) + WY(t), a = HY(t), o = a.x1, s = a.y1, u = t.angle || 0; e("text-anchor", VY[t.align] || "start"), u ? (n = Jq(o, s) + " " + Qq(u), (r || i) && (n += " " + Jq(r, i))) : n = Jq(o + r, s + i), e("transform", n) }, bound: qY, draw: function (e, t, n) { Vq(t, (t => { var r, i, a, o, s, u, l, c = null == t.opacity ? 1 : t.opacity; if (!(n && !n.intersects(t.bounds) || 0 === c || t.fontSize <= 0 || null == t.text || 0 === t.text.length)) { if (e.font = UY(t), e.textAlign = t.align || "left", i = (r = HY(t)).x1, a = r.y1, t.angle && (e.save(), e.translate(i, a), e.rotate(t.angle * dH), i = a = 0), i += t.dx || 0, a += (t.dy || 0) + WY(t), u = PY(t), Rq(e, t), TL(u)) for (s = zY(t), o = 0; o < u.length; ++o)l = LY(t, u[o]), t.fill && Bq(e, t, c) && e.fillText(l, i, a), t.stroke && jq(e, t, c) && e.strokeText(l, i, a), a += s; else l = LY(t, u), t.fill && Bq(e, t, c) && e.fillText(l, i, a), t.stroke && jq(e, t, c) && e.strokeText(l, i, a); t.angle && e.restore() } })) }, pick: Xq((function (e, t, n, r, i, a) { if (t.fontSize <= 0) return !1; if (!t.angle) return !0; var o = HY(t), s = o.x1, u = o.y1, l = qY(GY, t, 1), c = -t.angle * dH, h = Math.cos(c), d = Math.sin(c), f = h * i - d * a + (s - h * s + d * u), p = d * i + h * a + (u - d * s - h * u); return l.contains(f, p) })), isect: function (e, t) { const n = qY(GY, e, 2); return $q(t, n[0], n[1], n[2], n[3]) || $q(t, n[0], n[1], n[4], n[5]) || $q(t, n[4], n[5], n[6], n[7]) || $q(t, n[2], n[3], n[6], n[7]) } }, XY = rY("trail", (function (e, t) { return qH.context(e)(t) }), (function (e, t) { for (var n, r, i = e.length; --i >= 0;)if (!1 !== e[i].defined && (n = e[i].x - t[0]) * n + (r = e[i].y - t[1]) * r < (n = e[i].size || 1) * n) return e[i]; return null })), KY = { arc: nY, area: iY, group: dY, image: vY, line: xY, path: kY, rect: _Y, rule: AY, shape: TY, symbol: EY, text: YY, trail: XY }; function ZY(e, t, n) { var r = KY[e.mark.marktype], i = t || r.bound; return r.nested && (e = e.mark), i(e.bounds || (e.bounds = new QH), e, n) } var JY = { mark: null }; function QY(e, t, n) { var r, i, a, o, s = KY[e.marktype], u = s.bound, l = e.items, c = l && l.length; if (s.nested) return c ? a = l[0] : (JY.mark = e, a = JY), o = ZY(a, u, n), t = t && t.union(o) || o; if (t = t || e.bounds && e.bounds.clear() || new QH, c) for (r = 0, i = l.length; r < i; ++r)t.union(ZY(l[r], u, n)); return e.bounds = t } const eX = ["marktype", "name", "role", "interactive", "clip", "items", "zindex", "x", "y", "width", "height", "align", "baseline", "fill", "fillOpacity", "opacity", "blend", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeDash", "strokeDashOffset", "strokeForeground", "strokeOffset", "startAngle", "endAngle", "innerRadius", "outerRadius", "cornerRadius", "padAngle", "cornerRadiusTopLeft", "cornerRadiusTopRight", "cornerRadiusBottomLeft", "cornerRadiusBottomRight", "interpolate", "tension", "orient", "defined", "url", "aspect", "smooth", "path", "scaleX", "scaleY", "x2", "y2", "size", "shape", "text", "angle", "theta", "radius", "dir", "dx", "dy", "ellipsis", "limit", "lineBreak", "lineHeight", "font", "fontSize", "fontWeight", "fontStyle", "fontVariant", "description", "aria", "ariaRole", "ariaRoleDescription"]; function tX(e, t) { return JSON.stringify(e, eX, t) } function nX(e) { return rX("string" == typeof e ? JSON.parse(e) : e) } function rX(e) { var t, n, r, i = e.marktype, a = e.items; if (a) for (n = 0, r = a.length; n < r; ++n)t = i ? "mark" : "group", a[n][t] = e, a[n].zindex && (a[n][t].zdirty = !0), "group" === (i || t) && rX(a[n]); return i && QY(e), e } function iX(e) { arguments.length ? this.root = nX(e) : (this.root = aX({ marktype: "group", name: "root", role: "frame" }), this.root.items = [new tq(this.root)]) } function aX(e, t) { const n = { bounds: new QH, clip: !!e.clip, group: t, interactive: !1 !== e.interactive, items: [], marktype: e.marktype, name: e.name || void 0, role: e.role || void 0, zindex: e.zindex || 0 }; return null != e.aria && (n.aria = e.aria), e.description && (n.description = e.description), n } function oX(e, t, n) { return !e && "undefined" != typeof document && document.createElement && (e = document), e ? n ? e.createElementNS(n, t) : e.createElement(t) : null } function sX(e, t) { t = t.toLowerCase(); for (var n = e.childNodes, r = 0, i = n.length; r < i; ++r)if (n[r].tagName.toLowerCase() === t) return n[r] } function uX(e, t, n, r) { var i, a = e.childNodes[t]; return a && a.tagName.toLowerCase() === n.toLowerCase() || (i = a || null, a = oX(e.ownerDocument, n, r), e.insertBefore(a, i)), a } function lX(e, t) { for (var n = e.childNodes, r = n.length; r > t;)e.removeChild(n[--r]); return e } function cX(e) { return "mark-" + e.marktype + (e.role ? " role-" + e.role : "") + (e.name ? " " + e.name : "") } function hX(e, t) { const n = t.getBoundingClientRect(); return [e.clientX - n.left - (t.clientLeft || 0), e.clientY - n.top - (t.clientTop || 0)] } function dX(e, t) { this._active = null, this._handlers = {}, this._loader = e || qU(), this._tooltip = t || fX } function fX(e, t, n, r) { e.element().setAttribute("title", r || "") } function pX(e) { this._el = null, this._bgcolor = null, this._loader = new nq(e) } iX.prototype = { toJSON(e) { return tX(this.root, e || 0) }, mark(e, t, n) { const r = aX(e, t = t || this.root.items[0]); return t.items[n] = r, r.zindex && (r.group.zdirty = !0), r } }, dX.prototype = { initialize(e, t, n) { return this._el = e, this._obj = n || null, this.origin(t) }, element() { return this._el }, canvas() { return this._el && this._el.firstChild }, origin(e) { return arguments.length ? (this._origin = e || [0, 0], this) : this._origin.slice() }, scene(e) { return arguments.length ? (this._scene = e, this) : this._scene }, on() { }, off() { }, _handlerIndex(e, t, n) { for (let r = e ? e.length : 0; --r >= 0;)if (e[r].type === t && (!n || e[r].handler === n)) return r; return -1 }, handlers(e) { const t = this._handlers, n = []; if (e) n.push(...t[this.eventName(e)]); else for (const e in t) n.push(...t[e]); return n }, eventName(e) { const t = e.indexOf("."); return t < 0 ? e : e.slice(0, t) }, handleHref(e, t, n) { this._loader.sanitize(n, { context: "href" }).then((t => { const n = new MouseEvent(e.type, e), r = oX(null, "a"); for (const e in t) r.setAttribute(e, t[e]); r.dispatchEvent(n) })).catch((() => { })) }, handleTooltip(e, t, n) { if (t && null != t.tooltip) { t = function (e, t, n, r) { var i, a, o = e && e.mark; if (o && (i = KY[o.marktype]).tip) { for ((a = hX(t, n))[0] -= r[0], a[1] -= r[1]; e = e.mark.group;)a[0] -= e.x || 0, a[1] -= e.y || 0; e = i.tip(o.items, a) } return e }(t, e, this.canvas(), this._origin); const r = n && t && t.tooltip || null; this._tooltip.call(this._obj, this, e, t, r) } }, getItemBoundingClientRect(e) { const t = this.canvas(); if (!t) return; const n = t.getBoundingClientRect(), r = this._origin, i = e.bounds, a = i.width(), o = i.height(); let s = i.x1 + r[0] + n.left, u = i.y1 + r[1] + n.top; for (; e.mark && (e = e.mark.group);)s += e.x || 0, u += e.y || 0; return { x: s, y: u, width: a, height: o, left: s, top: u, right: s + a, bottom: u + o } } }, pX.prototype = { initialize(e, t, n, r, i) { return this._el = e, this.resize(t, n, r, i) }, element() { return this._el }, canvas() { return this._el && this._el.firstChild }, background(e) { return 0 === arguments.length ? this._bgcolor : (this._bgcolor = e, this) }, resize(e, t, n, r) { return this._width = e, this._height = t, this._origin = n || [0, 0], this._scale = r || 1, this }, dirty() { }, render(e) { const t = this; return t._call = function () { t._render(e) }, t._call(), t._call = null, t }, _render() { }, renderAsync(e) { const t = this.render(e); return this._ready ? this._ready.then((() => t)) : Promise.resolve(t) }, _load(e, t) { var n = this, r = n._loader[e](t); if (!n._ready) { const e = n._call; n._ready = n._loader.ready().then((t => { t && e(), n._ready = null })) } return r }, sanitizeURL(e) { return this._load("sanitizeURL", e) }, loadImage(e) { return this._load("loadImage", e) } }; const mX = "dragenter", gX = "dragleave", yX = "dragover", bX = "mousedown", vX = "mousemove", xX = "mouseout", wX = "mouseover", kX = "click", SX = "mousewheel", _X = "touchstart", CX = "touchmove", AX = "touchend", TX = ["keydown", "keypress", "keyup", mX, gX, yX, bX, "mouseup", vX, xX, wX, kX, "dblclick", "wheel", SX, _X, CX, AX], EX = vX, NX = xX, IX = kX; function MX(e, t) { dX.call(this, e, t), this._down = null, this._touch = null, this._first = !0, this._events = {} } function FX(e, t) { (e => e === _X || e === CX || e === AX ? [_X, CX, AX] : [e])(t).forEach((t => function (e, t) { const n = e.canvas(); n && !e._events[t] && (e._events[t] = 1, n.addEventListener(t, e[t] ? n => e[t](n) : n => e.fire(t, n))) }(e, t))) } function DX(e, t, n) { return function (r) { const i = this._active, a = this.pickEvent(r); a === i || (i && i.exit || this.fire(n, r), this._active = a, this.fire(t, r)), this.fire(e, r) } } function $X(e) { return function (t) { this.fire(e, t), this._active = null } } OL(MX, dX, { initialize(e, t, n) { return this._canvas = e && sX(e, "canvas"), [kX, bX, vX, xX, gX].forEach((e => FX(this, e))), dX.prototype.initialize.call(this, e, t, n) }, canvas() { return this._canvas }, context() { return this._canvas.getContext("2d") }, events: TX, DOMMouseScroll(e) { this.fire(SX, e) }, mousemove: DX(vX, wX, xX), dragover: DX(yX, mX, gX), mouseout: $X(xX), dragleave: $X(gX), mousedown(e) { this._down = this._active, this.fire(bX, e) }, click(e) { this._down === this._active && (this.fire(kX, e), this._down = null) }, touchstart(e) { this._touch = this.pickEvent(e.changedTouches[0]), this._first && (this._active = this._touch, this._first = !1), this.fire(_X, e, !0) }, touchmove(e) { this.fire(CX, e, !0) }, touchend(e) { this.fire(AX, e, !0), this._touch = null }, fire(e, t, n) { const r = n ? this._touch : this._active, i = this._handlers[e]; if (t.vegaType = e, e === IX && r && r.href ? this.handleHref(t, r, r.href) : e !== EX && e !== NX || this.handleTooltip(t, r, e !== NX), i) for (let e = 0, n = i.length; e < n; ++e)i[e].handler.call(this._obj, t, r) }, on(e, t) { const n = this.eventName(e), r = this._handlers; return this._handlerIndex(r[n], e, t) < 0 && (FX(this, e), (r[n] || (r[n] = [])).push({ type: e, handler: t })), this }, off(e, t) { const n = this.eventName(e), r = this._handlers[n], i = this._handlerIndex(r, e, t); return i >= 0 && r.splice(i, 1), this }, pickEvent(e) { const t = hX(e, this._canvas), n = this._origin; return this.pick(this._scene, t[0], t[1], t[0] - n[0], t[1] - n[1]) }, pick(e, t, n, r, i) { const a = this.context(); return KY[e.marktype].pick.call(this, a, e, t, n, r, i) } }); var RX = "undefined" != typeof window && window.devicePixelRatio || 1; function OX(e) { pX.call(this, e), this._options = {}, this._redraw = !1, this._dirty = new QH, this._tempb = new QH } const zX = pX.prototype; function PX(e, t) { dX.call(this, e, t); const n = this; n._hrefHandler = BX(n, ((e, t) => { t && t.href && n.handleHref(e, t, t.href) })), n._tooltipHandler = BX(n, ((e, t) => { n.handleTooltip(e, t, e.type !== NX) })) } OL(OX, pX, { initialize(e, t, n, r, i, a) { return this._options = a || {}, this._canvas = this._options.externalContext ? null : Fd(1, 1, this._options.type), e && this._canvas && (lX(e, 0).appendChild(this._canvas), this._canvas.setAttribute("class", "marks")), zX.initialize.call(this, e, t, n, r, i) }, resize(e, t, n, r) { if (zX.resize.call(this, e, t, n, r), this._canvas) !function (e, t, n, r, i, a) { const o = "undefined" != typeof HTMLElement && e instanceof HTMLElement && null != e.parentNode, s = e.getContext("2d"), u = o ? RX : i; e.width = t * u, e.height = n * u; for (const e in a) s[e] = a[e]; o && 1 !== u && (e.style.width = t + "px", e.style.height = n + "px"), s.pixelRatio = u, s.setTransform(u, 0, 0, u, u * r[0], u * r[1]) }(this._canvas, this._width, this._height, this._origin, this._scale, this._options.context); else { const e = this._options.externalContext; e || kL("CanvasRenderer is missing a valid canvas or context"), e.scale(this._scale, this._scale), e.translate(this._origin[0], this._origin[1]) } return this._redraw = !0, this }, canvas() { return this._canvas }, context() { return this._options.externalContext || (this._canvas ? this._canvas.getContext("2d") : null) }, dirty(e) { const t = this._tempb.clear().union(e.bounds); let n = e.mark.group; for (; n;)t.translate(n.x || 0, n.y || 0), n = n.mark.group; this._dirty.union(t) }, _render(e) { const t = this.context(), n = this._origin, r = this._width, i = this._height, a = this._dirty, o = ((e, t, n) => (new QH).set(0, 0, t, n).translate(-e[0], -e[1]))(n, r, i); t.save(); const s = this._redraw || a.empty() ? (this._redraw = !1, o.expand(1)) : function (e, t, n) { return t.expand(1).round(), e.pixelRatio % 1 && t.scale(e.pixelRatio).round().scale(1 / e.pixelRatio), t.translate(-n[0] % 1, -n[1] % 1), e.beginPath(), e.rect(t.x1, t.y1, t.width(), t.height()), e.clip(), t }(t, o.intersect(a), n); return this.clear(-n[0], -n[1], r, i), this.draw(t, e, s), t.restore(), a.clear(), this }, draw(e, t, n) { const r = KY[t.marktype]; t.clip && function (e, t) { var n = t.clip; e.save(), FL(n) ? (e.beginPath(), n(e), e.clip()) : aY(e, t.group) }(e, t), r.draw.call(this, e, t, n), t.clip && e.restore() }, clear(e, t, n, r) { const i = this._options, a = this.context(); "pdf" === i.type || i.externalContext || a.clearRect(e, t, n, r), null != this._bgcolor && (a.fillStyle = this._bgcolor, a.fillRect(e, t, n, r)) } }); const BX = (e, t) => n => { let r = n.target.__data__; r = Array.isArray(r) ? r[0] : r, n.vegaType = n.type, t.call(e._obj, n, r) }; OL(PX, dX, { initialize(e, t, n) { let r = this._svg; return r && (r.removeEventListener(IX, this._hrefHandler), r.removeEventListener(EX, this._tooltipHandler), r.removeEventListener(NX, this._tooltipHandler)), this._svg = r = e && sX(e, "svg"), r && (r.addEventListener(IX, this._hrefHandler), r.addEventListener(EX, this._tooltipHandler), r.addEventListener(NX, this._tooltipHandler)), dX.prototype.initialize.call(this, e, t, n) }, canvas() { return this._svg }, on(e, t) { const n = this.eventName(e), r = this._handlers; if (this._handlerIndex(r[n], e, t) < 0) { const i = { type: e, handler: t, listener: BX(this, t) }; (r[n] || (r[n] = [])).push(i), this._svg && this._svg.addEventListener(n, i.listener) } return this }, off(e, t) { const n = this.eventName(e), r = this._handlers[n], i = this._handlerIndex(r, e, t); return i >= 0 && (this._svg && this._svg.removeEventListener(n, r[i].listener), r.splice(i, 1)), this } }); const LX = "aria-hidden", jX = "aria-label", UX = "role", WX = "aria-roledescription", VX = "graphics-object", GX = "graphics-symbol", HX = (e, t, n) => ({ [UX]: e, [WX]: t, [jX]: n || void 0 }), qX = LL(["axis-domain", "axis-grid", "axis-label", "axis-tick", "axis-title", "legend-band", "legend-entry", "legend-gradient", "legend-label", "legend-title", "legend-symbol", "title"]), YX = { axis: { desc: "axis", caption: function (e) { const t = e.datum, n = e.orient, r = t.title ? QX(e) : null, i = e.context, a = i.scales[t.scale].value, o = i.dataflow.locale(), s = a.type, u = "left" === n || "right" === n ? "Y" : "X"; return `${u}-axis` + (r ? ` titled '${r}'` : "") + ` for a ${FG(s) ? "discrete" : s} scale` + ` with ${eH(o, a, e)}` } }, legend: { desc: "legend", caption: function (e) { const t = e.datum, n = t.title ? QX(e) : null, r = `${t.type || ""} legend`.trim(), i = t.scales, a = Object.keys(i), o = e.context, s = o.scales[i[a[0]]].value, u = o.dataflow.locale(); return function (e) { return e.length ? e[0].toUpperCase() + e.slice(1) : e }(r) + (n ? ` titled '${n}'` : "") + ` for ${function (e) { return e = e.map((e => e + ("fill" === e || "stroke" === e ? " color" : ""))), e.length < 2 ? e[0] : e.slice(0, -1).join(", ") + " and " + NL(e) }(a)}` + ` with ${eH(u, s, e)}` } }, "title-text": { desc: "title", caption: e => `Title text '${JX(e)}'` }, "title-subtitle": { desc: "subtitle", caption: e => `Subtitle text '${JX(e)}'` } }, XX = { ariaRole: UX, ariaRoleDescription: WX, description: jX }; function KX(e, t) { const n = !1 === t.aria; if (e(LX, n || void 0), n || null == t.description) for (const t in XX) e(XX[t], void 0); else { const n = t.mark.marktype; e(jX, t.description), e(UX, t.ariaRole || ("group" === n ? VX : GX)), e(WX, t.ariaRoleDescription || `${n} mark`) } } function ZX(e) { return !1 === e.aria ? { [LX]: !0 } : qX[e.role] ? null : YX[e.role] ? function (e, t) { try { const n = e.items[0], r = t.caption || (() => ""); return HX(t.role || GX, t.desc, n.description || r(n)) } catch (e) { return null } }(e, YX[e.role]) : function (e) { const t = e.marktype, n = "group" === t || "text" === t || e.items.some((e => null != e.description && !1 !== e.aria)); return HX(n ? VX : GX, `${t} mark container`, e.description) }(e) } function JX(e) { return ML(e.text).join(" ") } function QX(e) { try { return ML(NL(e.items).items[0].text).join(" ") } catch (e) { return null } } const eK = e => (e + "").replace(/&/g, "&").replace(//g, ">"), tK = e => eK(e).replace(/"/g, """).replace(/\t/g, " ").replace(/\n/g, " ").replace(/\r/g, " "); function nK() { let e = "", t = "", n = ""; const r = [], i = () => t = n = "", a = (e, n) => (null != n && (t += ` ${e}="${tK(n)}"`), o), o = { open(s, ...u) { (a => { t && (e += `${t}>${n}`, i()), r.push(a) })(s), t = "<" + s; for (const e of u) for (const t in e) a(t, e[t]); return o }, close() { const a = r.pop(); return e += t ? t + (n ? `>${n}` : "/>") : ``, i(), o }, attr: a, text: e => (n += eK(e), o), toString: () => e }; return o } const rK = e => iK(nK(), e) + ""; function iK(e, t) { if (e.open(t.tagName), t.hasAttributes()) { const n = t.attributes, r = n.length; for (let t = 0; t < r; ++t)e.attr(n[t].name, n[t].value) } if (t.hasChildNodes()) { const n = t.childNodes, r = n.length; for (let t = 0; t < r; t++) { const r = n[t]; 3 === r.nodeType ? e.text(r.nodeValue) : iK(e, r) } } return e.close() } const aK = { fill: "fill", fillOpacity: "fill-opacity", stroke: "stroke", strokeOpacity: "stroke-opacity", strokeWidth: "stroke-width", strokeCap: "stroke-linecap", strokeJoin: "stroke-linejoin", strokeDash: "stroke-dasharray", strokeDashOffset: "stroke-dashoffset", strokeMiterLimit: "stroke-miterlimit", opacity: "opacity", blend: "mix-blend-mode" }, oK = { fill: "none", "stroke-miterlimit": 10 }, sK = "http://www.w3.org/2000/xmlns/", uK = fY.xmlns; function lK(e) { pX.call(this, e), this._dirtyID = 0, this._dirty = [], this._svg = null, this._root = null, this._defs = null } const cK = pX.prototype; function hK(e, t) { for (; e && e.dirty !== t; e = e.mark.group) { if (e.dirty = t, !e.mark || e.mark.dirty === t) return; e.mark.dirty = t } } function dK(e, t, n) { let r, i, a; if ("radial" === t.gradient) { let r = uX(e, n++, "pattern", uK); xK(r, { id: nH + t.id, viewBox: "0,0,1,1", width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }), r = uX(r, 0, "rect", uK), xK(r, { width: 1, height: 1, fill: `url(${kK()}#${t.id})` }), xK(e = uX(e, n++, "radialGradient", uK), { id: t.id, fx: t.x1, fy: t.y1, fr: t.r1, cx: t.x2, cy: t.y2, r: t.r2 }) } else xK(e = uX(e, n++, "linearGradient", uK), { id: t.id, x1: t.x1, x2: t.x2, y1: t.y1, y2: t.y2 }); for (r = 0, i = t.stops.length; r < i; ++r)a = uX(e, r, "stop", uK), a.setAttribute("offset", t.stops[r].offset), a.setAttribute("stop-color", t.stops[r].color); return lX(e, r), n } function fK(e, t, n) { let r; return (e = uX(e, n, "clipPath", uK)).setAttribute("id", t.id), t.path ? (r = uX(e, 0, "path", uK), r.setAttribute("d", t.path)) : (r = uX(e, 0, "rect", uK), xK(r, { x: 0, y: 0, width: t.width, height: t.height })), lX(e, 1), n + 1 } function pK(e, t, n, r, i) { let a, o = e._svg; if (!o && (a = t.ownerDocument, o = oX(a, r, uK), e._svg = o, e.mark && (o.__data__ = e, o.__values__ = { fill: "default" }, "g" === r))) { const t = oX(a, "path", uK); o.appendChild(t), t.__data__ = e; const n = oX(a, "g", uK); o.appendChild(n), n.__data__ = e; const r = oX(a, "path", uK); o.appendChild(r), r.__data__ = e, r.__values__ = { fill: "default" } } return (o.ownerSVGElement !== i || function (e, t) { return e.parentNode && e.parentNode.childNodes.length > 1 && e.previousSibling != t }(o, n)) && t.insertBefore(o, n ? n.nextSibling : t.firstChild), o } OL(lK, pX, { initialize(e, t, n, r, i) { return this._defs = {}, this._clearDefs(), e && (this._svg = uX(e, 0, "svg", uK), this._svg.setAttributeNS(sK, "xmlns", uK), this._svg.setAttributeNS(sK, "xmlns:xlink", fY["xmlns:xlink"]), this._svg.setAttribute("version", fY.version), this._svg.setAttribute("class", "marks"), lX(e, 1), this._root = uX(this._svg, 0, "g", uK), xK(this._root, oK), lX(this._svg, 1)), this.background(this._bgcolor), cK.initialize.call(this, e, t, n, r, i) }, background(e) { return arguments.length && this._svg && this._svg.style.setProperty("background-color", e), cK.background.apply(this, arguments) }, resize(e, t, n, r) { return cK.resize.call(this, e, t, n, r), this._svg && (xK(this._svg, { width: this._width * this._scale, height: this._height * this._scale, viewBox: `0 0 ${this._width} ${this._height}` }), this._root.setAttribute("transform", `translate(${this._origin})`)), this._dirty = [], this }, canvas() { return this._svg }, svg() { const e = this._svg, t = this._bgcolor; if (!e) return null; let n; t && (e.removeAttribute("style"), n = uX(e, 0, "rect", uK), xK(n, { width: this._width, height: this._height, fill: t })); const r = rK(e); return t && (e.removeChild(n), this._svg.style.setProperty("background-color", t)), r }, _render(e) { return this._dirtyCheck() && (this._dirtyAll && this._clearDefs(), this.mark(this._root, e), lX(this._root, 1)), this.defs(), this._dirty = [], ++this._dirtyID, this }, dirty(e) { e.dirty !== this._dirtyID && (e.dirty = this._dirtyID, this._dirty.push(e)) }, isDirty(e) { return this._dirtyAll || !e._svg || e.dirty === this._dirtyID }, _dirtyCheck() { this._dirtyAll = !0; const e = this._dirty; if (!e.length || !this._dirtyID) return !0; const t = ++this._dirtyID; let n, r, i, a, o, s, u; for (o = 0, s = e.length; o < s; ++o)n = e[o], r = n.mark, r.marktype !== i && (i = r.marktype, a = KY[i]), r.zdirty && r.dirty !== t && (this._dirtyAll = !1, hK(n, t), r.items.forEach((e => { e.dirty = t }))), r.zdirty || (n.exit ? (a.nested && r.items.length ? (u = r.items[0], u._svg && this._update(a, u._svg, u)) : n._svg && (u = n._svg.parentNode, u && u.removeChild(n._svg)), n._svg = null) : (n = a.nested ? r.items[0] : n, n._update !== t && (n._svg && n._svg.ownerSVGElement ? this._update(a, n._svg, n) : (this._dirtyAll = !1, hK(n, t)), n._update = t))); return !this._dirtyAll }, mark(e, t, n) { if (!this.isDirty(t)) return t._svg; const r = this._svg, i = KY[t.marktype], a = !1 === t.interactive ? "none" : null, o = "g" === i.tag; let s = null, u = 0; const l = pK(t, e, n, "g", r); l.setAttribute("class", cX(t)); const c = ZX(t); for (const e in c) wK(l, e, c[e]); o || wK(l, "pointer-events", a), wK(l, "clip-path", t.clip ? JH(this, t, t.group) : null); const h = e => { const t = this.isDirty(e), n = pK(e, l, s, i.tag, r); t && (this._update(i, n, e), o && function (e, t, n) { t = t.lastChild.previousSibling; let r, i = 0; Vq(n, (n => { r = e.mark(t, n, r), ++i })), lX(t, 1 + i) }(this, n, e)), s = n, ++u }; return i.nested ? t.items.length && h(t.items[0]) : Vq(t, h), lX(l, u), l }, _update(e, t, n) { mK = t, gK = t.__values__, KX(bK, n), e.attr(bK, n, this); const r = yK[e.type]; r && r.call(this, e, t, n), mK && this.style(mK, n) }, style(e, t) { if (null != t) for (const n in aK) { let r = "font" === n ? jY(t) : t[n]; if (r === gK[n]) continue; const i = aK[n]; null == r ? e.removeAttribute(i) : (rH(r) && (r = iH(r, this._defs.gradient, kK())), e.setAttribute(i, r + "")), gK[n] = r } }, defs() { const e = this._svg, t = this._defs; let n = t.el, r = 0; for (const i in t.gradient) n || (t.el = n = uX(e, 1, "defs", uK)), r = dK(n, t.gradient[i], r); for (const i in t.clipping) n || (t.el = n = uX(e, 1, "defs", uK)), r = fK(n, t.clipping[i], r); n && (0 === r ? (e.removeChild(n), t.el = null) : lX(n, r)) }, _clearDefs() { const e = this._defs; e.gradient = {}, e.clipping = {} } }); let mK = null, gK = null; const yK = { group(e, t, n) { const r = mK = t.childNodes[2]; gK = r.__values__, e.foreground(bK, n, this), gK = t.__values__, mK = t.childNodes[1], e.content(bK, n, this); const i = mK = t.childNodes[0]; e.background(bK, n, this); const a = !1 === n.mark.interactive ? "none" : null; if (a !== gK.events && (wK(r, "pointer-events", a), wK(i, "pointer-events", a), gK.events = a), n.strokeForeground && n.stroke) { const e = n.fill; wK(r, "display", null), this.style(i, n), wK(i, "stroke", null), e && (n.fill = null), gK = r.__values__, this.style(r, n), e && (n.fill = e), mK = null } else wK(r, "display", "none") }, image(e, t, n) { !1 === n.smooth ? (vK(t, "image-rendering", "optimizeSpeed"), vK(t, "image-rendering", "pixelated")) : vK(t, "image-rendering", null) }, text(e, t, n) { const r = PY(n); let i, a, o, s; TL(r) ? (a = r.map((e => LY(n, e))), i = a.join("\n"), i !== gK.text && (lX(t, 0), o = t.ownerDocument, s = zY(n), a.forEach(((e, r) => { const i = oX(o, "tspan", uK); i.__data__ = n, i.textContent = e, r && (i.setAttribute("x", 0), i.setAttribute("dy", s)), t.appendChild(i) })), gK.text = i)) : (a = LY(n, r), a !== gK.text && (t.textContent = a, gK.text = a)), wK(t, "font-family", jY(n)), wK(t, "font-size", OY(n) + "px"), wK(t, "font-style", n.fontStyle), wK(t, "font-variant", n.fontVariant), wK(t, "font-weight", n.fontWeight) } }; function bK(e, t, n) { t !== gK[e] && (n ? function (e, t, n, r) { null != n ? e.setAttributeNS(r, t, n) : e.removeAttributeNS(r, t) }(mK, e, t, n) : wK(mK, e, t), gK[e] = t) } function vK(e, t, n) { n !== gK[t] && (null == n ? e.style.removeProperty(t) : e.style.setProperty(t, n + ""), gK[t] = n) } function xK(e, t) { for (const n in t) wK(e, n, t[n]) } function wK(e, t, n) { null != n ? e.setAttribute(t, n) : e.removeAttribute(t) } function kK() { let e; return "undefined" == typeof window ? "" : (e = window.location).hash ? e.href.slice(0, -e.hash.length) : e.href } function SK(e) { pX.call(this, e), this._text = null, this._defs = { gradient: {}, clipping: {} } } OL(SK, pX, { svg() { return this._text }, _render(e) { const t = nK(); t.open("svg", DL({}, fY, { class: "marks", width: this._width * this._scale, height: this._height * this._scale, viewBox: `0 0 ${this._width} ${this._height}` })); const n = this._bgcolor; return n && "transparent" !== n && "none" !== n && t.open("rect", { width: this._width, height: this._height, fill: n }).close(), t.open("g", oK, { transform: "translate(" + this._origin + ")" }), this.mark(t, e), t.close(), this.defs(t), this._text = t.close() + "", this }, mark(e, t) { const n = KY[t.marktype], r = n.tag, i = [KX, n.attr]; e.open("g", { class: cX(t), "clip-path": t.clip ? JH(this, t, t.group) : null }, ZX(t), { "pointer-events": "g" !== r && !1 === t.interactive ? "none" : null }); const a = a => { const o = this.href(a); if (o && e.open("a", o), e.open(r, this.attr(t, a, i, "g" !== r ? r : null)), "text" === r) { const t = PY(a); if (TL(t)) { const n = { x: 0, dy: zY(a) }; for (let r = 0; r < t.length; ++r)e.open("tspan", r ? n : null).text(LY(a, t[r])).close() } else e.text(LY(a, t)) } else if ("g" === r) { const r = a.strokeForeground, i = a.fill, o = a.stroke; r && o && (a.stroke = null), e.open("path", this.attr(t, a, n.background, "bgrect")).close(), e.open("g", this.attr(t, a, n.content)), Vq(a, (t => this.mark(e, t))), e.close(), r && o ? (i && (a.fill = null), a.stroke = o, e.open("path", this.attr(t, a, n.foreground, "bgrect")).close(), i && (a.fill = i)) : e.open("path", this.attr(t, a, n.foreground, "bgfore")).close() } e.close(), o && e.close() }; return n.nested ? t.items && t.items.length && a(t.items[0]) : Vq(t, a), e.close() }, href(e) { const t = e.href; let n; if (t) { if (n = this._hrefs && this._hrefs[t]) return n; this.sanitizeURL(t).then((e => { e["xlink:href"] = e.href, e.href = null, (this._hrefs || (this._hrefs = {}))[t] = e })) } return null }, attr(e, t, n, r) { const i = {}, a = (e, t, n, r) => { i[r || e] = t }; return Array.isArray(n) ? n.forEach((e => e(a, t, this))) : n(a, t, this), r && function (e, t, n, r, i) { if (null == t) return e; "bgrect" === r && !1 === n.interactive && (e["pointer-events"] = "none"); if ("bgfore" === r && (!1 === n.interactive && (e["pointer-events"] = "none"), e.display = "none", null !== t.fill)) return e; "image" === r && !1 === t.smooth && (e.style = "image-rendering: optimizeSpeed; image-rendering: pixelated;"); "text" === r && (e["font-family"] = jY(t), e["font-size"] = OY(t) + "px", e["font-style"] = t.fontStyle, e["font-variant"] = t.fontVariant, e["font-weight"] = t.fontWeight); for (const n in aK) { let r = t[n]; const a = aK[n]; ("transparent" !== r || "fill" !== a && "stroke" !== a) && null != r && (rH(r) && (r = iH(r, i.gradient, "")), e[a] = r) } }(i, t, e, r, this._defs), i }, defs(e) { const t = this._defs.gradient, n = this._defs.clipping; if (0 !== Object.keys(t).length + Object.keys(n).length) { e.open("defs"); for (const n in t) { const r = t[n], i = r.stops; "radial" === r.gradient ? (e.open("pattern", { id: nH + n, viewBox: "0,0,1,1", width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }), e.open("rect", { width: "1", height: "1", fill: "url(#" + n + ")" }).close(), e.close(), e.open("radialGradient", { id: n, fx: r.x1, fy: r.y1, fr: r.r1, cx: r.x2, cy: r.y2, r: r.r2 })) : e.open("linearGradient", { id: n, x1: r.x1, x2: r.x2, y1: r.y1, y2: r.y2 }); for (let t = 0; t < i.length; ++t)e.open("stop", { offset: i[t].offset, "stop-color": i[t].color }).close(); e.close() } for (const t in n) { const r = n[t]; e.open("clipPath", { id: t }), r.path ? e.open("path", { d: r.path }).close() : e.open("rect", { x: 0, y: 0, width: r.width, height: r.height }).close(), e.close() } e.close() } } }); const _K = "canvas", CK = "none", AK = { Canvas: _K, PNG: "png", SVG: "svg", None: CK }, TK = {}; function EK(e, t) { return e = String(e || "").toLowerCase(), arguments.length > 1 ? (TK[e] = t, this) : TK[e] } function NK(e, t, n) { const r = [], i = (new QH).union(t), a = e.marktype; return a ? IK(e, i, n, r) : "group" === a ? MK(e, i, n, r) : kL("Intersect scene must be mark node or group item.") } function IK(e, t, n, r) { if (function (e, t, n) { return e.bounds && t.intersects(e.bounds) && ("group" === e.marktype || !1 !== e.interactive && (!n || n(e))) }(e, t, n)) { const i = e.items, a = e.marktype, o = i.length; let s = 0; if ("group" === a) for (; s < o; ++s)MK(i[s], t, n, r); else for (const e = KY[a].isect; s < o; ++s) { const n = i[s]; FK(n, t, e) && r.push(n) } } return r } function MK(e, t, n, r) { n && n(e.mark) && FK(e, t, KY.group.isect) && r.push(e); const i = e.items, a = i && i.length; if (a) { const o = e.x || 0, s = e.y || 0; t.translate(-o, -s); for (let e = 0; e < a; ++e)IK(i[e], t, n, r); t.translate(o, s) } return r } function FK(e, t, n) { const r = e.bounds; return t.encloses(r) || t.intersects(r) && n(e, t) } TK[_K] = TK.png = { renderer: OX, headless: OX, handler: MX }, TK.svg = { renderer: lK, headless: SK, handler: PX }, TK[CK] = {}; const DK = new QH; function $K(e) { const t = e.clip; if (FL(t)) t(Sq(DK.clear())); else { if (!t) return; DK.set(0, 0, e.group.width, e.group.height) } e.bounds.intersect(DK) } const RK = 1e-9; function OK(e, t, n) { return e === t || ("path" === n ? zK(e, t) : e instanceof Date && t instanceof Date ? +e == +t : zL(e) && zL(t) ? Math.abs(e - t) <= RK : e && t && (EL(e) || EL(t)) ? function (e, t) { var n, r, i = Object.keys(e), a = Object.keys(t); if (i.length !== a.length) return !1; for (i.sort(), a.sort(), r = i.length - 1; r >= 0; r--)if (i[r] != a[r]) return !1; for (r = i.length - 1; r >= 0; r--)if (!OK(e[n = i[r]], t[n], n)) return !1; return typeof e == typeof t }(e, t) : e == t) } function zK(e, t) { return OK(hH(e), hH(t)) } function PK() { ZH(), tH = 0 } function BK(e, t, n) { return e.fields = t || [], e.fname = n, e } function LK(e) { return 1 === e.length ? jK(e[0]) : UK(e) } const jK = e => function (t) { return t[e] }, UK = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function WK(e) { throw Error(e) } function VK(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || WK("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && WK("Access path missing closing bracket: " + e), o && WK("Access path missing closing quote: " + e), i > r && (i++, l()), t } function GK(e, t, n) { const r = VK(e); return e = 1 === r.length ? r[0] : e, BK((n && n.get || LK)(r), [e], t || e) } GK("id"), BK((e => e), [], "identity"), BK((() => 0), [], "zero"), BK((() => 1), [], "one"), BK((() => !0), [], "true"), BK((() => !1), [], "false"); var HK = Array.isArray; function qK(e) { return e[e.length - 1] } function YK(e) { return null == e || "" === e ? null : +e } function XK(e) { return null != e ? HK(e) ? e : [e] : [] } const KK = Object.prototype.hasOwnProperty; function ZK(e, t) { return KK.call(e, t) } function JK(e, t) { switch (arguments.length) { case 0: break; case 1: this.range(e); break; default: this.range(t).domain(e) }return this } function QK(e, t) { switch (arguments.length) { case 0: break; case 1: "function" == typeof e ? this.interpolator(e) : this.range(e); break; default: this.domain(e), "function" == typeof t ? this.interpolator(t) : this.range(t) }return this } const eZ = Symbol("implicit"); function tZ() { var e = new Map, t = [], n = [], r = eZ; function i(i) { var a = i + "", o = e.get(a); if (!o) { if (r !== eZ) return r; e.set(a, o = t.push(i)) } return n[(o - 1) % n.length] } return i.domain = function (n) { if (!arguments.length) return t.slice(); t = [], e = new Map; for (const r of n) { const n = r + ""; e.has(n) || e.set(n, t.push(r)) } return i }, i.range = function (e) { return arguments.length ? (n = Array.from(e), i) : n.slice() }, i.unknown = function (e) { return arguments.length ? (r = e, i) : r }, i.copy = function () { return tZ(t, n).unknown(r) }, JK.apply(i, arguments), i } var nZ, rZ = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; function iZ(e) { if (!(t = rZ.exec(e))) throw new Error("invalid format: " + e); var t; return new aZ({ fill: t[1], align: t[2], sign: t[3], symbol: t[4], zero: t[5], width: t[6], comma: t[7], precision: t[8] && t[8].slice(1), trim: t[9], type: t[10] }) } function aZ(e) { this.fill = void 0 === e.fill ? " " : e.fill + "", this.align = void 0 === e.align ? ">" : e.align + "", this.sign = void 0 === e.sign ? "-" : e.sign + "", this.symbol = void 0 === e.symbol ? "" : e.symbol + "", this.zero = !!e.zero, this.width = void 0 === e.width ? void 0 : +e.width, this.comma = !!e.comma, this.precision = void 0 === e.precision ? void 0 : +e.precision, this.trim = !!e.trim, this.type = void 0 === e.type ? "" : e.type + "" } function oZ(e, t) { if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null; var n, r = e.slice(0, n); return [r.length > 1 ? r[0] + r.slice(2) : r, +e.slice(n + 1)] } function sZ(e) { return (e = oZ(Math.abs(e))) ? e[1] : NaN } function uZ(e, t) { var n = oZ(e, t); if (!n) return e + ""; var r = n[0], i = n[1]; return i < 0 ? "0." + new Array(-i).join("0") + r : r.length > i + 1 ? r.slice(0, i + 1) + "." + r.slice(i + 1) : r + new Array(i - r.length + 2).join("0") } iZ.prototype = aZ.prototype, aZ.prototype.toString = function () { return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (void 0 === this.width ? "" : Math.max(1, 0 | this.width)) + (this.comma ? "," : "") + (void 0 === this.precision ? "" : "." + Math.max(0, 0 | this.precision)) + (this.trim ? "~" : "") + this.type }; const lZ = { "%": (e, t) => (100 * e).toFixed(t), b: e => Math.round(e).toString(2), c: e => e + "", d: function (e) { return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10) }, e: (e, t) => e.toExponential(t), f: (e, t) => e.toFixed(t), g: (e, t) => e.toPrecision(t), o: e => Math.round(e).toString(8), p: (e, t) => uZ(100 * e, t), r: uZ, s: function (e, t) { var n = oZ(e, t); if (!n) return e + ""; var r = n[0], i = n[1], a = i - (nZ = 3 * Math.max(-8, Math.min(8, Math.floor(i / 3)))) + 1, o = r.length; return a === o ? r : a > o ? r + new Array(a - o + 1).join("0") : a > 0 ? r.slice(0, a) + "." + r.slice(a) : "0." + new Array(1 - a).join("0") + oZ(e, Math.max(0, t + a - 1))[0] }, X: e => Math.round(e).toString(16).toUpperCase(), x: e => Math.round(e).toString(16) }; function cZ(e) { return e } var hZ, dZ, fZ, pZ = Array.prototype.map, mZ = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; function gZ(e) { var t, n, r = void 0 === e.grouping || void 0 === e.thousands ? cZ : (t = pZ.call(e.grouping, Number), n = e.thousands + "", function (e, r) { for (var i = e.length, a = [], o = 0, s = t[0], u = 0; i > 0 && s > 0 && (u + s + 1 > r && (s = Math.max(1, r - u)), a.push(e.substring(i -= s, i + s)), !((u += s + 1) > r));)s = t[o = (o + 1) % t.length]; return a.reverse().join(n) }), i = void 0 === e.currency ? "" : e.currency[0] + "", a = void 0 === e.currency ? "" : e.currency[1] + "", o = void 0 === e.decimal ? "." : e.decimal + "", s = void 0 === e.numerals ? cZ : function (e) { return function (t) { return t.replace(/[0-9]/g, (function (t) { return e[+t] })) } }(pZ.call(e.numerals, String)), u = void 0 === e.percent ? "%" : e.percent + "", l = void 0 === e.minus ? "−" : e.minus + "", c = void 0 === e.nan ? "NaN" : e.nan + ""; function h(e) { var t = (e = iZ(e)).fill, n = e.align, h = e.sign, d = e.symbol, f = e.zero, p = e.width, m = e.comma, g = e.precision, y = e.trim, b = e.type; "n" === b ? (m = !0, b = "g") : lZ[b] || (void 0 === g && (g = 12), y = !0, b = "g"), (f || "0" === t && "=" === n) && (f = !0, t = "0", n = "="); var v = "$" === d ? i : "#" === d && /[boxX]/.test(b) ? "0" + b.toLowerCase() : "", x = "$" === d ? a : /[%p]/.test(b) ? u : "", w = lZ[b], k = /[defgprs%]/.test(b); function S(e) { var i, a, u, d = v, S = x; if ("c" === b) S = w(e) + S, e = ""; else { var _ = (e = +e) < 0 || 1 / e < 0; if (e = isNaN(e) ? c : w(Math.abs(e), g), y && (e = function (e) { e: for (var t, n = e.length, r = 1, i = -1; r < n; ++r)switch (e[r]) { case ".": i = t = r; break; case "0": 0 === i && (i = r), t = r; break; default: if (!+e[r]) break e; i > 0 && (i = 0) }return i > 0 ? e.slice(0, i) + e.slice(t + 1) : e }(e)), _ && 0 == +e && "+" !== h && (_ = !1), d = (_ ? "(" === h ? h : l : "-" === h || "(" === h ? "" : h) + d, S = ("s" === b ? mZ[8 + nZ / 3] : "") + S + (_ && "(" === h ? ")" : ""), k) for (i = -1, a = e.length; ++i < a;)if (48 > (u = e.charCodeAt(i)) || u > 57) { S = (46 === u ? o + e.slice(i + 1) : e.slice(i)) + S, e = e.slice(0, i); break } } m && !f && (e = r(e, 1 / 0)); var C = d.length + e.length + S.length, A = C < p ? new Array(p - C + 1).join(t) : ""; switch (m && f && (e = r(A + e, A.length ? p - S.length : 1 / 0), A = ""), n) { case "<": e = d + e + S + A; break; case "=": e = d + A + e + S; break; case "^": e = A.slice(0, C = A.length >> 1) + d + e + S + A.slice(C); break; default: e = A + d + e + S }return s(e) } return g = void 0 === g ? 6 : /[gprs]/.test(b) ? Math.max(1, Math.min(21, g)) : Math.max(0, Math.min(20, g)), S.toString = function () { return e + "" }, S } return { format: h, formatPrefix: function (e, t) { var n = h(((e = iZ(e)).type = "f", e)), r = 3 * Math.max(-8, Math.min(8, Math.floor(sZ(t) / 3))), i = Math.pow(10, -r), a = mZ[8 + r / 3]; return function (e) { return n(i * e) + a } } } } function yZ(e, t, n, r) { var i, a = _A(e, t, n); switch ((r = iZ(null == r ? ",f" : r)).type) { case "s": var o = Math.max(Math.abs(e), Math.abs(t)); return null != r.precision || isNaN(i = function (e, t) { return Math.max(0, 3 * Math.max(-8, Math.min(8, Math.floor(sZ(t) / 3))) - sZ(Math.abs(e))) }(a, o)) || (r.precision = i), fZ(r, o); case "": case "e": case "g": case "p": case "r": null != r.precision || isNaN(i = function (e, t) { return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, sZ(t) - sZ(e)) + 1 }(a, Math.max(Math.abs(e), Math.abs(t)))) || (r.precision = i - ("e" === r.type)); break; case "f": case "%": null != r.precision || isNaN(i = function (e) { return Math.max(0, -sZ(Math.abs(e))) }(a)) || (r.precision = i - 2 * ("%" === r.type)) }return dZ(r) } function bZ(e) { return +e } !function (e) { hZ = gZ(e), dZ = hZ.format, fZ = hZ.formatPrefix }({ thousands: ",", grouping: [3], currency: ["$", ""] }); var vZ = [0, 1]; function xZ(e) { return e } function wZ(e, t) { return (t -= e = +e) ? function (n) { return (n - e) / t } : function (e) { return function () { return e } }(isNaN(t) ? NaN : .5) } function kZ(e, t, n) { var r = e[0], i = e[1], a = t[0], o = t[1]; return i < r ? (r = wZ(i, r), a = n(o, a)) : (r = wZ(r, i), a = n(a, o)), function (e) { return a(r(e)) } } function SZ(e, t, n) { var r = Math.min(e.length, t.length) - 1, i = new Array(r), a = new Array(r), o = -1; for (e[r] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < r;)i[o] = wZ(e[o], e[o + 1]), a[o] = n(t[o], t[o + 1]); return function (t) { var n = gR(e, t, 1, r) - 1; return a[n](i[n](t)) } } function _Z(e, t) { return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown()) } function CZ() { var e, t, n, r, i, a, o = vZ, s = vZ, u = UC, l = xZ; function c() { var e = Math.min(o.length, s.length); return l !== xZ && (l = function (e, t) { var n; return e > t && (n = e, e = t, t = n), function (n) { return Math.max(e, Math.min(t, n)) } }(o[0], o[e - 1])), r = e > 2 ? SZ : kZ, i = a = null, h } function h(t) { return null == t || isNaN(t = +t) ? n : (i || (i = r(o.map(e), s, u)))(e(l(t))) } return h.invert = function (n) { return l(t((a || (a = r(s, o.map(e), zC)))(n))) }, h.domain = function (e) { return arguments.length ? (o = Array.from(e, bZ), c()) : o.slice() }, h.range = function (e) { return arguments.length ? (s = Array.from(e), c()) : s.slice() }, h.rangeRound = function (e) { return s = Array.from(e), u = j_, c() }, h.clamp = function (e) { return arguments.length ? (l = !!e || xZ, c()) : l !== xZ }, h.interpolate = function (e) { return arguments.length ? (u = e, c()) : u }, h.unknown = function (e) { return arguments.length ? (n = e, h) : n }, function (n, r) { return e = n, t = r, c() } } function AZ() { return CZ()(xZ, xZ) } function TZ(e) { var t = e.domain; return e.ticks = function (e) { var n = t(); return kA(n[0], n[n.length - 1], null == e ? 10 : e) }, e.tickFormat = function (e, n) { var r = t(); return yZ(r[0], r[r.length - 1], null == e ? 10 : e, n) }, e.nice = function (n) { null == n && (n = 10); var r, i, a = t(), o = 0, s = a.length - 1, u = a[o], l = a[s], c = 10; for (l < u && (i = u, u = l, l = i, i = o, o = s, s = i); c-- > 0;) { if ((i = SA(u, l, n)) === r) return a[o] = u, a[s] = l, t(a); if (i > 0) u = Math.floor(u / i) * i, l = Math.ceil(l / i) * i; else { if (!(i < 0)) break; u = Math.ceil(u * i) / i, l = Math.floor(l * i) / i } r = i } return e }, e } function EZ(e, t) { var n, r = 0, i = (e = e.slice()).length - 1, a = e[r], o = e[i]; return o < a && (n = r, r = i, i = n, n = a, a = o, o = n), e[r] = t.floor(a), e[i] = t.ceil(o), e } function NZ(e) { return Math.log(e) } function IZ(e) { return Math.exp(e) } function MZ(e) { return -Math.log(-e) } function FZ(e) { return -Math.exp(-e) } function DZ(e) { return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e } function $Z(e) { return function (t) { return -e(-t) } } function RZ(e) { var t, n, r = e(NZ, IZ), i = r.domain, a = 10; function o() { return t = function (e) { return e === Math.E ? Math.log : 10 === e && Math.log10 || 2 === e && Math.log2 || (e = Math.log(e), function (t) { return Math.log(t) / e }) }(a), n = function (e) { return 10 === e ? DZ : e === Math.E ? Math.exp : function (t) { return Math.pow(e, t) } }(a), i()[0] < 0 ? (t = $Z(t), n = $Z(n), e(MZ, FZ)) : e(NZ, IZ), r } return r.base = function (e) { return arguments.length ? (a = +e, o()) : a }, r.domain = function (e) { return arguments.length ? (i(e), o()) : i() }, r.ticks = function (e) { var r, o = i(), s = o[0], u = o[o.length - 1]; (r = u < s) && (d = s, s = u, u = d); var l, c, h, d = t(s), f = t(u), p = null == e ? 10 : +e, m = []; if (!(a % 1) && f - d < p) { if (d = Math.floor(d), f = Math.ceil(f), s > 0) { for (; d <= f; ++d)for (c = 1, l = n(d); c < a; ++c)if (!((h = l * c) < s)) { if (h > u) break; m.push(h) } } else for (; d <= f; ++d)for (c = a - 1, l = n(d); c >= 1; --c)if (!((h = l * c) < s)) { if (h > u) break; m.push(h) } 2 * m.length < p && (m = kA(s, u, p)) } else m = kA(d, f, Math.min(f - d, p)).map(n); return r ? m.reverse() : m }, r.tickFormat = function (e, i) { if (null == i && (i = 10 === a ? ".0e" : ","), "function" != typeof i && (i = dZ(i)), e === 1 / 0) return i; null == e && (e = 10); var o = Math.max(1, a * e / r.ticks().length); return function (e) { var r = e / n(Math.round(t(e))); return r * a < a - .5 && (r *= a), r <= o ? i(e) : "" } }, r.nice = function () { return i(EZ(i(), { floor: function (e) { return n(Math.floor(t(e))) }, ceil: function (e) { return n(Math.ceil(t(e))) } })) }, r } function OZ(e) { return function (t) { return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e) } } function zZ(e) { return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e) } function PZ(e) { return e < 0 ? -e * e : e * e } function BZ(e) { var t = e(xZ, xZ), n = 1; return t.exponent = function (t) { return arguments.length ? 1 === (n = +t) ? e(xZ, xZ) : .5 === n ? e(zZ, PZ) : e(OZ(n), OZ(1 / n)) : n }, TZ(t) } function LZ() { var e = BZ(CZ()); return e.copy = function () { return _Z(e, LZ()).exponent(e.exponent()) }, JK.apply(e, arguments), e } function jZ(e) { return function (t) { return Math.sign(t) * Math.log1p(Math.abs(t / e)) } } function UZ(e) { return function (t) { return Math.sign(t) * Math.expm1(Math.abs(t)) * e } } function WZ(e) { var t = 1, n = e(jZ(t), UZ(t)); return n.constant = function (n) { return arguments.length ? e(jZ(t = +n), UZ(t)) : t }, TZ(n) } const VZ = 1e3, GZ = 6e4, HZ = 36e5, qZ = 864e5, YZ = 6048e5, XZ = 2592e6, KZ = 31536e6; var ZZ = new Date, JZ = new Date; function QZ(e, t, n, r) { function i(t) { return e(t = 0 === arguments.length ? new Date : new Date(+t)), t } return i.floor = function (t) { return e(t = new Date(+t)), t }, i.ceil = function (n) { return e(n = new Date(n - 1)), t(n, 1), e(n), n }, i.round = function (e) { var t = i(e), n = i.ceil(e); return e - t < n - e ? t : n }, i.offset = function (e, n) { return t(e = new Date(+e), null == n ? 1 : Math.floor(n)), e }, i.range = function (n, r, a) { var o, s = []; if (n = i.ceil(n), a = null == a ? 1 : Math.floor(a), !(n < r && a > 0)) return s; do { s.push(o = new Date(+n)), t(n, a), e(n) } while (o < n && n < r); return s }, i.filter = function (n) { return QZ((function (t) { if (t >= t) for (; e(t), !n(t);)t.setTime(t - 1) }), (function (e, r) { if (e >= e) if (r < 0) for (; ++r <= 0;)for (; t(e, -1), !n(e);); else for (; --r >= 0;)for (; t(e, 1), !n(e);); })) }, n && (i.count = function (t, r) { return ZZ.setTime(+t), JZ.setTime(+r), e(ZZ), e(JZ), Math.floor(n(ZZ, JZ)) }, i.every = function (e) { return e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? i.filter(r ? function (t) { return r(t) % e == 0 } : function (t) { return i.count(0, t) % e == 0 }) : i : null }), i } var eJ = QZ((function () { }), (function (e, t) { e.setTime(+e + t) }), (function (e, t) { return t - e })); eJ.every = function (e) { return e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? QZ((function (t) { t.setTime(Math.floor(t / e) * e) }), (function (t, n) { t.setTime(+t + n * e) }), (function (t, n) { return (n - t) / e })) : eJ : null }; const tJ = eJ; eJ.range; var nJ = QZ((function (e) { e.setTime(e - e.getMilliseconds()) }), (function (e, t) { e.setTime(+e + t * VZ) }), (function (e, t) { return (t - e) / VZ }), (function (e) { return e.getUTCSeconds() })); const rJ = nJ; nJ.range; var iJ = QZ((function (e) { e.setTime(e - e.getMilliseconds() - e.getSeconds() * VZ) }), (function (e, t) { e.setTime(+e + t * GZ) }), (function (e, t) { return (t - e) / GZ }), (function (e) { return e.getMinutes() })); const aJ = iJ; iJ.range; var oJ = QZ((function (e) { e.setTime(e - e.getMilliseconds() - e.getSeconds() * VZ - e.getMinutes() * GZ) }), (function (e, t) { e.setTime(+e + t * HZ) }), (function (e, t) { return (t - e) / HZ }), (function (e) { return e.getHours() })); const sJ = oJ; oJ.range; var uJ = QZ((e => e.setHours(0, 0, 0, 0)), ((e, t) => e.setDate(e.getDate() + t)), ((e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * GZ) / qZ), (e => e.getDate() - 1)); const lJ = uJ; uJ.range; function cJ(e) { return QZ((function (t) { t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0) }), (function (e, t) { e.setDate(e.getDate() + 7 * t) }), (function (e, t) { return (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * GZ) / YZ })) } var hJ = cJ(0), dJ = cJ(1), fJ = cJ(2), pJ = cJ(3), mJ = cJ(4), gJ = cJ(5), yJ = cJ(6), bJ = (hJ.range, dJ.range, fJ.range, pJ.range, mJ.range, gJ.range, yJ.range, QZ((function (e) { e.setDate(1), e.setHours(0, 0, 0, 0) }), (function (e, t) { e.setMonth(e.getMonth() + t) }), (function (e, t) { return t.getMonth() - e.getMonth() + 12 * (t.getFullYear() - e.getFullYear()) }), (function (e) { return e.getMonth() }))); const vJ = bJ; bJ.range; var xJ = QZ((function (e) { e.setMonth(0, 1), e.setHours(0, 0, 0, 0) }), (function (e, t) { e.setFullYear(e.getFullYear() + t) }), (function (e, t) { return t.getFullYear() - e.getFullYear() }), (function (e) { return e.getFullYear() })); xJ.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? QZ((function (t) { t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0) }), (function (t, n) { t.setFullYear(t.getFullYear() + n * e) })) : null }; const wJ = xJ; xJ.range; var kJ = QZ((function (e) { e.setUTCSeconds(0, 0) }), (function (e, t) { e.setTime(+e + t * GZ) }), (function (e, t) { return (t - e) / GZ }), (function (e) { return e.getUTCMinutes() })); const SJ = kJ; kJ.range; var _J = QZ((function (e) { e.setUTCMinutes(0, 0, 0) }), (function (e, t) { e.setTime(+e + t * HZ) }), (function (e, t) { return (t - e) / HZ }), (function (e) { return e.getUTCHours() })); const CJ = _J; _J.range; var AJ = QZ((function (e) { e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + t) }), (function (e, t) { return (t - e) / qZ }), (function (e) { return e.getUTCDate() - 1 })); const TJ = AJ; AJ.range; function EJ(e) { return QZ((function (t) { t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + 7 * t) }), (function (e, t) { return (t - e) / YZ })) } var NJ = EJ(0), IJ = EJ(1), MJ = EJ(2), FJ = EJ(3), DJ = EJ(4), $J = EJ(5), RJ = EJ(6), OJ = (NJ.range, IJ.range, MJ.range, FJ.range, DJ.range, $J.range, RJ.range, QZ((function (e) { e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCMonth(e.getUTCMonth() + t) }), (function (e, t) { return t.getUTCMonth() - e.getUTCMonth() + 12 * (t.getUTCFullYear() - e.getUTCFullYear()) }), (function (e) { return e.getUTCMonth() }))); const zJ = OJ; OJ.range; var PJ = QZ((function (e) { e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCFullYear(e.getUTCFullYear() + t) }), (function (e, t) { return t.getUTCFullYear() - e.getUTCFullYear() }), (function (e) { return e.getUTCFullYear() })); PJ.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? QZ((function (t) { t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0) }), (function (t, n) { t.setUTCFullYear(t.getUTCFullYear() + n * e) })) : null }; const BJ = PJ; PJ.range; function LJ(e, t, n, r, i, a) { const o = [[rJ, 1, VZ], [rJ, 5, 5e3], [rJ, 15, 15e3], [rJ, 30, 3e4], [a, 1, GZ], [a, 5, 3e5], [a, 15, 9e5], [a, 30, 18e5], [i, 1, HZ], [i, 3, 108e5], [i, 6, 216e5], [i, 12, 432e5], [r, 1, qZ], [r, 2, 1728e5], [n, 1, YZ], [t, 1, XZ], [t, 3, 7776e6], [e, 1, KZ]]; function s(t, n, r) { const i = Math.abs(n - t) / r, a = Dl((([, , e]) => e)).right(o, i); if (a === o.length) return e.every(_A(t / KZ, n / KZ, r)); if (0 === a) return tJ.every(Math.max(_A(t, n, r), 1)); const [s, u] = o[i / o[a - 1][2] < o[a][2] / i ? a - 1 : a]; return s.every(u) } return [function (e, t, n) { const r = t < e; r && ([e, t] = [t, e]); const i = n && "function" == typeof n.range ? n : s(e, t, n), a = i ? i.range(e, +t + 1) : []; return r ? a.reverse() : a }, s] } const [jJ, UJ] = LJ(BJ, zJ, NJ, TJ, CJ, SJ), [WJ, VJ] = LJ(wJ, vJ, hJ, lJ, sJ, aJ); var GJ = new Date, HJ = new Date; function qJ(e, t, n, r) { function i(t) { return e(t = 0 === arguments.length ? new Date : new Date(+t)), t } return i.floor = function (t) { return e(t = new Date(+t)), t }, i.ceil = function (n) { return e(n = new Date(n - 1)), t(n, 1), e(n), n }, i.round = function (e) { var t = i(e), n = i.ceil(e); return e - t < n - e ? t : n }, i.offset = function (e, n) { return t(e = new Date(+e), null == n ? 1 : Math.floor(n)), e }, i.range = function (n, r, a) { var o, s = []; if (n = i.ceil(n), a = null == a ? 1 : Math.floor(a), !(n < r && a > 0)) return s; do { s.push(o = new Date(+n)), t(n, a), e(n) } while (o < n && n < r); return s }, i.filter = function (n) { return qJ((function (t) { if (t >= t) for (; e(t), !n(t);)t.setTime(t - 1) }), (function (e, r) { if (e >= e) if (r < 0) for (; ++r <= 0;)for (; t(e, -1), !n(e);); else for (; --r >= 0;)for (; t(e, 1), !n(e);); })) }, n && (i.count = function (t, r) { return GJ.setTime(+t), HJ.setTime(+r), e(GJ), e(HJ), Math.floor(n(GJ, HJ)) }, i.every = function (e) { return e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? i.filter(r ? function (t) { return r(t) % e == 0 } : function (t) { return i.count(0, t) % e == 0 }) : i : null }), i } const YJ = 6e4, XJ = 864e5, KJ = 6048e5; function ZJ(e) { return qJ((function (t) { t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + 7 * t) }), (function (e, t) { return (t - e) / KJ })) } var JJ = ZJ(0), QJ = ZJ(1), eQ = ZJ(2), tQ = ZJ(3), nQ = ZJ(4), rQ = ZJ(5), iQ = ZJ(6), aQ = (JJ.range, QJ.range, eQ.range, tQ.range, nQ.range, rQ.range, iQ.range, qJ((function (e) { e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + t) }), (function (e, t) { return (t - e) / XJ }), (function (e) { return e.getUTCDate() - 1 }))); const oQ = aQ; aQ.range; function sQ(e) { return qJ((function (t) { t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0) }), (function (e, t) { e.setDate(e.getDate() + 7 * t) }), (function (e, t) { return (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * YJ) / KJ })) } var uQ = sQ(0), lQ = sQ(1), cQ = sQ(2), hQ = sQ(3), dQ = sQ(4), fQ = sQ(5), pQ = sQ(6), mQ = (uQ.range, lQ.range, cQ.range, hQ.range, dQ.range, fQ.range, pQ.range, qJ((e => e.setHours(0, 0, 0, 0)), ((e, t) => e.setDate(e.getDate() + t)), ((e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * YJ) / XJ), (e => e.getDate() - 1))); const gQ = mQ; mQ.range; var yQ = qJ((function (e) { e.setMonth(0, 1), e.setHours(0, 0, 0, 0) }), (function (e, t) { e.setFullYear(e.getFullYear() + t) }), (function (e, t) { return t.getFullYear() - e.getFullYear() }), (function (e) { return e.getFullYear() })); yQ.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? qJ((function (t) { t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0) }), (function (t, n) { t.setFullYear(t.getFullYear() + n * e) })) : null }; const bQ = yQ; yQ.range; var vQ = qJ((function (e) { e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCFullYear(e.getUTCFullYear() + t) }), (function (e, t) { return t.getUTCFullYear() - e.getUTCFullYear() }), (function (e) { return e.getUTCFullYear() })); vQ.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? qJ((function (t) { t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0) }), (function (t, n) { t.setUTCFullYear(t.getUTCFullYear() + n * e) })) : null }; const xQ = vQ; vQ.range; function wQ(e) { if (0 <= e.y && e.y < 100) { var t = new Date(-1, e.m, e.d, e.H, e.M, e.S, e.L); return t.setFullYear(e.y), t } return new Date(e.y, e.m, e.d, e.H, e.M, e.S, e.L) } function kQ(e) { if (0 <= e.y && e.y < 100) { var t = new Date(Date.UTC(-1, e.m, e.d, e.H, e.M, e.S, e.L)); return t.setUTCFullYear(e.y), t } return new Date(Date.UTC(e.y, e.m, e.d, e.H, e.M, e.S, e.L)) } function SQ(e, t, n) { return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 } } var _Q, CQ, AQ, TQ = { "-": "", _: " ", 0: "0" }, EQ = /^\s*\d+/, NQ = /^%/, IQ = /[\\^$*+?|[\]().{}]/g; function MQ(e, t, n) { var r = e < 0 ? "-" : "", i = (r ? -e : e) + "", a = i.length; return r + (a < n ? new Array(n - a + 1).join(t) + i : i) } function FQ(e) { return e.replace(IQ, "\\$&") } function DQ(e) { return new RegExp("^(?:" + e.map(FQ).join("|") + ")", "i") } function $Q(e) { return new Map(e.map(((e, t) => [e.toLowerCase(), t]))) } function RQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 1)); return r ? (e.w = +r[0], n + r[0].length) : -1 } function OQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 1)); return r ? (e.u = +r[0], n + r[0].length) : -1 } function zQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.U = +r[0], n + r[0].length) : -1 } function PQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.V = +r[0], n + r[0].length) : -1 } function BQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.W = +r[0], n + r[0].length) : -1 } function LQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 4)); return r ? (e.y = +r[0], n + r[0].length) : -1 } function jQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1 } function UQ(e, t, n) { var r = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6)); return r ? (e.Z = r[1] ? 0 : -(r[2] + (r[3] || "00")), n + r[0].length) : -1 } function WQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 1)); return r ? (e.q = 3 * r[0] - 3, n + r[0].length) : -1 } function VQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.m = r[0] - 1, n + r[0].length) : -1 } function GQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.d = +r[0], n + r[0].length) : -1 } function HQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 3)); return r ? (e.m = 0, e.d = +r[0], n + r[0].length) : -1 } function qQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.H = +r[0], n + r[0].length) : -1 } function YQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.M = +r[0], n + r[0].length) : -1 } function XQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 2)); return r ? (e.S = +r[0], n + r[0].length) : -1 } function KQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 3)); return r ? (e.L = +r[0], n + r[0].length) : -1 } function ZQ(e, t, n) { var r = EQ.exec(t.slice(n, n + 6)); return r ? (e.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1 } function JQ(e, t, n) { var r = NQ.exec(t.slice(n, n + 1)); return r ? n + r[0].length : -1 } function QQ(e, t, n) { var r = EQ.exec(t.slice(n)); return r ? (e.Q = +r[0], n + r[0].length) : -1 } function e0(e, t, n) { var r = EQ.exec(t.slice(n)); return r ? (e.s = +r[0], n + r[0].length) : -1 } function t0(e, t) { return MQ(e.getDate(), t, 2) } function n0(e, t) { return MQ(e.getHours(), t, 2) } function r0(e, t) { return MQ(e.getHours() % 12 || 12, t, 2) } function i0(e, t) { return MQ(1 + gQ.count(bQ(e), e), t, 3) } function a0(e, t) { return MQ(e.getMilliseconds(), t, 3) } function o0(e, t) { return a0(e, t) + "000" } function s0(e, t) { return MQ(e.getMonth() + 1, t, 2) } function u0(e, t) { return MQ(e.getMinutes(), t, 2) } function l0(e, t) { return MQ(e.getSeconds(), t, 2) } function c0(e) { var t = e.getDay(); return 0 === t ? 7 : t } function h0(e, t) { return MQ(uQ.count(bQ(e) - 1, e), t, 2) } function d0(e) { var t = e.getDay(); return t >= 4 || 0 === t ? dQ(e) : dQ.ceil(e) } function f0(e, t) { return e = d0(e), MQ(dQ.count(bQ(e), e) + (4 === bQ(e).getDay()), t, 2) } function p0(e) { return e.getDay() } function m0(e, t) { return MQ(lQ.count(bQ(e) - 1, e), t, 2) } function g0(e, t) { return MQ(e.getFullYear() % 100, t, 2) } function y0(e, t) { return MQ((e = d0(e)).getFullYear() % 100, t, 2) } function b0(e, t) { return MQ(e.getFullYear() % 1e4, t, 4) } function v0(e, t) { var n = e.getDay(); return MQ((e = n >= 4 || 0 === n ? dQ(e) : dQ.ceil(e)).getFullYear() % 1e4, t, 4) } function x0(e) { var t = e.getTimezoneOffset(); return (t > 0 ? "-" : (t *= -1, "+")) + MQ(t / 60 | 0, "0", 2) + MQ(t % 60, "0", 2) } function w0(e, t) { return MQ(e.getUTCDate(), t, 2) } function k0(e, t) { return MQ(e.getUTCHours(), t, 2) } function S0(e, t) { return MQ(e.getUTCHours() % 12 || 12, t, 2) } function _0(e, t) { return MQ(1 + oQ.count(xQ(e), e), t, 3) } function C0(e, t) { return MQ(e.getUTCMilliseconds(), t, 3) } function A0(e, t) { return C0(e, t) + "000" } function T0(e, t) { return MQ(e.getUTCMonth() + 1, t, 2) } function E0(e, t) { return MQ(e.getUTCMinutes(), t, 2) } function N0(e, t) { return MQ(e.getUTCSeconds(), t, 2) } function I0(e) { var t = e.getUTCDay(); return 0 === t ? 7 : t } function M0(e, t) { return MQ(JJ.count(xQ(e) - 1, e), t, 2) } function F0(e) { var t = e.getUTCDay(); return t >= 4 || 0 === t ? nQ(e) : nQ.ceil(e) } function D0(e, t) { return e = F0(e), MQ(nQ.count(xQ(e), e) + (4 === xQ(e).getUTCDay()), t, 2) } function $0(e) { return e.getUTCDay() } function R0(e, t) { return MQ(QJ.count(xQ(e) - 1, e), t, 2) } function O0(e, t) { return MQ(e.getUTCFullYear() % 100, t, 2) } function z0(e, t) { return MQ((e = F0(e)).getUTCFullYear() % 100, t, 2) } function P0(e, t) { return MQ(e.getUTCFullYear() % 1e4, t, 4) } function B0(e, t) { var n = e.getUTCDay(); return MQ((e = n >= 4 || 0 === n ? nQ(e) : nQ.ceil(e)).getUTCFullYear() % 1e4, t, 4) } function L0() { return "+0000" } function j0() { return "%" } function U0(e) { return +e } function W0(e) { return Math.floor(+e / 1e3) } function V0(e) { return new Date(e) } function G0(e) { return e instanceof Date ? +e : +new Date(+e) } function H0(e, t, n, r, i, a, o, s, u, l) { var c = AZ(), h = c.invert, d = c.domain, f = l(".%L"), p = l(":%S"), m = l("%I:%M"), g = l("%I %p"), y = l("%a %d"), b = l("%b %d"), v = l("%B"), x = l("%Y"); function w(e) { return (u(e) < e ? f : s(e) < e ? p : o(e) < e ? m : a(e) < e ? g : r(e) < e ? i(e) < e ? y : b : n(e) < e ? v : x)(e) } return c.invert = function (e) { return new Date(h(e)) }, c.domain = function (e) { return arguments.length ? d(Array.from(e, G0)) : d().map(V0) }, c.ticks = function (t) { var n = d(); return e(n[0], n[n.length - 1], null == t ? 10 : t) }, c.tickFormat = function (e, t) { return null == t ? w : l(t) }, c.nice = function (e) { var n = d(); return e && "function" == typeof e.range || (e = t(n[0], n[n.length - 1], null == e ? 10 : e)), e ? d(EZ(n, e)) : c }, c.copy = function () { return _Z(c, H0(e, t, n, r, i, a, o, s, u, l)) }, c } function q0() { var e, t, n, r, i, a = 0, o = 1, s = xZ, u = !1; function l(t) { return null == t || isNaN(t = +t) ? i : s(0 === n ? .5 : (t = (r(t) - e) * n, u ? Math.max(0, Math.min(1, t)) : t)) } function c(e) { return function (t) { var n, r; return arguments.length ? ([n, r] = t, s = e(n, r), l) : [s(0), s(1)] } } return l.domain = function (i) { return arguments.length ? ([a, o] = i, e = r(a = +a), t = r(o = +o), n = e === t ? 0 : 1 / (t - e), l) : [a, o] }, l.clamp = function (e) { return arguments.length ? (u = !!e, l) : u }, l.interpolator = function (e) { return arguments.length ? (s = e, l) : s }, l.range = c(UC), l.rangeRound = c(j_), l.unknown = function (e) { return arguments.length ? (i = e, l) : i }, function (i) { return r = i, e = i(a), t = i(o), n = e === t ? 0 : 1 / (t - e), l } } function Y0(e, t) { return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown()) } function X0() { var e = TZ(q0()(xZ)); return e.copy = function () { return Y0(e, X0()) }, QK.apply(e, arguments) } function K0() { var e = BZ(q0()); return e.copy = function () { return Y0(e, K0()).exponent(e.exponent()) }, QK.apply(e, arguments) } function Z0(e, t) { void 0 === t && (t = e, e = UC); for (var n = 0, r = t.length - 1, i = t[0], a = new Array(r < 0 ? 0 : r); n < r;)a[n] = e(i, i = t[++n]); return function (e) { var t = Math.max(0, Math.min(r - 1, Math.floor(e *= r))); return a[t](e - t) } } function J0() { var e, t, n, r, i, a, o, s = 0, u = .5, l = 1, c = 1, h = xZ, d = !1; function f(e) { return isNaN(e = +e) ? o : (e = .5 + ((e = +a(e)) - t) * (c * e < c * t ? r : i), h(d ? Math.max(0, Math.min(1, e)) : e)) } function p(e) { return function (t) { var n, r, i; return arguments.length ? ([n, r, i] = t, h = Z0(e, [n, r, i]), f) : [h(0), h(.5), h(1)] } } return f.domain = function (o) { return arguments.length ? ([s, u, l] = o, e = a(s = +s), t = a(u = +u), n = a(l = +l), r = e === t ? 0 : .5 / (t - e), i = t === n ? 0 : .5 / (n - t), c = t < e ? -1 : 1, f) : [s, u, l] }, f.clamp = function (e) { return arguments.length ? (d = !!e, f) : d }, f.interpolator = function (e) { return arguments.length ? (h = e, f) : h }, f.range = p(UC), f.rangeRound = p(j_), f.unknown = function (e) { return arguments.length ? (o = e, f) : o }, function (o) { return a = o, e = o(s), t = o(u), n = o(l), r = e === t ? 0 : .5 / (t - e), i = t === n ? 0 : .5 / (n - t), c = t < e ? -1 : 1, f } } function Q0() { var e = BZ(J0()); return e.copy = function () { return Y0(e, Q0()).exponent(e.exponent()) }, QK.apply(e, arguments) } function e1(e) { var t = e.length; return function (n) { return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))] } } function t1(e, t) { var n = CC(+e, +t); return function (e) { var t = n(e); return t - 360 * Math.floor(t / 360) } } !function (e) { _Q = function (e) { var t = e.dateTime, n = e.date, r = e.time, i = e.periods, a = e.days, o = e.shortDays, s = e.months, u = e.shortMonths, l = DQ(i), c = $Q(i), h = DQ(a), d = $Q(a), f = DQ(o), p = $Q(o), m = DQ(s), g = $Q(s), y = DQ(u), b = $Q(u), v = { a: function (e) { return o[e.getDay()] }, A: function (e) { return a[e.getDay()] }, b: function (e) { return u[e.getMonth()] }, B: function (e) { return s[e.getMonth()] }, c: null, d: t0, e: t0, f: o0, g: y0, G: v0, H: n0, I: r0, j: i0, L: a0, m: s0, M: u0, p: function (e) { return i[+(e.getHours() >= 12)] }, q: function (e) { return 1 + ~~(e.getMonth() / 3) }, Q: U0, s: W0, S: l0, u: c0, U: h0, V: f0, w: p0, W: m0, x: null, X: null, y: g0, Y: b0, Z: x0, "%": j0 }, x = { a: function (e) { return o[e.getUTCDay()] }, A: function (e) { return a[e.getUTCDay()] }, b: function (e) { return u[e.getUTCMonth()] }, B: function (e) { return s[e.getUTCMonth()] }, c: null, d: w0, e: w0, f: A0, g: z0, G: B0, H: k0, I: S0, j: _0, L: C0, m: T0, M: E0, p: function (e) { return i[+(e.getUTCHours() >= 12)] }, q: function (e) { return 1 + ~~(e.getUTCMonth() / 3) }, Q: U0, s: W0, S: N0, u: I0, U: M0, V: D0, w: $0, W: R0, x: null, X: null, y: O0, Y: P0, Z: L0, "%": j0 }, w = { a: function (e, t, n) { var r = f.exec(t.slice(n)); return r ? (e.w = p.get(r[0].toLowerCase()), n + r[0].length) : -1 }, A: function (e, t, n) { var r = h.exec(t.slice(n)); return r ? (e.w = d.get(r[0].toLowerCase()), n + r[0].length) : -1 }, b: function (e, t, n) { var r = y.exec(t.slice(n)); return r ? (e.m = b.get(r[0].toLowerCase()), n + r[0].length) : -1 }, B: function (e, t, n) { var r = m.exec(t.slice(n)); return r ? (e.m = g.get(r[0].toLowerCase()), n + r[0].length) : -1 }, c: function (e, n, r) { return _(e, t, n, r) }, d: GQ, e: GQ, f: ZQ, g: jQ, G: LQ, H: qQ, I: qQ, j: HQ, L: KQ, m: VQ, M: YQ, p: function (e, t, n) { var r = l.exec(t.slice(n)); return r ? (e.p = c.get(r[0].toLowerCase()), n + r[0].length) : -1 }, q: WQ, Q: QQ, s: e0, S: XQ, u: OQ, U: zQ, V: PQ, w: RQ, W: BQ, x: function (e, t, r) { return _(e, n, t, r) }, X: function (e, t, n) { return _(e, r, t, n) }, y: jQ, Y: LQ, Z: UQ, "%": JQ }; function k(e, t) { return function (n) { var r, i, a, o = [], s = -1, u = 0, l = e.length; for (n instanceof Date || (n = new Date(+n)); ++s < l;)37 === e.charCodeAt(s) && (o.push(e.slice(u, s)), null != (i = TQ[r = e.charAt(++s)]) ? r = e.charAt(++s) : i = "e" === r ? " " : "0", (a = t[r]) && (r = a(n, i)), o.push(r), u = s + 1); return o.push(e.slice(u, s)), o.join("") } } function S(e, t) { return function (n) { var r, i, a = SQ(1900, void 0, 1); if (_(a, e, n += "", 0) != n.length) return null; if ("Q" in a) return new Date(a.Q); if ("s" in a) return new Date(1e3 * a.s + ("L" in a ? a.L : 0)); if (t && !("Z" in a) && (a.Z = 0), "p" in a && (a.H = a.H % 12 + 12 * a.p), void 0 === a.m && (a.m = "q" in a ? a.q : 0), "V" in a) { if (a.V < 1 || a.V > 53) return null; "w" in a || (a.w = 1), "Z" in a ? (i = (r = kQ(SQ(a.y, 0, 1))).getUTCDay(), r = i > 4 || 0 === i ? QJ.ceil(r) : QJ(r), r = oQ.offset(r, 7 * (a.V - 1)), a.y = r.getUTCFullYear(), a.m = r.getUTCMonth(), a.d = r.getUTCDate() + (a.w + 6) % 7) : (i = (r = wQ(SQ(a.y, 0, 1))).getDay(), r = i > 4 || 0 === i ? lQ.ceil(r) : lQ(r), r = gQ.offset(r, 7 * (a.V - 1)), a.y = r.getFullYear(), a.m = r.getMonth(), a.d = r.getDate() + (a.w + 6) % 7) } else ("W" in a || "U" in a) && ("w" in a || (a.w = "u" in a ? a.u % 7 : "W" in a ? 1 : 0), i = "Z" in a ? kQ(SQ(a.y, 0, 1)).getUTCDay() : wQ(SQ(a.y, 0, 1)).getDay(), a.m = 0, a.d = "W" in a ? (a.w + 6) % 7 + 7 * a.W - (i + 5) % 7 : a.w + 7 * a.U - (i + 6) % 7); return "Z" in a ? (a.H += a.Z / 100 | 0, a.M += a.Z % 100, kQ(a)) : wQ(a) } } function _(e, t, n, r) { for (var i, a, o = 0, s = t.length, u = n.length; o < s;) { if (r >= u) return -1; if (37 === (i = t.charCodeAt(o++))) { if (i = t.charAt(o++), !(a = w[i in TQ ? t.charAt(o++) : i]) || (r = a(e, n, r)) < 0) return -1 } else if (i != n.charCodeAt(r++)) return -1 } return r } return v.x = k(n, v), v.X = k(r, v), v.c = k(t, v), x.x = k(n, x), x.X = k(r, x), x.c = k(t, x), { format: function (e) { var t = k(e += "", v); return t.toString = function () { return e }, t }, parse: function (e) { var t = S(e += "", !1); return t.toString = function () { return e }, t }, utcFormat: function (e) { var t = k(e += "", x); return t.toString = function () { return e }, t }, utcParse: function (e) { var t = S(e += "", !0); return t.toString = function () { return e }, t } } }(e), CQ = _Q.format, _Q.parse, AQ = _Q.utcFormat, _Q.utcParse }({ dateTime: "%x, %X", date: "%-m/%-d/%Y", time: "%-I:%M:%S %p", periods: ["AM", "PM"], days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }); var n1, r1 = 180 / Math.PI, i1 = { translateX: 0, translateY: 0, rotate: 0, skewX: 0, scaleX: 1, scaleY: 1 }; function a1(e, t, n, r, i, a) { var o, s, u; return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (u = e * n + t * r) && (n -= e * u, r -= t * u), (s = Math.sqrt(n * n + r * r)) && (n /= s, r /= s, u /= s), e * r < t * n && (e = -e, t = -t, u = -u, o = -o), { translateX: i, translateY: a, rotate: Math.atan2(t, e) * r1, skewX: Math.atan(u) * r1, scaleX: o, scaleY: s } } function o1(e, t, n, r) { function i(e) { return e.length ? e.pop() + " " : "" } return function (a, o) { var s = [], u = []; return a = e(a), o = e(o), function (e, r, i, a, o, s) { if (e !== i || r !== a) { var u = o.push("translate(", null, t, null, n); s.push({ i: u - 4, x: zC(e, i) }, { i: u - 2, x: zC(r, a) }) } else (i || a) && o.push("translate(" + i + t + a + n) }(a.translateX, a.translateY, o.translateX, o.translateY, s, u), function (e, t, n, a) { e !== t ? (e - t > 180 ? t += 360 : t - e > 180 && (e += 360), a.push({ i: n.push(i(n) + "rotate(", null, r) - 2, x: zC(e, t) })) : t && n.push(i(n) + "rotate(" + t + r) }(a.rotate, o.rotate, s, u), function (e, t, n, a) { e !== t ? a.push({ i: n.push(i(n) + "skewX(", null, r) - 2, x: zC(e, t) }) : t && n.push(i(n) + "skewX(" + t + r) }(a.skewX, o.skewX, s, u), function (e, t, n, r, a, o) { if (e !== n || t !== r) { var s = a.push(i(a) + "scale(", null, ",", null, ")"); o.push({ i: s - 4, x: zC(e, n) }, { i: s - 2, x: zC(t, r) }) } else 1 === n && 1 === r || a.push(i(a) + "scale(" + n + "," + r + ")") }(a.scaleX, a.scaleY, o.scaleX, o.scaleY, s, u), a = o = null, function (e) { for (var t, n = -1, r = u.length; ++n < r;)s[(t = u[n]).i] = t.x(e); return s.join("") } } } var s1 = o1((function (e) { const t = new ("function" == typeof DOMMatrix ? DOMMatrix : WebKitCSSMatrix)(e + ""); return t.isIdentity ? i1 : a1(t.a, t.b, t.c, t.d, t.e, t.f) }), "px, ", "px)", "deg)"), u1 = o1((function (e) { return null == e ? i1 : (n1 || (n1 = document.createElementNS("http://www.w3.org/2000/svg", "g")), n1.setAttribute("transform", e), (e = n1.transform.baseVal.consolidate()) ? a1((e = e.matrix).a, e.b, e.c, e.d, e.e, e.f) : i1) }), ", ", ")", ")"); function l1(e) { return ((e = Math.exp(e)) + 1 / e) / 2 } const c1 = function e(t, n, r) { function i(e, i) { var a, o, s = e[0], u = e[1], l = e[2], c = i[0], h = i[1], d = i[2], f = c - s, p = h - u, m = f * f + p * p; if (m < 1e-12) o = Math.log(d / l) / t, a = function (e) { return [s + e * f, u + e * p, l * Math.exp(t * e * o)] }; else { var g = Math.sqrt(m), y = (d * d - l * l + r * m) / (2 * l * n * g), b = (d * d - l * l - r * m) / (2 * d * n * g), v = Math.log(Math.sqrt(y * y + 1) - y), x = Math.log(Math.sqrt(b * b + 1) - b); o = (x - v) / t, a = function (e) { var r = e * o, i = l1(v), a = l / (n * g) * (i * function (e) { return ((e = Math.exp(2 * e)) - 1) / (e + 1) }(t * r + v) - function (e) { return ((e = Math.exp(e)) - 1 / e) / 2 }(v)); return [s + a * f, u + a * p, l * i / l1(t * r + v)] } } return a.duration = 1e3 * o * t / Math.SQRT2, a } return i.rho = function (t) { var n = Math.max(.001, +t), r = n * n; return e(n, r, r * r) }, i }(Math.SQRT2, 2, 4); function h1(e) { return function (t, n) { var r = e((t = yC(t)).h, (n = yC(n)).h), i = TC(t.s, n.s), a = TC(t.l, n.l), o = TC(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.s = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } const d1 = h1(CC); var f1 = h1(TC); const p1 = Math.PI / 180, m1 = 180 / Math.PI, g1 = .96422, y1 = 1, b1 = .82521, v1 = 4 / 29, x1 = 6 / 29, w1 = .12841854934601665, k1 = .008856451679035631; function S1(e) { if (e instanceof C1) return new C1(e.l, e.a, e.b, e.opacity); if (e instanceof F1) return D1(e); e instanceof hC || (e = lC(e)); var t, n, r = N1(e.r), i = N1(e.g), a = N1(e.b), o = A1((.2225045 * r + .7168786 * i + .0606169 * a) / y1); return r === i && i === a ? t = n = o : (t = A1((.4360747 * r + .3850649 * i + .1430804 * a) / g1), n = A1((.0139322 * r + .0971045 * i + .7141733 * a) / b1)), new C1(116 * o - 16, 500 * (t - o), 200 * (o - n), e.opacity) } function _1(e, t, n, r) { return 1 === arguments.length ? S1(e) : new C1(e, t, n, null == r ? 1 : r) } function C1(e, t, n, r) { this.l = +e, this.a = +t, this.b = +n, this.opacity = +r } function A1(e) { return e > k1 ? Math.pow(e, 1 / 3) : e / w1 + v1 } function T1(e) { return e > x1 ? e * e * e : w1 * (e - v1) } function E1(e) { return 255 * (e <= .0031308 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - .055) } function N1(e) { return (e /= 255) <= .04045 ? e / 12.92 : Math.pow((e + .055) / 1.055, 2.4) } function I1(e) { if (e instanceof F1) return new F1(e.h, e.c, e.l, e.opacity); if (e instanceof C1 || (e = S1(e)), 0 === e.a && 0 === e.b) return new F1(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity); var t = Math.atan2(e.b, e.a) * m1; return new F1(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity) } function M1(e, t, n, r) { return 1 === arguments.length ? I1(e) : new F1(e, t, n, null == r ? 1 : r) } function F1(e, t, n, r) { this.h = +e, this.c = +t, this.l = +n, this.opacity = +r } function D1(e) { if (isNaN(e.h)) return new C1(e.l, 0, 0, e.opacity); var t = e.h * p1; return new C1(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity) } function $1(e, t) { var n = TC((e = _1(e)).l, (t = _1(t)).l), r = TC(e.a, t.a), i = TC(e.b, t.b), a = TC(e.opacity, t.opacity); return function (t) { return e.l = n(t), e.a = r(t), e.b = i(t), e.opacity = a(t), e + "" } } function R1(e) { return function (t, n) { var r = e((t = M1(t)).h, (n = M1(n)).h), i = TC(t.c, n.c), a = TC(t.l, n.l), o = TC(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.c = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } U_(C1, _1, W_(V_, { brighter: function (e) { return new C1(this.l + 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, darker: function (e) { return new C1(this.l - 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, rgb: function () { var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200; return new hC(E1(3.1338561 * (t = g1 * T1(t)) - 1.6168667 * (e = y1 * T1(e)) - .4906146 * (n = b1 * T1(n))), E1(-.9787684 * t + 1.9161415 * e + .033454 * n), E1(.0719453 * t - .2289914 * e + 1.4052427 * n), this.opacity) } })), U_(F1, M1, W_(V_, { brighter: function (e) { return new F1(this.h, this.c, this.l + 18 * (null == e ? 1 : e), this.opacity) }, darker: function (e) { return new F1(this.h, this.c, this.l - 18 * (null == e ? 1 : e), this.opacity) }, rgb: function () { return D1(this).rgb() } })); const O1 = R1(CC); var z1 = R1(TC), P1 = -.14861, B1 = 1.78277, L1 = -.29227, j1 = -.90649, U1 = 1.97294, W1 = -1.7884503806, V1 = 3.5172982438, G1 = -.6557636667999999; function H1(e, t, n, r) { return 1 === arguments.length ? function (e) { if (e instanceof q1) return new q1(e.h, e.s, e.l, e.opacity); e instanceof hC || (e = lC(e)); var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (G1 * r + W1 * t - V1 * n) / -5.9615122912, a = r - i, o = (U1 * (n - i) - L1 * a) / j1, s = Math.sqrt(o * o + a * a) / (U1 * i * (1 - i)), u = s ? Math.atan2(o, a) * m1 - 120 : NaN; return new q1(u < 0 ? u + 360 : u, s, i, e.opacity) }(e) : new q1(e, t, n, null == r ? 1 : r) } function q1(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function Y1(e) { return function t(n) { function r(t, r) { var i = e((t = H1(t)).h, (r = H1(r)).h), a = TC(t.s, r.s), o = TC(t.l, r.l), s = TC(t.opacity, r.opacity); return function (e) { return t.h = i(e), t.s = a(e), t.l = o(Math.pow(e, n)), t.opacity = s(e), t + "" } } return n = +n, r.gamma = t, r }(1) } U_(q1, H1, W_(V_, { brighter: function (e) { return e = null == e ? H_ : Math.pow(H_, e), new q1(this.h, this.s, this.l * e, this.opacity) }, darker: function (e) { return e = null == e ? G_ : Math.pow(G_, e), new q1(this.h, this.s, this.l * e, this.opacity) }, rgb: function () { var e = isNaN(this.h) ? 0 : (this.h + 120) * p1, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e); return new hC(255 * (t + n * (P1 * r + B1 * i)), 255 * (t + n * (L1 * r + j1 * i)), 255 * (t + n * (U1 * r)), this.opacity) } })); const X1 = Y1(CC); var K1 = Y1(TC); function Z1(e, t) { for (var n = new Array(t), r = 0; r < t; ++r)n[r] = e(r / (t - 1)); return n } const J1 = "year", Q1 = "quarter", e2 = "month", t2 = "week", n2 = "date", r2 = "day", i2 = "dayofyear", a2 = "hours", o2 = "minutes", s2 = "seconds", u2 = "milliseconds";[J1, Q1, e2, t2, n2, r2, i2, a2, o2, s2, u2].reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); new Date; mi.every(3), gi.every(3); const l2 = [J1, e2, n2, a2, o2, s2, u2], c2 = l2.slice(0, -1), h2 = c2.slice(0, -1), d2 = h2.slice(0, -1); d2.slice(0, -1); const f2 = "linear", p2 = "log", m2 = "pow", g2 = "sqrt", y2 = "symlog", b2 = "time", v2 = "utc", x2 = "sequential", w2 = "diverging", k2 = "quantile", S2 = "quantize", _2 = "threshold", C2 = "continuous", A2 = "discrete", T2 = "discretizing", E2 = "interpolating", N2 = "temporal"; function I2() { const e = tZ().unknown(void 0), t = e.domain, n = e.range; let r, i, a = [0, 1], o = !1, s = 0, u = 0, l = .5; function c() { const e = t().length, c = a[1] < a[0], h = a[1 - c], d = function (e, t, n) { const r = e - t + 2 * n; return e ? r > 0 ? r : 1 : 0 }(e, s, u); let f = a[c - 0]; r = (h - f) / (d || 1), o && (r = Math.floor(r)), f += (h - f - r * (e - s)) * l, i = r * (1 - s), o && (f = Math.round(f), i = Math.round(i)); const p = Fl(e).map((e => f + r * e)); return n(c ? p.reverse() : p) } return delete e.unknown, e.domain = function (e) { return arguments.length ? (t(e), c()) : t() }, e.range = function (e) { return arguments.length ? (a = [+e[0], +e[1]], c()) : a.slice() }, e.rangeRound = function (e) { return a = [+e[0], +e[1]], o = !0, c() }, e.bandwidth = function () { return i }, e.step = function () { return r }, e.round = function (e) { return arguments.length ? (o = !!e, c()) : o }, e.padding = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), s = u, c()) : s }, e.paddingInner = function (e) { return arguments.length ? (s = Math.max(0, Math.min(1, e)), c()) : s }, e.paddingOuter = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), c()) : u }, e.align = function (e) { return arguments.length ? (l = Math.max(0, Math.min(1, e)), c()) : l }, e.invertRange = function (e) { if (null == e[0] || null == e[1]) return; const r = a[1] < a[0], o = r ? n().reverse() : n(), s = o.length - 1; let u, l, c, h = +e[0], d = +e[1]; return h != h || d != d || (d < h && (c = h, h = d, d = c), d < o[0] || h > a[1 - r]) ? void 0 : (u = Math.max(0, pR(o, h) - 1), l = h === d ? u : pR(o, d) - 1, h - o[u] > i + 1e-10 && ++u, r && (c = u, u = s - l, l = s - c), u > l ? void 0 : t().slice(u, l + 1)) }, e.invert = function (t) { const n = e.invertRange([t, t]); return n ? n[0] : n }, e.copy = function () { return I2().domain(t()).range(a).round(o).paddingInner(s).paddingOuter(u).align(l) }, c() } function M2(e) { const t = e.copy; return e.padding = e.paddingOuter, delete e.paddingInner, e.copy = function () { return M2(t()) }, e } var F2 = Array.prototype.map; const D2 = Array.prototype.slice; const $2 = {}; function R2(e, t, n) { return arguments.length > 1 ? ($2[e] = function (e, t, n) { const r = function () { const n = t(); return n.invertRange || (n.invertRange = n.invert ? function (e) { return function (t) { let n, r = t[0], i = t[1]; return i < r && (n = r, r = i, i = n), [e.invert(r), e.invert(i)] } }(n) : n.invertExtent ? function (e) { return function (t) { const n = e.range(); let r, i, a, o, s = t[0], u = t[1], l = -1; for (u < s && (i = s, s = u, u = i), a = 0, o = n.length; a < o; ++a)n[a] >= s && n[a] <= u && (l < 0 && (l = a), r = a); if (!(l < 0)) return s = e.invertExtent(n[l]), u = e.invertExtent(n[r]), [void 0 === s[0] ? s[1] : s[0], void 0 === u[1] ? u[0] : u[1]] } }(n) : void 0), n.type = e, n }; return r.metadata = function (e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t }(XK(n)), r }(e, t, n), this) : function (e) { return ZK($2, e) }(e) ? $2[e] : void 0 } R2("identity", (function e(t) { var n; function r(e) { return null == e || isNaN(e = +e) ? n : e } return r.invert = r, r.domain = r.range = function (e) { return arguments.length ? (t = Array.from(e, bZ), r) : t.slice() }, r.unknown = function (e) { return arguments.length ? (n = e, r) : n }, r.copy = function () { return e(t).unknown(n) }, t = arguments.length ? Array.from(t, bZ) : [0, 1], TZ(r) })), R2(f2, (function e() { var t = AZ(); return t.copy = function () { return _Z(t, e()) }, JK.apply(t, arguments), TZ(t) }), C2), R2(p2, (function e() { var t = RZ(CZ()).domain([1, 10]); return t.copy = function () { return _Z(t, e()).base(t.base()) }, JK.apply(t, arguments), t }), [C2, p2]), R2(m2, LZ, C2), R2(g2, (function () { return LZ.apply(null, arguments).exponent(.5) }), C2), R2(y2, (function e() { var t = WZ(CZ()); return t.copy = function () { return _Z(t, e()).constant(t.constant()) }, JK.apply(t, arguments) }), C2), R2(b2, (function () { return JK.apply(H0(WJ, VJ, wJ, vJ, hJ, lJ, sJ, aJ, rJ, CQ).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments) }), [C2, N2]), R2(v2, (function () { return JK.apply(H0(jJ, UJ, BJ, zJ, NJ, TJ, CJ, SJ, rJ, AQ).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments) }), [C2, N2]), R2(x2, X0, [C2, E2]), R2("".concat(x2, "-").concat(f2), X0, [C2, E2]), R2("".concat(x2, "-").concat(p2), (function e() { var t = RZ(q0()).domain([1, 10]); return t.copy = function () { return Y0(t, e()).base(t.base()) }, QK.apply(t, arguments) }), [C2, E2, p2]), R2("".concat(x2, "-").concat(m2), K0, [C2, E2]), R2("".concat(x2, "-").concat(g2), (function () { return K0.apply(null, arguments).exponent(.5) }), [C2, E2]), R2("".concat(x2, "-").concat(y2), (function e() { var t = WZ(q0()); return t.copy = function () { return Y0(t, e()).constant(t.constant()) }, QK.apply(t, arguments) }), [C2, E2]), R2("".concat(w2, "-").concat(f2), (function e() { var t = TZ(J0()(xZ)); return t.copy = function () { return Y0(t, e()) }, QK.apply(t, arguments) }), [C2, E2]), R2("".concat(w2, "-").concat(p2), (function e() { var t = RZ(J0()).domain([.1, 1, 10]); return t.copy = function () { return Y0(t, e()).base(t.base()) }, QK.apply(t, arguments) }), [C2, E2, p2]), R2("".concat(w2, "-").concat(m2), Q0, [C2, E2]), R2("".concat(w2, "-").concat(g2), (function () { return Q0.apply(null, arguments).exponent(.5) }), [C2, E2]), R2("".concat(w2, "-").concat(y2), (function e() { var t = WZ(J0()); return t.copy = function () { return Y0(t, e()).constant(t.constant()) }, QK.apply(t, arguments) }), [C2, E2]), R2(k2, (function e() { var t, n = [], r = [], i = []; function a() { var e = 0, t = Math.max(1, r.length); for (i = new Array(t - 1); ++e < t;)i[e - 1] = Il(n, e / t); return o } function o(e) { return null == e || isNaN(e = +e) ? t : r[gR(i, e)] } return o.invertExtent = function (e) { var t = r.indexOf(e); return t < 0 ? [NaN, NaN] : [t > 0 ? i[t - 1] : n[0], t < i.length ? i[t] : n[n.length - 1]] }, o.domain = function (e) { if (!arguments.length) return n.slice(); n = []; for (let t of e) null == t || isNaN(t = +t) || n.push(t); return n.sort(Cl), a() }, o.range = function (e) { return arguments.length ? (r = Array.from(e), a()) : r.slice() }, o.unknown = function (e) { return arguments.length ? (t = e, o) : t }, o.quantiles = function () { return i.slice() }, o.copy = function () { return e().domain(n).range(r).unknown(t) }, JK.apply(o, arguments) }), [T2, k2]), R2(S2, (function e() { var t, n = 0, r = 1, i = 1, a = [.5], o = [0, 1]; function s(e) { return null != e && e <= e ? o[gR(a, e, 0, i)] : t } function u() { var e = -1; for (a = new Array(i); ++e < i;)a[e] = ((e + 1) * r - (e - i) * n) / (i + 1); return s } return s.domain = function (e) { return arguments.length ? ([n, r] = e, n = +n, r = +r, u()) : [n, r] }, s.range = function (e) { return arguments.length ? (i = (o = Array.from(e)).length - 1, u()) : o.slice() }, s.invertExtent = function (e) { var t = o.indexOf(e); return t < 0 ? [NaN, NaN] : t < 1 ? [n, a[0]] : t >= i ? [a[i - 1], r] : [a[t - 1], a[t]] }, s.unknown = function (e) { return arguments.length ? (t = e, s) : s }, s.thresholds = function () { return a.slice() }, s.copy = function () { return e().domain([n, r]).range(o).unknown(t) }, JK.apply(TZ(s), arguments) }), T2), R2(_2, (function e() { var t, n = [.5], r = [0, 1], i = 1; function a(e) { return null != e && e <= e ? r[gR(n, e, 0, i)] : t } return a.domain = function (e) { return arguments.length ? (n = Array.from(e), i = Math.min(n.length, r.length - 1), a) : n.slice() }, a.range = function (e) { return arguments.length ? (r = Array.from(e), i = Math.min(n.length, r.length - 1), a) : r.slice() }, a.invertExtent = function (e) { var t = r.indexOf(e); return [n[t - 1], n[t]] }, a.unknown = function (e) { return arguments.length ? (t = e, a) : t }, a.copy = function () { return e().domain(n).range(r).unknown(t) }, JK.apply(a, arguments) }), T2), R2("bin-ordinal", (function e() { let t = [], n = []; function r(e) { return null == e || e != e ? void 0 : n[(gR(t, e) - 1) % n.length] } return r.domain = function (e) { return arguments.length ? (t = function (e) { return F2.call(e, YK) }(e), r) : t.slice() }, r.range = function (e) { return arguments.length ? (n = D2.call(e), r) : n.slice() }, r.tickFormat = function (e, n) { return yZ(t[0], qK(t), null == e ? 10 : e, n) }, r.copy = function () { return e().domain(r.domain()).range(r.range()) }, r }), [A2, T2]), R2("ordinal", tZ, A2), R2("band", I2, A2), R2("point", (function () { return M2(I2().paddingInner(1)) }), A2); function O2(e, t) { const n = t[0], r = qK(t) - n; return function (t) { return e(n + t * r) } } function z2(e, t, n) { return Z0(B2(t || "rgb", n), e) } function P2(e, t) { const n = new Array(t), r = t + 1; for (let i = 0; i < t;)n[i] = e(++i / r); return n } function B2(e, t) { const n = b[function (e) { return "interpolate" + e.toLowerCase().split("-").map((e => e[0].toUpperCase() + e.slice(1))).join("") }(e)]; return null != t && n && n.gamma ? n.gamma(t) : n } function L2(e) { const t = e.length / 6 | 0, n = new Array(t); for (let r = 0; r < t;)n[r] = "#" + e.slice(6 * r, 6 * ++r); return n } function j2(e, t) { for (const n in e) W2(n, t(e[n])) } const U2 = {}; function W2(e, t) { return e = e && e.toLowerCase(), arguments.length > 1 ? (U2[e] = t, this) : U2[e] } j2({ category10: "1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf", category20: "1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5", category20b: "393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6", category20c: "3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9", tableau10: "4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac", tableau20: "4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5", accent: "7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666", dark2: "1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666", paired: "a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928", pastel1: "fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2", pastel2: "b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc", set1: "e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999", set2: "66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3", set3: "8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f" }, L2), j2({ blues: "cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90", greens: "d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429", greys: "e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e", oranges: "fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303", purples: "e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c", reds: "fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13", blueGreen: "d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429", bluePurple: "ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71", greenBlue: "d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1", orangeRed: "fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403", purpleBlue: "dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281", purpleBlueGreen: "dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353", purpleRed: "dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a", redPurple: "fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174", yellowGreen: "e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034", yellowOrangeBrown: "feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204", yellowOrangeRed: "fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225", blueOrange: "134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07", brownBlueGreen: "704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147", purpleGreen: "5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29", purpleOrange: "4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07", redBlue: "8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85", redGrey: "8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434", yellowGreenBlue: "eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185", redYellowBlue: "a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695", redYellowGreen: "a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837", pinkYellowGreen: "8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419", spectral: "9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2", viridis: "440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725", magma: "0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf", inferno: "0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4", plasma: "0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921", cividis: "00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647", rainbow: "6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa", sinebow: "ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040", turbo: "23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00", browns: "eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632", tealBlues: "bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985", teals: "bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667", warmGreys: "dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e", goldGreen: "f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36", goldOrange: "f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26", goldRed: "f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e", lightGreyRed: "efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b", lightGreyTeal: "e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc", lightMulti: "e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c", lightOrange: "f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b", lightTealBlue: "e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988", darkBlue: "3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff", darkGold: "3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff", darkGreen: "3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa", darkMulti: "3737371f5287197d8c29a86995ce3fffe800ffffff", darkRed: "3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c" }, (e => z2(L2(e)))); const V2 = e => e; function G2(e, t) { e && q2.hasOwnProperty(e.type) && q2[e.type](e, t) } var H2 = { Feature: function (e, t) { G2(e.geometry, t) }, FeatureCollection: function (e, t) { for (var n = e.features, r = -1, i = n.length; ++r < i;)G2(n[r].geometry, t) } }, q2 = { Sphere: function (e, t) { t.sphere() }, Point: function (e, t) { e = e.coordinates, t.point(e[0], e[1], e[2]) }, MultiPoint: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)e = n[r], t.point(e[0], e[1], e[2]) }, LineString: function (e, t) { Y2(e.coordinates, t, 0) }, MultiLineString: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)Y2(n[r], t, 0) }, Polygon: function (e, t) { X2(e.coordinates, t) }, MultiPolygon: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)X2(n[r], t) }, GeometryCollection: function (e, t) { for (var n = e.geometries, r = -1, i = n.length; ++r < i;)G2(n[r], t) } }; function Y2(e, t, n) { var r, i = -1, a = e.length - n; for (t.lineStart(); ++i < a;)r = e[i], t.point(r[0], r[1], r[2]); t.lineEnd() } function X2(e, t) { var n = -1, r = e.length; for (t.polygonStart(); ++n < r;)Y2(e[n], t, 1); t.polygonEnd() } function K2(e, t) { e && H2.hasOwnProperty(e.type) ? H2[e.type](e, t) : G2(e, t) } class Z2 { constructor() { this._partials = new Float64Array(32), this._n = 0 } add(e) { const t = this._partials; let n = 0; for (let r = 0; r < this._n && r < 32; r++) { const i = t[r], a = e + i, o = Math.abs(e) < Math.abs(i) ? e - (a - i) : i - (a - e); o && (t[n++] = o), e = a } return t[n] = e, this._n = n + 1, this } valueOf() { const e = this._partials; let t, n, r, i = this._n, a = 0; if (i > 0) { for (a = e[--i]; i > 0 && (t = a, n = e[--i], a = t + n, r = n - (a - t), !r);); i > 0 && (r < 0 && e[i - 1] < 0 || r > 0 && e[i - 1] > 0) && (n = 2 * r, t = a + n, n == t - a && (a = t)) } return a } } function J2() { } var Q2, e3, t3, n3, r3 = new Z2, i3 = new Z2, a3 = { point: J2, lineStart: J2, lineEnd: J2, polygonStart: function () { a3.lineStart = o3, a3.lineEnd = l3 }, polygonEnd: function () { a3.lineStart = a3.lineEnd = a3.point = J2, r3.add(tM(i3)), i3 = new Z2 }, result: function () { var e = r3 / 2; return r3 = new Z2, e } }; function o3() { a3.point = s3 } function s3(e, t) { a3.point = u3, Q2 = t3 = e, e3 = n3 = t } function u3(e, t) { i3.add(n3 * e - t3 * t), t3 = e, n3 = t } function l3() { u3(Q2, e3) } const c3 = a3; var h3 = 1 / 0, d3 = h3, f3 = -h3, p3 = f3, m3 = { point: function (e, t) { e < h3 && (h3 = e); e > f3 && (f3 = e); t < d3 && (d3 = t); t > p3 && (p3 = t) }, lineStart: J2, lineEnd: J2, polygonStart: J2, polygonEnd: J2, result: function () { var e = [[h3, d3], [f3, p3]]; return f3 = p3 = -(d3 = h3 = 1 / 0), e } }; const g3 = m3; var y3, b3, v3, x3, w3 = 0, k3 = 0, S3 = 0, _3 = 0, C3 = 0, A3 = 0, T3 = 0, E3 = 0, N3 = 0, I3 = { point: M3, lineStart: F3, lineEnd: R3, polygonStart: function () { I3.lineStart = O3, I3.lineEnd = z3 }, polygonEnd: function () { I3.point = M3, I3.lineStart = F3, I3.lineEnd = R3 }, result: function () { var e = N3 ? [T3 / N3, E3 / N3] : A3 ? [_3 / A3, C3 / A3] : S3 ? [w3 / S3, k3 / S3] : [NaN, NaN]; return w3 = k3 = S3 = _3 = C3 = A3 = T3 = E3 = N3 = 0, e } }; function M3(e, t) { w3 += e, k3 += t, ++S3 } function F3() { I3.point = D3 } function D3(e, t) { I3.point = $3, M3(v3 = e, x3 = t) } function $3(e, t) { var n = e - v3, r = t - x3, i = dM(n * n + r * r); _3 += i * (v3 + e) / 2, C3 += i * (x3 + t) / 2, A3 += i, M3(v3 = e, x3 = t) } function R3() { I3.point = M3 } function O3() { I3.point = P3 } function z3() { B3(y3, b3) } function P3(e, t) { I3.point = B3, M3(y3 = v3 = e, b3 = x3 = t) } function B3(e, t) { var n = e - v3, r = t - x3, i = dM(n * n + r * r); _3 += i * (v3 + e) / 2, C3 += i * (x3 + t) / 2, A3 += i, T3 += (i = x3 * e - v3 * t) * (v3 + e), E3 += i * (x3 + t), N3 += 3 * i, M3(v3 = e, x3 = t) } const L3 = I3; function j3(e) { this._context = e } j3.prototype = { _radius: 4.5, pointRadius: function (e) { return this._radius = e, this }, polygonStart: function () { this._line = 0 }, polygonEnd: function () { this._line = NaN }, lineStart: function () { this._point = 0 }, lineEnd: function () { 0 === this._line && this._context.closePath(), this._point = NaN }, point: function (e, t) { switch (this._point) { case 0: this._context.moveTo(e, t), this._point = 1; break; case 1: this._context.lineTo(e, t); break; default: this._context.moveTo(e + this._radius, t), this._context.arc(e, t, this._radius, 0, JI) } }, result: J2 }; var U3, W3, V3, G3, H3, q3 = new Z2, Y3 = { point: J2, lineStart: function () { Y3.point = X3 }, lineEnd: function () { U3 && K3(W3, V3), Y3.point = J2 }, polygonStart: function () { U3 = !0 }, polygonEnd: function () { U3 = null }, result: function () { var e = +q3; return q3 = new Z2, e } }; function X3(e, t) { Y3.point = K3, W3 = G3 = e, V3 = H3 = t } function K3(e, t) { G3 -= e, H3 -= t, q3.add(dM(G3 * G3 + H3 * H3)), G3 = e, H3 = t } const Z3 = Y3; function J3() { this._string = [] } function Q3(e) { return "m0," + e + "a" + e + "," + e + " 0 1,1 0," + -2 * e + "a" + e + "," + e + " 0 1,1 0," + 2 * e + "z" } function e4(e, t) { var n, r, i = 4.5; function a(e) { return e && ("function" == typeof i && r.pointRadius(+i.apply(this, arguments)), K2(e, n(r))), r.result() } return a.area = function (e) { return K2(e, n(c3)), c3.result() }, a.measure = function (e) { return K2(e, n(Z3)), Z3.result() }, a.bounds = function (e) { return K2(e, n(g3)), g3.result() }, a.centroid = function (e) { return K2(e, n(L3)), L3.result() }, a.projection = function (t) { return arguments.length ? (n = null == t ? (e = null, V2) : (e = t).stream, a) : e }, a.context = function (e) { return arguments.length ? (r = null == e ? (t = null, new J3) : new j3(t = e), "function" != typeof i && r.pointRadius(i), a) : t }, a.pointRadius = function (e) { return arguments.length ? (i = "function" == typeof e ? e : (r.pointRadius(+e), +e), a) : i }, a.projection(e).context(t) } function t4() { var e, t = []; return { point: function (t, n, r) { e.push([t, n, r]) }, lineStart: function () { t.push(e = []) }, lineEnd: J2, rejoin: function () { t.length > 1 && t.push(t.pop().concat(t.shift())) }, result: function () { var n = t; return t = [], e = null, n } } } function n4(e, t) { return tM(e[0] - t[0]) < qI && tM(e[1] - t[1]) < qI } function r4(e, t, n, r) { this.x = e, this.z = t, this.o = n, this.e = r, this.v = !1, this.n = this.p = null } function i4(e, t, n, r, i) { var a, o, s = [], u = []; if (e.forEach((function (e) { if (!((t = e.length - 1) <= 0)) { var t, n, r = e[0], o = e[t]; if (n4(r, o)) { if (!r[2] && !o[2]) { for (i.lineStart(), a = 0; a < t; ++a)i.point((r = e[a])[0], r[1]); return void i.lineEnd() } o[0] += 2 * qI } s.push(n = new r4(r, e, null, !0)), u.push(n.o = new r4(r, null, n, !1)), s.push(n = new r4(o, e, null, !1)), u.push(n.o = new r4(o, null, n, !0)) } })), s.length) { for (u.sort(t), a4(s), a4(u), a = 0, o = u.length; a < o; ++a)u[a].e = n = !n; for (var l, c, h = s[0]; ;) { for (var d = h, f = !0; d.v;)if ((d = d.n) === h) return; l = d.z, i.lineStart(); do { if (d.v = d.o.v = !0, d.e) { if (f) for (a = 0, o = l.length; a < o; ++a)i.point((c = l[a])[0], c[1]); else r(d.x, d.n.x, 1, i); d = d.n } else { if (f) for (l = d.p.z, a = l.length - 1; a >= 0; --a)i.point((c = l[a])[0], c[1]); else r(d.x, d.p.x, -1, i); d = d.p } l = (d = d.o).z, f = !f } while (!d.v); i.lineEnd() } } } function a4(e) { if (t = e.length) { for (var t, n, r = 0, i = e[0]; ++r < t;)i.n = n = e[r], n.p = i, i = n; i.n = n = e[0], n.p = i } } function o4(e) { return [rM(e[1], e[0]), mM(e[2])] } function s4(e) { var t = e[0], n = e[1], r = iM(n); return [r * iM(t), r * cM(t), cM(n)] } function u4(e, t) { return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] } function l4(e, t) { return [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]] } function c4(e, t) { e[0] += t[0], e[1] += t[1], e[2] += t[2] } function h4(e, t) { return [e[0] * t, e[1] * t, e[2] * t] } function d4(e) { var t = dM(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]); e[0] /= t, e[1] /= t, e[2] /= t } function f4(e) { return tM(e[0]) <= XI ? e[0] : hM(e[0]) * ((tM(e[0]) + XI) % JI - XI) } function p4(e) { return Array.from(function* (e) { for (const t of e) yield* t }(e)) } function m4(e, t, n, r) { return function (i) { var a, o, s, u = t(i), l = t4(), c = t(l), h = !1, d = { point: f, lineStart: m, lineEnd: g, polygonStart: function () { d.point = y, d.lineStart = b, d.lineEnd = v, o = [], a = [] }, polygonEnd: function () { d.point = f, d.lineStart = m, d.lineEnd = g, o = p4(o); var e = function (e, t) { var n = f4(t), r = t[1], i = cM(r), a = [cM(n), -iM(n), 0], o = 0, s = 0, u = new Z2; 1 === i ? r = KI + qI : -1 === i && (r = -KI - qI); for (var l = 0, c = e.length; l < c; ++l)if (d = (h = e[l]).length) for (var h, d, f = h[d - 1], p = f4(f), m = f[1] / 2 + ZI, g = cM(m), y = iM(m), b = 0; b < d; ++b, p = x, g = k, y = S, f = v) { var v = h[b], x = f4(v), w = v[1] / 2 + ZI, k = cM(w), S = iM(w), _ = x - p, C = _ >= 0 ? 1 : -1, A = C * _, T = A > XI, E = g * k; if (u.add(rM(E * C * cM(A), y * S + E * iM(A))), o += T ? _ + C * JI : _, T ^ p >= n ^ x >= n) { var N = l4(s4(f), s4(v)); d4(N); var I = l4(a, N); d4(I); var M = (T ^ _ >= 0 ? -1 : 1) * mM(I[2]); (r > M || r === M && (N[0] || N[1])) && (s += T ^ _ >= 0 ? 1 : -1) } } return (o < -qI || o < qI && u < -1e-12) ^ 1 & s }(a, r); o.length ? (h || (i.polygonStart(), h = !0), i4(o, y4, e, n, i)) : e && (h || (i.polygonStart(), h = !0), i.lineStart(), n(null, null, 1, i), i.lineEnd()), h && (i.polygonEnd(), h = !1), o = a = null }, sphere: function () { i.polygonStart(), i.lineStart(), n(null, null, 1, i), i.lineEnd(), i.polygonEnd() } }; function f(t, n) { e(t, n) && i.point(t, n) } function p(e, t) { u.point(e, t) } function m() { d.point = p, u.lineStart() } function g() { d.point = f, u.lineEnd() } function y(e, t) { s.push([e, t]), c.point(e, t) } function b() { c.lineStart(), s = [] } function v() { y(s[0][0], s[0][1]), c.lineEnd(); var e, t, n, r, u = c.clean(), d = l.result(), f = d.length; if (s.pop(), a.push(s), s = null, f) if (1 & u) { if ((t = (n = d[0]).length - 1) > 0) { for (h || (i.polygonStart(), h = !0), i.lineStart(), e = 0; e < t; ++e)i.point((r = n[e])[0], r[1]); i.lineEnd() } } else f > 1 && 2 & u && d.push(d.pop().concat(d.shift())), o.push(d.filter(g4)) } return d } } function g4(e) { return e.length > 1 } function y4(e, t) { return ((e = e.x)[0] < 0 ? e[1] - KI - qI : KI - e[1]) - ((t = t.x)[0] < 0 ? t[1] - KI - qI : KI - t[1]) } J3.prototype = { _radius: 4.5, _circle: Q3(4.5), pointRadius: function (e) { return (e = +e) !== this._radius && (this._radius = e, this._circle = null), this }, polygonStart: function () { this._line = 0 }, polygonEnd: function () { this._line = NaN }, lineStart: function () { this._point = 0 }, lineEnd: function () { 0 === this._line && this._string.push("Z"), this._point = NaN }, point: function (e, t) { switch (this._point) { case 0: this._string.push("M", e, ",", t), this._point = 1; break; case 1: this._string.push("L", e, ",", t); break; default: null == this._circle && (this._circle = Q3(this._radius)), this._string.push("M", e, ",", t, this._circle) } }, result: function () { if (this._string.length) { var e = this._string.join(""); return this._string = [], e } return null } }; const b4 = m4((function () { return !0 }), (function (e) { var t, n = NaN, r = NaN, i = NaN; return { lineStart: function () { e.lineStart(), t = 1 }, point: function (a, o) { var s = a > 0 ? XI : -XI, u = tM(a - n); tM(u - XI) < qI ? (e.point(n, r = (r + o) / 2 > 0 ? KI : -KI), e.point(i, r), e.lineEnd(), e.lineStart(), e.point(s, r), e.point(a, r), t = 0) : i !== s && u >= XI && (tM(n - i) < qI && (n -= i * qI), tM(a - s) < qI && (a -= s * qI), r = function (e, t, n, r) { var i, a, o = cM(e - n); return tM(o) > qI ? nM((cM(t) * (a = iM(r)) * cM(n) - cM(r) * (i = iM(t)) * cM(e)) / (i * a * o)) : (t + r) / 2 }(n, r, a, o), e.point(i, r), e.lineEnd(), e.lineStart(), e.point(s, r), t = 0), e.point(n = a, r = o), i = s }, lineEnd: function () { e.lineEnd(), n = r = NaN }, clean: function () { return 2 - t } } }), (function (e, t, n, r) { var i; if (null == e) i = n * KI, r.point(-XI, i), r.point(0, i), r.point(XI, i), r.point(XI, 0), r.point(XI, -i), r.point(0, -i), r.point(-XI, -i), r.point(-XI, 0), r.point(-XI, i); else if (tM(e[0] - t[0]) > qI) { var a = e[0] < t[0] ? XI : -XI; i = n * a / 2, r.point(-a, i), r.point(0, i), r.point(a, i) } else r.point(t[0], t[1]) }), [-XI, -KI]); function v4(e, t, n, r, i, a) { if (n) { var o = iM(t), s = cM(t), u = r * n; null == i ? (i = t + r * JI, a = t - u / 2) : (i = x4(o, i), a = x4(o, a), (r > 0 ? i < a : i > a) && (i += r * JI)); for (var l, c = i; r > 0 ? c > a : c < a; c -= u)l = o4([o, -s * iM(c), -s * cM(c)]), e.point(l[0], l[1]) } } function x4(e, t) { (t = s4(t))[0] -= e, d4(t); var n = pM(-t[1]); return ((-t[2] < 0 ? -n : n) + JI - qI) % JI } var w4 = 1e9, k4 = -1e9; function S4(e, t, n, r) { function i(i, a) { return e <= i && i <= n && t <= a && a <= r } function a(i, a, s, l) { var c = 0, h = 0; if (null == i || (c = o(i, s)) !== (h = o(a, s)) || u(i, a) < 0 ^ s > 0) do { l.point(0 === c || 3 === c ? e : n, c > 1 ? r : t) } while ((c = (c + s + 4) % 4) !== h); else l.point(a[0], a[1]) } function o(r, i) { return tM(r[0] - e) < qI ? i > 0 ? 0 : 3 : tM(r[0] - n) < qI ? i > 0 ? 2 : 1 : tM(r[1] - t) < qI ? i > 0 ? 1 : 0 : i > 0 ? 3 : 2 } function s(e, t) { return u(e.x, t.x) } function u(e, t) { var n = o(e, 1), r = o(t, 1); return n !== r ? n - r : 0 === n ? t[1] - e[1] : 1 === n ? e[0] - t[0] : 2 === n ? e[1] - t[1] : t[0] - e[0] } return function (o) { var u, l, c, h, d, f, p, m, g, y, b, v = o, x = t4(), w = { point: k, lineStart: function () { w.point = S, l && l.push(c = []); y = !0, g = !1, p = m = NaN }, lineEnd: function () { u && (S(h, d), f && g && x.rejoin(), u.push(x.result())); w.point = k, g && v.lineEnd() }, polygonStart: function () { v = x, u = [], l = [], b = !0 }, polygonEnd: function () { var t = function () { for (var t = 0, n = 0, i = l.length; n < i; ++n)for (var a, o, s = l[n], u = 1, c = s.length, h = s[0], d = h[0], f = h[1]; u < c; ++u)a = d, o = f, d = (h = s[u])[0], f = h[1], o <= r ? f > r && (d - a) * (r - o) > (f - o) * (e - a) && ++t : f <= r && (d - a) * (r - o) < (f - o) * (e - a) && --t; return t }(), n = b && t, i = (u = p4(u)).length; (n || i) && (o.polygonStart(), n && (o.lineStart(), a(null, null, 1, o), o.lineEnd()), i && i4(u, s, t, a, o), o.polygonEnd()); v = o, u = l = c = null } }; function k(e, t) { i(e, t) && v.point(e, t) } function S(a, o) { var s = i(a, o); if (l && c.push([a, o]), y) h = a, d = o, f = s, y = !1, s && (v.lineStart(), v.point(a, o)); else if (s && g) v.point(a, o); else { var u = [p = Math.max(k4, Math.min(w4, p)), m = Math.max(k4, Math.min(w4, m))], x = [a = Math.max(k4, Math.min(w4, a)), o = Math.max(k4, Math.min(w4, o))]; !function (e, t, n, r, i, a) { var o, s = e[0], u = e[1], l = 0, c = 1, h = t[0] - s, d = t[1] - u; if (o = n - s, h || !(o > 0)) { if (o /= h, h < 0) { if (o < l) return; o < c && (c = o) } else if (h > 0) { if (o > c) return; o > l && (l = o) } if (o = i - s, h || !(o < 0)) { if (o /= h, h < 0) { if (o > c) return; o > l && (l = o) } else if (h > 0) { if (o < l) return; o < c && (c = o) } if (o = r - u, d || !(o > 0)) { if (o /= d, d < 0) { if (o < l) return; o < c && (c = o) } else if (d > 0) { if (o > c) return; o > l && (l = o) } if (o = a - u, d || !(o < 0)) { if (o /= d, d < 0) { if (o > c) return; o > l && (l = o) } else if (d > 0) { if (o < l) return; o < c && (c = o) } return l > 0 && (e[0] = s + l * h, e[1] = u + l * d), c < 1 && (t[0] = s + c * h, t[1] = u + c * d), !0 } } } } }(u, x, e, t, n, r) ? s && (v.lineStart(), v.point(a, o), b = !1) : (g || (v.lineStart(), v.point(u[0], u[1])), v.point(x[0], x[1]), s || v.lineEnd(), b = !1) } p = a, m = o, g = s } return w } } function _4(e, t) { function n(n, r) { return n = e(n, r), t(n[0], n[1]) } return e.invert && t.invert && (n.invert = function (n, r) { return (n = t.invert(n, r)) && e.invert(n[0], n[1]) }), n } function C4(e, t) { return [tM(e) > XI ? e + Math.round(-e / JI) * JI : e, t] } function A4(e, t, n) { return (e %= JI) ? t || n ? _4(E4(e), N4(t, n)) : E4(e) : t || n ? N4(t, n) : C4 } function T4(e) { return function (t, n) { return [(t += e) > XI ? t - JI : t < -XI ? t + JI : t, n] } } function E4(e) { var t = T4(e); return t.invert = T4(-e), t } function N4(e, t) { var n = iM(e), r = cM(e), i = iM(t), a = cM(t); function o(e, t) { var o = iM(t), s = iM(e) * o, u = cM(e) * o, l = cM(t), c = l * n + s * r; return [rM(u * i - c * a, s * n - l * r), mM(c * i + u * a)] } return o.invert = function (e, t) { var o = iM(t), s = iM(e) * o, u = cM(e) * o, l = cM(t), c = l * i - u * a; return [rM(u * i + l * a, s * n + c * r), mM(c * n - s * r)] }, o } function I4(e) { return function (t) { var n = new M4; for (var r in e) n[r] = e[r]; return n.stream = t, n } } function M4() { } function F4(e, t, n) { var r = e.clipExtent && e.clipExtent(); return e.scale(150).translate([0, 0]), null != r && e.clipExtent(null), K2(n, e.stream(g3)), t(g3.result()), null != r && e.clipExtent(r), e } function D4(e, t, n) { return F4(e, (function (n) { var r = t[1][0] - t[0][0], i = t[1][1] - t[0][1], a = Math.min(r / (n[1][0] - n[0][0]), i / (n[1][1] - n[0][1])), o = +t[0][0] + (r - a * (n[1][0] + n[0][0])) / 2, s = +t[0][1] + (i - a * (n[1][1] + n[0][1])) / 2; e.scale(150 * a).translate([o, s]) }), n) } function $4(e, t, n) { return D4(e, [[0, 0], t], n) } function R4(e, t, n) { return F4(e, (function (n) { var r = +t, i = r / (n[1][0] - n[0][0]), a = (r - i * (n[1][0] + n[0][0])) / 2, o = -i * n[0][1]; e.scale(150 * i).translate([a, o]) }), n) } function O4(e, t, n) { return F4(e, (function (n) { var r = +t, i = r / (n[1][1] - n[0][1]), a = -i * n[0][0], o = (r - i * (n[1][1] + n[0][1])) / 2; e.scale(150 * i).translate([a, o]) }), n) } C4.invert = C4, M4.prototype = { constructor: M4, point: function (e, t) { this.stream.point(e, t) }, sphere: function () { this.stream.sphere() }, lineStart: function () { this.stream.lineStart() }, lineEnd: function () { this.stream.lineEnd() }, polygonStart: function () { this.stream.polygonStart() }, polygonEnd: function () { this.stream.polygonEnd() } }; var z4 = iM(30 * eM); function P4(e, t) { return +t ? function (e, t) { function n(r, i, a, o, s, u, l, c, h, d, f, p, m, g) { var y = l - r, b = c - i, v = y * y + b * b; if (v > 4 * t && m--) { var x = o + d, w = s + f, k = u + p, S = dM(x * x + w * w + k * k), _ = mM(k /= S), C = tM(tM(k) - 1) < qI || tM(a - h) < qI ? (a + h) / 2 : rM(w, x), A = e(C, _), T = A[0], E = A[1], N = T - r, I = E - i, M = b * N - y * I; (M * M / v > t || tM((y * N + b * I) / v - .5) > .3 || o * d + s * f + u * p < z4) && (n(r, i, a, o, s, u, T, E, C, x /= S, w /= S, k, m, g), g.point(T, E), n(T, E, C, x, w, k, l, c, h, d, f, p, m, g)) } } return function (t) { var r, i, a, o, s, u, l, c, h, d, f, p, m = { point: g, lineStart: y, lineEnd: v, polygonStart: function () { t.polygonStart(), m.lineStart = x }, polygonEnd: function () { t.polygonEnd(), m.lineStart = y } }; function g(n, r) { n = e(n, r), t.point(n[0], n[1]) } function y() { c = NaN, m.point = b, t.lineStart() } function b(r, i) { var a = s4([r, i]), o = e(r, i); n(c, h, l, d, f, p, c = o[0], h = o[1], l = r, d = a[0], f = a[1], p = a[2], 16, t), t.point(c, h) } function v() { m.point = g, t.lineEnd() } function x() { y(), m.point = w, m.lineEnd = k } function w(e, t) { b(r = e, t), i = c, a = h, o = d, s = f, u = p, m.point = b } function k() { n(c, h, l, d, f, p, i, a, r, o, s, u, 16, t), m.lineEnd = v, v() } return m } }(e, t) : function (e) { return I4({ point: function (t, n) { t = e(t, n), this.stream.point(t[0], t[1]) } }) }(e) } var B4 = I4({ point: function (e, t) { this.stream.point(e * eM, t * eM) } }); function L4(e, t, n, r, i, a) { if (!a) return function (e, t, n, r, i) { function a(a, o) { return [t + e * (a *= r), n - e * (o *= i)] } return a.invert = function (a, o) { return [(a - t) / e * r, (n - o) / e * i] }, a }(e, t, n, r, i); var o = iM(a), s = cM(a), u = o * e, l = s * e, c = o / e, h = s / e, d = (s * n - o * t) / e, f = (s * t + o * n) / e; function p(e, a) { return [u * (e *= r) - l * (a *= i) + t, n - l * e - u * a] } return p.invert = function (e, t) { return [r * (c * e - h * t + d), i * (f - h * e - c * t)] }, p } function j4(e) { return U4((function () { return e }))() } function U4(e) { var t, n, r, i, a, o, s, u, l, c, h = 150, d = 480, f = 250, p = 0, m = 0, g = 0, y = 0, b = 0, v = 0, x = 1, w = 1, k = null, S = b4, _ = null, C = V2, A = .5; function T(e) { return u(e[0] * eM, e[1] * eM) } function E(e) { return (e = u.invert(e[0], e[1])) && [e[0] * QI, e[1] * QI] } function N() { var e = L4(h, 0, 0, x, w, v).apply(null, t(p, m)), r = L4(h, d - e[0], f - e[1], x, w, v); return n = A4(g, y, b), s = _4(t, r), u = _4(n, s), o = P4(s, A), I() } function I() { return l = c = null, T } return T.stream = function (e) { return l && c === e ? l : l = B4(function (e) { return I4({ point: function (t, n) { var r = e(t, n); return this.stream.point(r[0], r[1]) } }) }(n)(S(o(C(c = e))))) }, T.preclip = function (e) { return arguments.length ? (S = e, k = void 0, I()) : S }, T.postclip = function (e) { return arguments.length ? (C = e, _ = r = i = a = null, I()) : C }, T.clipAngle = function (e) { return arguments.length ? (S = +e ? function (e) { var t = iM(e), n = 6 * eM, r = t > 0, i = tM(t) > qI; function a(e, n) { return iM(e) * iM(n) > t } function o(e, n, r) { var i = [1, 0, 0], a = l4(s4(e), s4(n)), o = u4(a, a), s = a[0], u = o - s * s; if (!u) return !r && e; var l = t * o / u, c = -t * s / u, h = l4(i, a), d = h4(i, l); c4(d, h4(a, c)); var f = h, p = u4(d, f), m = u4(f, f), g = p * p - m * (u4(d, d) - 1); if (!(g < 0)) { var y = dM(g), b = h4(f, (-p - y) / m); if (c4(b, d), b = o4(b), !r) return b; var v, x = e[0], w = n[0], k = e[1], S = n[1]; w < x && (v = x, x = w, w = v); var _ = w - x, C = tM(_ - XI) < qI; if (!C && S < k && (v = k, k = S, S = v), C || _ < qI ? C ? k + S > 0 ^ b[1] < (tM(b[0] - x) < qI ? k : S) : k <= b[1] && b[1] <= S : _ > XI ^ (x <= b[0] && b[0] <= w)) { var A = h4(f, (-p + y) / m); return c4(A, d), [b, o4(A)] } } } function s(t, n) { var i = r ? e : XI - e, a = 0; return t < -i ? a |= 1 : t > i && (a |= 2), n < -i ? a |= 4 : n > i && (a |= 8), a } return m4(a, (function (e) { var t, n, u, l, c; return { lineStart: function () { l = u = !1, c = 1 }, point: function (h, d) { var f, p = [h, d], m = a(h, d), g = r ? m ? 0 : s(h, d) : m ? s(h + (h < 0 ? XI : -XI), d) : 0; if (!t && (l = u = m) && e.lineStart(), m !== u && (!(f = o(t, p)) || n4(t, f) || n4(p, f)) && (p[2] = 1), m !== u) c = 0, m ? (e.lineStart(), f = o(p, t), e.point(f[0], f[1])) : (f = o(t, p), e.point(f[0], f[1], 2), e.lineEnd()), t = f; else if (i && t && r ^ m) { var y; g & n || !(y = o(p, t, !0)) || (c = 0, r ? (e.lineStart(), e.point(y[0][0], y[0][1]), e.point(y[1][0], y[1][1]), e.lineEnd()) : (e.point(y[1][0], y[1][1]), e.lineEnd(), e.lineStart(), e.point(y[0][0], y[0][1], 3))) } !m || t && n4(t, p) || e.point(p[0], p[1]), t = p, u = m, n = g }, lineEnd: function () { u && e.lineEnd(), t = null }, clean: function () { return c | (l && u) << 1 } } }), (function (t, r, i, a) { v4(a, e, n, i, t, r) }), r ? [0, -e] : [-XI, e - XI]) }(k = e * eM) : (k = null, b4), I()) : k * QI }, T.clipExtent = function (e) { return arguments.length ? (C = null == e ? (_ = r = i = a = null, V2) : S4(_ = +e[0][0], r = +e[0][1], i = +e[1][0], a = +e[1][1]), I()) : null == _ ? null : [[_, r], [i, a]] }, T.scale = function (e) { return arguments.length ? (h = +e, N()) : h }, T.translate = function (e) { return arguments.length ? (d = +e[0], f = +e[1], N()) : [d, f] }, T.center = function (e) { return arguments.length ? (p = e[0] % 360 * eM, m = e[1] % 360 * eM, N()) : [p * QI, m * QI] }, T.rotate = function (e) { return arguments.length ? (g = e[0] % 360 * eM, y = e[1] % 360 * eM, b = e.length > 2 ? e[2] % 360 * eM : 0, N()) : [g * QI, y * QI, b * QI] }, T.angle = function (e) { return arguments.length ? (v = e % 360 * eM, N()) : v * QI }, T.reflectX = function (e) { return arguments.length ? (x = e ? -1 : 1, N()) : x < 0 }, T.reflectY = function (e) { return arguments.length ? (w = e ? -1 : 1, N()) : w < 0 }, T.precision = function (e) { return arguments.length ? (o = P4(s, A = e * e), I()) : dM(A) }, T.fitExtent = function (e, t) { return D4(T, e, t) }, T.fitSize = function (e, t) { return $4(T, e, t) }, T.fitWidth = function (e, t) { return R4(T, e, t) }, T.fitHeight = function (e, t) { return O4(T, e, t) }, function () { return t = e.apply(this, arguments), T.invert = t.invert && E, N() } } function W4(e) { var t = 0, n = XI / 3, r = U4(e), i = r(t, n); return i.parallels = function (e) { return arguments.length ? r(t = e[0] * eM, n = e[1] * eM) : [t * QI, n * QI] }, i } function V4(e, t) { var n = cM(e), r = (n + cM(t)) / 2; if (tM(r) < qI) return function (e) { var t = iM(e); function n(e, n) { return [e * t, cM(n) / t] } return n.invert = function (e, n) { return [e / t, mM(n * t)] }, n }(e); var i = 1 + n * (2 * r - n), a = dM(i) / r; function o(e, t) { var n = dM(i - 2 * r * cM(t)) / r; return [n * cM(e *= r), a - n * iM(e)] } return o.invert = function (e, t) { var n = a - t, o = rM(e, tM(n)) * hM(n); return n * r < 0 && (o -= XI * hM(e) * hM(n)), [o / r, mM((i - (e * e + n * n) * r * r) / (2 * r))] }, o } function G4() { return W4(V4).scale(155.424).center([0, 33.6442]) } function H4() { return G4().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-.6, 38.7]) } function q4(e) { return function (t, n) { var r = iM(t), i = iM(n), a = e(r * i); return a === 1 / 0 ? [2, 0] : [a * i * cM(t), a * cM(n)] } } function Y4(e) { return function (t, n) { var r = dM(t * t + n * n), i = e(r), a = cM(i), o = iM(i); return [rM(t * a, r * o), mM(r && n * a / r)] } } var X4 = q4((function (e) { return dM(2 / (1 + e)) })); X4.invert = Y4((function (e) { return 2 * mM(e / 2) })); var K4 = q4((function (e) { return (e = pM(e)) && e / cM(e) })); function Z4(e, t) { return [e, uM(fM((KI + t) / 2))] } function J4(e) { var t, n, r, i = j4(e), a = i.center, o = i.scale, s = i.translate, u = i.clipExtent, l = null; function c() { var a = XI * o(), s = i(function (e) { function t(t) { return (t = e(t[0] * eM, t[1] * eM))[0] *= QI, t[1] *= QI, t } return e = A4(e[0] * eM, e[1] * eM, e.length > 2 ? e[2] * eM : 0), t.invert = function (t) { return (t = e.invert(t[0] * eM, t[1] * eM))[0] *= QI, t[1] *= QI, t }, t }(i.rotate()).invert([0, 0])); return u(null == l ? [[s[0] - a, s[1] - a], [s[0] + a, s[1] + a]] : e === Z4 ? [[Math.max(s[0] - a, l), t], [Math.min(s[0] + a, n), r]] : [[l, Math.max(s[1] - a, t)], [n, Math.min(s[1] + a, r)]]) } return i.scale = function (e) { return arguments.length ? (o(e), c()) : o() }, i.translate = function (e) { return arguments.length ? (s(e), c()) : s() }, i.center = function (e) { return arguments.length ? (a(e), c()) : a() }, i.clipExtent = function (e) { return arguments.length ? (null == e ? l = t = n = r = null : (l = +e[0][0], t = +e[0][1], n = +e[1][0], r = +e[1][1]), c()) : null == l ? null : [[l, t], [n, r]] }, c() } function Q4(e) { return fM((KI + e) / 2) } function e5(e, t) { var n = iM(e), r = e === t ? cM(e) : uM(n / iM(t)) / uM(Q4(t) / Q4(e)), i = n * lM(Q4(e), r) / r; if (!r) return Z4; function a(e, t) { i > 0 ? t < -KI + qI && (t = -KI + qI) : t > KI - qI && (t = KI - qI); var n = i / lM(Q4(t), r); return [n * cM(r * e), i - n * iM(r * e)] } return a.invert = function (e, t) { var n = i - t, a = hM(r) * dM(e * e + n * n), o = rM(e, tM(n)) * hM(n); return n * r < 0 && (o -= XI * hM(e) * hM(n)), [o / r, 2 * nM(lM(i / a, 1 / r)) - KI] }, a } function t5(e, t) { return [e, t] } function n5(e, t) { var n = iM(e), r = e === t ? cM(e) : (n - iM(t)) / (t - e), i = n / r + e; if (tM(r) < qI) return t5; function a(e, t) { var n = i - t, a = r * e; return [n * cM(a), i - n * iM(a)] } return a.invert = function (e, t) { var n = i - t, a = rM(e, tM(n)) * hM(n); return n * r < 0 && (a -= XI * hM(e) * hM(n)), [a / r, i - hM(r) * dM(e * e + n * n)] }, a } K4.invert = Y4((function (e) { return e })), Z4.invert = function (e, t) { return [e, 2 * nM(oM(t)) - KI] }, t5.invert = t5; var r5 = 1.340264, i5 = -.081106, a5 = 893e-6, o5 = .003796, s5 = dM(3) / 2; function u5(e, t) { var n = mM(s5 * cM(t)), r = n * n, i = r * r * r; return [e * iM(n) / (s5 * (r5 + 3 * i5 * r + i * (7 * a5 + .034164 * r))), n * (r5 + i5 * r + i * (a5 + o5 * r))] } function l5(e, t) { var n = iM(t), r = iM(e) * n; return [n * cM(e) / r, cM(t) / r] } function c5(e, t) { var n = t * t, r = n * n; return [e * (.8707 - .131979 * n + r * (r * (.003971 * n - .001529 * r) - .013791)), t * (1.007226 + n * (.015085 + r * (.028874 * n - .044475 - .005916 * r)))] } function h5(e, t) { return [iM(t) * cM(e), cM(t)] } function d5(e, t) { var n = iM(t), r = 1 + iM(e) * n; return [n * cM(e) / r, cM(t) / r] } function f5(e, t) { return [uM(fM((KI + t) / 2)), -e] } u5.invert = function (e, t) { for (var n, r = t, i = r * r, a = i * i * i, o = 0; o < 12 && (a = (i = (r -= n = (r * (r5 + i5 * i + a * (a5 + o5 * i)) - t) / (r5 + 3 * i5 * i + a * (7 * a5 + .034164 * i))) * r) * i * i, !(tM(n) < YI)); ++o); return [s5 * e * (r5 + 3 * i5 * i + a * (7 * a5 + .034164 * i)) / iM(r), mM(cM(r) / s5)] }, l5.invert = Y4(nM), c5.invert = function (e, t) { var n, r = t, i = 25; do { var a = r * r, o = a * a; r -= n = (r * (1.007226 + a * (.015085 + o * (.028874 * a - .044475 - .005916 * o))) - t) / (1.007226 + a * (.045255 + o * (.259866 * a - .311325 - .005916 * 11 * o))) } while (tM(n) > qI && --i > 0); return [e / (.8707 + (a = r * r) * (a * (a * a * a * (.003971 - .001529 * a) - .013791) - .131979)), r] }, h5.invert = Y4(mM), d5.invert = Y4((function (e) { return 2 * nM(e) })), f5.invert = function (e, t) { return [-t, 2 * nM(oM(e)) - KI] }; var p5 = Math.abs, m5 = (Math.atan, Math.atan2, Math.ceil, Math.cos), g5 = (Math.exp, Math.floor, Math.log, Math.max, Math.min, Math.pow, Math.round, Math.sign, Math.sin), y5 = (Math.tan, Math.PI), b5 = y5 / 2, v5 = (Math.SQRT1_2, w5(2)); w5(y5); function x5(e) { return e > 1 ? b5 : e < -1 ? -b5 : Math.asin(e) } function w5(e) { return e > 0 ? Math.sqrt(e) : 0 } function k5(e, t) { var n, r = e * g5(t), i = 30; do { t -= n = (t + g5(t) - r) / (1 + m5(t)) } while (p5(n) > 1e-6 && --i > 0); return t / 2 } var S5 = function (e, t, n) { function r(r, i) { return [e * r * m5(i = k5(n, i)), t * g5(i)] } return r.invert = function (r, i) { return i = x5(i / t), [r / (e * m5(i)), x5((2 * i + g5(2 * i)) / n)] }, r }(v5 / b5, v5, y5); e4(); const _5 = ["clipAngle", "clipExtent", "scale", "translate", "center", "rotate", "parallels", "precision", "reflectX", "reflectY", "coefficient", "distance", "fraction", "lobes", "parallel", "radius", "ratio", "spacing", "tilt"]; function C5(e, t) { if (!e || "string" != typeof e) throw new Error("Projection type must be a name string."); return e = e.toLowerCase(), arguments.length > 1 ? (A5[e] = function (e, t) { return function n() { const r = t(); return r.type = e, r.path = e4().projection(r), r.copy = r.copy || function () { const e = n(); return _5.forEach((t => { r[t] && e[t](r[t]()) })), e.path.pointRadius(r.path.pointRadius()), e }, r } }(e, t), this) : A5[e] || null } const A5 = { albers: H4, albersusa: function () { var e, t, n, r, i, a, o = H4(), s = G4().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), u = G4().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), l = { point: function (e, t) { a = [e, t] } }; function c(e) { var t = e[0], o = e[1]; return a = null, n.point(t, o), a || (r.point(t, o), a) || (i.point(t, o), a) } function h() { return e = t = null, c } return c.invert = function (e) { var t = o.scale(), n = o.translate(), r = (e[0] - n[0]) / t, i = (e[1] - n[1]) / t; return (i >= .12 && i < .234 && r >= -.425 && r < -.214 ? s : i >= .166 && i < .234 && r >= -.214 && r < -.115 ? u : o).invert(e) }, c.stream = function (n) { return e && t === n ? e : e = function (e) { var t = e.length; return { point: function (n, r) { for (var i = -1; ++i < t;)e[i].point(n, r) }, sphere: function () { for (var n = -1; ++n < t;)e[n].sphere() }, lineStart: function () { for (var n = -1; ++n < t;)e[n].lineStart() }, lineEnd: function () { for (var n = -1; ++n < t;)e[n].lineEnd() }, polygonStart: function () { for (var n = -1; ++n < t;)e[n].polygonStart() }, polygonEnd: function () { for (var n = -1; ++n < t;)e[n].polygonEnd() } } }([o.stream(t = n), s.stream(n), u.stream(n)]) }, c.precision = function (e) { return arguments.length ? (o.precision(e), s.precision(e), u.precision(e), h()) : o.precision() }, c.scale = function (e) { return arguments.length ? (o.scale(e), s.scale(.35 * e), u.scale(e), c.translate(o.translate())) : o.scale() }, c.translate = function (e) { if (!arguments.length) return o.translate(); var t = o.scale(), a = +e[0], c = +e[1]; return n = o.translate(e).clipExtent([[a - .455 * t, c - .238 * t], [a + .455 * t, c + .238 * t]]).stream(l), r = s.translate([a - .307 * t, c + .201 * t]).clipExtent([[a - .425 * t + qI, c + .12 * t + qI], [a - .214 * t - qI, c + .234 * t - qI]]).stream(l), i = u.translate([a - .205 * t, c + .212 * t]).clipExtent([[a - .214 * t + qI, c + .166 * t + qI], [a - .115 * t - qI, c + .234 * t - qI]]).stream(l), h() }, c.fitExtent = function (e, t) { return D4(c, e, t) }, c.fitSize = function (e, t) { return $4(c, e, t) }, c.fitWidth = function (e, t) { return R4(c, e, t) }, c.fitHeight = function (e, t) { return O4(c, e, t) }, c.scale(1070) }, azimuthalequalarea: function () { return j4(X4).scale(124.75).clipAngle(179.999) }, azimuthalequidistant: function () { return j4(K4).scale(79.4188).clipAngle(179.999) }, conicconformal: function () { return W4(e5).scale(109.5).parallels([30, 30]) }, conicequalarea: G4, conicequidistant: function () { return W4(n5).scale(131.154).center([0, 13.9389]) }, equalEarth: function () { return j4(u5).scale(177.158) }, equirectangular: function () { return j4(t5).scale(152.63) }, gnomonic: function () { return j4(l5).scale(144.049).clipAngle(60) }, identity: function () { var e, t, n, r, i, a, o, s = 1, u = 0, l = 0, c = 1, h = 1, d = 0, f = null, p = 1, m = 1, g = I4({ point: function (e, t) { var n = v([e, t]); this.stream.point(n[0], n[1]) } }), y = V2; function b() { return p = s * c, m = s * h, a = o = null, v } function v(n) { var r = n[0] * p, i = n[1] * m; if (d) { var a = i * e - r * t; r = r * e + i * t, i = a } return [r + u, i + l] } return v.invert = function (n) { var r = n[0] - u, i = n[1] - l; if (d) { var a = i * e + r * t; r = r * e - i * t, i = a } return [r / p, i / m] }, v.stream = function (e) { return a && o === e ? a : a = g(y(o = e)) }, v.postclip = function (e) { return arguments.length ? (y = e, f = n = r = i = null, b()) : y }, v.clipExtent = function (e) { return arguments.length ? (y = null == e ? (f = n = r = i = null, V2) : S4(f = +e[0][0], n = +e[0][1], r = +e[1][0], i = +e[1][1]), b()) : null == f ? null : [[f, n], [r, i]] }, v.scale = function (e) { return arguments.length ? (s = +e, b()) : s }, v.translate = function (e) { return arguments.length ? (u = +e[0], l = +e[1], b()) : [u, l] }, v.angle = function (n) { return arguments.length ? (t = cM(d = n % 360 * eM), e = iM(d), b()) : d * QI }, v.reflectX = function (e) { return arguments.length ? (c = e ? -1 : 1, b()) : c < 0 }, v.reflectY = function (e) { return arguments.length ? (h = e ? -1 : 1, b()) : h < 0 }, v.fitExtent = function (e, t) { return D4(v, e, t) }, v.fitSize = function (e, t) { return $4(v, e, t) }, v.fitWidth = function (e, t) { return R4(v, e, t) }, v.fitHeight = function (e, t) { return O4(v, e, t) }, v }, mercator: function () { return J4(Z4).scale(961 / JI) }, mollweide: function () { return j4(S5).scale(169.529) }, naturalEarth1: function () { return j4(c5).scale(175.295) }, orthographic: function () { return j4(h5).scale(249.5).clipAngle(90 + qI) }, stereographic: function () { return j4(d5).scale(250).clipAngle(142) }, transversemercator: function () { var e = J4(f5), t = e.center, n = e.rotate; return e.center = function (e) { return arguments.length ? t([-e[1], e[0]]) : [(e = t())[1], -e[0]] }, e.rotate = function (e) { return arguments.length ? n([e[0], e[1], e.length > 2 ? e[2] + 90 : 90]) : [(e = n())[0], e[1], e[2] - 90] }, n([0, 0, 90]).scale(159.155) } }; for (const e in A5) C5(e, A5[e]); const T5 = "Literal", E5 = "Property", N5 = "ArrayExpression", I5 = "BinaryExpression", M5 = "CallExpression", F5 = "ConditionalExpression", D5 = "LogicalExpression", $5 = "MemberExpression", R5 = "ObjectExpression", O5 = "UnaryExpression"; function z5(e) { this.type = e } var P5, B5, L5, j5, U5; z5.prototype.visit = function (e) { let t, n, r; if (e(this)) return 1; for (t = function (e) { switch (e.type) { case N5: return e.elements; case I5: case D5: return [e.left, e.right]; case M5: return [e.callee].concat(e.arguments); case F5: return [e.test, e.consequent, e.alternate]; case $5: return [e.object, e.property]; case R5: return e.properties; case E5: return [e.key, e.value]; case O5: return [e.argument]; default: return [] } }(this), n = 0, r = t.length; n < r; ++n)if (t[n].visit(e)) return 1 }; var W5 = 1, V5 = 2, G5 = 3, H5 = 4, q5 = 5, Y5 = 6, X5 = 7, K5 = 8; (P5 = {})[W5] = "Boolean", P5[V5] = "", P5[G5] = "Identifier", P5[H5] = "Keyword", P5[q5] = "Null", P5[Y5] = "Numeric", P5[X5] = "Punctuator", P5[K5] = "String", P5[9] = "RegularExpression"; var Z5 = "ArrayExpression", J5 = "BinaryExpression", Q5 = "CallExpression", e6 = "ConditionalExpression", t6 = "Identifier", n6 = "Literal", r6 = "LogicalExpression", i6 = "MemberExpression", a6 = "ObjectExpression", o6 = "Property", s6 = "UnaryExpression", u6 = "Unexpected token %0", l6 = "Unexpected number", c6 = "Unexpected string", h6 = "Unexpected identifier", d6 = "Unexpected reserved word", f6 = "Unexpected end of input", p6 = "Invalid regular expression", m6 = "Invalid regular expression: missing /", g6 = "Octal literals are not allowed in strict mode.", y6 = "Duplicate data property in object literal not allowed in strict mode", b6 = "ILLEGAL", v6 = "Disabled.", x6 = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), w6 = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"); function k6(e, t) { if (!e) throw new Error("ASSERT: " + t) } function S6(e) { return e >= 48 && e <= 57 } function _6(e) { return "0123456789abcdefABCDEF".includes(e) } function C6(e) { return "01234567".includes(e) } function A6(e) { return 32 === e || 9 === e || 11 === e || 12 === e || 160 === e || e >= 5760 && [5760, 6158, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].includes(e) } function T6(e) { return 10 === e || 13 === e || 8232 === e || 8233 === e } function E6(e) { return 36 === e || 95 === e || e >= 65 && e <= 90 || e >= 97 && e <= 122 || 92 === e || e >= 128 && x6.test(String.fromCharCode(e)) } function N6(e) { return 36 === e || 95 === e || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57 || 92 === e || e >= 128 && w6.test(String.fromCharCode(e)) } const I6 = { if: 1, in: 1, do: 1, var: 1, for: 1, new: 1, try: 1, let: 1, this: 1, else: 1, case: 1, void: 1, with: 1, enum: 1, while: 1, break: 1, catch: 1, throw: 1, const: 1, yield: 1, class: 1, super: 1, return: 1, typeof: 1, delete: 1, switch: 1, export: 1, import: 1, public: 1, static: 1, default: 1, finally: 1, extends: 1, package: 1, private: 1, function: 1, continue: 1, debugger: 1, interface: 1, protected: 1, instanceof: 1, implements: 1 }; function M6() { for (; L5 < j5;) { const e = B5.charCodeAt(L5); if (!A6(e) && !T6(e)) break; ++L5 } } function F6(e) { var t, n, r, i = 0; for (n = "u" === e ? 4 : 2, t = 0; t < n; ++t)L5 < j5 && _6(B5[L5]) ? (r = B5[L5++], i = 16 * i + "0123456789abcdef".indexOf(r.toLowerCase())) : Y6({}, u6, b6); return String.fromCharCode(i) } function D6() { var e, t, n, r; for (t = 0, "}" === (e = B5[L5]) && Y6({}, u6, b6); L5 < j5 && _6(e = B5[L5++]);)t = 16 * t + "0123456789abcdef".indexOf(e.toLowerCase()); return (t > 1114111 || "}" !== e) && Y6({}, u6, b6), t <= 65535 ? String.fromCharCode(t) : (n = 55296 + (t - 65536 >> 10), r = 56320 + (t - 65536 & 1023), String.fromCharCode(n, r)) } function $6() { var e, t; for (e = B5.charCodeAt(L5++), t = String.fromCharCode(e), 92 === e && (117 !== B5.charCodeAt(L5) && Y6({}, u6, b6), ++L5, (e = F6("u")) && "\\" !== e && E6(e.charCodeAt(0)) || Y6({}, u6, b6), t = e); L5 < j5 && N6(e = B5.charCodeAt(L5));)++L5, t += String.fromCharCode(e), 92 === e && (t = t.substr(0, t.length - 1), 117 !== B5.charCodeAt(L5) && Y6({}, u6, b6), ++L5, (e = F6("u")) && "\\" !== e && N6(e.charCodeAt(0)) || Y6({}, u6, b6), t += e); return t } function R6() { var e, t; return e = L5, t = 92 === B5.charCodeAt(L5) ? $6() : function () { var e, t; for (e = L5++; L5 < j5;) { if (92 === (t = B5.charCodeAt(L5))) return L5 = e, $6(); if (!N6(t)) break; ++L5 } return B5.slice(e, L5) }(), { type: 1 === t.length ? G5 : I6.hasOwnProperty(t) ? H5 : "null" === t ? q5 : "true" === t || "false" === t ? W5 : G5, value: t, start: e, end: L5 } } function O6() { var e, t, n, r, i = L5, a = B5.charCodeAt(L5), o = B5[L5]; switch (a) { case 46: case 40: case 41: case 59: case 44: case 123: case 125: case 91: case 93: case 58: case 63: case 126: return ++L5, { type: X5, value: String.fromCharCode(a), start: i, end: L5 }; default: if (61 === (e = B5.charCodeAt(L5 + 1))) switch (a) { case 43: case 45: case 47: case 60: case 62: case 94: case 124: case 37: case 38: case 42: return L5 += 2, { type: X5, value: String.fromCharCode(a) + String.fromCharCode(e), start: i, end: L5 }; case 33: case 61: return L5 += 2, 61 === B5.charCodeAt(L5) && ++L5, { type: X5, value: B5.slice(i, L5), start: i, end: L5 } } }return ">>>=" === (r = B5.substr(L5, 4)) ? { type: X5, value: r, start: i, end: L5 += 4 } : ">>>" === (n = r.substr(0, 3)) || "<<=" === n || ">>=" === n ? { type: X5, value: n, start: i, end: L5 += 3 } : o === (t = n.substr(0, 2))[1] && "+-<>&|".includes(o) || "=>" === t ? { type: X5, value: t, start: i, end: L5 += 2 } : ("//" === t && Y6({}, u6, b6), "<>=!+-*%&|^/".includes(o) ? (++L5, { type: X5, value: o, start: i, end: L5 }) : void Y6({}, u6, b6)) } function z6() { var e, t, n; if (k6(S6((n = B5[L5]).charCodeAt(0)) || "." === n, "Numeric literal must start with a decimal digit or a decimal point"), t = L5, e = "", "." !== n) { if (e = B5[L5++], n = B5[L5], "0" === e) { if ("x" === n || "X" === n) return ++L5, function (e) { let t = ""; for (; L5 < j5 && _6(B5[L5]);)t += B5[L5++]; return 0 === t.length && Y6({}, u6, b6), E6(B5.charCodeAt(L5)) && Y6({}, u6, b6), { type: Y5, value: parseInt("0x" + t, 16), start: e, end: L5 } }(t); if (C6(n)) return function (e) { let t = "0" + B5[L5++]; for (; L5 < j5 && C6(B5[L5]);)t += B5[L5++]; return (E6(B5.charCodeAt(L5)) || S6(B5.charCodeAt(L5))) && Y6({}, u6, b6), { type: Y5, value: parseInt(t, 8), octal: !0, start: e, end: L5 } }(t); n && S6(n.charCodeAt(0)) && Y6({}, u6, b6) } for (; S6(B5.charCodeAt(L5));)e += B5[L5++]; n = B5[L5] } if ("." === n) { for (e += B5[L5++]; S6(B5.charCodeAt(L5));)e += B5[L5++]; n = B5[L5] } if ("e" === n || "E" === n) if (e += B5[L5++], "+" !== (n = B5[L5]) && "-" !== n || (e += B5[L5++]), S6(B5.charCodeAt(L5))) for (; S6(B5.charCodeAt(L5));)e += B5[L5++]; else Y6({}, u6, b6); return E6(B5.charCodeAt(L5)) && Y6({}, u6, b6), { type: Y5, value: parseFloat(e), start: t, end: L5 } } function P6() { var e, t, n, r; return U5 = null, M6(), e = L5, t = function () { var e, t, n, r; for (k6("/" === (e = B5[L5]), "Regular expression literal must start with a slash"), t = B5[L5++], n = !1, r = !1; L5 < j5;)if (t += e = B5[L5++], "\\" === e) T6((e = B5[L5++]).charCodeAt(0)) && Y6({}, m6), t += e; else if (T6(e.charCodeAt(0))) Y6({}, m6); else if (n) "]" === e && (n = !1); else { if ("/" === e) { r = !0; break } "[" === e && (n = !0) } return r || Y6({}, m6), { value: t.substr(1, t.length - 2), literal: t } }(), n = function () { var e, t, n; for (t = "", n = ""; L5 < j5 && N6((e = B5[L5]).charCodeAt(0));)++L5, "\\" === e && L5 < j5 ? Y6({}, u6, b6) : (n += e, t += e); return n.search(/[^gimuy]/g) >= 0 && Y6({}, p6, n), { value: n, literal: t } }(), r = function (e, t) { let n = e; t.includes("u") && (n = n.replace(/\\u\{([0-9a-fA-F]+)\}/g, ((e, t) => { if (parseInt(t, 16) <= 1114111) return "x"; Y6({}, p6) })).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x")); try { new RegExp(n) } catch (e) { Y6({}, p6) } try { return new RegExp(e, t) } catch (e) { return null } }(t.value, n.value), { literal: t.literal + n.literal, value: r, regex: { pattern: t.value, flags: n.value }, start: e, end: L5 } } function B6() { if (M6(), L5 >= j5) return { type: V5, start: L5, end: L5 }; const e = B5.charCodeAt(L5); return E6(e) ? R6() : 40 === e || 41 === e || 59 === e ? O6() : 39 === e || 34 === e ? function () { var e, t, n, r, i = "", a = !1; for (k6("'" === (e = B5[L5]) || '"' === e, "String literal must starts with a quote"), t = L5, ++L5; L5 < j5;) { if ((n = B5[L5++]) === e) { e = ""; break } if ("\\" === n) if ((n = B5[L5++]) && T6(n.charCodeAt(0))) "\r" === n && "\n" === B5[L5] && ++L5; else switch (n) { case "u": case "x": "{" === B5[L5] ? (++L5, i += D6()) : i += F6(n); break; case "n": i += "\n"; break; case "r": i += "\r"; break; case "t": i += "\t"; break; case "b": i += "\b"; break; case "f": i += "\f"; break; case "v": i += "\v"; break; default: C6(n) ? (0 !== (r = "01234567".indexOf(n)) && (a = !0), L5 < j5 && C6(B5[L5]) && (a = !0, r = 8 * r + "01234567".indexOf(B5[L5++]), "0123".includes(n) && L5 < j5 && C6(B5[L5]) && (r = 8 * r + "01234567".indexOf(B5[L5++]))), i += String.fromCharCode(r)) : i += n } else { if (T6(n.charCodeAt(0))) break; i += n } } return "" !== e && Y6({}, u6, b6), { type: K5, value: i, octal: a, start: t, end: L5 } }() : 46 === e ? S6(B5.charCodeAt(L5 + 1)) ? z6() : O6() : S6(e) ? z6() : O6() } function L6() { const e = U5; return L5 = e.end, U5 = B6(), L5 = e.end, e } function j6() { const e = L5; U5 = B6(), L5 = e } function U6(e, t, n) { const r = new z5("||" === e || "&&" === e ? r6 : J5); return r.operator = e, r.left = t, r.right = n, r } function W6(e, t) { const n = new z5(Q5); return n.callee = e, n.arguments = t, n } function V6(e) { const t = new z5(t6); return t.name = e, t } function G6(e) { const t = new z5(n6); return t.value = e.value, t.raw = B5.slice(e.start, e.end), e.regex && ("//" === t.raw && (t.raw = "/(?:)/"), t.regex = e.regex), t } function H6(e, t, n) { const r = new z5(i6); return r.computed = "[" === e, r.object = t, r.property = n, r.computed || (n.member = !0), r } function q6(e, t, n) { const r = new z5(o6); return r.key = t, r.value = n, r.kind = e, r } function Y6(e, t) { var n, r = Array.prototype.slice.call(arguments, 2), i = t.replace(/%(\d)/g, ((e, t) => (k6(t < r.length, "Message reference must be in range"), r[t]))); throw (n = new Error(i)).index = L5, n.description = i, n } function X6(e) { e.type === V5 && Y6(e, f6), e.type === Y5 && Y6(e, l6), e.type === K5 && Y6(e, c6), e.type === G5 && Y6(e, h6), e.type === H5 && Y6(e, d6), Y6(e, u6, e.value) } function K6(e) { const t = L6(); t.type === X5 && t.value === e || X6(t) } function Z6(e) { return U5.type === X5 && U5.value === e } function J6(e) { return U5.type === H5 && U5.value === e } function Q6() { const e = []; for (L5 = U5.start, K6("["); !Z6("]");)Z6(",") ? (L6(), e.push(null)) : (e.push(h9()), Z6("]") || K6(",")); return L6(), function (e) { const t = new z5(Z5); return t.elements = e, t }(e) } function e9() { L5 = U5.start; const e = L6(); return e.type === K5 || e.type === Y5 ? (e.octal && Y6(e, g6), G6(e)) : V6(e.value) } function t9() { var e, t, n; return L5 = U5.start, (e = U5).type === G5 ? (n = e9(), K6(":"), q6("init", n, h9())) : e.type !== V5 && e.type !== X5 ? (t = e9(), K6(":"), q6("init", t, h9())) : void X6(e) } function n9() { var e, t, n = [], r = {}, i = String; for (L5 = U5.start, K6("{"); !Z6("}");)t = "$" + ((e = t9()).key.type === t6 ? e.key.name : i(e.key.value)), Object.prototype.hasOwnProperty.call(r, t) ? Y6({}, y6) : r[t] = !0, n.push(e), Z6("}") || K6(","); return K6("}"), function (e) { const t = new z5(a6); return t.properties = e, t }(n) } const r9 = { if: 1 }; function i9() { var e, t, n; if (Z6("(")) return function () { K6("("); const e = d9(); return K6(")"), e }(); if (Z6("[")) return Q6(); if (Z6("{")) return n9(); if (e = U5.type, L5 = U5.start, e === G5 || r9[U5.value]) n = V6(L6().value); else if (e === K5 || e === Y5) U5.octal && Y6(U5, g6), n = G6(L6()); else { if (e === H5) throw new Error(v6); e === W5 ? ((t = L6()).value = "true" === t.value, n = G6(t)) : e === q5 ? ((t = L6()).value = null, n = G6(t)) : Z6("/") || Z6("/=") ? (n = G6(P6()), j6()) : X6(L6()) } return n } function a9() { const e = []; if (K6("("), !Z6(")")) for (; L5 < j5 && (e.push(h9()), !Z6(")"));)K6(","); return K6(")"), e } function o9() { L5 = U5.start; const e = L6(); return function (e) { return e.type === G5 || e.type === H5 || e.type === W5 || e.type === q5 }(e) || X6(e), V6(e.value) } function s9() { K6("["); const e = d9(); return K6("]"), e } function u9() { const e = function () { var e; for (e = i9(); ;)if (Z6(".")) K6("."), e = H6(".", e, o9()); else if (Z6("(")) e = W6(e, a9()); else { if (!Z6("[")) break; e = H6("[", e, s9()) } return e }(); if (U5.type === X5 && (Z6("++") || Z6("--"))) throw new Error(v6); return e } function l9() { var e, t; if (U5.type !== X5 && U5.type !== H5) t = u9(); else { if (Z6("++") || Z6("--")) throw new Error(v6); if (Z6("+") || Z6("-") || Z6("~") || Z6("!")) e = L6(), t = l9(), t = function (e, t) { const n = new z5(s6); return n.operator = e, n.argument = t, n.prefix = !0, n }(e.value, t); else { if (J6("delete") || J6("void") || J6("typeof")) throw new Error(v6); t = u9() } } return t } function c9(e) { let t = 0; if (e.type !== X5 && e.type !== H5) return 0; switch (e.value) { case "||": t = 1; break; case "&&": t = 2; break; case "|": t = 3; break; case "^": t = 4; break; case "&": t = 5; break; case "==": case "!=": case "===": case "!==": t = 6; break; case "<": case ">": case "<=": case ">=": case "instanceof": case "in": t = 7; break; case "<<": case ">>": case ">>>": t = 8; break; case "+": case "-": t = 9; break; case "*": case "/": case "%": t = 11 }return t } function h9() { var e, t; return e = function () { var e, t, n, r, i, a, o, s, u, l; if (e = U5, u = l9(), 0 === (i = c9(r = U5))) return u; for (r.prec = i, L6(), t = [e, U5], a = [u, r, o = l9()]; (i = c9(U5)) > 0;) { for (; a.length > 2 && i <= a[a.length - 2].prec;)o = a.pop(), s = a.pop().value, u = a.pop(), t.pop(), n = U6(s, u, o), a.push(n); (r = L6()).prec = i, a.push(r), t.push(U5), n = l9(), a.push(n) } for (n = a[l = a.length - 1], t.pop(); l > 1;)t.pop(), n = U6(a[l - 1].value, a[l - 2], n), l -= 2; return n }(), Z6("?") && (L6(), t = h9(), K6(":"), e = function (e, t, n) { const r = new z5(e6); return r.test = e, r.consequent = t, r.alternate = n, r }(e, t, h9())), e } function d9() { const e = h9(); if (Z6(",")) throw new Error(v6); return e } var f9 = { NaN: "NaN", E: "Math.E", LN2: "Math.LN2", LN10: "Math.LN10", LOG2E: "Math.LOG2E", LOG10E: "Math.LOG10E", PI: "Math.PI", SQRT1_2: "Math.SQRT1_2", SQRT2: "Math.SQRT2", MIN_VALUE: "Number.MIN_VALUE", MAX_VALUE: "Number.MAX_VALUE" }; function p9(e) { function t(t, n, r) { return i => function (t, n, r, i) { let a = e(n[0]); return r && (a = r + "(" + a + ")", 0 === r.lastIndexOf("new ", 0) && (a = "(" + a + ")")), a + "." + t + (i < 0 ? "" : 0 === i ? "()" : "(" + n.slice(1).map(e).join(",") + ")") }(t, i, n, r) } const n = "new Date", r = "String", i = "RegExp"; return { isNaN: "Number.isNaN", isFinite: "Number.isFinite", abs: "Math.abs", acos: "Math.acos", asin: "Math.asin", atan: "Math.atan", atan2: "Math.atan2", ceil: "Math.ceil", cos: "Math.cos", exp: "Math.exp", floor: "Math.floor", hypot: "Math.hypot", log: "Math.log", max: "Math.max", min: "Math.min", pow: "Math.pow", random: "Math.random", round: "Math.round", sin: "Math.sin", sqrt: "Math.sqrt", tan: "Math.tan", clamp: function (t) { t.length < 3 && Vt("Missing arguments to clamp function."), t.length > 3 && Vt("Too many arguments to clamp function."); const n = t.map(e); return "Math.max(" + n[1] + ", Math.min(" + n[2] + "," + n[0] + "))" }, now: "Date.now", utc: "Date.UTC", datetime: n, date: t("getDate", n, 0), day: t("getDay", n, 0), year: t("getFullYear", n, 0), month: t("getMonth", n, 0), hours: t("getHours", n, 0), minutes: t("getMinutes", n, 0), seconds: t("getSeconds", n, 0), milliseconds: t("getMilliseconds", n, 0), time: t("getTime", n, 0), timezoneoffset: t("getTimezoneOffset", n, 0), utcdate: t("getUTCDate", n, 0), utcday: t("getUTCDay", n, 0), utcyear: t("getUTCFullYear", n, 0), utcmonth: t("getUTCMonth", n, 0), utchours: t("getUTCHours", n, 0), utcminutes: t("getUTCMinutes", n, 0), utcseconds: t("getUTCSeconds", n, 0), utcmilliseconds: t("getUTCMilliseconds", n, 0), length: t("length", null, -1), parseFloat: "parseFloat", parseInt: "parseInt", upper: t("toUpperCase", r, 0), lower: t("toLowerCase", r, 0), substring: t("substring", r), split: t("split", r), trim: t("trim", r, 0), regexp: i, test: t("test", i), if: function (t) { t.length < 3 && Vt("Missing arguments to if function."), t.length > 3 && Vt("Too many arguments to if function."); const n = t.map(e); return "(" + n[0] + "?" + n[1] + ":" + n[2] + ")" } } } class m9 { constructor() { this._partials = new Float64Array(32), this._n = 0 } add(e) { const t = this._partials; let n = 0; for (let r = 0; r < this._n && r < 32; r++) { const i = t[r], a = e + i, o = Math.abs(e) < Math.abs(i) ? e - (a - i) : i - (a - e); o && (t[n++] = o), e = a } return t[n] = e, this._n = n + 1, this } valueOf() { const e = this._partials; let t, n, r, i = this._n, a = 0; if (i > 0) { for (a = e[--i]; i > 0 && (t = a, n = e[--i], a = t + n, r = n - (a - t), !r);); i > 0 && (r < 0 && e[i - 1] < 0 || r > 0 && e[i - 1] > 0) && (n = 2 * r, t = a + n, n == t - a && (a = t)) } return a } } var g9 = 1e-6, y9 = Math.PI, b9 = y9 / 2, v9 = y9 / 4, x9 = 2 * y9, w9 = 180 / y9, k9 = y9 / 180, S9 = Math.abs, _9 = (Math.atan, Math.atan2), C9 = Math.cos, A9 = (Math.ceil, Math.exp, Math.floor, Math.hypot), T9 = (Math.log, Math.pow, Math.sin), E9 = (Math.sign, Math.sqrt); Math.tan; function N9(e) { return e > 1 ? b9 : e < -1 ? -b9 : Math.asin(e) } function I9() { } function M9(e, t) { e && D9.hasOwnProperty(e.type) && D9[e.type](e, t) } var F9 = { Feature: function (e, t) { M9(e.geometry, t) }, FeatureCollection: function (e, t) { for (var n = e.features, r = -1, i = n.length; ++r < i;)M9(n[r].geometry, t) } }, D9 = { Sphere: function (e, t) { t.sphere() }, Point: function (e, t) { e = e.coordinates, t.point(e[0], e[1], e[2]) }, MultiPoint: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)e = n[r], t.point(e[0], e[1], e[2]) }, LineString: function (e, t) { $9(e.coordinates, t, 0) }, MultiLineString: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)$9(n[r], t, 0) }, Polygon: function (e, t) { R9(e.coordinates, t) }, MultiPolygon: function (e, t) { for (var n = e.coordinates, r = -1, i = n.length; ++r < i;)R9(n[r], t) }, GeometryCollection: function (e, t) { for (var n = e.geometries, r = -1, i = n.length; ++r < i;)M9(n[r], t) } }; function $9(e, t, n) { var r, i = -1, a = e.length - n; for (t.lineStart(); ++i < a;)r = e[i], t.point(r[0], r[1], r[2]); t.lineEnd() } function R9(e, t) { var n = -1, r = e.length; for (t.polygonStart(); ++n < r;)$9(e[n], t, 1); t.polygonEnd() } function O9(e, t) { e && F9.hasOwnProperty(e.type) ? F9[e.type](e, t) : M9(e, t) } var z9, P9, B9, L9, j9, U9, W9, V9, G9, H9, q9, Y9, X9, K9, Z9, J9, Q9 = new m9, e8 = new m9, t8 = { point: I9, lineStart: I9, lineEnd: I9, polygonStart: function () { Q9 = new m9, t8.lineStart = n8, t8.lineEnd = r8 }, polygonEnd: function () { var e = +Q9; e8.add(e < 0 ? x9 + e : e), this.lineStart = this.lineEnd = this.point = I9 }, sphere: function () { e8.add(x9) } }; function n8() { t8.point = i8 } function r8() { a8(z9, P9) } function i8(e, t) { t8.point = a8, z9 = e, P9 = t, B9 = e *= k9, L9 = C9(t = (t *= k9) / 2 + v9), j9 = T9(t) } function a8(e, t) { var n = (e *= k9) - B9, r = n >= 0 ? 1 : -1, i = r * n, a = C9(t = (t *= k9) / 2 + v9), o = T9(t), s = j9 * o, u = L9 * a + s * C9(i), l = s * r * T9(i); Q9.add(_9(l, u)), B9 = e, L9 = a, j9 = o } function o8(e, t) { return [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]] } var s8, u8, l8, c8, h8, d8, f8, p8, m8, g8, y8, b8, v8, x8, w8, k8, S8 = { point: _8, lineStart: A8, lineEnd: T8, polygonStart: function () { S8.point = E8, S8.lineStart = N8, S8.lineEnd = I8, K9 = new m9, t8.polygonStart() }, polygonEnd: function () { t8.polygonEnd(), S8.point = _8, S8.lineStart = A8, S8.lineEnd = T8, Q9 < 0 ? (U9 = -(V9 = 180), W9 = -(G9 = 90)) : K9 > g9 ? G9 = 90 : K9 < -1e-6 && (W9 = -90), J9[0] = U9, J9[1] = V9 }, sphere: function () { U9 = -(V9 = 180), W9 = -(G9 = 90) } }; function _8(e, t) { Z9.push(J9 = [U9 = e, V9 = e]), t < W9 && (W9 = t), t > G9 && (G9 = t) } function C8(e, t) { var n, r, i = function (e) { var t = e[0], n = e[1], r = C9(n); return [r * C9(t), r * T9(t), T9(n)] }([e * k9, t * k9]); if (X9) { var a = o8(X9, i), o = o8([a[1], -a[0], 0], a); r = E9((n = o)[0] * n[0] + n[1] * n[1] + n[2] * n[2]), n[0] /= r, n[1] /= r, n[2] /= r, o = function (e) { return [_9(e[1], e[0]), N9(e[2])] }(o); var s, u = e - H9, l = u > 0 ? 1 : -1, c = o[0] * w9 * l, h = S9(u) > 180; h ^ (l * H9 < c && c < l * e) ? (s = o[1] * w9) > G9 && (G9 = s) : h ^ (l * H9 < (c = (c + 360) % 360 - 180) && c < l * e) ? (s = -o[1] * w9) < W9 && (W9 = s) : (t < W9 && (W9 = t), t > G9 && (G9 = t)), h ? e < H9 ? M8(U9, e) > M8(U9, V9) && (V9 = e) : M8(e, V9) > M8(U9, V9) && (U9 = e) : V9 >= U9 ? (e < U9 && (U9 = e), e > V9 && (V9 = e)) : e > H9 ? M8(U9, e) > M8(U9, V9) && (V9 = e) : M8(e, V9) > M8(U9, V9) && (U9 = e) } else Z9.push(J9 = [U9 = e, V9 = e]); t < W9 && (W9 = t), t > G9 && (G9 = t), X9 = i, H9 = e } function A8() { S8.point = C8 } function T8() { J9[0] = U9, J9[1] = V9, S8.point = _8, X9 = null } function E8(e, t) { if (X9) { var n = e - H9; K9.add(S9(n) > 180 ? n + (n > 0 ? 360 : -360) : n) } else q9 = e, Y9 = t; t8.point(e, t), C8(e, t) } function N8() { t8.lineStart() } function I8() { E8(q9, Y9), t8.lineEnd(), S9(K9) > g9 && (U9 = -(V9 = 180)), J9[0] = U9, J9[1] = V9, X9 = null } function M8(e, t) { return (t -= e) < 0 ? t + 360 : t } function F8(e, t) { return e[0] - t[0] } function D8(e, t) { return e[0] <= e[1] ? e[0] <= t && t <= e[1] : t < e[0] || e[1] < t } var $8 = { sphere: I9, point: R8, lineStart: z8, lineEnd: L8, polygonStart: function () { $8.lineStart = j8, $8.lineEnd = U8 }, polygonEnd: function () { $8.lineStart = z8, $8.lineEnd = L8 } }; function R8(e, t) { e *= k9; var n = C9(t *= k9); O8(n * C9(e), n * T9(e), T9(t)) } function O8(e, t, n) { ++s8, l8 += (e - l8) / s8, c8 += (t - c8) / s8, h8 += (n - h8) / s8 } function z8() { $8.point = P8 } function P8(e, t) { e *= k9; var n = C9(t *= k9); x8 = n * C9(e), w8 = n * T9(e), k8 = T9(t), $8.point = B8, O8(x8, w8, k8) } function B8(e, t) { e *= k9; var n = C9(t *= k9), r = n * C9(e), i = n * T9(e), a = T9(t), o = _9(E9((o = w8 * a - k8 * i) * o + (o = k8 * r - x8 * a) * o + (o = x8 * i - w8 * r) * o), x8 * r + w8 * i + k8 * a); u8 += o, d8 += o * (x8 + (x8 = r)), f8 += o * (w8 + (w8 = i)), p8 += o * (k8 + (k8 = a)), O8(x8, w8, k8) } function L8() { $8.point = R8 } function j8() { $8.point = W8 } function U8() { V8(b8, v8), $8.point = R8 } function W8(e, t) { b8 = e, v8 = t, e *= k9, t *= k9, $8.point = V8; var n = C9(t); x8 = n * C9(e), w8 = n * T9(e), k8 = T9(t), O8(x8, w8, k8) } function V8(e, t) { e *= k9; var n = C9(t *= k9), r = n * C9(e), i = n * T9(e), a = T9(t), o = w8 * a - k8 * i, s = k8 * r - x8 * a, u = x8 * i - w8 * r, l = A9(o, s, u), c = N9(l), h = l && -c / l; m8.add(h * o), g8.add(h * s), y8.add(h * u), u8 += c, d8 += c * (x8 + (x8 = r)), f8 += c * (w8 + (w8 = i)), p8 += c * (k8 + (k8 = a)), O8(x8, w8, k8) } function G8(e, t, n) { e.prototype = t.prototype = n, n.constructor = e } function H8(e, t) { var n = Object.create(e.prototype); for (var r in t) n[r] = t[r]; return n } function q8() { } var Y8 = .7, X8 = 1.4285714285714286, K8 = "\\s*([+-]?\\d+)\\s*", Z8 = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", J8 = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Q8 = /^#([0-9a-f]{3,8})$/, e7 = new RegExp(`^rgb\\(${K8},${K8},${K8}\\)$`), t7 = new RegExp(`^rgb\\(${J8},${J8},${J8}\\)$`), n7 = new RegExp(`^rgba\\(${K8},${K8},${K8},${Z8}\\)$`), r7 = new RegExp(`^rgba\\(${J8},${J8},${J8},${Z8}\\)$`), i7 = new RegExp(`^hsl\\(${Z8},${J8},${J8}\\)$`), a7 = new RegExp(`^hsla\\(${Z8},${J8},${J8},${Z8}\\)$`), o7 = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; function s7() { return this.rgb().formatHex() } function u7() { return this.rgb().formatRgb() } function l7(e) { var t, n; return e = (e + "").trim().toLowerCase(), (t = Q8.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), 6 === n ? c7(t) : 3 === n ? new p7(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, (15 & t) << 4 | 15 & t, 1) : 8 === n ? h7(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (255 & t) / 255) : 4 === n ? h7(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, ((15 & t) << 4 | 15 & t) / 255) : null) : (t = e7.exec(e)) ? new p7(t[1], t[2], t[3], 1) : (t = t7.exec(e)) ? new p7(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, 1) : (t = n7.exec(e)) ? h7(t[1], t[2], t[3], t[4]) : (t = r7.exec(e)) ? h7(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, t[4]) : (t = i7.exec(e)) ? x7(t[1], t[2] / 100, t[3] / 100, 1) : (t = a7.exec(e)) ? x7(t[1], t[2] / 100, t[3] / 100, t[4]) : o7.hasOwnProperty(e) ? c7(o7[e]) : "transparent" === e ? new p7(NaN, NaN, NaN, 0) : null } function c7(e) { return new p7(e >> 16 & 255, e >> 8 & 255, 255 & e, 1) } function h7(e, t, n, r) { return r <= 0 && (e = t = n = NaN), new p7(e, t, n, r) } function d7(e) { return e instanceof q8 || (e = l7(e)), e ? new p7((e = e.rgb()).r, e.g, e.b, e.opacity) : new p7 } function f7(e, t, n, r) { return 1 === arguments.length ? d7(e) : new p7(e, t, n, null == r ? 1 : r) } function p7(e, t, n, r) { this.r = +e, this.g = +t, this.b = +n, this.opacity = +r } function m7() { return `#${v7(this.r)}${v7(this.g)}${v7(this.b)}` } function g7() { const e = y7(this.opacity); return `${1 === e ? "rgb(" : "rgba("}${b7(this.r)}, ${b7(this.g)}, ${b7(this.b)}${1 === e ? ")" : `, ${e})`}` } function y7(e) { return isNaN(e) ? 1 : Math.max(0, Math.min(1, e)) } function b7(e) { return Math.max(0, Math.min(255, Math.round(e) || 0)) } function v7(e) { return ((e = b7(e)) < 16 ? "0" : "") + e.toString(16) } function x7(e, t, n, r) { return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new S7(e, t, n, r) } function w7(e) { if (e instanceof S7) return new S7(e.h, e.s, e.l, e.opacity); if (e instanceof q8 || (e = l7(e)), !e) return new S7; if (e instanceof S7) return e; var t = (e = e.rgb()).r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, u = (a + i) / 2; return s ? (o = t === a ? (n - r) / s + 6 * (n < r) : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= u < .5 ? a + i : 2 - a - i, o *= 60) : s = u > 0 && u < 1 ? 0 : o, new S7(o, s, u, e.opacity) } function k7(e, t, n, r) { return 1 === arguments.length ? w7(e) : new S7(e, t, n, null == r ? 1 : r) } function S7(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function _7(e) { return (e = (e || 0) % 360) < 0 ? e + 360 : e } function C7(e) { return Math.max(0, Math.min(1, e || 0)) } function A7(e, t, n) { return 255 * (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) } G8(q8, l7, { copy(e) { return Object.assign(new this.constructor, this, e) }, displayable() { return this.rgb().displayable() }, hex: s7, formatHex: s7, formatHex8: function () { return this.rgb().formatHex8() }, formatHsl: function () { return w7(this).formatHsl() }, formatRgb: u7, toString: u7 }), G8(p7, f7, H8(q8, { brighter(e) { return e = null == e ? X8 : Math.pow(X8, e), new p7(this.r * e, this.g * e, this.b * e, this.opacity) }, darker(e) { return e = null == e ? Y8 : Math.pow(Y8, e), new p7(this.r * e, this.g * e, this.b * e, this.opacity) }, rgb() { return this }, clamp() { return new p7(b7(this.r), b7(this.g), b7(this.b), y7(this.opacity)) }, displayable() { return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1 }, hex: m7, formatHex: m7, formatHex8: function () { return `#${v7(this.r)}${v7(this.g)}${v7(this.b)}${v7(255 * (isNaN(this.opacity) ? 1 : this.opacity))}` }, formatRgb: g7, toString: g7 })), G8(S7, k7, H8(q8, { brighter(e) { return e = null == e ? X8 : Math.pow(X8, e), new S7(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? Y8 : Math.pow(Y8, e), new S7(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = this.h % 360 + 360 * (this.h < 0), t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r; return new p7(A7(e >= 240 ? e - 240 : e + 120, i, r), A7(e, i, r), A7(e < 120 ? e + 240 : e - 120, i, r), this.opacity) }, clamp() { return new S7(_7(this.h), C7(this.s), C7(this.l), y7(this.opacity)) }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1 }, formatHsl() { const e = y7(this.opacity); return `${1 === e ? "hsl(" : "hsla("}${_7(this.h)}, ${100 * C7(this.s)}%, ${100 * C7(this.l)}%${1 === e ? ")" : `, ${e})`}` } })); const T7 = Math.PI / 180, E7 = 180 / Math.PI, N7 = .96422, I7 = .82521, M7 = 4 / 29, F7 = 6 / 29, D7 = .12841854934601665; function $7(e) { if (e instanceof O7) return new O7(e.l, e.a, e.b, e.opacity); if (e instanceof W7) return V7(e); e instanceof p7 || (e = d7(e)); var t, n, r = L7(e.r), i = L7(e.g), a = L7(e.b), o = z7((.2225045 * r + .7168786 * i + .0606169 * a) / 1); return r === i && i === a ? t = n = o : (t = z7((.4360747 * r + .3850649 * i + .1430804 * a) / N7), n = z7((.0139322 * r + .0971045 * i + .7141733 * a) / I7)), new O7(116 * o - 16, 500 * (t - o), 200 * (o - n), e.opacity) } function R7(e, t, n, r) { return 1 === arguments.length ? $7(e) : new O7(e, t, n, null == r ? 1 : r) } function O7(e, t, n, r) { this.l = +e, this.a = +t, this.b = +n, this.opacity = +r } function z7(e) { return e > .008856451679035631 ? Math.pow(e, 1 / 3) : e / D7 + M7 } function P7(e) { return e > F7 ? e * e * e : D7 * (e - M7) } function B7(e) { return 255 * (e <= .0031308 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - .055) } function L7(e) { return (e /= 255) <= .04045 ? e / 12.92 : Math.pow((e + .055) / 1.055, 2.4) } function j7(e) { if (e instanceof W7) return new W7(e.h, e.c, e.l, e.opacity); if (e instanceof O7 || (e = $7(e)), 0 === e.a && 0 === e.b) return new W7(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity); var t = Math.atan2(e.b, e.a) * E7; return new W7(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity) } function U7(e, t, n, r) { return 1 === arguments.length ? j7(e) : new W7(e, t, n, null == r ? 1 : r) } function W7(e, t, n, r) { this.h = +e, this.c = +t, this.l = +n, this.opacity = +r } function V7(e) { if (isNaN(e.h)) return new O7(e.l, 0, 0, e.opacity); var t = e.h * T7; return new O7(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity) } function G7(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function H7(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function q7() { return 0 } G8(O7, R7, H8(q8, { brighter(e) { return new O7(this.l + 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, darker(e) { return new O7(this.l - 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, rgb() { var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200; return new p7(B7(3.1338561 * (t = N7 * P7(t)) - 1.6168667 * (e = 1 * P7(e)) - .4906146 * (n = I7 * P7(n))), B7(-.9787684 * t + 1.9161415 * e + .033454 * n), B7(.0719453 * t - .2289914 * e + 1.4052427 * n), this.opacity) } })), G8(W7, U7, H8(q8, { brighter(e) { return new W7(this.h, this.c, this.l + 18 * (null == e ? 1 : e), this.opacity) }, darker(e) { return new W7(this.h, this.c, this.l - 18 * (null == e ? 1 : e), this.opacity) }, rgb() { return V7(this).rgb() } })); Map; class Y7 extends Set { constructor(e, t = J7) { if (super(), Object.defineProperties(this, { _intern: { value: new Map }, _key: { value: t } }), null != e) for (const t of e) this.add(t) } has(e) { return super.has(X7(this, e)) } add(e) { return super.add(K7(this, e)) } delete(e) { return super.delete(Z7(this, e)) } } function X7({ _intern: e, _key: t }, n) { const r = t(n); return e.has(r) ? e.get(r) : n } function K7({ _intern: e, _key: t }, n) { const r = t(n); return e.has(r) ? e.get(r) : (e.set(r, n), n) } function Z7({ _intern: e, _key: t }, n) { const r = t(n); return e.has(r) && (n = e.get(r), e.delete(r)), n } function J7(e) { return null !== e && "object" == typeof e ? e.valueOf() : e } function Q7(e) { return e instanceof Y7 ? e : new Y7(e) } const eee = Symbol("vega_selection_getter"); function tee(e) { return e.getter && e.getter[eee] || (e.getter = Ht(e.field), e.getter[eee] = !0), e.getter } const nee = "intersect", ree = "union", iee = "or", aee = "and", oee = "_vgsid_", see = Ht(oee), uee = "index:unit"; function lee(e, t) { for (var n, r, i = t.fields, a = t.values, o = i.length, s = 0; s < o; ++s)if (Un(n = tee(r = i[s])(e)) && (n = dn(n)), Un(a[s]) && (a[s] = dn(a[s])), on(a[s]) && Un(a[s][0]) && (a[s] = a[s].map(dn)), "E" === r.type) { if (on(a[s]) ? a[s].indexOf(n) < 0 : n !== a[s]) return !1 } else if ("R" === r.type) { if (!jn(n, a[s])) return !1 } else if ("R-RE" === r.type) { if (!jn(n, a[s], !0, !1)) return !1 } else if ("R-E" === r.type) { if (!jn(n, a[s], !1, !1)) return !1 } else if ("R-LE" === r.type && !jn(n, a[s], !1, !0)) return !1; return !0 } function cee(e, t, n) { for (var r, i, a, o, s, u = this.context.data[e], l = u ? u.values.value : [], c = u ? u[uee] && u[uee].value : void 0, h = n === nee, d = l.length, f = 0; f < d; ++f)if (r = l[f], c && h) { if (-1 === (a = (i = i || {})[o = r.unit] || 0)) continue; if (s = lee(t, r), i[o] = s ? -1 : ++a, s && 1 === c.size) return !0; if (!s && a === c.get(o).count) return !1 } else if (h ^ (s = lee(t, r))) return s; return d && h } const hee = function (e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = G7, n = (t, n) => G7(e(t), n), r = (t, n) => e(t) - n) : (t = e === G7 || e === H7 ? e : q7, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } }(see), dee = hee.left, fee = hee.right; function pee(e, t, n) { const r = this.context.data[e], i = r ? r.values.value : [], a = r ? r[uee] && r[uee].value : void 0, o = n === nee, s = see(t), u = dee(i, s); if (u === i.length) return !1; if (see(i[u]) !== s) return !1; if (a && o) { if (1 === a.size) return !0; if (fee(i, s) - u < a.size) return !1 } return !0 } function mee(e, t) { return e.map((e => $n(t.fields ? { values: t.fields.map((t => tee(t)(e.datum))) } : { [oee]: see(e.datum) }, t))) } function gee(e, t, n, r) { for (var i, a, o, s, u, l, c, h, d, f, p, m, g = this.context.data[e], y = g ? g.values.value : [], b = {}, v = {}, x = {}, w = y.length, k = 0; k < w; ++k)if (s = (i = y[k]).unit, a = i.fields, o = i.values, a && o) { for (p = 0, m = a.length; p < m; ++p)u = a[p], h = (c = b[u.field] || (b[u.field] = {}))[s] || (c[s] = []), x[u.field] = d = u.type.charAt(0), f = yee[`${d}_union`], c[s] = f(h, _n(o[p])); n && (h = v[s] || (v[s] = [])).push(_n(o).reduce(((e, t, n) => (e[a[n].field] = t, e)), {})) } else u = oee, l = see(i), (h = (c = b[u] || (b[u] = {}))[s] || (c[s] = [])).push(l), n && (h = v[s] || (v[s] = [])).push({ [oee]: l }); if (t = t || ree, b[oee] ? b[oee] = yee[`${oee}_${t}`](...Object.values(b[oee])) : Object.keys(b).forEach((e => { b[e] = Object.keys(b[e]).map((t => b[e][t])).reduce(((n, r) => void 0 === n ? r : yee[`${x[e]}_${t}`](n, r))) })), y = Object.keys(v), n && y.length) { b[r ? "vlPoint" : "vlMulti"] = t === ree ? { [iee]: y.reduce(((e, t) => (e.push(...v[t]), e)), []) } : { [aee]: y.map((e => ({ [iee]: v[e] }))) } } return b } var yee = { [`${oee}_union`]: function (...e) { const t = new Y7; for (const n of e) for (const e of n) t.add(e); return t }, [`${oee}_intersect`]: function (e, ...t) { e = new Y7(e), t = t.map(Q7); e: for (const n of e) for (const r of t) if (!r.has(n)) { e.delete(n); continue e } return e }, E_union: function (e, t) { if (!e.length) return t; for (var n = 0, r = t.length; n < r; ++n)e.indexOf(t[n]) < 0 && e.push(t[n]); return e }, E_intersect: function (e, t) { return e.length ? e.filter((e => t.indexOf(e) >= 0)) : t }, R_union: function (e, t) { var n = dn(t[0]), r = dn(t[1]); return n > r && (n = t[1], r = t[0]), e.length ? (e[0] > n && (e[0] = n), e[1] < r && (e[1] = r), e) : [n, r] }, R_intersect: function (e, t) { var n = dn(t[0]), r = dn(t[1]); return n > r && (n = t[1], r = t[0]), e.length ? r < e[0] || e[1] < n ? [] : (e[0] < n && (e[0] = n), e[1] > r && (e[1] = r), e) : [n, r] } }; function bee(e, t, n, r) { t[0].type !== T5 && Vt("First argument to selection functions must be a string literal."); const i = t[0].value, a = "unit", o = "@" + a, s = ":" + i; (t.length >= 2 && hn(t).value) !== nee || zn(r, o) || (r[o] = n.getData(i).indataRef(n, a)), zn(r, s) || (r[s] = n.getData(i).tuplesRef()) } function vee(e) { const t = this.context.data[e]; return t ? t.values.value : [] } const xee = e => function (t, n) { const r = this.context.dataflow.locale(); return null === t ? "null" : r[e](n)(t) }, wee = xee("format"), kee = xee("timeFormat"), See = xee("utcFormat"), _ee = xee("timeParse"), Cee = xee("utcParse"), Aee = new Date(2e3, 0, 1); function Tee(e, t, n) { return Number.isInteger(e) && Number.isInteger(t) ? (Aee.setYear(2e3), Aee.setMonth(e), Aee.setDate(t), kee.call(this, Aee, n)) : "" } const Eee = "$"; function Nee(e, t, n, r) { t[0].type !== T5 && Vt("First argument to data functions must be a string literal."); const i = t[0].value, a = ":" + i; if (!zn(a, r)) try { r[a] = n.getData(i).tuplesRef() } catch (e) { } } function Iee(e, t, n, r) { if (t[0].type === T5) Mee(n, r, t[0].value); else for (e in n.scales) Mee(n, r, e) } function Mee(e, t, n) { const r = "%" + n; if (!zn(t, r)) try { t[r] = e.scaleRef(n) } catch (e) { } } function Fee(e, t) { if (Cn(e)) return e; if (Vn(e)) { const n = t.scales[e]; return n && function (e) { return e && !0 === e[hb] }(n.value) ? n.value : void 0 } } function Dee(e, t, n) { t.__bandwidth = e => e && e.bandwidth ? e.bandwidth() : 0, n._bandwidth = Iee, n._range = Iee, n._scale = Iee; const r = t => "_[" + (t.type === T5 ? Yn("%" + t.value) : Yn("%") + "+" + e(t)) + "]"; return { _bandwidth: e => `this.__bandwidth(${r(e[0])})`, _range: e => `${r(e[0])}.range()`, _scale: t => `${r(t[0])}(${e(t[1])})` } } function $ee(e, t) { return function (n, r, i) { if (n) { const t = Fee(n, (i || this).context); return t && t.path[e](r) } return t(r) } } const Ree = $ee("area", (function (e) { return e8 = new m9, O9(e, t8), 2 * e8 })), Oee = $ee("bounds", (function (e) { var t, n, r, i, a, o, s; if (G9 = V9 = -(U9 = W9 = 1 / 0), Z9 = [], O9(e, S8), n = Z9.length) { for (Z9.sort(F8), t = 1, a = [r = Z9[0]]; t < n; ++t)D8(r, (i = Z9[t])[0]) || D8(r, i[1]) ? (M8(r[0], i[1]) > M8(r[0], r[1]) && (r[1] = i[1]), M8(i[0], r[1]) > M8(r[0], r[1]) && (r[0] = i[0])) : a.push(r = i); for (o = -1 / 0, t = 0, r = a[n = a.length - 1]; t <= n; r = i, ++t)i = a[t], (s = M8(r[1], i[0])) > o && (o = s, U9 = i[0], V9 = r[1]) } return Z9 = J9 = null, U9 === 1 / 0 || W9 === 1 / 0 ? [[NaN, NaN], [NaN, NaN]] : [[U9, W9], [V9, G9]] })), zee = $ee("centroid", (function (e) { s8 = u8 = l8 = c8 = h8 = d8 = f8 = p8 = 0, m8 = new m9, g8 = new m9, y8 = new m9, O9(e, $8); var t = +m8, n = +g8, r = +y8, i = A9(t, n, r); return i < 1e-12 && (t = d8, n = f8, r = p8, u8 < g9 && (t = l8, n = c8, r = h8), (i = A9(t, n, r)) < 1e-12) ? [NaN, NaN] : [_9(n, t) * w9, N9(r / i) * w9] })); function Pee(e, t, n) { try { e[t].apply(e, ["EXPRESSION"].concat([].slice.call(n))) } catch (t) { e.warn(t) } return n[n.length - 1] } function Bee(e) { const t = e / 255; return t <= .03928 ? t / 12.92 : Math.pow((t + .055) / 1.055, 2.4) } function Lee(e) { const t = f7(e); return .2126 * Bee(t.r) + .7152 * Bee(t.g) + .0722 * Bee(t.b) } function jee(e, t) { return e === t || e != e && t != t || (on(e) ? !(!on(t) || e.length !== t.length) && function (e, t) { for (let n = 0, r = e.length; n < r; ++n)if (!jee(e[n], t[n])) return !1; return !0 }(e, t) : !(!sn(e) || !sn(t)) && Uee(e, t)) } function Uee(e, t) { for (const n in e) if (!jee(e[n], t[n])) return !1; return !0 } function Wee(e) { return t => Uee(e, t) } const Vee = {}; function Gee(e) { return on(e) || ArrayBuffer.isView(e) ? e : null } function Hee(e) { return Gee(e) || (Vn(e) ? e : null) } const qee = e => e.data; function Yee(e, t) { const n = vee.call(t, e); return n.root && n.root.lookup || {} } const Xee = () => "undefined" != typeof window && window || null; function Kee(e, t, n) { if (!e) return []; const [r, i] = e, a = (new qv).set(r[0], r[1], i[0], i[1]); return function (e, t, n) { const r = [], i = (new qv).union(t), a = e.marktype; return a ? AS(e, i, n, r) : "group" === a ? TS(e, i, n, r) : Vt("Intersect scene must be mark node or group item.") }(n || this.context.dataflow.scenegraph().root, a, function (e) { let t = null; if (e) { const n = _n(e.marktype), r = _n(e.markname); t = e => (!n.length || n.some((t => e.marktype === t))) && (!r.length || r.some((t => e.name === t))) } return t }(t)) } const Zee = { random: () => Hu(), cumulativeNormal: Qu, cumulativeLogNormal: al, cumulativeUniform: ll, densityNormal: Ju, densityLogNormal: il, densityUniform: ul, quantileNormal: el, quantileLogNormal: ol, quantileUniform: cl, sampleNormal: Zu, sampleLogNormal: rl, sampleUniform: sl, isArray: on, isBoolean: function (e) { return "boolean" == typeof e }, isDate: Un, isDefined: e => void 0 !== e, isNumber: Wn, isObject: sn, isRegExp: function (e) { return "[object RegExp]" === Object.prototype.toString.call(e) }, isString: Vn, isTuple: Ys, isValid: e => null != e && e == e, toBoolean: Xn, toDate: e => Zn(e), toNumber: dn, toString: Jn, indexof: function (e) { for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return Hee(e).indexOf(...n) }, join: function (e) { for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return Gee(e).join(...n) }, lastindexof: function (e) { for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return Hee(e).lastIndexOf(...n) }, replace: function (e, t, n) { return Cn(n) && Vt("Function argument passed to replace."), String(e).replace(t, n) }, reverse: function (e) { return Gee(e).slice().reverse() }, slice: function (e) { for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)n[r - 1] = arguments[r]; return Hee(e).slice(...n) }, flush: function (e, t, n, r, i, a) { if (!n && 0 !== n) return a; const o = +n; let s, u = e[0], l = hn(e); l < u && (s = u, u = l, l = s), s = Math.abs(t - u); const c = Math.abs(l - t); return s < c && s <= o ? r : c <= o ? i : a }, lerp: function (e, t) { const n = e[0], r = hn(e), i = +t; return i ? 1 === i ? r : n + i * (r - n) : n }, merge: function () { const e = [].slice.call(arguments); return e.unshift({}), $n(...e) }, pad: function (e, t, n, r) { const i = n || " ", a = e + "", o = t - a.length; return o <= 0 ? a : "left" === r ? Hn(i, o) + a : "center" === r ? Hn(i, ~~(o / 2)) + a + Hn(i, Math.ceil(o / 2)) : a + Hn(i, o) }, peek: hn, pluck: function (e, t) { const n = Vee[t] || (Vee[t] = Ht(t)); return on(e) ? e.map(n) : n(e) }, span: qn, inrange: jn, truncate: function (e, t, n, r) { const i = null != r ? r : "…", a = e + "", o = a.length, s = Math.max(0, t - i.length); return o <= t ? a : "left" === n ? i + a.slice(o - s) : "center" === n ? a.slice(0, Math.ceil(s / 2)) + i + a.slice(o - ~~(s / 2)) : a.slice(0, s) + i }, rgb: f7, lab: R7, hcl: U7, hsl: k7, luminance: Lee, contrast: function (e, t) { const n = Lee(e), r = Lee(t); return (Math.max(n, r) + .05) / (Math.min(n, r) + .05) }, sequence: function (e, t, n) { e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n; for (var r = -1, i = 0 | Math.max(0, Math.ceil((t - e) / n)), a = new Array(i); ++r < i;)a[r] = e + r * n; return a }, format: wee, utcFormat: See, utcParse: Cee, utcOffset: function (e, t, n) { return ma(pa(e), t, n) }, utcSequence: function (e, t, n, r) { return ga(pa(e), t, n, r) }, timeFormat: kee, timeParse: _ee, timeOffset: function (e, t, n) { return ma(fa(e), t, n) }, timeSequence: function (e, t, n, r) { return ga(fa(e), t, n, r) }, timeUnitSpecifier: function (e, t) { const n = $n({}, Hi, t), r = Gi(e), i = r.length; let a, o, s = "", u = 0; for (u = 0; u < i;)for (a = r.length; a > u; --a)if (o = r.slice(u, a).join("-"), null != n[o]) { s += n[o], u = a; break } return s.trim() }, monthFormat: function (e) { return Tee.call(this, e, 1, "%B") }, monthAbbrevFormat: function (e) { return Tee.call(this, e, 1, "%b") }, dayFormat: function (e) { return Tee.call(this, 0, 2 + e, "%A") }, dayAbbrevFormat: function (e) { return Tee.call(this, 0, 2 + e, "%a") }, quarter: function (e) { return 1 + ~~(new Date(e).getMonth() / 3) }, utcquarter: function (e) { return 1 + ~~(new Date(e).getUTCMonth() / 3) }, week: function (e) { return Ki(new Date(e)) }, utcweek: function (e) { return ea(new Date(e)) }, dayofyear: function (e) { return Xi(new Date(e)) }, utcdayofyear: function (e) { return Qi(new Date(e)) }, warn: function () { return Pee(this.context.dataflow, "warn", arguments) }, info: function () { return Pee(this.context.dataflow, "info", arguments) }, debug: function () { return Pee(this.context.dataflow, "debug", arguments) }, extent: e => Rn(e), inScope: function (e) { const t = this.context.group; let n = !1; if (t) for (; e;) { if (e === t) { n = !0; break } e = e.mark.group } return n }, intersect: Kee, clampRange: function (e, t, n) { let r, i = e[0], a = e[1]; return a < i && (r = a, a = i, i = r), r = a - i, r >= n - t ? [t, n] : [i = Math.min(Math.max(i, t), n - r), i + r] }, pinchDistance: function (e) { const t = e.touches, n = t[0].clientX - t[1].clientX, r = t[0].clientY - t[1].clientY; return Math.hypot(n, r) }, pinchAngle: function (e) { const t = e.touches; return Math.atan2(t[0].clientY - t[1].clientY, t[0].clientX - t[1].clientX) }, screen: function () { const e = Xee(); return e ? e.screen : {} }, containerSize: function () { const e = this.context.dataflow, t = e.container && e.container(); return t ? [t.clientWidth, t.clientHeight] : [void 0, void 0] }, windowSize: function () { const e = Xee(); return e ? [e.innerWidth, e.innerHeight] : [void 0, void 0] }, bandspace: function (e, t, n) { return Py(e || 0, t || 0, n || 0) }, setdata: function (e, t) { const n = this.context.dataflow, r = this.context.data[e].input; return n.pulse(r, n.changeset().remove(Zt).insert(t)), 1 }, pathShape: function (e) { let t = null; return function (n) { return n ? vv(n, t = t || uv(e)) : e } }, panLinear: function (e, t) { return bn(e, t, dn, Yt) }, panLog: function (e, t) { var n = Math.sign(e[0]); return bn(e, t, pn(n), fn(n)) }, panPow: function (e, t, n) { return bn(e, t, yn(n), yn(1 / n)) }, panSymlog: function (e, t, n) { return bn(e, t, mn(n), gn(n)) }, zoomLinear: xn, zoomLog: wn, zoomPow: kn, zoomSymlog: Sn, encode: function (e, t, n) { if (e) { const n = this.context.dataflow, r = e.mark.source; n.pulse(r, n.changeset().encode(e, t)) } return void 0 !== n ? n : e }, modify: function (e, t, n, r, i, a) { const o = this.context.dataflow, s = this.context.data[e], u = s.input, l = o.stamp(); let c, h, d = s.changes; if (!1 === o._trigger || !(u.value.length || t || r)) return 0; if ((!d || d.stamp < l) && (s.changes = d = o.changeset(), d.stamp = l, o.runAfter((() => { s.modified = !0, o.pulse(u, d).run() }), !0, 1)), n && (c = !0 === n ? Zt : on(n) || Ys(n) ? n : Wee(n), d.remove(c)), t && d.insert(t), r && (c = Wee(r), u.value.some(c) ? d.remove(c) : d.insert(r)), i) for (h in a) d.modify(i, h, a[h]); return 1 }, lassoAppend: function (e, t, n) { let r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 5; const i = (e = _n(e))[e.length - 1]; return void 0 === i || Math.hypot(i[0] - t, i[1] - n) > r ? [...e, [t, n]] : e }, lassoPath: function (e) { return _n(e).reduce(((t, n, r) => { let [i, a] = n; return t + (0 == r ? `M ${i},${a} ` : r === e.length - 1 ? " Z" : `L ${i},${a} `) }), "") }, intersectLasso: function (e, t, n) { const { x: r, y: i, mark: a } = n, o = (new qv).set(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER); for (const [e, n] of t) e < o.x1 && (o.x1 = e), e > o.x2 && (o.x2 = e), n < o.y1 && (o.y1 = n), n > o.y2 && (o.y2 = n); return o.translate(r, i), Kee([[o.x1, o.y1], [o.x2, o.y2]], e, a).filter((e => function (e, t, n) { let r = 0; for (let i = 0, a = n.length - 1; i < n.length; a = i++) { const [o, s] = n[a], [u, l] = n[i]; l > t != s > t && e < (o - u) * (t - l) / (s - l) + u && r++ } return 1 & r }(e.x, e.y, t))) } }, Jee = ["view", "item", "group", "xy", "x", "y"], Qee = "this.", ete = {}, tte = { forbidden: ["_"], allowed: ["datum", "event", "item"], fieldvar: "datum", globalvar: e => `_[${Yn(Eee + e)}]`, functions: function (e) { const t = p9(e); Jee.forEach((e => t[e] = "event.vega." + e)); for (const e in Zee) t[e] = Qee + e; return $n(t, Dee(e, Zee, ete)), t }, constants: f9, visitors: ete }, nte = function (e) { const t = (e = e || {}).allowed ? Qn(e.allowed) : {}, n = e.forbidden ? Qn(e.forbidden) : {}, r = e.constants || f9, i = (e.functions || p9)(h), a = e.globalvar, o = e.fieldvar, s = Cn(a) ? a : e => `${a}["${e}"]`; let u = {}, l = {}, c = 0; function h(e) { if (Vn(e)) return e; const t = d[e.type]; return null == t && Vt("Unsupported type: " + e.type), t(e) } const d = { Literal: e => e.raw, Identifier: e => { const i = e.name; return c > 0 ? i : zn(n, i) ? Vt("Illegal identifier: " + i) : zn(r, i) ? r[i] : zn(t, i) ? i : (u[i] = 1, s(i)) }, MemberExpression: e => { const t = !e.computed, n = h(e.object); t && (c += 1); const r = h(e.property); return n === o && (l[function (e) { const t = e && e.length - 1; return t && ('"' === e[0] && '"' === e[t] || "'" === e[0] && "'" === e[t]) ? e.slice(1, -1) : e }(r)] = 1), t && (c -= 1), n + (t ? "." + r : "[" + r + "]") }, CallExpression: e => { "Identifier" !== e.callee.type && Vt("Illegal callee type: " + e.callee.type); const t = e.callee.name, n = e.arguments, r = zn(i, t) && i[t]; return r || Vt("Unrecognized function: " + t), Cn(r) ? r(n) : r + "(" + n.map(h).join(",") + ")" }, ArrayExpression: e => "[" + e.elements.map(h).join(",") + "]", BinaryExpression: e => "(" + h(e.left) + " " + e.operator + " " + h(e.right) + ")", UnaryExpression: e => "(" + e.operator + h(e.argument) + ")", ConditionalExpression: e => "(" + h(e.test) + "?" + h(e.consequent) + ":" + h(e.alternate) + ")", LogicalExpression: e => "(" + h(e.left) + e.operator + h(e.right) + ")", ObjectExpression: e => "{" + e.properties.map(h).join(",") + "}", Property: e => { c += 1; const t = h(e.key); return c -= 1, t + ":" + h(e.value) } }; function f(e) { const t = { code: h(e), globals: Object.keys(u), fields: Object.keys(l) }; return u = {}, l = {}, t } return f.functions = i, f.constants = r, f }(tte); function rte(e, t, n) { return 1 === arguments.length ? Zee[e] : (Zee[e] = t, n && (ete[e] = n), nte && (nte.functions[e] = Qee + e), this) } function ite(e, t) { const n = {}; let r; try { r = function (e) { L5 = 0, j5 = (B5 = e).length, U5 = null, j6(); const t = d9(); if (U5.type !== V5) throw new Error("Unexpect token after expression."); return t }(e = Vn(e) ? e : Yn(e) + "") } catch (t) { Vt("Expression parse error: " + e) } r.visit((e => { if (e.type !== M5) return; const r = e.callee.name, i = tte.visitors[r]; i && i(r, e.arguments, t, n) })); const i = nte(r); return i.globals.forEach((e => { const r = Eee + e; !zn(n, r) && t.getSignal(e) && (n[r] = t.signalRef(e)) })), { $expr: $n({ code: i.code }, t.options.ast ? { ast: r } : null), $fields: i.fields, $params: n } } rte("bandwidth", (function (e, t) { const n = Fee(e, (t || this).context); return n && n.bandwidth ? n.bandwidth() : 0 }), Iee), rte("copy", (function (e, t) { const n = Fee(e, (t || this).context); return n ? n.copy() : void 0 }), Iee), rte("domain", (function (e, t) { const n = Fee(e, (t || this).context); return n ? n.domain() : [] }), Iee), rte("range", (function (e, t) { const n = Fee(e, (t || this).context); return n && n.range ? n.range() : [] }), Iee), rte("invert", (function (e, t, n) { const r = Fee(e, (n || this).context); return r ? on(t) ? (r.invertRange || r.invert)(t) : (r.invert || r.invertExtent)(t) : void 0 }), Iee), rte("scale", (function (e, t, n) { const r = Fee(e, (n || this).context); return r ? r(t) : void 0 }), Iee), rte("gradient", (function (e, t, n, r, i) { e = Fee(e, (i || this).context); const a = function (e, t) { var n, r = []; return n = { gradient: "linear", x1: e ? e[0] : 0, y1: e ? e[1] : 0, x2: t ? t[0] : 1, y2: t ? t[1] : 0, stops: r, stop: function (e, t) { return r.push({ offset: e, color: t }), n } } }(t, n); let o = e.domain(), s = o[0], u = hn(o), l = Yt; return u - s ? l = _b(e, s, u) : e = (e.interpolator ? fb("sequential")().interpolator(e.interpolator()) : fb("linear")().interpolate(e.interpolate()).range(e.range())).domain([s = 0, u = 1]), e.ticks && (o = e.ticks(+r || 15), s !== o[0] && o.unshift(s), u !== hn(o) && o.push(u)), o.forEach((t => a.stop(l(t), e(t)))), a }), Iee), rte("geoArea", Ree, Iee), rte("geoBounds", Oee, Iee), rte("geoCentroid", zee, Iee), rte("geoShape", (function (e, t, n) { const r = Fee(e, (n || this).context); return function (e) { return r ? r.path.context(e)(t) : "" } }), Iee), rte("geoScale", (function (e, t) { const n = Fee(e, (t || this).context); return n && n.scale() }), Iee), rte("indata", (function (e, t, n) { const r = this.context.data[e]["index:" + t], i = r ? r.value.get(n) : void 0; return i ? i.count : i }), (function (e, t, n, r) { t[0].type !== T5 && Vt("First argument to indata must be a string literal."), t[1].type !== T5 && Vt("Second argument to indata must be a string literal."); const i = t[0].value, a = t[1].value, o = "@" + a; zn(o, r) || (r[o] = n.getData(i).indataRef(n, a)) })), rte("data", vee, Nee), rte("treePath", (function (e, t, n) { const r = Yee(e, this), i = r[t], a = r[n]; return i && a ? i.path(a).map(qee) : void 0 }), Nee), rte("treeAncestors", (function (e, t) { const n = Yee(e, this)[t]; return n ? n.ancestors().map(qee) : void 0 }), Nee), rte("vlSelectionTest", cee, bee), rte("vlSelectionIdTest", pee, bee), rte("vlSelectionResolve", gee, bee), rte("vlSelectionTuples", mee); const ate = Qn(["rule"]), ote = Qn(["group", "image", "rect"]); function ste(e) { return (e + "").toLowerCase() } function ute(e, t, n) { n.endsWith(";") || (n = "return(" + n + ");"); const r = Function(...t.concat(n)); return e && e.functions ? r.bind(e.functions) : r } var lte = { operator: (e, t) => ute(e, ["_"], t.code), parameter: (e, t) => ute(e, ["datum", "_"], t.code), event: (e, t) => ute(e, ["event"], t.code), handler: (e, t) => ute(e, ["_", "event"], `var datum=event.item&&event.item.datum;return ${t.code};`), encode: (e, t) => { const { marktype: n, channels: r } = t; let i = "var o=item,datum=o.datum,m=0,$;"; for (const e in r) { const t = "o[" + Yn(e) + "]"; i += `$=${r[e].code};if(${t}!==$)${t}=$,m=1;` } return i += function (e, t) { let n = ""; return ate[t] || (e.x2 && (e.x ? (ote[t] && (n += "if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"), n += "o.width=o.x2-o.x;") : n += "o.x=o.x2-(o.width||0);"), e.xc && (n += "o.x=o.xc-(o.width||0)/2;"), e.y2 && (e.y ? (ote[t] && (n += "if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"), n += "o.height=o.y2-o.y;") : n += "o.y=o.y2-(o.height||0);"), e.yc && (n += "o.y=o.yc-(o.height||0)/2;")), n }(r, n), i += "return m;", ute(e, ["item", "_"], i) }, codegen: { get(e) { const t = `[${e.map(Yn).join("][")}]`, n = Function("_", `return _${t};`); return n.path = t, n }, comparator(e, t) { let n; const r = Function("a", "b", "var u, v; return " + e.map(((e, r) => { const i = t[r]; let a, o; return e.path ? (a = `a${e.path}`, o = `b${e.path}`) : ((n = n || {})["f" + r] = e, a = `this.f${r}(a)`, o = `this.f${r}(b)`), function (e, t, n, r) { return `((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${n}\n : (u > v || v == null) && u != null ? ${r}\n : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n}\n : v !== v && u === u ? ${r} : ` }(a, o, -i, i) })).join("") + "0;"); return n ? r.bind(n) : r } } }; function cte(e, t, n) { if (!e || !sn(e)) return e; for (let r, i = 0, a = hte.length; i < a; ++i)if (r = hte[i], zn(e, r.key)) return r.parse(e, t, n); return e } var hte = [{ key: "$ref", parse: function (e, t) { return t.get(e.$ref) || Vt("Operator not defined: " + e.$ref) } }, { key: "$key", parse: function (e, t) { const n = "k:" + e.$key + "_" + !!e.$flat; return t.fn[n] || (t.fn[n] = Gn(e.$key, e.$flat, t.expr.codegen)) } }, { key: "$expr", parse: function (e, t, n) { e.$params && t.parseParameters(e.$params, n); const r = "e:" + e.$expr.code; return t.fn[r] || (t.fn[r] = Pt(t.parameterExpression(e.$expr), e.$fields)) } }, { key: "$field", parse: function (e, t) { if (!e.$field) return null; const n = "f:" + e.$field + "_" + e.$name; return t.fn[n] || (t.fn[n] = Ht(e.$field, e.$name, t.expr.codegen)) } }, { key: "$encode", parse: function (e, t) { const n = e.$encode, r = {}; for (const e in n) { const i = n[e]; r[e] = Pt(t.encodeExpression(i.$expr), i.$fields), r[e].output = i.$output } return r } }, { key: "$compare", parse: function (e, t) { const n = "c:" + e.$compare + "_" + e.$order, r = _n(e.$compare).map((e => e && e.$tupleid ? Xs : e)); return t.fn[n] || (t.fn[n] = Tn(r, e.$order, t.expr.codegen)) } }, { key: "$context", parse: function (e, t) { return t } }, { key: "$subflow", parse: function (e, t) { const n = e.$subflow; return function (e, r, i) { const a = t.fork().parse(n), o = a.get(n.operators[0].id), s = a.signals.parent; return s && s.set(i), o.detachSubflow = () => t.detach(a), o } } }, { key: "$tupleid", parse: function () { return Xs } }]; const dte = { skip: !0 }; function fte(e, t, n, r) { this.dataflow = e, this.transforms = t, this.events = e.events.bind(e), this.expr = r || lte, this.signals = {}, this.scales = {}, this.nodes = {}, this.data = {}, this.fn = {}, n && (this.functions = Object.create(n), this.functions.context = this) } function pte(e) { this.dataflow = e.dataflow, this.transforms = e.transforms, this.events = e.events, this.expr = e.expr, this.signals = Object.create(e.signals), this.scales = Object.create(e.scales), this.nodes = Object.create(e.nodes), this.data = Object.create(e.data), this.fn = Object.create(e.fn), e.functions && (this.functions = Object.create(e.functions), this.functions.context = this) } function mte(e, t) { e && (null == t ? e.removeAttribute("aria-label") : e.setAttribute("aria-label", t)) } fte.prototype = pte.prototype = { fork() { const e = new pte(this); return (this.subcontext || (this.subcontext = [])).push(e), e }, detach(e) { this.subcontext = this.subcontext.filter((t => t !== e)); const t = Object.keys(e.nodes); for (const n of t) e.nodes[n]._targets = null; for (const n of t) e.nodes[n].detach(); e.nodes = null }, get(e) { return this.nodes[e] }, set(e, t) { return this.nodes[e] = t }, add(e, t) { const n = this, r = n.dataflow, i = e.value; if (n.set(e.id, t), function (e) { return "collect" === ste(e) }(e.type) && i && (i.$ingest ? r.ingest(t, i.$ingest, i.$format) : i.$request ? r.preload(t, i.$request, i.$format) : r.pulse(t, r.changeset().insert(i))), e.root && (n.root = t), e.parent) { let i = n.get(e.parent.$ref); i ? (r.connect(i, [t]), t.targets().add(i)) : (n.unresolved = n.unresolved || []).push((() => { i = n.get(e.parent.$ref), r.connect(i, [t]), t.targets().add(i) })) } if (e.signal && (n.signals[e.signal] = t), e.scale && (n.scales[e.scale] = t), e.data) for (const r in e.data) { const i = n.data[r] || (n.data[r] = {}); e.data[r].forEach((e => i[e] = t)) } }, resolve() { return (this.unresolved || []).forEach((e => e())), delete this.unresolved, this }, operator(e, t) { this.add(e, this.dataflow.add(e.value, t)) }, transform(e, t) { this.add(e, this.dataflow.add(this.transforms[ste(t)])) }, stream(e, t) { this.set(e.id, t) }, update(e, t, n, r, i) { this.dataflow.on(t, n, r, i, e.options) }, operatorExpression(e) { return this.expr.operator(this, e) }, parameterExpression(e) { return this.expr.parameter(this, e) }, eventExpression(e) { return this.expr.event(this, e) }, handlerExpression(e) { return this.expr.handler(this, e) }, encodeExpression(e) { return this.expr.encode(this, e) }, parse: function (e) { const t = this, n = e.operators || []; return e.background && (t.background = e.background), e.eventConfig && (t.eventConfig = e.eventConfig), e.locale && (t.locale = e.locale), n.forEach((e => t.parseOperator(e))), n.forEach((e => t.parseOperatorParameters(e))), (e.streams || []).forEach((e => t.parseStream(e))), (e.updates || []).forEach((e => t.parseUpdate(e))), t.resolve() }, parseOperator: function (e) { const t = this; !function (e) { return "operator" === ste(e) }(e.type) && e.type ? t.transform(e, e.type) : t.operator(e, e.update ? t.operatorExpression(e.update) : null) }, parseOperatorParameters: function (e) { const t = this; if (e.params) { const n = t.get(e.id); n || Vt("Invalid operator id: " + e.id), t.dataflow.connect(n, n.parameters(t.parseParameters(e.params), e.react, e.initonly)) } }, parseParameters: function (e, t) { t = t || {}; const n = this; for (const r in e) { const i = e[r]; t[r] = on(i) ? i.map((e => cte(e, n, t))) : cte(i, n, t) } return t }, parseStream: function (e) { var t, n = this, r = null != e.filter ? n.eventExpression(e.filter) : void 0, i = null != e.stream ? n.get(e.stream) : void 0; e.source ? i = n.events(e.source, e.type, r) : e.merge && (i = (t = e.merge.map((e => n.get(e))))[0].merge.apply(t[0], t.slice(1))), e.between && (t = e.between.map((e => n.get(e))), i = i.between(t[0], t[1])), e.filter && (i = i.filter(r)), null != e.throttle && (i = i.throttle(+e.throttle)), null != e.debounce && (i = i.debounce(+e.debounce)), null == i && Vt("Invalid stream definition: " + JSON.stringify(e)), e.consume && i.consume(!0), n.stream(e, i) }, parseUpdate: function (e) { var t, n = this, r = sn(r = e.source) ? r.$ref : r, i = n.get(r), a = e.update, o = void 0; i || Vt("Source not defined: " + e.source), t = e.target && e.target.$expr ? n.eventExpression(e.target.$expr) : n.get(e.target), a && a.$expr && (a.$params && (o = n.parseParameters(a.$params)), a = n.handlerExpression(a.$expr)), n.update(e, i, t, a, o) }, getState: function (e) { var t = this, n = {}; if (e.signals) { var r = n.signals = {}; Object.keys(t.signals).forEach((n => { const i = t.signals[n]; e.signals(n, i) && (r[n] = i.value) })) } if (e.data) { var i = n.data = {}; Object.keys(t.data).forEach((n => { const r = t.data[n]; e.data(n, r) && (i[n] = r.input.value) })) } return t.subcontext && !1 !== e.recurse && (n.subcontext = t.subcontext.map((t => t.getState(e)))), n }, setState: function (e) { var t = this, n = t.dataflow, r = e.data, i = e.signals; Object.keys(i || {}).forEach((e => { n.update(t.signals[e], i[e], dte) })), Object.keys(r || {}).forEach((e => { n.pulse(t.data[e].input, n.changeset().remove(Zt).insert(r[e])) })), (e.subcontext || []).forEach(((e, n) => { const r = t.subcontext[n]; r && r.setState(e) })) } }; const gte = "default"; function yte(e, t) { const n = e.globalCursor() ? "undefined" != typeof document && document.body : e.container(); if (n) return null == t ? n.style.removeProperty("cursor") : n.style.cursor = t } function bte(e, t) { var n = e._runtime.data; return zn(n, t) || Vt("Unrecognized data set: " + t), n[t] } function vte(e, t) { nu(t) || Vt("Second argument to changes must be a changeset."); const n = bte(this, e); return n.modified = !0, this.pulse(n.input, t) } function xte(e) { var t = e.padding(); return Math.max(0, e._viewWidth + t.left + t.right) } function wte(e) { var t = e.padding(); return Math.max(0, e._viewHeight + t.top + t.bottom) } function kte(e) { var t = e.padding(), n = e._origin; return [t.left + n[0], t.top + n[1]] } function Ste(e, t, n) { var r, i, a = e._renderer, o = a && a.canvas(); return o && (i = kte(e), (r = nk(t.changedTouches ? t.changedTouches[0] : t, o))[0] -= i[0], r[1] -= i[1]), t.dataflow = e, t.item = n, t.vega = function (e, t, n) { const r = t ? "group" === t.mark.marktype ? t : t.mark.group : null; function i(e) { var n, i = r; if (e) for (n = t; n; n = n.mark.group)if (n.mark.name === e) { i = n; break } return i && i.mark && i.mark.interactive ? i : {} } function a(e) { if (!e) return n; Vn(e) && (e = i(e)); const t = n.slice(); for (; e;)t[0] -= e.x || 0, t[1] -= e.y || 0, e = e.mark && e.mark.group; return t } return { view: Fn(e), item: Fn(t || {}), group: i, xy: a, x: e => a(e)[0], y: e => a(e)[1] } }(e, n, r), t } const _te = "view", Cte = { trap: !1 }; function Ate(e, t, n, r) { e._eventListeners.push({ type: n, sources: _n(t), handler: r }) } function Tte(e, t, n) { const r = e._eventConfig && e._eventConfig[t]; return !(!1 === r || sn(r) && !r[n]) || (e.warn(`Blocked ${t} ${n} event listener.`), !1) } function Ete(e) { return e.item } function Nte(e) { return e.item.mark.source } function Ite(e) { return function (t, n) { return n.vega.view().changeset().encode(n.item, e) } } function Mte(e, t, n) { const r = document.createElement(e); for (const e in t) r.setAttribute(e, t[e]); return null != n && (r.textContent = n), r } function Fte(e, t, n, r) { const i = n.event || "input", a = () => e.update(t.value); r.signal(n.signal, t.value), t.addEventListener(i, a), Ate(r, t, i, a), e.set = e => { t.value = e, t.dispatchEvent(function (e) { return "undefined" != typeof Event ? new Event(e) : { type: e } }(i)) } } function Dte(e, t, n, r) { const i = r.signal(n.signal), a = Mte("div", { class: "vega-bind" }), o = "radio" === n.input ? a : a.appendChild(Mte("label")); o.appendChild(Mte("span", { class: "vega-bind-name" }, n.name || n.signal)), t.appendChild(a); let s = $te; switch (n.input) { case "checkbox": s = Rte; break; case "select": s = Ote; break; case "radio": s = zte; break; case "range": s = Pte }s(e, o, n, i) } function $te(e, t, n, r) { const i = Mte("input"); for (const e in n) "signal" !== e && "element" !== e && i.setAttribute("input" === e ? "type" : e, n[e]); i.setAttribute("name", n.signal), i.value = r, t.appendChild(i), i.addEventListener("input", (() => e.update(i.value))), e.elements = [i], e.set = e => i.value = e } function Rte(e, t, n, r) { const i = { type: "checkbox", name: n.signal }; r && (i.checked = !0); const a = Mte("input", i); t.appendChild(a), a.addEventListener("change", (() => e.update(a.checked))), e.elements = [a], e.set = e => a.checked = !!e || null } function Ote(e, t, n, r) { const i = Mte("select", { name: n.signal }), a = n.labels || []; n.options.forEach(((e, t) => { const n = { value: e }; Bte(e, r) && (n.selected = !0), i.appendChild(Mte("option", n, (a[t] || e) + "")) })), t.appendChild(i), i.addEventListener("change", (() => { e.update(n.options[i.selectedIndex]) })), e.elements = [i], e.set = e => { for (let t = 0, r = n.options.length; t < r; ++t)if (Bte(n.options[t], e)) return void (i.selectedIndex = t) } } function zte(e, t, n, r) { const i = Mte("span", { class: "vega-bind-radio" }), a = n.labels || []; t.appendChild(i), e.elements = n.options.map(((t, o) => { const s = { type: "radio", name: n.signal, value: t }; Bte(t, r) && (s.checked = !0); const u = Mte("input", s); u.addEventListener("change", (() => e.update(t))); const l = Mte("label", {}, (a[o] || t) + ""); return l.prepend(u), i.appendChild(l), u })), e.set = t => { const n = e.elements, r = n.length; for (let e = 0; e < r; ++e)Bte(n[e].value, t) && (n[e].checked = !0) } } function Pte(e, t, n, r) { r = void 0 !== r ? r : (+n.max + +n.min) / 2; const i = null != n.max ? n.max : Math.max(100, +r) || 100, a = n.min || Math.min(0, i, +r) || 0, o = n.step || _A(a, i, 100), s = Mte("input", { type: "range", name: n.signal, min: a, max: i, step: o }); s.value = r; const u = Mte("span", {}, +r); t.appendChild(s), t.appendChild(u); const l = () => { u.textContent = s.value, e.update(+s.value) }; s.addEventListener("input", l), s.addEventListener("change", l), e.elements = [s], e.set = e => { s.value = e, u.textContent = e } } function Bte(e, t) { return e === t || e + "" == t + "" } function Lte(e, t, n, r, i, a) { return (t = t || new r(e.loader())).initialize(n, xte(e), wte(e), kte(e), i, a).background(e.background()) } function jte(e, t) { return t ? function () { try { t.apply(this, arguments) } catch (t) { e.error(t) } } : null } function Ute(e, t, n) { if ("string" == typeof t) { if ("undefined" == typeof document) return e.error("DOM document instance not found."), null; if (!(t = document.querySelector(t))) return e.error("Signal bind element not found: " + t), null } if (t && n) try { t.innerHTML = "" } catch (n) { t = null, e.error(n) } return t } const Wte = e => +e || 0; function Vte(e) { return sn(e) ? { top: Wte(e.top), bottom: Wte(e.bottom), left: Wte(e.left), right: Wte(e.right) } : (e => ({ top: e, bottom: e, left: e, right: e }))(Wte(e)) } async function Gte(e, t, n, r) { const i = CS(t), a = i && i.headless; return a || Vt("Unrecognized renderer type: " + t), await e.runAsync(), Lte(e, null, null, a, n, r).renderAsync(e._scenegraph.root) } function Hte(e, t, n) { return function (e, t, n, r) { return new fte(e, t, n, r) }(e, Nu, Zee, n).parse(t) } var qte = "width", Yte = "height", Xte = "padding", Kte = { skip: !0 }; function Zte(e, t) { var n = e.autosize(), r = e.padding(); return t - (n && n.contains === Xte ? r.left + r.right : 0) } function Jte(e, t) { var n = e.autosize(), r = e.padding(); return t - (n && n.contains === Xte ? r.top + r.bottom : 0) } function Qte(e, t) { return t.modified && on(t.input.value) && e.indexOf("_:vega:_") } function ene(e, t) { return !("parent" === e || t instanceof Nu.proxy) } function tne(e, t, n, r) { const i = e.element(); i && i.setAttribute("title", function (e) { return null == e ? "" : on(e) ? nne(e) : sn(e) && !Un(e) ? (t = e, Object.keys(t).map((e => { const n = t[e]; return e + ": " + (on(n) ? nne(n) : rne(n)) })).join("\n")) : e + ""; var t }(r)) } function nne(e) { return "[" + e.map(rne).join(", ") + "]" } function rne(e) { return on(e) ? "[…]" : sn(e) && !Un(e) ? "{…}" : e } function ine(e, t) { const n = this; if (t = t || {}, Au.call(n), t.loader && n.loader(t.loader), t.logger && n.logger(t.logger), null != t.logLevel && n.logLevel(t.logLevel), t.locale || e.locale) { const r = $n({}, e.locale, t.locale); n.locale(function (e, t) { const n = e ? cs(e) : hs(), r = t ? ms(t) : gs(); return ys(n, r) }(r.number, r.time)) } n._el = null, n._elBind = null, n._renderType = t.renderer || SS.Canvas, n._scenegraph = new Xw; const r = n._scenegraph.root; n._renderer = null, n._tooltip = t.tooltip || tne, n._redraw = !0, n._handler = (new Ak).scene(r), n._globalCursor = !1, n._preventDefault = !1, n._timers = [], n._eventListeners = [], n._resizeListeners = [], n._eventConfig = function (e) { const t = $n({ defaults: {} }, e), n = (e, t) => { t.forEach((t => { on(e[t]) && (e[t] = Qn(e[t])) })) }; return n(t.defaults, ["prevent", "allow"]), n(t, ["view", "window", "selector"]), t }(e.eventConfig), n.globalCursor(n._eventConfig.globalCursor); const i = Hte(n, e, t.expr); n._runtime = i, n._signals = i.signals, n._bind = (e.bindings || []).map((e => ({ state: null, param: $n({}, e) }))), i.root && i.root.set(r), r.source = i.data.root.input, n.pulse(i.data.root.input, n.changeset().insert(r.items)), n._width = n.width(), n._height = n.height(), n._viewWidth = Zte(n, n._width), n._viewHeight = Jte(n, n._height), n._origin = [0, 0], n._resize = 0, n._autosize = 1, function (e) { var t = e._signals, n = t[qte], r = t[Yte], i = t[Xte]; function a() { e._autosize = e._resize = 1 } e._resizeWidth = e.add(null, (t => { e._width = t.size, e._viewWidth = Zte(e, t.size), a() }), { size: n }), e._resizeHeight = e.add(null, (t => { e._height = t.size, e._viewHeight = Jte(e, t.size), a() }), { size: r }); const o = e.add(null, a, { pad: i }); e._resizeWidth.rank = n.rank + 1, e._resizeHeight.rank = r.rank + 1, o.rank = i.rank + 1 }(n), function (e) { e.add(null, (t => (e._background = t.bg, e._resize = 1, t.bg)), { bg: e._signals.background }) }(n), function (e) { const t = e._signals.cursor || (e._signals.cursor = e.add({ user: gte, item: null })); e.on(e.events("view", "mousemove"), t, ((e, n) => { const r = t.value, i = r ? Vn(r) ? r : r.user : gte, a = n.item && n.item.cursor || null; return r && i === r.user && a == r.item ? r : { user: i, item: a } })), e.add(null, (function (t) { let n = t.cursor, r = this.value; return Vn(n) || (r = n.item, n = n.user), yte(e, n && n !== gte ? n : r || n), r }), { cursor: t }) }(n), n.description(e.description), t.hover && n.hover(), t.container && n.initialize(t.container, t.bind) } function ane(e, t) { return zn(e._signals, t) ? e._signals[t] : Vt("Unrecognized signal name: " + Yn(t)) } function one(e, t) { const n = (e._targets || []).filter((e => e._update && e._update.handler === t)); return n.length ? n[0] : null } function sne(e, t, n, r) { let i = one(n, r); return i || (i = jte(e, (() => r(t, n.value))), i.handler = r, e.on(n, null, i)), e } function une(e, t, n) { const r = one(t, n); return r && t._targets.remove(r), e } Ln(ine, Au, { async evaluate(e, t, n) { if (await Au.prototype.evaluate.call(this, e, t), this._redraw || this._resize) try { this._renderer && (this._resize && (this._resize = 0, function (e) { var t = kte(e), n = xte(e), r = wte(e); e._renderer.background(e.background()), e._renderer.resize(n, r, t), e._handler.origin(t), e._resizeListeners.forEach((t => { try { t(n, r) } catch (t) { e.error(t) } })) }(this)), await this._renderer.renderAsync(this._scenegraph.root)), this._redraw = !1 } catch (e) { this.error(e) } return n && Gs(this, n), this }, dirty(e) { this._redraw = !0, this._renderer && this._renderer.dirty(e) }, description(e) { if (arguments.length) { const t = null != e ? e + "" : null; return t !== this._desc && mte(this._el, this._desc = t), this } return this._desc }, container() { return this._el }, scenegraph() { return this._scenegraph }, origin() { return this._origin.slice() }, signal(e, t, n) { const r = ane(this, e); return 1 === arguments.length ? r.value : this.update(r, t, n) }, width(e) { return arguments.length ? this.signal("width", e) : this.signal("width") }, height(e) { return arguments.length ? this.signal("height", e) : this.signal("height") }, padding(e) { return arguments.length ? this.signal("padding", Vte(e)) : Vte(this.signal("padding")) }, autosize(e) { return arguments.length ? this.signal("autosize", e) : this.signal("autosize") }, background(e) { return arguments.length ? this.signal("background", e) : this.signal("background") }, renderer(e) { return arguments.length ? (CS(e) || Vt("Unrecognized renderer type: " + e), e !== this._renderType && (this._renderType = e, this._resetRenderer()), this) : this._renderType }, tooltip(e) { return arguments.length ? (e !== this._tooltip && (this._tooltip = e, this._resetRenderer()), this) : this._tooltip }, loader(e) { return arguments.length ? (e !== this._loader && (Au.prototype.loader.call(this, e), this._resetRenderer()), this) : this._loader }, resize() { return this._autosize = 1, this.touch(ane(this, "autosize")) }, _resetRenderer() { this._renderer && (this._renderer = null, this.initialize(this._el, this._elBind)) }, _resizeView: function (e, t, n, r, i, a) { this.runAfter((o => { let s = 0; o._autosize = 0, o.width() !== n && (s = 1, o.signal(qte, n, Kte), o._resizeWidth.skip(!0)), o.height() !== r && (s = 1, o.signal(Yte, r, Kte), o._resizeHeight.skip(!0)), o._viewWidth !== e && (o._resize = 1, o._viewWidth = e), o._viewHeight !== t && (o._resize = 1, o._viewHeight = t), o._origin[0] === i[0] && o._origin[1] === i[1] || (o._resize = 1, o._origin = i), s && o.run("enter"), a && o.runAfter((e => e.resize())) }), !1, 1) }, addEventListener(e, t, n) { let r = t; return n && !1 === n.trap || (r = jte(this, t), r.raw = t), this._handler.on(e, r), this }, removeEventListener(e, t) { for (var n, r, i = this._handler.handlers(e), a = i.length; --a >= 0;)if (r = i[a].type, n = i[a].handler, e === r && (t === n || t === n.raw)) { this._handler.off(r, n); break } return this }, addResizeListener(e) { const t = this._resizeListeners; return t.indexOf(e) < 0 && t.push(e), this }, removeResizeListener(e) { var t = this._resizeListeners, n = t.indexOf(e); return n >= 0 && t.splice(n, 1), this }, addSignalListener(e, t) { return sne(this, e, ane(this, e), t) }, removeSignalListener(e, t) { return une(this, ane(this, e), t) }, addDataListener(e, t) { return sne(this, e, bte(this, e).values, t) }, removeDataListener(e, t) { return une(this, bte(this, e).values, t) }, globalCursor(e) { if (arguments.length) { if (this._globalCursor !== !!e) { const t = yte(this, null); this._globalCursor = !!e, t && yte(this, t) } return this } return this._globalCursor }, preventDefault(e) { return arguments.length ? (this._preventDefault = e, this) : this._preventDefault }, timer: function (e, t) { this._timers.push(function (e, t, n) { var r = new _F, i = t; return null == t ? (r.restart(e, t, n), r) : (r._restart = r.restart, r.restart = function (e, t, n) { t = +t, n = null == n ? kF() : +n, r._restart((function a(o) { o += i, r._restart(a, i += t, n), e(o) }), t, n) }, r.restart(e, t, n), r) }((function (t) { e({ timestamp: Date.now(), elapsed: t }) }), t)) }, events: function (e, t, n) { var r, i = this, a = new hu(n), o = function (n, r) { i.runAsync(null, (() => { e === _te && function (e, t) { var n = e._eventConfig.defaults, r = n.prevent, i = n.allow; return !1 !== r && !0 !== i && (!0 === r || !1 === i || (r ? r[t] : i ? !i[t] : e.preventDefault())) }(i, t) && n.preventDefault(), a.receive(Ste(i, n, r)) })) }; if ("timer" === e) Tte(i, "timer", t) && i.timer(o, t); else if (e === _te) Tte(i, "view", t) && i.addEventListener(t, o, Cte); else if ("window" === e ? Tte(i, "window", t) && "undefined" != typeof window && (r = [window]) : "undefined" != typeof document && Tte(i, "selector", t) && (r = document.querySelectorAll(e)), r) { for (var s = 0, u = r.length; s < u; ++s)r[s].addEventListener(t, o); Ate(i, r, t, o) } else i.warn("Can not resolve event source: " + e); return a }, finalize: function () { var e, t, n, r = this._tooltip, i = this._timers, a = this._eventListeners; for (e = i.length; --e >= 0;)i[e].stop(); for (e = a.length; --e >= 0;)for (t = (n = a[e]).sources.length; --t >= 0;)n.sources[t].removeEventListener(n.type, n.handler); return r && r.call(this, this._handler, null, null, null), this }, hover: function (e, t) { return t = [t || "update", (e = [e || "hover"])[0]], this.on(this.events("view", "mouseover", Ete), Nte, Ite(e)), this.on(this.events("view", "mouseout", Ete), Nte, Ite(t)), this }, data: function (e, t) { return arguments.length < 2 ? bte(this, e).values.value : vte.call(this, e, ru().remove(Zt).insert(t)) }, change: vte, insert: function (e, t) { return vte.call(this, e, ru().insert(t)) }, remove: function (e, t) { return vte.call(this, e, ru().remove(t)) }, scale: function (e) { var t = this._runtime.scales; return zn(t, e) || Vt("Unrecognized scale or projection: " + e), t[e].value }, initialize: function (e, t) { const n = this, r = n._renderType, i = n._eventConfig.bind, a = CS(r); e = n._el = e ? Ute(n, e, !0) : null, function (e) { const t = e.container(); t && (t.setAttribute("role", "graphics-document"), t.setAttribute("aria-roleDescription", "visualization"), mte(t, e.description())) }(n), a || n.error("Unrecognized renderer type: " + r); const o = a.handler || Ak, s = e ? a.renderer : a.headless; return n._renderer = s ? Lte(n, n._renderer, e, s) : null, n._handler = function (e, t, n, r) { const i = new r(e.loader(), jte(e, e.tooltip())).scene(e.scenegraph().root).initialize(n, kte(e), e); return t && t.handlers().forEach((e => { i.on(e.type, e.handler) })), i }(n, n._handler, e, o), n._redraw = !0, e && "none" !== i && (t = t ? n._elBind = Ute(n, t, !0) : e.appendChild(Mte("form", { class: "vega-bindings" })), n._bind.forEach((e => { e.param.element && "container" !== i && (e.element = Ute(n, e.param.element, !!e.param.input)) })), n._bind.forEach((e => { !function (e, t, n) { if (!t) return; const r = n.param; let i = n.state; i || (i = n.state = { elements: null, active: !1, set: null, update: t => { t != e.signal(r.signal) && e.runAsync(null, (() => { i.source = !0, e.signal(r.signal, t) })) } }, r.debounce && (i.update = Dn(r.debounce, i.update))), (null == r.input && r.element ? Fte : Dte)(i, t, r, e), i.active || (e.on(e._signals[r.signal], null, (() => { i.source ? i.source = !1 : i.set(e.signal(r.signal)) })), i.active = !0) }(n, e.element || t, e) }))), n }, toImageURL: async function (e, t) { e !== SS.Canvas && e !== SS.SVG && e !== SS.PNG && Vt("Unrecognized image type: " + e); const n = await Gte(this, e, t); return e === SS.SVG ? function (e, t) { const n = new Blob([e], { type: t }); return window.URL.createObjectURL(n) }(n.svg(), "image/svg+xml") : n.canvas().toDataURL("image/png") }, toCanvas: async function (e, t) { return (await Gte(this, SS.Canvas, e, t)).canvas() }, toSVG: async function (e) { return (await Gte(this, SS.SVG, e)).svg() }, getState: function (e) { return this._runtime.getState(e || { data: Qte, signals: ene, recurse: !0 }) }, setState: function (e) { return this.runAsync(null, (t => { t._trigger = !1, t._runtime.setState(e) }), (e => { e._trigger = !0 })), this } }); var lne, cne = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; function hne(e) { if (!(t = cne.exec(e))) throw new Error("invalid format: " + e); var t; return new dne({ fill: t[1], align: t[2], sign: t[3], symbol: t[4], zero: t[5], width: t[6], comma: t[7], precision: t[8] && t[8].slice(1), trim: t[9], type: t[10] }) } function dne(e) { this.fill = void 0 === e.fill ? " " : e.fill + "", this.align = void 0 === e.align ? ">" : e.align + "", this.sign = void 0 === e.sign ? "-" : e.sign + "", this.symbol = void 0 === e.symbol ? "" : e.symbol + "", this.zero = !!e.zero, this.width = void 0 === e.width ? void 0 : +e.width, this.comma = !!e.comma, this.precision = void 0 === e.precision ? void 0 : +e.precision, this.trim = !!e.trim, this.type = void 0 === e.type ? "" : e.type + "" } function fne(e, t) { if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null; var n, r = e.slice(0, n); return [r.length > 1 ? r[0] + r.slice(2) : r, +e.slice(n + 1)] } function pne(e) { return (e = fne(Math.abs(e))) ? e[1] : NaN } function mne(e, t) { var n = fne(e, t); if (!n) return e + ""; var r = n[0], i = n[1]; return i < 0 ? "0." + new Array(-i).join("0") + r : r.length > i + 1 ? r.slice(0, i + 1) + "." + r.slice(i + 1) : r + new Array(i - r.length + 2).join("0") } hne.prototype = dne.prototype, dne.prototype.toString = function () { return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (void 0 === this.width ? "" : Math.max(1, 0 | this.width)) + (this.comma ? "," : "") + (void 0 === this.precision ? "" : "." + Math.max(0, 0 | this.precision)) + (this.trim ? "~" : "") + this.type }; const gne = { "%": (e, t) => (100 * e).toFixed(t), b: e => Math.round(e).toString(2), c: e => e + "", d: function (e) { return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10) }, e: (e, t) => e.toExponential(t), f: (e, t) => e.toFixed(t), g: (e, t) => e.toPrecision(t), o: e => Math.round(e).toString(8), p: (e, t) => mne(100 * e, t), r: mne, s: function (e, t) { var n = fne(e, t); if (!n) return e + ""; var r = n[0], i = n[1], a = i - (lne = 3 * Math.max(-8, Math.min(8, Math.floor(i / 3)))) + 1, o = r.length; return a === o ? r : a > o ? r + new Array(a - o + 1).join("0") : a > 0 ? r.slice(0, a) + "." + r.slice(a) : "0." + new Array(1 - a).join("0") + fne(e, Math.max(0, t + a - 1))[0] }, X: e => Math.round(e).toString(16).toUpperCase(), x: e => Math.round(e).toString(16) }; function yne(e) { return e } var bne, vne, xne, wne = Array.prototype.map, kne = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; function Sne(e) { var t, n, r = void 0 === e.grouping || void 0 === e.thousands ? yne : (t = wne.call(e.grouping, Number), n = e.thousands + "", function (e, r) { for (var i = e.length, a = [], o = 0, s = t[0], u = 0; i > 0 && s > 0 && (u + s + 1 > r && (s = Math.max(1, r - u)), a.push(e.substring(i -= s, i + s)), !((u += s + 1) > r));)s = t[o = (o + 1) % t.length]; return a.reverse().join(n) }), i = void 0 === e.currency ? "" : e.currency[0] + "", a = void 0 === e.currency ? "" : e.currency[1] + "", o = void 0 === e.decimal ? "." : e.decimal + "", s = void 0 === e.numerals ? yne : function (e) { return function (t) { return t.replace(/[0-9]/g, (function (t) { return e[+t] })) } }(wne.call(e.numerals, String)), u = void 0 === e.percent ? "%" : e.percent + "", l = void 0 === e.minus ? "−" : e.minus + "", c = void 0 === e.nan ? "NaN" : e.nan + ""; function h(e) { var t = (e = hne(e)).fill, n = e.align, h = e.sign, d = e.symbol, f = e.zero, p = e.width, m = e.comma, g = e.precision, y = e.trim, b = e.type; "n" === b ? (m = !0, b = "g") : gne[b] || (void 0 === g && (g = 12), y = !0, b = "g"), (f || "0" === t && "=" === n) && (f = !0, t = "0", n = "="); var v = "$" === d ? i : "#" === d && /[boxX]/.test(b) ? "0" + b.toLowerCase() : "", x = "$" === d ? a : /[%p]/.test(b) ? u : "", w = gne[b], k = /[defgprs%]/.test(b); function S(e) { var i, a, u, d = v, S = x; if ("c" === b) S = w(e) + S, e = ""; else { var _ = (e = +e) < 0 || 1 / e < 0; if (e = isNaN(e) ? c : w(Math.abs(e), g), y && (e = function (e) { e: for (var t, n = e.length, r = 1, i = -1; r < n; ++r)switch (e[r]) { case ".": i = t = r; break; case "0": 0 === i && (i = r), t = r; break; default: if (!+e[r]) break e; i > 0 && (i = 0) }return i > 0 ? e.slice(0, i) + e.slice(t + 1) : e }(e)), _ && 0 == +e && "+" !== h && (_ = !1), d = (_ ? "(" === h ? h : l : "-" === h || "(" === h ? "" : h) + d, S = ("s" === b ? kne[8 + lne / 3] : "") + S + (_ && "(" === h ? ")" : ""), k) for (i = -1, a = e.length; ++i < a;)if (48 > (u = e.charCodeAt(i)) || u > 57) { S = (46 === u ? o + e.slice(i + 1) : e.slice(i)) + S, e = e.slice(0, i); break } } m && !f && (e = r(e, 1 / 0)); var C = d.length + e.length + S.length, A = C < p ? new Array(p - C + 1).join(t) : ""; switch (m && f && (e = r(A + e, A.length ? p - S.length : 1 / 0), A = ""), n) { case "<": e = d + e + S + A; break; case "=": e = d + A + e + S; break; case "^": e = A.slice(0, C = A.length >> 1) + d + e + S + A.slice(C); break; default: e = A + d + e + S }return s(e) } return g = void 0 === g ? 6 : /[gprs]/.test(b) ? Math.max(1, Math.min(21, g)) : Math.max(0, Math.min(20, g)), S.toString = function () { return e + "" }, S } return { format: h, formatPrefix: function (e, t) { var n = h(((e = hne(e)).type = "f", e)), r = 3 * Math.max(-8, Math.min(8, Math.floor(pne(t) / 3))), i = Math.pow(10, -r), a = kne[8 + r / 3]; return function (e) { return n(i * e) + a } } } } function _ne(e, t, n) { return e.fields = t || [], e.fname = n, e } function Cne(e) { return 1 === e.length ? Ane(e[0]) : Tne(e) } !function (e) { bne = Sne(e), vne = bne.format, xne = bne.formatPrefix }({ thousands: ",", grouping: [3], currency: ["$", ""] }); const Ane = e => function (t) { return t[e] }, Tne = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function Ene(e) { throw Error(e) } function Nne(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || Ene("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && Ene("Access path missing closing bracket: " + e), o && Ene("Access path missing closing quote: " + e), i > r && (i++, l()), t } function Ine(e, t, n) { const r = Nne(e); return e = 1 === r.length ? r[0] : e, _ne((n && n.get || Cne)(r), [e], t || e) } Ine("id"), _ne((e => e), [], "identity"), _ne((() => 0), [], "zero"), _ne((() => 1), [], "one"), _ne((() => !0), [], "true"), _ne((() => !1), [], "false"); Array.isArray; function Mne(e) { return e === Object(e) } function Fne(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } Object.prototype.hasOwnProperty; function Dne(e) { return "string" == typeof e } const $ne = "year", Rne = "quarter", One = "month", zne = "week", Pne = "date", Bne = "day", Lne = "dayofyear", jne = "hours", Une = "minutes", Wne = "seconds", Vne = "milliseconds";[$ne, Rne, One, zne, Pne, Bne, Lne, jne, Une, Wne, Vne].reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); new Date; const Gne = { [$ne]: fi, [Rne]: mi.every(3), [One]: mi, [zne]: Jr, [Pne]: Yr, [Bne]: Yr, [Lne]: Yr, [jne]: yi, [Une]: vi, [Wne]: wi, [Vne]: ki }, Hne = { [$ne]: pi, [Rne]: gi.every(3), [One]: gi, [zne]: oi, [Pne]: Xr, [Bne]: Xr, [Lne]: Xr, [jne]: bi, [Une]: xi, [Wne]: wi, [Vne]: ki }; function qne(e) { return Gne[e] } function Yne(e) { return Hne[e] } const Xne = [$ne, One, Pne, jne, Une, Wne, Vne], Kne = Xne.slice(0, -1), Zne = Kne.slice(0, -1), Jne = Zne.slice(0, -1); Jne.slice(0, -1); var Qne = new Date, ere = new Date; function tre(e, t, n, r) { function i(t) { return e(t = 0 === arguments.length ? new Date : new Date(+t)), t } return i.floor = function (t) { return e(t = new Date(+t)), t }, i.ceil = function (n) { return e(n = new Date(n - 1)), t(n, 1), e(n), n }, i.round = function (e) { var t = i(e), n = i.ceil(e); return e - t < n - e ? t : n }, i.offset = function (e, n) { return t(e = new Date(+e), null == n ? 1 : Math.floor(n)), e }, i.range = function (n, r, a) { var o, s = []; if (n = i.ceil(n), a = null == a ? 1 : Math.floor(a), !(n < r && a > 0)) return s; do { s.push(o = new Date(+n)), t(n, a), e(n) } while (o < n && n < r); return s }, i.filter = function (n) { return tre((function (t) { if (t >= t) for (; e(t), !n(t);)t.setTime(t - 1) }), (function (e, r) { if (e >= e) if (r < 0) for (; ++r <= 0;)for (; t(e, -1), !n(e);); else for (; --r >= 0;)for (; t(e, 1), !n(e);); })) }, n && (i.count = function (t, r) { return Qne.setTime(+t), ere.setTime(+r), e(Qne), e(ere), Math.floor(n(Qne, ere)) }, i.every = function (e) { return e = Math.floor(e), isFinite(e) && e > 0 ? e > 1 ? i.filter(r ? function (t) { return r(t) % e == 0 } : function (t) { return i.count(0, t) % e == 0 }) : i : null }), i } const nre = 6e4, rre = 864e5, ire = 6048e5; function are(e) { return tre((function (t) { t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + 7 * t) }), (function (e, t) { return (t - e) / ire })) } var ore = are(0), sre = are(1), ure = are(2), lre = are(3), cre = are(4), hre = are(5), dre = are(6), fre = (ore.range, sre.range, ure.range, lre.range, cre.range, hre.range, dre.range, tre((function (e) { e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCDate(e.getUTCDate() + t) }), (function (e, t) { return (t - e) / rre }), (function (e) { return e.getUTCDate() - 1 }))); const pre = fre; fre.range; function mre(e) { return tre((function (t) { t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0) }), (function (e, t) { e.setDate(e.getDate() + 7 * t) }), (function (e, t) { return (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * nre) / ire })) } var gre = mre(0), yre = mre(1), bre = mre(2), vre = mre(3), xre = mre(4), wre = mre(5), kre = mre(6), Sre = (gre.range, yre.range, bre.range, vre.range, xre.range, wre.range, kre.range, tre((e => e.setHours(0, 0, 0, 0)), ((e, t) => e.setDate(e.getDate() + t)), ((e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * nre) / rre), (e => e.getDate() - 1))); const _re = Sre; Sre.range; var Cre = tre((function (e) { e.setMonth(0, 1), e.setHours(0, 0, 0, 0) }), (function (e, t) { e.setFullYear(e.getFullYear() + t) }), (function (e, t) { return t.getFullYear() - e.getFullYear() }), (function (e) { return e.getFullYear() })); Cre.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? tre((function (t) { t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0) }), (function (t, n) { t.setFullYear(t.getFullYear() + n * e) })) : null }; const Are = Cre; Cre.range; var Tre = tre((function (e) { e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0) }), (function (e, t) { e.setUTCFullYear(e.getUTCFullYear() + t) }), (function (e, t) { return t.getUTCFullYear() - e.getUTCFullYear() }), (function (e) { return e.getUTCFullYear() })); Tre.every = function (e) { return isFinite(e = Math.floor(e)) && e > 0 ? tre((function (t) { t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0) }), (function (t, n) { t.setUTCFullYear(t.getUTCFullYear() + n * e) })) : null }; const Ere = Tre; Tre.range; function Nre(e) { if (0 <= e.y && e.y < 100) { var t = new Date(-1, e.m, e.d, e.H, e.M, e.S, e.L); return t.setFullYear(e.y), t } return new Date(e.y, e.m, e.d, e.H, e.M, e.S, e.L) } function Ire(e) { if (0 <= e.y && e.y < 100) { var t = new Date(Date.UTC(-1, e.m, e.d, e.H, e.M, e.S, e.L)); return t.setUTCFullYear(e.y), t } return new Date(Date.UTC(e.y, e.m, e.d, e.H, e.M, e.S, e.L)) } function Mre(e, t, n) { return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 } } function Fre(e) { var t = e.dateTime, n = e.date, r = e.time, i = e.periods, a = e.days, o = e.shortDays, s = e.months, u = e.shortMonths, l = Vre(i), c = Gre(i), h = Vre(a), d = Gre(a), f = Vre(o), p = Gre(o), m = Vre(s), g = Gre(s), y = Vre(u), b = Gre(u), v = { a: function (e) { return o[e.getDay()] }, A: function (e) { return a[e.getDay()] }, b: function (e) { return u[e.getMonth()] }, B: function (e) { return s[e.getMonth()] }, c: null, d: die, e: die, f: yie, g: Eie, G: Iie, H: fie, I: pie, j: mie, L: gie, m: bie, M: vie, p: function (e) { return i[+(e.getHours() >= 12)] }, q: function (e) { return 1 + ~~(e.getMonth() / 3) }, Q: Qie, s: eae, S: xie, u: wie, U: kie, V: _ie, w: Cie, W: Aie, x: null, X: null, y: Tie, Y: Nie, Z: Mie, "%": Jie }, x = { a: function (e) { return o[e.getUTCDay()] }, A: function (e) { return a[e.getUTCDay()] }, b: function (e) { return u[e.getUTCMonth()] }, B: function (e) { return s[e.getUTCMonth()] }, c: null, d: Fie, e: Fie, f: zie, g: Yie, G: Kie, H: Die, I: $ie, j: Rie, L: Oie, m: Pie, M: Bie, p: function (e) { return i[+(e.getUTCHours() >= 12)] }, q: function (e) { return 1 + ~~(e.getUTCMonth() / 3) }, Q: Qie, s: eae, S: Lie, u: jie, U: Uie, V: Vie, w: Gie, W: Hie, x: null, X: null, y: qie, Y: Xie, Z: Zie, "%": Jie }, w = { a: function (e, t, n) { var r = f.exec(t.slice(n)); return r ? (e.w = p.get(r[0].toLowerCase()), n + r[0].length) : -1 }, A: function (e, t, n) { var r = h.exec(t.slice(n)); return r ? (e.w = d.get(r[0].toLowerCase()), n + r[0].length) : -1 }, b: function (e, t, n) { var r = y.exec(t.slice(n)); return r ? (e.m = b.get(r[0].toLowerCase()), n + r[0].length) : -1 }, B: function (e, t, n) { var r = m.exec(t.slice(n)); return r ? (e.m = g.get(r[0].toLowerCase()), n + r[0].length) : -1 }, c: function (e, n, r) { return _(e, t, n, r) }, d: nie, e: nie, f: uie, g: Jre, G: Zre, H: iie, I: iie, j: rie, L: sie, m: tie, M: aie, p: function (e, t, n) { var r = l.exec(t.slice(n)); return r ? (e.p = c.get(r[0].toLowerCase()), n + r[0].length) : -1 }, q: eie, Q: cie, s: hie, S: oie, u: qre, U: Yre, V: Xre, w: Hre, W: Kre, x: function (e, t, r) { return _(e, n, t, r) }, X: function (e, t, n) { return _(e, r, t, n) }, y: Jre, Y: Zre, Z: Qre, "%": lie }; function k(e, t) { return function (n) { var r, i, a, o = [], s = -1, u = 0, l = e.length; for (n instanceof Date || (n = new Date(+n)); ++s < l;)37 === e.charCodeAt(s) && (o.push(e.slice(u, s)), null != (i = Pre[r = e.charAt(++s)]) ? r = e.charAt(++s) : i = "e" === r ? " " : "0", (a = t[r]) && (r = a(n, i)), o.push(r), u = s + 1); return o.push(e.slice(u, s)), o.join("") } } function S(e, t) { return function (n) { var r, i, a = Mre(1900, void 0, 1); if (_(a, e, n += "", 0) != n.length) return null; if ("Q" in a) return new Date(a.Q); if ("s" in a) return new Date(1e3 * a.s + ("L" in a ? a.L : 0)); if (t && !("Z" in a) && (a.Z = 0), "p" in a && (a.H = a.H % 12 + 12 * a.p), void 0 === a.m && (a.m = "q" in a ? a.q : 0), "V" in a) { if (a.V < 1 || a.V > 53) return null; "w" in a || (a.w = 1), "Z" in a ? (i = (r = Ire(Mre(a.y, 0, 1))).getUTCDay(), r = i > 4 || 0 === i ? sre.ceil(r) : sre(r), r = pre.offset(r, 7 * (a.V - 1)), a.y = r.getUTCFullYear(), a.m = r.getUTCMonth(), a.d = r.getUTCDate() + (a.w + 6) % 7) : (i = (r = Nre(Mre(a.y, 0, 1))).getDay(), r = i > 4 || 0 === i ? yre.ceil(r) : yre(r), r = _re.offset(r, 7 * (a.V - 1)), a.y = r.getFullYear(), a.m = r.getMonth(), a.d = r.getDate() + (a.w + 6) % 7) } else ("W" in a || "U" in a) && ("w" in a || (a.w = "u" in a ? a.u % 7 : "W" in a ? 1 : 0), i = "Z" in a ? Ire(Mre(a.y, 0, 1)).getUTCDay() : Nre(Mre(a.y, 0, 1)).getDay(), a.m = 0, a.d = "W" in a ? (a.w + 6) % 7 + 7 * a.W - (i + 5) % 7 : a.w + 7 * a.U - (i + 6) % 7); return "Z" in a ? (a.H += a.Z / 100 | 0, a.M += a.Z % 100, Ire(a)) : Nre(a) } } function _(e, t, n, r) { for (var i, a, o = 0, s = t.length, u = n.length; o < s;) { if (r >= u) return -1; if (37 === (i = t.charCodeAt(o++))) { if (i = t.charAt(o++), !(a = w[i in Pre ? t.charAt(o++) : i]) || (r = a(e, n, r)) < 0) return -1 } else if (i != n.charCodeAt(r++)) return -1 } return r } return v.x = k(n, v), v.X = k(r, v), v.c = k(t, v), x.x = k(n, x), x.X = k(r, x), x.c = k(t, x), { format: function (e) { var t = k(e += "", v); return t.toString = function () { return e }, t }, parse: function (e) { var t = S(e += "", !1); return t.toString = function () { return e }, t }, utcFormat: function (e) { var t = k(e += "", x); return t.toString = function () { return e }, t }, utcParse: function (e) { var t = S(e += "", !0); return t.toString = function () { return e }, t } } } var Dre, $re, Rre, Ore, zre, Pre = { "-": "", _: " ", 0: "0" }, Bre = /^\s*\d+/, Lre = /^%/, jre = /[\\^$*+?|[\]().{}]/g; function Ure(e, t, n) { var r = e < 0 ? "-" : "", i = (r ? -e : e) + "", a = i.length; return r + (a < n ? new Array(n - a + 1).join(t) + i : i) } function Wre(e) { return e.replace(jre, "\\$&") } function Vre(e) { return new RegExp("^(?:" + e.map(Wre).join("|") + ")", "i") } function Gre(e) { return new Map(e.map(((e, t) => [e.toLowerCase(), t]))) } function Hre(e, t, n) { var r = Bre.exec(t.slice(n, n + 1)); return r ? (e.w = +r[0], n + r[0].length) : -1 } function qre(e, t, n) { var r = Bre.exec(t.slice(n, n + 1)); return r ? (e.u = +r[0], n + r[0].length) : -1 } function Yre(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.U = +r[0], n + r[0].length) : -1 } function Xre(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.V = +r[0], n + r[0].length) : -1 } function Kre(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.W = +r[0], n + r[0].length) : -1 } function Zre(e, t, n) { var r = Bre.exec(t.slice(n, n + 4)); return r ? (e.y = +r[0], n + r[0].length) : -1 } function Jre(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1 } function Qre(e, t, n) { var r = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6)); return r ? (e.Z = r[1] ? 0 : -(r[2] + (r[3] || "00")), n + r[0].length) : -1 } function eie(e, t, n) { var r = Bre.exec(t.slice(n, n + 1)); return r ? (e.q = 3 * r[0] - 3, n + r[0].length) : -1 } function tie(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.m = r[0] - 1, n + r[0].length) : -1 } function nie(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.d = +r[0], n + r[0].length) : -1 } function rie(e, t, n) { var r = Bre.exec(t.slice(n, n + 3)); return r ? (e.m = 0, e.d = +r[0], n + r[0].length) : -1 } function iie(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.H = +r[0], n + r[0].length) : -1 } function aie(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.M = +r[0], n + r[0].length) : -1 } function oie(e, t, n) { var r = Bre.exec(t.slice(n, n + 2)); return r ? (e.S = +r[0], n + r[0].length) : -1 } function sie(e, t, n) { var r = Bre.exec(t.slice(n, n + 3)); return r ? (e.L = +r[0], n + r[0].length) : -1 } function uie(e, t, n) { var r = Bre.exec(t.slice(n, n + 6)); return r ? (e.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1 } function lie(e, t, n) { var r = Lre.exec(t.slice(n, n + 1)); return r ? n + r[0].length : -1 } function cie(e, t, n) { var r = Bre.exec(t.slice(n)); return r ? (e.Q = +r[0], n + r[0].length) : -1 } function hie(e, t, n) { var r = Bre.exec(t.slice(n)); return r ? (e.s = +r[0], n + r[0].length) : -1 } function die(e, t) { return Ure(e.getDate(), t, 2) } function fie(e, t) { return Ure(e.getHours(), t, 2) } function pie(e, t) { return Ure(e.getHours() % 12 || 12, t, 2) } function mie(e, t) { return Ure(1 + _re.count(Are(e), e), t, 3) } function gie(e, t) { return Ure(e.getMilliseconds(), t, 3) } function yie(e, t) { return gie(e, t) + "000" } function bie(e, t) { return Ure(e.getMonth() + 1, t, 2) } function vie(e, t) { return Ure(e.getMinutes(), t, 2) } function xie(e, t) { return Ure(e.getSeconds(), t, 2) } function wie(e) { var t = e.getDay(); return 0 === t ? 7 : t } function kie(e, t) { return Ure(gre.count(Are(e) - 1, e), t, 2) } function Sie(e) { var t = e.getDay(); return t >= 4 || 0 === t ? xre(e) : xre.ceil(e) } function _ie(e, t) { return e = Sie(e), Ure(xre.count(Are(e), e) + (4 === Are(e).getDay()), t, 2) } function Cie(e) { return e.getDay() } function Aie(e, t) { return Ure(yre.count(Are(e) - 1, e), t, 2) } function Tie(e, t) { return Ure(e.getFullYear() % 100, t, 2) } function Eie(e, t) { return Ure((e = Sie(e)).getFullYear() % 100, t, 2) } function Nie(e, t) { return Ure(e.getFullYear() % 1e4, t, 4) } function Iie(e, t) { var n = e.getDay(); return Ure((e = n >= 4 || 0 === n ? xre(e) : xre.ceil(e)).getFullYear() % 1e4, t, 4) } function Mie(e) { var t = e.getTimezoneOffset(); return (t > 0 ? "-" : (t *= -1, "+")) + Ure(t / 60 | 0, "0", 2) + Ure(t % 60, "0", 2) } function Fie(e, t) { return Ure(e.getUTCDate(), t, 2) } function Die(e, t) { return Ure(e.getUTCHours(), t, 2) } function $ie(e, t) { return Ure(e.getUTCHours() % 12 || 12, t, 2) } function Rie(e, t) { return Ure(1 + pre.count(Ere(e), e), t, 3) } function Oie(e, t) { return Ure(e.getUTCMilliseconds(), t, 3) } function zie(e, t) { return Oie(e, t) + "000" } function Pie(e, t) { return Ure(e.getUTCMonth() + 1, t, 2) } function Bie(e, t) { return Ure(e.getUTCMinutes(), t, 2) } function Lie(e, t) { return Ure(e.getUTCSeconds(), t, 2) } function jie(e) { var t = e.getUTCDay(); return 0 === t ? 7 : t } function Uie(e, t) { return Ure(ore.count(Ere(e) - 1, e), t, 2) } function Wie(e) { var t = e.getUTCDay(); return t >= 4 || 0 === t ? cre(e) : cre.ceil(e) } function Vie(e, t) { return e = Wie(e), Ure(cre.count(Ere(e), e) + (4 === Ere(e).getUTCDay()), t, 2) } function Gie(e) { return e.getUTCDay() } function Hie(e, t) { return Ure(sre.count(Ere(e) - 1, e), t, 2) } function qie(e, t) { return Ure(e.getUTCFullYear() % 100, t, 2) } function Yie(e, t) { return Ure((e = Wie(e)).getUTCFullYear() % 100, t, 2) } function Xie(e, t) { return Ure(e.getUTCFullYear() % 1e4, t, 4) } function Kie(e, t) { var n = e.getUTCDay(); return Ure((e = n >= 4 || 0 === n ? cre(e) : cre.ceil(e)).getUTCFullYear() % 1e4, t, 4) } function Zie() { return "+0000" } function Jie() { return "%" } function Qie(e) { return +e } function eae(e) { return Math.floor(+e / 1e3) } function tae(e) { const t = {}; return n => t[n] || (t[n] = e(n)) } function nae(e) { const t = tae(e.format), n = e.formatPrefix; return { format: t, formatPrefix: n, formatFloat(e) { const n = hne(e || ","); if (null == n.precision) { switch (n.precision = 12, n.type) { case "%": n.precision -= 2; break; case "e": n.precision -= 1 }return function (e, t) { return n => { const r = e(n), i = r.indexOf(t); if (i < 0) return r; let a = function (e, t) { let n, r = e.lastIndexOf("e"); if (r > 0) return r; for (r = e.length; --r > t;)if (n = e.charCodeAt(r), n >= 48 && n <= 57) return r + 1 }(r, i); const o = a < r.length ? r.slice(a) : ""; for (; --a > i;)if ("0" !== r[a]) { ++a; break } return r.slice(0, a) + o } }(t(n), t(".1f")(1)[1]) } return t(n) }, formatSpan(e, r, i, a) { a = hne(null == a ? ",f" : a); const o = _A(e, r, i), s = Math.max(Math.abs(e), Math.abs(r)); let u; if (null == a.precision) switch (a.type) { case "s": return isNaN(u = function (e, t) { return Math.max(0, 3 * Math.max(-8, Math.min(8, Math.floor(pne(t) / 3))) - pne(Math.abs(e))) }(o, s)) || (a.precision = u), n(a, s); case "": case "e": case "g": case "p": case "r": isNaN(u = function (e, t) { return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, pne(t) - pne(e)) + 1 }(o, s)) || (a.precision = u - ("e" === a.type)); break; case "f": case "%": isNaN(u = function (e) { return Math.max(0, -pne(Math.abs(e))) }(o)) || (a.precision = u - 2 * ("%" === a.type)) }return t(a) } } } let rae, iae; function aae() { return rae = nae({ format: vne, formatPrefix: xne }) } function oae(e) { return nae(Sne(e)) } function sae(e) { return arguments.length ? rae = oae(e) : rae } function uae(e, t, n) { Mne(n = n || {}) || Ene("Invalid time multi-format specifier: ".concat(n)); const r = t(Wne), i = t(Une), a = t(jne), o = t(Pne), s = t(zne), u = t(One), l = t(Rne), c = t($ne), h = e(n[Vne] || ".%L"), d = e(n[Wne] || ":%S"), f = e(n[Une] || "%I:%M"), p = e(n[jne] || "%I %p"), m = e(n[Pne] || n[Bne] || "%a %d"), g = e(n[zne] || "%b %d"), y = e(n[One] || "%B"), b = e(n[Rne] || "%B"), v = e(n[$ne] || "%Y"); return e => (r(e) < e ? h : i(e) < e ? d : a(e) < e ? f : o(e) < e ? p : u(e) < e ? s(e) < e ? m : g : c(e) < e ? l(e) < e ? y : b : v)(e) } function lae(e) { const t = tae(e.format), n = tae(e.utcFormat); return { timeFormat: e => Dne(e) ? t(e) : uae(t, qne, e), utcFormat: e => Dne(e) ? n(e) : uae(n, Yne, e), timeParse: tae(e.parse), utcParse: tae(e.utcParse) } } function cae() { return iae = lae({ format: $re, parse: Rre, utcFormat: Ore, utcParse: zre }) } function hae(e) { return lae(Fre(e)) } function dae(e) { return arguments.length ? iae = hae(e) : iae } !function (e) { Dre = Fre(e), $re = Dre.format, Rre = Dre.parse, Ore = Dre.utcFormat, zre = Dre.utcParse }({ dateTime: "%x, %X", date: "%-m/%-d/%Y", time: "%-I:%M:%S %p", periods: ["AM", "PM"], days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }), aae(), cae(); const fae = (e, t) => Fne({}, e, t); function pae(e, t) { const n = e ? oae(e) : sae(), r = t ? hae(t) : dae(); return fae(n, r) } function mae(e, t) { const n = arguments.length; return n && 2 !== n && Ene("defaultLocale expects either zero or two arguments."), n ? fae(sae(e), dae(t)) : fae(sae(), dae()) } function gae() { return aae(), cae(), mae() } function yae(e, t, n) { return e.fields = t || [], e.fname = n, e } function bae(e) { return 1 === e.length ? vae(e[0]) : xae(e) } const vae = e => function (t) { return t[e] }, xae = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function wae(e) { throw Error(e) } function kae(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || wae("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && wae("Access path missing closing bracket: " + e), o && wae("Access path missing closing quote: " + e), i > r && (i++, l()), t } function Sae(e, t, n) { const r = kae(e); return e = 1 === r.length ? r[0] : e, yae((n && n.get || bae)(r), [e], t || e) } Sae("id"); const _ae = yae((e => e), [], "identity"), Cae = (yae((() => 0), [], "zero"), yae((() => 1), [], "one"), yae((() => !0), [], "true")); yae((() => !1), [], "false"); var Aae = Array.isArray; function Tae(e) { return e === Object(e) } function Eae(e) { return e[e.length - 1] } function Nae(e) { return null == e || "" === e ? null : +e } const Iae = e => t => e * Math.exp(t), Mae = e => t => Math.log(e * t), Fae = e => t => Math.sign(t) * Math.log1p(Math.abs(t / e)), Dae = e => t => Math.sign(t) * Math.expm1(Math.abs(t)) * e, $ae = e => t => t < 0 ? -Math.pow(-t, e) : Math.pow(t, e); function Rae(e, t, n, r) { const i = n(e[0]), a = n(Eae(e)), o = (a - i) * t; return [r(i - o), r(a - o)] } function Oae(e, t, n, r, i) { const a = r(e[0]), o = r(Eae(e)), s = null != t ? r(t) : (a + o) / 2; return [i(s + (a - s) * n), i(s + (o - s) * n)] } function zae(e) { return null != e ? Aae(e) ? e : [e] : [] } function Pae(e) { return "function" == typeof e } function Bae(e) { for (let t, n, r = 1, i = arguments.length; r < i; ++r)for (n in t = arguments[r], t) e[n] = t[n]; return e } const Lae = Object.prototype.hasOwnProperty; function jae(e, t) { return Lae.call(e, t) } function Uae(e) { return "[object Date]" === Object.prototype.toString.call(e) } function Wae(e) { return "number" == typeof e } function Vae(e) { return "string" == typeof e } function Gae(e, t) { let n = ""; for (; --t >= 0;)n += e; return n } function Hae(e) { return Aae(e) ? "[" + e.map(Hae) + "]" : Tae(e) || Vae(e) ? JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029") : e } function qae(e) { return null == e || "" === e ? null : !(!e || "false" === e || "0" === e) && !!e } const Yae = e => Wae(e) || Uae(e) ? e : Date.parse(e); function Xae(e, t) { return t = t || Yae, null == e || "" === e ? null : t(e) } function Kae(e) { return null == e || "" === e ? null : e + "" } function Zae(e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t } const Jae = "Literal", Qae = "Property", eoe = "ArrayExpression", toe = "BinaryExpression", noe = "CallExpression", roe = "ConditionalExpression", ioe = "LogicalExpression", aoe = "MemberExpression", ooe = "ObjectExpression", soe = "UnaryExpression"; function uoe(e) { this.type = e } var loe; uoe.prototype.visit = function (e) { let t, n, r; if (e(this)) return 1; for (t = function (e) { switch (e.type) { case eoe: return e.elements; case toe: case ioe: return [e.left, e.right]; case noe: return [e.callee].concat(e.arguments); case roe: return [e.test, e.consequent, e.alternate]; case aoe: return [e.object, e.property]; case ooe: return e.properties; case Qae: return [e.key, e.value]; case soe: return [e.argument]; default: return [] } }(this), n = 0, r = t.length; n < r; ++n)if (t[n].visit(e)) return 1 }; (loe = {})[1] = "Boolean", loe[2] = "", loe[3] = "Identifier", loe[4] = "Keyword", loe[5] = "Null", loe[6] = "Numeric", loe[7] = "Punctuator", loe[8] = "String", loe[9] = "RegularExpression"; var coe = { NaN: "NaN", E: "Math.E", LN2: "Math.LN2", LN10: "Math.LN10", LOG2E: "Math.LOG2E", LOG10E: "Math.LOG10E", PI: "Math.PI", SQRT1_2: "Math.SQRT1_2", SQRT2: "Math.SQRT2", MIN_VALUE: "Number.MIN_VALUE", MAX_VALUE: "Number.MAX_VALUE" }; function hoe(e) { function t(t, n, r) { return i => function (t, n, r, i) { let a = e(n[0]); return r && (a = r + "(" + a + ")", 0 === r.lastIndexOf("new ", 0) && (a = "(" + a + ")")), a + "." + t + (i < 0 ? "" : 0 === i ? "()" : "(" + n.slice(1).map(e).join(",") + ")") }(t, i, n, r) } const n = "new Date", r = "String", i = "RegExp"; return { isNaN: "Number.isNaN", isFinite: "Number.isFinite", abs: "Math.abs", acos: "Math.acos", asin: "Math.asin", atan: "Math.atan", atan2: "Math.atan2", ceil: "Math.ceil", cos: "Math.cos", exp: "Math.exp", floor: "Math.floor", hypot: "Math.hypot", log: "Math.log", max: "Math.max", min: "Math.min", pow: "Math.pow", random: "Math.random", round: "Math.round", sin: "Math.sin", sqrt: "Math.sqrt", tan: "Math.tan", clamp: function (t) { t.length < 3 && wae("Missing arguments to clamp function."), t.length > 3 && wae("Too many arguments to clamp function."); const n = t.map(e); return "Math.max(" + n[1] + ", Math.min(" + n[2] + "," + n[0] + "))" }, now: "Date.now", utc: "Date.UTC", datetime: n, date: t("getDate", n, 0), day: t("getDay", n, 0), year: t("getFullYear", n, 0), month: t("getMonth", n, 0), hours: t("getHours", n, 0), minutes: t("getMinutes", n, 0), seconds: t("getSeconds", n, 0), milliseconds: t("getMilliseconds", n, 0), time: t("getTime", n, 0), timezoneoffset: t("getTimezoneOffset", n, 0), utcdate: t("getUTCDate", n, 0), utcday: t("getUTCDay", n, 0), utcyear: t("getUTCFullYear", n, 0), utcmonth: t("getUTCMonth", n, 0), utchours: t("getUTCHours", n, 0), utcminutes: t("getUTCMinutes", n, 0), utcseconds: t("getUTCSeconds", n, 0), utcmilliseconds: t("getUTCMilliseconds", n, 0), length: t("length", null, -1), parseFloat: "parseFloat", parseInt: "parseInt", upper: t("toUpperCase", r, 0), lower: t("toLowerCase", r, 0), substring: t("substring", r), split: t("split", r), trim: t("trim", r, 0), regexp: i, test: t("test", i), if: function (t) { t.length < 3 && wae("Missing arguments to if function."), t.length > 3 && wae("Too many arguments to if function."); const n = t.map(e); return "(" + n[0] + "?" + n[1] + ":" + n[2] + ")" } } } var doe, foe, poe, moe, goe, yoe, boe, voe, xoe, woe, koe, Soe, _oe, Coe, Aoe, Toe, Eoe = new Z2, Noe = new Z2, Ioe = { point: J2, lineStart: J2, lineEnd: J2, polygonStart: function () { Eoe = new Z2, Ioe.lineStart = Moe, Ioe.lineEnd = Foe }, polygonEnd: function () { var e = +Eoe; Noe.add(e < 0 ? JI + e : e), this.lineStart = this.lineEnd = this.point = J2 }, sphere: function () { Noe.add(JI) } }; function Moe() { Ioe.point = Doe } function Foe() { $oe(doe, foe) } function Doe(e, t) { Ioe.point = $oe, doe = e, foe = t, poe = e *= eM, moe = iM(t = (t *= eM) / 2 + ZI), goe = cM(t) } function $oe(e, t) { var n = (e *= eM) - poe, r = n >= 0 ? 1 : -1, i = r * n, a = iM(t = (t *= eM) / 2 + ZI), o = cM(t), s = goe * o, u = moe * a + s * iM(i), l = s * r * cM(i); Eoe.add(rM(l, u)), poe = e, moe = a, goe = o } var Roe, Ooe, zoe, Poe, Boe, Loe, joe, Uoe, Woe, Voe, Goe, Hoe, qoe, Yoe, Xoe, Koe, Zoe = { point: Joe, lineStart: ese, lineEnd: tse, polygonStart: function () { Zoe.point = nse, Zoe.lineStart = rse, Zoe.lineEnd = ise, Coe = new Z2, Ioe.polygonStart() }, polygonEnd: function () { Ioe.polygonEnd(), Zoe.point = Joe, Zoe.lineStart = ese, Zoe.lineEnd = tse, Eoe < 0 ? (yoe = -(voe = 180), boe = -(xoe = 90)) : Coe > qI ? xoe = 90 : Coe < -qI && (boe = -90), Toe[0] = yoe, Toe[1] = voe }, sphere: function () { yoe = -(voe = 180), boe = -(xoe = 90) } }; function Joe(e, t) { Aoe.push(Toe = [yoe = e, voe = e]), t < boe && (boe = t), t > xoe && (xoe = t) } function Qoe(e, t) { var n = s4([e * eM, t * eM]); if (_oe) { var r = l4(_oe, n), i = l4([r[1], -r[0], 0], r); d4(i), i = o4(i); var a, o = e - woe, s = o > 0 ? 1 : -1, u = i[0] * QI * s, l = tM(o) > 180; l ^ (s * woe < u && u < s * e) ? (a = i[1] * QI) > xoe && (xoe = a) : l ^ (s * woe < (u = (u + 360) % 360 - 180) && u < s * e) ? (a = -i[1] * QI) < boe && (boe = a) : (t < boe && (boe = t), t > xoe && (xoe = t)), l ? e < woe ? ase(yoe, e) > ase(yoe, voe) && (voe = e) : ase(e, voe) > ase(yoe, voe) && (yoe = e) : voe >= yoe ? (e < yoe && (yoe = e), e > voe && (voe = e)) : e > woe ? ase(yoe, e) > ase(yoe, voe) && (voe = e) : ase(e, voe) > ase(yoe, voe) && (yoe = e) } else Aoe.push(Toe = [yoe = e, voe = e]); t < boe && (boe = t), t > xoe && (xoe = t), _oe = n, woe = e } function ese() { Zoe.point = Qoe } function tse() { Toe[0] = yoe, Toe[1] = voe, Zoe.point = Joe, _oe = null } function nse(e, t) { if (_oe) { var n = e - woe; Coe.add(tM(n) > 180 ? n + (n > 0 ? 360 : -360) : n) } else koe = e, Soe = t; Ioe.point(e, t), Qoe(e, t) } function rse() { Ioe.lineStart() } function ise() { nse(koe, Soe), Ioe.lineEnd(), tM(Coe) > qI && (yoe = -(voe = 180)), Toe[0] = yoe, Toe[1] = voe, _oe = null } function ase(e, t) { return (t -= e) < 0 ? t + 360 : t } function ose(e, t) { return e[0] - t[0] } function sse(e, t) { return e[0] <= e[1] ? e[0] <= t && t <= e[1] : t < e[0] || e[1] < t } var use = { sphere: J2, point: lse, lineStart: hse, lineEnd: pse, polygonStart: function () { use.lineStart = mse, use.lineEnd = gse }, polygonEnd: function () { use.lineStart = hse, use.lineEnd = pse } }; function lse(e, t) { e *= eM; var n = iM(t *= eM); cse(n * iM(e), n * cM(e), cM(t)) } function cse(e, t, n) { ++Roe, zoe += (e - zoe) / Roe, Poe += (t - Poe) / Roe, Boe += (n - Boe) / Roe } function hse() { use.point = dse } function dse(e, t) { e *= eM; var n = iM(t *= eM); Yoe = n * iM(e), Xoe = n * cM(e), Koe = cM(t), use.point = fse, cse(Yoe, Xoe, Koe) } function fse(e, t) { e *= eM; var n = iM(t *= eM), r = n * iM(e), i = n * cM(e), a = cM(t), o = rM(dM((o = Xoe * a - Koe * i) * o + (o = Koe * r - Yoe * a) * o + (o = Yoe * i - Xoe * r) * o), Yoe * r + Xoe * i + Koe * a); Ooe += o, Loe += o * (Yoe + (Yoe = r)), joe += o * (Xoe + (Xoe = i)), Uoe += o * (Koe + (Koe = a)), cse(Yoe, Xoe, Koe) } function pse() { use.point = lse } function mse() { use.point = yse } function gse() { bse(Hoe, qoe), use.point = lse } function yse(e, t) { Hoe = e, qoe = t, e *= eM, t *= eM, use.point = bse; var n = iM(t); Yoe = n * iM(e), Xoe = n * cM(e), Koe = cM(t), cse(Yoe, Xoe, Koe) } function bse(e, t) { e *= eM; var n = iM(t *= eM), r = n * iM(e), i = n * cM(e), a = cM(t), o = Xoe * a - Koe * i, s = Koe * r - Yoe * a, u = Yoe * i - Xoe * r, l = sM(o, s, u), c = mM(l), h = l && -c / l; Woe.add(h * o), Voe.add(h * s), Goe.add(h * u), Ooe += c, Loe += c * (Yoe + (Yoe = r)), joe += c * (Xoe + (Xoe = i)), Uoe += c * (Koe + (Koe = a)), cse(Yoe, Xoe, Koe) } function vse(e, t) { return null == e || null == t ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN } function xse(e, t) { return null == e || null == t ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN } function wse(e) { let t, n, r; function i(e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) < 0 ? i = t + 1 : a = t } while (i < a) } return i } return 2 !== e.length ? (t = vse, n = (t, n) => vse(e(t), n), r = (t, n) => e(t) - n) : (t = e === vse || e === xse ? e : kse, n = e, r = e), { left: i, center: function (e, t, n = 0, a = e.length) { const o = i(e, t, n, a - 1); return o > n && r(e[o - 1], t) > -r(e[o], t) ? o - 1 : o }, right: function (e, r, i = 0, a = e.length) { if (i < a) { if (0 !== t(r, r)) return a; do { const t = i + a >>> 1; n(e[t], r) <= 0 ? i = t + 1 : a = t } while (i < a) } return i } } } function kse() { return 0 } const Sse = wse(vse), _se = Sse.right, Cse = (Sse.left, wse((function (e) { return null === e ? NaN : +e })).center, _se); function Ase(e, t, n) { e.prototype = t.prototype = n, n.constructor = e } function Tse(e, t) { var n = Object.create(e.prototype); for (var r in t) n[r] = t[r]; return n } function Ese() { } var Nse = .7, Ise = 1.4285714285714286, Mse = "\\s*([+-]?\\d+)\\s*", Fse = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Dse = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", $se = /^#([0-9a-f]{3,8})$/, Rse = new RegExp(`^rgb\\(${Mse},${Mse},${Mse}\\)$`), Ose = new RegExp(`^rgb\\(${Dse},${Dse},${Dse}\\)$`), zse = new RegExp(`^rgba\\(${Mse},${Mse},${Mse},${Fse}\\)$`), Pse = new RegExp(`^rgba\\(${Dse},${Dse},${Dse},${Fse}\\)$`), Bse = new RegExp(`^hsl\\(${Fse},${Dse},${Dse}\\)$`), Lse = new RegExp(`^hsla\\(${Fse},${Dse},${Dse},${Fse}\\)$`), jse = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; function Use() { return this.rgb().formatHex() } function Wse() { return this.rgb().formatRgb() } function Vse(e) { var t, n; return e = (e + "").trim().toLowerCase(), (t = $se.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), 6 === n ? Gse(t) : 3 === n ? new Xse(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, (15 & t) << 4 | 15 & t, 1) : 8 === n ? Hse(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (255 & t) / 255) : 4 === n ? Hse(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | 240 & t, ((15 & t) << 4 | 15 & t) / 255) : null) : (t = Rse.exec(e)) ? new Xse(t[1], t[2], t[3], 1) : (t = Ose.exec(e)) ? new Xse(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, 1) : (t = zse.exec(e)) ? Hse(t[1], t[2], t[3], t[4]) : (t = Pse.exec(e)) ? Hse(255 * t[1] / 100, 255 * t[2] / 100, 255 * t[3] / 100, t[4]) : (t = Bse.exec(e)) ? tue(t[1], t[2] / 100, t[3] / 100, 1) : (t = Lse.exec(e)) ? tue(t[1], t[2] / 100, t[3] / 100, t[4]) : jse.hasOwnProperty(e) ? Gse(jse[e]) : "transparent" === e ? new Xse(NaN, NaN, NaN, 0) : null } function Gse(e) { return new Xse(e >> 16 & 255, e >> 8 & 255, 255 & e, 1) } function Hse(e, t, n, r) { return r <= 0 && (e = t = n = NaN), new Xse(e, t, n, r) } function qse(e) { return e instanceof Ese || (e = Vse(e)), e ? new Xse((e = e.rgb()).r, e.g, e.b, e.opacity) : new Xse } function Yse(e, t, n, r) { return 1 === arguments.length ? qse(e) : new Xse(e, t, n, null == r ? 1 : r) } function Xse(e, t, n, r) { this.r = +e, this.g = +t, this.b = +n, this.opacity = +r } function Kse() { return `#${eue(this.r)}${eue(this.g)}${eue(this.b)}` } function Zse() { const e = Jse(this.opacity); return `${1 === e ? "rgb(" : "rgba("}${Qse(this.r)}, ${Qse(this.g)}, ${Qse(this.b)}${1 === e ? ")" : `, ${e})`}` } function Jse(e) { return isNaN(e) ? 1 : Math.max(0, Math.min(1, e)) } function Qse(e) { return Math.max(0, Math.min(255, Math.round(e) || 0)) } function eue(e) { return ((e = Qse(e)) < 16 ? "0" : "") + e.toString(16) } function tue(e, t, n, r) { return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new iue(e, t, n, r) } function nue(e) { if (e instanceof iue) return new iue(e.h, e.s, e.l, e.opacity); if (e instanceof Ese || (e = Vse(e)), !e) return new iue; if (e instanceof iue) return e; var t = (e = e.rgb()).r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, u = (a + i) / 2; return s ? (o = t === a ? (n - r) / s + 6 * (n < r) : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= u < .5 ? a + i : 2 - a - i, o *= 60) : s = u > 0 && u < 1 ? 0 : o, new iue(o, s, u, e.opacity) } function rue(e, t, n, r) { return 1 === arguments.length ? nue(e) : new iue(e, t, n, null == r ? 1 : r) } function iue(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function aue(e) { return (e = (e || 0) % 360) < 0 ? e + 360 : e } function oue(e) { return Math.max(0, Math.min(1, e || 0)) } function sue(e, t, n) { return 255 * (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) } function uue(e, t, n, r, i) { var a = e * e, o = a * e; return ((1 - 3 * e + 3 * a - o) * t + (4 - 6 * a + 3 * o) * n + (1 + 3 * e + 3 * a - 3 * o) * r + o * i) / 6 } function lue(e) { var t = e.length - 1; return function (n) { var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], a = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - a, s = r < t - 1 ? e[r + 2] : 2 * a - i; return uue((n - r / t) * t, o, i, a, s) } } function cue(e) { var t = e.length; return function (n) { var r = Math.floor(((n %= 1) < 0 ? ++n : n) * t), i = e[(r + t - 1) % t], a = e[r % t], o = e[(r + 1) % t], s = e[(r + 2) % t]; return uue((n - r / t) * t, i, a, o, s) } } Ase(Ese, Vse, { copy(e) { return Object.assign(new this.constructor, this, e) }, displayable() { return this.rgb().displayable() }, hex: Use, formatHex: Use, formatHex8: function () { return this.rgb().formatHex8() }, formatHsl: function () { return nue(this).formatHsl() }, formatRgb: Wse, toString: Wse }), Ase(Xse, Yse, Tse(Ese, { brighter(e) { return e = null == e ? Ise : Math.pow(Ise, e), new Xse(this.r * e, this.g * e, this.b * e, this.opacity) }, darker(e) { return e = null == e ? Nse : Math.pow(Nse, e), new Xse(this.r * e, this.g * e, this.b * e, this.opacity) }, rgb() { return this }, clamp() { return new Xse(Qse(this.r), Qse(this.g), Qse(this.b), Jse(this.opacity)) }, displayable() { return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1 }, hex: Kse, formatHex: Kse, formatHex8: function () { return `#${eue(this.r)}${eue(this.g)}${eue(this.b)}${eue(255 * (isNaN(this.opacity) ? 1 : this.opacity))}` }, formatRgb: Zse, toString: Zse })), Ase(iue, rue, Tse(Ese, { brighter(e) { return e = null == e ? Ise : Math.pow(Ise, e), new iue(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? Nse : Math.pow(Nse, e), new iue(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = this.h % 360 + 360 * (this.h < 0), t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r; return new Xse(sue(e >= 240 ? e - 240 : e + 120, i, r), sue(e, i, r), sue(e < 120 ? e + 240 : e - 120, i, r), this.opacity) }, clamp() { return new iue(aue(this.h), oue(this.s), oue(this.l), Jse(this.opacity)) }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1 }, formatHsl() { const e = Jse(this.opacity); return `${1 === e ? "hsl(" : "hsla("}${aue(this.h)}, ${100 * oue(this.s)}%, ${100 * oue(this.l)}%${1 === e ? ")" : `, ${e})`}` } })); const hue = e => () => e; function due(e, t) { return function (n) { return e + n * t } } function fue(e, t) { var n = t - e; return n ? due(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : hue(isNaN(e) ? t : e) } function pue(e) { return 1 == (e = +e) ? mue : function (t, n) { return n - t ? function (e, t, n) { return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function (r) { return Math.pow(e + r * t, n) } }(t, n, e) : hue(isNaN(t) ? n : t) } } function mue(e, t) { var n = t - e; return n ? due(e, n) : hue(isNaN(e) ? t : e) } const gue = function e(t) { var n = pue(t); function r(e, t) { var r = n((e = Yse(e)).r, (t = Yse(t)).r), i = n(e.g, t.g), a = n(e.b, t.b), o = mue(e.opacity, t.opacity); return function (t) { return e.r = r(t), e.g = i(t), e.b = a(t), e.opacity = o(t), e + "" } } return r.gamma = e, r }(1); function yue(e) { return function (t) { var n, r, i = t.length, a = new Array(i), o = new Array(i), s = new Array(i); for (n = 0; n < i; ++n)r = Yse(t[n]), a[n] = r.r || 0, o[n] = r.g || 0, s[n] = r.b || 0; return a = e(a), o = e(o), s = e(s), r.opacity = 1, function (e) { return r.r = a(e), r.g = o(e), r.b = s(e), r + "" } } } var bue = yue(lue), vue = yue(cue); function xue(e, t) { t || (t = []); var n, r = e ? Math.min(t.length, e.length) : 0, i = t.slice(); return function (a) { for (n = 0; n < r; ++n)i[n] = e[n] * (1 - a) + t[n] * a; return i } } function wue(e) { return ArrayBuffer.isView(e) && !(e instanceof DataView) } function kue(e, t) { return (wue(t) ? xue : Sue)(e, t) } function Sue(e, t) { var n, r = t ? t.length : 0, i = e ? Math.min(r, e.length) : 0, a = new Array(i), o = new Array(r); for (n = 0; n < i; ++n)a[n] = Iue(e[n], t[n]); for (; n < r; ++n)o[n] = t[n]; return function (e) { for (n = 0; n < i; ++n)o[n] = a[n](e); return o } } function _ue(e, t) { var n = new Date; return e = +e, t = +t, function (r) { return n.setTime(e * (1 - r) + t * r), n } } function Cue(e, t) { return e = +e, t = +t, function (n) { return e * (1 - n) + t * n } } function Aue(e, t) { var n, r = {}, i = {}; for (n in null !== e && "object" == typeof e || (e = {}), null !== t && "object" == typeof t || (t = {}), t) n in e ? r[n] = Iue(e[n], t[n]) : i[n] = t[n]; return function (e) { for (n in r) i[n] = r[n](e); return i } } var Tue = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Eue = new RegExp(Tue.source, "g"); function Nue(e, t) { var n, r, i, a = Tue.lastIndex = Eue.lastIndex = 0, o = -1, s = [], u = []; for (e += "", t += ""; (n = Tue.exec(e)) && (r = Eue.exec(t));)(i = r.index) > a && (i = t.slice(a, i), s[o] ? s[o] += i : s[++o] = i), (n = n[0]) === (r = r[0]) ? s[o] ? s[o] += r : s[++o] = r : (s[++o] = null, u.push({ i: o, x: Cue(n, r) })), a = Eue.lastIndex; return a < t.length && (i = t.slice(a), s[o] ? s[o] += i : s[++o] = i), s.length < 2 ? u[0] ? function (e) { return function (t) { return e(t) + "" } }(u[0].x) : function (e) { return function () { return e } }(t) : (t = u.length, function (e) { for (var n, r = 0; r < t; ++r)s[(n = u[r]).i] = n.x(e); return s.join("") }) } function Iue(e, t) { var n, r = typeof t; return null == t || "boolean" === r ? hue(t) : ("number" === r ? Cue : "string" === r ? (n = Vse(t)) ? (t = n, gue) : Nue : t instanceof Vse ? gue : t instanceof Date ? _ue : wue(t) ? xue : Array.isArray(t) ? Sue : "function" != typeof t.valueOf && "function" != typeof t.toString || isNaN(t) ? Aue : Cue)(e, t) } function Mue(e, t) { void 0 === t && (t = e, e = Iue); for (var n = 0, r = t.length - 1, i = t[0], a = new Array(r < 0 ? 0 : r); n < r;)a[n] = e(i, i = t[++n]); return function (e) { var t = Math.max(0, Math.min(r - 1, Math.floor(e *= r))); return a[t](e - t) } } function Fue(e) { var t = e.length; return function (n) { return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))] } } function Due(e, t) { var n = fue(+e, +t); return function (e) { var t = n(e); return t - 360 * Math.floor(t / 360) } } function $ue(e, t) { return e = +e, t = +t, function (n) { return Math.round(e * (1 - n) + t * n) } } var Rue, Oue = 180 / Math.PI, zue = { translateX: 0, translateY: 0, rotate: 0, skewX: 0, scaleX: 1, scaleY: 1 }; function Pue(e, t, n, r, i, a) { var o, s, u; return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (u = e * n + t * r) && (n -= e * u, r -= t * u), (s = Math.sqrt(n * n + r * r)) && (n /= s, r /= s, u /= s), e * r < t * n && (e = -e, t = -t, u = -u, o = -o), { translateX: i, translateY: a, rotate: Math.atan2(t, e) * Oue, skewX: Math.atan(u) * Oue, scaleX: o, scaleY: s } } function Bue(e, t, n, r) { function i(e) { return e.length ? e.pop() + " " : "" } return function (a, o) { var s = [], u = []; return a = e(a), o = e(o), function (e, r, i, a, o, s) { if (e !== i || r !== a) { var u = o.push("translate(", null, t, null, n); s.push({ i: u - 4, x: Cue(e, i) }, { i: u - 2, x: Cue(r, a) }) } else (i || a) && o.push("translate(" + i + t + a + n) }(a.translateX, a.translateY, o.translateX, o.translateY, s, u), function (e, t, n, a) { e !== t ? (e - t > 180 ? t += 360 : t - e > 180 && (e += 360), a.push({ i: n.push(i(n) + "rotate(", null, r) - 2, x: Cue(e, t) })) : t && n.push(i(n) + "rotate(" + t + r) }(a.rotate, o.rotate, s, u), function (e, t, n, a) { e !== t ? a.push({ i: n.push(i(n) + "skewX(", null, r) - 2, x: Cue(e, t) }) : t && n.push(i(n) + "skewX(" + t + r) }(a.skewX, o.skewX, s, u), function (e, t, n, r, a, o) { if (e !== n || t !== r) { var s = a.push(i(a) + "scale(", null, ",", null, ")"); o.push({ i: s - 4, x: Cue(e, n) }, { i: s - 2, x: Cue(t, r) }) } else 1 === n && 1 === r || a.push(i(a) + "scale(" + n + "," + r + ")") }(a.scaleX, a.scaleY, o.scaleX, o.scaleY, s, u), a = o = null, function (e) { for (var t, n = -1, r = u.length; ++n < r;)s[(t = u[n]).i] = t.x(e); return s.join("") } } } var Lue = Bue((function (e) { const t = new ("function" == typeof DOMMatrix ? DOMMatrix : WebKitCSSMatrix)(e + ""); return t.isIdentity ? zue : Pue(t.a, t.b, t.c, t.d, t.e, t.f) }), "px, ", "px)", "deg)"), jue = Bue((function (e) { return null == e ? zue : (Rue || (Rue = document.createElementNS("http://www.w3.org/2000/svg", "g")), Rue.setAttribute("transform", e), (e = Rue.transform.baseVal.consolidate()) ? Pue((e = e.matrix).a, e.b, e.c, e.d, e.e, e.f) : zue) }), ", ", ")", ")"); function Uue(e) { return ((e = Math.exp(e)) + 1 / e) / 2 } const Wue = function e(t, n, r) { function i(e, i) { var a, o, s = e[0], u = e[1], l = e[2], c = i[0], h = i[1], d = i[2], f = c - s, p = h - u, m = f * f + p * p; if (m < 1e-12) o = Math.log(d / l) / t, a = function (e) { return [s + e * f, u + e * p, l * Math.exp(t * e * o)] }; else { var g = Math.sqrt(m), y = (d * d - l * l + r * m) / (2 * l * n * g), b = (d * d - l * l - r * m) / (2 * d * n * g), v = Math.log(Math.sqrt(y * y + 1) - y), x = Math.log(Math.sqrt(b * b + 1) - b); o = (x - v) / t, a = function (e) { var r = e * o, i = Uue(v), a = l / (n * g) * (i * function (e) { return ((e = Math.exp(2 * e)) - 1) / (e + 1) }(t * r + v) - function (e) { return ((e = Math.exp(e)) - 1 / e) / 2 }(v)); return [s + a * f, u + a * p, l * i / Uue(t * r + v)] } } return a.duration = 1e3 * o * t / Math.SQRT2, a } return i.rho = function (t) { var n = Math.max(.001, +t), r = n * n; return e(n, r, r * r) }, i }(Math.SQRT2, 2, 4); function Vue(e) { return function (t, n) { var r = e((t = rue(t)).h, (n = rue(n)).h), i = mue(t.s, n.s), a = mue(t.l, n.l), o = mue(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.s = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } const Gue = Vue(fue); var Hue = Vue(mue); const que = Math.PI / 180, Yue = 180 / Math.PI, Xue = .96422, Kue = 1, Zue = .82521, Jue = 4 / 29, Que = 6 / 29, ele = .12841854934601665, tle = .008856451679035631; function nle(e) { if (e instanceof ile) return new ile(e.l, e.a, e.b, e.opacity); if (e instanceof hle) return dle(e); e instanceof Xse || (e = qse(e)); var t, n, r = ule(e.r), i = ule(e.g), a = ule(e.b), o = ale((.2225045 * r + .7168786 * i + .0606169 * a) / Kue); return r === i && i === a ? t = n = o : (t = ale((.4360747 * r + .3850649 * i + .1430804 * a) / Xue), n = ale((.0139322 * r + .0971045 * i + .7141733 * a) / Zue)), new ile(116 * o - 16, 500 * (t - o), 200 * (o - n), e.opacity) } function rle(e, t, n, r) { return 1 === arguments.length ? nle(e) : new ile(e, t, n, null == r ? 1 : r) } function ile(e, t, n, r) { this.l = +e, this.a = +t, this.b = +n, this.opacity = +r } function ale(e) { return e > tle ? Math.pow(e, 1 / 3) : e / ele + Jue } function ole(e) { return e > Que ? e * e * e : ele * (e - Jue) } function sle(e) { return 255 * (e <= .0031308 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - .055) } function ule(e) { return (e /= 255) <= .04045 ? e / 12.92 : Math.pow((e + .055) / 1.055, 2.4) } function lle(e) { if (e instanceof hle) return new hle(e.h, e.c, e.l, e.opacity); if (e instanceof ile || (e = nle(e)), 0 === e.a && 0 === e.b) return new hle(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity); var t = Math.atan2(e.b, e.a) * Yue; return new hle(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity) } function cle(e, t, n, r) { return 1 === arguments.length ? lle(e) : new hle(e, t, n, null == r ? 1 : r) } function hle(e, t, n, r) { this.h = +e, this.c = +t, this.l = +n, this.opacity = +r } function dle(e) { if (isNaN(e.h)) return new ile(e.l, 0, 0, e.opacity); var t = e.h * que; return new ile(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity) } function fle(e, t) { var n = mue((e = rle(e)).l, (t = rle(t)).l), r = mue(e.a, t.a), i = mue(e.b, t.b), a = mue(e.opacity, t.opacity); return function (t) { return e.l = n(t), e.a = r(t), e.b = i(t), e.opacity = a(t), e + "" } } function ple(e) { return function (t, n) { var r = e((t = cle(t)).h, (n = cle(n)).h), i = mue(t.c, n.c), a = mue(t.l, n.l), o = mue(t.opacity, n.opacity); return function (e) { return t.h = r(e), t.c = i(e), t.l = a(e), t.opacity = o(e), t + "" } } } Ase(ile, rle, Tse(Ese, { brighter(e) { return new ile(this.l + 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, darker(e) { return new ile(this.l - 18 * (null == e ? 1 : e), this.a, this.b, this.opacity) }, rgb() { var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200; return new Xse(sle(3.1338561 * (t = Xue * ole(t)) - 1.6168667 * (e = Kue * ole(e)) - .4906146 * (n = Zue * ole(n))), sle(-.9787684 * t + 1.9161415 * e + .033454 * n), sle(.0719453 * t - .2289914 * e + 1.4052427 * n), this.opacity) } })), Ase(hle, cle, Tse(Ese, { brighter(e) { return new hle(this.h, this.c, this.l + 18 * (null == e ? 1 : e), this.opacity) }, darker(e) { return new hle(this.h, this.c, this.l - 18 * (null == e ? 1 : e), this.opacity) }, rgb() { return dle(this).rgb() } })); const mle = ple(fue); var gle = ple(mue), yle = -.14861, ble = 1.78277, vle = -.29227, xle = -.90649, wle = 1.97294, kle = -1.7884503806, Sle = 3.5172982438, _le = -.6557636667999999; function Cle(e, t, n, r) { return 1 === arguments.length ? function (e) { if (e instanceof Ale) return new Ale(e.h, e.s, e.l, e.opacity); e instanceof Xse || (e = qse(e)); var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (_le * r + kle * t - Sle * n) / -5.9615122912, a = r - i, o = (wle * (n - i) - vle * a) / xle, s = Math.sqrt(o * o + a * a) / (wle * i * (1 - i)), u = s ? Math.atan2(o, a) * Yue - 120 : NaN; return new Ale(u < 0 ? u + 360 : u, s, i, e.opacity) }(e) : new Ale(e, t, n, null == r ? 1 : r) } function Ale(e, t, n, r) { this.h = +e, this.s = +t, this.l = +n, this.opacity = +r } function Tle(e) { return function t(n) { function r(t, r) { var i = e((t = Cle(t)).h, (r = Cle(r)).h), a = mue(t.s, r.s), o = mue(t.l, r.l), s = mue(t.opacity, r.opacity); return function (e) { return t.h = i(e), t.s = a(e), t.l = o(Math.pow(e, n)), t.opacity = s(e), t + "" } } return n = +n, r.gamma = t, r }(1) } Ase(Ale, Cle, Tse(Ese, { brighter(e) { return e = null == e ? Ise : Math.pow(Ise, e), new Ale(this.h, this.s, this.l * e, this.opacity) }, darker(e) { return e = null == e ? Nse : Math.pow(Nse, e), new Ale(this.h, this.s, this.l * e, this.opacity) }, rgb() { var e = isNaN(this.h) ? 0 : (this.h + 120) * que, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e); return new Xse(255 * (t + n * (yle * r + ble * i)), 255 * (t + n * (vle * r + xle * i)), 255 * (t + n * (wle * r)), this.opacity) } })); const Ele = Tle(fue); var Nle = Tle(mue); function Ile(e, t) { for (var n = new Array(t), r = 0; r < t; ++r)n[r] = e(r / (t - 1)); return n } const Mle = "year", Fle = "quarter", Dle = "month", $le = "week", Rle = "date", Ole = "day", zle = "dayofyear", Ple = "hours", Ble = "minutes", Lle = "seconds", jle = "milliseconds", Ule = [Mle, Fle, Dle, $le, Rle, Ole, zle, Ple, Ble, Lle, jle].reduce(((e, t, n) => (e[t] = 1 + n, e)), {}); const Wle = { [Mle]: "%Y ", [Fle]: "Q%q ", [Dle]: "%b ", [Rle]: "%d ", [$le]: "W%U ", [Ole]: "%a ", [zle]: "%j ", [Ple]: "%H:00", [Ble]: "00:%M", [Lle]: ":%S", [jle]: ".%L", [`${Mle}-${Dle}`]: "%Y-%m ", [`${Mle}-${Dle}-${Rle}`]: "%Y-%m-%d ", [`${Ple}-${Ble}`]: "%H:%M" }; const Vle = new Date; function Gle(e) { return Vle.setFullYear(e), Vle.setMonth(0), Vle.setDate(1), Vle.setHours(0, 0, 0, 0), Vle } function Hle(e) { return Yr.count(Gle(e.getFullYear()) - 1, e) } function qle(e) { return Jr.count(Gle(e.getFullYear()) - 1, e) } function Yle(e) { const t = Date.UTC(e.getUTCFullYear(), 0, 1); return Xr.count(t - 1, e) } function Xle(e) { const t = Date.UTC(e.getUTCFullYear(), 0, 1); return oi.count(t - 1, e) } const Kle = { [Mle]: fi, [Fle]: mi.every(3), [Dle]: mi, [$le]: Jr, [Rle]: Yr, [Ole]: Yr, [zle]: Yr, [Ple]: yi, [Ble]: vi, [Lle]: wi, [jle]: ki }, Zle = { [Mle]: pi, [Fle]: gi.every(3), [Dle]: gi, [$le]: oi, [Rle]: Xr, [Ole]: Xr, [zle]: Xr, [Ple]: bi, [Ble]: xi, [Lle]: wi, [jle]: ki }; function Jle(e) { return Kle[e] } function Qle(e) { return Zle[e] } function ece(e, t, n) { return e ? e.offset(t, n) : void 0 } function tce(e, t, n, r) { return e ? e.range(t, n, r) : void 0 } const nce = [Mle, Dle, Rle, Ple, Ble, Lle, jle], rce = nce.slice(0, -1), ice = rce.slice(0, -1), ace = ice.slice(0, -1); ace.slice(0, -1); function oce(e, t, n) { const r = e - t + 2 * n; return e ? r > 0 ? r : 1 : 0 } const sce = "linear", uce = "log", lce = "pow", cce = "sqrt", hce = "symlog", dce = "time", fce = "utc", pce = "sequential", mce = "diverging", gce = "quantile", yce = "quantize", bce = "threshold", vce = "continuous", xce = "discrete", wce = "discretizing", kce = "interpolating", Sce = "temporal"; function _ce() { const e = wm().unknown(void 0), t = e.domain, n = e.range; let r, i, a = [0, 1], o = !1, s = 0, u = 0, l = .5; function c() { const e = t().length, c = a[1] < a[0], h = a[1 - c], d = oce(e, s, u); let f = a[c - 0]; r = (h - f) / (d || 1), o && (r = Math.floor(r)), f += (h - f - r * (e - s)) * l, i = r * (1 - s), o && (f = Math.round(f), i = Math.round(i)); const p = function (e, t, n) { e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n; for (var r = -1, i = 0 | Math.max(0, Math.ceil((t - e) / n)), a = new Array(i); ++r < i;)a[r] = e + r * n; return a }(e).map((e => f + r * e)); return n(c ? p.reverse() : p) } return delete e.unknown, e.domain = function (e) { return arguments.length ? (t(e), c()) : t() }, e.range = function (e) { return arguments.length ? (a = [+e[0], +e[1]], c()) : a.slice() }, e.rangeRound = function (e) { return a = [+e[0], +e[1]], o = !0, c() }, e.bandwidth = function () { return i }, e.step = function () { return r }, e.round = function (e) { return arguments.length ? (o = !!e, c()) : o }, e.padding = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), s = u, c()) : s }, e.paddingInner = function (e) { return arguments.length ? (s = Math.max(0, Math.min(1, e)), c()) : s }, e.paddingOuter = function (e) { return arguments.length ? (u = Math.max(0, Math.min(1, e)), c()) : u }, e.align = function (e) { return arguments.length ? (l = Math.max(0, Math.min(1, e)), c()) : l }, e.invertRange = function (e) { if (null == e[0] || null == e[1]) return; const r = a[1] < a[0], o = r ? n().reverse() : n(), s = o.length - 1; let u, l, c, h = +e[0], d = +e[1]; return h != h || d != d || (d < h && (c = h, h = d, d = c), d < o[0] || h > a[1 - r]) ? void 0 : (u = Math.max(0, _se(o, h) - 1), l = h === d ? u : _se(o, d) - 1, h - o[u] > i + 1e-10 && ++u, r && (c = u, u = s - l, l = s - c), u > l ? void 0 : t().slice(u, l + 1)) }, e.invert = function (t) { const n = e.invertRange([t, t]); return n ? n[0] : n }, e.copy = function () { return _ce().domain(t()).range(a).round(o).paddingInner(s).paddingOuter(u).align(l) }, c() } function Cce(e) { const t = e.copy; return e.padding = e.paddingOuter, delete e.paddingInner, e.copy = function () { return Cce(t()) }, e } var Ace = Array.prototype.map; const Tce = Array.prototype.slice; const Ece = new Map, Nce = Symbol("vega_scale"); function Ice(e, t, n) { const r = function () { const n = t(); return n.invertRange || (n.invertRange = n.invert ? function (e) { return function (t) { let n, r = t[0], i = t[1]; return i < r && (n = r, r = i, i = n), [e.invert(r), e.invert(i)] } }(n) : n.invertExtent ? function (e) { return function (t) { const n = e.range(); let r, i, a, o, s = t[0], u = t[1], l = -1; for (u < s && (i = s, s = u, u = i), a = 0, o = n.length; a < o; ++a)n[a] >= s && n[a] <= u && (l < 0 && (l = a), r = a); if (!(l < 0)) return s = e.invertExtent(n[l]), u = e.invertExtent(n[r]), [void 0 === s[0] ? s[1] : s[0], void 0 === u[1] ? u[0] : u[1]] } }(n) : void 0), n.type = e, function (e) { return e[Nce] = !0, e }(n) }; return r.metadata = Zae(zae(n)), r } function Mce(e, t, n) { return arguments.length > 1 ? (Ece.set(e, Ice(e, t, n)), this) : function (e) { return Ece.has(e) }(e) ? Ece.get(e) : void 0 } function Fce(e, t) { const n = Ece.get(e); return n && n.metadata[t] } function Dce(e) { return Fce(e, xce) } Mce("identity", fp), Mce(sce, dp, vce), Mce(uce, kp, [vce, uce]), Mce(lce, Tp, vce), Mce(cce, Ep, vce), Mce(hce, Fp, vce), Mce(dce, Kp, [vce, Sce]), Mce(fce, Zp, [vce, Sce]), Mce(pce, em, [vce, kce]), Mce(`${pce}-${sce}`, em, [vce, kce]), Mce(`${pce}-${uce}`, tm, [vce, kce, uce]), Mce(`${pce}-${lce}`, rm, [vce, kce]), Mce(`${pce}-${cce}`, im, [vce, kce]), Mce(`${pce}-${hce}`, nm, [vce, kce]), Mce(`${mce}-${sce}`, om, [vce, kce]), Mce(`${mce}-${uce}`, sm, [vce, kce, uce]), Mce(`${mce}-${lce}`, lm, [vce, kce]), Mce(`${mce}-${cce}`, cm, [vce, kce]), Mce(`${mce}-${hce}`, um, [vce, kce]), Mce(gce, dm, [wce, gce]), Mce(yce, fm, wce), Mce(bce, pm, wce), Mce("bin-ordinal", (function e() { let t = [], n = []; function r(e) { return null == e || e != e ? void 0 : n[(Cse(t, e) - 1) % n.length] } return r.domain = function (e) { return arguments.length ? (t = function (e) { return Ace.call(e, Nae) }(e), r) : t.slice() }, r.range = function (e) { return arguments.length ? (n = Tce.call(e), r) : n.slice() }, r.tickFormat = function (e, n) { return cp(t[0], Eae(t), null == e ? 10 : e, n) }, r.copy = function () { return e().domain(r.domain()).range(r.range()) }, r }), [xce, wce]), Mce("ordinal", wm, xce), Mce("band", _ce, xce), Mce("point", (function () { return Cce(_ce().paddingInner(1)) }), xce); const $ce = ["clamp", "base", "constant", "exponent"]; function Rce(e, t, n) { return Mue(function (e, t) { const n = v[function (e) { return "interpolate" + e.toLowerCase().split("-").map((e => e[0].toUpperCase() + e.slice(1))).join("") }(e)]; return null != t && n && n.gamma ? n.gamma(t) : n }(t || "rgb", n), e) } function Oce(e, t, n) { const r = n - t; let i, a, o; return r && Number.isFinite(r) ? (i = (a = e.type).indexOf("-"), a = i < 0 ? a : a.slice(i + 1), o = Mce(a)().domain([t, n]).range([0, 1]), $ce.forEach((t => e[t] ? o[t](e[t]()) : 0)), o) : Pae(s = .5) ? s : () => s; var s } function zce(e) { if (Aae(e)) return e; const t = e.length / 6 | 0, n = new Array(t); for (let r = 0; r < t;)n[r] = "#" + e.slice(6 * r, 6 * ++r); return n } function Pce(e, t) { for (const n in e) Lce(n, t(e[n])) } const Bce = {}; function Lce(e, t) { return e = e && e.toLowerCase(), arguments.length > 1 ? (Bce[e] = t, this) : Bce[e] } Pce({ accent: Ey, category10: Ny, category20: "1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5", category20b: "393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6", category20c: "3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9", dark2: Iy, observable10: My, paired: Fy, pastel1: Dy, pastel2: $y, set1: Ry, set2: Oy, set3: zy, tableau10: "4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac", tableau20: "4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5" }, zce), Pce({ blues: "cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90", greens: "d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429", greys: "e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e", oranges: "fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303", purples: "e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c", reds: "fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13", blueGreen: "d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429", bluePurple: "ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71", greenBlue: "d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1", orangeRed: "fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403", purpleBlue: "dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281", purpleBlueGreen: "dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353", purpleRed: "dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a", redPurple: "fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174", yellowGreen: "e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034", yellowOrangeBrown: "feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204", yellowOrangeRed: "fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225", blueOrange: "134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07", brownBlueGreen: "704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147", purpleGreen: "5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29", purpleOrange: "4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07", redBlue: "8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85", redGrey: "8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434", yellowGreenBlue: "eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185", redYellowBlue: "a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695", redYellowGreen: "a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837", pinkYellowGreen: "8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419", spectral: "9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2", viridis: "440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725", magma: "0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf", inferno: "0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4", plasma: "0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921", cividis: "00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647", rainbow: "6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa", sinebow: "ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040", turbo: "23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00", browns: "eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632", tealBlues: "bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985", teals: "bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667", warmGreys: "dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e", goldGreen: "f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36", goldOrange: "f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26", goldRed: "f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e", lightGreyRed: "efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b", lightGreyTeal: "e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc", lightMulti: "e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c", lightOrange: "f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b", lightTealBlue: "e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988", darkBlue: "3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff", darkGold: "3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff", darkGreen: "3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa", darkMulti: "3737371f5287197d8c29a86995ce3fffe800ffffff", darkRed: "3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c" }, (e => Rce(zce(e)))); const jce = e => Aae(e) ? e.map((e => String(e))) : String(e), Uce = (e, t) => e[1] - t[1], Wce = (e, t) => t[1] - e[1]; function Vce(e, t) { return e.bins ? function (e, t, n) { let r = e.range(), i = r[0], a = Eae(r), o = Uce; if (i > a && (r = a, a = i, i = r, o = Wce), i = Math.floor(i), a = Math.ceil(a), t = t.map((t => [t, e(t)])).filter((e => i <= e[1] && e[1] <= a)).sort(o).map((e => e[0])), n > 0 && t.length > 1) { const e = [t[0], Eae(t)]; for (; t.length > n && t.length >= 3;)t = t.filter(((e, t) => !(t % 2))); t.length < 3 && (t = e) } return t }(e, e.bins, t) : e.ticks ? e.ticks(t) : e.domain() } function Gce(e, t, n, r, i, a) { const o = t.type; let s = jce; if (o === dce || i === dce) s = e.timeFormat(r); else if (o === fce || i === fce) s = e.utcFormat(r); else if (function (e) { return Fce(e, uce) }(o)) { const i = e.formatFloat(r); if (a || t.bins) s = i; else { const e = Hce(t, n, !1); s = t => e(t) ? i(t) : "" } } else if (t.tickFormat) { const i = t.domain(); s = e.formatSpan(i[0], i[i.length - 1], n, r) } else r && (s = e.format(r)); return s } function Hce(e, t, n) { const r = Vce(e, t), i = e.base(), a = Math.log(i), o = Math.max(1, i * t / r.length), s = e => { let t = e / Math.pow(i, Math.round(Math.log(e) / a)); return t * i < i - .5 && (t *= i), t <= o }; return n ? r.filter(s) : s } const qce = { [gce]: "quantiles", [yce]: "thresholds", [bce]: "domain" }, Yce = { [gce]: "quantiles", [yce]: "domain" }; function Xce(e, t) { return e.bins ? function (e) { const t = e.slice(0, -1); return t.max = Eae(e), t }(e.bins) : e.type === uce ? Hce(e, t, !0) : qce[e.type] ? function (e) { const t = [-1 / 0].concat(e); return t.max = 1 / 0, t }(e[qce[e.type]]()) : Vce(e, t) } function Kce(e, t, n, r, i, a, o) { const s = Yce[t.type] && a !== dce && a !== fce ? function (e, t, n) { const r = t[Yce[t.type]](), i = r.length; let a, o = i > 1 ? r[1] - r[0] : r[0]; for (a = 1; a < i; ++a)o = Math.min(o, r[a] - r[a - 1]); return e.formatSpan(0, o, 30, n) }(e, t, i) : Gce(e, t, n, i, a, o); return "symbol" === r && (e => qce[e.type] || e.bins)(t) ? Zce(s) : "discrete" === r ? Qce(s) : ehe(s) } const Zce = e => (t, n, r) => { const i = Jce(r[n + 1], Jce(r.max, 1 / 0)), a = the(t, e), o = the(i, e); return a && o ? a + " – " + o : o ? "< " + o : "≥ " + a }, Jce = (e, t) => null != e ? e : t, Qce = e => (t, n) => n ? e(t) : null, ehe = e => t => e(t), the = (e, t) => Number.isFinite(e) ? t(e) : null; function nhe(e, t, n, r) { const i = r || t.type; return Vae(n) && function (e) { return Fce(e, Sce) }(i) && (n = n.replace(/%a/g, "%A").replace(/%b/g, "%B")), n || i !== dce ? n || i !== fce ? Kce(e, t, 5, null, n, r, !0) : e.utcFormat("%A, %d %B %Y, %X UTC") : e.timeFormat("%A, %d %B %Y, %X") } function rhe(e, t, n) { n = n || {}; const r = Math.max(3, n.maxlen || 7), i = nhe(e, t, n.format, n.formatType); if (function (e) { return Fce(e, wce) }(t.type)) { const e = Xce(t).slice(1).map(i), n = e.length; return `${n} boundar${1 === n ? "y" : "ies"}: ${e.join(", ")}` } if (Dce(t.type)) { const e = t.domain(), n = e.length; return `${n} value${1 === n ? "" : "s"}: ${n > r ? e.slice(0, r - 2).map(i).join(", ") + ", ending with " + e.slice(-1).map(i) : e.map(i).join(", ")}` } { const e = t.domain(); return `values from ${i(e[0])} to ${i(Eae(e))}` } } const ihe = Math.sqrt(50), ahe = Math.sqrt(10), ohe = Math.sqrt(2); function she(e, t, n) { const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), a = r / Math.pow(10, i), o = a >= ihe ? 10 : a >= ahe ? 5 : a >= ohe ? 2 : 1; let s, u, l; return i < 0 ? (l = Math.pow(10, -i) / o, s = Math.round(e * l), u = Math.round(t * l), s / l < e && ++s, u / l > t && --u, l = -l) : (l = Math.pow(10, i) * o, s = Math.round(e / l), u = Math.round(t / l), s * l < e && ++s, u * l > t && --u), u < s && .5 <= n && n < 2 ? she(e, t, 2 * n) : [s, u, l] } function uhe(e, t, n) { return she(e = +e, t = +t, n = +n)[2] } function lhe(e) { const t = {}; return n => t[n] || (t[n] = e(n)) } function che(e) { const t = lhe(e.format), n = e.formatPrefix; return { format: t, formatPrefix: n, formatFloat(e) { const n = kr(e || ","); if (null == n.precision) { switch (n.precision = 12, n.type) { case "%": n.precision -= 2; break; case "e": n.precision -= 1 }return function (e, t) { return n => { const r = e(n), i = r.indexOf(t); if (i < 0) return r; let a = function (e, t) { let n, r = e.lastIndexOf("e"); if (r > 0) return r; for (r = e.length; --r > t;)if (n = e.charCodeAt(r), n >= 48 && n <= 57) return r + 1 }(r, i); const o = a < r.length ? r.slice(a) : ""; for (; --a > i;)if ("0" !== r[a]) { ++a; break } return r.slice(0, a) + o } }(t(n), t(".1f")(1)[1]) } return t(n) }, formatSpan(e, r, i, a) { a = kr(null == a ? ",f" : a); const o = function (e, t, n) { n = +n; const r = (t = +t) < (e = +e), i = r ? uhe(t, e, n) : uhe(e, t, n); return (r ? -1 : 1) * (i < 0 ? 1 / -i : i) }(e, r, i), s = Math.max(Math.abs(e), Math.abs(r)); let u; if (null == a.precision) switch (a.type) { case "s": return isNaN(u = Ar(o, s)) || (a.precision = u), n(a, s); case "": case "e": case "g": case "p": case "r": isNaN(u = Tr(o, s)) || (a.precision = u - ("e" === a.type)); break; case "f": case "%": isNaN(u = Er(o)) || (a.precision = u - 2 * ("%" === a.type)) }return t(a) } } } let hhe, dhe; function fhe() { return hhe = che({ format: Dr, formatPrefix: $r }) } function phe(e, t, n) { Tae(n = n || {}) || wae(`Invalid time multi-format specifier: ${n}`); const r = t(Lle), i = t(Ble), a = t(Ple), o = t(Rle), s = t($le), u = t(Dle), l = t(Fle), c = t(Mle), h = e(n[jle] || ".%L"), d = e(n[Lle] || ":%S"), f = e(n[Ble] || "%I:%M"), p = e(n[Ple] || "%I %p"), m = e(n[Rle] || n[Ole] || "%a %d"), g = e(n[$le] || "%b %d"), y = e(n[Dle] || "%B"), b = e(n[Fle] || "%B"), v = e(n[Mle] || "%Y"); return e => (r(e) < e ? h : i(e) < e ? d : a(e) < e ? f : o(e) < e ? p : u(e) < e ? s(e) < e ? m : g : c(e) < e ? l(e) < e ? y : b : v)(e) } function mhe(e) { const t = lhe(e.format), n = lhe(e.utcFormat); return { timeFormat: e => Vae(e) ? t(e) : phe(t, Jle, e), utcFormat: e => Vae(e) ? n(e) : phe(n, Qle, e), timeParse: lhe(e.parse), utcParse: lhe(e.utcParse) } } function ghe() { return dhe = mhe({ format: za, parse: Pa, utcFormat: Ba, utcParse: La }) } fhe(), ghe(); const yhe = /^(data:|([A-Za-z]+:)?\/\/)/, bhe = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i, vhe = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g, xhe = "file://"; async function whe(e, t) { const n = await this.sanitize(e, t), r = n.href; return n.localFile ? this.file(r) : this.http(r, t) } async function khe(e, t) { t = Bae({}, this.options, t); const n = this.fileAccess, r = { href: null }; let i, a, o; const s = bhe.test(e.replace(vhe, "")); null != e && "string" == typeof e && s || wae("Sanitize failure, invalid URI: " + Hae(e)); const u = yhe.test(e); return (o = t.baseURL) && !u && (e.startsWith("/") || o.endsWith("/") || (e = "/" + e), e = o + e), a = (i = e.startsWith(xhe)) || "file" === t.mode || "http" !== t.mode && !u && n, i ? e = e.slice(7) : e.startsWith("//") && ("file" === t.defaultProtocol ? (e = e.slice(2), a = !0) : e = (t.defaultProtocol || "http") + ":" + e), Object.defineProperty(r, "localFile", { value: !!a }), r.href = e, t.target && (r.target = t.target + ""), t.rel && (r.rel = t.rel + ""), "image" === t.context && t.crossOrigin && (r.crossOrigin = t.crossOrigin + ""), r } function She(e) { return e ? t => new Promise(((n, r) => { e.readFile(t, ((e, t) => { e ? r(e) : n(t) })) })) : _he } async function _he() { wae("No file system access.") } function Che(e) { return e ? async function (t, n) { const r = Bae({}, this.options.http, n), i = n && n.response, a = await e(t, r); return a.ok ? Pae(a[i]) ? a[i]() : a.text() : wae(a.status + "" + a.statusText) } : Ahe } async function Ahe() { wae("No HTTP fetch method available.") } function The(e) { const t = function (t, n) { const r = { delimiter: e }; return Ehe(t, n ? Bae(n, r) : r) }; return t.responseType = "text", t } function Ehe(e, t) { return t.header && (e = t.header.map(Hae).join(t.delimiter) + "\n" + e), sr(t.delimiter).parse(e + "") } function Nhe(e, t) { const n = t && t.property ? Sae(t.property) : _ae; return !Tae(e) || (r = e, "function" == typeof Buffer && Pae(Buffer.isBuffer) && Buffer.isBuffer(r)) ? n(JSON.parse(e)) : function (e, t) { !Aae(e) && function (e) { return e && Pae(e[Symbol.iterator]) }(e) && (e = [...e]); return t && t.copy ? JSON.parse(JSON.stringify(e)) : e }(n(e), t); var r } Ehe.responseType = "text", Nhe.responseType = "json"; const Ihe = { interior: (e, t) => e !== t, exterior: (e, t) => e === t }; function Mhe(e, t) { let n, r, i, a; return e = Nhe(e, t), t && t.feature ? (n = lr, i = t.feature) : t && t.mesh ? (n = fr, i = t.mesh, a = Ihe[t.filter]) : wae("Missing TopoJSON feature or mesh parameter."), r = (r = e.objects[i]) ? n(e, r, a) : wae("Invalid TopoJSON object: " + i), r && r.features || [r] } Mhe.responseType = "json"; The(","), The("\t"); const Fhe = function (e, t) { return n => ({ options: n || {}, sanitize: khe, load: whe, fileAccess: !!t, file: She(t), http: Che(e) }) }("undefined" != typeof fetch && fetch, null); let Dhe = 0; const $he = "p_"; function Rhe(e) { return e && e.gradient } function Ohe(e, t, n) { const r = e.gradient; let i = e.id, a = "radial" === r ? $he : ""; return i || (i = e.id = "gradient_" + Dhe++, "radial" === r ? (e.x1 = zhe(e.x1, .5), e.y1 = zhe(e.y1, .5), e.r1 = zhe(e.r1, 0), e.x2 = zhe(e.x2, .5), e.y2 = zhe(e.y2, .5), e.r2 = zhe(e.r2, .5), a = $he) : (e.x1 = zhe(e.x1, 0), e.y1 = zhe(e.y1, 0), e.x2 = zhe(e.x2, 1), e.y2 = zhe(e.y2, 0))), t[i] = e, "url(" + (n || "") + "#" + a + i + ")" } function zhe(e, t) { return null != e ? e : t } const Phe = { basis: { curve: uh }, "basis-closed": { curve: hh }, "basis-open": { curve: fh }, bundle: { curve: mh, tension: "beta", value: .85 }, cardinal: { curve: bh, tension: "tension", value: 0 }, "cardinal-open": { curve: xh, tension: "tension", value: 0 }, "cardinal-closed": { curve: kh, tension: "tension", value: 0 }, "catmull-rom": { curve: zh, tension: "alpha", value: .5 }, "catmull-rom-closed": { curve: Bh, tension: "alpha", value: .5 }, "catmull-rom-open": { curve: jh, tension: "alpha", value: .5 }, linear: { curve: Wh }, "linear-closed": { curve: Gh }, monotone: { horizontal: ed, vertical: Qh }, natural: { curve: rd }, step: { curve: ad }, "step-after": { curve: sd }, "step-before": { curve: od } }; function Bhe(e, t, n) { var r = jae(Phe, e) && Phe[e], i = null; return r && (i = r.curve || r[t || "vertical"], r.tension && null != n && (i = i[r.tension](n))), i } const Lhe = { m: 2, l: 2, h: 1, v: 1, z: 0, c: 6, s: 4, q: 4, t: 2, a: 7 }, jhe = /[mlhvzcsqta]([^mlhvzcsqta]+|$)/gi, Uhe = /^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/, Whe = /^((\s+,?\s*)|(,\s*))/, Vhe = /^[01]/; function Ghe(e) { const t = []; return (e.match(jhe) || []).forEach((e => { let n = e[0]; const r = n.toLowerCase(), i = Lhe[r], a = function (e, t, n) { const r = []; for (let i = 0; t && i < n.length;)for (let a = 0; a < t; ++a) { const t = "a" !== e || 3 !== a && 4 !== a ? Uhe : Vhe, o = n.slice(i).match(t); if (null === o) throw Error("Invalid SVG path, incorrect parameter type"); i += o[0].length, r.push(+o[0]); const s = n.slice(i).match(Whe); null !== s && (i += s[0].length) } return r }(r, i, e.slice(1).trim()), o = a.length; if (o < i || o && o % i != 0) throw Error("Invalid SVG path, incorrect parameter count"); if (t.push([n, ...a.slice(0, i)]), o !== i) { "m" === r && (n = "M" === n ? "L" : "l"); for (let e = i; e < o; e += i)t.push([n, ...a.slice(e, e + i)]) } })), t } const Hhe = Math.PI / 180, qhe = Math.PI / 2, Yhe = 2 * Math.PI, Xhe = Math.sqrt(3) / 2; var Khe = {}, Zhe = {}, Jhe = [].join; function Qhe(e) { const t = Jhe.call(e); if (Zhe[t]) return Zhe[t]; var n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], u = e[6], l = e[7]; const c = l * o, h = -u * s, d = u * o, f = l * s, p = Math.cos(i), m = Math.sin(i), g = Math.cos(a), y = Math.sin(a), b = .5 * (a - i), v = Math.sin(.5 * b), x = 8 / 3 * v * v / Math.sin(b), w = n + p - x * m, k = r + m + x * p, S = n + g, _ = r + y, C = S + x * y, A = _ - x * g; return Zhe[t] = [c * w + h * k, d * w + f * k, c * C + h * A, d * C + f * A, c * S + h * _, d * S + f * _] } const ede = ["l", 0, 0, 0, 0, 0, 0, 0]; function tde(e, t, n) { const r = ede[0] = e[0]; if ("a" === r || "A" === r) ede[1] = t * e[1], ede[2] = n * e[2], ede[3] = e[3], ede[4] = e[4], ede[5] = e[5], ede[6] = t * e[6], ede[7] = n * e[7]; else if ("h" === r || "H" === r) ede[1] = t * e[1]; else if ("v" === r || "V" === r) ede[1] = n * e[1]; else for (var i = 1, a = e.length; i < a; ++i)ede[i] = (i % 2 == 1 ? t : n) * e[i]; return ede } function nde(e, t, n, r, i, a) { var o, s, u, l, c, h = null, d = 0, f = 0, p = 0, m = 0, g = 0, y = 0; null == n && (n = 0), null == r && (r = 0), null == i && (i = 1), null == a && (a = i), e.beginPath && e.beginPath(); for (var b = 0, v = t.length; b < v; ++b) { switch (o = t[b], 1 === i && 1 === a || (o = tde(o, i, a)), o[0]) { case "l": d += o[1], f += o[2], e.lineTo(d + n, f + r); break; case "L": d = o[1], f = o[2], e.lineTo(d + n, f + r); break; case "h": d += o[1], e.lineTo(d + n, f + r); break; case "H": d = o[1], e.lineTo(d + n, f + r); break; case "v": f += o[1], e.lineTo(d + n, f + r); break; case "V": f = o[1], e.lineTo(d + n, f + r); break; case "m": g = d += o[1], y = f += o[2], e.moveTo(d + n, f + r); break; case "M": g = d = o[1], y = f = o[2], e.moveTo(d + n, f + r); break; case "c": s = d + o[5], u = f + o[6], p = d + o[3], m = f + o[4], e.bezierCurveTo(d + o[1] + n, f + o[2] + r, p + n, m + r, s + n, u + r), d = s, f = u; break; case "C": d = o[5], f = o[6], p = o[3], m = o[4], e.bezierCurveTo(o[1] + n, o[2] + r, p + n, m + r, d + n, f + r); break; case "s": s = d + o[3], u = f + o[4], p = 2 * d - p, m = 2 * f - m, e.bezierCurveTo(p + n, m + r, d + o[1] + n, f + o[2] + r, s + n, u + r), p = d + o[1], m = f + o[2], d = s, f = u; break; case "S": s = o[3], u = o[4], p = 2 * d - p, m = 2 * f - m, e.bezierCurveTo(p + n, m + r, o[1] + n, o[2] + r, s + n, u + r), d = s, f = u, p = o[1], m = o[2]; break; case "q": s = d + o[3], u = f + o[4], p = d + o[1], m = f + o[2], e.quadraticCurveTo(p + n, m + r, s + n, u + r), d = s, f = u; break; case "Q": s = o[3], u = o[4], e.quadraticCurveTo(o[1] + n, o[2] + r, s + n, u + r), d = s, f = u, p = o[1], m = o[2]; break; case "t": s = d + o[1], u = f + o[2], null === h[0].match(/[QqTt]/) ? (p = d, m = f) : "t" === h[0] ? (p = 2 * d - l, m = 2 * f - c) : "q" === h[0] && (p = 2 * d - p, m = 2 * f - m), l = p, c = m, e.quadraticCurveTo(p + n, m + r, s + n, u + r), f = u, p = (d = s) + o[1], m = f + o[2]; break; case "T": s = o[1], u = o[2], p = 2 * d - p, m = 2 * f - m, e.quadraticCurveTo(p + n, m + r, s + n, u + r), d = s, f = u; break; case "a": rde(e, d + n, f + r, [o[1], o[2], o[3], o[4], o[5], o[6] + d + n, o[7] + f + r]), d += o[6], f += o[7]; break; case "A": rde(e, d + n, f + r, [o[1], o[2], o[3], o[4], o[5], o[6] + n, o[7] + r]), d = o[6], f = o[7]; break; case "z": case "Z": d = g, f = y, e.closePath() }h = o } } function rde(e, t, n, r) { const i = function (e, t, n, r, i, a, o, s, u) { const l = Jhe.call(arguments); if (Khe[l]) return Khe[l]; const c = o * Hhe, h = Math.sin(c), d = Math.cos(c), f = d * (s - e) * .5 + h * (u - t) * .5, p = d * (u - t) * .5 - h * (s - e) * .5; let m = f * f / ((n = Math.abs(n)) * n) + p * p / ((r = Math.abs(r)) * r); m > 1 && (m = Math.sqrt(m), n *= m, r *= m); const g = d / n, y = h / n, b = -h / r, v = d / r, x = g * s + y * u, w = b * s + v * u, k = g * e + y * t, S = b * e + v * t; let _ = 1 / ((k - x) * (k - x) + (S - w) * (S - w)) - .25; _ < 0 && (_ = 0); let C = Math.sqrt(_); a == i && (C = -C); const A = .5 * (x + k) - C * (S - w), T = .5 * (w + S) + C * (k - x), E = Math.atan2(w - T, x - A); let N = Math.atan2(S - T, k - A) - E; N < 0 && 1 === a ? N += Yhe : N > 0 && 0 === a && (N -= Yhe); const I = Math.ceil(Math.abs(N / (qhe + .001))), M = []; for (let e = 0; e < I; ++e) { const t = E + e * N / I, i = E + (e + 1) * N / I; M[e] = [A, T, t, i, n, r, h, d] } return Khe[l] = M }(r[5], r[6], r[0], r[1], r[3], r[4], r[2], t, n); for (let t = 0; t < i.length; ++t) { const n = Qhe(i[t]); e.bezierCurveTo(n[0], n[1], n[2], n[3], n[4], n[5]) } } const ide = .5773502691896257, ade = { circle: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(n, 0), e.arc(0, 0, n, 0, Yhe) } }, cross: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = n / 2.5; e.moveTo(-n, -r), e.lineTo(-n, r), e.lineTo(-r, r), e.lineTo(-r, n), e.lineTo(r, n), e.lineTo(r, r), e.lineTo(n, r), e.lineTo(n, -r), e.lineTo(r, -r), e.lineTo(r, -n), e.lineTo(-r, -n), e.lineTo(-r, -r), e.closePath() } }, diamond: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(-n, 0), e.lineTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.closePath() } }, square: { draw: function (e, t) { var n = Math.sqrt(t), r = -n / 2; e.rect(r, r, n, n) } }, arrow: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = n / 7, i = n / 2.5, a = n / 8; e.moveTo(-r, n), e.lineTo(r, n), e.lineTo(r, -a), e.lineTo(i, -a), e.lineTo(0, -n), e.lineTo(-i, -a), e.lineTo(-r, -a), e.closePath() } }, wedge: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = Xhe * n, i = r - n * ide, a = n / 4; e.moveTo(0, -r - i), e.lineTo(-a, r - i), e.lineTo(a, r - i), e.closePath() } }, triangle: { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = Xhe * n, i = r - n * ide; e.moveTo(0, -r - i), e.lineTo(-n, r - i), e.lineTo(n, r - i), e.closePath() } }, "triangle-up": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = Xhe * n; e.moveTo(0, -r), e.lineTo(-n, r), e.lineTo(n, r), e.closePath() } }, "triangle-down": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = Xhe * n; e.moveTo(0, r), e.lineTo(-n, -r), e.lineTo(n, -r), e.closePath() } }, "triangle-right": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = Xhe * n; e.moveTo(r, 0), e.lineTo(-r, -n), e.lineTo(-r, n), e.closePath() } }, "triangle-left": { draw: function (e, t) { var n = Math.sqrt(t) / 2, r = Xhe * n; e.moveTo(-r, 0), e.lineTo(r, -n), e.lineTo(r, n), e.closePath() } }, stroke: { draw: function (e, t) { const n = Math.sqrt(t) / 2; e.moveTo(-n, 0), e.lineTo(n, 0) } } }; function ode(e) { return jae(ade, e) ? ade[e] : function (e) { if (!jae(sde, e)) { const t = Ghe(e); sde[e] = { draw: function (e, n) { nde(e, t, 0, 0, Math.sqrt(n) / 2) } } } return sde[e] }(e) } var sde = {}; const ude = .448084975506; function lde(e) { return e.x } function cde(e) { return e.y } function hde(e) { return e.width } function dde(e) { return e.height } function fde(e) { return "function" == typeof e ? e : () => +e } function pde(e, t, n) { return Math.max(t, Math.min(e, n)) } function mde(e, t) { return null != e ? e : t } const gde = e => e.x || 0, yde = e => e.y || 0, bde = e => !(!1 === e.defined), vde = Sd().startAngle((e => e.startAngle || 0)).endAngle((e => e.endAngle || 0)).padAngle((e => e.padAngle || 0)).innerRadius((e => e.innerRadius || 0)).outerRadius((e => e.outerRadius || 0)).cornerRadius((e => e.cornerRadius || 0)), xde = Ed().x(gde).y1(yde).y0((e => (e.y || 0) + (e.height || 0))).defined(bde), wde = Ed().y(yde).x1(gde).x0((e => (e.x || 0) + (e.width || 0))).defined(bde), kde = Td().x(gde).y(yde).defined(bde), Sde = function () { var e = lde, t = cde, n = hde, r = dde, i = fde(0), a = i, o = i, s = i, u = null; function l(l, c, h) { var d, f = null != c ? c : +e.call(this, l), p = null != h ? h : +t.call(this, l), m = +n.call(this, l), g = +r.call(this, l), y = Math.min(m, g) / 2, b = pde(+i.call(this, l), 0, y), v = pde(+a.call(this, l), 0, y), x = pde(+o.call(this, l), 0, y), w = pde(+s.call(this, l), 0, y); if (u || (u = d = md()), b <= 0 && v <= 0 && x <= 0 && w <= 0) u.rect(f, p, m, g); else { var k = f + m, S = p + g; u.moveTo(f + b, p), u.lineTo(k - v, p), u.bezierCurveTo(k - ude * v, p, k, p + ude * v, k, p + v), u.lineTo(k, S - w), u.bezierCurveTo(k, S - ude * w, k - ude * w, S, k - w, S), u.lineTo(f + x, S), u.bezierCurveTo(f + ude * x, S, f, S - ude * x, f, S - x), u.lineTo(f, p + b), u.bezierCurveTo(f, p + ude * b, f + ude * b, p, f + b, p), u.closePath() } if (d) return u = null, d + "" || null } return l.x = function (t) { return arguments.length ? (e = fde(t), l) : e }, l.y = function (e) { return arguments.length ? (t = fde(e), l) : t }, l.width = function (e) { return arguments.length ? (n = fde(e), l) : n }, l.height = function (e) { return arguments.length ? (r = fde(e), l) : r }, l.cornerRadius = function (e, t, n, r) { return arguments.length ? (i = fde(e), a = null != t ? fde(t) : i, s = null != n ? fde(n) : i, o = null != r ? fde(r) : a, l) : i }, l.context = function (e) { return arguments.length ? (u = null == e ? null : e, l) : u }, l }().x(gde).y(yde).width((e => e.width || 0)).height((e => e.height || 0)).cornerRadius((e => mde(e.cornerRadiusTopLeft, e.cornerRadius) || 0), (e => mde(e.cornerRadiusTopRight, e.cornerRadius) || 0), (e => mde(e.cornerRadiusBottomRight, e.cornerRadius) || 0), (e => mde(e.cornerRadiusBottomLeft, e.cornerRadius) || 0)), _de = Md().type((e => ode(e.shape || "circle"))).size((e => mde(e.size, 64))), Cde = function () { var e, t, n, r, i, a, o, s, u = null; function l(e, t, n) { const r = n / 2; if (i) { var l = o - t, c = e - a; if (l || c) { var h = Math.hypot(l, c), d = (l /= h) * s, f = (c /= h) * s, p = Math.atan2(c, l); u.moveTo(a - d, o - f), u.lineTo(e - l * r, t - c * r), u.arc(e, t, r, p - Math.PI, p), u.lineTo(a + d, o + f), u.arc(a, o, s, p, p + Math.PI) } else u.arc(e, t, r, 0, Yhe); u.closePath() } else i = 1; a = e, o = t, s = r } function c(a) { var o, s, c, h = a.length, d = !1; for (null == u && (u = c = md()), o = 0; o <= h; ++o)!(o < h && r(s = a[o], o, a)) === d && (d = !d) && (i = 0), d && l(+e(s, o, a), +t(s, o, a), +n(s, o, a)); if (c) return u = null, c + "" || null } return c.x = function (t) { return arguments.length ? (e = t, c) : e }, c.y = function (e) { return arguments.length ? (t = e, c) : t }, c.size = function (e) { return arguments.length ? (n = e, c) : n }, c.defined = function (e) { return arguments.length ? (r = e, c) : r }, c.context = function (e) { return arguments.length ? (u = null == e ? null : e, c) : u }, c }().x(gde).y(yde).defined(bde).size((e => e.size || 1)); function Ade(e) { return e.cornerRadius || e.cornerRadiusTopLeft || e.cornerRadiusTopRight || e.cornerRadiusBottomRight || e.cornerRadiusBottomLeft } function Tde(e, t, n, r) { return Sde.context(e)(t, n, r) } var Ede = 1; function Nde(e, t, n) { var r = t.clip, i = e._defs, a = t.clip_id || (t.clip_id = "clip" + Ede++), o = i.clipping[a] || (i.clipping[a] = { id: a }); return Pae(r) ? o.path = r(null) : Ade(n) ? o.path = Tde(null, n, 0, 0) : (o.width = n.width || 0, o.height = n.height || 0), "url(#" + a + ")" } function Ide(e) { this.clear(), e && this.union(e) } function Mde(e) { this.mark = e, this.bounds = this.bounds || new Ide } function Fde(e) { Mde.call(this, e), this.items = this.items || [] } Ide.prototype = { clone() { return new Ide(this) }, clear() { return this.x1 = +Number.MAX_VALUE, this.y1 = +Number.MAX_VALUE, this.x2 = -Number.MAX_VALUE, this.y2 = -Number.MAX_VALUE, this }, empty() { return this.x1 === +Number.MAX_VALUE && this.y1 === +Number.MAX_VALUE && this.x2 === -Number.MAX_VALUE && this.y2 === -Number.MAX_VALUE }, equals(e) { return this.x1 === e.x1 && this.y1 === e.y1 && this.x2 === e.x2 && this.y2 === e.y2 }, set(e, t, n, r) { return n < e ? (this.x2 = e, this.x1 = n) : (this.x1 = e, this.x2 = n), r < t ? (this.y2 = t, this.y1 = r) : (this.y1 = t, this.y2 = r), this }, add(e, t) { return e < this.x1 && (this.x1 = e), t < this.y1 && (this.y1 = t), e > this.x2 && (this.x2 = e), t > this.y2 && (this.y2 = t), this }, expand(e) { return this.x1 -= e, this.y1 -= e, this.x2 += e, this.y2 += e, this }, round() { return this.x1 = Math.floor(this.x1), this.y1 = Math.floor(this.y1), this.x2 = Math.ceil(this.x2), this.y2 = Math.ceil(this.y2), this }, scale(e) { return this.x1 *= e, this.y1 *= e, this.x2 *= e, this.y2 *= e, this }, translate(e, t) { return this.x1 += e, this.x2 += e, this.y1 += t, this.y2 += t, this }, rotate(e, t, n) { const r = this.rotatedPoints(e, t, n); return this.clear().add(r[0], r[1]).add(r[2], r[3]).add(r[4], r[5]).add(r[6], r[7]) }, rotatedPoints(e, t, n) { var { x1: r, y1: i, x2: a, y2: o } = this, s = Math.cos(e), u = Math.sin(e), l = t - t * s + n * u, c = n - t * u - n * s; return [s * r - u * i + l, u * r + s * i + c, s * r - u * o + l, u * r + s * o + c, s * a - u * i + l, u * a + s * i + c, s * a - u * o + l, u * a + s * o + c] }, union(e) { return e.x1 < this.x1 && (this.x1 = e.x1), e.y1 < this.y1 && (this.y1 = e.y1), e.x2 > this.x2 && (this.x2 = e.x2), e.y2 > this.y2 && (this.y2 = e.y2), this }, intersect(e) { return e.x1 > this.x1 && (this.x1 = e.x1), e.y1 > this.y1 && (this.y1 = e.y1), e.x2 < this.x2 && (this.x2 = e.x2), e.y2 < this.y2 && (this.y2 = e.y2), this }, encloses(e) { return e && this.x1 <= e.x1 && this.x2 >= e.x2 && this.y1 <= e.y1 && this.y2 >= e.y2 }, alignsWith(e) { return e && (this.x1 == e.x1 || this.x2 == e.x2 || this.y1 == e.y1 || this.y2 == e.y2) }, intersects(e) { return e && !(this.x2 < e.x1 || this.x1 > e.x2 || this.y2 < e.y1 || this.y1 > e.y2) }, contains(e, t) { return !(e < this.x1 || e > this.x2 || t < this.y1 || t > this.y2) }, width() { return this.x2 - this.x1 }, height() { return this.y2 - this.y1 } }, function (e, t, n) { const r = e.prototype = Object.create(t.prototype); Object.defineProperty(r, "constructor", { value: e, writable: !0, enumerable: !0, configurable: !0 }), Bae(r, n) }(Fde, Mde); class Dde { constructor(e) { this._pending = 0, this._loader = e || Fhe() } pending() { return this._pending } sanitizeURL(e) { const t = this; return $de(t), t._loader.sanitize(e, { context: "href" }).then((e => (Rde(t), e))).catch((() => (Rde(t), null))) } loadImage(e) { const t = this, n = Dd(); return $de(t), t._loader.sanitize(e, { context: "image" }).then((e => { const r = e.href; if (!r || !n) throw { url: r }; const i = new n, a = jae(e, "crossOrigin") ? e.crossOrigin : "anonymous"; return null != a && (i.crossOrigin = a), i.onload = () => Rde(t), i.onerror = () => Rde(t), i.src = r, i })).catch((e => (Rde(t), { complete: !1, width: 0, height: 0, src: e && e.url || "" }))) } ready() { const e = this; return new Promise((t => { !function n(r) { e.pending() ? setTimeout((() => { n(!0) }), 10) : t(r) }(!1) })) } } function $de(e) { e._pending += 1 } function Rde(e) { e._pending -= 1 } function Ode(e, t, n) { if (t.stroke && 0 !== t.opacity && 0 !== t.strokeOpacity) { const r = null != t.strokeWidth ? +t.strokeWidth : 1; e.expand(r + (n ? function (e, t) { return e.strokeJoin && "miter" !== e.strokeJoin ? 0 : t }(t, r) : 0)) } return e } const zde = Yhe - 1e-8; let Pde, Bde, Lde, jde, Ude, Wde, Vde, Gde; const Hde = (e, t) => Pde.add(e, t), qde = (e, t) => Hde(Bde = e, Lde = t), Yde = e => Hde(e, Pde.y1), Xde = e => Hde(Pde.x1, e), Kde = (e, t) => Ude * e + Vde * t, Zde = (e, t) => Wde * e + Gde * t, Jde = (e, t) => Hde(Kde(e, t), Zde(e, t)), Qde = (e, t) => qde(Kde(e, t), Zde(e, t)); function efe(e, t) { return Pde = e, t ? (jde = t * Hhe, Ude = Gde = Math.cos(jde), Wde = Math.sin(jde), Vde = -Wde) : (Ude = Gde = 1, jde = Wde = Vde = 0), tfe } const tfe = { beginPath() { }, closePath() { }, moveTo: Qde, lineTo: Qde, rect(e, t, n, r) { jde ? (Jde(e + n, t), Jde(e + n, t + r), Jde(e, t + r), Qde(e, t)) : (Hde(e + n, t + r), qde(e, t)) }, quadraticCurveTo(e, t, n, r) { const i = Kde(e, t), a = Zde(e, t), o = Kde(n, r), s = Zde(n, r); nfe(Bde, i, o, Yde), nfe(Lde, a, s, Xde), qde(o, s) }, bezierCurveTo(e, t, n, r, i, a) { const o = Kde(e, t), s = Zde(e, t), u = Kde(n, r), l = Zde(n, r), c = Kde(i, a), h = Zde(i, a); rfe(Bde, o, u, c, Yde), rfe(Lde, s, l, h, Xde), qde(c, h) }, arc(e, t, n, r, i, a) { if (r += jde, i += jde, Bde = n * Math.cos(i) + e, Lde = n * Math.sin(i) + t, Math.abs(i - r) > zde) Hde(e - n, t - n), Hde(e + n, t + n); else { const o = r => Hde(n * Math.cos(r) + e, n * Math.sin(r) + t); let s, u; if (o(r), o(i), i !== r) if ((r %= Yhe) < 0 && (r += Yhe), (i %= Yhe) < 0 && (i += Yhe), i < r && (a = !a, s = r, r = i, i = s), a) for (i -= Yhe, s = r - r % qhe, u = 0; u < 4 && s > i; ++u, s -= qhe)o(s); else for (s = r - r % qhe + qhe, u = 0; u < 4 && s < i; ++u, s += qhe)o(s) } } }; function nfe(e, t, n, r) { const i = (e - t) / (e + n - 2 * t); 0 < i && i < 1 && r(e + (t - e) * i) } function rfe(e, t, n, r, i) { const a = r - e + 3 * t - 3 * n, o = e + n - 2 * t, s = e - t; let u, l = 0, c = 0; Math.abs(a) > 1e-14 ? (u = o * o + s * a, u >= 0 && (u = Math.sqrt(u), l = (-o + u) / a, c = (-o - u) / a)) : l = .5 * s / o, 0 < l && l < 1 && i(ife(l, e, t, n, r)), 0 < c && c < 1 && i(ife(c, e, t, n, r)) } function ife(e, t, n, r, i) { const a = 1 - e, o = a * a, s = e * e; return o * a * t + 3 * o * e * n + 3 * a * s * r + s * e * i } var afe = (afe = Fd(1, 1)) ? afe.getContext("2d") : null; const ofe = new Ide; function sfe(e) { return function (t, n) { if (!afe) return !0; e(afe, t), ofe.clear().union(t.bounds).intersect(n).round(); const { x1: r, y1: i, x2: a, y2: o } = ofe; for (let e = i; e <= o; ++e)for (let t = r; t <= a; ++t)if (afe.isPointInPath(t, e)) return !0; return !1 } } function ufe(e, t) { return t.contains(e.x || 0, e.y || 0) } function lfe(e, t) { const n = e.x || 0, r = e.y || 0, i = e.width || 0, a = e.height || 0; return t.intersects(ofe.set(n, r, n + i, r + a)) } function cfe(e, t, n, r, i) { const { x1: a, y1: o, x2: s, y2: u } = e, l = r - t, c = i - n; let h, d, f, p, m = 0, g = 1; for (p = 0; p < 4; ++p) { if (0 === p && (h = -l, d = -(a - t)), 1 === p && (h = l, d = s - t), 2 === p && (h = -c, d = -(o - n)), 3 === p && (h = c, d = u - n), Math.abs(h) < 1e-10 && d < 0) return !1; if (f = d / h, h < 0) { if (f > g) return !1; f > m && (m = f) } else if (h > 0) { if (f < m) return !1; f < g && (g = f) } } return !0 } function hfe(e, t) { e.globalCompositeOperation = t.blend || "source-over" } function dfe(e, t) { return null == e ? t : e } function ffe(e, t) { const n = t.length; for (let r = 0; r < n; ++r)e.addColorStop(t[r].offset, t[r].color); return e } function pfe(e, t, n) { return Rhe(n) ? function (e, t, n) { const r = n.width(), i = n.height(); let a; if ("radial" === t.gradient) a = e.createRadialGradient(n.x1 + dfe(t.x1, .5) * r, n.y1 + dfe(t.y1, .5) * i, Math.max(r, i) * dfe(t.r1, 0), n.x1 + dfe(t.x2, .5) * r, n.y1 + dfe(t.y2, .5) * i, Math.max(r, i) * dfe(t.r2, .5)); else { const o = dfe(t.x1, 0), s = dfe(t.y1, 0), u = dfe(t.x2, 1), l = dfe(t.y2, 0); if (o !== u && s !== l && r !== i) { const n = Fd(Math.ceil(r), Math.ceil(i)), a = n.getContext("2d"); return a.scale(r, i), a.fillStyle = ffe(a.createLinearGradient(o, s, u, l), t.stops), a.fillRect(0, 0, r, i), e.createPattern(n, "no-repeat") } a = e.createLinearGradient(n.x1 + o * r, n.y1 + s * i, n.x1 + u * r, n.y1 + l * i) } return ffe(a, t.stops) }(e, n, t.bounds) : n } function mfe(e, t, n) { return (n *= null == t.fillOpacity ? 1 : t.fillOpacity) > 0 && (e.globalAlpha = n, e.fillStyle = pfe(e, t, t.fill), !0) } var gfe = []; function yfe(e, t, n) { var r = null != (r = t.strokeWidth) ? r : 1; return !(r <= 0) && ((n *= null == t.strokeOpacity ? 1 : t.strokeOpacity) > 0 && (e.globalAlpha = n, e.strokeStyle = pfe(e, t, t.stroke), e.lineWidth = r, e.lineCap = t.strokeCap || "butt", e.lineJoin = t.strokeJoin || "miter", e.miterLimit = t.strokeMiterLimit || 10, e.setLineDash && (e.setLineDash(t.strokeDash || gfe), e.lineDashOffset = t.strokeDashOffset || 0), !0)) } function bfe(e, t) { return e.zindex - t.zindex || e.index - t.index } function vfe(e) { if (!e.zdirty) return e.zitems; var t, n, r, i = e.items, a = []; for (n = 0, r = i.length; n < r; ++n)(t = i[n]).index = n, t.zindex && a.push(t); return e.zdirty = !1, e.zitems = a.sort(bfe) } function xfe(e, t) { var n, r, i = e.items; if (!i || !i.length) return; const a = vfe(e); if (a && a.length) { for (n = 0, r = i.length; n < r; ++n)i[n].zindex || t(i[n]); i = a } for (n = 0, r = i.length; n < r; ++n)t(i[n]) } function wfe(e, t) { var n, r, i = e.items; if (!i || !i.length) return null; const a = vfe(e); for (a && a.length && (i = a), r = i.length; --r >= 0;)if (n = t(i[r])) return n; if (i === a) for (r = (i = e.items).length; --r >= 0;)if (!i[r].zindex && (n = t(i[r]))) return n; return null } function kfe(e) { return function (t, n, r) { xfe(n, (n => { r && !r.intersects(n.bounds) || _fe(e, t, n, n) })) } } function Sfe(e) { return function (t, n, r) { !n.items.length || r && !r.intersects(n.bounds) || _fe(e, t, n.items[0], n.items) } } function _fe(e, t, n, r) { var i = null == n.opacity ? 1 : n.opacity; 0 !== i && (e(t, r) || (hfe(t, n), n.fill && mfe(t, n, i) && t.fill(), n.stroke && yfe(t, n, i) && t.stroke())) } function Cfe(e) { return e = e || Cae, function (t, n, r, i, a, o) { return r *= t.pixelRatio, i *= t.pixelRatio, wfe(n, (n => { const s = n.bounds; if ((!s || s.contains(a, o)) && s) return e(t, n, r, i, a, o) ? n : void 0 })) } } function Afe(e, t) { return function (n, r, i, a) { var o, s, u = Array.isArray(r) ? r[0] : r, l = null == t ? u.fill : t, c = u.stroke && n.isPointInStroke; return c && (o = u.strokeWidth, s = u.strokeCap, n.lineWidth = null != o ? o : 1, n.lineCap = null != s ? s : "butt"), !e(n, r) && (l && n.isPointInPath(i, a) || c && n.isPointInStroke(i, a)) } } function Tfe(e) { return Cfe(Afe(e)) } function Efe(e, t) { return "translate(" + e + "," + t + ")" } function Nfe(e) { return "rotate(" + e + ")" } function Ife(e) { return Efe(e.x || 0, e.y || 0) } function Mfe(e, t, n) { function r(e, n) { var r = n.x || 0, i = n.y || 0, a = n.angle || 0; e.translate(r, i), a && e.rotate(a *= Hhe), e.beginPath(), t(e, n), a && e.rotate(-a), e.translate(-r, -i) } return { type: e, tag: "path", nested: !1, attr: function (e, n) { e("transform", function (e) { return Efe(e.x || 0, e.y || 0) + (e.angle ? " " + Nfe(e.angle) : "") }(n)), e("d", t(null, n)) }, bound: function (e, n) { return t(efe(e, n.angle), n), Ode(e, n).translate(n.x || 0, n.y || 0) }, draw: kfe(r), pick: Tfe(r), isect: n || sfe(r) } } var Ffe = Mfe("arc", (function (e, t) { return vde.context(e)(t) })); function Dfe(e, t, n) { function r(e, n) { e.beginPath(), t(e, n) } const i = Afe(r); return { type: e, tag: "path", nested: !0, attr: function (e, n) { var r = n.mark.items; r.length && e("d", t(null, r)) }, bound: function (e, n) { var r = n.items; return 0 === r.length ? e : (t(efe(e), r), Ode(e, r[0])) }, draw: Sfe(r), pick: function (e, t, n, r, a, o) { var s = t.items, u = t.bounds; return !s || !s.length || u && !u.contains(a, o) ? null : (n *= e.pixelRatio, r *= e.pixelRatio, i(e, s, n, r) ? s[0] : null) }, isect: ufe, tip: n } } var $fe = Dfe("area", (function (e, t) { const n = t[0], r = n.interpolate || "linear"; return ("horizontal" === n.orient ? wde : xde).curve(Bhe(r, n.orient, n.tension)).context(e)(t) }), (function (e, t) { for (var n, r, i = "horizontal" === e[0].orient ? t[1] : t[0], a = "horizontal" === e[0].orient ? "y" : "x", o = e.length, s = 1 / 0; --o >= 0;)!1 !== e[o].defined && (r = Math.abs(e[o][a] - i)) < s && (s = r, n = e[o]); return n })); function Rfe(e, t) { e.beginPath(), Ade(t) ? Tde(e, t, 0, 0) : e.rect(0, 0, t.width || 0, t.height || 0), e.clip() } function Ofe(e) { const t = dfe(e.strokeWidth, 1); return null != e.strokeOffset ? e.strokeOffset : e.stroke && t > .5 && t < 1.5 ? .5 - Math.abs(t - 1) : 0 } function zfe(e, t) { const n = Ofe(t); e("d", Tde(null, t, n, n)) } function Pfe(e, t, n, r) { const i = Ofe(t); e.beginPath(), Tde(e, t, (n || 0) + i, (r || 0) + i) } const Bfe = Afe(Pfe), Lfe = Afe(Pfe, !1), jfe = Afe(Pfe, !0); var Ufe = { type: "group", tag: "g", nested: !1, attr: function (e, t) { e("transform", Ife(t)) }, bound: function (e, t) { if (!t.clip && t.items) { const n = t.items, r = n.length; for (let t = 0; t < r; ++t)e.union(n[t].bounds) } return (t.clip || t.width || t.height) && !t.noBound && e.add(0, 0).add(t.width || 0, t.height || 0), Ode(e, t), e.translate(t.x || 0, t.y || 0) }, draw: function (e, t, n, r) { xfe(t, (t => { const i = t.x || 0, a = t.y || 0, o = t.strokeForeground, s = null == t.opacity ? 1 : t.opacity; (t.stroke || t.fill) && s && (Pfe(e, t, i, a), hfe(e, t), t.fill && mfe(e, t, s) && e.fill(), t.stroke && !o && yfe(e, t, s) && e.stroke()), e.save(), e.translate(i, a), t.clip && Rfe(e, t), n && n.translate(-i, -a), xfe(t, (t => { ("group" === t.marktype || null == r || r.includes(t.marktype)) && this.draw(e, t, n, r) })), n && n.translate(i, a), e.restore(), o && t.stroke && s && (Pfe(e, t, i, a), hfe(e, t), yfe(e, t, s) && e.stroke()) })) }, pick: function (e, t, n, r, i, a) { if (t.bounds && !t.bounds.contains(i, a) || !t.items) return null; const o = n * e.pixelRatio, s = r * e.pixelRatio; return wfe(t, (u => { let l, c, h; const d = u.bounds; if (d && !d.contains(i, a)) return; c = u.x || 0, h = u.y || 0; const f = c + (u.width || 0), p = h + (u.height || 0), m = u.clip; if (m && (i < c || i > f || a < h || a > p)) return; if (e.save(), e.translate(c, h), c = i - c, h = a - h, m && Ade(u) && !jfe(e, u, o, s)) return e.restore(), null; const g = u.strokeForeground, y = !1 !== t.interactive; return y && g && u.stroke && Lfe(e, u, o, s) ? (e.restore(), u) : (l = wfe(u, (e => function (e, t, n) { return (!1 !== e.interactive || "group" === e.marktype) && e.bounds && e.bounds.contains(t, n) }(e, c, h) ? this.pick(e, n, r, c, h) : null)), !l && y && (u.fill || !g && u.stroke) && Bfe(e, u, o, s) && (l = u), e.restore(), l || null) })) }, isect: lfe, content: function (e, t, n) { e("clip-path", t.clip ? Nde(n, t, t) : null) }, background: function (e, t) { e("class", "background"), e("aria-hidden", !0), zfe(e, t) }, foreground: function (e, t) { e("class", "foreground"), e("aria-hidden", !0), t.strokeForeground ? zfe(e, t) : e("d", "") } }, Wfe = { xmlns: "http://www.w3.org/2000/svg", "xmlns:xlink": "http://www.w3.org/1999/xlink", version: "1.1" }; function Vfe(e, t) { var n = e.image; return (!n || e.url && e.url !== n.url) && (n = { complete: !1, width: 0, height: 0 }, t.loadImage(e.url).then((t => { e.image = t, e.image.url = e.url }))), n } function Gfe(e, t) { return null != e.width ? e.width : t && t.width ? !1 !== e.aspect && e.height ? e.height * t.width / t.height : t.width : 0 } function Hfe(e, t) { return null != e.height ? e.height : t && t.height ? !1 !== e.aspect && e.width ? e.width * t.height / t.width : t.height : 0 } function qfe(e, t) { return "center" === e ? t / 2 : "right" === e ? t : 0 } function Yfe(e, t) { return "middle" === e ? t / 2 : "bottom" === e ? t : 0 } var Xfe = { type: "image", tag: "image", nested: !1, attr: function (e, t, n) { const r = Vfe(t, n), i = Gfe(t, r), a = Hfe(t, r), o = (t.x || 0) - qfe(t.align, i), s = (t.y || 0) - Yfe(t.baseline, a); e("href", !r.src && r.toDataURL ? r.toDataURL() : r.src || "", Wfe["xmlns:xlink"], "xlink:href"), e("transform", Efe(o, s)), e("width", i), e("height", a), e("preserveAspectRatio", !1 === t.aspect ? "none" : "xMidYMid") }, bound: function (e, t) { const n = t.image, r = Gfe(t, n), i = Hfe(t, n), a = (t.x || 0) - qfe(t.align, r), o = (t.y || 0) - Yfe(t.baseline, i); return e.set(a, o, a + r, o + i) }, draw: function (e, t, n) { xfe(t, (t => { if (n && !n.intersects(t.bounds)) return; const r = Vfe(t, this); let i = Gfe(t, r), a = Hfe(t, r); if (0 === i || 0 === a) return; let o, s, u, l, c = (t.x || 0) - qfe(t.align, i), h = (t.y || 0) - Yfe(t.baseline, a); !1 !== t.aspect && (s = r.width / r.height, u = t.width / t.height, s == s && u == u && s !== u && (u < s ? (l = i / s, h += (a - l) / 2, a = l) : (l = a * s, c += (i - l) / 2, i = l))), (r.complete || r.toDataURL) && (hfe(e, t), e.globalAlpha = null != (o = t.opacity) ? o : 1, e.imageSmoothingEnabled = !1 !== t.smooth, e.drawImage(r, c, h, i, a)) })) }, pick: Cfe(), isect: Cae, get: Vfe, xOffset: qfe, yOffset: Yfe }, Kfe = Dfe("line", (function (e, t) { const n = t[0], r = n.interpolate || "linear"; return kde.curve(Bhe(r, n.orient, n.tension)).context(e)(t) }), (function (e, t) { for (var n, r, i = Math.pow(e[0].strokeWidth || 1, 2), a = e.length; --a >= 0;)if (!1 !== e[a].defined && (n = e[a].x - t[0]) * n + (r = e[a].y - t[1]) * r < i) return e[a]; return null })); function Zfe(e, t) { var n = t.path; if (null == n) return !0; var r = t.x || 0, i = t.y || 0, a = t.scaleX || 1, o = t.scaleY || 1, s = (t.angle || 0) * Hhe, u = t.pathCache; u && u.path === n || ((t.pathCache = u = Ghe(n)).path = n), s && e.rotate && e.translate ? (e.translate(r, i), e.rotate(s), nde(e, u, 0, 0, a, o), e.rotate(-s), e.translate(-r, -i)) : nde(e, u, r, i, a, o) } var Jfe = { type: "path", tag: "path", nested: !1, attr: function (e, t) { var n = t.scaleX || 1, r = t.scaleY || 1; 1 === n && 1 === r || e("vector-effect", "non-scaling-stroke"), e("transform", function (e) { return Efe(e.x || 0, e.y || 0) + (e.angle ? " " + Nfe(e.angle) : "") + (e.scaleX || e.scaleY ? " " + function (e, t) { return "scale(" + e + "," + t + ")" }(e.scaleX || 1, e.scaleY || 1) : "") }(t)), e("d", t.path) }, bound: function (e, t) { return Zfe(efe(e, t.angle), t) ? e.set(0, 0, 0, 0) : Ode(e, t, !0) }, draw: kfe(Zfe), pick: Tfe(Zfe), isect: sfe(Zfe) }; function Qfe(e, t) { e.beginPath(), Tde(e, t) } var epe = { type: "rect", tag: "path", nested: !1, attr: function (e, t) { e("d", Tde(null, t)) }, bound: function (e, t) { var n, r; return Ode(e.set(n = t.x || 0, r = t.y || 0, n + t.width || 0, r + t.height || 0), t) }, draw: kfe(Qfe), pick: Tfe(Qfe), isect: lfe }; function tpe(e, t, n) { var r, i, a, o; return !(!t.stroke || !yfe(e, t, n)) && (r = t.x || 0, i = t.y || 0, a = null != t.x2 ? t.x2 : r, o = null != t.y2 ? t.y2 : i, e.beginPath(), e.moveTo(r, i), e.lineTo(a, o), !0) } var npe = { type: "rule", tag: "line", nested: !1, attr: function (e, t) { e("transform", Ife(t)), e("x2", null != t.x2 ? t.x2 - (t.x || 0) : 0), e("y2", null != t.y2 ? t.y2 - (t.y || 0) : 0) }, bound: function (e, t) { var n, r; return Ode(e.set(n = t.x || 0, r = t.y || 0, null != t.x2 ? t.x2 : n, null != t.y2 ? t.y2 : r), t) }, draw: function (e, t, n) { xfe(t, (t => { if (!n || n.intersects(t.bounds)) { var r = null == t.opacity ? 1 : t.opacity; r && tpe(e, t, r) && (hfe(e, t), e.stroke()) } })) }, pick: Cfe((function (e, t, n, r) { return !!e.isPointInStroke && (tpe(e, t, 1) && e.isPointInStroke(n, r)) })), isect: function (e, t) { const n = e.x || 0, r = e.y || 0; return cfe(t, n, r, null != e.x2 ? e.x2 : n, null != e.y2 ? e.y2 : r) } }, rpe = Mfe("shape", (function (e, t) { return (t.mark.shape || t.shape).context(e)(t) })), ipe = Mfe("symbol", (function (e, t) { return _de.context(e)(t) }), ufe); const ape = function (e) { let t, n, r; e = +e || 1e4; const i = () => { t = {}, n = {}, r = 0 }, a = (i, a) => (++r > e && (n = t, t = {}, r = 1), t[i] = a); return i(), { clear: i, has: e => jae(t, e) || jae(n, e), get: e => jae(t, e) ? t[e] : jae(n, e) ? a(e, n[e]) : void 0, set: (e, n) => jae(t, e) ? t[e] = n : a(e, n) } }(); var ope = { height: dpe, measureWidth: cpe, estimateWidth: upe, width: upe, canvas: spe }; function spe(e) { ope.width = e && afe ? cpe : upe } function upe(e, t) { return lpe(mpe(e, t), dpe(e)) } function lpe(e, t) { return ~~(.8 * e.length * t) } function cpe(e, t) { return dpe(e) <= 0 || !(t = mpe(e, t)) ? 0 : hpe(t, ype(e)) } function hpe(e, t) { const n = `(${t}) ${e}`; let r = ape.get(n); return void 0 === r && (afe.font = t, r = afe.measureText(e).width, ape.set(n, r)), r } function dpe(e) { return null != e.fontSize ? +e.fontSize || 0 : 11 } function fpe(e) { return null != e.lineHeight ? e.lineHeight : dpe(e) + 2 } function ppe(e) { return t = e.lineBreak && e.text && !Aae(e.text) ? e.text.split(e.lineBreak) : e.text, Aae(t) ? t.length > 1 ? t : t[0] : t; var t } function mpe(e, t) { const n = null == t ? "" : (t + "").trim(); return e.limit > 0 && n.length ? function (e, t) { var n = +e.limit, r = function (e) { if (ope.width === cpe) { const t = ype(e); return e => hpe(e, t) } if (ope.width === upe) { const t = dpe(e); return e => lpe(e, t) } return t => ope.width(e, t) }(e); if (r(t) < n) return t; var i, a = e.ellipsis || "…", o = "rtl" === e.dir, s = 0, u = t.length; if (n -= r(a), o) { for (; s < u;)i = s + u >>> 1, r(t.slice(i)) > n ? s = i + 1 : u = i; return a + t.slice(s) } for (; s < u;)i = 1 + (s + u >>> 1), r(t.slice(0, i)) < n ? s = i : u = i - 1; return t.slice(0, s) + a }(e, n) : n } function gpe(e, t) { var n = e.font; return (t && n ? String(n).replace(/"/g, "'") : n) || "sans-serif" } function ype(e, t) { return (e.fontStyle ? e.fontStyle + " " : "") + (e.fontVariant ? e.fontVariant + " " : "") + (e.fontWeight ? e.fontWeight + " " : "") + dpe(e) + "px " + gpe(e, t) } function bpe(e) { var t = e.baseline, n = dpe(e); return Math.round("top" === t ? .79 * n : "middle" === t ? .3 * n : "bottom" === t ? -.21 * n : "line-top" === t ? .29 * n + .5 * fpe(e) : "line-bottom" === t ? .29 * n - .5 * fpe(e) : 0) } spe(!0); const vpe = { left: "start", center: "middle", right: "end" }, xpe = new Ide; function wpe(e) { var t, n = e.x || 0, r = e.y || 0, i = e.radius || 0; return i && (t = (e.theta || 0) - qhe, n += i * Math.cos(t), r += i * Math.sin(t)), xpe.x1 = n, xpe.y1 = r, xpe } function kpe(e, t, n) { var r, i = ope.height(t), a = t.align, o = wpe(t), s = o.x1, u = o.y1, l = t.dx || 0, c = (t.dy || 0) + bpe(t) - Math.round(.8 * i), h = ppe(t); if (Aae(h) ? (i += fpe(t) * (h.length - 1), r = h.reduce(((e, n) => Math.max(e, ope.width(t, n))), 0)) : r = ope.width(t, h), "center" === a ? l -= r / 2 : "right" === a && (l -= r), e.set(l += s, c += u, l + r, c + i), t.angle && !n) e.rotate(t.angle * Hhe, s, u); else if (2 === n) return e.rotatedPoints(t.angle * Hhe, s, u); return e } var Spe = { type: "text", tag: "text", nested: !1, attr: function (e, t) { var n, r = t.dx || 0, i = (t.dy || 0) + bpe(t), a = wpe(t), o = a.x1, s = a.y1, u = t.angle || 0; e("text-anchor", vpe[t.align] || "start"), u ? (n = Efe(o, s) + " " + Nfe(u), (r || i) && (n += " " + Efe(r, i))) : n = Efe(o + r, s + i), e("transform", n) }, bound: kpe, draw: function (e, t, n) { xfe(t, (t => { var r, i, a, o, s, u, l, c = null == t.opacity ? 1 : t.opacity; if (!(n && !n.intersects(t.bounds) || 0 === c || t.fontSize <= 0 || null == t.text || 0 === t.text.length)) { if (e.font = ype(t), e.textAlign = t.align || "left", i = (r = wpe(t)).x1, a = r.y1, t.angle && (e.save(), e.translate(i, a), e.rotate(t.angle * Hhe), i = a = 0), i += t.dx || 0, a += (t.dy || 0) + bpe(t), u = ppe(t), hfe(e, t), Aae(u)) for (s = fpe(t), o = 0; o < u.length; ++o)l = mpe(t, u[o]), t.fill && mfe(e, t, c) && e.fillText(l, i, a), t.stroke && yfe(e, t, c) && e.strokeText(l, i, a), a += s; else l = mpe(t, u), t.fill && mfe(e, t, c) && e.fillText(l, i, a), t.stroke && yfe(e, t, c) && e.strokeText(l, i, a); t.angle && e.restore() } })) }, pick: Cfe((function (e, t, n, r, i, a) { if (t.fontSize <= 0) return !1; if (!t.angle) return !0; var o = wpe(t), s = o.x1, u = o.y1, l = kpe(xpe, t, 1), c = -t.angle * Hhe, h = Math.cos(c), d = Math.sin(c), f = h * i - d * a + (s - h * s + d * u), p = d * i + h * a + (u - d * s - h * u); return l.contains(f, p) })), isect: function (e, t) { const n = kpe(xpe, e, 2); return cfe(t, n[0], n[1], n[2], n[3]) || cfe(t, n[0], n[1], n[4], n[5]) || cfe(t, n[4], n[5], n[6], n[7]) || cfe(t, n[2], n[3], n[6], n[7]) } }, _pe = Dfe("trail", (function (e, t) { return Cde.context(e)(t) }), (function (e, t) { for (var n, r, i = e.length; --i >= 0;)if (!1 !== e[i].defined && (n = e[i].x - t[0]) * n + (r = e[i].y - t[1]) * r < (n = e[i].size || 1) * n) return e[i]; return null })), Cpe = { arc: Ffe, area: $fe, group: Ufe, image: Xfe, line: Kfe, path: Jfe, rect: epe, rule: npe, shape: rpe, symbol: ipe, text: Spe, trail: _pe }; function Ape(e, t, n) { return !e && "undefined" != typeof document && document.createElement && (e = document), e ? n ? e.createElementNS(n, t) : e.createElement(t) : null } function Tpe(e, t) { t = t.toLowerCase(); for (var n = e.childNodes, r = 0, i = n.length; r < i; ++r)if (n[r].tagName.toLowerCase() === t) return n[r] } function Epe(e, t, n, r) { var i, a = e.childNodes[t]; return a && a.tagName.toLowerCase() === n.toLowerCase() || (i = a || null, a = Ape(e.ownerDocument, n, r), e.insertBefore(a, i)), a } function Npe(e, t) { for (var n = e.childNodes, r = n.length; r > t;)e.removeChild(n[--r]); return e } function Ipe(e) { return "mark-" + e.marktype + (e.role ? " role-" + e.role : "") + (e.name ? " " + e.name : "") } function Mpe(e, t) { const n = t.getBoundingClientRect(); return [e.clientX - n.left - (t.clientLeft || 0), e.clientY - n.top - (t.clientTop || 0)] } class Fpe { constructor(e, t) { this._active = null, this._handlers = {}, this._loader = e || Fhe(), this._tooltip = t || Dpe } initialize(e, t, n) { return this._el = e, this._obj = n || null, this.origin(t) } element() { return this._el } canvas() { return this._el && this._el.firstChild } origin(e) { return arguments.length ? (this._origin = e || [0, 0], this) : this._origin.slice() } scene(e) { return arguments.length ? (this._scene = e, this) : this._scene } on() { } off() { } _handlerIndex(e, t, n) { for (let r = e ? e.length : 0; --r >= 0;)if (e[r].type === t && (!n || e[r].handler === n)) return r; return -1 } handlers(e) { const t = this._handlers, n = []; if (e) n.push(...t[this.eventName(e)]); else for (const e in t) n.push(...t[e]); return n } eventName(e) { const t = e.indexOf("."); return t < 0 ? e : e.slice(0, t) } handleHref(e, t, n) { this._loader.sanitize(n, { context: "href" }).then((t => { const n = new MouseEvent(e.type, e), r = Ape(null, "a"); for (const e in t) r.setAttribute(e, t[e]); r.dispatchEvent(n) })).catch((() => { })) } handleTooltip(e, t, n) { if (t && null != t.tooltip) { t = function (e, t, n, r) { var i, a, o = e && e.mark; if (o && (i = Cpe[o.marktype]).tip) { for ((a = Mpe(t, n))[0] -= r[0], a[1] -= r[1]; e = e.mark.group;)a[0] -= e.x || 0, a[1] -= e.y || 0; e = i.tip(o.items, a) } return e }(t, e, this.canvas(), this._origin); const r = n && t && t.tooltip || null; this._tooltip.call(this._obj, this, e, t, r) } } getItemBoundingClientRect(e) { const t = this.canvas(); if (!t) return; const n = t.getBoundingClientRect(), r = this._origin, i = e.bounds, a = i.width(), o = i.height(); let s = i.x1 + r[0] + n.left, u = i.y1 + r[1] + n.top; for (; e.mark && (e = e.mark.group);)s += e.x || 0, u += e.y || 0; return { x: s, y: u, width: a, height: o, left: s, top: u, right: s + a, bottom: u + o } } } function Dpe(e, t, n, r) { e.element().setAttribute("title", r || "") } class $pe { constructor(e) { this._el = null, this._bgcolor = null, this._loader = new Dde(e) } initialize(e, t, n, r, i) { return this._el = e, this.resize(t, n, r, i) } element() { return this._el } canvas() { return this._el && this._el.firstChild } background(e) { return 0 === arguments.length ? this._bgcolor : (this._bgcolor = e, this) } resize(e, t, n, r) { return this._width = e, this._height = t, this._origin = n || [0, 0], this._scale = r || 1, this } dirty() { } render(e, t) { const n = this; return n._call = function () { n._render(e, t) }, n._call(), n._call = null, n } _render() { } renderAsync(e, t) { const n = this.render(e, t); return this._ready ? this._ready.then((() => n)) : Promise.resolve(n) } _load(e, t) { var n = this, r = n._loader[e](t); if (!n._ready) { const e = n._call; n._ready = n._loader.ready().then((t => { t && e(), n._ready = null })) } return r } sanitizeURL(e) { return this._load("sanitizeURL", e) } loadImage(e) { return this._load("loadImage", e) } } const Rpe = "dragenter", Ope = "dragleave", zpe = "dragover", Ppe = "pointerdown", Bpe = "pointermove", Lpe = "pointerout", jpe = "pointerover", Upe = "mousedown", Wpe = "mousemove", Vpe = "mouseout", Gpe = "mouseover", Hpe = "click", qpe = "mousewheel", Ype = "touchstart", Xpe = "touchmove", Kpe = "touchend", Zpe = ["keydown", "keypress", "keyup", Rpe, Ope, zpe, Ppe, "pointerup", Bpe, Lpe, jpe, Upe, "mouseup", Wpe, Vpe, Gpe, Hpe, "dblclick", "wheel", qpe, Ype, Xpe, Kpe], Jpe = Bpe, Qpe = Vpe, eme = Hpe; class tme extends Fpe { constructor(e, t) { super(e, t), this._down = null, this._touch = null, this._first = !0, this._events = {}, this.events = Zpe, this.pointermove = ame([Bpe, Wpe], [jpe, Gpe], [Lpe, Vpe]), this.dragover = ame([zpe], [Rpe], [Ope]), this.pointerout = ome([Lpe, Vpe]), this.dragleave = ome([Ope]) } initialize(e, t, n) { return this._canvas = e && Tpe(e, "canvas"), [Hpe, Upe, Ppe, Bpe, Lpe, Ope].forEach((e => rme(this, e))), super.initialize(e, t, n) } canvas() { return this._canvas } context() { return this._canvas.getContext("2d") } DOMMouseScroll(e) { this.fire(qpe, e) } pointerdown(e) { this._down = this._active, this.fire(Ppe, e) } mousedown(e) { this._down = this._active, this.fire(Upe, e) } click(e) { this._down === this._active && (this.fire(Hpe, e), this._down = null) } touchstart(e) { this._touch = this.pickEvent(e.changedTouches[0]), this._first && (this._active = this._touch, this._first = !1), this.fire(Ype, e, !0) } touchmove(e) { this.fire(Xpe, e, !0) } touchend(e) { this.fire(Kpe, e, !0), this._touch = null } fire(e, t, n) { const r = n ? this._touch : this._active, i = this._handlers[e]; if (t.vegaType = e, e === eme && r && r.href ? this.handleHref(t, r, r.href) : e !== Jpe && e !== Qpe || this.handleTooltip(t, r, e !== Qpe), i) for (let e = 0, n = i.length; e < n; ++e)i[e].handler.call(this._obj, t, r) } on(e, t) { const n = this.eventName(e), r = this._handlers; return this._handlerIndex(r[n], e, t) < 0 && (rme(this, e), (r[n] || (r[n] = [])).push({ type: e, handler: t })), this } off(e, t) { const n = this.eventName(e), r = this._handlers[n], i = this._handlerIndex(r, e, t); return i >= 0 && r.splice(i, 1), this } pickEvent(e) { const t = Mpe(e, this._canvas), n = this._origin; return this.pick(this._scene, t[0], t[1], t[0] - n[0], t[1] - n[1]) } pick(e, t, n, r, i) { const a = this.context(); return Cpe[e.marktype].pick.call(this, a, e, t, n, r, i) } } const nme = e => e === Ype || e === Xpe || e === Kpe ? [Ype, Xpe, Kpe] : [e]; function rme(e, t) { nme(t).forEach((t => function (e, t) { const n = e.canvas(); n && !e._events[t] && (e._events[t] = 1, n.addEventListener(t, e[t] ? n => e[t](n) : n => e.fire(t, n))) }(e, t))) } function ime(e, t, n) { t.forEach((t => e.fire(t, n))) } function ame(e, t, n) { return function (r) { const i = this._active, a = this.pickEvent(r); a === i || (i && i.exit || ime(this, n, r), this._active = a, ime(this, t, r)), ime(this, e, r) } } function ome(e) { return function (t) { ime(this, e, t), this._active = null } } function sme(e, t, n, r, i, a) { const o = "undefined" != typeof HTMLElement && e instanceof HTMLElement && null != e.parentNode, s = e.getContext("2d"), u = o ? "undefined" != typeof window && window.devicePixelRatio || 1 : i; e.width = t * u, e.height = n * u; for (const e in a) s[e] = a[e]; return o && 1 !== u && (e.style.width = t + "px", e.style.height = n + "px"), s.pixelRatio = u, s.setTransform(u, 0, 0, u, u * r[0], u * r[1]), e } class ume extends $pe { constructor(e) { super(e), this._options = {}, this._redraw = !1, this._dirty = new Ide, this._tempb = new Ide } initialize(e, t, n, r, i, a) { return this._options = a || {}, this._canvas = this._options.externalContext ? null : Fd(1, 1, this._options.type), e && this._canvas && (Npe(e, 0).appendChild(this._canvas), this._canvas.setAttribute("class", "marks")), super.initialize(e, t, n, r, i) } resize(e, t, n, r) { if (super.resize(e, t, n, r), this._canvas) sme(this._canvas, this._width, this._height, this._origin, this._scale, this._options.context); else { const e = this._options.externalContext; e || wae("CanvasRenderer is missing a valid canvas or context"), e.scale(this._scale, this._scale), e.translate(this._origin[0], this._origin[1]) } return this._redraw = !0, this } canvas() { return this._canvas } context() { return this._options.externalContext || (this._canvas ? this._canvas.getContext("2d") : null) } dirty(e) { const t = this._tempb.clear().union(e.bounds); let n = e.mark.group; for (; n;)t.translate(n.x || 0, n.y || 0), n = n.mark.group; this._dirty.union(t) } _render(e, t) { const n = this.context(), r = this._origin, i = this._width, a = this._height, o = this._dirty, s = lme(r, i, a); n.save(); const u = this._redraw || o.empty() ? (this._redraw = !1, s.expand(1)) : function (e, t, n) { t.expand(1).round(), e.pixelRatio % 1 && t.scale(e.pixelRatio).round().scale(1 / e.pixelRatio); return t.translate(-n[0] % 1, -n[1] % 1), e.beginPath(), e.rect(t.x1, t.y1, t.width(), t.height()), e.clip(), t }(n, s.intersect(o), r); return this.clear(-r[0], -r[1], i, a), this.draw(n, e, u, t), n.restore(), o.clear(), this } draw(e, t, n, r) { if ("group" !== t.marktype && null != r && !r.includes(t.marktype)) return; const i = Cpe[t.marktype]; t.clip && function (e, t) { var n = t.clip; e.save(), Pae(n) ? (e.beginPath(), n(e), e.clip()) : Rfe(e, t.group) }(e, t), i.draw.call(this, e, t, n, r), t.clip && e.restore() } clear(e, t, n, r) { const i = this._options, a = this.context(); "pdf" === i.type || i.externalContext || a.clearRect(e, t, n, r), null != this._bgcolor && (a.fillStyle = this._bgcolor, a.fillRect(e, t, n, r)) } } const lme = (e, t, n) => (new Ide).set(0, 0, t, n).translate(-e[0], -e[1]); const cme = (e, t) => n => { let r = n.target.__data__; r = Array.isArray(r) ? r[0] : r, n.vegaType = n.type, t.call(e._obj, n, r) }, hme = "aria-hidden", dme = "aria-label", fme = "role", pme = "aria-roledescription", mme = "graphics-object", gme = "graphics-symbol", yme = (e, t, n) => ({ [fme]: e, [pme]: t, [dme]: n || void 0 }), bme = Zae(["axis-domain", "axis-grid", "axis-label", "axis-tick", "axis-title", "legend-band", "legend-entry", "legend-gradient", "legend-label", "legend-title", "legend-symbol", "title"]), vme = { axis: { desc: "axis", caption: function (e) { const t = e.datum, n = e.orient, r = t.title ? _me(e) : null, i = e.context, a = i.scales[t.scale].value, o = i.dataflow.locale(), s = a.type, u = "left" === n || "right" === n ? "Y" : "X"; return `${u}-axis` + (r ? ` titled '${r}'` : "") + ` for a ${Dce(s) ? "discrete" : s} scale` + ` with ${rhe(o, a, e)}` } }, legend: { desc: "legend", caption: function (e) { const t = e.datum, n = t.title ? _me(e) : null, r = `${t.type || ""} legend`.trim(), i = t.scales, a = Object.keys(i), o = e.context, s = o.scales[i[a[0]]].value, u = o.dataflow.locale(); return function (e) { return e.length ? e[0].toUpperCase() + e.slice(1) : e }(r) + (n ? ` titled '${n}'` : "") + ` for ${function (e) { return e = e.map((e => e + ("fill" === e || "stroke" === e ? " color" : ""))), e.length < 2 ? e[0] : e.slice(0, -1).join(", ") + " and " + Eae(e) }(a)}` + ` with ${rhe(u, s, e)}` } }, "title-text": { desc: "title", caption: e => `Title text '${Sme(e)}'` }, "title-subtitle": { desc: "subtitle", caption: e => `Subtitle text '${Sme(e)}'` } }, xme = { ariaRole: fme, ariaRoleDescription: pme, description: dme }; function wme(e, t) { const n = !1 === t.aria; if (e(hme, n || void 0), n || null == t.description) for (const t in xme) e(xme[t], void 0); else { const n = t.mark.marktype; e(dme, t.description), e(fme, t.ariaRole || ("group" === n ? mme : gme)), e(pme, t.ariaRoleDescription || `${n} mark`) } } function kme(e) { return !1 === e.aria ? { [hme]: !0 } : bme[e.role] ? null : vme[e.role] ? function (e, t) { try { const n = e.items[0], r = t.caption || (() => ""); return yme(t.role || gme, t.desc, n.description || r(n)) } catch (e) { return null } }(e, vme[e.role]) : function (e) { const t = e.marktype, n = "group" === t || "text" === t || e.items.some((e => null != e.description && !1 !== e.aria)); return yme(n ? mme : gme, `${t} mark container`, e.description) }(e) } function Sme(e) { return zae(e.text).join(" ") } function _me(e) { try { return zae(Eae(e.items).items[0].text).join(" ") } catch (e) { return null } } const Cme = e => (e + "").replace(/&/g, "&").replace(//g, ">"); function Ame() { let e = "", t = "", n = ""; const r = [], i = () => t = n = "", a = (e, n) => { var r; return null != n && (t += ` ${e}="${r = n, Cme(r).replace(/"/g, """).replace(/\t/g, " ").replace(/\n/g, " ").replace(/\r/g, " ")}"`), o }, o = { open(s) { (a => { t && (e += `${t}>${n}`, i()), r.push(a) })(s), t = "<" + s; for (var u = arguments.length, l = new Array(u > 1 ? u - 1 : 0), c = 1; c < u; c++)l[c - 1] = arguments[c]; for (const e of l) for (const t in e) a(t, e[t]); return o }, close() { const a = r.pop(); return e += t ? t + (n ? `>${n}` : "/>") : ``, i(), o }, attr: a, text: e => (n += Cme(e), o), toString: () => e }; return o } const Tme = e => Eme(Ame(), e) + ""; function Eme(e, t) { if (e.open(t.tagName), t.hasAttributes()) { const n = t.attributes, r = n.length; for (let t = 0; t < r; ++t)e.attr(n[t].name, n[t].value) } if (t.hasChildNodes()) { const n = t.childNodes; for (const t of n) 3 === t.nodeType ? e.text(t.nodeValue) : Eme(e, t) } return e.close() } const Nme = { fill: "fill", fillOpacity: "fill-opacity", stroke: "stroke", strokeOpacity: "stroke-opacity", strokeWidth: "stroke-width", strokeCap: "stroke-linecap", strokeJoin: "stroke-linejoin", strokeDash: "stroke-dasharray", strokeDashOffset: "stroke-dashoffset", strokeMiterLimit: "stroke-miterlimit", opacity: "opacity" }, Ime = { blend: "mix-blend-mode" }, Mme = { fill: "none", "stroke-miterlimit": 10 }, Fme = "http://www.w3.org/2000/xmlns/", Dme = Wfe.xmlns; class $me extends $pe { constructor(e) { super(e), this._dirtyID = 0, this._dirty = [], this._svg = null, this._root = null, this._defs = null } initialize(e, t, n, r, i) { return this._defs = {}, this._clearDefs(), e && (this._svg = Epe(e, 0, "svg", Dme), this._svg.setAttributeNS(Fme, "xmlns", Dme), this._svg.setAttributeNS(Fme, "xmlns:xlink", Wfe["xmlns:xlink"]), this._svg.setAttribute("version", Wfe.version), this._svg.setAttribute("class", "marks"), Npe(e, 1), this._root = Epe(this._svg, 0, "g", Dme), Vme(this._root, Mme), Npe(this._svg, 1)), this.background(this._bgcolor), super.initialize(e, t, n, r, i) } background(e) { return arguments.length && this._svg && this._svg.style.setProperty("background-color", e), super.background(...arguments) } resize(e, t, n, r) { return super.resize(e, t, n, r), this._svg && (Vme(this._svg, { width: this._width * this._scale, height: this._height * this._scale, viewBox: `0 0 ${this._width} ${this._height}` }), this._root.setAttribute("transform", `translate(${this._origin})`)), this._dirty = [], this } canvas() { return this._svg } svg() { const e = this._svg, t = this._bgcolor; if (!e) return null; let n; t && (e.removeAttribute("style"), n = Epe(e, 0, "rect", Dme), Vme(n, { width: this._width, height: this._height, fill: t })); const r = Tme(e); return t && (e.removeChild(n), this._svg.style.setProperty("background-color", t)), r } _render(e, t) { return this._dirtyCheck() && (this._dirtyAll && this._clearDefs(), this.mark(this._root, e, void 0, t), Npe(this._root, 1)), this.defs(), this._dirty = [], ++this._dirtyID, this } dirty(e) { e.dirty !== this._dirtyID && (e.dirty = this._dirtyID, this._dirty.push(e)) } isDirty(e) { return this._dirtyAll || !e._svg || !e._svg.ownerSVGElement || e.dirty === this._dirtyID } _dirtyCheck() { this._dirtyAll = !0; const e = this._dirty; if (!e.length || !this._dirtyID) return !0; const t = ++this._dirtyID; let n, r, i, a, o, s, u; for (o = 0, s = e.length; o < s; ++o)n = e[o], r = n.mark, r.marktype !== i && (i = r.marktype, a = Cpe[i]), r.zdirty && r.dirty !== t && (this._dirtyAll = !1, Rme(n, t), r.items.forEach((e => { e.dirty = t }))), r.zdirty || (n.exit ? (a.nested && r.items.length ? (u = r.items[0], u._svg && this._update(a, u._svg, u)) : n._svg && (u = n._svg.parentNode, u && u.removeChild(n._svg)), n._svg = null) : (n = a.nested ? r.items[0] : n, n._update !== t && (n._svg && n._svg.ownerSVGElement ? this._update(a, n._svg, n) : (this._dirtyAll = !1, Rme(n, t)), n._update = t))); return !this._dirtyAll } mark(e, t, n, r) { if (!this.isDirty(t)) return t._svg; const i = this._svg, a = t.marktype, o = Cpe[a], s = !1 === t.interactive ? "none" : null, u = "g" === o.tag, l = Pme(t, e, n, "g", i); if ("group" !== a && null != r && !r.includes(a)) return Npe(l, 0), t._svg; l.setAttribute("class", Ipe(t)); const c = kme(t); for (const e in c) Gme(l, e, c[e]); u || Gme(l, "pointer-events", s), Gme(l, "clip-path", t.clip ? Nde(this, t, t.group) : null); let h = null, d = 0; const f = e => { const t = this.isDirty(e), n = Pme(e, l, h, o.tag, i); t && (this._update(o, n, e), u && function (e, t, n, r) { t = t.lastChild.previousSibling; let i, a = 0; xfe(n, (n => { i = e.mark(t, n, i, r), ++a })), Npe(t, 1 + a) }(this, n, e, r)), h = n, ++d }; return o.nested ? t.items.length && f(t.items[0]) : xfe(t, f), Npe(l, d), l } _update(e, t, n) { Bme = t, Lme = t.__values__, wme(Ume, n), e.attr(Ume, n, this); const r = jme[e.type]; r && r.call(this, e, t, n), Bme && this.style(Bme, n) } style(e, t) { if (null != t) { for (const n in Nme) { let r = "font" === n ? gpe(t) : t[n]; if (r === Lme[n]) continue; const i = Nme[n]; null == r ? e.removeAttribute(i) : (Rhe(r) && (r = Ohe(r, this._defs.gradient, Hme())), e.setAttribute(i, r + "")), Lme[n] = r } for (const n in Ime) Wme(e, Ime[n], t[n]) } } defs() { const e = this._svg, t = this._defs; let n = t.el, r = 0; for (const i in t.gradient) n || (t.el = n = Epe(e, 1, "defs", Dme)), r = Ome(n, t.gradient[i], r); for (const i in t.clipping) n || (t.el = n = Epe(e, 1, "defs", Dme)), r = zme(n, t.clipping[i], r); n && (0 === r ? (e.removeChild(n), t.el = null) : Npe(n, r)) } _clearDefs() { const e = this._defs; e.gradient = {}, e.clipping = {} } } function Rme(e, t) { for (; e && e.dirty !== t; e = e.mark.group) { if (e.dirty = t, !e.mark || e.mark.dirty === t) return; e.mark.dirty = t } } function Ome(e, t, n) { let r, i, a; if ("radial" === t.gradient) { let r = Epe(e, n++, "pattern", Dme); Vme(r, { id: $he + t.id, viewBox: "0,0,1,1", width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }), r = Epe(r, 0, "rect", Dme), Vme(r, { width: 1, height: 1, fill: `url(${Hme()}#${t.id})` }), Vme(e = Epe(e, n++, "radialGradient", Dme), { id: t.id, fx: t.x1, fy: t.y1, fr: t.r1, cx: t.x2, cy: t.y2, r: t.r2 }) } else Vme(e = Epe(e, n++, "linearGradient", Dme), { id: t.id, x1: t.x1, x2: t.x2, y1: t.y1, y2: t.y2 }); for (r = 0, i = t.stops.length; r < i; ++r)a = Epe(e, r, "stop", Dme), a.setAttribute("offset", t.stops[r].offset), a.setAttribute("stop-color", t.stops[r].color); return Npe(e, r), n } function zme(e, t, n) { let r; return (e = Epe(e, n, "clipPath", Dme)).setAttribute("id", t.id), t.path ? (r = Epe(e, 0, "path", Dme), r.setAttribute("d", t.path)) : (r = Epe(e, 0, "rect", Dme), Vme(r, { x: 0, y: 0, width: t.width, height: t.height })), Npe(e, 1), n + 1 } function Pme(e, t, n, r, i) { let a, o = e._svg; if (!o && (a = t.ownerDocument, o = Ape(a, r, Dme), e._svg = o, e.mark && (o.__data__ = e, o.__values__ = { fill: "default" }, "g" === r))) { const t = Ape(a, "path", Dme); o.appendChild(t), t.__data__ = e; const n = Ape(a, "g", Dme); o.appendChild(n), n.__data__ = e; const r = Ape(a, "path", Dme); o.appendChild(r), r.__data__ = e, r.__values__ = { fill: "default" } } return (o.ownerSVGElement !== i || function (e, t) { return e.parentNode && e.parentNode.childNodes.length > 1 && e.previousSibling != t }(o, n)) && t.insertBefore(o, n ? n.nextSibling : t.firstChild), o } let Bme = null, Lme = null; const jme = { group(e, t, n) { const r = Bme = t.childNodes[2]; Lme = r.__values__, e.foreground(Ume, n, this), Lme = t.__values__, Bme = t.childNodes[1], e.content(Ume, n, this); const i = Bme = t.childNodes[0]; e.background(Ume, n, this); const a = !1 === n.mark.interactive ? "none" : null; if (a !== Lme.events && (Gme(r, "pointer-events", a), Gme(i, "pointer-events", a), Lme.events = a), n.strokeForeground && n.stroke) { const e = n.fill; Gme(r, "display", null), this.style(i, n), Gme(i, "stroke", null), e && (n.fill = null), Lme = r.__values__, this.style(r, n), e && (n.fill = e), Bme = null } else Gme(r, "display", "none") }, image(e, t, n) { !1 === n.smooth ? (Wme(t, "image-rendering", "optimizeSpeed"), Wme(t, "image-rendering", "pixelated")) : Wme(t, "image-rendering", null) }, text(e, t, n) { const r = ppe(n); let i, a, o, s; Aae(r) ? (a = r.map((e => mpe(n, e))), i = a.join("\n"), i !== Lme.text && (Npe(t, 0), o = t.ownerDocument, s = fpe(n), a.forEach(((e, r) => { const i = Ape(o, "tspan", Dme); i.__data__ = n, i.textContent = e, r && (i.setAttribute("x", 0), i.setAttribute("dy", s)), t.appendChild(i) })), Lme.text = i)) : (a = mpe(n, r), a !== Lme.text && (t.textContent = a, Lme.text = a)), Gme(t, "font-family", gpe(n)), Gme(t, "font-size", dpe(n) + "px"), Gme(t, "font-style", n.fontStyle), Gme(t, "font-variant", n.fontVariant), Gme(t, "font-weight", n.fontWeight) } }; function Ume(e, t, n) { t !== Lme[e] && (n ? function (e, t, n, r) { null != n ? e.setAttributeNS(r, t, n) : e.removeAttributeNS(r, t) }(Bme, e, t, n) : Gme(Bme, e, t), Lme[e] = t) } function Wme(e, t, n) { n !== Lme[t] && (null == n ? e.style.removeProperty(t) : e.style.setProperty(t, n + ""), Lme[t] = n) } function Vme(e, t) { for (const n in t) Gme(e, n, t[n]) } function Gme(e, t, n) { null != n ? e.setAttribute(t, n) : e.removeAttribute(t) } function Hme() { let e; return "undefined" == typeof window ? "" : (e = window.location).hash ? e.href.slice(0, -e.hash.length) : e.href } const qme = { svgMarkTypes: ["text"], svgOnTop: !0, debug: !1 }; class Yme extends $pe { constructor(e) { super(e), this._svgRenderer = new $me(e), this._canvasRenderer = new ume(e) } initialize(e, t, n, r, i) { this._root_el = Epe(e, 0, "div"); const a = Epe(this._root_el, 0, "div"), o = Epe(this._root_el, 1, "div"); return this._root_el.style.position = "relative", qme.debug || (a.style.height = "100%", o.style.position = "absolute", o.style.top = "0", o.style.left = "0", o.style.height = "100%", o.style.width = "100%"), this._svgEl = qme.svgOnTop ? o : a, this._canvasEl = qme.svgOnTop ? a : o, this._svgEl.style.pointerEvents = "none", this._canvasRenderer.initialize(this._canvasEl, t, n, r, i), this._svgRenderer.initialize(this._svgEl, t, n, r, i), super.initialize(e, t, n, r, i) } dirty(e) { return qme.svgMarkTypes.includes(e.mark.marktype) ? this._svgRenderer.dirty(e) : this._canvasRenderer.dirty(e), this } _render(e, t) { const n = (t ?? ["arc", "area", "image", "line", "path", "rect", "rule", "shape", "symbol", "text", "trail"]).filter((e => !qme.svgMarkTypes.includes(e))); this._svgRenderer.render(e, qme.svgMarkTypes), this._canvasRenderer.render(e, n) } resize(e, t, n, r) { return super.resize(e, t, n, r), this._svgRenderer.resize(e, t, n, r), this._canvasRenderer.resize(e, t, n, r), this } background(e) { return qme.svgOnTop ? this._canvasRenderer.background(e) : this._svgRenderer.background(e), this } } const Xme = "canvas", Kme = "hybrid", Zme = "none", Jme = {}; function Qme(e, t, n, r) { if (function (e, t, n) { return e.bounds && t.intersects(e.bounds) && ("group" === e.marktype || !1 !== e.interactive && (!n || n(e))) }(e, t, n)) { const i = e.items, a = e.marktype, o = i.length; let s = 0; if ("group" === a) for (; s < o; ++s)ege(i[s], t, n, r); else for (const e = Cpe[a].isect; s < o; ++s) { const n = i[s]; tge(n, t, e) && r.push(n) } } return r } function ege(e, t, n, r) { n && n(e.mark) && tge(e, t, Cpe.group.isect) && r.push(e); const i = e.items, a = i && i.length; if (a) { const o = e.x || 0, s = e.y || 0; t.translate(-o, -s); for (let e = 0; e < a; ++e)Qme(i[e], t, n, r); t.translate(o, s) } return r } function tge(e, t, n) { const r = e.bounds; return t.encloses(r) || t.intersects(r) && n(e, t) } Jme[Xme] = Jme.png = { renderer: ume, headless: ume, handler: tme }, Jme.svg = { renderer: $me, headless: class extends $pe { constructor(e) { super(e), this._text = null, this._defs = { gradient: {}, clipping: {} } } svg() { return this._text } _render(e) { const t = Ame(); t.open("svg", Bae({}, Wfe, { class: "marks", width: this._width * this._scale, height: this._height * this._scale, viewBox: `0 0 ${this._width} ${this._height}` })); const n = this._bgcolor; return n && "transparent" !== n && "none" !== n && t.open("rect", { width: this._width, height: this._height, fill: n }).close(), t.open("g", Mme, { transform: "translate(" + this._origin + ")" }), this.mark(t, e), t.close(), this.defs(t), this._text = t.close() + "", this } mark(e, t) { const n = Cpe[t.marktype], r = n.tag, i = [wme, n.attr]; e.open("g", { class: Ipe(t), "clip-path": t.clip ? Nde(this, t, t.group) : null }, kme(t), { "pointer-events": "g" !== r && !1 === t.interactive ? "none" : null }); const a = a => { const o = this.href(a); if (o && e.open("a", o), e.open(r, this.attr(t, a, i, "g" !== r ? r : null)), "text" === r) { const t = ppe(a); if (Aae(t)) { const n = { x: 0, dy: fpe(a) }; for (let r = 0; r < t.length; ++r)e.open("tspan", r ? n : null).text(mpe(a, t[r])).close() } else e.text(mpe(a, t)) } else if ("g" === r) { const r = a.strokeForeground, i = a.fill, o = a.stroke; r && o && (a.stroke = null), e.open("path", this.attr(t, a, n.background, "bgrect")).close(), e.open("g", this.attr(t, a, n.content)), xfe(a, (t => this.mark(e, t))), e.close(), r && o ? (i && (a.fill = null), a.stroke = o, e.open("path", this.attr(t, a, n.foreground, "bgrect")).close(), i && (a.fill = i)) : e.open("path", this.attr(t, a, n.foreground, "bgfore")).close() } e.close(), o && e.close() }; return n.nested ? t.items && t.items.length && a(t.items[0]) : xfe(t, a), e.close() } href(e) { const t = e.href; let n; if (t) { if (n = this._hrefs && this._hrefs[t]) return n; this.sanitizeURL(t).then((e => { e["xlink:href"] = e.href, e.href = null, (this._hrefs || (this._hrefs = {}))[t] = e })) } return null } attr(e, t, n, r) { const i = {}, a = (e, t, n, r) => { i[r || e] = t }; return Array.isArray(n) ? n.forEach((e => e(a, t, this))) : n(a, t, this), r && function (e, t, n, r, i) { let a; if (null == t) return e; "bgrect" === r && !1 === n.interactive && (e["pointer-events"] = "none"); if ("bgfore" === r && (!1 === n.interactive && (e["pointer-events"] = "none"), e.display = "none", null !== t.fill)) return e; "image" === r && !1 === t.smooth && (a = ["image-rendering: optimizeSpeed;", "image-rendering: pixelated;"]); "text" === r && (e["font-family"] = gpe(t), e["font-size"] = dpe(t) + "px", e["font-style"] = t.fontStyle, e["font-variant"] = t.fontVariant, e["font-weight"] = t.fontWeight); for (const n in Nme) { let r = t[n]; const a = Nme[n]; ("transparent" !== r || "fill" !== a && "stroke" !== a) && null != r && (Rhe(r) && (r = Ohe(r, i.gradient, "")), e[a] = r) } for (const e in Ime) { const n = t[e]; null != n && (a = a || [], a.push(`${Ime[e]}: ${n};`)) } a && (e.style = a.join(" ")) }(i, t, e, r, this._defs), i } defs(e) { const t = this._defs.gradient, n = this._defs.clipping; if (0 !== Object.keys(t).length + Object.keys(n).length) { e.open("defs"); for (const n in t) { const r = t[n], i = r.stops; "radial" === r.gradient ? (e.open("pattern", { id: $he + n, viewBox: "0,0,1,1", width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }), e.open("rect", { width: "1", height: "1", fill: "url(#" + n + ")" }).close(), e.close(), e.open("radialGradient", { id: n, fx: r.x1, fy: r.y1, fr: r.r1, cx: r.x2, cy: r.y2, r: r.r2 })) : e.open("linearGradient", { id: n, x1: r.x1, x2: r.x2, y1: r.y1, y2: r.y2 }); for (let t = 0; t < i.length; ++t)e.open("stop", { offset: i[t].offset, "stop-color": i[t].color }).close(); e.close() } for (const t in n) { const r = n[t]; e.open("clipPath", { id: t }), r.path ? e.open("path", { d: r.path }).close() : e.open("rect", { x: 0, y: 0, width: r.width, height: r.height }).close(), e.close() } e.close() } } }, handler: class extends Fpe { constructor(e, t) { super(e, t); const n = this; n._hrefHandler = cme(n, ((e, t) => { t && t.href && n.handleHref(e, t, t.href) })), n._tooltipHandler = cme(n, ((e, t) => { n.handleTooltip(e, t, e.type !== Qpe) })) } initialize(e, t, n) { let r = this._svg; return r && (r.removeEventListener(eme, this._hrefHandler), r.removeEventListener(Jpe, this._tooltipHandler), r.removeEventListener(Qpe, this._tooltipHandler)), this._svg = r = e && Tpe(e, "svg"), r && (r.addEventListener(eme, this._hrefHandler), r.addEventListener(Jpe, this._tooltipHandler), r.addEventListener(Qpe, this._tooltipHandler)), super.initialize(e, t, n) } canvas() { return this._svg } on(e, t) { const n = this.eventName(e), r = this._handlers; if (this._handlerIndex(r[n], e, t) < 0) { const i = { type: e, handler: t, listener: cme(this, t) }; (r[n] || (r[n] = [])).push(i), this._svg && this._svg.addEventListener(n, i.listener) } return this } off(e, t) { const n = this.eventName(e), r = this._handlers[n], i = this._handlerIndex(r, e, t); return i >= 0 && (this._svg && this._svg.removeEventListener(n, r[i].listener), r.splice(i, 1)), this } } }, Jme[Kme] = { renderer: Yme, headless: Yme, handler: class extends tme { constructor(e, t) { super(e, t) } initialize(e, t, n) { const r = Epe(Epe(e, 0, "div"), qme.svgOnTop ? 0 : 1, "div"); return super.initialize(r, t, n) } } }, Jme[Zme] = {}; new Ide; var nge = Math.random; const rge = Math.sqrt(2 * Math.PI), ige = Math.SQRT2; let age = NaN; function oge(e, t) { e = e || 0, t = null == t ? 1 : t; let n, r, i = 0, a = 0; if (age == age) i = age, age = NaN; else { do { i = 2 * nge() - 1, a = 2 * nge() - 1, n = i * i + a * a } while (0 === n || n > 1); r = Math.sqrt(-2 * Math.log(n) / n), i *= r, age = a * r } return e + i * t } function sge(e, t, n) { const r = (e - (t || 0)) / (n = null == n ? 1 : n); return Math.exp(-.5 * r * r) / (n * rge) } function uge(e, t, n) { const r = (e - (t = t || 0)) / (n = null == n ? 1 : n), i = Math.abs(r); let a; if (i > 37) a = 0; else { const e = Math.exp(-i * i / 2); let t; i < 7.07106781186547 ? (t = .0352624965998911 * i + .700383064443688, t = t * i + 6.37396220353165, t = t * i + 33.912866078383, t = t * i + 112.079291497871, t = t * i + 221.213596169931, t = t * i + 220.206867912376, a = e * t, t = .0883883476483184 * i + 1.75566716318264, t = t * i + 16.064177579207, t = t * i + 86.7807322029461, t = t * i + 296.564248779674, t = t * i + 637.333633378831, t = t * i + 793.826512519948, t = t * i + 440.413735824752, a /= t) : (t = i + .65, t = i + 4 / t, t = i + 3 / t, t = i + 2 / t, t = i + 1 / t, a = e / t / 2.506628274631) } return r > 0 ? 1 - a : a } function lge(e, t, n) { return e < 0 || e > 1 ? NaN : (t || 0) + (null == n ? 1 : n) * ige * function (e) { let t, n = -Math.log((1 - e) * (1 + e)); n < 6.25 ? (n -= 3.125, t = -364441206401782e-35, t = t * n - 16850591381820166e-35, t = 128584807152564e-32 + t * n, t = 11157877678025181e-33 + t * n, t = t * n - 1333171662854621e-31, t = 20972767875968562e-33 + t * n, t = 6637638134358324e-30 + t * n, t = t * n - 4054566272975207e-29, t = t * n - 8151934197605472e-29, t = 26335093153082323e-28 + t * n, t = t * n - 12975133253453532e-27, t = t * n - 5415412054294628e-26, t = 1.0512122733215323e-9 + t * n, t = t * n - 4.112633980346984e-9, t = t * n - 2.9070369957882005e-8, t = 4.2347877827932404e-7 + t * n, t = t * n - 13654692000834679e-22, t = t * n - 13882523362786469e-21, t = .00018673420803405714 + t * n, t = t * n - .000740702534166267, t = t * n - .006033670871430149, t = .24015818242558962 + t * n, t = 1.6536545626831027 + t * n) : n < 16 ? (n = Math.sqrt(n) - 3.25, t = 2.2137376921775787e-9, t = 9.075656193888539e-8 + t * n, t = t * n - 2.7517406297064545e-7, t = 1.8239629214389228e-8 + t * n, t = 15027403968909828e-22 + t * n, t = t * n - 4013867526981546e-21, t = 29234449089955446e-22 + t * n, t = 12475304481671779e-21 + t * n, t = t * n - 47318229009055734e-21, t = 6828485145957318e-20 + t * n, t = 24031110387097894e-21 + t * n, t = t * n - .0003550375203628475, t = .0009532893797373805 + t * n, t = t * n - .0016882755560235047, t = .002491442096107851 + t * n, t = t * n - .003751208507569241, t = .005370914553590064 + t * n, t = 1.0052589676941592 + t * n, t = 3.0838856104922208 + t * n) : Number.isFinite(n) ? (n = Math.sqrt(n) - 5, t = -27109920616438573e-27, t = t * n - 2.555641816996525e-10, t = 1.5076572693500548e-9 + t * n, t = t * n - 3.789465440126737e-9, t = 7.61570120807834e-9 + t * n, t = t * n - 1.496002662714924e-8, t = 2.914795345090108e-8 + t * n, t = t * n - 6.771199775845234e-8, t = 2.2900482228026655e-7 + t * n, t = t * n - 9.9298272942317e-7, t = 4526062597223154e-21 + t * n, t = t * n - 1968177810553167e-20, t = 7599527703001776e-20 + t * n, t = t * n - .00021503011930044477, t = t * n - .00013871931833623122, t = 1.0103004648645344 + t * n, t = 4.849906401408584 + t * n) : t = 1 / 0; return t * e }(2 * e - 1) } function cge(e, t) { return e = e || 0, t = null == t ? 1 : t, Math.exp(e + oge() * t) } function hge(e, t, n) { if (e <= 0) return 0; t = t || 0, n = null == n ? 1 : n; const r = (Math.log(e) - t) / n; return Math.exp(-.5 * r * r) / (n * rge * e) } function dge(e, t, n) { return uge(Math.log(e), t, n) } function fge(e, t, n) { return Math.exp(lge(e, t, n)) } function pge(e, t) { return null == t && (t = null == e ? 1 : e, e = 0), e + (t - e) * nge() } function mge(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e >= t && e <= n ? 1 / (n - t) : 0 } function gge(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e < t ? 0 : e > n ? 1 : (e - t) / (n - t) } function yge(e, t, n) { return null == n && (n = null == t ? 1 : t, t = 0), e >= 0 && e <= 1 ? t + e * (n - t) : NaN } Math.PI; function bge(e) { const t = this.context.data[e]; return t ? t.values.value : [] } const vge = e => function (t, n) { return this.context.dataflow.locale()[e](n)(t) }, xge = vge("format"), wge = vge("timeFormat"), kge = vge("utcFormat"), Sge = vge("timeParse"), _ge = vge("utcParse"), Cge = new Date(2e3, 0, 1); function Age(e, t, n) { return Number.isInteger(e) && Number.isInteger(t) ? (Cge.setYear(2e3), Cge.setMonth(e), Cge.setDate(t), wge.call(this, Cge, n)) : "" } function Tge(e, t, n, r) { t[0].type !== Jae && wae("First argument to data functions must be a string literal."); const i = t[0].value, a = ":" + i; if (!jae(a, r)) try { r[a] = n.getData(i).tuplesRef() } catch (e) { } } function Ege(e, t, n, r) { if (t[0].type === Jae) Nge(n, r, t[0].value); else for (e in n.scales) Nge(n, r, e) } function Nge(e, t, n) { const r = "%" + n; if (!jae(t, r)) try { t[r] = e.scaleRef(n) } catch (e) { } } function Ige(e, t) { let n; return Pae(e) ? e : Vae(e) ? (n = t.scales[e]) && n.value : void 0 } function Mge(e, t, n) { t.__bandwidth = e => e && e.bandwidth ? e.bandwidth() : 0, n._bandwidth = Ege, n._range = Ege, n._scale = Ege; const r = t => "_[" + (t.type === Jae ? Hae("%" + t.value) : Hae("%") + "+" + e(t)) + "]"; return { _bandwidth: e => `this.__bandwidth(${r(e[0])})`, _range: e => `${r(e[0])}.range()`, _scale: t => `${r(t[0])}(${e(t[1])})` } } function Fge(e, t) { return function (n, r, i) { if (n) { const t = Ige(n, (i || this).context); return t && t.path[e](r) } return t(r) } } const Dge = Fge("area", (function (e) { return Noe = new Z2, K2(e, Ioe), 2 * Noe })), $ge = Fge("bounds", (function (e) { var t, n, r, i, a, o, s; if (xoe = voe = -(yoe = boe = 1 / 0), Aoe = [], K2(e, Zoe), n = Aoe.length) { for (Aoe.sort(ose), t = 1, a = [r = Aoe[0]]; t < n; ++t)sse(r, (i = Aoe[t])[0]) || sse(r, i[1]) ? (ase(r[0], i[1]) > ase(r[0], r[1]) && (r[1] = i[1]), ase(i[0], r[1]) > ase(r[0], r[1]) && (r[0] = i[0])) : a.push(r = i); for (o = -1 / 0, t = 0, r = a[n = a.length - 1]; t <= n; r = i, ++t)i = a[t], (s = ase(r[1], i[0])) > o && (o = s, yoe = i[0], voe = r[1]) } return Aoe = Toe = null, yoe === 1 / 0 || boe === 1 / 0 ? [[NaN, NaN], [NaN, NaN]] : [[yoe, boe], [voe, xoe]] })), Rge = Fge("centroid", (function (e) { Roe = Ooe = zoe = Poe = Boe = Loe = joe = Uoe = 0, Woe = new Z2, Voe = new Z2, Goe = new Z2, K2(e, use); var t = +Woe, n = +Voe, r = +Goe, i = sM(t, n, r); return i < YI && (t = Loe, n = joe, r = Uoe, Ooe < qI && (t = zoe, n = Poe, r = Boe), (i = sM(t, n, r)) < YI) ? [NaN, NaN] : [rM(n, t) * QI, mM(r / i) * QI] })); function Oge(e, t, n) { try { e[t].apply(e, ["EXPRESSION"].concat([].slice.call(n))) } catch (t) { e.warn(t) } return n[n.length - 1] } function zge(e) { const t = e / 255; return t <= .03928 ? t / 12.92 : Math.pow((t + .055) / 1.055, 2.4) } function Pge(e) { const t = cC(e); return .2126 * zge(t.r) + .7152 * zge(t.g) + .0722 * zge(t.b) } function Bge(e, t) { return e === t || e != e && t != t || (Aae(e) ? !(!Aae(t) || e.length !== t.length) && function (e, t) { for (let n = 0, r = e.length; n < r; ++n)if (!Bge(e[n], t[n])) return !1; return !0 }(e, t) : !(!Tae(e) || !Tae(t)) && Lge(e, t)) } function Lge(e, t) { for (const n in e) if (!Bge(e[n], t[n])) return !1; return !0 } function jge(e) { return t => Lge(e, t) } const Uge = {}; function Wge(e) { return Aae(e) || ArrayBuffer.isView(e) ? e : null } function Vge(e) { return Wge(e) || (Vae(e) ? e : null) } const Gge = e => e.data; function Hge(e, t) { const n = bge.call(t, e); return n.root && n.root.lookup || {} } const qge = () => "undefined" != typeof window && window || null; const Yge = { random: () => nge(), cumulativeNormal: uge, cumulativeLogNormal: dge, cumulativeUniform: gge, densityNormal: sge, densityLogNormal: hge, densityUniform: mge, quantileNormal: lge, quantileLogNormal: fge, quantileUniform: yge, sampleNormal: oge, sampleLogNormal: cge, sampleUniform: pge, isArray: Aae, isBoolean: function (e) { return "boolean" == typeof e }, isDate: Uae, isDefined: e => void 0 !== e, isNumber: Wae, isObject: Tae, isRegExp: function (e) { return "[object RegExp]" === Object.prototype.toString.call(e) }, isString: Vae, isTuple: Ys, isValid: e => null != e && e == e, toBoolean: qae, toDate: Xae, toNumber: Nae, toString: Kae, indexof: function (e, ...t) { return Vge(e).indexOf(...t) }, join: function (e, ...t) { return Wge(e).join(...t) }, lastindexof: function (e, ...t) { return Vge(e).lastIndexOf(...t) }, replace: function (e, t, n) { return Pae(n) && wae("Function argument passed to replace."), String(e).replace(t, n) }, reverse: function (e) { return Wge(e).slice().reverse() }, slice: function (e, ...t) { return Vge(e).slice(...t) }, flush: function (e, t, n, r, i, a) { if (!n && 0 !== n) return a; const o = +n; let s, u = e[0], l = Eae(e); l < u && (s = u, u = l, l = s), s = Math.abs(t - u); const c = Math.abs(l - t); return s < c && s <= o ? r : c <= o ? i : a }, lerp: function (e, t) { const n = e[0], r = Eae(e), i = +t; return i ? 1 === i ? r : n + i * (r - n) : n }, merge: function () { const e = [].slice.call(arguments); return e.unshift({}), Bae(...e) }, pad: function (e, t, n, r) { const i = n || " ", a = e + "", o = t - a.length; return o <= 0 ? a : "left" === r ? Gae(i, o) + a : "center" === r ? Gae(i, ~~(o / 2)) + a + Gae(i, Math.ceil(o / 2)) : a + Gae(i, o) }, peek: Eae, pluck: function (e, t) { const n = Uge[t] || (Uge[t] = Sae(t)); return Aae(e) ? e.map(n) : n(e) }, span: function (e) { return e && Eae(e) - e[0] || 0 }, inrange: function (e, t, n, r) { let i, a = t[0], o = t[t.length - 1]; return a > o && (i = a, a = o, o = i), r = void 0 === r || r, ((n = void 0 === n || n) ? a <= e : a < e) && (r ? e <= o : e < o) }, truncate: function (e, t, n, r) { const i = null != r ? r : "…", a = e + "", o = a.length, s = Math.max(0, t - i.length); return o <= t ? a : "left" === n ? i + a.slice(o - s) : "center" === n ? a.slice(0, Math.ceil(s / 2)) + i + a.slice(o - ~~(s / 2)) : a.slice(0, s) + i }, rgb: cC, lab: _1, hcl: M1, hsl: yC, luminance: Pge, contrast: function (e, t) { const n = Pge(e), r = Pge(t); return (Math.max(n, r) + .05) / (Math.min(n, r) + .05) }, sequence: Fl, format: xge, utcFormat: kge, utcParse: _ge, utcOffset: function (e, t, n) { return ece(Qle(e), t, n) }, utcSequence: function (e, t, n, r) { return tce(Qle(e), t, n, r) }, timeFormat: wge, timeParse: Sge, timeOffset: function (e, t, n) { return ece(Jle(e), t, n) }, timeSequence: function (e, t, n, r) { return tce(Jle(e), t, n, r) }, timeUnitSpecifier: function (e, t) { const n = Bae({}, Wle, t), r = function (e) { const t = zae(e).slice(), n = {}; return t.length || wae("Missing time unit."), t.forEach((e => { jae(Ule, e) ? n[e] = 1 : wae(`Invalid time unit: ${e}.`) })), (n[$le] || n[Ole] ? 1 : 0) + (n[Fle] || n[Dle] || n[Rle] ? 1 : 0) + (n[zle] ? 1 : 0) > 1 && wae(`Incompatible time units: ${e}`), t.sort(((e, t) => Ule[e] - Ule[t])), t }(e), i = r.length; let a, o, s = "", u = 0; for (u = 0; u < i;)for (a = r.length; a > u; --a)if (o = r.slice(u, a).join("-"), null != n[o]) { s += n[o], u = a; break } return s.trim() }, monthFormat: function (e) { return Age.call(this, e, 1, "%B") }, monthAbbrevFormat: function (e) { return Age.call(this, e, 1, "%b") }, dayFormat: function (e) { return Age.call(this, 0, 2 + e, "%A") }, dayAbbrevFormat: function (e) { return Age.call(this, 0, 2 + e, "%a") }, quarter: function (e) { return 1 + ~~(new Date(e).getMonth() / 3) }, utcquarter: function (e) { return 1 + ~~(new Date(e).getUTCMonth() / 3) }, week: function (e) { return qle(new Date(e)) }, utcweek: function (e) { return Xle(new Date(e)) }, dayofyear: function (e) { return Hle(new Date(e)) }, utcdayofyear: function (e) { return Yle(new Date(e)) }, warn: function () { return Oge(this.context.dataflow, "warn", arguments) }, info: function () { return Oge(this.context.dataflow, "info", arguments) }, debug: function () { return Oge(this.context.dataflow, "debug", arguments) }, extent: function (e, t) { let n, r, i, a, o = 0; if (e && (n = e.length)) if (null == t) { for (r = e[o]; o < n && (null == r || r != r); r = e[++o]); for (i = a = r; o < n; ++o)r = e[o], null != r && (r < i && (i = r), r > a && (a = r)) } else { for (r = t(e[o]); o < n && (null == r || r != r); r = t(e[++o])); for (i = a = r; o < n; ++o)r = t(e[o]), null != r && (r < i && (i = r), r > a && (a = r)) } return [i, a] }, inScope: function (e) { const t = this.context.group; let n = !1; if (t) for (; e;) { if (e === t) { n = !0; break } e = e.mark.group } return n }, intersect: function (e, t, n) { if (!e) return []; const [r, i] = e, a = (new Ide).set(r[0], r[1], i[0], i[1]); return function (e, t, n) { const r = [], i = (new Ide).union(t), a = e.marktype; return a ? Qme(e, i, n, r) : "group" === a ? ege(e, i, n, r) : wae("Intersect scene must be mark node or group item.") }(n || this.context.dataflow.scenegraph().root, a, function (e) { let t = null; if (e) { const n = zae(e.marktype), r = zae(e.markname); t = e => (!n.length || n.some((t => e.marktype === t))) && (!r.length || r.some((t => e.name === t))) } return t }(t)) }, clampRange: function (e, t, n) { let r, i = e[0], a = e[1]; return a < i && (r = a, a = i, i = r), r = a - i, r >= n - t ? [t, n] : [i = Math.min(Math.max(i, t), n - r), i + r] }, pinchDistance: function (e) { const t = e.touches, n = t[0].clientX - t[1].clientX, r = t[0].clientY - t[1].clientY; return Math.sqrt(n * n + r * r) }, pinchAngle: function (e) { const t = e.touches; return Math.atan2(t[0].clientY - t[1].clientY, t[0].clientX - t[1].clientX) }, screen: function () { const e = qge(); return e ? e.screen : {} }, containerSize: function () { const e = this.context.dataflow, t = e.container && e.container(); return t ? [t.clientWidth, t.clientHeight] : [void 0, void 0] }, windowSize: function () { const e = qge(); return e ? [e.innerWidth, e.innerHeight] : [void 0, void 0] }, bandspace: function (e, t, n) { return oce(e || 0, t || 0, n || 0) }, setdata: function (e, t) { const n = this.context.dataflow, r = this.context.data[e].input; return n.pulse(r, n.changeset().remove(Cae).insert(t)), 1 }, pathShape: function (e) { let t = null; return function (n) { return n ? nde(n, t = t || Ghe(e)) : e } }, panLinear: function (e, t) { return Rae(e, t, Nae, _ae) }, panLog: function (e, t) { var n = Math.sign(e[0]); return Rae(e, t, Mae(n), Iae(n)) }, panPow: function (e, t, n) { return Rae(e, t, $ae(n), $ae(1 / n)) }, panSymlog: function (e, t, n) { return Rae(e, t, Fae(n), Dae(n)) }, zoomLinear: function (e, t, n) { return Oae(e, t, n, Nae, _ae) }, zoomLog: function (e, t, n) { const r = Math.sign(e[0]); return Oae(e, t, n, Mae(r), Iae(r)) }, zoomPow: function (e, t, n, r) { return Oae(e, t, n, $ae(r), $ae(1 / r)) }, zoomSymlog: function (e, t, n, r) { return Oae(e, t, n, Fae(r), Dae(r)) }, encode: function (e, t, n) { if (e) { const n = this.context.dataflow, r = e.mark.source; n.pulse(r, n.changeset().encode(e, t)) } return void 0 !== n ? n : e }, modify: function (e, t, n, r, i, a) { const o = this.context.dataflow, s = this.context.data[e], u = s.input, l = o.stamp(); let c, h, d = s.changes; if (!1 === o._trigger || !(u.value.length || t || r)) return 0; if ((!d || d.stamp < l) && (s.changes = d = o.changeset(), d.stamp = l, o.runAfter((() => { s.modified = !0, o.pulse(u, d).run() }), !0, 1)), n && (c = !0 === n ? Cae : Aae(n) || Ys(n) ? n : jge(n), d.remove(c)), t && d.insert(t), r && (c = jge(r), u.value.some(c) ? d.remove(c) : d.insert(r)), i) for (h in a) d.modify(i, h, a[h]); return 1 } }, Xge = ["view", "item", "group", "xy", "x", "y"], Kge = "this.", Zge = {}, Jge = { forbidden: ["_"], allowed: ["datum", "event", "item"], fieldvar: "datum", globalvar: e => `_[${Hae("$" + e)}]`, functions: function (e) { const t = hoe(e); Xge.forEach((e => t[e] = "event.vega." + e)); for (const e in Yge) t[e] = Kge + e; return Bae(t, Mge(e, Yge, Zge)), t }, constants: coe, visitors: Zge }, Qge = function (e) { const t = (e = e || {}).allowed ? Zae(e.allowed) : {}, n = e.forbidden ? Zae(e.forbidden) : {}, r = e.constants || coe, i = (e.functions || hoe)(h), a = e.globalvar, o = e.fieldvar, s = Pae(a) ? a : e => `${a}["${e}"]`; let u = {}, l = {}, c = 0; function h(e) { if (Vae(e)) return e; const t = d[e.type]; return null == t && wae("Unsupported type: " + e.type), t(e) } const d = { Literal: e => e.raw, Identifier: e => { const i = e.name; return c > 0 ? i : jae(n, i) ? wae("Illegal identifier: " + i) : jae(r, i) ? r[i] : jae(t, i) ? i : (u[i] = 1, s(i)) }, MemberExpression: e => { const t = !e.computed, n = h(e.object); t && (c += 1); const r = h(e.property); return n === o && (l[function (e) { const t = e && e.length - 1; return t && ('"' === e[0] && '"' === e[t] || "'" === e[0] && "'" === e[t]) ? e.slice(1, -1) : e }(r)] = 1), t && (c -= 1), n + (t ? "." + r : "[" + r + "]") }, CallExpression: e => { "Identifier" !== e.callee.type && wae("Illegal callee type: " + e.callee.type); const t = e.callee.name, n = e.arguments, r = jae(i, t) && i[t]; return r || wae("Unrecognized function: " + t), Pae(r) ? r(n) : r + "(" + n.map(h).join(",") + ")" }, ArrayExpression: e => "[" + e.elements.map(h).join(",") + "]", BinaryExpression: e => "(" + h(e.left) + " " + e.operator + " " + h(e.right) + ")", UnaryExpression: e => "(" + e.operator + h(e.argument) + ")", ConditionalExpression: e => "(" + h(e.test) + "?" + h(e.consequent) + ":" + h(e.alternate) + ")", LogicalExpression: e => "(" + h(e.left) + e.operator + h(e.right) + ")", ObjectExpression: e => "{" + e.properties.map(h).join(",") + "}", Property: e => { c += 1; const t = h(e.key); return c -= 1, t + ":" + h(e.value) } }; function f(e) { const t = { code: h(e), globals: Object.keys(u), fields: Object.keys(l) }; return u = {}, l = {}, t } return f.functions = i, f.constants = r, f }(Jge); function eye(e, t, n) { return 1 === arguments.length ? Yge[e] : (Yge[e] = t, n && (Zge[e] = n), Qge && (Qge.functions[e] = Kge + e), this) } eye("bandwidth", (function (e, t) { const n = Ige(e, (t || this).context); return n && n.bandwidth ? n.bandwidth() : 0 }), Ege), eye("copy", (function (e, t) { const n = Ige(e, (t || this).context); return n ? n.copy() : void 0 }), Ege), eye("domain", (function (e, t) { const n = Ige(e, (t || this).context); return n ? n.domain() : [] }), Ege), eye("range", (function (e, t) { const n = Ige(e, (t || this).context); return n && n.range ? n.range() : [] }), Ege), eye("invert", (function (e, t, n) { const r = Ige(e, (n || this).context); return r ? Aae(t) ? (r.invertRange || r.invert)(t) : (r.invert || r.invertExtent)(t) : void 0 }), Ege), eye("scale", (function (e, t, n) { const r = Ige(e, (n || this).context); return r ? r(t) : void 0 }), Ege), eye("gradient", (function (e, t, n, r, i) { e = Ige(e, (i || this).context); const a = function (e, t) { var n, r = []; return n = { gradient: "linear", x1: e ? e[0] : 0, y1: e ? e[1] : 0, x2: t ? t[0] : 1, y2: t ? t[1] : 0, stops: r, stop: function (e, t) { return r.push({ offset: e, color: t }), n } } }(t, n); let o = e.domain(), s = o[0], u = Eae(o), l = _ae; return u - s ? l = Oce(e, s, u) : e = (e.interpolator ? Mce("sequential")().interpolator(e.interpolator()) : Mce("linear")().interpolate(e.interpolate()).range(e.range())).domain([s = 0, u = 1]), e.ticks && (o = e.ticks(+r || 15), s !== o[0] && o.unshift(s), u !== Eae(o) && o.push(u)), o.forEach((t => a.stop(l(t), e(t)))), a }), Ege), eye("geoArea", Dge, Ege), eye("geoBounds", $ge, Ege), eye("geoCentroid", Rge, Ege), eye("geoShape", (function (e, t, n) { const r = Ige(e, (n || this).context); return function (e) { return r ? r.path.context(e)(t) : "" } }), Ege), eye("indata", (function (e, t, n) { const r = this.context.data[e]["index:" + t], i = r ? r.value.get(n) : void 0; return i ? i.count : i }), (function (e, t, n, r) { t[0].type !== Jae && wae("First argument to indata must be a string literal."), t[1].type !== Jae && wae("Second argument to indata must be a string literal."); const i = t[0].value, a = t[1].value, o = "@" + a; jae(o, r) || (r[o] = n.getData(i).indataRef(n, a)) })), eye("data", bge, Tge), eye("treePath", (function (e, t, n) { const r = Hge(e, this), i = r[t], a = r[n]; return i && a ? i.path(a).map(Gge) : void 0 }), Tge), eye("treeAncestors", (function (e, t) { const n = Hge(e, this)[t]; return n ? n.ancestors().map(Gge) : void 0 }), Tge), eye("vlSelectionTest", cee, bee), eye("vlSelectionIdTest", pee, bee), eye("vlSelectionResolve", gee, bee), eye("vlSelectionTuples", mee); const tye = "view", nye = "[", rye = "]", iye = "{", aye = "}", oye = ":", sye = ",", uye = "@", lye = ">", cye = /[[\]{}]/, hye = { "*": 1, arc: 1, area: 1, group: 1, image: 1, line: 1, path: 1, rect: 1, rule: 1, shape: 1, symbol: 1, text: 1, trail: 1 }; let dye, fye; function pye(e, t, n, r, i) { const a = e.length; let o, s = 0; for (; t < a; ++t) { if (o = e[t], !s && o === n) return t; i && i.indexOf(o) >= 0 ? --s : r && r.indexOf(o) >= 0 && ++s } return t } function mye(e) { const t = [], n = e.length; let r = 0, i = 0; for (; i < n;)i = pye(e, i, sye, nye + iye, rye + aye), t.push(e.substring(r, i).trim()), r = ++i; if (0 === t.length) throw "Empty event selector: " + e; return t } function gye(e) { return "[" === e[0] ? function (e) { const t = e.length; let n, r = 1; if (r = pye(e, r, rye, nye, rye), r === t) throw "Empty between selector: " + e; if (n = mye(e.substring(1, r)), 2 !== n.length) throw "Between selector must have two elements: " + e; if (e = e.slice(r + 1).trim(), e[0] !== lye) throw "Expected '>' after between selector: " + e; n = n.map(gye); const i = gye(e.slice(1).trim()); if (i.between) return { between: n, stream: i }; i.between = n; return i }(e) : function (e) { const t = { source: dye }, n = []; let r, i, a = [0, 0], o = 0, s = 0, u = e.length, l = 0; if (e[u - 1] === aye) { if (l = e.lastIndexOf(iye), !(l >= 0)) throw "Unmatched right brace: " + e; try { a = function (e) { const t = e.split(sye); if (!e.length || t.length > 2) throw e; return t.map((t => { const n = +t; if (n != n) throw e; return n })) }(e.substring(l + 1, u - 1)) } catch (t) { throw "Invalid throttle specification: " + e } u = (e = e.slice(0, l).trim()).length, l = 0 } if (!u) throw e; e[0] === uye && (o = ++l); r = pye(e, l, oye), r < u && (n.push(e.substring(s, r).trim()), s = l = ++r); if (l = pye(e, l, nye), l === u) n.push(e.substring(s, u).trim()); else if (n.push(e.substring(s, l).trim()), i = [], s = ++l, s === u) throw "Unmatched left bracket: " + e; for (; l < u;) { if (l = pye(e, l, rye), l === u) throw "Unmatched left bracket: " + e; if (i.push(e.substring(s, l).trim()), l < u - 1 && e[++l] !== nye) throw "Expected left bracket: " + e; s = ++l } if (!(u = n.length) || cye.test(n[u - 1])) throw "Invalid event selector: " + e; u > 1 ? (t.type = n[1], o ? t.markname = n[0].slice(1) : !function (e) { return fye[e] }(n[0]) ? t.source = n[0] : t.marktype = n[0]) : t.type = n[0]; "!" === t.type.slice(-1) && (t.consume = !0, t.type = t.type.slice(0, -1)); null != i && (t.filter = i); a[0] && (t.throttle = a[0]); a[1] && (t.debounce = a[1]); return t }(e) } function yye(e) { return sn(e) ? e : { type: e || "pad" } } const bye = e => +e || 0, vye = e => ({ top: e, bottom: e, left: e, right: e }); function xye(e) { return sn(e) ? e.signal ? e : { top: bye(e.top), bottom: bye(e.bottom), left: bye(e.left), right: bye(e.right) } : vye(bye(e)) } const wye = e => sn(e) && !on(e) ? $n({}, e) : { value: e }; function kye(e, t, n, r) { if (null != n) { return sn(n) && !on(n) || on(n) && n.length && sn(n[0]) ? e.update[t] = n : e[r || "enter"][t] = { value: n }, 1 } return 0 } function Sye(e, t, n) { for (const n in t) kye(e, n, t[n]); for (const t in n) kye(e, t, n[t], "update") } function _ye(e, t, n) { for (const r in t) n && zn(n, r) || (e[r] = $n(e[r] || {}, t[r])); return e } function Cye(e, t) { return t && (t.enter && t.enter[e] || t.update && t.update[e]) } const Aye = "mark", Tye = "frame", Eye = "scope", Nye = "axis", Iye = "axis-domain", Mye = "axis-grid", Fye = "axis-label", Dye = "axis-tick", $ye = "axis-title", Rye = "legend", Oye = "legend-band", zye = "legend-entry", Pye = "legend-gradient", Bye = "legend-label", Lye = "legend-symbol", jye = "legend-title", Uye = "title", Wye = "title-text", Vye = "title-subtitle"; function Gye(e, t, n) { e[t] = n && n.signal ? { signal: n.signal } : { value: n } } const Hye = e => Vn(e) ? Yn(e) : e.signal ? `(${e.signal})` : Kye(e); function qye(e) { if (null != e.gradient) return function (e) { const t = [e.start, e.stop, e.count].map((e => null == e ? null : Yn(e))); for (; t.length && null == hn(t);)t.pop(); return t.unshift(Hye(e.gradient)), `gradient(${t.join(",")})` }(e); let t = e.signal ? `(${e.signal})` : e.color ? function (e) { return e.c ? Yye("hcl", e.h, e.c, e.l) : e.h || e.s ? Yye("hsl", e.h, e.s, e.l) : e.l || e.a ? Yye("lab", e.l, e.a, e.b) : e.r || e.g || e.b ? Yye("rgb", e.r, e.g, e.b) : null }(e.color) : null != e.field ? Kye(e.field) : void 0 !== e.value ? Yn(e.value) : void 0; return null != e.scale && (t = function (e, t) { const n = Hye(e.scale); null != e.range ? t = `lerp(_range(${n}), ${+e.range})` : (void 0 !== t && (t = `_scale(${n}, ${t})`), e.band && (t = (t ? t + "+" : "") + `_bandwidth(${n})` + (1 == +e.band ? "" : "*" + Xye(e.band)), e.extra && (t = `(datum.extra ? _scale(${n}, datum.extra.value) : ${t})`)), null == t && (t = "0")); return t }(e, t)), void 0 === t && (t = null), null != e.exponent && (t = `pow(${t},${Xye(e.exponent)})`), null != e.mult && (t += `*${Xye(e.mult)}`), null != e.offset && (t += `+${Xye(e.offset)}`), e.round && (t = `round(${t})`), t } const Yye = (e, t, n, r) => `(${e}(${[t, n, r].map(qye).join(",")})+'')`; function Xye(e) { return sn(e) ? "(" + qye(e) + ")" : e } function Kye(e) { return Zye(sn(e) ? e : { datum: e }) } function Zye(e) { let t, n, r; if (e.signal) t = "datum", r = e.signal; else if (e.group || e.parent) { for (n = Math.max(1, e.level || 1), t = "item"; n-- > 0;)t += ".mark.group"; e.parent ? (r = e.parent, t += ".datum") : r = e.group } else e.datum ? (t = "datum", r = e.datum) : Vt("Invalid field reference: " + Yn(e)); return e.signal || (r = Vn(r) ? Gt(r).map(Yn).join("][") : Zye(r)), t + "[" + r + "]" } function Jye(e, t, n, r, i, a) { const o = {}; (a = a || {}).encoders = { $encode: o }, e = function (e, t, n, r, i) { const a = {}, o = {}; let s, u, l, c; for (u in u = "lineBreak", "text" !== t || null == i[u] || Cye(u, e) || Gye(a, u, i[u]), ("legend" == n || String(n).startsWith("axis")) && (n = null), c = n === Tye ? i.group : n === Aye ? $n({}, i.mark, i[t]) : null, c) l = Cye(u, e) || ("fill" === u || "stroke" === u) && (Cye("fill", e) || Cye("stroke", e)), l || Gye(a, u, c[u]); for (u in _n(r).forEach((t => { const n = i.style && i.style[t]; for (const t in n) Cye(t, e) || Gye(a, t, n[t]) })), e = $n({}, e), a) c = a[u], c.signal ? (s = s || {})[u] = c : o[u] = c; return e.enter = $n(o, e.enter), s && (e.update = $n(s, e.update)), e }(e, t, n, r, i.config); for (const n in e) o[n] = Qye(e[n], t, a, i); return a } function Qye(e, t, n, r) { const i = {}, a = {}; for (const t in e) null != e[t] && (i[t] = ebe((o = e[t], on(o) ? function (e) { let t = ""; return e.forEach((e => { const n = qye(e); t += e.test ? `(${e.test})?${n}:` : n })), ":" === hn(t) && (t += "null"), t }(o) : qye(o)), r, n, a)); var o; return { $expr: { marktype: t, channels: i }, $fields: Object.keys(a), $output: Object.keys(e) } } function ebe(e, t, n, r) { const i = ite(e, t); return i.$fields.forEach((e => r[e] = 1)), $n(n, i.$params), i.$expr } const tbe = "outer", nbe = ["value", "update", "init", "react", "bind"]; function rbe(e, t) { Vt(e + ' for "outer" push: ' + Yn(t)) } function ibe(e, t) { const n = e.name; if (e.push === tbe) t.signals[n] || rbe("No prior signal definition", n), nbe.forEach((t => { void 0 !== e[t] && rbe("Invalid property ", t) })); else { const r = t.addSignal(n, e.value); !1 === e.react && (r.react = !1), e.bind && t.addBinding(n, e.bind) } } function abe(e, t, n, r) { this.id = -1, this.type = e, this.value = t, this.params = n, r && (this.parent = r) } function obe(e, t, n, r) { return new abe(e, t, n, r) } function sbe(e, t) { return obe("operator", e, t) } function ube(e) { const t = { $ref: e.id }; return e.id < 0 && (e.refs = e.refs || []).push(t), t } function lbe(e, t) { return t ? { $field: e, $name: t } : { $field: e } } const cbe = lbe("key"); function hbe(e, t) { return { $compare: e, $order: t } } function dbe(e, t) { return (e && e.signal ? "$" + e.signal : e || "") + (e && t ? "_" : "") + (t && t.signal ? "$" + t.signal : t || "") } const fbe = "scope", pbe = "view"; function mbe(e) { return e && e.signal } function gbe(e) { if (mbe(e)) return !0; if (sn(e)) for (const t in e) if (gbe(e[t])) return !0; return !1 } function ybe(e, t) { return null != e ? e : t } function bbe(e) { return e && e.signal || e } const vbe = "timer"; function xbe(e, t) { return (e.merge ? wbe : e.stream ? kbe : e.type ? Sbe : Vt("Invalid stream specification: " + Yn(e)))(e, t) } function wbe(e, t) { const n = e.merge.map((e => xbe(e, t))), r = _be({ merge: n }, e, t); return t.addStream(r).id } function kbe(e, t) { const n = _be({ stream: xbe(e.stream, t) }, e, t); return t.addStream(n).id } function Sbe(e, t) { let n; e.type === vbe ? (n = t.event(vbe, e.throttle), e = { between: e.between, filter: e.filter }) : n = t.event(function (e) { return e === fbe ? pbe : e || pbe }(e.source), e.type); const r = _be({ stream: n }, e, t); return 1 === Object.keys(r).length ? n : t.addStream(r).id } function _be(e, t, n) { let r = t.between; return r && (2 !== r.length && Vt('Stream "between" parameter must have 2 entries: ' + Yn(t)), e.between = [xbe(r[0], n), xbe(r[1], n)]), r = t.filter ? [].concat(t.filter) : [], (t.marktype || t.markname || t.markrole) && r.push(function (e, t, n) { const r = "event.item"; return r + (e && "*" !== e ? "&&" + r + ".mark.marktype==='" + e + "'" : "") + (n ? "&&" + r + ".mark.role==='" + n + "'" : "") + (t ? "&&" + r + ".mark.name==='" + t + "'" : "") }(t.marktype, t.markname, t.markrole)), t.source === fbe && r.push("inScope(event.item)"), r.length && (e.filter = ite("(" + r.join(")&&(") + ")", n).$expr), null != (r = t.throttle) && (e.throttle = +r), null != (r = t.debounce) && (e.debounce = +r), t.consume && (e.consume = !0), e } const Cbe = { code: "_.$value", ast: { type: "Identifier", value: "value" } }; function Abe(e, t, n) { const r = e.encode, i = { target: n }; let a = e.events, o = e.update, s = []; a || Vt("Signal update missing events specification."), Vn(a) && (a = function (e, t, n) { return dye = t || tye, fye = n || hye, mye(e.trim()).map(gye) }(a, t.isSubscope() ? fbe : pbe)), a = _n(a).filter((e => e.signal || e.scale ? (s.push(e), 0) : 1)), s.length > 1 && (s = [Tbe(s)]), a.length && s.push(a.length > 1 ? { merge: a } : a[0]), null != r && (o && Vt("Signal encode and update are mutually exclusive."), o = "encode(item()," + Yn(r) + ")"), i.update = Vn(o) ? ite(o, t) : null != o.expr ? ite(o.expr, t) : null != o.value ? o.value : null != o.signal ? { $expr: Cbe, $params: { $value: t.signalRef(o.signal) } } : Vt("Invalid signal update specification."), e.force && (i.options = { force: !0 }), s.forEach((e => t.addUpdate($n(function (e, t) { return { source: e.signal ? t.signalRef(e.signal) : e.scale ? t.scaleRef(e.scale) : xbe(e, t) } }(e, t), i)))) } function Tbe(e) { return { signal: "[" + e.map((e => e.scale ? 'scale("' + e.scale + '")' : e.signal)) + "]" } } const Ebe = e => (t, n, r) => obe(e, n, t || void 0, r), Nbe = Ebe("aggregate"), Ibe = Ebe("axisticks"), Mbe = Ebe("bound"), Fbe = Ebe("collect"), Dbe = Ebe("compare"), $be = Ebe("datajoin"), Rbe = Ebe("encode"), Obe = Ebe("expression"), zbe = Ebe("facet"), Pbe = Ebe("field"), Bbe = Ebe("key"), Lbe = Ebe("legendentries"), jbe = Ebe("load"), Ube = Ebe("mark"), Wbe = Ebe("multiextent"), Vbe = Ebe("multivalues"), Gbe = Ebe("overlap"), Hbe = Ebe("params"), qbe = Ebe("prefacet"), Ybe = Ebe("projection"), Xbe = Ebe("proxy"), Kbe = Ebe("relay"), Zbe = Ebe("render"), Jbe = Ebe("scale"), Qbe = Ebe("sieve"), eve = Ebe("sortitems"), tve = Ebe("viewlayout"), nve = Ebe("values"); let rve = 0; const ive = { min: "min", max: "max", count: "sum" }; function ave(e, t) { const n = t.getScale(e.name).params; let r; for (r in n.domain = lve(e.domain, e, t), null != e.range && (n.range = yve(e, t, n)), null != e.interpolate && function (e, t) { t.interpolate = ove(e.type || e), null != e.gamma && (t.interpolateGamma = ove(e.gamma)) }(e.interpolate, n), null != e.nice && (n.nice = function (e) { return sn(e) ? { interval: ove(e.interval), step: ove(e.step) } : ove(e) }(e.nice)), null != e.bins && (n.bins = function (e, t) { return e.signal || on(e) ? sve(e, t) : t.objectProperty(e) }(e.bins, t)), e) zn(n, r) || "name" === r || (n[r] = ove(e[r], t)) } function ove(e, t) { return sn(e) ? e.signal ? t.signalRef(e.signal) : Vt("Unsupported object: " + Yn(e)) : e } function sve(e, t) { return e.signal ? t.signalRef(e.signal) : e.map((e => ove(e, t))) } function uve(e) { Vt("Can not find data set: " + Yn(e)) } function lve(e, t, n) { if (e) return e.signal ? n.signalRef(e.signal) : (on(e) ? cve : e.fields ? dve : hve)(e, t, n); null == t.domainMin && null == t.domainMax || Vt("No scale domain defined for domainMin/domainMax to override.") } function cve(e, t, n) { return e.map((e => ove(e, n))) } function hve(e, t, n) { const r = n.getData(e.data); return r || uve(e.data), yb(t.type) ? r.valuesRef(n, e.field, pve(e.sort, !1)) : wb(t.type) ? r.domainRef(n, e.field) : r.extentRef(n, e.field) } function dve(e, t, n) { const r = e.data, i = e.fields.reduce(((e, t) => (t = Vn(t) ? { data: r, field: t } : on(t) || t.signal ? function (e, t) { const n = "_:vega:_" + rve++, r = Fbe({}); if (on(e)) r.value = { $ingest: e }; else if (e.signal) { const i = "setdata(" + Yn(n) + "," + e.signal + ")"; r.params.input = t.signalRef(i) } return t.addDataPipeline(n, [r, Qbe({})]), { data: n, field: "data" } }(t, n) : t, e.push(t), e)), []); return (yb(t.type) ? fve : wb(t.type) ? mve : gve)(e, n, i) } function fve(e, t, n) { const r = pve(e.sort, !0); let i, a; const o = n.map((e => { const n = t.getData(e.data); return n || uve(e.data), n.countsRef(t, e.field, r) })), s = { groupby: cbe, pulse: o }; r && (i = r.op || "count", a = r.field ? dbe(i, r.field) : "count", s.ops = [ive[i]], s.fields = [t.fieldRef(a)], s.as = [a]), i = t.add(Nbe(s)); const u = t.add(Fbe({ pulse: ube(i) })); return a = t.add(nve({ field: cbe, sort: t.sortRef(r), pulse: ube(u) })), ube(a) } function pve(e, t) { return e && (e.field || e.op ? e.field || "count" === e.op ? t && e.field && e.op && !ive[e.op] && Vt("Multiple domain scales can not be sorted using " + e.op) : Vt("No field provided for sort aggregate op: " + e.op) : sn(e) ? e.field = "key" : e = { field: "key" }), e } function mve(e, t, n) { const r = n.map((e => { const n = t.getData(e.data); return n || uve(e.data), n.domainRef(t, e.field) })); return ube(t.add(Vbe({ values: r }))) } function gve(e, t, n) { const r = n.map((e => { const n = t.getData(e.data); return n || uve(e.data), n.extentRef(t, e.field) })); return ube(t.add(Wbe({ extents: r }))) } function yve(e, t, n) { const r = t.config.range; let i = e.range; if (i.signal) return t.signalRef(i.signal); if (Vn(i)) { if (r && zn(r, i)) return yve(e = $n({}, e, { range: r[i] }), t, n); "width" === i ? i = [0, { signal: "width" }] : "height" === i ? i = yb(e.type) ? [0, { signal: "height" }] : [{ signal: "height" }, 0] : Vt("Unrecognized scale range value: " + Yn(i)) } else { if (i.scheme) return n.scheme = on(i.scheme) ? sve(i.scheme, t) : ove(i.scheme, t), i.extent && (n.schemeExtent = sve(i.extent, t)), void (i.count && (n.schemeCount = ove(i.count, t))); if (i.step) return void (n.rangeStep = ove(i.step, t)); if (yb(e.type) && !on(i)) return lve(i, e, t); on(i) || Vt("Unsupported range type: " + Yn(i)) } return i.map((e => (on(e) ? sve : ove)(e, t))) } function bve(e, t, n) { return on(e) ? e.map((e => bve(e, t, n))) : sn(e) ? e.signal ? n.signalRef(e.signal) : "fit" === t ? e : Vt("Unsupported parameter object: " + Yn(e)) : e } const vve = "top", xve = "left", wve = "right", kve = "bottom", Sve = "center", _ve = "vertical", Cve = "start", Ave = "end", Tve = "index", Eve = "label", Nve = "offset", Ive = "perc", Mve = "perc2", Fve = "value", Dve = "guide-label", $ve = "guide-title", Rve = "group-title", Ove = "group-subtitle", zve = "symbol", Pve = "gradient", Bve = "discrete", Lve = "size", jve = [Lve, "shape", "fill", "stroke", "strokeWidth", "strokeDash", "opacity"], Uve = { name: 1, style: 1, interactive: 1 }, Wve = { value: 0 }, Vve = { value: 1 }, Gve = "group", Hve = "rect", qve = "rule", Yve = "symbol", Xve = "text"; function Kve(e) { return e.type = Gve, e.interactive = e.interactive || !1, e } function Zve(e, t) { const n = (n, r) => ybe(e[n], ybe(t[n], r)); return n.isVertical = n => _ve === ybe(e.direction, t.direction || (n ? t.symbolDirection : t.gradientDirection)), n.gradientLength = () => ybe(e.gradientLength, t.gradientLength || t.gradientWidth), n.gradientThickness = () => ybe(e.gradientThickness, t.gradientThickness || t.gradientHeight), n.entryColumns = () => ybe(e.columns, ybe(t.columns, +n.isVertical(!0))), n } function Jve(e, t) { const n = t && (t.update && t.update[e] || t.enter && t.enter[e]); return n && n.signal ? n : n ? n.value : null } function Qve(e, t, n) { return `item.anchor === '${Cve}' ? ${e} : item.anchor === '${Ave}' ? ${t} : ${n}` } const exe = Qve(Yn(xve), Yn(wve), Yn(Sve)); function txe(e, t) { return t ? e ? sn(e) ? Object.assign({}, e, { offset: txe(e.offset, t) }) : { value: e, offset: t } : t : e } function nxe(e, t) { return t ? (e.name = t.name, e.style = t.style || e.style, e.interactive = !!t.interactive, e.encode = _ye(e.encode, t, Uve)) : e.interactive = !1, e } function rxe(e, t, n, r) { const i = Zve(e, n), a = i.isVertical(), o = i.gradientThickness(), s = i.gradientLength(); let u, l, c, h, d; a ? (l = [0, 1], c = [0, 0], h = o, d = s) : (l = [0, 0], c = [1, 0], h = s, d = o); const f = { enter: u = { opacity: Wve, x: Wve, y: Wve, width: wye(h), height: wye(d) }, update: $n({}, u, { opacity: Vve, fill: { gradient: t, start: l, stop: c } }), exit: { opacity: Wve } }; return Sye(f, { stroke: i("gradientStrokeColor"), strokeWidth: i("gradientStrokeWidth") }, { opacity: i("gradientOpacity") }), nxe({ type: Hve, role: Pye, encode: f }, r) } function ixe(e, t, n, r, i) { const a = Zve(e, n), o = a.isVertical(), s = a.gradientThickness(), u = a.gradientLength(); let l, c, h, d, f = ""; o ? (l = "y", h = "y2", c = "x", d = "width", f = "1-") : (l = "x", h = "x2", c = "y", d = "height"); const p = { opacity: Wve, fill: { scale: t, field: Fve } }; p[l] = { signal: f + "datum." + Ive, mult: u }, p[c] = Wve, p[h] = { signal: f + "datum." + Mve, mult: u }, p[d] = wye(s); const m = { enter: p, update: $n({}, p, { opacity: Vve }), exit: { opacity: Wve } }; return Sye(m, { stroke: a("gradientStrokeColor"), strokeWidth: a("gradientStrokeWidth") }, { opacity: a("gradientOpacity") }), nxe({ type: Hve, role: Oye, key: Fve, from: i, encode: m }, r) } const axe = `datum.${Ive}<=0?"${xve}":datum.${Ive}>=1?"${wve}":"${Sve}"`, oxe = `datum.${Ive}<=0?"${kve}":datum.${Ive}>=1?"${vve}":"middle"`; function sxe(e, t, n, r) { const i = Zve(e, t), a = i.isVertical(), o = wye(i.gradientThickness()), s = i.gradientLength(); let u, l, c, h, d = i("labelOverlap"), f = ""; const p = { enter: u = { opacity: Wve }, update: l = { opacity: Vve, text: { field: Eve } }, exit: { opacity: Wve } }; return Sye(p, { fill: i("labelColor"), fillOpacity: i("labelOpacity"), font: i("labelFont"), fontSize: i("labelFontSize"), fontStyle: i("labelFontStyle"), fontWeight: i("labelFontWeight"), limit: ybe(e.labelLimit, t.gradientLabelLimit) }), a ? (u.align = { value: "left" }, u.baseline = l.baseline = { signal: oxe }, c = "y", h = "x", f = "1-") : (u.align = l.align = { signal: axe }, u.baseline = { value: "top" }, c = "x", h = "y"), u[c] = l[c] = { signal: f + "datum." + Ive, mult: s }, u[h] = l[h] = o, o.offset = ybe(e.labelOffset, t.gradientLabelOffset) || 0, d = d ? { separation: i("labelSeparation"), method: d, order: "datum." + Tve } : void 0, nxe({ type: Xve, role: Bye, style: Dve, key: Fve, from: r, encode: p, overlap: d }, n) } function uxe(e, t, n, r, i) { const a = Zve(e, t), o = n.entries, s = !(!o || !o.interactive), u = o ? o.name : void 0, l = a("clipHeight"), c = a("symbolOffset"), h = { data: "value" }, d = `(${i}) ? datum.${Nve} : datum.${Lve}`, f = l ? wye(l) : { field: Lve }, p = `datum.${Tve}`, m = `max(1, ${i})`; let g, y, b, v, x; f.mult = .5, g = { enter: y = { opacity: Wve, x: { signal: d, mult: .5, offset: c }, y: f }, update: b = { opacity: Vve, x: y.x, y: y.y }, exit: { opacity: Wve } }; let w = null, k = null; e.fill || (w = t.symbolBaseFillColor, k = t.symbolBaseStrokeColor), Sye(g, { fill: a("symbolFillColor", w), shape: a("symbolType"), size: a("symbolSize"), stroke: a("symbolStrokeColor", k), strokeDash: a("symbolDash"), strokeDashOffset: a("symbolDashOffset"), strokeWidth: a("symbolStrokeWidth") }, { opacity: a("symbolOpacity") }), jve.forEach((t => { e[t] && (b[t] = y[t] = { scale: e[t], field: Fve }) })); const S = nxe({ type: Yve, role: Lye, key: Fve, from: h, clip: !!l || void 0, encode: g }, n.symbols), _ = wye(c); _.offset = a("labelOffset"), g = { enter: y = { opacity: Wve, x: { signal: d, offset: _ }, y: f }, update: b = { opacity: Vve, text: { field: Eve }, x: y.x, y: y.y }, exit: { opacity: Wve } }, Sye(g, { align: a("labelAlign"), baseline: a("labelBaseline"), fill: a("labelColor"), fillOpacity: a("labelOpacity"), font: a("labelFont"), fontSize: a("labelFontSize"), fontStyle: a("labelFontStyle"), fontWeight: a("labelFontWeight"), limit: a("labelLimit") }); const C = nxe({ type: Xve, role: Bye, style: Dve, key: Fve, from: h, encode: g }, n.labels); return g = { enter: { noBound: { value: !l }, width: Wve, height: l ? wye(l) : Wve, opacity: Wve }, exit: { opacity: Wve }, update: b = { opacity: Vve, row: { signal: null }, column: { signal: null } } }, a.isVertical(!0) ? (v = `ceil(item.mark.items.length / ${m})`, b.row.signal = `${p}%${v}`, b.column.signal = `floor(${p} / ${v})`, x = { field: ["row", p] }) : (b.row.signal = `floor(${p} / ${m})`, b.column.signal = `${p} % ${m}`, x = { field: p }), b.column.signal = `(${i})?${b.column.signal}:${p}`, Kve({ role: Eye, from: r = { facet: { data: r, name: "value", groupby: Tve } }, encode: _ye(g, o, Uve), marks: [S, C], name: u, interactive: s, sort: x }) } const lxe = 'item.orient === "left"', cxe = 'item.orient === "right"', hxe = `(${lxe} || ${cxe})`, dxe = `datum.vgrad && ${hxe}`, fxe = Qve('"top"', '"bottom"', '"middle"'), pxe = `datum.vgrad && ${cxe} ? (${Qve('"right"', '"left"', '"center"')}) : (${hxe} && !(datum.vgrad && ${lxe})) ? "left" : ${exe}`, mxe = `item._anchor || (${hxe} ? "middle" : "start")`, gxe = `${dxe} ? (${lxe} ? -90 : 90) : 0`, yxe = `${hxe} ? (datum.vgrad ? (${cxe} ? "bottom" : "top") : ${fxe}) : "top"`; function bxe(e, t) { let n; return sn(e) && (e.signal ? n = e.signal : e.path ? n = "pathShape(" + vxe(e.path) + ")" : e.sphere && (n = "geoShape(" + vxe(e.sphere) + ', {type: "Sphere"})')), n ? t.signalRef(n) : !!e } function vxe(e) { return sn(e) && e.signal ? e.signal : Yn(e) } function xxe(e) { const t = e.role || ""; return t.indexOf("axis") && t.indexOf("legend") && t.indexOf("title") ? e.type === Gve ? Eye : t || Aye : t } function wxe(e) { return { marktype: e.type, name: e.name || void 0, role: e.role || xxe(e), zindex: +e.zindex || void 0, aria: e.aria, description: e.description } } function kxe(e, t) { return e && e.signal ? t.signalRef(e.signal) : !1 !== e } function Sxe(e, t) { const n = Iu(e.type); n || Vt("Unrecognized transform type: " + Yn(e.type)); const r = obe(n.type.toLowerCase(), null, _xe(n, e, t)); return e.signal && t.addSignal(e.signal, t.proxy(r)), r.metadata = n.metadata || {}, r } function _xe(e, t, n) { const r = {}, i = e.params.length; for (let a = 0; a < i; ++a) { const i = e.params[a]; r[i.name] = Cxe(i, t, n) } return r } function Cxe(e, t, n) { const r = e.type, i = t[e.name]; return "index" === r ? function (e, t, n) { Vn(t.from) || Vt('Lookup "from" parameter must be a string literal.'); return n.getData(t.from).lookupRef(n, t.key) }(0, t, n) : void 0 !== i ? "param" === r ? function (e, t, n) { const r = t[e.name]; return e.array ? (on(r) || Vt("Expected an array of sub-parameters. Instead: " + Yn(r)), r.map((t => Txe(e, t, n)))) : Txe(e, r, n) }(e, t, n) : "projection" === r ? n.projectionRef(t[e.name]) : e.array && !mbe(i) ? i.map((t => Axe(e, t, n))) : Axe(e, i, n) : void (e.required && Vt("Missing required " + Yn(t.type) + " parameter: " + Yn(e.name))) } function Axe(e, t, n) { const r = e.type; if (mbe(t)) return Mxe(r) ? Vt("Expression references can not be signals.") : Fxe(r) ? n.fieldRef(t) : Dxe(r) ? n.compareRef(t) : n.signalRef(t.signal); { const i = e.expr || Fxe(r); return i && Exe(t) ? n.exprRef(t.expr, t.as) : i && Nxe(t) ? lbe(t.field, t.as) : Mxe(r) ? ite(t, n) : Ixe(r) ? ube(n.getData(t).values) : Fxe(r) ? lbe(t) : Dxe(r) ? n.compareRef(t) : t } } function Txe(e, t, n) { const r = e.params.length; let i; for (let n = 0; n < r; ++n) { i = e.params[n]; for (const e in i.key) if (i.key[e] !== t[e]) { i = null; break } if (i) break } i || Vt("Unsupported parameter: " + Yn(t)); const a = $n(_xe(i, t, n), i.key); return ube(n.add(Hbe(a))) } const Exe = e => e && e.expr, Nxe = e => e && e.field, Ixe = e => "data" === e, Mxe = e => "expr" === e, Fxe = e => "field" === e, Dxe = e => "compare" === e; function $xe(e, t) { return e.$ref ? e : e.data && e.data.$ref ? e.data : ube(t.getData(e.data).output) } function Rxe(e, t, n, r, i) { this.scope = e, this.input = t, this.output = n, this.values = r, this.aggregate = i, this.index = {} } function Oxe(e) { return Vn(e) ? e : null } function zxe(e, t, n) { const r = dbe(n.op, n.field); let i; if (t.ops) { for (let e = 0, n = t.as.length; e < n; ++e)if (t.as[e] === r) return } else t.ops = ["count"], t.fields = [null], t.as = ["count"]; n.op && (t.ops.push((i = n.op.signal) ? e.signalRef(i) : n.op), t.fields.push(e.fieldRef(n.field)), t.as.push(r)) } function Pxe(e, t, n, r, i, a, o) { const s = t[n] || (t[n] = {}), u = function (e) { return sn(e) ? ("descending" === e.order ? "-" : "+") + dbe(e.op, e.field) : "" }(a); let l, c, h = Oxe(i); if (null != h && (e = t.scope, h += u ? "|" + u : "", l = s[h]), !l) { const n = a ? { field: cbe, pulse: t.countsRef(e, i, a) } : { field: e.fieldRef(i), pulse: ube(t.output) }; u && (n.sort = e.sortRef(a)), c = e.add(obe(r, void 0, n)), o && (t.index[i] = c), l = ube(c), null != h && (s[h] = l) } return l } function Bxe(e, t, n) { const r = e.remove, i = e.insert, a = e.toggle, o = e.modify, s = e.values, u = t.add(sbe()), l = ite("if(" + e.trigger + ',modify("' + n + '",' + [i, r, a, o, s].map((e => null == e ? "null" : e)).join(",") + "),0)", t); u.update = l.$expr, u.params = l.$params } function Lxe(e, t) { const n = xxe(e), r = e.type === Gve, i = e.from && e.from.facet, a = e.overlap; let o, s, u, l, c, h, d, f = e.layout || n === Eye || n === Tye; const p = n === Aye || f || i, m = function (e, t, n) { let r, i, a, o, s; return e ? (r = e.facet) && (t || Vt("Only group marks can be faceted."), null != r.field ? o = s = $xe(r, n) : (e.data ? s = ube(n.getData(e.data).aggregate) : (a = Sxe($n({ type: "aggregate", groupby: _n(r.groupby) }, r.aggregate), n), a.params.key = n.keyRef(r.groupby), a.params.pulse = $xe(r, n), o = s = ube(n.add(a))), i = n.keyRef(r.groupby, !0))) : o = ube(n.add(Fbe(null, [{}]))), o || (o = $xe(e, n)), { key: i, pulse: o, parent: s } }(e.from, r, t); s = t.add($be({ key: m.key || (e.key ? lbe(e.key) : void 0), pulse: m.pulse, clean: !r })); const g = ube(s); s = u = t.add(Fbe({ pulse: g })), s = t.add(Ube({ markdef: wxe(e), interactive: kxe(e.interactive, t), clip: bxe(e.clip, t), context: { $context: !0 }, groups: t.lookup(), parent: t.signals.parent ? t.signalRef("parent") : null, index: t.markpath(), pulse: ube(s) })); const y = ube(s); s = l = t.add(Rbe(Jye(e.encode, e.type, n, e.style, t, { mod: !1, pulse: y }))), s.params.parent = t.encode(), e.transform && e.transform.forEach((e => { const n = Sxe(e, t), r = n.metadata; (r.generates || r.changes) && Vt("Mark transforms should not generate new data."), r.nomod || (l.params.mod = !0), n.params.pulse = ube(s), t.add(s = n) })), e.sort && (s = t.add(eve({ sort: t.compareRef(e.sort), pulse: ube(s) }))); const b = ube(s); (i || f) && (f = t.add(tve({ layout: t.objectProperty(e.layout), legends: t.legends, mark: y, pulse: b })), h = ube(f)); const v = t.add(Mbe({ mark: y, pulse: h || b })); d = ube(v), r && (p && (o = t.operators, o.pop(), f && o.pop()), t.pushState(b, h || d, g), i ? function (e, t, n) { const r = e.from.facet, i = r.name, a = $xe(r, t); let o; r.name || Vt("Facet must have a name: " + Yn(r)), r.data || Vt("Facet must reference a data set: " + Yn(r)), r.field ? o = t.add(qbe({ field: t.fieldRef(r.field), pulse: a })) : r.groupby ? o = t.add(zbe({ key: t.keyRef(r.groupby), group: ube(t.proxy(n.parent)), pulse: a })) : Vt("Facet must specify groupby or field: " + Yn(r)); const s = t.fork(), u = s.add(Fbe()), l = s.add(Qbe({ pulse: ube(u) })); s.addData(i, new Rxe(s, u, u, l)), s.addSignal("parent", null), o.params.subflow = { $subflow: s.parse(e).toRuntime() } }(e, t, m) : p ? function (e, t, n) { const r = t.add(qbe({ pulse: n.pulse })), i = t.fork(); i.add(Qbe()), i.addSignal("parent", null), r.params.subflow = { $subflow: i.parse(e).toRuntime() } }(e, t, m) : t.parse(e), t.popState(), p && (f && o.push(f), o.push(v))), a && (d = function (e, t, n) { const r = e.method, i = e.bound, a = e.separation, o = { separation: mbe(a) ? n.signalRef(a.signal) : a, method: mbe(r) ? n.signalRef(r.signal) : r, pulse: t }; e.order && (o.sort = n.compareRef({ field: e.order })); if (i) { const e = i.tolerance; o.boundTolerance = mbe(e) ? n.signalRef(e.signal) : +e, o.boundScale = n.scaleRef(i.scale), o.boundOrient = i.orient } return ube(n.add(Gbe(o))) }(a, d, t)); const x = t.add(Zbe({ pulse: d })), w = t.add(Qbe({ pulse: ube(x) }, void 0, t.parent())); null != e.name && (c = e.name, t.addData(c, new Rxe(t, u, x, w)), e.on && e.on.forEach((e => { (e.insert || e.remove || e.toggle) && Vt("Marks only support modify triggers."), Bxe(e, t, c) }))) } function jxe(e, t) { const n = t.config.legend, r = e.encode || {}, i = Zve(e, n), a = r.legend || {}, o = a.name || void 0, s = a.interactive, u = a.style, l = {}; let c, h, d, f = 0; jve.forEach((t => e[t] ? (l[t] = e[t], f = f || e[t]) : 0)), f || Vt("Missing valid scale for legend."); const p = function (e, t) { let n = e.type || zve; e.type || 1 !== function (e) { return jve.reduce(((t, n) => t + (e[n] ? 1 : 0)), 0) }(e) || !e.fill && !e.stroke || (n = gb(t) ? Pve : bb(t) ? Bve : zve); return n !== Pve ? n : bb(t) ? Bve : Pve }(e, t.scaleType(f)), m = { title: null != e.title, scales: l, type: p, vgrad: "symbol" !== p && i.isVertical() }, g = ube(t.add(Fbe(null, [m]))), y = ube(t.add(Lbe(h = { type: p, scale: t.scaleRef(f), count: t.objectProperty(i("tickCount")), limit: t.property(i("symbolLimit")), values: t.objectProperty(e.values), minstep: t.property(e.tickMinStep), formatType: t.property(e.formatType), formatSpecifier: t.property(e.format) }))); return p === Pve ? (d = [rxe(e, f, n, r.gradient), sxe(e, n, r.labels, y)], h.count = h.count || t.signalRef(`max(2,2*floor((${bbe(i.gradientLength())})/100))`)) : p === Bve ? d = [ixe(e, f, n, r.gradient, y), sxe(e, n, r.labels, y)] : (c = function (e, t) { const n = Zve(e, t); return { align: n("gridAlign"), columns: n.entryColumns(), center: { row: !0, column: !1 }, padding: { row: n("rowPadding"), column: n("columnPadding") } } }(e, n), d = [uxe(e, n, r, y, bbe(c.columns))], h.size = function (e, t, n) { const r = bbe(Wxe("size", e, n)), i = bbe(Wxe("strokeWidth", e, n)), a = bbe(function (e, t, n) { return Jve("fontSize", e) || function (e, t, n) { const r = t.config.style[n]; return r && r[e] }("fontSize", t, n) }(n[1].encode, t, Dve)); return ite(`max(ceil(sqrt(${r})+${i}),${a})`, t) }(e, t, d[0].marks)), d = [Kve({ role: zye, from: g, encode: { enter: { x: { value: 0 }, y: { value: 0 } } }, marks: d, layout: c, interactive: s })], m.title && d.push(function (e, t, n, r) { const i = Zve(e, t), a = { enter: { opacity: Wve }, update: { opacity: Vve, x: { field: { group: "padding" } }, y: { field: { group: "padding" } } }, exit: { opacity: Wve } }; return Sye(a, { orient: i("titleOrient"), _anchor: i("titleAnchor"), anchor: { signal: mxe }, angle: { signal: gxe }, align: { signal: pxe }, baseline: { signal: yxe }, text: e.title, fill: i("titleColor"), fillOpacity: i("titleOpacity"), font: i("titleFont"), fontSize: i("titleFontSize"), fontStyle: i("titleFontStyle"), fontWeight: i("titleFontWeight"), limit: i("titleLimit"), lineHeight: i("titleLineHeight") }, { align: i("titleAlign"), baseline: i("titleBaseline") }), nxe({ type: Xve, role: jye, style: $ve, from: r, encode: a }, n) }(e, n, r.title, g)), Lxe(Kve({ role: Rye, from: g, encode: _ye(Uxe(i, e, n), a, Uve), marks: d, aria: i("aria"), description: i("description"), zindex: i("zindex"), name: o, interactive: s, style: u }), t) } function Uxe(e, t, n) { const r = { enter: {}, update: {} }; return Sye(r, { orient: e("orient"), offset: e("offset"), padding: e("padding"), titlePadding: e("titlePadding"), cornerRadius: e("cornerRadius"), fill: e("fillColor"), stroke: e("strokeColor"), strokeWidth: n.strokeWidth, strokeDash: n.strokeDash, x: e("legendX"), y: e("legendY"), format: t.format, formatType: t.formatType }), r } function Wxe(e, t, n) { return t[e] ? `scale("${t[e]}",datum)` : Jve(e, n[0].encode) } Rxe.fromEntries = function (e, t) { const n = t.length, r = t[n - 1], i = t[n - 2]; let a = t[0], o = null, s = 1; for (a && "load" === a.type && (a = t[1]), e.add(t[0]); s < n; ++s)t[s].params.pulse = ube(t[s - 1]), e.add(t[s]), "aggregate" === t[s].type && (o = t[s]); return new Rxe(e, a, i, r, o) }, Rxe.prototype = { countsRef(e, t, n) { const r = this, i = r.counts || (r.counts = {}), a = Oxe(t); let o, s, u; return null != a && (e = r.scope, o = i[a]), o ? n && n.field && zxe(e, o.agg.params, n) : (u = { groupby: e.fieldRef(t, "key"), pulse: ube(r.output) }, n && n.field && zxe(e, u, n), s = e.add(Nbe(u)), o = e.add(Fbe({ pulse: ube(s) })), o = { agg: s, ref: ube(o) }, null != a && (i[a] = o)), o.ref }, tuplesRef() { return ube(this.values) }, extentRef(e, t) { return Pxe(e, this, "extent", "extent", t, !1) }, domainRef(e, t) { return Pxe(e, this, "domain", "values", t, !1) }, valuesRef(e, t, n) { return Pxe(e, this, "vals", "values", t, n || !0) }, lookupRef(e, t) { return Pxe(e, this, "lookup", "tupleindex", t, !1) }, indataRef(e, t) { return Pxe(e, this, "indata", "tupleindex", t, !0, !0) } }; const Vxe = `item.orient==="${xve}"?-90:item.orient==="${wve}"?90:0`; function Gxe(e, t) { const n = Zve(e = Vn(e) ? { text: e } : e, t.config.title), r = e.encode || {}, i = r.group || {}, a = i.name || void 0, o = i.interactive, s = i.style, u = [], l = ube(t.add(Fbe(null, [{}]))); return u.push(function (e, t, n, r) { const i = { value: 0 }, a = e.text, o = { enter: { opacity: i }, update: { opacity: { value: 1 } }, exit: { opacity: i } }; return Sye(o, { text: a, align: { signal: "item.mark.group.align" }, angle: { signal: "item.mark.group.angle" }, limit: { signal: "item.mark.group.limit" }, baseline: "top", dx: t("dx"), dy: t("dy"), fill: t("color"), font: t("font"), fontSize: t("fontSize"), fontStyle: t("fontStyle"), fontWeight: t("fontWeight"), lineHeight: t("lineHeight") }, { align: t("align"), angle: t("angle"), baseline: t("baseline") }), nxe({ type: Xve, role: Wye, style: Rve, from: r, encode: o }, n) }(e, n, function (e) { const t = e.encode; return t && t.title || $n({ name: e.name, interactive: e.interactive, style: e.style }, t) }(e), l)), e.subtitle && u.push(function (e, t, n, r) { const i = { value: 0 }, a = e.subtitle, o = { enter: { opacity: i }, update: { opacity: { value: 1 } }, exit: { opacity: i } }; return Sye(o, { text: a, align: { signal: "item.mark.group.align" }, angle: { signal: "item.mark.group.angle" }, limit: { signal: "item.mark.group.limit" }, baseline: "top", dx: t("dx"), dy: t("dy"), fill: t("subtitleColor"), font: t("subtitleFont"), fontSize: t("subtitleFontSize"), fontStyle: t("subtitleFontStyle"), fontWeight: t("subtitleFontWeight"), lineHeight: t("subtitleLineHeight") }, { align: t("align"), angle: t("angle"), baseline: t("baseline") }), nxe({ type: Xve, role: Vye, style: Ove, from: r, encode: o }, n) }(e, n, r.subtitle, l)), Lxe(Kve({ role: Uye, from: l, encode: Hxe(n, i), marks: u, aria: n("aria"), description: n("description"), zindex: n("zindex"), name: a, interactive: o, style: s }), t) } function Hxe(e, t) { const n = { enter: {}, update: {} }; return Sye(n, { orient: e("orient"), anchor: e("anchor"), align: { signal: exe }, angle: { signal: Vxe }, limit: e("limit"), frame: e("frame"), offset: e("offset") || 0, padding: e("subtitlePadding") }), _ye(n, t, Uve) } function qxe(e, t) { const n = []; e.transform && e.transform.forEach((e => { n.push(Sxe(e, t)) })), e.on && e.on.forEach((n => { Bxe(n, t, e.name) })), t.addDataPipeline(e.name, function (e, t, n) { const r = []; let i, a, o, s, u, l = null, c = !1, h = !1; e.values ? mbe(e.values) || gbe(e.format) ? (r.push(Xxe(t, e)), r.push(l = Yxe())) : r.push(l = Yxe({ $ingest: e.values, $format: e.format })) : e.url ? gbe(e.url) || gbe(e.format) ? (r.push(Xxe(t, e)), r.push(l = Yxe())) : r.push(l = Yxe({ $request: e.url, $format: e.format })) : e.source && (l = i = _n(e.source).map((e => ube(t.getData(e).output))), r.push(null)); for (a = 0, o = n.length; a < o; ++a)s = n[a], u = s.metadata, l || u.source || r.push(l = Yxe()), r.push(s), u.generates && (h = !0), u.modifies && !h && (c = !0), u.source ? l = s : u.changes && (l = null); i && (o = i.length - 1, r[0] = Kbe({ derive: c, pulse: o ? i : i[0] }), (c || o) && r.splice(1, 0, Yxe())); l || r.push(Yxe()); return r.push(Qbe({})), r }(e, t, n)) } function Yxe(e) { const t = Fbe({}, e); return t.metadata = { source: !0 }, t } function Xxe(e, t) { return jbe({ url: t.url ? e.property(t.url) : void 0, async: t.async ? e.property(t.async) : void 0, values: t.values ? e.property(t.values) : void 0, format: e.objectProperty(t.format) }) } const Kxe = e => e === kve || e === vve, Zxe = (e, t, n) => mbe(e) ? iwe(e.signal, t, n) : e === xve || e === vve ? t : n, Jxe = (e, t, n) => mbe(e) ? nwe(e.signal, t, n) : Kxe(e) ? t : n, Qxe = (e, t, n) => mbe(e) ? rwe(e.signal, t, n) : Kxe(e) ? n : t, ewe = (e, t, n) => mbe(e) ? awe(e.signal, t, n) : e === vve ? { value: t } : { value: n }, twe = (e, t, n) => mbe(e) ? owe(e.signal, t, n) : e === wve ? { value: t } : { value: n }, nwe = (e, t, n) => swe(`${e} === '${vve}' || ${e} === '${kve}'`, t, n), rwe = (e, t, n) => swe(`${e} !== '${vve}' && ${e} !== '${kve}'`, t, n), iwe = (e, t, n) => lwe(`${e} === '${xve}' || ${e} === '${vve}'`, t, n), awe = (e, t, n) => lwe(`${e} === '${vve}'`, t, n), owe = (e, t, n) => lwe(`${e} === '${wve}'`, t, n), swe = (e, t, n) => (t = null != t ? wye(t) : t, n = null != n ? wye(n) : n, uwe(t) && uwe(n) ? { signal: `${e} ? (${t = t ? t.signal || Yn(t.value) : null}) : (${n = n ? n.signal || Yn(n.value) : null})` } : [$n({ test: e }, t)].concat(n || [])), uwe = e => null == e || 1 === Object.keys(e).length, lwe = (e, t, n) => ({ signal: `${e} ? (${hwe(t)}) : (${hwe(n)})` }), cwe = (e, t, n, r, i) => ({ signal: (null != r ? `${e} === '${xve}' ? (${hwe(r)}) : ` : "") + (null != n ? `${e} === '${kve}' ? (${hwe(n)}) : ` : "") + (null != i ? `${e} === '${wve}' ? (${hwe(i)}) : ` : "") + (null != t ? `${e} === '${vve}' ? (${hwe(t)}) : ` : "") + "(null)" }), hwe = e => mbe(e) ? e.signal : null == e ? null : Yn(e), dwe = (e, t) => 0 === t ? 0 : mbe(e) ? { signal: `(${e.signal}) * ${t}` } : { value: e * t }, fwe = (e, t) => { const n = e.signal; return n && n.endsWith("(null)") ? { signal: n.slice(0, -6) + t.signal } : e }; function pwe(e, t, n, r) { let i; if (t && zn(t, e)) return t[e]; if (zn(n, e)) return n[e]; if (e.startsWith("title")) { switch (e) { case "titleColor": i = "fill"; break; case "titleFont": case "titleFontSize": case "titleFontWeight": i = e[5].toLowerCase() + e.slice(6) }return r[$ve][i] } if (e.startsWith("label")) { switch (e) { case "labelColor": i = "fill"; break; case "labelFont": case "labelFontSize": i = e[5].toLowerCase() + e.slice(6) }return r[Dve][i] } return null } function mwe(e) { const t = {}; for (const n of e) if (n) for (const e in n) t[e] = 1; return Object.keys(t) } function gwe(e, t) { return { scale: e.scale, range: t } } function ywe(e, t, n, r, i) { const a = Zve(e, t), o = e.orient, s = e.gridScale, u = Zxe(o, 1, -1), l = function (e, t) { if (1 === t); else if (sn(e)) { let n = e = $n({}, e); for (; null != n.mult;) { if (!sn(n.mult)) return n.mult = mbe(t) ? { signal: `(${n.mult}) * (${t.signal})` } : n.mult * t, e; n = n.mult = $n({}, n.mult) } n.mult = t } else e = mbe(t) ? { signal: `(${t.signal}) * (${e || 0})` } : t * (e || 0); return e }(e.offset, u); let c, h, d; const f = { enter: c = { opacity: Wve }, update: d = { opacity: Vve }, exit: h = { opacity: Wve } }; Sye(f, { stroke: a("gridColor"), strokeCap: a("gridCap"), strokeDash: a("gridDash"), strokeDashOffset: a("gridDashOffset"), strokeOpacity: a("gridOpacity"), strokeWidth: a("gridWidth") }); const p = { scale: e.scale, field: Fve, band: i.band, extra: i.extra, offset: i.offset, round: a("tickRound") }, m = Jxe(o, { signal: "height" }, { signal: "width" }), g = s ? { scale: s, range: 0, mult: u, offset: l } : { value: 0, offset: l }, y = s ? { scale: s, range: 1, mult: u, offset: l } : $n(m, { mult: u, offset: l }); return c.x = d.x = Jxe(o, p, g), c.y = d.y = Qxe(o, p, g), c.x2 = d.x2 = Qxe(o, y), c.y2 = d.y2 = Jxe(o, y), h.x = Jxe(o, p), h.y = Qxe(o, p), nxe({ type: qve, role: Mye, key: Fve, from: r, encode: f }, n) } function bwe(e, t, n, r, i) { return { signal: 'flush(range("' + e + '"), scale("' + e + '", datum.value), ' + t + "," + n + "," + r + "," + i + ")" } } function vwe(e, t, n, r) { const i = Zve(e, t), a = e.orient, o = Zxe(a, -1, 1); let s, u; const l = { enter: s = { opacity: Wve, anchor: wye(i("titleAnchor", null)), align: { signal: exe } }, update: u = $n({}, s, { opacity: Vve, text: wye(e.title) }), exit: { opacity: Wve } }, c = { signal: `lerp(range("${e.scale}"), ${Qve(0, 1, .5)})` }; return u.x = Jxe(a, c), u.y = Qxe(a, c), s.angle = Jxe(a, Wve, dwe(o, 90)), s.baseline = Jxe(a, ewe(a, kve, vve), { value: kve }), u.angle = s.angle, u.baseline = s.baseline, Sye(l, { fill: i("titleColor"), fillOpacity: i("titleOpacity"), font: i("titleFont"), fontSize: i("titleFontSize"), fontStyle: i("titleFontStyle"), fontWeight: i("titleFontWeight"), limit: i("titleLimit"), lineHeight: i("titleLineHeight") }, { align: i("titleAlign"), angle: i("titleAngle"), baseline: i("titleBaseline") }), function (e, t, n, r) { const i = (e, t) => null != e ? (n.update[t] = fwe(wye(e), n.update[t]), !1) : !Cye(t, r), a = i(e("titleX"), "x"), o = i(e("titleY"), "y"); n.enter.auto = o === a ? wye(o) : Jxe(t, wye(o), wye(a)) }(i, a, l, n), l.update.align = fwe(l.update.align, s.align), l.update.angle = fwe(l.update.angle, s.angle), l.update.baseline = fwe(l.update.baseline, s.baseline), nxe({ type: Xve, role: $ye, style: $ve, from: r, encode: l }, n) } function xwe(e, t) { const n = function (e, t) { var n, r, i, a = t.config, o = a.style, s = a.axis, u = "band" === t.scaleType(e.scale) && a.axisBand, l = e.orient; if (mbe(l)) { const e = mwe([a.axisX, a.axisY]), t = mwe([a.axisTop, a.axisBottom, a.axisLeft, a.axisRight]); for (i of (n = {}, e)) n[i] = Jxe(l, pwe(i, a.axisX, s, o), pwe(i, a.axisY, s, o)); for (i of (r = {}, t)) r[i] = cwe(l.signal, pwe(i, a.axisTop, s, o), pwe(i, a.axisBottom, s, o), pwe(i, a.axisLeft, s, o), pwe(i, a.axisRight, s, o)) } else n = l === vve || l === kve ? a.axisX : a.axisY, r = a["axis" + l[0].toUpperCase() + l.slice(1)]; return n || r || u ? $n({}, s, n, r, u) : s }(e, t), r = e.encode || {}, i = r.axis || {}, a = i.name || void 0, o = i.interactive, s = i.style, u = Zve(e, n), l = function (e) { const t = e("tickBand"); let n, r, i = e("tickOffset"); return t ? t.signal ? (n = { signal: `(${t.signal}) === 'extent' ? 1 : 0.5` }, r = { signal: `(${t.signal}) === 'extent'` }, sn(i) || (i = { signal: `(${t.signal}) === 'extent' ? 0 : ${i}` })) : "extent" === t ? (n = 1, r = !0, i = 0) : (n = .5, r = !1) : (n = e("bandPosition"), r = e("tickExtra")), { extra: r, band: n, offset: i } }(u), c = { scale: e.scale, ticks: !!u("ticks"), labels: !!u("labels"), grid: !!u("grid"), domain: !!u("domain"), title: null != e.title }, h = ube(t.add(Fbe({}, [c]))), d = ube(t.add(Ibe({ scale: t.scaleRef(e.scale), extra: t.property(l.extra), count: t.objectProperty(e.tickCount), values: t.objectProperty(e.values), minstep: t.property(e.tickMinStep), formatType: t.property(e.formatType), formatSpecifier: t.property(e.format) }))), f = []; let p; return c.grid && f.push(ywe(e, n, r.grid, d, l)), c.ticks && (p = u("tickSize"), f.push(function (e, t, n, r, i, a) { const o = Zve(e, t), s = e.orient, u = Zxe(s, -1, 1); let l, c, h; const d = { enter: l = { opacity: Wve }, update: h = { opacity: Vve }, exit: c = { opacity: Wve } }; Sye(d, { stroke: o("tickColor"), strokeCap: o("tickCap"), strokeDash: o("tickDash"), strokeDashOffset: o("tickDashOffset"), strokeOpacity: o("tickOpacity"), strokeWidth: o("tickWidth") }); const f = wye(i); f.mult = u; const p = { scale: e.scale, field: Fve, band: a.band, extra: a.extra, offset: a.offset, round: o("tickRound") }; return h.y = l.y = Jxe(s, Wve, p), h.y2 = l.y2 = Jxe(s, f), c.x = Jxe(s, p), h.x = l.x = Qxe(s, Wve, p), h.x2 = l.x2 = Qxe(s, f), c.y = Qxe(s, p), nxe({ type: qve, role: Dye, key: Fve, from: r, encode: d }, n) }(e, n, r.ticks, d, p, l))), c.labels && (p = c.ticks ? p : 0, f.push(function (e, t, n, r, i, a) { const o = Zve(e, t), s = e.orient, u = e.scale, l = Zxe(s, -1, 1), c = bbe(o("labelFlush")), h = bbe(o("labelFlushOffset")), d = o("labelAlign"), f = o("labelBaseline"); let p, m = 0 === c || !!c; const g = wye(i); g.mult = l, g.offset = wye(o("labelPadding") || 0), g.offset.mult = l; const y = { scale: u, field: Fve, band: .5, offset: txe(a.offset, o("labelOffset")) }, b = Jxe(s, m ? bwe(u, c, '"left"', '"right"', '"center"') : { value: "center" }, twe(s, "left", "right")), v = Jxe(s, ewe(s, "bottom", "top"), m ? bwe(u, c, '"top"', '"bottom"', '"middle"') : { value: "middle" }), x = bwe(u, c, `-(${h})`, h, 0); m = m && h; const w = { opacity: Wve, x: Jxe(s, y, g), y: Qxe(s, y, g) }, k = { enter: w, update: p = { opacity: Vve, text: { field: Eve }, x: w.x, y: w.y, align: b, baseline: v }, exit: { opacity: Wve, x: w.x, y: w.y } }; Sye(k, { dx: !d && m ? Jxe(s, x) : null, dy: !f && m ? Qxe(s, x) : null }), Sye(k, { angle: o("labelAngle"), fill: o("labelColor"), fillOpacity: o("labelOpacity"), font: o("labelFont"), fontSize: o("labelFontSize"), fontWeight: o("labelFontWeight"), fontStyle: o("labelFontStyle"), limit: o("labelLimit"), lineHeight: o("labelLineHeight") }, { align: d, baseline: f }); const S = o("labelBound"); let _ = o("labelOverlap"); return _ = _ || S ? { separation: o("labelSeparation"), method: _, order: "datum.index", bound: S ? { scale: u, orient: s, tolerance: S } : null } : void 0, p.align !== b && (p.align = fwe(p.align, b)), p.baseline !== v && (p.baseline = fwe(p.baseline, v)), nxe({ type: Xve, role: Fye, style: Dve, key: Fve, from: r, encode: k, overlap: _ }, n) }(e, n, r.labels, d, p, l))), c.domain && f.push(function (e, t, n, r) { const i = Zve(e, t), a = e.orient; let o, s; const u = { enter: o = { opacity: Wve }, update: s = { opacity: Vve }, exit: { opacity: Wve } }; Sye(u, { stroke: i("domainColor"), strokeCap: i("domainCap"), strokeDash: i("domainDash"), strokeDashOffset: i("domainDashOffset"), strokeWidth: i("domainWidth"), strokeOpacity: i("domainOpacity") }); const l = gwe(e, 0), c = gwe(e, 1); return o.x = s.x = Jxe(a, l, Wve), o.x2 = s.x2 = Jxe(a, c), o.y = s.y = Qxe(a, l, Wve), o.y2 = s.y2 = Qxe(a, c), nxe({ type: qve, role: Iye, from: r, encode: u }, n) }(e, n, r.domain, h)), c.title && f.push(vwe(e, n, r.title, h)), Lxe(Kve({ role: Nye, from: h, encode: _ye(wwe(u, e), i, Uve), marks: f, aria: u("aria"), description: u("description"), zindex: u("zindex"), name: a, interactive: o, style: s }), t) } function wwe(e, t) { const n = { enter: {}, update: {} }; return Sye(n, { orient: e("orient"), offset: e("offset") || 0, position: ybe(t.position, 0), titlePadding: e("titlePadding"), minExtent: e("minExtent"), maxExtent: e("maxExtent"), range: { signal: `abs(span(range("${t.scale}")))` }, translate: e("translate"), format: t.format, formatType: t.formatType }), n } function kwe(e, t, n) { const r = _n(e.signals), i = _n(e.scales); return n || r.forEach((e => ibe(e, t))), _n(e.projections).forEach((e => function (e, t) { const n = t.config.projection || {}, r = {}; for (const n in e) "name" !== n && (r[n] = bve(e[n], n, t)); for (const e in n) null == r[e] && (r[e] = bve(n[e], e, t)); t.addProjection(e.name, r) }(e, t))), i.forEach((e => function (e, t) { const n = e.type || "linear"; pb(n) || Vt("Unrecognized scale type: " + Yn(n)), t.addScale(e.name, { type: n, domain: void 0 }) }(e, t))), _n(e.data).forEach((e => qxe(e, t))), i.forEach((e => ave(e, t))), (n || r).forEach((e => function (e, t) { const n = t.getSignal(e.name); let r = e.update; e.init && (r ? Vt("Signals can not include both init and update expressions.") : (r = e.init, n.initonly = !0)), r && (r = ite(r, t), n.update = r.$expr, n.params = r.$params), e.on && e.on.forEach((e => Abe(e, t, n.id))) }(e, t))), _n(e.axes).forEach((e => xwe(e, t))), _n(e.marks).forEach((e => Lxe(e, t))), _n(e.legends).forEach((e => jxe(e, t))), e.title && Gxe(e.title, t), t.parseLambdas(), t } const Swe = e => _ye({ enter: { x: { value: 0 }, y: { value: 0 } }, update: { width: { signal: "width" }, height: { signal: "height" } } }, e); function _we(e, t) { const n = t.config, r = ube(t.root = t.add(sbe())), i = function (e, t) { const n = n => ybe(e[n], t[n]), r = [Cwe("background", n("background")), Cwe("autosize", yye(n("autosize"))), Cwe("padding", xye(n("padding"))), Cwe("width", n("width") || 0), Cwe("height", n("height") || 0)], i = r.reduce(((e, t) => (e[t.name] = t, e)), {}), a = {}; return _n(e.signals).forEach((e => { zn(i, e.name) ? e = $n(i[e.name], e) : r.push(e), a[e.name] = e })), _n(t.signals).forEach((e => { zn(a, e.name) || zn(i, e.name) || r.push(e) })), r }(e, n); i.forEach((e => ibe(e, t))), t.description = e.description || n.description, t.eventConfig = n.events, t.legends = t.objectProperty(n.legend && n.legend.layout), t.locale = n.locale; const a = t.add(Fbe()), o = t.add(Rbe(Jye(Swe(e.encode), Gve, Tye, e.style, t, { pulse: ube(a) }))), s = t.add(tve({ layout: t.objectProperty(e.layout), legends: t.legends, autosize: t.signalRef("autosize"), mark: r, pulse: ube(o) })); t.operators.pop(), t.pushState(ube(o), ube(s), null), kwe(e, t, i), t.operators.push(s); let u = t.add(Mbe({ mark: r, pulse: ube(s) })); return u = t.add(Zbe({ pulse: ube(u) })), u = t.add(Qbe({ pulse: ube(u) })), t.addData("root", new Rxe(t, a, a, u)), t } function Cwe(e, t) { return t && t.signal ? { name: e, update: t.signal } : { name: e, value: t } } function Awe(e, t) { this.config = e || {}, this.options = t || {}, this.bindings = [], this.field = {}, this.signals = {}, this.lambdas = {}, this.scales = {}, this.events = {}, this.data = {}, this.streams = [], this.updates = [], this.operators = [], this.eventConfig = null, this.locale = null, this._id = 0, this._subid = 0, this._nextsub = [0], this._parent = [], this._encode = [], this._lookup = [], this._markpath = [] } function Twe(e) { this.config = e.config, this.options = e.options, this.legends = e.legends, this.field = Object.create(e.field), this.signals = Object.create(e.signals), this.lambdas = Object.create(e.lambdas), this.scales = Object.create(e.scales), this.events = Object.create(e.events), this.data = Object.create(e.data), this.streams = [], this.updates = [], this.operators = [], this._id = 0, this._subid = ++e._nextsub[0], this._nextsub = e._nextsub, this._parent = e._parent.slice(), this._encode = e._encode.slice(), this._lookup = e._lookup.slice(), this._markpath = e._markpath } function Ewe(e) { return (on(e) ? Nwe : Iwe)(e) } function Nwe(e) { const t = e.length; let n = "["; for (let r = 0; r < t; ++r) { const t = e[r]; n += (r > 0 ? "," : "") + (sn(t) ? t.signal || Ewe(t) : Yn(t)) } return n + "]" } function Iwe(e) { let t, n, r = "{", i = 0; for (t in e) n = e[t], r += (++i > 1 ? "," : "") + Yn(t) + ":" + (sn(n) ? n.signal || Ewe(n) : Yn(n)); return r + "}" } function Mwe(e, t, n) { return sn(e) || Vt("Input Vega specification must be an object."), t = function () { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)t[n] = arguments[n]; return t.reduce(((e, t) => { for (const n in t) if ("signals" === n) e.signals = cn(e.signals, t.signals); else { const r = "legend" === n ? { layout: 1 } : "style" === n || null; ln(e, n, t[n], r) } return e }), {}) }(function () { const e = "sans-serif", t = "#4c78a8", n = "#000", r = "#888", i = "#ddd"; return { description: "Vega visualization", padding: 0, autosize: "pad", background: null, events: { defaults: { allow: ["wheel"] } }, group: null, mark: null, arc: { fill: t }, area: { fill: t }, image: null, line: { stroke: t, strokeWidth: 2 }, path: { stroke: t }, rect: { fill: t }, rule: { stroke: n }, shape: { stroke: t }, symbol: { fill: t, size: 64 }, text: { fill: n, font: e, fontSize: 11 }, trail: { fill: t, size: 2 }, style: { "guide-label": { fill: n, font: e, fontSize: 10 }, "guide-title": { fill: n, font: e, fontSize: 11, fontWeight: "bold" }, "group-title": { fill: n, font: e, fontSize: 13, fontWeight: "bold" }, "group-subtitle": { fill: n, font: e, fontSize: 12 }, point: { size: 30, strokeWidth: 2, shape: "circle" }, circle: { size: 30, strokeWidth: 2 }, square: { size: 30, strokeWidth: 2, shape: "square" }, cell: { fill: "transparent", stroke: i } }, title: { orient: "top", anchor: "middle", offset: 4, subtitlePadding: 3 }, axis: { minExtent: 0, maxExtent: 200, bandPosition: .5, domain: !0, domainWidth: 1, domainColor: r, grid: !1, gridWidth: 1, gridColor: i, labels: !0, labelAngle: 0, labelLimit: 180, labelOffset: 0, labelPadding: 2, ticks: !0, tickColor: r, tickOffset: 0, tickRound: !0, tickSize: 5, tickWidth: 1, titlePadding: 4 }, axisBand: { tickOffset: -.5 }, projection: { type: "mercator" }, legend: { orient: "right", padding: 0, gridAlign: "each", columnPadding: 10, rowPadding: 2, symbolDirection: "vertical", gradientDirection: "vertical", gradientLength: 200, gradientThickness: 16, gradientStrokeColor: i, gradientStrokeWidth: 0, gradientLabelOffset: 2, labelAlign: "left", labelBaseline: "middle", labelLimit: 160, labelOffset: 4, labelOverlap: !0, symbolLimit: 30, symbolType: "circle", symbolSize: 100, symbolOffset: 0, symbolStrokeWidth: 1.5, symbolBaseFillColor: "transparent", symbolBaseStrokeColor: r, titleLimit: 180, titleOrient: "top", titlePadding: 5, layout: { offset: 18, direction: "horizontal", left: { direction: "vertical" }, right: { direction: "vertical" } } }, range: { category: { scheme: "tableau10" }, ordinal: { scheme: "blues" }, heatmap: { scheme: "yellowgreenblue" }, ramp: { scheme: "blues" }, diverging: { scheme: "blueorange", extent: [1, 0] }, symbol: ["circle", "square", "triangle-up", "cross", "diamond", "triangle-right", "triangle-down", "triangle-left"] } } }(), t, e.config), _we(e, new Awe(t, n)).toRuntime() } Awe.prototype = Twe.prototype = { parse(e) { return kwe(e, this) }, fork() { return new Twe(this) }, isSubscope() { return this._subid > 0 }, toRuntime() { return this.finish(), { description: this.description, operators: this.operators, streams: this.streams, updates: this.updates, bindings: this.bindings, eventConfig: this.eventConfig, locale: this.locale } }, id() { return (this._subid ? this._subid + ":" : 0) + this._id++ }, add(e) { return this.operators.push(e), e.id = this.id(), e.refs && (e.refs.forEach((t => { t.$ref = e.id })), e.refs = null), e }, proxy(e) { const t = e instanceof abe ? ube(e) : e; return this.add(Xbe({ value: t })) }, addStream(e) { return this.streams.push(e), e.id = this.id(), e }, addUpdate(e) { return this.updates.push(e), e }, finish() { let e, t; for (e in this.root && (this.root.root = !0), this.signals) this.signals[e].signal = e; for (e in this.scales) this.scales[e].scale = e; function n(e, t, n) { let r, i; e && (r = e.data || (e.data = {}), i = r[t] || (r[t] = []), i.push(n)) } for (e in this.data) { t = this.data[e], n(t.input, e, "input"), n(t.output, e, "output"), n(t.values, e, "values"); for (const r in t.index) n(t.index[r], e, "index:" + r) } return this }, pushState(e, t, n) { this._encode.push(ube(this.add(Qbe({ pulse: e })))), this._parent.push(t), this._lookup.push(n ? ube(this.proxy(n)) : null), this._markpath.push(-1) }, popState() { this._encode.pop(), this._parent.pop(), this._lookup.pop(), this._markpath.pop() }, parent() { return hn(this._parent) }, encode() { return hn(this._encode) }, lookup() { return hn(this._lookup) }, markpath() { const e = this._markpath; return ++e[e.length - 1] }, fieldRef(e, t) { if (Vn(e)) return lbe(e, t); e.signal || Vt("Unsupported field reference: " + Yn(e)); const n = e.signal; let r = this.field[n]; if (!r) { const e = { name: this.signalRef(n) }; t && (e.as = t), this.field[n] = r = ube(this.add(Pbe(e))) } return r }, compareRef(e) { let t = !1; const n = e => mbe(e) ? (t = !0, this.signalRef(e.signal)) : function (e) { return e && e.expr }(e) ? (t = !0, this.exprRef(e.expr)) : e, r = _n(e.field).map(n), i = _n(e.order).map(n); return t ? ube(this.add(Dbe({ fields: r, orders: i }))) : hbe(r, i) }, keyRef(e, t) { let n = !1; const r = this.signals; return e = _n(e).map((e => mbe(e) ? (n = !0, ube(r[e.signal])) : e)), n ? ube(this.add(Bbe({ fields: e, flat: t }))) : function (e, t) { const n = { $key: e }; return t && (n.$flat = !0), n }(e, t) }, sortRef(e) { if (!e) return e; const t = dbe(e.op, e.field), n = e.order || "ascending"; return n.signal ? ube(this.add(Dbe({ fields: t, orders: this.signalRef(n.signal) }))) : hbe(t, n) }, event(e, t) { const n = e + ":" + t; if (!this.events[n]) { const r = this.id(); this.streams.push({ id: r, source: e, type: t }), this.events[n] = r } return this.events[n] }, hasOwnSignal(e) { return zn(this.signals, e) }, addSignal(e, t) { this.hasOwnSignal(e) && Vt("Duplicate signal name: " + Yn(e)); const n = t instanceof abe ? t : this.add(sbe(t)); return this.signals[e] = n }, getSignal(e) { return this.signals[e] || Vt("Unrecognized signal name: " + Yn(e)), this.signals[e] }, signalRef(e) { return this.signals[e] ? ube(this.signals[e]) : (zn(this.lambdas, e) || (this.lambdas[e] = this.add(sbe(null))), ube(this.lambdas[e])) }, parseLambdas() { const e = Object.keys(this.lambdas); for (let t = 0, n = e.length; t < n; ++t) { const n = e[t], r = ite(n, this), i = this.lambdas[n]; i.params = r.$params, i.update = r.$expr } }, property(e) { return e && e.signal ? this.signalRef(e.signal) : e }, objectProperty(e) { return e && sn(e) ? this.signalRef(e.signal || Ewe(e)) : e }, exprRef(e, t) { const n = { expr: ite(e, this) }; return t && (n.expr.$name = t), ube(this.add(Obe(n))) }, addBinding(e, t) { this.bindings || Vt("Nested signals do not support binding: " + Yn(e)), this.bindings.push($n({ signal: e }, t)) }, addScaleProj(e, t) { zn(this.scales, e) && Vt("Duplicate scale or projection name: " + Yn(e)), this.scales[e] = this.add(t) }, addScale(e, t) { this.addScaleProj(e, Jbe(t)) }, addProjection(e, t) { this.addScaleProj(e, Ybe(t)) }, getScale(e) { return this.scales[e] || Vt("Unrecognized scale name: " + Yn(e)), this.scales[e] }, scaleRef(e) { return ube(this.getScale(e)) }, scaleType(e) { return this.getScale(e).params.type }, projectionRef(e) { return this.scaleRef(e) }, projectionType(e) { return this.scaleType(e) }, addData(e, t) { return zn(this.data, e) && Vt("Duplicate data set name: " + Yn(e)), this.data[e] = t }, getData(e) { return this.data[e] || Vt("Undefined data set name: " + Yn(e)), this.data[e] }, addDataPipeline(e, t) { return zn(this.data, e) && Vt("Duplicate data set name: " + Yn(e)), this.addData(e, Rxe.fromEntries(this, t)) } }; const Fwe = Qn(["rule"]), Dwe = Qn(["group", "image", "rect"]); function $we(e) { return (e + "").toLowerCase() } function Rwe(e, t, n) { n.endsWith(";") || (n = "return(" + n + ");"); const r = Function(...t.concat(n)); return e && e.functions ? r.bind(e.functions) : r } var Owe = { operator: (e, t) => Rwe(e, ["_"], t.code), parameter: (e, t) => Rwe(e, ["datum", "_"], t.code), event: (e, t) => Rwe(e, ["event"], t.code), handler: (e, t) => Rwe(e, ["_", "event"], `var datum=event.item&&event.item.datum;return ${t.code};`), encode: (e, t) => { const { marktype: n, channels: r } = t; let i = "var o=item,datum=o.datum,m=0,$;"; for (const e in r) { const t = "o[" + Yn(e) + "]"; i += `$=${r[e].code};if(${t}!==$)${t}=$,m=1;` } return i += function (e, t) { let n = ""; return Fwe[t] || (e.x2 && (e.x ? (Dwe[t] && (n += "if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"), n += "o.width=o.x2-o.x;") : n += "o.x=o.x2-(o.width||0);"), e.xc && (n += "o.x=o.xc-(o.width||0)/2;"), e.y2 && (e.y ? (Dwe[t] && (n += "if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"), n += "o.height=o.y2-o.y;") : n += "o.y=o.y2-(o.height||0);"), e.yc && (n += "o.y=o.yc-(o.height||0)/2;")), n }(r, n), i += "return m;", Rwe(e, ["item", "_"], i) }, codegen: { get(e) { const t = `[${e.map(Yn).join("][")}]`, n = Function("_", `return _${t};`); return n.path = t, n }, comparator(e, t) { let n; const r = Function("a", "b", "var u, v; return " + e.map(((e, r) => { const i = t[r]; let a, o; return e.path ? (a = `a${e.path}`, o = `b${e.path}`) : ((n = n || {})["f" + r] = e, a = `this.f${r}(a)`, o = `this.f${r}(b)`), function (e, t, n, r) { return `((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${n}\n : (u > v || v == null) && u != null ? ${r}\n : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n}\n : v !== v && u === u ? ${r} : ` }(a, o, -i, i) })).join("") + "0;"); return n ? r.bind(n) : r } } }; function zwe(e, t, n) { if (!e || !sn(e)) return e; for (let r, i = 0, a = Pwe.length; i < a; ++i)if (r = Pwe[i], zn(e, r.key)) return r.parse(e, t, n); return e } var Pwe = [{ key: "$ref", parse: function (e, t) { return t.get(e.$ref) || Vt("Operator not defined: " + e.$ref) } }, { key: "$key", parse: function (e, t) { const n = "k:" + e.$key + "_" + !!e.$flat; return t.fn[n] || (t.fn[n] = Gn(e.$key, e.$flat, t.expr.codegen)) } }, { key: "$expr", parse: function (e, t, n) { e.$params && t.parseParameters(e.$params, n); const r = "e:" + e.$expr.code; return t.fn[r] || (t.fn[r] = Pt(t.parameterExpression(e.$expr), e.$fields)) } }, { key: "$field", parse: function (e, t) { if (!e.$field) return null; const n = "f:" + e.$field + "_" + e.$name; return t.fn[n] || (t.fn[n] = Ht(e.$field, e.$name, t.expr.codegen)) } }, { key: "$encode", parse: function (e, t) { const n = e.$encode, r = {}; for (const e in n) { const i = n[e]; r[e] = Pt(t.encodeExpression(i.$expr), i.$fields), r[e].output = i.$output } return r } }, { key: "$compare", parse: function (e, t) { const n = "c:" + e.$compare + "_" + e.$order, r = _n(e.$compare).map((e => e && e.$tupleid ? Xs : e)); return t.fn[n] || (t.fn[n] = Tn(r, e.$order, t.expr.codegen)) } }, { key: "$context", parse: function (e, t) { return t } }, { key: "$subflow", parse: function (e, t) { const n = e.$subflow; return function (e, r, i) { const a = t.fork().parse(n), o = a.get(n.operators[0].id), s = a.signals.parent; return s && s.set(i), o.detachSubflow = () => t.detach(a), o } } }, { key: "$tupleid", parse: function () { return Xs } }]; const Bwe = { skip: !0 }; function Lwe(e, t, n, r) { return new jwe(e, t, n, r) } function jwe(e, t, n, r) { this.dataflow = e, this.transforms = t, this.events = e.events.bind(e), this.expr = r || Owe, this.signals = {}, this.scales = {}, this.nodes = {}, this.data = {}, this.fn = {}, n && (this.functions = Object.create(n), this.functions.context = this) } function Uwe(e) { this.dataflow = e.dataflow, this.transforms = e.transforms, this.events = e.events, this.expr = e.expr, this.signals = Object.create(e.signals), this.scales = Object.create(e.scales), this.nodes = Object.create(e.nodes), this.data = Object.create(e.data), this.fn = Object.create(e.fn), e.functions && (this.functions = Object.create(e.functions), this.functions.context = this) } function Wwe(e, t, n) { return e.fields = t || [], e.fname = n, e } function Vwe(e) { return 1 === e.length ? Gwe(e[0]) : Hwe(e) } jwe.prototype = Uwe.prototype = { fork() { const e = new Uwe(this); return (this.subcontext || (this.subcontext = [])).push(e), e }, detach(e) { this.subcontext = this.subcontext.filter((t => t !== e)); const t = Object.keys(e.nodes); for (const n of t) e.nodes[n]._targets = null; for (const n of t) e.nodes[n].detach(); e.nodes = null }, get(e) { return this.nodes[e] }, set(e, t) { return this.nodes[e] = t }, add(e, t) { const n = this, r = n.dataflow, i = e.value; if (n.set(e.id, t), function (e) { return "collect" === $we(e) }(e.type) && i && (i.$ingest ? r.ingest(t, i.$ingest, i.$format) : i.$request ? r.preload(t, i.$request, i.$format) : r.pulse(t, r.changeset().insert(i))), e.root && (n.root = t), e.parent) { let i = n.get(e.parent.$ref); i ? (r.connect(i, [t]), t.targets().add(i)) : (n.unresolved = n.unresolved || []).push((() => { i = n.get(e.parent.$ref), r.connect(i, [t]), t.targets().add(i) })) } if (e.signal && (n.signals[e.signal] = t), e.scale && (n.scales[e.scale] = t), e.data) for (const r in e.data) { const i = n.data[r] || (n.data[r] = {}); e.data[r].forEach((e => i[e] = t)) } }, resolve() { return (this.unresolved || []).forEach((e => e())), delete this.unresolved, this }, operator(e, t) { this.add(e, this.dataflow.add(e.value, t)) }, transform(e, t) { this.add(e, this.dataflow.add(this.transforms[$we(t)])) }, stream(e, t) { this.set(e.id, t) }, update(e, t, n, r, i) { this.dataflow.on(t, n, r, i, e.options) }, operatorExpression(e) { return this.expr.operator(this, e) }, parameterExpression(e) { return this.expr.parameter(this, e) }, eventExpression(e) { return this.expr.event(this, e) }, handlerExpression(e) { return this.expr.handler(this, e) }, encodeExpression(e) { return this.expr.encode(this, e) }, parse: function (e) { const t = this, n = e.operators || []; return e.background && (t.background = e.background), e.eventConfig && (t.eventConfig = e.eventConfig), e.locale && (t.locale = e.locale), n.forEach((e => t.parseOperator(e))), n.forEach((e => t.parseOperatorParameters(e))), (e.streams || []).forEach((e => t.parseStream(e))), (e.updates || []).forEach((e => t.parseUpdate(e))), t.resolve() }, parseOperator: function (e) { const t = this; !function (e) { return "operator" === $we(e) }(e.type) && e.type ? t.transform(e, e.type) : t.operator(e, e.update ? t.operatorExpression(e.update) : null) }, parseOperatorParameters: function (e) { const t = this; if (e.params) { const n = t.get(e.id); n || Vt("Invalid operator id: " + e.id), t.dataflow.connect(n, n.parameters(t.parseParameters(e.params), e.react, e.initonly)) } }, parseParameters: function (e, t) { t = t || {}; const n = this; for (const r in e) { const i = e[r]; t[r] = on(i) ? i.map((e => zwe(e, n, t))) : zwe(i, n, t) } return t }, parseStream: function (e) { var t, n = this, r = null != e.filter ? n.eventExpression(e.filter) : void 0, i = null != e.stream ? n.get(e.stream) : void 0; e.source ? i = n.events(e.source, e.type, r) : e.merge && (i = (t = e.merge.map((e => n.get(e))))[0].merge.apply(t[0], t.slice(1))), e.between && (t = e.between.map((e => n.get(e))), i = i.between(t[0], t[1])), e.filter && (i = i.filter(r)), null != e.throttle && (i = i.throttle(+e.throttle)), null != e.debounce && (i = i.debounce(+e.debounce)), null == i && Vt("Invalid stream definition: " + JSON.stringify(e)), e.consume && i.consume(!0), n.stream(e, i) }, parseUpdate: function (e) { var t, n = this, r = sn(r = e.source) ? r.$ref : r, i = n.get(r), a = e.update, o = void 0; i || Vt("Source not defined: " + e.source), t = e.target && e.target.$expr ? n.eventExpression(e.target.$expr) : n.get(e.target), a && a.$expr && (a.$params && (o = n.parseParameters(a.$params)), a = n.handlerExpression(a.$expr)), n.update(e, i, t, a, o) }, getState: function (e) { var t = this, n = {}; if (e.signals) { var r = n.signals = {}; Object.keys(t.signals).forEach((n => { const i = t.signals[n]; e.signals(n, i) && (r[n] = i.value) })) } if (e.data) { var i = n.data = {}; Object.keys(t.data).forEach((n => { const r = t.data[n]; e.data(n, r) && (i[n] = r.input.value) })) } return t.subcontext && !1 !== e.recurse && (n.subcontext = t.subcontext.map((t => t.getState(e)))), n }, setState: function (e) { var t = this, n = t.dataflow, r = e.data, i = e.signals; Object.keys(i || {}).forEach((e => { n.update(t.signals[e], i[e], Bwe) })), Object.keys(r || {}).forEach((e => { n.pulse(t.data[e].input, n.changeset().remove(Zt).insert(r[e])) })), (e.subcontext || []).forEach(((e, n) => { const r = t.subcontext[n]; r && r.setState(e) })) } }; const Gwe = e => function (t) { return t[e] }, Hwe = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function qwe(e) { throw Error(e) } function Ywe(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || qwe("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && qwe("Access path missing closing bracket: " + e), o && qwe("Access path missing closing quote: " + e), i > r && (i++, l()), t } function Xwe(e, t, n) { const r = Ywe(e); return e = 1 === r.length ? r[0] : e, Wwe((n && n.get || Vwe)(r), [e], t || e) } Xwe("id"), Wwe((e => e), [], "identity"), Wwe((() => 0), [], "zero"), Wwe((() => 1), [], "one"), Wwe((() => !0), [], "true"), Wwe((() => !1), [], "false"); Array.isArray; function Kwe(e) { return "function" == typeof e } const Zwe = Object.prototype.hasOwnProperty; function Jwe(e, t) { return Zwe.call(e, t) } function Qwe(e) { return "string" == typeof e } function eke(e) { const t = {}, n = e.length; for (let r = 0; r < n; ++r)t[e[r]] = !0; return t } const tke = "Property", nke = "ArrayExpression", rke = "BinaryExpression", ike = "CallExpression", ake = "ConditionalExpression", oke = "LogicalExpression", ske = "MemberExpression", uke = "ObjectExpression", lke = "UnaryExpression"; function cke(e) { this.type = e } var hke, dke, fke, pke, mke; cke.prototype.visit = function (e) { let t, n, r; if (e(this)) return 1; for (t = function (e) { switch (e.type) { case nke: return e.elements; case rke: case oke: return [e.left, e.right]; case ike: return [e.callee].concat(e.arguments); case ake: return [e.test, e.consequent, e.alternate]; case ske: return [e.object, e.property]; case uke: return e.properties; case tke: return [e.key, e.value]; case lke: return [e.argument]; default: return [] } }(this), n = 0, r = t.length; n < r; ++n)if (t[n].visit(e)) return 1 }; var gke = 1, yke = 2, bke = 3, vke = 4, xke = 5, wke = 6, kke = 7, Ske = 8; (hke = {})[gke] = "Boolean", hke[yke] = "", hke[bke] = "Identifier", hke[vke] = "Keyword", hke[xke] = "Null", hke[wke] = "Numeric", hke[kke] = "Punctuator", hke[Ske] = "String", hke[9] = "RegularExpression"; var _ke = "ArrayExpression", Cke = "BinaryExpression", Ake = "CallExpression", Tke = "ConditionalExpression", Eke = "Identifier", Nke = "Literal", Ike = "LogicalExpression", Mke = "MemberExpression", Fke = "ObjectExpression", Dke = "Property", $ke = "UnaryExpression", Rke = "Unexpected token %0", Oke = "Unexpected number", zke = "Unexpected string", Pke = "Unexpected identifier", Bke = "Unexpected reserved word", Lke = "Unexpected end of input", jke = "Invalid regular expression", Uke = "Invalid regular expression: missing /", Wke = "Octal literals are not allowed in strict mode.", Vke = "Duplicate data property in object literal not allowed in strict mode", Gke = "ILLEGAL", Hke = "Disabled.", qke = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), Yke = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"); function Xke(e, t) { if (!e) throw new Error("ASSERT: " + t) } function Kke(e) { return e >= 48 && e <= 57 } function Zke(e) { return "0123456789abcdefABCDEF".indexOf(e) >= 0 } function Jke(e) { return "01234567".indexOf(e) >= 0 } function Qke(e) { return 32 === e || 9 === e || 11 === e || 12 === e || 160 === e || e >= 5760 && [5760, 6158, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(e) >= 0 } function eSe(e) { return 10 === e || 13 === e || 8232 === e || 8233 === e } function tSe(e) { return 36 === e || 95 === e || e >= 65 && e <= 90 || e >= 97 && e <= 122 || 92 === e || e >= 128 && qke.test(String.fromCharCode(e)) } function nSe(e) { return 36 === e || 95 === e || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57 || 92 === e || e >= 128 && Yke.test(String.fromCharCode(e)) } const rSe = { if: 1, in: 1, do: 1, var: 1, for: 1, new: 1, try: 1, let: 1, this: 1, else: 1, case: 1, void: 1, with: 1, enum: 1, while: 1, break: 1, catch: 1, throw: 1, const: 1, yield: 1, class: 1, super: 1, return: 1, typeof: 1, delete: 1, switch: 1, export: 1, import: 1, public: 1, static: 1, default: 1, finally: 1, extends: 1, package: 1, private: 1, function: 1, continue: 1, debugger: 1, interface: 1, protected: 1, instanceof: 1, implements: 1 }; function iSe() { for (; fke < pke;) { const e = dke.charCodeAt(fke); if (!Qke(e) && !eSe(e)) break; ++fke } } function aSe(e) { var t, n, r, i = 0; for (n = "u" === e ? 4 : 2, t = 0; t < n; ++t)fke < pke && Zke(dke[fke]) ? (r = dke[fke++], i = 16 * i + "0123456789abcdef".indexOf(r.toLowerCase())) : wSe({}, Rke, Gke); return String.fromCharCode(i) } function oSe() { var e, t, n, r; for (t = 0, "}" === (e = dke[fke]) && wSe({}, Rke, Gke); fke < pke && Zke(e = dke[fke++]);)t = 16 * t + "0123456789abcdef".indexOf(e.toLowerCase()); return (t > 1114111 || "}" !== e) && wSe({}, Rke, Gke), t <= 65535 ? String.fromCharCode(t) : (n = 55296 + (t - 65536 >> 10), r = 56320 + (t - 65536 & 1023), String.fromCharCode(n, r)) } function sSe() { var e, t; for (e = dke.charCodeAt(fke++), t = String.fromCharCode(e), 92 === e && (117 !== dke.charCodeAt(fke) && wSe({}, Rke, Gke), ++fke, (e = aSe("u")) && "\\" !== e && tSe(e.charCodeAt(0)) || wSe({}, Rke, Gke), t = e); fke < pke && nSe(e = dke.charCodeAt(fke));)++fke, t += String.fromCharCode(e), 92 === e && (t = t.substr(0, t.length - 1), 117 !== dke.charCodeAt(fke) && wSe({}, Rke, Gke), ++fke, (e = aSe("u")) && "\\" !== e && nSe(e.charCodeAt(0)) || wSe({}, Rke, Gke), t += e); return t } function uSe() { var e, t; return e = fke, t = 92 === dke.charCodeAt(fke) ? sSe() : function () { var e, t; for (e = fke++; fke < pke;) { if (92 === (t = dke.charCodeAt(fke))) return fke = e, sSe(); if (!nSe(t)) break; ++fke } return dke.slice(e, fke) }(), { type: 1 === t.length ? bke : rSe.hasOwnProperty(t) ? vke : "null" === t ? xke : "true" === t || "false" === t ? gke : bke, value: t, start: e, end: fke } } function lSe() { var e, t, n, r, i = fke, a = dke.charCodeAt(fke), o = dke[fke]; switch (a) { case 46: case 40: case 41: case 59: case 44: case 123: case 125: case 91: case 93: case 58: case 63: case 126: return ++fke, { type: kke, value: String.fromCharCode(a), start: i, end: fke }; default: if (61 === (e = dke.charCodeAt(fke + 1))) switch (a) { case 43: case 45: case 47: case 60: case 62: case 94: case 124: case 37: case 38: case 42: return fke += 2, { type: kke, value: String.fromCharCode(a) + String.fromCharCode(e), start: i, end: fke }; case 33: case 61: return fke += 2, 61 === dke.charCodeAt(fke) && ++fke, { type: kke, value: dke.slice(i, fke), start: i, end: fke } } }return ">>>=" === (r = dke.substr(fke, 4)) ? { type: kke, value: r, start: i, end: fke += 4 } : ">>>" === (n = r.substr(0, 3)) || "<<=" === n || ">>=" === n ? { type: kke, value: n, start: i, end: fke += 3 } : o === (t = n.substr(0, 2))[1] && "+-<>&|".indexOf(o) >= 0 || "=>" === t ? { type: kke, value: t, start: i, end: fke += 2 } : ("//" === t && wSe({}, Rke, Gke), "<>=!+-*%&|^/".indexOf(o) >= 0 ? (++fke, { type: kke, value: o, start: i, end: fke }) : void wSe({}, Rke, Gke)) } function cSe() { var e, t, n; if (Xke(Kke((n = dke[fke]).charCodeAt(0)) || "." === n, "Numeric literal must start with a decimal digit or a decimal point"), t = fke, e = "", "." !== n) { if (e = dke[fke++], n = dke[fke], "0" === e) { if ("x" === n || "X" === n) return ++fke, function (e) { let t = ""; for (; fke < pke && Zke(dke[fke]);)t += dke[fke++]; return 0 === t.length && wSe({}, Rke, Gke), tSe(dke.charCodeAt(fke)) && wSe({}, Rke, Gke), { type: wke, value: parseInt("0x" + t, 16), start: e, end: fke } }(t); if (Jke(n)) return function (e) { let t = "0" + dke[fke++]; for (; fke < pke && Jke(dke[fke]);)t += dke[fke++]; return (tSe(dke.charCodeAt(fke)) || Kke(dke.charCodeAt(fke))) && wSe({}, Rke, Gke), { type: wke, value: parseInt(t, 8), octal: !0, start: e, end: fke } }(t); n && Kke(n.charCodeAt(0)) && wSe({}, Rke, Gke) } for (; Kke(dke.charCodeAt(fke));)e += dke[fke++]; n = dke[fke] } if ("." === n) { for (e += dke[fke++]; Kke(dke.charCodeAt(fke));)e += dke[fke++]; n = dke[fke] } if ("e" === n || "E" === n) if (e += dke[fke++], "+" !== (n = dke[fke]) && "-" !== n || (e += dke[fke++]), Kke(dke.charCodeAt(fke))) for (; Kke(dke.charCodeAt(fke));)e += dke[fke++]; else wSe({}, Rke, Gke); return tSe(dke.charCodeAt(fke)) && wSe({}, Rke, Gke), { type: wke, value: parseFloat(e), start: t, end: fke } } function hSe() { var e, t, n, r; return mke = null, iSe(), e = fke, t = function () { var e, t, n, r; for (Xke("/" === (e = dke[fke]), "Regular expression literal must start with a slash"), t = dke[fke++], n = !1, r = !1; fke < pke;)if (t += e = dke[fke++], "\\" === e) eSe((e = dke[fke++]).charCodeAt(0)) && wSe({}, Uke), t += e; else if (eSe(e.charCodeAt(0))) wSe({}, Uke); else if (n) "]" === e && (n = !1); else { if ("/" === e) { r = !0; break } "[" === e && (n = !0) } return r || wSe({}, Uke), { value: t.substr(1, t.length - 2), literal: t } }(), n = function () { var e, t, n; for (t = "", n = ""; fke < pke && nSe((e = dke[fke]).charCodeAt(0));)++fke, "\\" === e && fke < pke ? wSe({}, Rke, Gke) : (n += e, t += e); return n.search(/[^gimuy]/g) >= 0 && wSe({}, jke, n), { value: n, literal: t } }(), r = function (e, t) { let n = e; t.indexOf("u") >= 0 && (n = n.replace(/\\u\{([0-9a-fA-F]+)\}/g, ((e, t) => { if (parseInt(t, 16) <= 1114111) return "x"; wSe({}, jke) })).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x")); try { new RegExp(n) } catch (e) { wSe({}, jke) } try { return new RegExp(e, t) } catch (e) { return null } }(t.value, n.value), { literal: t.literal + n.literal, value: r, regex: { pattern: t.value, flags: n.value }, start: e, end: fke } } function dSe() { if (iSe(), fke >= pke) return { type: yke, start: fke, end: fke }; const e = dke.charCodeAt(fke); return tSe(e) ? uSe() : 40 === e || 41 === e || 59 === e ? lSe() : 39 === e || 34 === e ? function () { var e, t, n, r, i = "", a = !1; for (Xke("'" === (e = dke[fke]) || '"' === e, "String literal must starts with a quote"), t = fke, ++fke; fke < pke;) { if ((n = dke[fke++]) === e) { e = ""; break } if ("\\" === n) if ((n = dke[fke++]) && eSe(n.charCodeAt(0))) "\r" === n && "\n" === dke[fke] && ++fke; else switch (n) { case "u": case "x": "{" === dke[fke] ? (++fke, i += oSe()) : i += aSe(n); break; case "n": i += "\n"; break; case "r": i += "\r"; break; case "t": i += "\t"; break; case "b": i += "\b"; break; case "f": i += "\f"; break; case "v": i += "\v"; break; default: Jke(n) ? (0 !== (r = "01234567".indexOf(n)) && (a = !0), fke < pke && Jke(dke[fke]) && (a = !0, r = 8 * r + "01234567".indexOf(dke[fke++]), "0123".indexOf(n) >= 0 && fke < pke && Jke(dke[fke]) && (r = 8 * r + "01234567".indexOf(dke[fke++]))), i += String.fromCharCode(r)) : i += n } else { if (eSe(n.charCodeAt(0))) break; i += n } } return "" !== e && wSe({}, Rke, Gke), { type: Ske, value: i, octal: a, start: t, end: fke } }() : 46 === e ? Kke(dke.charCodeAt(fke + 1)) ? cSe() : lSe() : Kke(e) ? cSe() : lSe() } function fSe() { const e = mke; return fke = e.end, mke = dSe(), fke = e.end, e } function pSe() { const e = fke; mke = dSe(), fke = e } function mSe(e, t, n) { const r = new cke("||" === e || "&&" === e ? Ike : Cke); return r.operator = e, r.left = t, r.right = n, r } function gSe(e, t) { const n = new cke(Ake); return n.callee = e, n.arguments = t, n } function ySe(e) { const t = new cke(Eke); return t.name = e, t } function bSe(e) { const t = new cke(Nke); return t.value = e.value, t.raw = dke.slice(e.start, e.end), e.regex && ("//" === t.raw && (t.raw = "/(?:)/"), t.regex = e.regex), t } function vSe(e, t, n) { const r = new cke(Mke); return r.computed = "[" === e, r.object = t, r.property = n, r.computed || (n.member = !0), r } function xSe(e, t, n) { const r = new cke(Dke); return r.key = t, r.value = n, r.kind = e, r } function wSe(e, t) { var n, r = Array.prototype.slice.call(arguments, 2), i = t.replace(/%(\d)/g, ((e, t) => (Xke(t < r.length, "Message reference must be in range"), r[t]))); throw (n = new Error(i)).index = fke, n.description = i, n } function kSe(e) { e.type === yke && wSe(e, Lke), e.type === wke && wSe(e, Oke), e.type === Ske && wSe(e, zke), e.type === bke && wSe(e, Pke), e.type === vke && wSe(e, Bke), wSe(e, Rke, e.value) } function SSe(e) { const t = fSe(); t.type === kke && t.value === e || kSe(t) } function _Se(e) { return mke.type === kke && mke.value === e } function CSe(e) { return mke.type === vke && mke.value === e } function ASe() { const e = []; for (fke = mke.start, SSe("["); !_Se("]");)_Se(",") ? (fSe(), e.push(null)) : (e.push(PSe()), _Se("]") || SSe(",")); return fSe(), function (e) { const t = new cke(_ke); return t.elements = e, t }(e) } function TSe() { fke = mke.start; const e = fSe(); return e.type === Ske || e.type === wke ? (e.octal && wSe(e, Wke), bSe(e)) : ySe(e.value) } function ESe() { var e, t, n; return fke = mke.start, (e = mke).type === bke ? (n = TSe(), SSe(":"), xSe("init", n, PSe())) : e.type !== yke && e.type !== kke ? (t = TSe(), SSe(":"), xSe("init", t, PSe())) : void kSe(e) } function NSe() { var e, t, n = [], r = {}, i = String; for (fke = mke.start, SSe("{"); !_Se("}");)t = "$" + ((e = ESe()).key.type === Eke ? e.key.name : i(e.key.value)), Object.prototype.hasOwnProperty.call(r, t) ? wSe({}, Vke) : r[t] = !0, n.push(e), _Se("}") || SSe(","); return SSe("}"), function (e) { const t = new cke(Fke); return t.properties = e, t }(n) } const ISe = { if: 1 }; function MSe() { var e, t, n; if (_Se("(")) return function () { SSe("("); const e = BSe(); return SSe(")"), e }(); if (_Se("[")) return ASe(); if (_Se("{")) return NSe(); if (e = mke.type, fke = mke.start, e === bke || ISe[mke.value]) n = ySe(fSe().value); else if (e === Ske || e === wke) mke.octal && wSe(mke, Wke), n = bSe(fSe()); else { if (e === vke) throw new Error(Hke); e === gke ? ((t = fSe()).value = "true" === t.value, n = bSe(t)) : e === xke ? ((t = fSe()).value = null, n = bSe(t)) : _Se("/") || _Se("/=") ? (n = bSe(hSe()), pSe()) : kSe(fSe()) } return n } function FSe() { const e = []; if (SSe("("), !_Se(")")) for (; fke < pke && (e.push(PSe()), !_Se(")"));)SSe(","); return SSe(")"), e } function DSe() { fke = mke.start; const e = fSe(); return function (e) { return e.type === bke || e.type === vke || e.type === gke || e.type === xke }(e) || kSe(e), ySe(e.value) } function $Se() { SSe("["); const e = BSe(); return SSe("]"), e } function RSe() { const e = function () { var e; for (e = MSe(); ;)if (_Se(".")) SSe("."), e = vSe(".", e, DSe()); else if (_Se("(")) e = gSe(e, FSe()); else { if (!_Se("[")) break; e = vSe("[", e, $Se()) } return e }(); if (mke.type === kke && (_Se("++") || _Se("--"))) throw new Error(Hke); return e } function OSe() { var e, t; if (mke.type !== kke && mke.type !== vke) t = RSe(); else { if (_Se("++") || _Se("--")) throw new Error(Hke); if (_Se("+") || _Se("-") || _Se("~") || _Se("!")) e = fSe(), t = OSe(), t = function (e, t) { const n = new cke($ke); return n.operator = e, n.argument = t, n.prefix = !0, n }(e.value, t); else { if (CSe("delete") || CSe("void") || CSe("typeof")) throw new Error(Hke); t = RSe() } } return t } function zSe(e) { let t = 0; if (e.type !== kke && e.type !== vke) return 0; switch (e.value) { case "||": t = 1; break; case "&&": t = 2; break; case "|": t = 3; break; case "^": t = 4; break; case "&": t = 5; break; case "==": case "!=": case "===": case "!==": t = 6; break; case "<": case ">": case "<=": case ">=": case "instanceof": case "in": t = 7; break; case "<<": case ">>": case ">>>": t = 8; break; case "+": case "-": t = 9; break; case "*": case "/": case "%": t = 11 }return t } function PSe() { var e, t; return e = function () { var e, t, n, r, i, a, o, s, u, l; if (e = mke, u = OSe(), 0 === (i = zSe(r = mke))) return u; for (r.prec = i, fSe(), t = [e, mke], a = [u, r, o = OSe()]; (i = zSe(mke)) > 0;) { for (; a.length > 2 && i <= a[a.length - 2].prec;)o = a.pop(), s = a.pop().value, u = a.pop(), t.pop(), n = mSe(s, u, o), a.push(n); (r = fSe()).prec = i, a.push(r), t.push(mke), n = OSe(), a.push(n) } for (n = a[l = a.length - 1], t.pop(); l > 1;)t.pop(), n = mSe(a[l - 1].value, a[l - 2], n), l -= 2; return n }(), _Se("?") && (fSe(), t = PSe(), SSe(":"), e = function (e, t, n) { const r = new cke(Tke); return r.test = e, r.consequent = t, r.alternate = n, r }(e, t, PSe())), e } function BSe() { const e = PSe(); if (_Se(",")) throw new Error(Hke); return e } function LSe(e) { fke = 0, pke = (dke = e).length, mke = null, pSe(); const t = BSe(); if (mke.type !== yke) throw new Error("Unexpect token after expression."); return t } var jSe = { NaN: "NaN", E: "Math.E", LN2: "Math.LN2", LN10: "Math.LN10", LOG2E: "Math.LOG2E", LOG10E: "Math.LOG10E", PI: "Math.PI", SQRT1_2: "Math.SQRT1_2", SQRT2: "Math.SQRT2", MIN_VALUE: "Number.MIN_VALUE", MAX_VALUE: "Number.MAX_VALUE" }; function USe(e) { function t(t, n, r) { return i => function (t, n, r, i) { let a = e(n[0]); return r && (a = r + "(" + a + ")", 0 === r.lastIndexOf("new ", 0) && (a = "(" + a + ")")), a + "." + t + (i < 0 ? "" : 0 === i ? "()" : "(" + n.slice(1).map(e).join(",") + ")") }(t, i, n, r) } const n = "new Date", r = "String", i = "RegExp"; return { isNaN: "Number.isNaN", isFinite: "Number.isFinite", abs: "Math.abs", acos: "Math.acos", asin: "Math.asin", atan: "Math.atan", atan2: "Math.atan2", ceil: "Math.ceil", cos: "Math.cos", exp: "Math.exp", floor: "Math.floor", log: "Math.log", max: "Math.max", min: "Math.min", pow: "Math.pow", random: "Math.random", round: "Math.round", sin: "Math.sin", sqrt: "Math.sqrt", tan: "Math.tan", clamp: function (t) { t.length < 3 && qwe("Missing arguments to clamp function."), t.length > 3 && qwe("Too many arguments to clamp function."); const n = t.map(e); return "Math.max(" + n[1] + ", Math.min(" + n[2] + "," + n[0] + "))" }, now: "Date.now", utc: "Date.UTC", datetime: n, date: t("getDate", n, 0), day: t("getDay", n, 0), year: t("getFullYear", n, 0), month: t("getMonth", n, 0), hours: t("getHours", n, 0), minutes: t("getMinutes", n, 0), seconds: t("getSeconds", n, 0), milliseconds: t("getMilliseconds", n, 0), time: t("getTime", n, 0), timezoneoffset: t("getTimezoneOffset", n, 0), utcdate: t("getUTCDate", n, 0), utcday: t("getUTCDay", n, 0), utcyear: t("getUTCFullYear", n, 0), utcmonth: t("getUTCMonth", n, 0), utchours: t("getUTCHours", n, 0), utcminutes: t("getUTCMinutes", n, 0), utcseconds: t("getUTCSeconds", n, 0), utcmilliseconds: t("getUTCMilliseconds", n, 0), length: t("length", null, -1), parseFloat: "parseFloat", parseInt: "parseInt", upper: t("toUpperCase", r, 0), lower: t("toLowerCase", r, 0), substring: t("substring", r), split: t("split", r), trim: t("trim", r, 0), regexp: i, test: t("test", i), if: function (t) { t.length < 3 && qwe("Missing arguments to if function."), t.length > 3 && qwe("Too many arguments to if function."); const n = t.map(e); return "(" + n[0] + "?" + n[1] + ":" + n[2] + ")" } } } function WSe(e) { const t = (e = e || {}).allowed ? eke(e.allowed) : {}, n = e.forbidden ? eke(e.forbidden) : {}, r = e.constants || jSe, i = (e.functions || USe)(h), a = e.globalvar, o = e.fieldvar, s = Kwe(a) ? a : e => "".concat(a, '["').concat(e, '"]'); let u = {}, l = {}, c = 0; function h(e) { if (Qwe(e)) return e; const t = d[e.type]; return null == t && qwe("Unsupported type: " + e.type), t(e) } const d = { Literal: e => e.raw, Identifier: e => { const i = e.name; return c > 0 ? i : Jwe(n, i) ? qwe("Illegal identifier: " + i) : Jwe(r, i) ? r[i] : Jwe(t, i) ? i : (u[i] = 1, s(i)) }, MemberExpression: e => { const t = !e.computed, n = h(e.object); t && (c += 1); const r = h(e.property); return n === o && (l[function (e) { const t = e && e.length - 1; return t && ('"' === e[0] && '"' === e[t] || "'" === e[0] && "'" === e[t]) ? e.slice(1, -1) : e }(r)] = 1), t && (c -= 1), n + (t ? "." + r : "[" + r + "]") }, CallExpression: e => { "Identifier" !== e.callee.type && qwe("Illegal callee type: " + e.callee.type); const t = e.callee.name, n = e.arguments, r = Jwe(i, t) && i[t]; return r || qwe("Unrecognized function: " + t), Kwe(r) ? r(n) : r + "(" + n.map(h).join(",") + ")" }, ArrayExpression: e => "[" + e.elements.map(h).join(",") + "]", BinaryExpression: e => "(" + h(e.left) + " " + e.operator + " " + h(e.right) + ")", UnaryExpression: e => "(" + e.operator + h(e.argument) + ")", ConditionalExpression: e => "(" + h(e.test) + "?" + h(e.consequent) + ":" + h(e.alternate) + ")", LogicalExpression: e => "(" + h(e.left) + e.operator + h(e.right) + ")", ObjectExpression: e => "{" + e.properties.map(h).join(",") + "}", Property: e => { c += 1; const t = h(e.key); return c -= 1, t + ":" + h(e.value) } }; function f(e) { const t = { code: h(e), globals: Object.keys(u), fields: Object.keys(l) }; return u = {}, l = {}, t } return f.functions = i, f.constants = r, f } const VSe = "view", GSe = "[", HSe = "]", qSe = "{", YSe = "}", XSe = ":", KSe = ",", ZSe = "@", JSe = ">", QSe = /[[\]{}]/, e_e = { "*": 1, arc: 1, area: 1, group: 1, image: 1, line: 1, path: 1, rect: 1, rule: 1, shape: 1, symbol: 1, text: 1, trail: 1 }; let t_e, n_e; function r_e(e, t, n) { return t_e = t || VSe, n_e = n || e_e, a_e(e.trim()).map(o_e) } function i_e(e, t, n, r, i) { const a = e.length; let o, s = 0; for (; t < a; ++t) { if (o = e[t], !s && o === n) return t; i && i.indexOf(o) >= 0 ? --s : r && r.indexOf(o) >= 0 && ++s } return t } function a_e(e) { const t = [], n = e.length; let r = 0, i = 0; for (; i < n;)i = i_e(e, i, KSe, GSe + qSe, HSe + YSe), t.push(e.substring(r, i).trim()), r = ++i; if (0 === t.length) throw "Empty event selector: " + e; return t } function o_e(e) { return "[" === e[0] ? function (e) { const t = e.length; let n, r = 1; if (r = i_e(e, r, HSe, GSe, HSe), r === t) throw "Empty between selector: " + e; if (n = a_e(e.substring(1, r)), 2 !== n.length) throw "Between selector must have two elements: " + e; if (e = e.slice(r + 1).trim(), e[0] !== JSe) throw "Expected '>' after between selector: " + e; n = n.map(o_e); const i = o_e(e.slice(1).trim()); if (i.between) return { between: n, stream: i }; i.between = n; return i }(e) : function (e) { const t = { source: t_e }, n = []; let r, i, a = [0, 0], o = 0, s = 0, u = e.length, l = 0; if (e[u - 1] === YSe) { if (l = e.lastIndexOf(qSe), !(l >= 0)) throw "Unmatched right brace: " + e; try { a = function (e) { const t = e.split(KSe); if (!e.length || t.length > 2) throw e; return t.map((t => { const n = +t; if (n != n) throw e; return n })) }(e.substring(l + 1, u - 1)) } catch (t) { throw "Invalid throttle specification: " + e } u = (e = e.slice(0, l).trim()).length, l = 0 } if (!u) throw e; e[0] === ZSe && (o = ++l); r = i_e(e, l, XSe), r < u && (n.push(e.substring(s, r).trim()), s = l = ++r); if (l = i_e(e, l, GSe), l === u) n.push(e.substring(s, u).trim()); else if (n.push(e.substring(s, l).trim()), i = [], s = ++l, s === u) throw "Unmatched left bracket: " + e; for (; l < u;) { if (l = i_e(e, l, HSe), l === u) throw "Unmatched left bracket: " + e; if (i.push(e.substring(s, l).trim()), l < u - 1 && e[++l] !== GSe) throw "Expected left bracket: " + e; s = ++l } if (!(u = n.length) || QSe.test(n[u - 1])) throw "Invalid event selector: " + e; u > 1 ? (t.type = n[1], o ? t.markname = n[0].slice(1) : !function (e) { return n_e[e] }(n[0]) ? t.source = n[0] : t.marktype = n[0]) : t.type = n[0]; "!" === t.type.slice(-1) && (t.consume = !0, t.type = t.type.slice(0, -1)); null != i && (t.filter = i); a[0] && (t.throttle = a[0]); a[1] && (t.debounce = a[1]); return t }(e) } var s_e = "5.20.0"; ot(Nu, a, s, u, l, c, d, h, f, p, m, g); const u_e = s_e; function l_e(e, t, n) { return e.fields = t || [], e.fname = n, e } function c_e(e) { return 1 === e.length ? h_e(e[0]) : d_e(e) } const h_e = e => function (t) { return t[e] }, d_e = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function f_e(e) { throw Error(e) } function p_e(e) { var t, n, r, i = [], a = null, o = 0, s = e.length, u = ""; function l() { i.push(u + e.substring(t, n)), u = "", t = n + 1 } for (e += "", t = n = 0; n < s; ++n)if ("\\" === (r = e[n])) u += e.substring(t, n), u += e.substring(++n, ++n), t = n; else if (r === a) l(), a = null, o = -1; else { if (a) continue; t === o && '"' === r || t === o && "'" === r ? (t = n + 1, a = r) : "." !== r || o ? "[" === r ? (n > t && l(), o = t = n + 1) : "]" === r && (o || f_e("Access path missing open bracket: " + e), o > 0 && l(), o = 0, t = n + 1) : n > t ? l() : t = n + 1 } return o && f_e("Access path missing closing bracket: " + e), a && f_e("Access path missing closing quote: " + e), n > t && (n++, l()), i } var m_e = [], g_e = (function (e, t, n) { const r = p_e(e); e = 1 === r.length ? r[0] : e, l_e((n && n.get || c_e)(r), [e], t || e) }("id"), l_e((function (e) { return e }), m_e, "identity")); l_e((function () { return 0 }), m_e, "zero"), l_e((function () { return 1 }), m_e, "one"), l_e((function () { return !0 }), m_e, "true"), l_e((function () { return !1 }), m_e, "false"); function y_e(e, t, n) { var r = [t].concat([].slice.call(n)); console[e].apply(console, r) } const b_e = Array.isArray; function v_e(e) { return e === Object(e) } const x_e = e => "__proto__" !== e; function w_e(...e) { return e.reduce(((e, t) => { for (var n in t) if ("signals" === n) e.signals = S_e(e.signals, t.signals); else { var r = "legend" === n ? { layout: 1 } : "style" === n || null; k_e(e, n, t[n], r) } return e }), {}) } function k_e(e, t, n, r) { var i, a; if (x_e(t)) if (v_e(n) && !b_e(n)) for (i in a = v_e(e[t]) ? e[t] : e[t] = {}, n) r && (!0 === r || r[i]) ? k_e(a, i, n[i]) : x_e(i) && (a[i] = n[i]); else e[t] = n } function S_e(e, t) { if (null == e) return t; const n = {}, r = []; function i(e) { n[e.name] || (n[e.name] = 1, r.push(e)) } return t.forEach(i), e.forEach(i), r } function __e(e) { return null != e ? b_e(e) ? e : [e] : [] } const C_e = Object.prototype.hasOwnProperty; function A_e(e, t) { return C_e.call(e, t) } function T_e(e) { return "boolean" == typeof e } function E_e(e) { return "number" == typeof e } function N_e(e) { return "string" == typeof e } function I_e(e) { return b_e(e) ? "[" + e.map(I_e) + "]" : v_e(e) || N_e(e) ? JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029") : e } function M_e(e) { for (var t = {}, n = 0, r = e.length; n < r; ++n)t[e[n]] = !0; return t } function F_e(e, t) { var n = {}; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (null != e && "function" == typeof Object.getOwnPropertySymbols) { var i = 0; for (r = Object.getOwnPropertySymbols(e); i < r.length; i++)t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]) } return n } Object.create; Object.create; Array.prototype.flat || Object.defineProperty(Array.prototype, "flat", { configurable: !0, value: function e() { var t = isNaN(arguments[0]) ? 1 : Number(arguments[0]); return t ? Array.prototype.reduce.call(this, (function (n, r) { return Array.isArray(r) ? n.push.apply(n, e.call(r, t - 1)) : n.push(r), n }), []) : Array.prototype.slice.call(this) }, writable: !0 }), Array.prototype.flatMap || Object.defineProperty(Array.prototype, "flatMap", { configurable: !0, value: function (e) { return Array.prototype.map.apply(this, arguments).flat() }, writable: !0 }); var D_e = n(1779), $_e = n.n(D_e), R_e = n(2017), O_e = n.n(R_e), z_e = n(2492), P_e = n.n(z_e); function B_e(e) { return !!e.or } function L_e(e) { return !!e.and } function j_e(e) { return !!e.not } function U_e(e, t) { if (j_e(e)) U_e(e.not, t); else if (L_e(e)) for (const n of e.and) U_e(n, t); else if (B_e(e)) for (const n of e.or) U_e(n, t); else t(e) } function W_e(e, t) { return j_e(e) ? { not: W_e(e.not, t) } : L_e(e) ? { and: e.and.map((e => W_e(e, t))) } : B_e(e) ? { or: e.or.map((e => W_e(e, t))) } : t(e) } const V_e = O_e(), G_e = $_e(); function H_e(e, t) { const n = {}; for (const r of t) A_e(e, r) && (n[r] = e[r]); return n } function q_e(e, t) { const n = Object.assign({}, e); for (const e of t) delete n[e]; return n } Set.prototype.toJSON = function () { return `Set(${[...this].map((e => P_e()(e))).join(",")})` }; const Y_e = P_e(); function X_e(e) { if (E_e(e)) return e; const t = N_e(e) ? e : P_e()(e); if (t.length < 250) return t; let n = 0; for (let e = 0; e < t.length; e++) { n = (n << 5) - n + t.charCodeAt(e), n |= 0 } return n } function K_e(e) { return !1 === e || null === e } function Z_e(e, t) { return e.indexOf(t) > -1 } function J_e(e, t) { let n = 0; for (const [r, i] of e.entries()) if (t(i, r, n++)) return !0; return !1 } function Q_e(e, t) { let n = 0; for (const [r, i] of e.entries()) if (!t(i, r, n++)) return !1; return !0 } function eCe(e, t) { for (const n of oCe(t)) k_e(e, n, t[n], !0) } function tCe(e, t) { const n = [], r = {}; let i; for (const a of e) i = t(a), i in r || (r[i] = 1, n.push(a)); return n } function nCe(e, t) { for (const n of e) if (t.has(n)) return !0; return !1 } function rCe(e) { const t = new Set; for (const n of e) { const e = p_e(n).map(((e, t) => 0 === t ? e : `[${e}]`)), r = e.map(((t, n) => e.slice(0, n + 1).join(""))); for (const e of r) t.add(e) } return t } function iCe(e, t) { return void 0 === e || void 0 === t || nCe(rCe(e), rCe(t)) } function aCe(e) { return 0 === oCe(e).length } const oCe = Object.keys, sCe = Object.values; function uCe(e) { const t = []; for (const n in e) A_e(e, n) && t.push({ key: n, value: e[n] }); return t } function lCe(e) { return !0 === e || !1 === e } function cCe(e) { const t = e.replace(/\W/g, "_"); return (e.match(/^\d+/) ? "_" : "") + t } function hCe(e, t) { return j_e(e) ? "!(" + hCe(e.not, t) + ")" : L_e(e) ? "(" + e.and.map((e => hCe(e, t))).join(") && (") + ")" : B_e(e) ? "(" + e.or.map((e => hCe(e, t))).join(") || (") + ")" : t(e) } function dCe(e, t) { if (0 === t.length) return !0; const n = t.shift(); return n in e && dCe(e[n], t) && delete e[n], aCe(e) } function fCe(e) { return e.charAt(0).toUpperCase() + e.substr(1) } function pCe(e, t = "datum") { const n = p_e(e), r = []; for (let e = 1; e <= n.length; e++) { const i = `[${n.slice(0, e).map(I_e).join("][")}]`; r.push(`${t}${i}`) } return r.join(" && ") } function mCe(e) { return e.replace(/(\[|\]|\.|'|")/g, "\\$1") } function gCe(e) { return `${p_e(e).map(mCe).join("\\.")}` } function yCe(e, t, n) { return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), n) } function bCe(e) { return `${p_e(e).join(".")}` } function vCe(e) { return e ? p_e(e).length : 0 } function xCe(...e) { for (const t of e) if (void 0 !== t) return t } let wCe = 42; function kCe(e) { if (void 0 !== e) return (e % 360 + 360) % 360 } function SCe(e) { return !!E_e(e) || !isNaN(e) && !isNaN(parseFloat(e)) } const _Ce = { domainColor: { part: "domain", vgProp: "stroke" }, labelAlign: { part: "labels", vgProp: "align" }, labelBaseline: { part: "labels", vgProp: "baseline" }, labelColor: { part: "labels", vgProp: "fill" }, labelFont: { part: "labels", vgProp: "font" }, labelFontSize: { part: "labels", vgProp: "fontSize" }, labelFontStyle: { part: "labels", vgProp: "fontStyle" }, labelFontWeight: { part: "labels", vgProp: "fontWeight" }, labelOpacity: { part: "labels", vgProp: "opacity" }, labelOffset: null, labelPadding: null, gridColor: { part: "grid", vgProp: "stroke" }, gridDash: { part: "grid", vgProp: "strokeDash" }, gridDashOffset: { part: "grid", vgProp: "strokeDash" }, gridOpacity: { part: "grid", vgProp: "opacity" }, gridWidth: { part: "grid", vgProp: "strokeWidth" }, tickColor: { part: "ticks", vgProp: "stroke" }, tickDash: { part: "ticks", vgProp: "strokeDash" }, tickDashOffset: { part: "ticks", vgProp: "strokeDash" }, tickOpacity: { part: "ticks", vgProp: "opacity" }, tickSize: null, tickWidth: { part: "ticks", vgProp: "strokeWidth" }, titleColor: { part: "title", vgProp: "fill" }, title: null }; function CCe(e) { return e && e.condition } const ACe = ["domain", "grid", "labels", "ticks", "title"], TCe = { grid: "grid", gridCap: "grid", gridColor: "grid", gridDash: "grid", gridDashOffset: "grid", gridOpacity: "grid", gridScale: "grid", gridWidth: "grid", orient: "main", bandPosition: "both", aria: "main", description: "main", domain: "main", domainCap: "main", domainColor: "main", domainDash: "main", domainDashOffset: "main", domainOpacity: "main", domainWidth: "main", format: "main", formatType: "main", labelAlign: "main", labelAngle: "main", labelBaseline: "main", labelBound: "main", labelColor: "main", labelFlush: "main", labelFlushOffset: "main", labelFont: "main", labelFontSize: "main", labelFontStyle: "main", labelFontWeight: "main", labelLimit: "main", labelLineHeight: "main", labelOffset: "main", labelOpacity: "main", labelOverlap: "main", labelPadding: "main", labels: "main", labelSeparation: "main", maxExtent: "main", minExtent: "main", offset: "both", position: "main", tickCap: "main", tickColor: "main", tickDash: "main", tickDashOffset: "main", tickMinStep: "main", tickOffset: "both", tickOpacity: "main", tickRound: "both", ticks: "main", tickSize: "main", tickWidth: "both", title: "main", titleAlign: "main", titleAnchor: "main", titleAngle: "main", titleBaseline: "main", titleColor: "main", titleFont: "main", titleFontSize: "main", titleFontStyle: "main", titleFontWeight: "main", titleLimit: "main", titleLineHeight: "main", titleOpacity: "main", titlePadding: "main", titleX: "main", titleY: "main", encode: "both", scale: "both", tickBand: "both", tickCount: "both", tickExtra: "both", translate: "both", values: "both", zindex: "both" }, ECe = { orient: 1, aria: 1, bandPosition: 1, description: 1, domain: 1, domainCap: 1, domainColor: 1, domainDash: 1, domainDashOffset: 1, domainOpacity: 1, domainWidth: 1, format: 1, formatType: 1, grid: 1, gridCap: 1, gridColor: 1, gridDash: 1, gridDashOffset: 1, gridOpacity: 1, gridWidth: 1, labelAlign: 1, labelAngle: 1, labelBaseline: 1, labelBound: 1, labelColor: 1, labelFlush: 1, labelFlushOffset: 1, labelFont: 1, labelFontSize: 1, labelFontStyle: 1, labelFontWeight: 1, labelLimit: 1, labelLineHeight: 1, labelOffset: 1, labelOpacity: 1, labelOverlap: 1, labelPadding: 1, labels: 1, labelSeparation: 1, maxExtent: 1, minExtent: 1, offset: 1, position: 1, tickBand: 1, tickCap: 1, tickColor: 1, tickCount: 1, tickDash: 1, tickDashOffset: 1, tickExtra: 1, tickMinStep: 1, tickOffset: 1, tickOpacity: 1, tickRound: 1, ticks: 1, tickSize: 1, tickWidth: 1, title: 1, titleAlign: 1, titleAnchor: 1, titleAngle: 1, titleBaseline: 1, titleColor: 1, titleFont: 1, titleFontSize: 1, titleFontStyle: 1, titleFontWeight: 1, titleLimit: 1, titleLineHeight: 1, titleOpacity: 1, titlePadding: 1, titleX: 1, titleY: 1, translate: 1, values: 1, zindex: 1 }, NCe = Object.assign(Object.assign({}, ECe), { style: 1, labelExpr: 1, encoding: 1 }); function ICe(e) { return !!NCe[e] } oCe(NCe); const MCe = { arc: "arc", area: "area", bar: "bar", image: "image", line: "line", point: "point", rect: "rect", rule: "rule", text: "text", tick: "tick", trail: "trail", circle: "circle", square: "square", geoshape: "geoshape" }, FCe = MCe.arc, DCe = MCe.area, $Ce = MCe.bar, RCe = MCe.image, OCe = MCe.line, zCe = MCe.point, PCe = MCe.rect, BCe = MCe.rule, LCe = MCe.text, jCe = MCe.tick, UCe = MCe.trail, WCe = MCe.circle, VCe = MCe.square, GCe = MCe.geoshape; function HCe(e) { return Z_e(["line", "area", "trail"], e) } function qCe(e) { return Z_e(["rect", "bar", "image", "arc"], e) } const YCe = oCe(MCe); function XCe(e) { return e.type } M_e(YCe); const KCe = ["stroke", "strokeWidth", "strokeDash", "strokeDashOffset", "strokeOpacity", "strokeJoin", "strokeMiterLimit", "fill", "fillOpacity"], ZCe = oCe({ color: 1, filled: 1, invalid: 1, order: 1, radius2: 1, theta2: 1, timeUnitBand: 1, timeUnitBandPosition: 1 }), JCe = { horizontal: ["cornerRadiusTopRight", "cornerRadiusBottomRight"], vertical: ["cornerRadiusTopLeft", "cornerRadiusTopRight"] }, QCe = { binSpacing: 1, continuousBandSize: 5, timeUnitBandPosition: .5 }, eAe = { binSpacing: 0, continuousBandSize: 5, timeUnitBandPosition: .5 }; function tAe(e) { return "mark" in e } class nAe { constructor(e, t) { this.name = e, this.run = t } hasMatchingType(e) { return !!tAe(e) && function (e) { return XCe(e) ? e.type : e }(e.mark) === this.name } } const rAe = { argmax: 1, argmin: 1, average: 1, count: 1, distinct: 1, product: 1, max: 1, mean: 1, median: 1, min: 1, missing: 1, q1: 1, q3: 1, ci0: 1, ci1: 1, stderr: 1, stdev: 1, stdevp: 1, sum: 1, valid: 1, values: 1, variance: 1, variancep: 1 }, iAe = { count: 1, min: 1, max: 1 }; function aAe(e) { return !!e && !!e.argmin } function oAe(e) { return !!e && !!e.argmax } oCe(rAe); function sAe(e) { return N_e(e) && !!rAe[e] } const uAe = ["count", "valid", "missing", "distinct"]; function lAe(e) { return N_e(e) && Z_e(uAe, e) } const cAe = ["count", "sum", "distinct", "valid", "missing"], hAe = M_e(["mean", "average", "median", "q1", "q3", "min", "max"]), dAe = "row", fAe = "column", pAe = "facet", mAe = "x", gAe = "y", yAe = "x2", bAe = "y2", vAe = "radius", xAe = "radius2", wAe = "theta", kAe = "theta2", SAe = "latitude", _Ae = "longitude", CAe = "latitude2", AAe = "longitude2", TAe = "color", EAe = "fill", NAe = "stroke", IAe = "shape", MAe = "size", FAe = "angle", DAe = "opacity", $Ae = "fillOpacity", RAe = "strokeOpacity", OAe = "strokeWidth", zAe = "strokeDash", PAe = "text", BAe = "order", LAe = "detail", jAe = "key", UAe = "tooltip", WAe = "href", VAe = "url", GAe = "description", HAe = { theta: 1, theta2: 1, radius: 1, radius2: 1 }; function qAe(e) { return e in HAe } const YAe = { longitude: 1, longitude2: 1, latitude: 1, latitude2: 1 }; const XAe = oCe(YAe), KAe = Object.assign(Object.assign(Object.assign(Object.assign({}, { x: 1, y: 1, x2: 1, y2: 1 }), HAe), YAe), { color: 1, fill: 1, stroke: 1, opacity: 1, fillOpacity: 1, strokeOpacity: 1, strokeWidth: 1, strokeDash: 1, size: 1, angle: 1, shape: 1, order: 1, text: 1, detail: 1, key: 1, tooltip: 1, href: 1, url: 1, description: 1 }); function ZAe(e) { return e === TAe || e === EAe || e === NAe } const JAe = { row: 1, column: 1, facet: 1 }, QAe = oCe(JAe), eTe = Object.assign(Object.assign({}, KAe), JAe), tTe = oCe(eTe), { order: nTe, detail: rTe, tooltip: iTe } = eTe, aTe = F_e(eTe, ["order", "detail", "tooltip"]), { row: oTe, column: sTe, facet: uTe } = aTe, lTe = F_e(aTe, ["row", "column", "facet"]); oCe(aTe), oCe(lTe); function cTe(e) { return !!eTe[e] } const hTe = [yAe, bAe, CAe, AAe, kAe, xAe]; function dTe(e) { return fTe(e) !== e } function fTe(e) { switch (e) { case yAe: return mAe; case bAe: return gAe; case CAe: return SAe; case AAe: return _Ae; case kAe: return wAe; case xAe: return vAe }return e } function pTe(e) { if (qAe(e)) switch (e) { case wAe: return "startAngle"; case kAe: return "endAngle"; case vAe: return "outerRadius"; case xAe: return "innerRadius" }return e } function mTe(e) { switch (e) { case mAe: return yAe; case gAe: return bAe; case SAe: return CAe; case _Ae: return AAe; case wAe: return kAe; case vAe: return xAe } } function gTe(e) { switch (e) { case mAe: case yAe: return "width"; case gAe: case bAe: return "height" } } oCe(KAe); const { x: yTe, y: bTe, x2: vTe, y2: xTe, latitude: wTe, longitude: kTe, latitude2: STe, longitude2: _Te, theta: CTe, theta2: ATe, radius: TTe, radius2: ETe } = KAe, NTe = F_e(KAe, ["x", "y", "x2", "y2", "latitude", "longitude", "latitude2", "longitude2", "theta", "theta2", "radius", "radius2"]), ITe = oCe(NTe), MTe = { x: 1, y: 1 }, FTe = oCe(MTe); function DTe(e) { return e in MTe } const $Te = { theta: 1, radius: 1 }, RTe = oCe($Te); function OTe(e) { return "width" === e ? mAe : gAe } const { text: zTe, tooltip: PTe, href: BTe, url: LTe, description: jTe, detail: UTe, key: WTe, order: VTe } = NTe, GTe = F_e(NTe, ["text", "tooltip", "href", "url", "description", "detail", "key", "order"]), HTe = oCe(GTe); const qTe = Object.assign(Object.assign(Object.assign({}, MTe), $Te), GTe), YTe = oCe(qTe); function XTe(e) { return !!qTe[e] } function KTe(e, t) { return function (e) { switch (e) { case TAe: case EAe: case NAe: case GAe: case LAe: case jAe: case UAe: case WAe: case BAe: case DAe: case $Ae: case RAe: case OAe: case pAe: case dAe: case fAe: return ZTe; case mAe: case gAe: case SAe: case _Ae: return QTe; case yAe: case bAe: case CAe: case AAe: return { area: "always", bar: "always", image: "always", rect: "always", rule: "always", circle: "binned", point: "binned", square: "binned", tick: "binned", line: "binned", trail: "binned" }; case MAe: return { point: "always", tick: "always", rule: "always", circle: "always", square: "always", bar: "always", text: "always", line: "always", trail: "always" }; case zAe: return { line: "always", point: "always", tick: "always", rule: "always", circle: "always", square: "always", bar: "always", geoshape: "always" }; case IAe: return { point: "always", geoshape: "always" }; case PAe: return { text: "always" }; case FAe: return { point: "always", square: "always", text: "always" }; case VAe: return { image: "always" }; case wAe: case vAe: return { text: "always", arc: "always" }; case kAe: case xAe: return { arc: "always" } } }(e)[t] } const ZTe = { arc: "always", area: "always", bar: "always", circle: "always", geoshape: "always", image: "always", line: "always", rule: "always", point: "always", rect: "always", square: "always", trail: "always", text: "always", tick: "always" }, { geoshape: JTe } = ZTe, QTe = F_e(ZTe, ["geoshape"]); function eEe(e) { switch (e) { case mAe: case gAe: case wAe: case vAe: case MAe: case FAe: case OAe: case DAe: case $Ae: case RAe: case yAe: case bAe: case kAe: case xAe: return; case pAe: case dAe: case fAe: case IAe: case zAe: case PAe: case UAe: case WAe: case VAe: case GAe: return "discrete"; case TAe: case EAe: case NAe: return "flexible"; case SAe: case _Ae: case CAe: case AAe: case LAe: case jAe: case BAe: return } } function tEe(e) { return T_e(e) && (e = vMe(e, void 0)), "bin" + oCe(e).map((t => aEe(e[t]) ? cCe(`_${t}_${Object.entries(e[t])}`) : cCe(`_${t}_${e[t]}`))).join("") } function nEe(e) { return !0 === e || iEe(e) && !e.binned } function rEe(e) { return "binned" === e || iEe(e) && !0 === e.binned } function iEe(e) { return v_e(e) } function aEe(e) { return null == e ? void 0 : e.selection } function oEe(e) { switch (e) { case dAe: case fAe: case MAe: case TAe: case EAe: case NAe: case OAe: case DAe: case $Ae: case RAe: case IAe: return 6; case zAe: return 4; default: return 10 } } function sEe(e) { return `Invalid specification ${JSON.stringify(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".` } const uEe = 'Autosize "fit" only works for single views and layered views.'; function lEe(e) { return `${"width" == e ? "Width" : "Height"} "container" only works for single views and layered views.` } function cEe(e) { return `${"width" == e ? "Width" : "Height"} "container" only works well with autosize "fit" or "fit-${"width" == e ? "x" : "y"}".` } function hEe(e) { return e ? `Dropping "fit-${e}" because spec has discrete ${gTe(e)}.` : 'Dropping "fit" because spec has discrete size.' } function dEe(e) { return `Cannot project a selection on encoding channel "${e}", which has no field.` } function fEe(e, t) { return `Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").` } function pEe(e) { return `Selection not supported for ${e} yet.` } function mEe(e) { return `The "columns" property cannot be used when "${e}" has nested row/column.` } function gEe(e, t, n) { return `An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.` } function yEe(e) { return `Ignoring an invalid transform: ${Y_e(e)}.` } function bEe(e) { return `Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.` } function vEe(e) { return `Invalid field type "${e}".` } function xEe(e, t) { const { fill: n, stroke: r } = t; return `Dropping color ${e} as the plot also has ${n && r ? "fill and stroke" : n ? "fill" : "stroke"}.` } function wEe(e, t) { return `Dropping ${Y_e(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.` } function kEe(e, t, n) { return `${e} dropped as it is incompatible with "${t}"${n ? ` when ${n}` : ""}.` } function SEe(e) { return `${e} encoding should be discrete (ordinal / nominal / binned).` } function _Ee(e, t) { return `Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${"ordinal" === t ? "order" : "magnitude"}.` } function CEe(e) { return `Using unaggregated domain with raw field has no effect (${Y_e(e)}).` } function AEe(e) { return `Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.` } function TEe(e) { return `Unaggregated domain is currently unsupported for log scale (${Y_e(e)}).` } function EEe(e, t, n) { return `${n}-scale's "${t}" is dropped as it does not work with ${e} scale.` } function NEe(e) { return `The step for "${e}" is dropped because the ${"width" === e ? "x" : "y"} is continuous.` } const IEe = "Domains that should be unioned has conflicting sort properties. Sort will be set to true."; function MEe(e, t) { return `Invalid ${e}: ${Y_e(t)}.` } function FEe(e) { return `1D error band does not support ${e}.` } function DEe(e) { return `Channel ${e} is required for "binned" bin.` } const $Ee = function (e, t) { var n = e || 0; return { level: function (e) { return arguments.length ? (n = +e, this) : n }, error: function () { return n >= 1 && y_e(t || "error", "ERROR", arguments), this }, warn: function () { return n >= 2 && y_e(t || "warn", "WARN", arguments), this }, info: function () { return n >= 3 && y_e(t || "log", "INFO", arguments), this }, debug: function () { return n >= 4 && y_e(t || "log", "DEBUG", arguments), this } } }(2); let REe = $Ee; function OEe() { return REe = $Ee, REe } function zEe(...e) { REe.warn(...e) } function PEe(e) { if (e && v_e(e)) for (const t of HEe) if (t in e) return !0; return !1 } const BEe = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"], LEe = BEe.map((e => e.substr(0, 3))), jEe = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"], UEe = jEe.map((e => e.substr(0, 3))); function WEe(e, t) { const n = []; if (t && void 0 !== e.day && oCe(e).length > 1 && (zEe(function (e) { return `Dropping day from datetime ${Y_e(e)} as day cannot be combined with other units.` }(e)), delete (e = G_e(e)).day), void 0 !== e.year ? n.push(e.year) : n.push(2012), void 0 !== e.month) { const r = t ? function (e) { if (SCe(e) && (e = +e), E_e(e)) return e - 1; { const t = e.toLowerCase(), n = BEe.indexOf(t); if (-1 !== n) return n; const r = t.substr(0, 3), i = LEe.indexOf(r); if (-1 !== i) return i; throw new Error(MEe("month", e)) } }(e.month) : e.month; n.push(r) } else if (void 0 !== e.quarter) { const r = t ? function (e) { if (SCe(e) && (e = +e), E_e(e)) return e > 4 && zEe(MEe("quarter", e)), e - 1; throw new Error(MEe("quarter", e)) }(e.quarter) : e.quarter; n.push(E_e(r) ? 3 * r : r + "*3") } else n.push(0); if (void 0 !== e.date) n.push(e.date); else if (void 0 !== e.day) { const r = t ? function (e) { if (SCe(e) && (e = +e), E_e(e)) return e % 7; { const t = e.toLowerCase(), n = jEe.indexOf(t); if (-1 !== n) return n; const r = t.substr(0, 3), i = UEe.indexOf(r); if (-1 !== i) return i; throw new Error(MEe("day", e)) } }(e.day) : e.day; n.push(E_e(r) ? r + 1 : r + "+1") } else n.push(1); for (const t of ["hours", "minutes", "seconds", "milliseconds"]) { const r = e[t]; n.push(void 0 === r ? 0 : r) } return n } function VEe(e) { const t = WEe(e, !0).join(", "); return e.utc ? `utc(${t})` : `datetime(${t})` } const GEe = { year: 1, quarter: 1, month: 1, week: 1, day: 1, dayofyear: 1, date: 1, hours: 1, minutes: 1, seconds: 1, milliseconds: 1 }, HEe = oCe(GEe); function qEe(e) { return e.startsWith("utc") } const YEe = { "year-month": "%b %Y ", "year-month-date": "%b %d, %Y " }; function XEe(e) { const t = []; for (const n of HEe) KEe(e, n) && t.push(n); return t } function KEe(e, t) { const n = e.indexOf(t); return !(n < 0) && (!(n > 0 && "seconds" === t && "i" === e.charAt(n - 1)) && (!(e.length > n + 3 && "day" === t && "o" === e.charAt(n + 3)) && !(n > 0 && "year" === t && "f" === e.charAt(n - 1)))) } function ZEe(e, t, { end: n } = { end: !1 }) { const r = pCe(t), i = qEe(e) ? "utc" : ""; let a; const o = {}; for (const t of HEe) KEe(e, t) && (o[t] = "quarter" === (s = t) ? `(${i}quarter(${r})-1)` : `${i}${s}(${r})`, a = t); var s; return n && (o[a] += "+1"), function (e) { const t = WEe(e, !1).join(", "); return e.utc ? `utc(${t})` : `datetime(${t})` }(o) } function JEe(e) { if (!e) return; const t = XEe(e); return `timeUnitSpecifier(${P_e()(t)}, ${P_e()(YEe)})` } function QEe(e) { if (!e) return; let t; return N_e(e) ? t = { unit: e } : v_e(e) && (t = Object.assign(Object.assign({}, e), e.unit ? { unit: e.unit } : {})), qEe(t.unit) && (t.utc = !0, t.unit = t.unit.substr(3)), t } function eNe(e) { return e && !!e.signal } function tNe(e) { return !!e.step } function nNe(e) { return !b_e(e) && ("field" in e && "data" in e) } const rNe = oCe({ aria: 1, description: 1, ariaRole: 1, ariaRoleDescription: 1, blend: 1, opacity: 1, fill: 1, fillOpacity: 1, stroke: 1, strokeCap: 1, strokeWidth: 1, strokeOpacity: 1, strokeDash: 1, strokeDashOffset: 1, strokeJoin: 1, strokeOffset: 1, strokeMiterLimit: 1, startAngle: 1, endAngle: 1, padAngle: 1, innerRadius: 1, outerRadius: 1, size: 1, shape: 1, interpolate: 1, tension: 1, orient: 1, align: 1, baseline: 1, text: 1, dir: 1, dx: 1, dy: 1, ellipsis: 1, limit: 1, radius: 1, theta: 1, angle: 1, font: 1, fontSize: 1, fontWeight: 1, fontStyle: 1, lineBreak: 1, lineHeight: 1, cursor: 1, href: 1, tooltip: 1, cornerRadius: 1, cornerRadiusTopLeft: 1, cornerRadiusTopRight: 1, cornerRadiusBottomLeft: 1, cornerRadiusBottomRight: 1, aspect: 1, width: 1, height: 1 }), iNe = { arc: 1, area: 1, group: 1, image: 1, line: 1, path: 1, rect: 1, rule: 1, shape: 1, symbol: 1, text: 1, trail: 1 }, aNe = ["cornerRadius", "cornerRadiusTopLeft", "cornerRadiusTopRight", "cornerRadiusBottomLeft", "cornerRadiusBottomRight"]; function oNe(e) { return e && !!e.field && void 0 !== e.equal } function sNe(e) { return e && !!e.field && void 0 !== e.lt } function uNe(e) { return e && !!e.field && void 0 !== e.lte } function lNe(e) { return e && !!e.field && void 0 !== e.gt } function cNe(e) { return e && !!e.field && void 0 !== e.gte } function hNe(e) { if (e && e.field) { if (b_e(e.range) && 2 === e.range.length) return !0; if (eNe(e.range)) return !0 } return !1 } function dNe(e) { return e && !!e.field && (b_e(e.oneOf) || b_e(e.in)) } function fNe(e) { return dNe(e) || oNe(e) || hNe(e) || sNe(e) || lNe(e) || uNe(e) || cNe(e) } function pNe(e, t) { return kMe(e, { timeUnit: t, wrapTime: !0 }) } function mNe(e, t = !0) { var n; const { field: r } = e, i = null === (n = QEe(e.timeUnit)) || void 0 === n ? void 0 : n.unit, a = i ? "time(" + ZEe(i, r) + ")" : iMe(e, { expr: "datum" }); if (oNe(e)) return a + "===" + pNe(e.equal, i); if (sNe(e)) { return `${a}<${pNe(e.lt, i)}` } if (lNe(e)) { return `${a}>${pNe(e.gt, i)}` } if (uNe(e)) { return `${a}<=${pNe(e.lte, i)}` } if (cNe(e)) { return `${a}>=${pNe(e.gte, i)}` } if (dNe(e)) return `indexof([${function (e, t) { return e.map((e => pNe(e, t))) }(e.oneOf, i).join(",")}], ${a}) !== -1`; if (function (e) { return e && !!e.field && void 0 !== e.valid }(e)) return gNe(a, e.valid); if (hNe(e)) { const { range: n } = e, r = eNe(n) ? { signal: `${n.signal}[0]` } : n[0], o = eNe(n) ? { signal: `${n.signal}[1]` } : n[1]; if (null !== r && null !== o && t) return "inrange(" + a + ", [" + pNe(r, i) + ", " + pNe(o, i) + "])"; const s = []; return null !== r && s.push(`${a} >= ${pNe(r, i)}`), null !== o && s.push(`${a} <= ${pNe(o, i)}`), s.length > 0 ? s.join(" && ") : "true" } throw new Error(`Invalid field predicate: ${JSON.stringify(e)}`) } function gNe(e, t = !0) { return t ? `isValid(${e}) && isFinite(+${e})` : `!isValid(${e}) || !isFinite(+${e})` } function yNe(e) { var t; return fNe(e) && e.timeUnit ? Object.assign(Object.assign({}, e), { timeUnit: null === (t = QEe(e.timeUnit)) || void 0 === t ? void 0 : t.unit }) : e } const bNe = { quantitative: "quantitative", ordinal: "ordinal", temporal: "temporal", nominal: "nominal", geojson: "geojson" }; const vNe = bNe.quantitative, xNe = bNe.ordinal, wNe = bNe.temporal, kNe = bNe.nominal, SNe = bNe.geojson, _Ne = oCe(bNe); const CNe = "linear", ANe = "log", TNe = "pow", ENe = "sqrt", NNe = "symlog", INe = "time", MNe = "utc", FNe = "quantile", DNe = "quantize", $Ne = "threshold", RNe = "point", ONe = "band", zNe = { linear: "numeric", log: "numeric", pow: "numeric", sqrt: "numeric", symlog: "numeric", identity: "numeric", sequential: "numeric", time: "time", utc: "time", ordinal: "ordinal", "bin-ordinal": "bin-ordinal", point: "ordinal-position", band: "ordinal-position", quantile: "discretizing", quantize: "discretizing", threshold: "discretizing" }, PNe = oCe(zNe); function BNe(e, t) { const n = zNe[e], r = zNe[t]; return n === r || "ordinal-position" === n && "time" === r || "ordinal-position" === r && "time" === n } const LNe = { linear: 0, log: 1, pow: 1, sqrt: 1, symlog: 1, identity: 1, sequential: 1, time: 0, utc: 0, point: 10, band: 11, ordinal: 0, "bin-ordinal": 0, quantile: 0, quantize: 0, threshold: 0 }; function jNe(e) { return LNe[e] } const UNe = ["linear", "log", "pow", "sqrt", "symlog", "time", "utc"], WNe = M_e(UNe), VNe = M_e(["linear", "log", "pow", "sqrt", "symlog"]); const GNe = M_e(["quantile", "quantize", "threshold"]), HNe = M_e(UNe.concat(["quantile", "quantize", "threshold", "sequential", "identity"])), qNe = M_e(["ordinal", "bin-ordinal", "point", "band"]); function YNe(e) { return e in qNe } function XNe(e) { return e in HNe } function KNe(e) { return e in WNe } function ZNe(e) { return e in GNe } function JNe(e) { return null == e ? void 0 : e.selection } const QNe = { type: 1, domain: 1, domainMid: 1, align: 1, range: 1, scheme: 1, bins: 1, reverse: 1, round: 1, clamp: 1, nice: 1, base: 1, exponent: 1, constant: 1, interpolate: 1, zero: 1, padding: 1, paddingInner: 1, paddingOuter: 1 }, { type: eIe, domain: tIe, range: nIe, scheme: rIe } = (oCe(QNe), QNe), iIe = F_e(QNe, ["type", "domain", "range", "scheme"]), aIe = oCe(iIe); !function () { var e; const t = {}; for (const n of tTe) for (const r of _Ne) for (const i of PNe) { const a = cIe(n, r); lIe(n, i) && uIe(i, r) && (t[a] = null !== (e = t[a]) && void 0 !== e ? e : [], t[a].push(i)) } }(); function oIe(e, t) { switch (t) { case "type": case "domain": case "reverse": case "range": return !0; case "scheme": case "interpolate": return !Z_e(["point", "band", "identity"], e); case "bins": return !Z_e(["point", "band", "identity", "ordinal"], e); case "round": return KNe(e) || "band" === e || "point" === e; case "padding": return KNe(e) || Z_e(["point", "band"], e); case "paddingOuter": case "align": return Z_e(["point", "band"], e); case "paddingInner": return "band" === e; case "domainMid": case "clamp": return KNe(e); case "nice": return KNe(e) || "quantize" === e || "threshold" === e; case "exponent": return "pow" === e; case "base": return "log" === e; case "constant": return "symlog" === e; case "zero": return XNe(e) && !Z_e(["log", "time", "utc", "threshold", "quantile"], e) } } function sIe(e, t) { switch (t) { case "interpolate": case "scheme": case "domainMid": return ZAe(e) ? void 0 : `Cannot use the scale property "${e}" with non-color channel.`; case "align": case "type": case "bins": case "domain": case "range": case "base": case "exponent": case "constant": case "nice": case "padding": case "paddingInner": case "paddingOuter": case "reverse": case "round": case "clamp": case "zero": return } } function uIe(e, t) { return Z_e([xNe, kNe], t) ? void 0 === e || YNe(e) : t === wNe ? Z_e([INe, MNe, void 0], e) : t !== vNe || Z_e([ANe, TNe, ENe, NNe, FNe, DNe, $Ne, CNe, void 0], e) } function lIe(e, t) { if (!XTe(e)) return !1; switch (e) { case mAe: case gAe: case wAe: case vAe: return KNe(t) || Z_e(["band", "point"], t); case MAe: case OAe: case DAe: case $Ae: case RAe: case FAe: return KNe(t) || ZNe(t) || Z_e(["band", "point", "ordinal"], t); case TAe: case EAe: case NAe: return "band" !== t; case zAe: return "ordinal" === t || ZNe(t); case IAe: return "ordinal" === t } } function cIe(e, t) { return e + "_" + t } function hIe(e) { const { channel: t, channelDef: n, markDef: r, scale: i, config: a } = e, o = yIe(e); return HIe(n) && !lAe(n.aggregate) && i && KNe(i.get("type")) && !1 === i.get("zero") ? dIe({ fieldDef: n, channel: t, markDef: r, ref: o, config: a }) : o } function dIe({ fieldDef: e, channel: t, markDef: n, ref: r, config: i }) { if (HCe(n.type)) return r; return null === MMe("invalid", n, i) ? r : [fIe(e, t), r] } function fIe(e, t) { const n = pIe(e, !0), r = "y" === fTe(t) ? { field: { group: "height" } } : { value: 0 }; return Object.assign({ test: n }, r) } function pIe(e, t = !0) { return gNe(N_e(e) ? e : iMe(e, { expr: "datum" }), !t) } function mIe(e, t, n, r) { const i = {}; if (t && (i.scale = t), YIe(e)) { const { datum: t } = e; PEe(t) ? i.signal = VEe(t) : eNe(t) ? i.signal = t.signal : i.value = t } else i.field = iMe(e, n); if (r) { const { offset: e, band: t } = r; e && (i.offset = e), t && (i.band = t) } return i } function gIe({ scaleName: e, fieldOrDatumDef: t, fieldOrDatumDef2: n, offset: r, startSuffix: i, band: a = .5 }) { const o = 0 < a && a < 1 ? "datum" : void 0, s = iMe(t, { expr: o, suffix: i }), u = void 0 !== n ? iMe(n, { expr: o }) : iMe(t, { suffix: "end", expr: o }), l = {}; if (0 === a || 1 === a) { l.scale = e; const t = 0 === a ? s : u; l.field = t } else { const t = `${a} * ${s} + ${1 - a} * ${u}`; l.signal = `scale("${e}", ${t})` } return r && (l.offset = r), l } function yIe({ channel: e, channelDef: t, channel2Def: n, markDef: r, config: i, scaleName: a, scale: o, stack: s, offset: u, defaultRef: l, band: c }) { var h; if (t) { if (ZIe(t)) { if (JIe(t)) { c = null != c ? c : jIe({ channel: e, fieldDef: t, fieldDef2: n, markDef: r, stack: s, config: i, isMidPoint: !0 }); const { bin: o, timeUnit: l, type: h } = t; if (nEe(o) || c && l && h === wNe) return s && s.impute ? mIe(t, a, { binSuffix: "mid" }, { offset: u }) : c ? gIe({ scaleName: a, fieldOrDatumDef: t, band: c, offset: u }) : mIe(t, a, _Me(t, e) ? { binSuffix: "range" } : {}, { offset: u }); if (rEe(o)) { if (HIe(n)) return gIe({ scaleName: a, fieldOrDatumDef: t, fieldOrDatumDef2: n, band: c, offset: u }); zEe(DEe(e === mAe ? yAe : bAe)) } } const l = null == o ? void 0 : o.get("type"); return mIe(t, a, YNe(l) ? { binSuffix: "range" } : {}, { offset: u, band: "band" === l ? null !== (h = null != c ? c : t.band) && void 0 !== h ? h : .5 : void 0 }) } if (QIe(t)) { const n = t.value, r = u ? { offset: u } : {}; return Object.assign(Object.assign({}, bIe(e, n)), r) } } return "function" == typeof l && (l = l()), l ? Object.assign(Object.assign({}, l), u ? { offset: u } : {}) : l } function bIe(e, t) { return Z_e(["x", "x2"], e) && "width" === t ? { field: { group: "width" } } : Z_e(["y", "y2"], e) && "height" === t ? { field: { group: "height" } } : TMe(t) } function vIe(e) { return e && "number" !== e && "time" !== e } function xIe(e, t, n) { return `${e}(${t}${n ? `, ${JSON.stringify(n)}` : ""})` } function wIe({ fieldOrDatumDef: e, format: t, formatType: n, expr: r, normalizeStack: i, config: a }) { var o, s; if (vIe(n)) return SIe({ fieldOrDatumDef: e, format: t, formatType: n, expr: r, config: a }); const u = kIe(e, r, i); if (wMe(e)) { const n = function (e, t, n, r, i) { return !t || n ? `${i ? "utc" : "time"}Format(${e}, '${n = N_e(n) ? n : r}')` : function (e, t, n) { if (!e) return; const r = JEe(e); return `${n || qEe(e) ? "utc" : "time"}Format(${t}, ${r})` }(t, e, i) }(u, HIe(e) ? null === (o = QEe(e.timeUnit)) || void 0 === o ? void 0 : o.unit : void 0, t, a.timeFormat, eMe(e) && (null === (s = e.scale) || void 0 === s ? void 0 : s.type) === MNe); return n ? { signal: n } : void 0 } if (t = AIe(qIe(e), t, a), HIe(e) && nEe(e.bin)) { return { signal: NIe(u, iMe(e, { expr: r, binSuffix: "end" }), t, n, a) } } return t || "quantitative" === qIe(e) ? { signal: `${TIe(u, t)}` } : { signal: `isValid(${u}) ? ${u} : ""+${u}` } } function kIe(e, t, n) { return HIe(e) ? n ? `${iMe(e, { expr: t, suffix: "end" })}-${iMe(e, { expr: t, suffix: "start" })}` : iMe(e, { expr: t }) : function (e) { const { datum: t } = e; return PEe(t) ? VEe(t) : `${JSON.stringify(t)}` }(e) } function SIe({ fieldOrDatumDef: e, format: t, formatType: n, expr: r, normalizeStack: i, config: a, field: o }) { if (o = null != o ? o : kIe(e, r, i), HIe(e) && nEe(e.bin)) { return { signal: NIe(o, iMe(e, { expr: r, binSuffix: "end" }), t, n, a) } } return { signal: xIe(n, o, t) } } function _Ie(e, t, n, r, i, a) { var o; if (!vIe(r)) { if (wMe(e)) { return function (e, t, n, r) { if (e) return e; if (t) return { signal: JEe(t) }; return r ? void 0 : n.timeFormat }(n, HIe(e) ? null === (o = QEe(e.timeUnit)) || void 0 === o ? void 0 : o.unit : void 0, i, a) } return AIe(t, n, i) } } function CIe(e, t, n) { return e && (eNe(e) || "number" === e || "time" === e) ? e : wMe(t) && "time" !== n && "utc" !== n ? "time" : void 0 } function AIe(e, t, n) { return N_e(t) ? t : e === vNe ? n.numberFormat : void 0 } function TIe(e, t) { return `format(${e}, "${t || ""}")` } function EIe(e, t, n, r) { var i; return vIe(n) ? xIe(n, e, t) : TIe(e, null !== (i = N_e(t) ? t : void 0) && void 0 !== i ? i : r.numberFormat) } function NIe(e, t, n, r, i) { const a = EIe(e, n, r, i), o = EIe(t, n, r, i); return `${gNe(e, !1)} ? "null" : ${a} + " – " + ${o}` } const IIe = "min", MIe = { x: 1, y: 1, color: 1, fill: 1, stroke: 1, strokeWidth: 1, size: 1, shape: 1, fillOpacity: 1, strokeOpacity: 1, opacity: 1, text: 1 }; function FIe(e) { return e in MIe } function DIe(e) { return !!e && !!e.encoding } function $Ie(e) { return !(!e || "count" !== e.op && !e.field) } function RIe(e) { return !!e && b_e(e) } function OIe(e) { return "row" in e || "column" in e } function zIe(e) { return !!e && "header" in e } function PIe(e) { return "facet" in e } function BIe(e) { const { field: t, timeUnit: n, bin: r, aggregate: i } = e; return Object.assign(Object.assign(Object.assign(Object.assign({}, n ? { timeUnit: n } : {}), r ? { bin: r } : {}), i ? { aggregate: i } : {}), { field: t }) } function LIe(e) { return JIe(e) && "sort" in e } function jIe({ channel: e, fieldDef: t, fieldDef2: n, markDef: r, stack: i, config: a, isMidPoint: o }) { if (ZIe(t) && void 0 !== t.band) return t.band; if (HIe(t)) { const { timeUnit: e, bin: i } = t; if (e && !n) return o ? FMe("timeUnitBandPosition", r, a) : qCe(r.type) ? FMe("timeUnitBand", r, a) : 0; if (nEe(i)) return qCe(r.type) && !o ? 1 : .5 } return (null == i ? void 0 : i.fieldChannel) === e && o ? .5 : void 0 } function UIe(e, t, n, r, i, a) { return !!(nEe(t.bin) || t.timeUnit && JIe(t) && "temporal" === t.type) && !!jIe({ channel: e, fieldDef: t, fieldDef2: n, stack: r, markDef: i, config: a }) } function WIe(e) { return !!e && "condition" in e } function VIe(e) { const t = e && e.condition; return !!t && !b_e(t) && HIe(t) } function GIe(e) { const t = e && e.condition; return !!t && !b_e(t) && ZIe(t) } function HIe(e) { return !(!e || !e.field && "count" !== e.aggregate) } function qIe(e) { return e && e.type } function YIe(e) { return !!e && "datum" in e } function XIe(e) { return JIe(e) && oMe(e) || KIe(e) } function KIe(e) { return YIe(e) && E_e(e.datum) } function ZIe(e) { return HIe(e) || YIe(e) } function JIe(e) { return !!e && ("field" in e && "type" in e || "count" === e.aggregate) } function QIe(e) { return e && "value" in e && "value" in e } function eMe(e) { return !!e && ("scale" in e || "sort" in e) } function tMe(e) { return e && ("axis" in e || "stack" in e || "impute" in e) } function nMe(e) { return !!e && "legend" in e } function rMe(e) { return !!e && ("format" in e || "formatType" in e) } function iMe(e, t = {}) { var n, r, i; let a = e.field; const o = t.prefix; let s = t.suffix, u = ""; if (function (e) { return "count" === e.aggregate }(e)) a = function (e) { return 0 === e.indexOf("__") }(l = "count") ? l : `__${l}`; else { let o; if (!t.nofn) if (function (e) { return "op" in e }(e)) o = e.op; else { const { bin: l, aggregate: c, timeUnit: h } = e; nEe(l) ? (o = tEe(l), s = (null !== (n = t.binSuffix) && void 0 !== n ? n : "") + (null !== (r = t.suffix) && void 0 !== r ? r : "")) : c ? oAe(c) ? (u = `["${a}"]`, a = `argmax_${c.argmax}`) : aAe(c) ? (u = `["${a}"]`, a = `argmin_${c.argmin}`) : o = String(c) : h && (o = function (e) { const t = QEe(e), { utc: n } = t, r = F_e(t, ["utc"]); return r.unit ? (n ? "utc" : "") + oCe(r).map((e => cCe(`${"unit" === e ? "" : `_${e}_`}${r[e]}`))).join("") : (n ? "utc" : "") + "timeunit" + oCe(r).map((e => cCe(`_${e}_${r[e]}`))).join("") }(h), s = (!Z_e(["range", "mid"], t.binSuffix) && t.binSuffix || "") + (null !== (i = t.suffix) && void 0 !== i ? i : "")) } o && (a = a ? `${o}_${a}` : o) } var l; return s && (a = `${a}_${s}`), o && (a = `${o}_${a}`), t.forAs ? bCe(a) : t.expr ? function (e, t = "datum") { return `${t}[${I_e(p_e(e).join("."))}]` }(a, t.expr) + u : gCe(a) + u } function aMe(e) { switch (e.type) { case "nominal": case "ordinal": case "geojson": return !0; case "quantitative": return HIe(e) && !!e.bin; case "temporal": return !1 }throw new Error(vEe(e.type)) } function oMe(e) { return !aMe(e) } const sMe = (e, t) => { switch (t.fieldTitle) { case "plain": return e.field; case "functional": return function (e) { const { aggregate: t, bin: n, timeUnit: r, field: i } = e; if (oAe(t)) return `${i} for argmax(${t.argmax})`; if (aAe(t)) return `${i} for argmin(${t.argmin})`; const a = QEe(r), o = t || (null == a ? void 0 : a.unit) || (null == a ? void 0 : a.maxbins) && "timeunit" || nEe(n) && "bin"; return o ? o.toUpperCase() + "(" + i + ")" : i }(e); default: return function (e, t) { var n; const { field: r, bin: i, timeUnit: a, aggregate: o } = e; if ("count" === o) return t.countTitle; if (nEe(i)) return `${r} (binned)`; if (a) { const e = null === (n = QEe(a)) || void 0 === n ? void 0 : n.unit; if (e) return `${r} (${XEe(e).join("-")})` } else if (o) return oAe(o) ? `${r} for max ${o.argmax}` : aAe(o) ? `${r} for min ${o.argmin}` : `${fCe(o)} of ${r}`; return r }(e, t) } }; let uMe = sMe; function lMe(e) { uMe = e } function cMe(e, t, { allowDisabling: n, includeDefault: r = !0 }) { var i, a; const o = (null !== (i = hMe(e)) && void 0 !== i ? i : {}).title; if (!HIe(e)) return o; const s = e, u = r ? dMe(s, t) : void 0; return n ? xCe(o, s.title, u) : null !== (a = null != o ? o : s.title) && void 0 !== a ? a : u } function hMe(e) { return tMe(e) && e.axis ? e.axis : nMe(e) && e.legend ? e.legend : zIe(e) && e.header ? e.header : void 0 } function dMe(e, t) { return uMe(e, t) } function fMe(e) { var t; if (rMe(e)) { const { format: t, formatType: n } = e; return { format: t, formatType: n } } { const n = null !== (t = hMe(e)) && void 0 !== t ? t : {}, { format: r, formatType: i } = n; return { format: r, formatType: i } } } function pMe(e) { return HIe(e) ? e : VIe(e) ? e.condition : void 0 } function mMe(e) { return ZIe(e) ? e : GIe(e) ? e.condition : void 0 } function gMe(e, t, n) { if (N_e(e) || E_e(e) || T_e(e)) { return zEe(function (e, t, n) { return `Channel ${e} is a ${t}. Converted to {value: ${Y_e(n)}}.` }(t, N_e(e) ? "string" : E_e(e) ? "number" : "boolean", e)), { value: e } } return ZIe(e) ? yMe(e, t, n) : GIe(e) ? Object.assign(Object.assign({}, e), { condition: yMe(e.condition, t, n) }) : e } function yMe(e, t, n) { if (rMe(e)) { const { format: r, formatType: i } = e, a = F_e(e, ["format", "formatType"]); if (vIe(i) && !n.customFormatTypes) return zEe(bEe(t)), yMe(a, t, n) } else { const r = tMe(e) ? "axis" : nMe(e) ? "legend" : zIe(e) ? "header" : null; if (r && e[r]) { const i = e[r], { format: a, formatType: o } = i, s = F_e(i, ["format", "formatType"]); if (vIe(o) && !n.customFormatTypes) return zEe(bEe(t)), yMe(Object.assign(Object.assign({}, e), { [r]: s }), t, n) } } return HIe(e) ? bMe(e, t) : function (e) { let t = e.type; if (t) return e; const { datum: n } = e; return t = E_e(n) ? "quantitative" : N_e(n) ? "nominal" : PEe(n) ? "temporal" : void 0, Object.assign(Object.assign({}, e), { type: t }) }(e) } function bMe(e, t) { const { aggregate: n, timeUnit: r, bin: i, field: a } = e, o = Object.assign({}, e); if (!n || sAe(n) || oAe(n) || aAe(n) || (zEe(function (e) { return `Invalid aggregation operator "${e}".` }(n)), delete o.aggregate), r && (o.timeUnit = QEe(r)), a && (o.field = `${a}`), nEe(i) && (o.bin = vMe(i, t)), rEe(i) && !DTe(t) && zEe(`Channel ${t} should not be used with "binned" bin.`), JIe(o)) { const { type: e } = o, t = function (e) { if (e) switch (e = e.toLowerCase()) { case "q": case vNe: return "quantitative"; case "t": case wNe: return "temporal"; case "o": case xNe: return "ordinal"; case "n": case kNe: return "nominal"; case SNe: return "geojson" } }(e); e !== t && (o.type = t), "quantitative" !== e && lAe(n) && (zEe(function (e, t) { return `Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.` }(e, n)), o.type = "quantitative") } else if (!dTe(t)) { const e = function (e, t) { if (e.timeUnit) return "temporal"; if (nEe(e.bin)) return "quantitative"; switch (eEe(t)) { case "continuous": default: return "quantitative"; case "discrete": case "flexible": return "nominal" } }(o, t); zEe(function (e, t) { return `Missing type for channel "${e}", using "${t}" instead.` }(t, e)), o.type = e } if (JIe(o)) { const { compatible: e, warning: n } = function (e, t) { const n = e.type; if ("geojson" === n && "shape" !== t) return { compatible: !1, warning: `Channel ${t} should not be used with a geojson data.` }; switch (t) { case dAe: case fAe: case pAe: return oMe(e) ? { compatible: !1, warning: SEe(t) } : xMe; case mAe: case gAe: case TAe: case EAe: case NAe: case PAe: case LAe: case jAe: case UAe: case WAe: case VAe: case FAe: case wAe: case vAe: case GAe: return xMe; case _Ae: case AAe: case SAe: case CAe: return n !== vNe ? { compatible: !1, warning: `Channel ${t} should be used with a quantitative field only, not ${e.type} field.` } : xMe; case DAe: case $Ae: case RAe: case OAe: case MAe: case kAe: case xAe: case yAe: case bAe: return "nominal" !== n || e.sort ? xMe : { compatible: !1, warning: `Channel ${t} should not be used with an unsorted discrete field.` }; case zAe: return Z_e(["ordinal", "nominal"], e.type) ? xMe : { compatible: !1, warning: "StrokeDash channel should be used with only discrete data." }; case IAe: return Z_e(["ordinal", "nominal", "geojson"], e.type) ? xMe : { compatible: !1, warning: "Shape channel should be used with only either discrete or geojson data." }; case BAe: return "nominal" !== e.type || "sort" in e ? xMe : { compatible: !1, warning: "Channel order is inappropriate for nominal field, which has no inherent order." } } }(o, t); e || zEe(n) } if (LIe(o) && N_e(o.sort)) { const { sort: e } = o; if (FIe(e)) return Object.assign(Object.assign({}, o), { sort: { encoding: e } }); const t = e.substr(1); if ("-" === e.charAt(0) && FIe(t)) return Object.assign(Object.assign({}, o), { sort: { encoding: t, order: "descending" } }) } if (zIe(o)) { const { header: e } = o, { orient: t } = e, n = F_e(e, ["orient"]); if (t) return Object.assign(Object.assign({}, o), { header: Object.assign(Object.assign({}, n), { labelOrient: e.labelOrient || t, titleOrient: e.titleOrient || t }) }) } return o } function vMe(e, t) { return T_e(e) ? { maxbins: oEe(t) } : "binned" === e ? { binned: !0 } : e.maxbins || e.step ? e : Object.assign(Object.assign({}, e), { maxbins: oEe(t) }) } const xMe = { compatible: !0 }; function wMe(e) { const { formatType: t } = fMe(e); return "time" === t || !t && function (e) { return e && ("temporal" === e.type || HIe(e) && !!e.timeUnit) }(e) } function kMe(e, { timeUnit: t, type: n, wrapTime: r, undefinedIfExprNotRequired: i }) { var a; const o = t && (null === (a = QEe(t)) || void 0 === a ? void 0 : a.unit); let s, u = o || "temporal" === n; return eNe(e) ? s = e.signal : PEe(e) ? (u = !0, s = VEe(e)) : (N_e(e) || E_e(e)) && u && (s = `datetime(${JSON.stringify(e)})`, function (e) { return !!GEe[e] }(o) && (E_e(e) && e < 1e4 || N_e(e) && isNaN(Date.parse(e))) && (s = VEe({ [o]: e }))), s ? r && u ? `time(${s})` : s : i ? void 0 : JSON.stringify(e) } function SMe(e, t) { const { type: n } = e; return t.map((t => { const r = kMe(t, { timeUnit: HIe(e) ? e.timeUnit : void 0, type: n, undefinedIfExprNotRequired: !0 }); return void 0 !== r ? { signal: r } : t })) } function _Me(e, t) { return nEe(e.bin) ? XTe(t) && Z_e(["ordinal", "nominal"], e.type) : (console.warn("Only call this method for binned field defs."), !1) } function CMe(e) { const { anchor: t, frame: n, offset: r, orient: i, color: a, subtitleColor: o, subtitleFont: s, subtitleFontSize: u, subtitleFontStyle: l, subtitleFontWeight: c, subtitleLineHeight: h, subtitlePadding: d } = e, f = F_e(e, ["anchor", "frame", "offset", "orient", "color", "subtitleColor", "subtitleFont", "subtitleFontSize", "subtitleFontStyle", "subtitleFontWeight", "subtitleLineHeight", "subtitlePadding"]), p = Object.assign(Object.assign({}, f), a ? { fill: a } : {}), m = Object.assign(Object.assign(Object.assign(Object.assign({}, t ? { anchor: t } : {}), n ? { frame: n } : {}), r ? { offset: r } : {}), i ? { orient: i } : {}), g = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, o ? { subtitleColor: o } : {}), s ? { subtitleFont: s } : {}), u ? { subtitleFontSize: u } : {}), l ? { subtitleFontStyle: l } : {}), c ? { subtitleFontWeight: c } : {}), h ? { subtitleLineHeight: h } : {}), d ? { subtitlePadding: d } : {}); return { titleMarkConfig: p, subtitleMarkConfig: H_e(p, ["align", "baseline", "dx", "dy", "limit"]), nonMark: m, subtitle: g } } function AMe(e) { return N_e(e) || b_e(e) && N_e(e[0]) } function TMe(e) { return eNe(e) ? e : void 0 !== e ? { value: e } : void 0 } function EMe(e) { return eNe(e) ? e.signal : I_e(e.value) } function NMe(e) { return eNe(e) ? e.signal : null == e ? null : I_e(e) } function IMe(e) { var t; return [].concat(e.type, null !== (t = e.style) && void 0 !== t ? t : []) } function MMe(e, t, n, r = {}) { const { vgChannel: i, ignoreVgConfig: a } = r; return i && void 0 !== t[i] ? t[i] : void 0 !== t[e] ? t[e] : !a || i && i !== e ? FMe(e, t, n, r) : void 0 } function FMe(e, t, n, { vgChannel: r } = {}) { return xCe(r ? DMe(e, t, n.style) : void 0, DMe(e, t, n.style), r ? n[t.type][r] : void 0, n[t.type][e], r ? n.mark[r] : n.mark[e]) } function DMe(e, t, n) { return $Me(e, IMe(t), n) } function $Me(e, t, n) { let r; t = __e(t); for (const i of t) { const t = n[i]; t && void 0 !== t[e] && (r = t[e]) } return r } function RMe(e, t) { return __e(e).reduce(((e, n) => { var r; return e.field.push(iMe(n, t)), e.order.push(null !== (r = n.sort) && void 0 !== r ? r : "ascending"), e }), { field: [], order: [] }) } function OMe(e, t) { const n = [...e]; return t.forEach((e => { for (const t of n) if (V_e(t, e)) return; n.push(e) })), n } function zMe(e, t) { return V_e(e, t) || !t ? e : e ? [...__e(e), ...__e(t)].join(", ") : t } function PMe(e, t) { const n = e.value, r = t.value; if (null == n || null === r) return { explicit: e.explicit, value: null }; if ((AMe(n) || eNe(n)) && (AMe(r) || eNe(r))) return { explicit: e.explicit, value: zMe(n, r) }; if (AMe(n) || eNe(n)) return { explicit: e.explicit, value: n }; if (AMe(r) || eNe(r)) return { explicit: e.explicit, value: r }; if (!(AMe(n) || eNe(n) || AMe(r) || eNe(r))) return { explicit: e.explicit, value: OMe(n, r) }; throw new Error("It should never reach here") } function BMe(e, t) { const n = e && e[t]; return !!n && (b_e(n) ? J_e(n, (e => !!e.field)) : HIe(n) || VIe(n)) } function LMe(e) { return J_e(tTe, (t => { if (BMe(e, t)) { const n = e[t]; if (b_e(n)) return J_e(n, (e => !!e.aggregate)); { const e = pMe(n); return e && !!e.aggregate } } return !1 })) } function jMe(e, t) { const n = [], r = [], i = [], a = [], o = {}; return VMe(e, ((s, u) => { if (HIe(s)) { const { field: l, aggregate: c, bin: h, timeUnit: d } = s, f = F_e(s, ["field", "aggregate", "bin", "timeUnit"]); if (c || d || h) { const e = hMe(s), p = e && e.title; let m = iMe(s, { forAs: !0 }); const g = Object.assign(Object.assign(Object.assign({}, p ? [] : { title: cMe(s, t, { allowDisabling: !0 }) }), f), { field: m }); if (c) { let e; if (oAe(c) ? (e = "argmax", m = iMe({ op: "argmax", field: c.argmax }, { forAs: !0 }), g.field = `${m}.${l}`) : aAe(c) ? (e = "argmin", m = iMe({ op: "argmin", field: c.argmin }, { forAs: !0 }), g.field = `${m}.${l}`) : "boxplot" !== c && "errorbar" !== c && "errorband" !== c && (e = c), e) { const t = { op: e, as: m }; l && (t.field = l), a.push(t) } } else if (n.push(m), JIe(s) && nEe(h)) { if (r.push({ bin: h, field: l, as: m }), n.push(iMe(s, { binSuffix: "end" })), _Me(s, u) && n.push(iMe(s, { binSuffix: "range" })), DTe(u)) { const e = { field: m + "_end" }; o[u + "2"] = e } g.bin = "binned", dTe(u) || (g.type = vNe) } else if (d) { i.push({ timeUnit: d, field: l, as: m }); const e = JIe(s) && s.type !== wNe && "time"; e && (u === PAe || u === UAe ? g.formatType = e : !function (e) { return !!NTe[e] }(u) ? DTe(u) && (g.axis = Object.assign({ formatType: e }, g.axis)) : g.legend = Object.assign({ formatType: e }, g.legend)) } o[u] = g } else n.push(l), o[u] = e[u] } else o[u] = e[u] })), { bins: r, timeUnits: i, aggregate: a, groupby: n, encoding: o } } function UMe(e, t, n) { const r = t.type; return oCe(e).reduce(((i, a) => { if (!cTe(a)) return zEe(function (e) { return `${e}-encoding is dropped as ${e} is not a valid encoding channel.` }(a)), i; const o = e[a]; if ("angle" !== a || "arc" !== r || e.theta || (zEe("Arc marks uses theta channel rather than angle, replacing angle with theta."), a = wAe), !function (e, t, n) { const r = KTe(t, n); if (!r) return !1; if ("binned" === r) { const n = e[t === yAe ? mAe : gAe]; return !!(HIe(n) && HIe(e[t]) && rEe(n.bin)) } return !0 }(e, a, r)) return zEe(kEe(a, r)), i; if (a === MAe && "line" === r) { const t = pMe(e[a]); if (null == t ? void 0 : t.aggregate) return zEe("Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead."), i } if (a === TAe && (t.filled ? "fill" in e : "stroke" in e)) return zEe(xEe("encoding", { fill: "fill" in e, stroke: "stroke" in e })), i; if (a === LAe || a === BAe && !b_e(o) && !QIe(o) || a === UAe && b_e(o)) o && (i[a] = __e(o).reduce(((e, t) => (HIe(t) ? e.push(bMe(t, a)) : zEe(wEe(t, a)), e)), [])); else { if (a === UAe && null === o) i[a] = null; else if (!(HIe(o) || YIe(o) || QIe(o) || WIe(o) || eNe(o))) return zEe(wEe(o, a)), i; i[a] = gMe(o, a, n) } return i }), {}) } function WMe(e) { const t = []; for (const n of oCe(e)) if (BMe(e, n)) { const r = __e(e[n]); for (const e of r) HIe(e) ? t.push(e) : VIe(e) && t.push(e.condition) } return t } function VMe(e, t, n) { if (e) for (const r of oCe(e)) { const i = e[r]; if (b_e(i)) for (const e of i) t.call(n, e, r); else t.call(n, i, r) } } function GMe(e, t, n, r) { return e ? oCe(e).reduce(((n, i) => { const a = e[i]; return b_e(a) ? a.reduce(((e, n) => t.call(r, e, n, i)), n) : t.call(r, n, a, i) }), n) : n } function HMe(e, t) { return oCe(t).reduce(((n, r) => { switch (r) { case mAe: case gAe: case WAe: case GAe: case VAe: case yAe: case bAe: case wAe: case kAe: case vAe: case xAe: case SAe: case _Ae: case CAe: case AAe: case PAe: case IAe: case FAe: case UAe: return n; case BAe: if ("line" === e || "trail" === e) return n; case LAe: case jAe: { const e = t[r]; if (b_e(e) || HIe(e)) for (const t of __e(e)) t.aggregate || n.push(iMe(t, {})); return n } case MAe: if ("trail" === e) return n; case TAe: case EAe: case NAe: case DAe: case $Ae: case RAe: case zAe: case OAe: { const e = pMe(t[r]); return e && !e.aggregate && n.push(iMe(e, {})), n } } }), []) } function qMe(e, t, n, r = !0) { if ("tooltip" in n) return { tooltip: n.tooltip }; return { tooltip: [...e.map((({ fieldPrefix: e, titlePrefix: n }) => { const i = r ? ` of ${t.field}` : ""; return { field: e + t.field, type: t.type, title: eNe(n) ? { signal: n + `"${escape(i)}"` } : n + i } })), ...WMe(n)] } } function YMe(e) { const { axis: t, title: n, field: r } = e; return t && void 0 !== t.title ? void 0 : xCe(n, r) } function XMe(e, t, n, r, i) { const { scale: a, axis: o } = n; return ({ partName: s, mark: u, positionPrefix: l, endPositionPrefix: c, aria: h, extraEncoding: d = {} }) => { const f = YMe(n); return KMe(e, s, i, h, { mark: u, encoding: Object.assign(Object.assign(Object.assign({ [t]: Object.assign(Object.assign(Object.assign({ field: l + "_" + n.field, type: n.type }, void 0 !== f ? { title: f } : {}), void 0 !== a ? { scale: a } : {}), void 0 !== o ? { axis: o } : {}) }, N_e(c) ? { [t + "2"]: { field: c + "_" + n.field } } : {}), r), d) }) } } function KMe(e, t, n, r, i) { const { clip: a, color: o, opacity: s } = e, u = e.type; return e[t] || void 0 === e[t] && n[t] ? [Object.assign(Object.assign({}, i), { mark: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, n[t]), a ? { clip: a } : {}), o ? { color: o } : {}), s ? { opacity: s } : {}), XCe(i.mark) ? i.mark : { type: i.mark }), { style: `${u}-${t}` }), T_e(e[t]) ? {} : e[t]), !1 === r ? { aria: r } : {}) })] : [] } function ZMe(e, t, n) { const { encoding: r } = e, i = "vertical" === t ? "y" : "x", a = r[i], o = r[i + "2"], s = r[i + "Error"], u = r[i + "Error2"]; return { continuousAxisChannelDef: JMe(a, n), continuousAxisChannelDef2: JMe(o, n), continuousAxisChannelDefError: JMe(s, n), continuousAxisChannelDefError2: JMe(u, n), continuousAxis: i } } function JMe(e, t) { if (e && e.aggregate) { const { aggregate: n } = e, r = F_e(e, ["aggregate"]); return n !== t && zEe(function (e, t) { return `Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.` }(n, t)), r } return e } function QMe(e, t) { const { mark: n, encoding: r } = e, { x: i, y: a } = r; if (XIe(i)) { if (XIe(a)) { const e = HIe(i) && i.aggregate, r = HIe(a) && a.aggregate; if (e || r !== t) { if (r || e !== t) { if (e === t && r === t) throw new Error("Both x and y cannot have aggregate"); return XCe(n) && n.orient ? n.orient : "vertical" } return "horizontal" } return "vertical" } return "horizontal" } if (XIe(a)) return "vertical"; throw new Error("Need a valid continuous axis for " + t + "s") } const eFe = "boxplot", tFe = new nAe(eFe, rFe); function nFe(e) { return E_e(e) ? "tukey" : e } function rFe(e, { config: t }) { var n, r; const { mark: i, encoding: a, selection: o, projection: s } = e, u = F_e(e, ["mark", "encoding", "selection", "projection"]), l = XCe(i) ? i : { type: i }; o && zEe(pEe("boxplot")); const c = null !== (n = l.extent) && void 0 !== n ? n : t.boxplot.extent, h = MMe("size", l, t), d = nFe(c), { transform: f, continuousAxisChannelDef: p, continuousAxis: m, groupby: g, aggregate: y, encodingWithoutContinuousAxis: b, ticksOrient: v, boxOrient: x, customTooltipWithoutAggregatedField: w } = function (e, t, n) { const r = QMe(e, eFe), { continuousAxisChannelDef: i, continuousAxis: a } = ZMe(e, r, eFe), o = i.field, s = nFe(t), u = [...iFe(o), { op: "median", field: o, as: "mid_box_" + o }, { op: "min", field: o, as: ("min-max" === s ? "lower_whisker_" : "min_") + o }, { op: "max", field: o, as: ("min-max" === s ? "upper_whisker_" : "max_") + o }], l = "min-max" === s || "tukey" === s ? [] : [{ calculate: `datum["upper_box_${o}"] - datum["lower_box_${o}"]`, as: "iqr_" + o }, { calculate: `min(datum["upper_box_${o}"] + datum["iqr_${o}"] * ${t}, datum["max_${o}"])`, as: "upper_whisker_" + o }, { calculate: `max(datum["lower_box_${o}"] - datum["iqr_${o}"] * ${t}, datum["min_${o}"])`, as: "lower_whisker_" + o }], c = e.encoding, h = a, d = (c[h], F_e(c, ["symbol" == typeof h ? h : h + ""])), { customTooltipWithoutAggregatedField: f, filteredEncoding: p } = function (e) { const { tooltip: t } = e, n = F_e(e, ["tooltip"]); if (!t) return { filteredEncoding: e }; let r, i; if (b_e(t)) { for (const e of t) e.aggregate ? (r || (r = []), r.push(e)) : (i || (i = []), i.push(e)); r && (n.tooltip = r) } else t.aggregate ? n.tooltip = t : i = t; return b_e(i) && 1 === i.length && (i = i[0]), { customTooltipWithoutAggregatedField: i, filteredEncoding: n } }(d), { bins: m, timeUnits: g, aggregate: y, groupby: b, encoding: v } = jMe(p, n), x = "vertical" === r ? "horizontal" : "vertical", w = r, k = [...m, ...g, { aggregate: [...y, ...u], groupby: b }, ...l]; return { transform: k, groupby: b, aggregate: y, continuousAxisChannelDef: i, continuousAxis: a, encodingWithoutContinuousAxis: v, ticksOrient: x, boxOrient: w, customTooltipWithoutAggregatedField: f } }(e, c, t), { color: k, size: S } = b, _ = F_e(b, ["color", "size"]), C = e => XMe(l, m, p, e, t.boxplot), A = C(_), T = C(b), E = C(Object.assign(Object.assign({}, _), S ? { size: S } : {})), N = qMe([{ fieldPrefix: "min-max" === d ? "upper_whisker_" : "max_", titlePrefix: "Max" }, { fieldPrefix: "upper_box_", titlePrefix: "Q3" }, { fieldPrefix: "mid_box_", titlePrefix: "Median" }, { fieldPrefix: "lower_box_", titlePrefix: "Q1" }, { fieldPrefix: "min-max" === d ? "lower_whisker_" : "min_", titlePrefix: "Min" }], p, b), I = { type: "tick", color: "black", opacity: 1, orient: v, invalid: null }, M = "min-max" === d ? N : qMe([{ fieldPrefix: "upper_whisker_", titlePrefix: "Upper Whisker" }, { fieldPrefix: "lower_whisker_", titlePrefix: "Lower Whisker" }], p, b), F = [...A({ partName: "rule", mark: { type: "rule", invalid: null }, positionPrefix: "lower_whisker", endPositionPrefix: "lower_box", aria: !1, extraEncoding: M }), ...A({ partName: "rule", mark: { type: "rule", invalid: null }, positionPrefix: "upper_box", endPositionPrefix: "upper_whisker", aria: !1, extraEncoding: M }), ...A({ partName: "ticks", mark: I, positionPrefix: "lower_whisker", aria: !1, extraEncoding: M }), ...A({ partName: "ticks", mark: I, positionPrefix: "upper_whisker", aria: !1, extraEncoding: M })], D = [..."tukey" !== d ? F : [], ...T({ partName: "box", mark: Object.assign(Object.assign({ type: "bar" }, h ? { size: h } : {}), { orient: x, invalid: null }), positionPrefix: "lower_box", endPositionPrefix: "upper_box", aria: !1, extraEncoding: N }), ...E({ partName: "median", mark: Object.assign(Object.assign(Object.assign({ type: "tick", invalid: null }, v_e(t.boxplot.median) && t.boxplot.median.color ? { color: t.boxplot.median.color } : {}), h ? { size: h } : {}), { orient: v, ariaRoleDescription: "box" }), positionPrefix: "mid_box", extraEncoding: N })]; let $; if ("min-max" !== d) { const e = `datum["lower_box_${p.field}"]`, n = `datum["upper_box_${p.field}"]`, r = `(${n} - ${e})`, i = `${e} - ${c} * ${r}`, a = `${n} + ${c} * ${r}`, o = `datum["${p.field}"]`, s = { joinaggregate: iFe(p.field), groupby: g }; let u; "tukey" === d && (u = { transform: [{ filter: `(${i} <= ${o}) && (${o} <= ${a})` }, { aggregate: [{ op: "min", field: p.field, as: "lower_whisker_" + p.field }, { op: "max", field: p.field, as: "upper_whisker_" + p.field }, { op: "min", field: "lower_box_" + p.field, as: "lower_box_" + p.field }, { op: "max", field: "upper_box_" + p.field, as: "upper_box_" + p.field }, ...y], groupby: g }], layer: F }); const { tooltip: h } = _, f = F_e(_, ["tooltip"]), { scale: b, axis: v } = p, x = YMe(p), k = KMe(l, "outliers", t.boxplot, !0, { transform: [{ filter: `(${o} < ${i}) || (${o} > ${a})` }], mark: "point", encoding: Object.assign(Object.assign({ [m]: Object.assign(Object.assign(Object.assign({ field: p.field, type: p.type }, void 0 !== x ? { title: x } : {}), void 0 !== b ? { scale: b } : {}), void 0 !== v ? { axis: v } : {}) }, f), w ? { tooltip: w } : {}) })[0]; k && u ? $ = { transform: [s], layer: [k, u] } : k ? ($ = k, $.transform.unshift(s)) : u && ($ = u, $.transform.unshift(s)) } return $ ? Object.assign(Object.assign({}, u), { layer: [$, { transform: f, layer: D }] }) : Object.assign(Object.assign({}, u), { transform: (null !== (r = u.transform) && void 0 !== r ? r : []).concat(f), layer: D }) } function iFe(e) { return [{ op: "q1", field: e, as: "lower_box_" + e }, { op: "q3", field: e, as: "upper_box_" + e }] } const aFe = "errorbar", oFe = new nAe(aFe, sFe); function sFe(e, { config: t }) { const { transform: n, continuousAxisChannelDef: r, continuousAxis: i, encodingWithoutContinuousAxis: a, ticksOrient: o, markDef: s, outerSpec: u, tooltipEncoding: l } = lFe(e, aFe, t), c = XMe(s, i, r, a, t.errorbar), h = { type: "tick", orient: o }, d = [...c({ partName: "ticks", mark: h, positionPrefix: "lower", aria: !1, extraEncoding: l }), ...c({ partName: "ticks", mark: h, positionPrefix: "upper", aria: !1, extraEncoding: l }), ...c({ partName: "rule", mark: { type: "rule", ariaRoleDescription: "errorbar" }, positionPrefix: "lower", endPositionPrefix: "upper", extraEncoding: l })]; return Object.assign(Object.assign(Object.assign({}, u), { transform: n }), d.length > 1 ? { layer: d } : Object.assign({}, d[0])) } function uFe(e, t) { const { encoding: n } = e; if (function (e) { return (ZIe(e.x) || ZIe(e.y)) && !ZIe(e.x2) && !ZIe(e.y2) && !ZIe(e.xError) && !ZIe(e.xError2) && !ZIe(e.yError) && !ZIe(e.yError2) }(n)) return { orient: QMe(e, t), inputType: "raw" }; const r = function (e) { return ZIe(e.x2) || ZIe(e.y2) }(n), i = function (e) { return ZIe(e.xError) || ZIe(e.xError2) || ZIe(e.yError) || ZIe(e.yError2) }(n), a = n.x, o = n.y; if (r) { if (i) throw new Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`); const e = n.x2, r = n.y2; if (ZIe(e) && ZIe(r)) throw new Error(`${t} cannot have both x2 and y2`); if (ZIe(e)) { if (XIe(a)) return { orient: "horizontal", inputType: "aggregated-upper-lower" }; throw new Error(`Both x and x2 have to be quantitative in ${t}`) } if (ZIe(r)) { if (XIe(o)) return { orient: "vertical", inputType: "aggregated-upper-lower" }; throw new Error(`Both y and y2 have to be quantitative in ${t}`) } throw new Error("No ranged axis") } { const e = n.xError, r = n.xError2, i = n.yError, s = n.yError2; if (ZIe(r) && !ZIe(e)) throw new Error(`${t} cannot have xError2 without xError`); if (ZIe(s) && !ZIe(i)) throw new Error(`${t} cannot have yError2 without yError`); if (ZIe(e) && ZIe(i)) throw new Error(`${t} cannot have both xError and yError with both are quantiative`); if (ZIe(e)) { if (XIe(a)) return { orient: "horizontal", inputType: "aggregated-error" }; throw new Error("All x, xError, and xError2 (if exist) have to be quantitative") } if (ZIe(i)) { if (XIe(o)) return { orient: "vertical", inputType: "aggregated-error" }; throw new Error("All y, yError, and yError2 (if exist) have to be quantitative") } throw new Error("No ranged axis") } } function lFe(e, t, n) { var r; const { mark: i, encoding: a, selection: o, projection: s } = e, u = F_e(e, ["mark", "encoding", "selection", "projection"]), l = XCe(i) ? i : { type: i }; o && zEe(pEe(t)); const { orient: c, inputType: h } = uFe(e, t), { continuousAxisChannelDef: d, continuousAxisChannelDef2: f, continuousAxisChannelDefError: p, continuousAxisChannelDefError2: m, continuousAxis: g } = ZMe(e, c, t), { errorBarSpecificAggregate: y, postAggregateCalculates: b, tooltipSummary: v, tooltipTitleWithFieldName: x } = function (e, t, n, r, i, a, o, s) { let u = [], l = []; const c = t.field; let h, d = !1; if ("raw" === a) { const t = e.center ? e.center : e.extent ? "iqr" === e.extent ? "median" : "mean" : s.errorbar.center, n = e.extent ? e.extent : "mean" === t ? "stderr" : "iqr"; if ("median" === t != ("iqr" === n) && zEe(function (e, t, n) { return `${e} is not usually used with ${t} for ${n}.` }(t, n, o)), "stderr" === n || "stdev" === n) u = [{ op: n, field: c, as: "extent_" + c }, { op: t, field: c, as: "center_" + c }], l = [{ calculate: `datum["center_${c}"] + datum["extent_${c}"]`, as: "upper_" + c }, { calculate: `datum["center_${c}"] - datum["extent_${c}"]`, as: "lower_" + c }], h = [{ fieldPrefix: "center_", titlePrefix: fCe(t) }, { fieldPrefix: "upper_", titlePrefix: cFe(t, n, "+") }, { fieldPrefix: "lower_", titlePrefix: cFe(t, n, "-") }], d = !0; else { let t, r, i; e.center && e.extent && zEe(function (e, t) { return `Center is not needed to be specified in ${t} when extent is ${e}.` }(e.extent, o)), "ci" === n ? (t = "mean", r = "ci0", i = "ci1") : (t = "median", r = "q1", i = "q3"), u = [{ op: r, field: c, as: "lower_" + c }, { op: i, field: c, as: "upper_" + c }, { op: t, field: c, as: "center_" + c }], h = [{ fieldPrefix: "upper_", titlePrefix: cMe({ field: c, aggregate: i, type: "quantitative" }, s, { allowDisabling: !1 }) }, { fieldPrefix: "lower_", titlePrefix: cMe({ field: c, aggregate: r, type: "quantitative" }, s, { allowDisabling: !1 }) }, { fieldPrefix: "center_", titlePrefix: cMe({ field: c, aggregate: t, type: "quantitative" }, s, { allowDisabling: !1 }) }] } } else { (e.center || e.extent) && zEe(function (e, t) { return `${t ? "extent " : ""}${t && e ? "and " : ""}${e ? "center " : ""}${t && e ? "are " : "is "}not needed when data are aggregated.` }(e.center, e.extent)), "aggregated-upper-lower" === a ? (h = [], l = [{ calculate: `datum["${n.field}"]`, as: "upper_" + c }, { calculate: `datum["${c}"]`, as: "lower_" + c }]) : "aggregated-error" === a && (h = [{ fieldPrefix: "", titlePrefix: c }], l = [{ calculate: `datum["${c}"] + datum["${r.field}"]`, as: "upper_" + c }], i ? l.push({ calculate: `datum["${c}"] + datum["${i.field}"]`, as: "lower_" + c }) : l.push({ calculate: `datum["${c}"] - datum["${r.field}"]`, as: "lower_" + c })); for (const e of l) h.push({ fieldPrefix: e.as.substring(0, 6), titlePrefix: yCe(yCe(e.calculate, 'datum["', ""), '"]', "") }) } return { postAggregateCalculates: l, errorBarSpecificAggregate: u, tooltipSummary: h, tooltipTitleWithFieldName: d } }(l, d, f, p, m, h, t, n), w = a, k = g, S = (w[k], "x" === g ? "x2" : "y2"), _ = (w[S], "x" === g ? "xError" : "yError"), C = (w[_], "x" === g ? "xError2" : "yError2"), A = (w[C], F_e(w, ["symbol" == typeof k ? k : k + "", "symbol" == typeof S ? S : S + "", "symbol" == typeof _ ? _ : _ + "", "symbol" == typeof C ? C : C + ""])), { bins: T, timeUnits: E, aggregate: N, groupby: I, encoding: M } = jMe(A, n), F = [...N, ...y], D = "raw" !== h ? [] : I, $ = qMe(v, d, M, x); return { transform: [...null !== (r = u.transform) && void 0 !== r ? r : [], ...T, ...E, ...0 === F.length ? [] : [{ aggregate: F, groupby: D }], ...b], groupby: D, continuousAxisChannelDef: d, continuousAxis: g, encodingWithoutContinuousAxis: M, ticksOrient: "vertical" === c ? "horizontal" : "vertical", markDef: l, outerSpec: u, tooltipEncoding: $ } } function cFe(e, t, n) { return fCe(e) + " " + n + " " + t } const hFe = "errorband", dFe = new nAe(hFe, fFe); function fFe(e, { config: t }) { const { transform: n, continuousAxisChannelDef: r, continuousAxis: i, encodingWithoutContinuousAxis: a, markDef: o, outerSpec: s, tooltipEncoding: u } = lFe(e, hFe, t), l = o, c = XMe(l, i, r, a, t.errorband), h = void 0 !== e.encoding.x && void 0 !== e.encoding.y; let d = { type: h ? "area" : "rect" }, f = { type: h ? "line" : "rule" }; const p = Object.assign(Object.assign({}, l.interpolate ? { interpolate: l.interpolate } : {}), l.tension && l.interpolate ? { tension: l.tension } : {}); return h ? (d = Object.assign(Object.assign(Object.assign({}, d), p), { ariaRoleDescription: "errorband" }), f = Object.assign(Object.assign({}, f), p)) : l.interpolate ? zEe(FEe("interpolate")) : l.tension && zEe(FEe("tension")), Object.assign(Object.assign({}, s), { transform: n, layer: [...c({ partName: "band", mark: d, positionPrefix: "lower", endPositionPrefix: "upper", extraEncoding: u }), ...c({ partName: "borders", mark: f, positionPrefix: "lower", aria: !1, extraEncoding: u }), ...c({ partName: "borders", mark: f, positionPrefix: "upper", aria: !1, extraEncoding: u })] }) } const pFe = {}; function mFe(e, t, n) { const r = new nAe(e, t); pFe[e] = { normalizer: r, parts: n } } mFe(eFe, rFe, ["box", "median", "outliers", "rule", "ticks"]), mFe(aFe, sFe, ["ticks", "rule"]), mFe(hFe, fFe, ["band", "borders"]); const gFe = ["gradientHorizontalMaxLength", "gradientHorizontalMinLength", "gradientVerticalMaxLength", "gradientVerticalMinLength", "unselectedOpacity"], yFe = ["size", "shape", "fill", "stroke", "strokeDash", "strokeWidth", "opacity"], bFe = { fillColor: { part: "legend", vgProp: "fill" }, gradientStrokeColor: { part: "gradient", vgProp: "stroke" }, labelColor: { part: "labels", vgProp: "fill" }, strokeColor: { part: "legend", vgProp: "stroke" }, symbolFillColor: { part: "symbols", vgProp: "fill" }, symbolStrokeColor: { part: "symbols", vgProp: "stroke" }, titleColor: { part: "title", vgProp: "fill" } }, vFe = { aria: 1, clipHeight: 1, columnPadding: 1, columns: 1, cornerRadius: 1, description: 1, direction: 1, fillColor: 1, format: 1, formatType: 1, gradientLength: 1, gradientOpacity: 1, gradientStrokeColor: 1, gradientStrokeWidth: 1, gradientThickness: 1, gridAlign: 1, labelAlign: 1, labelBaseline: 1, labelColor: 1, labelFont: 1, labelFontSize: 1, labelFontStyle: 1, labelFontWeight: 1, labelLimit: 1, labelOffset: 1, labelOpacity: 1, labelOverlap: 1, labelPadding: 1, labelSeparation: 1, legendX: 1, legendY: 1, offset: 1, orient: 1, padding: 1, rowPadding: 1, strokeColor: 1, symbolDash: 1, symbolDashOffset: 1, symbolFillColor: 1, symbolLimit: 1, symbolOffset: 1, symbolOpacity: 1, symbolSize: 1, symbolStrokeColor: 1, symbolStrokeWidth: 1, symbolType: 1, tickCount: 1, tickMinStep: 1, title: 1, titleAlign: 1, titleAnchor: 1, titleBaseline: 1, titleColor: 1, titleFont: 1, titleFontSize: 1, titleFontStyle: 1, titleFontWeight: 1, titleLimit: 1, titleLineHeight: 1, titleOpacity: 1, titleOrient: 1, titlePadding: 1, type: 1, values: 1, zindex: 1 }, xFe = (oCe(vFe), "_vgsid_"), wFe = { single: { on: "click", fields: [xFe], resolve: "global", empty: "all", clear: "dblclick" }, multi: { on: "click", fields: [xFe], toggle: "event.shiftKey", resolve: "global", empty: "all", clear: "dblclick" }, interval: { on: "[mousedown, window:mouseup] > window:mousemove!", encodings: ["x", "y"], translate: "[mousedown, window:mouseup] > window:mousemove!", zoom: "wheel!", mark: { fill: "#333", fillOpacity: .125, stroke: "white" }, resolve: "global", clear: "dblclick" } }; function kFe(e) { return !(!e || "legend" !== e && !e.legend) } function SFe(e) { return kFe(e) && v_e(e) } function _Fe(e) { return "concat" in e } function CFe(e) { return "vconcat" in e } function AFe(e) { return "hconcat" in e } function TFe(e) { return v_e(e) && void 0 !== e.step } function EFe(e) { return e.view || e.width || e.height } const NFe = oCe({ align: 1, bounds: 1, center: 1, columns: 1, spacing: 1 }); function IFe(e, t) { var n; return null !== (n = e[t]) && void 0 !== n ? n : e["width" === t ? "continuousWidth" : "continuousHeight"] } function MFe(e, t) { const n = FFe(e, t); return TFe(n) ? n.step : DFe } function FFe(e, t) { var n; return xCe(null !== (n = e[t]) && void 0 !== n ? n : e["width" === t ? "discreteWidth" : "discreteHeight"], { step: e.step }) } const DFe = 20; const $Fe = { background: "white", padding: 5, timeFormat: "%b %d, %Y", countTitle: "Count of Records", view: { continuousWidth: 200, continuousHeight: 200, step: DFe }, mark: { color: "#4c78a8", invalid: "filter", timeUnitBand: 1 }, arc: {}, area: {}, bar: QCe, circle: {}, geoshape: {}, image: {}, line: {}, point: {}, rect: eAe, rule: { color: "black" }, square: {}, text: { color: "black" }, tick: { thickness: 1 }, trail: {}, boxplot: { size: 14, extent: 1.5, box: {}, median: { color: "white" }, outliers: {}, rule: {}, ticks: null }, errorbar: { center: "mean", rule: !0, ticks: !1 }, errorband: { band: { opacity: .3 }, borders: !1 }, scale: { pointPadding: .5, barBandPaddingInner: .1, rectBandPaddingInner: 0, minBandSize: 2, minFontSize: 8, maxFontSize: 40, minOpacity: .3, maxOpacity: .8, minSize: 9, minStrokeWidth: 1, maxStrokeWidth: 4, quantileCount: 4, quantizeCount: 4 }, projection: {}, legend: { gradientHorizontalMaxLength: 200, gradientHorizontalMinLength: 100, gradientVerticalMaxLength: 200, gradientVerticalMinLength: 64, unselectedOpacity: .35 }, header: { titlePadding: 10, labelPadding: 10 }, headerColumn: {}, headerRow: {}, headerFacet: {}, selection: wFe, style: {}, title: {}, facet: { spacing: 20 }, concat: { spacing: 20 } }, RFe = ["#4c78a8", "#f58518", "#e45756", "#72b7b2", "#54a24b", "#eeca3b", "#b279a2", "#ff9da6", "#9d755d", "#bab0ac"], OFe = { text: 11, guideLabel: 10, guideTitle: 11, groupTitle: 13, groupSubtitle: 12 }, zFe = { blue: RFe[0], orange: RFe[1], red: RFe[2], teal: RFe[3], green: RFe[4], yellow: RFe[5], purple: RFe[6], pink: RFe[7], brown: RFe[8], gray0: "#000", gray1: "#111", gray2: "#222", gray3: "#333", gray4: "#444", gray5: "#555", gray6: "#666", gray7: "#777", gray8: "#888", gray9: "#999", gray10: "#aaa", gray11: "#bbb", gray12: "#ccc", gray13: "#ddd", gray14: "#eee", gray15: "#fff" }; function PFe(e = {}) { const { color: t, font: n, fontSize: r } = e, i = F_e(e, ["color", "font", "fontSize"]); return w_e({}, $Fe, n ? function (e) { return { text: { font: e }, style: { "guide-label": { font: e }, "guide-title": { font: e }, "group-title": { font: e }, "group-subtitle": { font: e } } } }(n) : {}, t ? function (e = {}) { return { signals: [{ name: "color", value: v_e(e) ? Object.assign(Object.assign({}, zFe), e) : zFe }], mark: { color: { signal: "color.blue" } }, rule: { color: { signal: "color.gray0" } }, text: { color: { signal: "color.gray0" } }, style: { "guide-label": { fill: { signal: "color.gray0" } }, "guide-title": { fill: { signal: "color.gray0" } }, "group-title": { fill: { signal: "color.gray0" } }, "group-subtitle": { fill: { signal: "color.gray0" } }, cell: { stroke: { signal: "color.gray8" } } }, axis: { domainColor: { signal: "color.gray13" }, gridColor: { signal: "color.gray8" }, tickColor: { signal: "color.gray13" } }, range: { category: [{ signal: "color.blue" }, { signal: "color.orange" }, { signal: "color.red" }, { signal: "color.teal" }, { signal: "color.green" }, { signal: "color.yellow" }, { signal: "color.purple" }, { signal: "color.pink" }, { signal: "color.brown" }, { signal: "color.grey8" }] } } }(t) : {}, r ? function (e) { return { signals: [{ name: "fontSize", value: v_e(e) ? Object.assign(Object.assign({}, OFe), e) : OFe }], text: { fontSize: { signal: "fontSize.text" } }, style: { "guide-label": { fontSize: { signal: "fontSize.guideLabel" } }, "guide-title": { fontSize: { signal: "fontSize.guideTitle" } }, "group-title": { fontSize: { signal: "fontSize.groupTitle" } }, "group-subtitle": { fontSize: { signal: "fontSize.groupSubtitle" } } } } }(r) : {}, i || {}) } const BFe = ["view", ...YCe], LFe = ["color", "fontSize", "background", "padding", "facet", "concat", "numberFormat", "timeFormat", "countTitle", "header", "axisQuantitative", "axisTemporal", "axisDiscrete", "axisPoint", "axisXBand", "axisXPoint", "axisXDiscrete", "axisXQuantitative", "axisXTemporal", "axisYBand", "axisYPoint", "axisYDiscrete", "axisYQuantitative", "axisYTemporal", "scale", "selection", "overlay"], jFe = Object.assign({ view: ["continuousWidth", "continuousHeight", "discreteWidth", "discreteHeight", "step"] }, { area: ["line", "point"], bar: ["binSpacing", "continuousBandSize", "discreteBandSize"], rect: ["binSpacing", "continuousBandSize", "discreteBandSize"], line: ["point"], tick: ["bandSize", "thickness"] }); function UFe(e) { e = G_e(e); for (const t of LFe) delete e[t]; if (e.axis) for (const t in e.axis) CCe(e.axis[t]) && delete e.axis[t]; if (e.legend) for (const t of gFe) delete e.legend[t]; if (e.mark) { for (const t of ZCe) delete e.mark[t]; e.mark.tooltip && v_e(e.mark.tooltip) && delete e.mark.tooltip } for (const t of BFe) { for (const n of ZCe) delete e[t][n]; const n = jFe[t]; if (n) for (const r of n) delete e[t][r]; WFe(e, t) } for (const t of oCe(pFe)) delete e[t]; !function (e) { const { titleMarkConfig: t, subtitleMarkConfig: n, subtitle: r } = CMe(e.title); aCe(t) || (e.style["group-title"] = Object.assign(Object.assign({}, e.style["group-title"]), t)); aCe(n) || (e.style["group-subtitle"] = Object.assign(Object.assign({}, e.style["group-subtitle"]), n)); aCe(r) ? delete e.title : e.title = r }(e); for (const t in e) v_e(e[t]) && aCe(e[t]) && delete e[t]; return aCe(e) ? void 0 : e } function WFe(e, t, n, r) { const i = r ? e[t][r] : e[t]; "view" === t && (n = "cell"); const a = Object.assign(Object.assign({}, i), e.style[null != n ? n : t]); aCe(a) || (e.style[null != n ? n : t] = a), r || delete e[t] } function VFe(e) { return "layer" in e } class GFe { map(e, t) { return PIe(e) ? this.mapFacet(e, t) : function (e) { return "repeat" in e }(e) ? this.mapRepeat(e, t) : AFe(e) ? this.mapHConcat(e, t) : CFe(e) ? this.mapVConcat(e, t) : _Fe(e) ? this.mapConcat(e, t) : this.mapLayerOrUnit(e, t) } mapLayerOrUnit(e, t) { if (VFe(e)) return this.mapLayer(e, t); if (tAe(e)) return this.mapUnit(e, t); throw new Error(sEe(e)) } mapLayer(e, t) { return Object.assign(Object.assign({}, e), { layer: e.layer.map((e => this.mapLayerOrUnit(e, t))) }) } mapHConcat(e, t) { return Object.assign(Object.assign({}, e), { hconcat: e.hconcat.map((e => this.map(e, t))) }) } mapVConcat(e, t) { return Object.assign(Object.assign({}, e), { vconcat: e.vconcat.map((e => this.map(e, t))) }) } mapConcat(e, t) { const { concat: n } = e, r = F_e(e, ["concat"]); return Object.assign(Object.assign({}, r), { concat: n.map((e => this.map(e, t))) }) } mapFacet(e, t) { return Object.assign(Object.assign({}, e), { spec: this.map(e.spec, t) }) } mapRepeat(e, t) { return Object.assign(Object.assign({}, e), { spec: this.map(e.spec, t) }) } } const HFe = { zero: 1, center: 1, normalize: 1 }; const qFe = new Set([FCe, $Ce, DCe, BCe, zCe, WCe, VCe, OCe, LCe, jCe]), YFe = new Set([$Ce, DCe, FCe]); function XFe(e, t) { var n, r; const i = "x" === t ? "y" : "radius", a = e[t], o = e[i]; if (HIe(a) && HIe(o)) if ("quantitative" === qIe(a) && "quantitative" === qIe(o)) { if (a.stack) return t; if (o.stack) return i; const e = HIe(a) && !!a.aggregate; if (e !== (HIe(o) && !!o.aggregate)) return e ? t : i; { const e = null === (n = a.scale) || void 0 === n ? void 0 : n.type, s = null === (r = o.scale) || void 0 === r ? void 0 : r.type; if (e && "linear" !== e) return i; if (s && "linear" !== s) return t } } else { if ("quantitative" === qIe(a)) return t; if ("quantitative" === qIe(o)) return i } else { if ("quantitative" === qIe(a)) return t; if ("quantitative" === qIe(o)) return i } } function KFe(e, t, n = {}) { const r = XCe(e) ? e.type : e; if (!qFe.has(r)) return null; const i = XFe(t, "x") || XFe(t, "theta"); if (!i) return null; const a = t[i], o = HIe(a) ? iMe(a, {}) : void 0; let s = function (e) { switch (e) { case "x": return "y"; case "y": return "x"; case "theta": return "radius"; case "radius": return "theta" } }(i), u = t[s], l = HIe(u) ? iMe(u, {}) : void 0; l === o && (l = void 0, u = void 0, s = void 0); const c = ITe.reduce(((e, n) => { if ("tooltip" !== n && BMe(t, n)) { const r = t[n]; for (const t of __e(r)) { const r = pMe(t); if (r.aggregate) continue; const i = iMe(r, {}); i && i === l || e.push({ channel: n, fieldDef: r }) } } return e }), []); let h; if (void 0 !== a.stack ? h = T_e(a.stack) ? a.stack ? "zero" : null : a.stack : c.length > 0 && YFe.has(r) && (h = "zero"), !h || !function (e) { return e in HFe }(h)) return null; if (LMe(t) && 0 === c.length) return null; if (a.scale && a.scale.type && a.scale.type !== CNe) { if (n.disallowNonLinearStack) return null; zEe(function (e) { return `Cannot stack non-linear scale (${e}).` }(a.scale.type)) } return ZIe(t[mTe(i)]) ? (void 0 !== a.stack && zEe(`Cannot stack "${d = i}" if there is already "${d}2".`), null) : (HIe(a) && a.aggregate && !Z_e(cAe, a.aggregate) && zEe(`Stacking is applied even though the aggregate function is non-summative ("${a.aggregate}").`), { groupbyChannel: u ? s : void 0, groupbyField: l, fieldChannel: i, impute: null !== a.impute && HCe(r), stackBy: c, offset: h }); var d } function ZFe(e) { const { point: t, line: n } = e, r = F_e(e, ["point", "line"]); return oCe(r).length > 1 ? r : r.type } function JFe(e) { for (const t of ["line", "area", "rule", "trail"]) e[t] && (e = Object.assign(Object.assign({}, e), { [t]: q_e(e[t], ["point", "line"]) })); return e } function QFe(e, t = {}, n) { return "transparent" === e.point ? { opacity: 0 } : e.point ? v_e(e.point) ? e.point : {} : void 0 !== e.point ? null : t.point || n.shape ? v_e(t.point) ? t.point : {} : void 0 } function eDe(e, t = {}) { return e.line ? !0 === e.line ? {} : e.line : void 0 !== e.line ? null : t.line ? !0 === t.line ? {} : t.line : void 0 } class tDe { constructor() { this.name = "path-overlay" } hasMatchingType(e, t) { if (tAe(e)) { const { mark: n, encoding: r } = e, i = XCe(n) ? n : { type: n }; switch (i.type) { case "line": case "rule": case "trail": return !!QFe(i, t[i.type], r); case "area": return !!QFe(i, t[i.type], r) || !!eDe(i, t[i.type]) } } return !1 } run(e, t, n) { const { config: r } = t, { selection: i, projection: a, encoding: o, mark: s } = e, u = F_e(e, ["selection", "projection", "encoding", "mark"]), l = XCe(s) ? s : { type: s }, c = QFe(l, r[l.type], o), h = "area" === l.type && eDe(l, r[l.type]), d = [Object.assign(Object.assign({}, i ? { selection: i } : {}), { mark: ZFe(Object.assign(Object.assign({}, "area" === l.type && void 0 === l.opacity && void 0 === l.fillOpacity ? { opacity: .7 } : {}), l)), encoding: q_e(o, ["shape"]) })], f = KFe(l, o); let p = o; if (f) { const { fieldChannel: e, offset: t } = f; p = Object.assign(Object.assign({}, o), { [e]: Object.assign(Object.assign({}, o[e]), t ? { stack: t } : {}) }) } return h && d.push(Object.assign(Object.assign({}, a ? { projection: a } : {}), { mark: Object.assign(Object.assign({ type: "line" }, H_e(l, ["clip", "interpolate", "tension", "tooltip"])), h), encoding: p })), c && d.push(Object.assign(Object.assign({}, a ? { projection: a } : {}), { mark: Object.assign(Object.assign({ type: "point", opacity: 1, filled: !0 }, H_e(l, ["clip", "tooltip"])), c), encoding: p })), n(Object.assign(Object.assign({}, u), { layer: d }), Object.assign(Object.assign({}, t), { config: JFe(r) })) } } class nDe { constructor() { this.name = "RangeStep" } hasMatchingType(e) { var t; if (tAe(e) && e.encoding) for (const n of FTe) { const r = e.encoding[n]; if (r && ZIe(r) && (null === (t = null == r ? void 0 : r.scale) || void 0 === t ? void 0 : t.rangeStep)) return !0 } return !1 } run(e) { var t; const n = {}; let r = Object.assign({}, e.encoding); for (const e of FTe) { const i = gTe(e), a = r[e]; if (a && ZIe(a) && (null === (t = null == a ? void 0 : a.scale) || void 0 === t ? void 0 : t.rangeStep)) { const { scale: t } = a, o = F_e(a, ["scale"]), s = t, { rangeStep: u } = s, l = F_e(s, ["rangeStep"]); n[i] = { step: t.rangeStep }, zEe('Scale\'s "rangeStep" is deprecated and will be removed in Vega-Lite 5.0. Please use "width"/"height": {"step": ...} instead. See https://vega.github.io/vega-lite/docs/size.html.'), r = Object.assign(Object.assign({}, r), { [e]: Object.assign(Object.assign({}, o), aCe(l) ? {} : { scale: l }) }) } } return Object.assign(Object.assign(Object.assign({}, n), e), { encoding: r }) } } function rDe(e, t) { return t ? OIe(e) ? lDe(e, t) : oDe(e, t) : e } function iDe(e, t) { return t ? lDe(e, t) : e } function aDe(e, t, n) { const r = t[e]; return function (e) { return e && !N_e(e) && "repeat" in e }(r) ? r.repeat in n ? Object.assign(Object.assign({}, t), { [e]: n[r.repeat] }) : void zEe(function (e) { return `Unknown repeated value "${e}".` }(r.repeat)) : t } function oDe(e, t) { if (void 0 !== (e = aDe("field", e, t))) { if (null === e) return null; if (LIe(e) && $Ie(e.sort)) { const n = aDe("field", e.sort, t); e = Object.assign(Object.assign({}, e), n ? { sort: n } : {}) } return e } } function sDe(e, t) { if (HIe(e)) return oDe(e, t); { const n = aDe("datum", e, t); return n === e || n.type || (n.type = "nominal"), n } } function uDe(e, t) { if (!ZIe(e)) { if (GIe(e)) { const n = sDe(e.condition, t); if (n) return Object.assign(Object.assign({}, e), { condition: n }); { const { condition: t } = e; return F_e(e, ["condition"]) } } return e } { const n = sDe(e, t); if (n) return n; if (WIe(e)) return { condition: e.condition } } } function lDe(e, t) { const n = {}; for (const r in e) if (A_e(e, r)) { const i = e[r]; if (b_e(i)) n[r] = i.map((e => uDe(e, t))).filter((e => e)); else { const e = uDe(i, t); void 0 !== e && (n[r] = e) } } return n } class cDe { constructor() { this.name = "RuleForRangedLine" } hasMatchingType(e) { if (tAe(e)) { const { encoding: t, mark: n } = e; if ("line" === n) for (const e of hTe) { const n = t[fTe(e)]; if (t[e] && (HIe(n) && !rEe(n.bin) || YIe(n))) return !0 } } return !1 } run(e, t, n) { const { encoding: r } = e; var i, a; return zEe((i = !!r.x2, a = !!r.y2, `Line mark is for continuous lines and thus cannot be used with ${i && a ? "x2 and y2" : i ? "x2" : "y2"}. We will use the rule mark (line segments) instead.`)), n(Object.assign(Object.assign({}, e), { mark: "rule" }), t) } } function hDe(e) { const { parentEncoding: t, encoding: n } = e; if (t && n) { const e = oCe(t).reduce(((e, t) => (n[t] && e.push(t), e)), []); e.length > 0 && zEe(`Layer's shared ${(r = e).join(",")} channel ${1 === r.length ? "is" : "are"} overriden.`) } var r; const i = Object.assign(Object.assign({}, null != t ? t : {}), null != n ? n : {}); return aCe(i) ? void 0 : i } function dDe(e) { const { parentProjection: t, projection: n } = e; return t && n && zEe(function (e) { const { parentProjection: t, projection: n } = e; return `Layer's shared projection ${Y_e(t)} is overridden by a child projection ${Y_e(n)}.` }({ parentProjection: t, projection: n })), null != n ? n : t } function fDe(e, t) { void 0 === t && (t = PFe(e.config)); const n = function (e, t = {}) { return pDe.map(e, { config: t }) }(e, t), { width: r, height: i } = e, a = function (e, t, n) { let { width: r, height: i } = t; const a = tAe(e) || VFe(e), o = {}; a ? "container" == r && "container" == i ? (o.type = "fit", o.contains = "padding") : "container" == r ? (o.type = "fit-x", o.contains = "padding") : "container" == i && (o.type = "fit-y", o.contains = "padding") : ("container" == r && (zEe(lEe("width")), r = void 0), "container" == i && (zEe(lEe("height")), i = void 0)); const s = Object.assign(Object.assign(Object.assign({ type: "pad" }, o), n ? mDe(n.autosize) : {}), mDe(e.autosize)); "fit" !== s.type || a || (zEe(uEe), s.type = "pad"); "container" == r && "fit" != s.type && "fit-x" != s.type && zEe(cEe("width")); "container" == i && "fit" != s.type && "fit-y" != s.type && zEe(cEe("height")); if (V_e(s, { type: "pad" })) return; return s }(n, { width: r, height: i, autosize: e.autosize }, t); return Object.assign(Object.assign({}, n), a ? { autosize: a } : {}) } const pDe = new class extends GFe { constructor() { super(...arguments), this.nonFacetUnitNormalizers = [tFe, oFe, dFe, new tDe, new cDe, new nDe] } map(e, t) { if (tAe(e)) { const n = BMe(e.encoding, dAe), r = BMe(e.encoding, fAe), i = BMe(e.encoding, pAe); if (n || r || i) return this.mapFacetedUnit(e, t) } return super.map(e, t) } mapUnit(e, t) { const { parentEncoding: n, parentProjection: r } = t, i = Object.assign(Object.assign({}, e), { encoding: iDe(e.encoding, t.repeater) }); if (n || r) return this.mapUnitWithParentEncodingOrProjection(i, t); const a = this.mapLayerOrUnit.bind(this); for (const e of this.nonFacetUnitNormalizers) if (e.hasMatchingType(i, t.config)) return e.run(i, t, a); return i } mapRepeat(e, t) { return function (e) { return !b_e(e.repeat) && e.repeat.layer }(e) ? this.mapLayerRepeat(e, t) : this.mapNonLayerRepeat(e, t) } mapLayerRepeat(e, t) { const { repeat: n, spec: r } = e, i = F_e(e, ["repeat", "spec"]), { row: a, column: o, layer: s } = n, { repeater: u = {}, repeaterPrefix: l = "" } = t; return a || o ? this.mapRepeat(Object.assign(Object.assign({}, e), { repeat: Object.assign(Object.assign({}, a ? { row: a } : {}), o ? { column: o } : {}), spec: { repeat: { layer: s }, spec: r } }), t) : Object.assign(Object.assign({}, i), { layer: s.map((e => { const n = Object.assign(Object.assign({}, u), { layer: e }), i = (r.name || "") + l + `child__layer_${cCe(e)}`, a = this.mapLayerOrUnit(r, Object.assign(Object.assign({}, t), { repeater: n, repeaterPrefix: i })); return a.name = i, a })) }) } mapNonLayerRepeat(e, t) { var n; const { repeat: r, spec: i, data: a } = e, o = F_e(e, ["repeat", "spec", "data"]); !b_e(r) && e.columns && (e = q_e(e, ["columns"]), zEe(mEe("repeat"))); const s = [], { repeater: u = {}, repeaterPrefix: l = "" } = t, c = !b_e(r) && r.row || [u ? u.row : null], h = !b_e(r) && r.column || [u ? u.column : null], d = b_e(r) && r || [u ? u.repeat : null]; for (const e of d) for (const n of c) for (const a of h) { const o = { repeat: e, row: n, column: a, layer: u.layer }, c = (i.name || "") + l + "child__" + (b_e(r) ? `${cCe(e)}` : (r.row ? `row_${cCe(n)}` : "") + (r.column ? `column_${cCe(a)}` : "")), h = this.map(i, Object.assign(Object.assign({}, t), { repeater: o, repeaterPrefix: c })); h.name = c, s.push(q_e(h, ["data"])) } const f = b_e(r) ? e.columns : r.column ? r.column.length : 1; return Object.assign(Object.assign({ data: null !== (n = i.data) && void 0 !== n ? n : a, align: "all" }, o), { columns: f, concat: s }) } mapFacet(e, t) { const { facet: n } = e; return OIe(n) && e.columns && (e = q_e(e, ["columns"]), zEe(mEe("facet"))), super.mapFacet(e, t) } mapUnitWithParentEncodingOrProjection(e, t) { const { encoding: n, projection: r } = e, { parentEncoding: i, parentProjection: a, config: o } = t, s = dDe({ parentProjection: a, projection: r }), u = hDe({ parentEncoding: i, encoding: iDe(n, t.repeater) }); return this.mapUnit(Object.assign(Object.assign(Object.assign({}, e), s ? { projection: s } : {}), u ? { encoding: u } : {}), { config: o }) } mapFacetedUnit(e, t) { const n = e.encoding, { row: r, column: i, facet: a } = n, o = F_e(n, ["row", "column", "facet"]), { mark: s, width: u, projection: l, height: c, view: h, selection: d, encoding: f } = e, p = F_e(e, ["mark", "width", "projection", "height", "view", "selection", "encoding"]), { facetMapping: m, layout: g } = this.getFacetMappingAndLayout({ row: r, column: i, facet: a }, t), y = iDe(o, t.repeater); return this.mapFacet(Object.assign(Object.assign(Object.assign({}, p), g), { facet: m, spec: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, u ? { width: u } : {}), c ? { height: c } : {}), h ? { view: h } : {}), l ? { projection: l } : {}), { mark: s, encoding: y }), d ? { selection: d } : {}) }), t) } getFacetMappingAndLayout(e, t) { var n; const { row: r, column: i, facet: a } = e; if (r || i) { a && zEe(`Facet encoding dropped as ${(o = [...r ? [dAe] : [], ...i ? [fAe] : []]).join(" and ")} ${o.length > 1 ? "are" : "is"} also specified.`); const t = {}, s = {}; for (const r of [dAe, fAe]) { const i = e[r]; if (i) { const { align: e, center: a, spacing: o, columns: u } = i, l = F_e(i, ["align", "center", "spacing", "columns"]); t[r] = l; for (const e of ["align", "center", "spacing"]) void 0 !== i[e] && (s[e] = null !== (n = s[e]) && void 0 !== n ? n : {}, s[e][r] = i[e]) } } return { facetMapping: t, layout: s } } { const { align: e, center: n, spacing: r, columns: i } = a; return { facetMapping: rDe(F_e(a, ["align", "center", "spacing", "columns"]), t.repeater), layout: Object.assign(Object.assign(Object.assign(Object.assign({}, e ? { align: e } : {}), n ? { center: n } : {}), r ? { spacing: r } : {}), i ? { columns: i } : {}) } } var o } mapLayer(e, t) { var { parentEncoding: n, parentProjection: r } = t, i = F_e(t, ["parentEncoding", "parentProjection"]); const { encoding: a, projection: o } = e, s = F_e(e, ["encoding", "projection"]), u = Object.assign(Object.assign({}, i), { parentEncoding: hDe({ parentEncoding: n, encoding: a }), parentProjection: dDe({ parentProjection: r, projection: o }) }); return super.mapLayer(s, u) } }; function mDe(e) { return N_e(e) ? { type: e } : null != e ? e : {} } const gDe = ["background", "padding"]; function yDe(e) { return gDe.reduce(((t, n) => (e && void 0 !== e[n] && (t[n] = e[n]), t)), {}) } class bDe { constructor(e = {}, t = {}) { this.explicit = e, this.implicit = t } clone() { return new bDe(G_e(this.explicit), G_e(this.implicit)) } combine() { return Object.assign(Object.assign({}, this.explicit), this.implicit) } get(e) { return xCe(this.explicit[e], this.implicit[e]) } getWithExplicit(e) { return void 0 !== this.explicit[e] ? { explicit: !0, value: this.explicit[e] } : void 0 !== this.implicit[e] ? { explicit: !1, value: this.implicit[e] } : { explicit: !1, value: void 0 } } setWithExplicit(e, t) { void 0 !== t.value && this.set(e, t.value, t.explicit) } set(e, t, n) { return delete this[n ? "implicit" : "explicit"][e], this[n ? "explicit" : "implicit"][e] = t, this } copyKeyFromSplit(e, t) { void 0 !== t.explicit[e] ? this.set(e, t.explicit[e], !0) : void 0 !== t.implicit[e] && this.set(e, t.implicit[e], !1) } copyKeyFromObject(e, t) { void 0 !== t[e] && this.set(e, t[e], !0) } copyAll(e) { for (const t of oCe(e.combine())) { const n = e.getWithExplicit(t); this.setWithExplicit(t, n) } } } function vDe(e) { return { explicit: !0, value: e } } function xDe(e) { return { explicit: !1, value: e } } function wDe(e) { return (t, n, r, i) => { const a = e(t.value, n.value); return a > 0 ? t : a < 0 ? n : kDe(t, n, r, i) } } function kDe(e, t, n, r) { return e.explicit && t.explicit && zEe(function (e, t, n, r) { return `Conflicting ${t.toString()} property "${e.toString()}" (${Y_e(n)} and ${Y_e(r)}). Using ${Y_e(n)}.` }(n, r, e.value, t.value)), e } function SDe(e, t, n, r, i = kDe) { return void 0 === e || void 0 === e.value ? t : e.explicit && !t.explicit ? e : t.explicit && !e.explicit ? t : V_e(e.value, t.value) ? e : i(e, t, n, r) } class _De extends bDe { constructor(e = {}, t = {}, n = !1) { super(e, t), this.explicit = e, this.implicit = t, this.parseNothing = n } clone() { const e = super.clone(); return e.parseNothing = this.parseNothing, e } } function CDe(e) { return "url" in e } function ADe(e) { return "values" in e } function TDe(e) { return "name" in e && !CDe(e) && !ADe(e) && !EDe(e) } function EDe(e) { return e && (NDe(e) || IDe(e) || MDe(e)) } function NDe(e) { return "sequence" in e } function IDe(e) { return "sphere" in e } function MDe(e) { return "graticule" in e } const FDe = "main", DDe = "raw"; function $De(e) { return "filter" in e } function RDe(e) { return "lookup" in e } function ODe(e) { return "pivot" in e } function zDe(e) { return "density" in e } function PDe(e) { return "quantile" in e } function BDe(e) { return "regression" in e } function LDe(e) { return "loess" in e } function jDe(e) { return "sample" in e } function UDe(e) { return "window" in e } function WDe(e) { return "joinaggregate" in e } function VDe(e) { return "flatten" in e } function GDe(e) { return "calculate" in e } function HDe(e) { return "bin" in e } function qDe(e) { return "impute" in e } function YDe(e) { return "timeUnit" in e } function XDe(e) { return "aggregate" in e } function KDe(e) { return "stack" in e } function ZDe(e) { return "fold" in e } function JDe(e, t, n, r) { const i = WIe(t) && t.condition, a = r(t); if (i) { const t = __e(i).map((t => { const n = r(t), i = function (e) { return e.selection }(t) ? VOe(e, t.selection) : HOe(e, t.test); return Object.assign({ test: i }, n) })); return { [n]: [...t, ...void 0 !== a ? [a] : []] } } return void 0 !== a ? { [n]: a } : {} } function QDe(e, t = "text") { const n = e.encoding[t]; return JDe(e, n, t, (t => e$e(t, e.config))) } function e$e(e, t, n = "datum") { if (e) { if (QIe(e)) return TMe(e.value); if (ZIe(e)) { const { format: r, formatType: i } = fMe(e); return wIe({ fieldOrDatumDef: e, format: r, formatType: i, expr: n, config: t }) } } } function t$e(e, t = {}) { const { encoding: n, markDef: r, config: i, stack: a } = e, o = n.tooltip; if (b_e(o)) return { tooltip: r$e({ tooltip: o }, a, i, t) }; { const s = t.reactiveGeom ? "datum.datum" : "datum"; return JDe(e, o, "tooltip", (e => { const o = e$e(e, i, s); if (o) return o; if (null === e) return; let u = MMe("tooltip", r, i); return !0 === u && (u = { content: "encoding" }), N_e(u) ? { value: u } : v_e(u) ? "encoding" === u.content ? r$e(n, a, i, t) : { signal: s } : void 0 })) } } function n$e(e, t, n, { reactiveGeom: r } = {}) { const i = {}, a = r ? "datum.datum" : "datum", o = []; function s(r, s) { const u = fTe(s), l = JIe(r) ? r : Object.assign(Object.assign({}, r), { type: e[u].type }), c = __e(cMe(l, n, { allowDisabling: !1 })).join(", "); let h; if (DTe(s)) { const r = "x" === s ? "x2" : "y2", o = pMe(e[r]); if (rEe(l.bin) && o) { const e = iMe(l, { expr: a }), t = iMe(o, { expr: a }), { format: s, formatType: u } = fMe(l); h = NIe(e, t, s, u, n), i[r] = !0 } else if (t && t.fieldChannel === s && "normalize" === t.offset) { const { format: e, formatType: t } = fMe(l); h = wIe({ fieldOrDatumDef: l, format: e, formatType: t, expr: a, config: n, normalizeStack: !0 }).signal } } h = null != h ? h : e$e(l, n, a).signal, o.push({ channel: s, key: c, value: h }) } VMe(e, ((e, t) => { HIe(e) ? s(e, t) : VIe(e) && s(e.condition, t) })); const u = {}; for (const { channel: e, key: t, value: n } of o) i[e] || u[t] || (u[I_e(t)] = n); return u } function r$e(e, t, n, { reactiveGeom: r } = {}) { const i = uCe(n$e(e, t, n, { reactiveGeom: r })).map((({ key: e, value: t }) => `${e}: ${t}`)); return i.length > 0 ? { signal: `{${i.join(", ")}}` } : void 0 } function i$e(e) { const { markDef: t, config: n } = e, r = MMe("aria", t, n); return !1 === r ? {} : Object.assign(Object.assign(Object.assign({}, r ? { aria: r } : {}), function (e) { const { mark: t, markDef: n, config: r } = e; if (!1 === r.aria) return {}; const i = MMe("ariaRoleDescription", n, r); if (null != i) return { ariaRoleDescription: { value: i } }; return t in iNe ? {} : { ariaRoleDescription: { value: t } } }(e)), function (e) { const { encoding: t, markDef: n, config: r, stack: i } = e, a = t.description; if (a) return JDe(e, a, "description", (t => e$e(t, e.config))); const o = MMe("description", n, r); if (null != o) return { description: TMe(o) }; if (!1 === r.aria) return {}; const s = n$e(t, i, r); if (aCe(s)) return; return { description: { signal: uCe(s).map((({ key: e, value: t }) => `${e} + ": " + (${t})`)).join(' + "; " + ') } } }(e)) } function a$e(e, t, n = {}) { const { markDef: r, encoding: i, config: a } = t, { vgChannel: o } = n; let { defaultRef: s, defaultValue: u } = n; void 0 === s && (u = null != u ? u : MMe(e, r, a, { vgChannel: o, ignoreVgConfig: !0 }), void 0 !== u && (s = TMe(u))); const l = i[e]; return JDe(t, l, null != o ? o : e, (n => yIe({ channel: e, channelDef: n, markDef: r, config: a, scaleName: t.scaleName(e), scale: t.getScaleComponent(e), stack: null, defaultRef: s }))) } function o$e(e, t = { filled: void 0 }) { var n, r, i, a; const { markDef: o, encoding: s, config: u } = e, { type: l } = o, c = null !== (n = t.filled) && void 0 !== n ? n : MMe("filled", o, u), h = Z_e(["bar", "point", "circle", "square", "geoshape"], l) ? "transparent" : void 0, d = null !== (i = null !== (r = MMe(!0 === c ? "color" : void 0, o, u, { vgChannel: "fill" })) && void 0 !== r ? r : u.mark[!0 === c && "color"]) && void 0 !== i ? i : h, f = null !== (a = MMe(!1 === c ? "color" : void 0, o, u, { vgChannel: "stroke" })) && void 0 !== a ? a : u.mark[!1 === c && "color"], p = c ? "fill" : "stroke", m = Object.assign(Object.assign({}, d ? { fill: TMe(d) } : {}), f ? { stroke: TMe(f) } : {}); return o.color && (c ? o.fill : o.stroke) && zEe(xEe("property", { fill: "fill" in o, stroke: "stroke" in o })), Object.assign(Object.assign(Object.assign(Object.assign({}, m), a$e("color", e, { vgChannel: p, defaultValue: c ? d : f })), a$e("fill", e, { defaultValue: s.fill ? d : void 0 })), a$e("stroke", e, { defaultValue: s.stroke ? f : void 0 })) } function s$e(e, t) { const n = function (e) { switch (e) { case mAe: return "xOffset"; case gAe: return "yOffset"; case yAe: return "x2Offset"; case bAe: return "y2Offset"; case wAe: return "thetaOffset"; case vAe: return "radiusOffset"; case kAe: return "theta2Offset"; case xAe: return "radius2Offset" } }(e), r = t[n]; if (r) return r } function u$e(e, t, { defaultPos: n, vgChannel: r, isMidPoint: i }) { const { encoding: a, markDef: o, config: s, stack: u } = t, l = a[e], c = a[mTe(e)], h = t.scaleName(e), d = t.getScaleComponent(e), f = s$e(e, o), p = l$e({ model: t, defaultPos: n, channel: e, scaleName: h, scale: d }), m = !l && DTe(e) && (a.latitude || a.longitude) ? { field: t.getName(e) } : function (e) { const { channel: t, channelDef: n, isMidPoint: r, scaleName: i, stack: a, offset: o, markDef: s, config: u } = e; if (ZIe(n) && a && t === a.fieldChannel) { if (HIe(n)) { const e = jIe({ channel: t, fieldDef: n, isMidPoint: r, markDef: s, stack: a, config: u }); if (void 0 !== e) return gIe({ scaleName: i, fieldOrDatumDef: n, startSuffix: "start", band: e, offset: o }) } return mIe(n, i, { suffix: "end" }, { offset: o }) } return hIe(e) }({ channel: e, channelDef: l, channel2Def: c, markDef: o, config: s, isMidPoint: i, scaleName: h, scale: d, stack: u, offset: f, defaultRef: p }); return m ? { [r || e]: m } : void 0 } function l$e({ model: e, defaultPos: t, channel: n, scaleName: r, scale: i }) { const { markDef: a, config: o } = e; return () => { const s = fTe(n), u = pTe(n), l = MMe(n, a, o, { vgChannel: u }); if (void 0 !== l) return bIe(n, l); switch (t) { case "zeroOrMin": case "zeroOrMax": if (r) { const e = i.get("type"); if (Z_e([ANe, INe, MNe], e)); else if (i.domainDefinitelyIncludesZero()) return { scale: r, value: 0 } } if ("zeroOrMin" === t) return "y" === s ? { field: { group: "height" } } : { value: 0 }; switch (s) { case "radius": return { signal: `min(${e.width.signal},${e.height.signal})/2` }; case "theta": return { signal: "2*PI" }; case "x": return { field: { group: "width" } }; case "y": return { value: 0 } }break; case "mid": { const t = e[gTe(n)]; return Object.assign(Object.assign({}, t), { mult: .5 }) } } } } const c$e = { left: "x", center: "xc", right: "x2" }, h$e = { top: "y", middle: "yc", bottom: "y2" }; function d$e(e, t, n, r = "middle") { if ("radius" === e || "theta" === e) return pTe(e); const i = MMe("x" === e ? "align" : "baseline", t, n); return "x" === e ? c$e[i || ("top" === r ? "left" : "center")] : h$e[i || r] } function f$e(e, t, { defaultPos: n, defaultPos2: r, range: i }) { return i ? p$e(e, t, { defaultPos: n, defaultPos2: r }) : u$e(e, t, { defaultPos: n }) } function p$e(e, t, { defaultPos: n, defaultPos2: r }) { const { markDef: i, config: a } = t, o = mTe(e), s = gTe(e), u = function (e, t, n) { const { encoding: r, mark: i, markDef: a, stack: o, config: s } = e, u = fTe(n), l = gTe(n), c = pTe(n), h = r[u], d = e.scaleName(u), f = e.getScaleComponent(u), p = s$e(n in r || n in a ? n : u, e.markDef); if (!h && ("x2" === n || "y2" === n) && (r.latitude || r.longitude)) return { [c]: { field: e.getName(n) } }; const m = function ({ channel: e, channelDef: t, channel2Def: n, markDef: r, config: i, scaleName: a, scale: o, stack: s, offset: u, defaultRef: l }) { if (ZIe(t) && s && e.charAt(0) === s.fieldChannel.charAt(0)) return mIe(t, a, { suffix: "start" }, { offset: u }); return hIe({ channel: e, channelDef: n, scaleName: a, scale: o, stack: s, markDef: r, config: i, offset: u, defaultRef: l }) }({ channel: n, channelDef: h, channel2Def: r[n], markDef: a, config: s, scaleName: d, scale: f, stack: o, offset: p, defaultRef: void 0 }); if (void 0 !== m) return { [c]: m }; return m$e(n, a) || m$e(n, { [n]: DMe(n, a, s.style), [l]: DMe(l, a, s.style) }) || m$e(n, s[i]) || m$e(n, s.mark) || { [c]: l$e({ model: e, defaultPos: t, channel: n, scaleName: d, scale: f })() } }(t, r, o), l = u[s] ? d$e(e, i, a) : pTe(e); return Object.assign(Object.assign({}, u$e(e, t, { defaultPos: n, vgChannel: l })), u) } function m$e(e, t) { const n = gTe(e), r = pTe(e); return void 0 !== t[r] ? { [r]: bIe(e, t[r]) } : void 0 !== t[e] ? { [r]: bIe(e, t[e]) } : t[n] ? { [n]: bIe(e, t[n]) } : void 0 } function g$e(e, t, n) { var r, i, a, o; const { config: s, encoding: u, markDef: l, stack: c } = e, h = mTe(t), d = gTe(t), f = u[t], p = u[h], m = e.getScaleComponent(t), g = m ? m.get("type") : void 0, y = e.scaleName(t), b = l.orient, v = null !== (i = null !== (r = u[d]) && void 0 !== r ? r : u.size) && void 0 !== i ? i : MMe("size", l, s, { vgChannel: d }), x = "bar" === n && ("x" === t ? "vertical" === b : "horizontal" === b); if (HIe(f) && (nEe(f.bin) || rEe(f.bin) || f.timeUnit && !p) && !v && !YNe(g)) { const n = jIe({ channel: t, fieldDef: f, stack: c, markDef: l, config: s }), r = null === (a = e.component.axes[t]) || void 0 === a ? void 0 : a[0]; return function ({ fieldDef: e, fieldDef2: t, channel: n, band: r, scaleName: i, markDef: a, spacing: o = 0, axisTranslate: s, reverse: u, config: l }) { const c = mTe(n), h = pTe(n), d = pTe(c), f = s$e(n, a); if (nEe(e.bin) || e.timeUnit) return { [d]: v$e({ channel: n, fieldDef: e, scaleName: i, markDef: a, band: (1 - r) / 2, offset: b$e(c, o, u, s, f), config: l }), [h]: v$e({ channel: n, fieldDef: e, scaleName: i, markDef: a, band: 1 - (1 - r) / 2, offset: b$e(n, o, u, s, f), config: l }) }; if (rEe(e.bin)) { const r = mIe(e, i, {}, { offset: b$e(c, o, u, s, f) }); if (HIe(t)) return { [d]: r, [h]: mIe(t, i, {}, { offset: b$e(n, o, u, s, f) }) }; if (iEe(e.bin) && e.bin.step) return { [d]: r, [h]: { signal: `scale("${i}", ${iMe(e, { expr: "datum" })} + ${e.bin.step})`, offset: b$e(n, o, u, s, f) } } } return void zEe(DEe(c)) }({ fieldDef: f, fieldDef2: p, channel: t, markDef: l, scaleName: y, band: n, axisTranslate: null !== (o = null == r ? void 0 : r.get("translate")) && void 0 !== o ? o : .5, spacing: DTe(t) ? MMe("binSpacing", l, s) : void 0, reverse: m.get("reverse"), config: s }) } return (ZIe(f) && YNe(g) || x) && !p ? function (e, t, n, r) { var i; const { markDef: a, encoding: o, config: s, stack: u } = r, l = a.orient, c = r.scaleName(n), h = r.getScaleComponent(n), d = gTe(n), f = mTe(n), p = "horizontal" === l && "y" === n || "vertical" === l && "x" === n, m = MMe(p ? "size" : d, a, s, { vgChannel: d }); let g; (o.size || void 0 !== m) && (p ? g = a$e("size", r, { vgChannel: d, defaultValue: m }) : zEe(function (e) { return `Cannot apply size to non-oriented mark "${e}".` }(a.type))); const y = null !== (i = ZIe(t) ? jIe({ channel: n, fieldDef: t, markDef: a, stack: u, config: s }) : void 0) && void 0 !== i ? i : 1; g = g || { [d]: y$e(e, d, c, h, s, y) }; const b = "band" !== (null == h ? void 0 : h.get("type")) || !("band" in g[d]), v = d$e(n, a, s, b ? "middle" : "top"), x = s$e(n, a), w = hIe({ channel: n, channelDef: t, markDef: a, config: s, scaleName: c, scale: h, stack: u, offset: x, defaultRef: l$e({ model: r, defaultPos: "mid", channel: n, scaleName: c, scale: h }), band: b ? .5 : (1 - y) / 2 }); if (d) return Object.assign({ [v]: w }, g); { const e = pTe(f), t = g[d], n = x ? Object.assign(Object.assign({}, t), { offset: x }) : t; return { [v]: w, [e]: b_e(w) ? [w[0], Object.assign(Object.assign({}, w[1]), { offset: n })] : Object.assign(Object.assign({}, w), { offset: n }) } } }(n, f, t, e) : p$e(t, e, { defaultPos: "zeroOrMax", defaultPos2: "zeroOrMin" }) } function y$e(e, t, n, r, i, a) { if (r) { const t = r.get("type"); if ("point" === t || "band" === t) { if (void 0 !== i[e].discreteBandSize) return { value: i[e].discreteBandSize }; if (t === RNe) { const e = r.get("range"); return tNe(e) && E_e(e.step) ? { value: e.step - 2 } : { value: DFe - 2 } } return { scale: n, band: a } } return { value: i[e].continuousBandSize } } const o = MFe(i.view, t), s = xCe(i[e].discreteBandSize, o - 2); return void 0 !== s ? { value: s } : void 0 } function b$e(e, t, n, r, i) { if (qAe(e)) return 0; const a = "x" === e || "y2" === e ? -t / 2 : t / 2; if (eNe(n)) { const e = NMe(i); return { signal: `${n.signal} ? ${r - a}${e ? "-" + e : ""} : ${r + a}${e ? "+" + e : ""}` } } if (eNe(i)) { const e = r + (n ? -a : a); return { signal: `${e || ""}${n ? " - " : e ? " + " : ""}${i.signal}` } } return i = i || 0, r + (n ? -i - a : +i + a) } function v$e({ channel: e, fieldDef: t, scaleName: n, markDef: r, band: i, offset: a, config: o }) { return dIe({ fieldDef: t, channel: e, markDef: r, ref: gIe({ scaleName: n, fieldOrDatumDef: t, band: i, offset: a }), config: o }) } const x$e = new Set(["aria"]); function w$e(e, t) { const { fill: n, stroke: r } = "include" === t.color ? o$e(e) : {}; return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, function (e, t) { return rNe.reduce(((n, r) => (x$e.has(r) || void 0 === e[r] || "ignore" === t[r] || (n[r] = TMe(e[r])), n)), {}) }(e.markDef, t)), k$e(e, "fill", n)), k$e(e, "stroke", r)), a$e("opacity", e)), a$e("fillOpacity", e)), a$e("strokeOpacity", e)), a$e("strokeWidth", e)), a$e("strokeDash", e)), t$e(e)), QDe(e, "href")), i$e(e)) } function k$e(e, t, n) { const { config: r, mark: i, markDef: a } = e; if ("hide" === MMe("invalid", a, r) && n && !HCe(i)) { const r = function (e, { invalid: t = !1, channels: n }) { const r = n.reduce(((t, n) => { const r = e.getScaleComponent(n); if (r) { const i = r.get("type"), a = e.vgField(n, { expr: "datum" }); a && XNe(i) && (t[a] = !0) } return t }), {}), i = oCe(r); if (i.length > 0) { const e = t ? "||" : "&&"; return i.map((e => pIe(e, t))).join(` ${e} `) } return }(e, { invalid: !0, channels: YTe }); if (r) return { [t]: [{ test: r, value: null }, ...__e(n)] } } return n ? { [t]: n } : {} } function S$e(e) { const { config: t, markDef: n } = e; if (MMe("invalid", n, t)) { const t = function (e, { invalid: t = !1, channels: n }) { const r = n.reduce(((t, n) => { const r = e.getScaleComponent(n); if (r) { const i = r.get("type"), a = e.vgField(n, { expr: "datum" }); a && XNe(i) && (t[a] = !0) } return t }), {}), i = oCe(r); if (i.length > 0) { const e = t ? "||" : "&&"; return i.map((e => pIe(e, t))).join(` ${e} `) } return }(e, { channels: FTe }); if (t) return { defined: { signal: t } } } return {} } function _$e(e, t) { if (void 0 !== t) return { [e]: TMe(t) } } const C$e = "voronoi", A$e = { has: e => "interval" !== e.type && e.nearest, parse: (e, t) => { if (t.events) for (const n of t.events) n.markname = e.getName(C$e) }, marks: (e, t, n) => { const { x: r, y: i } = t.project.hasChannel, a = e.mark; if (HCe(a)) return zEe(`The "nearest" transform is not supported for ${a} marks.`), n; const o = { name: e.getName(C$e), type: "path", interactive: !0, from: { data: e.getName("marks") }, encode: { update: Object.assign({ fill: { value: "transparent" }, strokeWidth: { value: .35 }, stroke: { value: "transparent" }, isVoronoi: { value: !0 } }, t$e(e, { reactiveGeom: !0 })) }, transform: [{ type: "voronoi", x: { expr: r || !i ? "datum.datum.x || 0" : "0" }, y: { expr: i || !r ? "datum.datum.y || 0" : "0" }, size: [e.getSizeSignalRef("width"), e.getSizeSignalRef("height")] }] }; let s = 0, u = !1; return n.forEach(((t, n) => { var r; const i = null !== (r = t.name) && void 0 !== r ? r : ""; i === e.component.mark[0].name ? s = n : i.indexOf(C$e) >= 0 && (u = !0) })), u || n.splice(s + 1, 0, o), n } }, T$e = A$e; class E$e { constructor(e, t) { this.debugName = t, this._children = [], this._parent = null, e && (this.parent = e) } clone() { throw new Error("Cannot clone node") } get parent() { return this._parent } set parent(e) { this._parent = e, e && e.addChild(this) } get children() { return this._children } numChildren() { return this._children.length } addChild(e, t) { this._children.indexOf(e) > -1 ? console.warn("Attempt to add the same child twice.") : void 0 !== t ? this._children.splice(t, 0, e) : this._children.push(e) } removeChild(e) { const t = this._children.indexOf(e); return this._children.splice(t, 1), t } remove() { let e = this._parent.removeChild(this); for (const t of this._children) t._parent = this._parent, this._parent.addChild(t, e++) } insertAsParentOf(e) { const t = e.parent; t.removeChild(this), this.parent = t, e.parent = this } swapWithParent() { const e = this._parent, t = e.parent; for (const t of this._children) t.parent = e; this._children = [], e.removeChild(this), e.parent.removeChild(e), this.parent = t, e.parent = this } } class N$e extends E$e { constructor(e, t, n, r) { super(e, t), this.type = n, this.refCounts = r, this._source = this._name = t, this.refCounts && !(this._name in this.refCounts) && (this.refCounts[this._name] = 0) } clone() { const e = new this.constructor; return e.debugName = "clone_" + this.debugName, e._source = this._source, e._name = "clone_" + this._name, e.type = this.type, e.refCounts = this.refCounts, e.refCounts[e._name] = 0, e } dependentFields() { return new Set } producedFields() { return new Set } hash() { return void 0 === this._hash && (this._hash = `Output ${function (e) { const t = ++wCe; return e ? String(e) + t : t }()}`), this._hash } getSource() { return this.refCounts[this._name]++, this._source } isRequired() { return !!this.refCounts[this._name] } setSource(e) { this._source = e } } class I$e extends E$e { constructor(e, t) { super(e), this.formula = t } clone() { return new I$e(null, G_e(this.formula)) } static makeFromEncoding(e, t) { const n = t.reduceFieldDef(((e, n, r) => { const { field: i, timeUnit: a } = n, o = SBe(t) ? t.encoding[mTe(r)] : void 0, s = SBe(t) && UIe(r, n, o, t.stack, t.markDef, t.config); if (a) { const t = iMe(n, { forAs: !0 }); e[X_e({ as: t, field: i, timeUnit: a })] = Object.assign({ as: t, field: i, timeUnit: a }, s ? { band: !0 } : {}) } return e }), {}); return aCe(n) ? null : new I$e(e, n) } static makeFromTransform(e, t) { const n = Object.assign({}, t), { timeUnit: r } = n, i = F_e(n, ["timeUnit"]), a = QEe(r), o = Object.assign(Object.assign({}, i), { timeUnit: a }); return new I$e(e, { [X_e(o)]: o }) } merge(e) { this.formula = Object.assign({}, this.formula); for (const t in e.formula) this.formula[t] && !e.formula[t].band || (this.formula[t] = e.formula[t]); for (const t of e.children) e.removeChild(t), t.parent = this; e.remove() } producedFields() { return new Set(sCe(this.formula).map((e => e.as))) } dependentFields() { return new Set(sCe(this.formula).map((e => e.field))) } hash() { return `TimeUnit ${X_e(this.formula)}` } assemble() { const e = []; for (const t of sCe(this.formula)) { const { field: n, as: r, timeUnit: i } = t, a = QEe(i), { unit: o, utc: s } = a, u = F_e(a, ["unit", "utc"]); e.push(Object.assign(Object.assign(Object.assign(Object.assign({ field: gCe(n), type: "timeunit" }, o ? { units: XEe(o) } : {}), s ? { timezone: "utc" } : {}), u), { as: [r, `${r}_end`] })) } return e } } const M$e = "_tuple_fields"; class F$e { constructor(...e) { this.items = e, this.hasChannel = {}, this.hasField = {} } } const D$e = { has: () => !0, parse: (e, t, n) => { var r, i, a; const o = t.name, s = null !== (r = t.project) && void 0 !== r ? r : t.project = new F$e, u = {}, l = {}, c = new Set, h = (e, t) => { const n = "visual" === t ? e.channel : e.field; let r = cCe(`${o}_${n}`); for (let e = 1; c.has(r); e++)r = cCe(`${o}_${n}_${e}`); return c.add(r), { [t]: r } }; if (!n.fields && !n.encodings) { const t = e.config.selection[n.type]; if (n.init) for (const e of __e(n.init)) for (const r of oCe(e)) lTe[r] ? (n.encodings || (n.encodings = [])).push(r) : "interval" === n.type ? (zEe('Interval selections should be initialized using "x" and/or "y" keys.'), n.encodings = t.encodings) : (n.fields || (n.fields = [])).push(r); else n.encodings = t.encodings, n.fields = t.fields } for (const e of null !== (i = n.fields) && void 0 !== i ? i : []) { const t = { type: "E", field: e }; t.signals = Object.assign({}, h(t, "data")), s.items.push(t), s.hasField[e] = t } for (const r of null !== (a = n.encodings) && void 0 !== a ? a : []) { const n = e.fieldDef(r); if (n) { let i = n.field; if (n.aggregate) { zEe(fEe(r, n.aggregate)); continue } if (!i) { zEe(dEe(r)); continue } if (n.timeUnit) { i = e.vgField(r); const t = { timeUnit: n.timeUnit, as: i, field: n.field }; l[X_e(t)] = t } if (!u[i]) { let a = "E"; if ("interval" === t.type) { XNe(e.getScaleComponent(r).get("type")) && (a = "R") } else n.bin && (a = "R-RE"); const o = { field: i, channel: r, type: a }; o.signals = Object.assign(Object.assign({}, h(o, "data")), h(o, "visual")), s.items.push(u[i] = o), s.hasField[i] = s.hasChannel[r] = u[i] } } else zEe(dEe(r)) } if (n.init) { const e = e => s.items.map((t => void 0 !== e[t.channel] ? e[t.channel] : e[t.field])); if ("interval" === n.type) t.init = e(n.init); else { const r = __e(n.init); t.init = r.map(e) } } aCe(l) || (s.timeUnit = new I$e(null, l)) }, signals: (e, t, n) => { const r = t.name + M$e, i = n.filter((e => e.name === r)); return i.length > 0 ? n : n.concat({ name: r, value: t.project.items.map((e => { const { signals: t, hasLegend: n } = e, r = F_e(e, ["signals", "hasLegend"]); return r.field = gCe(r.field), r })) }) } }, $$e = { has: e => "single" === e.type && "global" === e.resolve && e.bind && "scales" !== e.bind && !kFe(e.bind), parse: (e, t, n, r) => { r.on || delete t.events, r.clear || delete t.clear }, topLevelSignals: (e, t, n) => { const r = t.name, i = t.project, a = t.bind, o = t.init && t.init[0], s = T$e.has(t) ? "(item().isVoronoi ? datum.datum : datum)" : "datum"; return i.items.forEach(((e, i) => { var u, l; const c = cCe(`${r}_${e.field}`), h = n.filter((e => e.name === c)); h.length || n.unshift(Object.assign(Object.assign({ name: c }, o ? { init: eRe(o[i]) } : { value: null }), { on: t.events ? [{ events: t.events, update: `datum && item().mark.marktype !== 'group' ? ${s}[${I_e(e.field)}] : null` }] : [], bind: null !== (l = null !== (u = a[e.field]) && void 0 !== u ? u : a[e.channel]) && void 0 !== l ? l : a })) })), n }, signals: (e, t, n) => { const r = t.name, i = t.project, a = n.filter((e => e.name === r + hRe))[0], o = r + M$e, s = i.items.map((e => cCe(`${r}_${e.field}`))), u = s.map((e => `${e} !== null`)).join(" && "); return s.length && (a.update = `${u} ? {fields: ${o}, values: [${s.join(", ")}]} : null`), delete a.value, delete a.on, n } }, R$e = $$e, O$e = "_toggle", z$e = { has: e => "multi" === e.type && !!e.toggle, signals: (e, t, n) => n.concat({ name: t.name + O$e, value: !1, on: [{ events: t.events, update: t.toggle }] }), modifyExpr: (e, t) => { const n = t.name + hRe, r = t.name + O$e; return `${r} ? null : ${n}, ` + ("global" === t.resolve ? `${r} ? null : true, ` : `${r} ? null : {unit: ${gRe(e)}}, `) + `${r} ? ${n} : null` } }, P$e = { has: e => void 0 !== e.clear && !1 !== e.clear, parse: (e, t, n) => { n.clear && (t.clear = N_e(n.clear) ? r_e(n.clear, "scope") : n.clear) }, topLevelSignals: (e, t, n) => { if (R$e.has(t)) for (const e of t.project.items) { const r = n.findIndex((n => n.name === cCe(`${t.name}_${e.field}`))); -1 !== r && n[r].on.push({ events: t.clear, update: "null" }) } return n }, signals: (e, t, n) => { function r(e, r) { -1 !== e && n[e].on && n[e].on.push({ events: t.clear, update: r }) } if ("interval" === t.type) for (const e of t.project.items) { const t = n.findIndex((t => t.name === e.signals.visual)); if (r(t, "[0, 0]"), -1 === t) { r(n.findIndex((t => t.name === e.signals.data)), "null") } } else { let e = n.findIndex((e => e.name === t.name + hRe)); r(e, "null"), z$e.has(t) && (e = n.findIndex((e => e.name === t.name + O$e)), r(e, "false")) } return n } }, B$e = { has: e => "interval" === e.type && "global" === e.resolve && e.bind && "scales" === e.bind, parse: (e, t) => { const n = t.scales = []; for (const r of t.project.items) { const i = r.channel; if (!XTe(i)) continue; const a = e.getScaleComponent(i), o = a ? a.get("type") : void 0; if (!a || !XNe(o)) { zEe("Scale bindings are currently only supported for scales with unbinned, continuous domains."); continue } const s = { selection: t.name, field: r.field }; a.set("selectionExtent", s, !0), n.push(r) } }, topLevelSignals: (e, t, n) => { const r = t.scales.filter((e => 0 === n.filter((t => t.name === e.signals.data)).length)); if (!e.parent || U$e(e) || 0 === r.length) return n; const i = n.filter((e => e.name === t.name))[0]; let a = i.update; if (a.indexOf(fRe) >= 0) i.update = `{${r.map((e => `${I_e(e.field)}: ${e.signals.data}`)).join(", ")}}`; else { for (const e of r) { const t = `${I_e(e.field)}: ${e.signals.data}`; a.indexOf(t) < 0 && (a = `${a.substring(0, a.length - 1)}, ${t}}`) } i.update = a } return n.concat(r.map((e => ({ name: e.signals.data })))) }, signals: (e, t, n) => { if (e.parent && !U$e(e)) for (const e of t.scales) { const t = n.filter((t => t.name === e.signals.data))[0]; t.push = "outer", delete t.value, delete t.update } return n } }, L$e = B$e; function j$e(e, t) { return `domain(${I_e(e.scaleName(t))})` } function U$e(e) { var t; return e.parent && ABe(e.parent) && (null !== (t = !e.parent.parent) && void 0 !== t ? t : U$e(e.parent.parent)) } const W$e = { has: e => { const t = "global" === e.resolve && e.bind && kFe(e.bind), n = 1 === e.project.items.length && e.project.items[0].field !== xFe; return t && !n && zEe("Legend bindings are only supported for selections over an individual field or encoding channel."), t && n }, parse: (e, t, n, r) => { var i; if (r.on || delete t.events, r.clear || delete t.clear, r.on || r.clear) { const e = 'event.item && indexof(event.item.mark.role, "legend") < 0'; for (const n of t.events) n.filter = __e(null !== (i = n.filter) && void 0 !== i ? i : []), n.filter.indexOf(e) < 0 && n.filter.push(e) } const a = SFe(t.bind) ? t.bind.legend : "click", o = N_e(a) ? r_e(a, "view") : __e(a); t.bind = { legend: { merge: o } } }, topLevelSignals: (e, t, n) => { const r = t.name, i = SFe(t.bind) && t.bind.legend, a = e => t => { const n = G_e(t); return n.markname = e, n }; for (const e of t.project.items) { if (!e.hasLegend) continue; const o = `${cCe(e.field)}_legend`, s = `${r}_${o}`, u = n.filter((e => e.name === s)); if (0 === u.length) { const e = i.merge.map(a(`${o}_symbols`)).concat(i.merge.map(a(`${o}_labels`))).concat(i.merge.map(a(`${o}_entries`))); n.unshift(Object.assign(Object.assign({ name: s }, t.init ? {} : { value: null }), { on: [{ events: e, update: "datum.value || item().items[0].items[0].datum.value", force: !0 }, { events: i.merge, update: `!event.item || !datum ? null : ${s}`, force: !0 }] })) } } return n }, signals: (e, t, n) => { const r = t.name, i = t.project, a = n.find((e => e.name === r + hRe)), o = r + M$e, s = i.items.filter((e => e.hasLegend)).map((e => cCe(`${r}_${cCe(e.field)}_legend`))), u = `${s.map((e => `${e} !== null`)).join(" && ")} ? {fields: ${o}, values: [${s.join(", ")}]} : null`; t.events && s.length > 0 ? a.on.push({ events: s.map((e => ({ signal: e }))), update: u }) : s.length > 0 && (a.update = u, delete a.value, delete a.on); const l = n.find((e => e.name === r + O$e)), c = SFe(t.bind) && t.bind.legend; return l && (t.events ? l.on.push(Object.assign(Object.assign({}, l.on[0]), { events: c })) : l.on[0].events = c), n } }; const V$e = "_translate_anchor", G$e = "_translate_delta", H$e = { has: e => "interval" === e.type && e.translate, signals: (e, t, n) => { const r = t.name, i = L$e.has(t), a = r + V$e, { x: o, y: s } = t.project.hasChannel; let u = r_e(t.translate, "scope"); return i || (u = u.map((e => (e.between[0].markname = r + rRe, e)))), n.push({ name: a, value: {}, on: [{ events: u.map((e => e.between[0])), update: "{x: x(unit), y: y(unit)" + (void 0 !== o ? ", extent_x: " + (i ? j$e(e, mAe) : `slice(${o.signals.visual})`) : "") + (void 0 !== s ? ", extent_y: " + (i ? j$e(e, gAe) : `slice(${s.signals.visual})`) : "") + "}" }] }, { name: r + G$e, value: {}, on: [{ events: u, update: `{x: ${a}.x - x(unit), y: ${a}.y - y(unit)}` }] }), void 0 !== o && q$e(e, t, o, "width", n), void 0 !== s && q$e(e, t, s, "height", n), n } }; function q$e(e, t, n, r, i) { var a; const o = t.name, s = o + V$e, u = o + G$e, l = n.channel, c = L$e.has(t), h = i.filter((e => e.name === n.signals[c ? "data" : "visual"]))[0], d = e.getSizeSignalRef(r).signal, f = e.getScaleComponent(l), p = f.get("type"), m = `${s}.extent_${l}`, g = `${c ? "log" === p ? "panLog" : "pow" === p ? "panPow" : "panLinear" : "panLinear"}(${m}, ${`${c && l === mAe ? "-" : ""}${u}.${l} / ` + (c ? `${d}` : `span(${m})`)}` + (c && "pow" === p ? `, ${null !== (a = f.get("exponent")) && void 0 !== a ? a : 1}` : "") + ")"; h.on.push({ events: { signal: u }, update: c ? g : `clampRange(${g}, 0, ${d})` }) } const Y$e = "_zoom_anchor", X$e = "_zoom_delta", K$e = { has: e => "interval" === e.type && e.zoom, signals: (e, t, n) => { const r = t.name, i = L$e.has(t), a = r + X$e, { x: o, y: s } = t.project.hasChannel, u = I_e(e.scaleName(mAe)), l = I_e(e.scaleName(gAe)); let c = r_e(t.zoom, "scope"); return i || (c = c.map((e => (e.markname = r + rRe, e)))), n.push({ name: r + Y$e, on: [{ events: c, update: i ? "{" + [u ? `x: invert(${u}, x(unit))` : "", l ? `y: invert(${l}, y(unit))` : ""].filter((e => !!e)).join(", ") + "}" : "{x: x(unit), y: y(unit)}" }] }, { name: a, on: [{ events: c, force: !0, update: "pow(1.001, event.deltaY * pow(16, event.deltaMode))" }] }), void 0 !== o && Z$e(e, t, o, "width", n), void 0 !== s && Z$e(e, t, s, "height", n), n } }; function Z$e(e, t, n, r, i) { var a; const o = t.name, s = n.channel, u = L$e.has(t), l = i.filter((e => e.name === n.signals[u ? "data" : "visual"]))[0], c = e.getSizeSignalRef(r).signal, h = e.getScaleComponent(s), d = h.get("type"), f = u ? j$e(e, s) : l.name, p = o + X$e, m = `${u ? "log" === d ? "zoomLog" : "pow" === d ? "zoomPow" : "zoomLinear" : "zoomLinear"}(${f}, ${`${o}${Y$e}.${s}`}, ${p}` + (u && "pow" === d ? `, ${null !== (a = h.get("exponent")) && void 0 !== a ? a : 1}` : "") + ")"; l.on.push({ events: { signal: p }, update: u ? m : `clampRange(${m}, 0, ${c})` }) } const J$e = [D$e, z$e, L$e, W$e, H$e, K$e, R$e, T$e, P$e]; function Q$e(e, t) { for (const n of J$e) n.has(e) && t(n) } function eRe(e, t = !0, n = g_e) { if (b_e(e)) { const r = e.map((e => eRe(e, t, n))); return t ? `[${r.join(", ")}]` : r } return PEe(e) ? n(t ? VEe(e) : function (e) { const t = WEe(e, !0); return e.utc ? +new Date(Date.UTC(...t)) : +new Date(...t) }(e)) : t ? n(JSON.stringify(e)) : e } function tRe(e, t) { return mRe(e, ((n, r) => { t = r.marks ? r.marks(e, n, t) : t, Q$e(n, (r => { r.marks && (t = r.marks(e, n, t)) })) })), t } function nRe(e) { return e.map((e => (e.on && !e.on.length && delete e.on, e))) } const rRe = "_brush", iRe = "_scale_trigger", aRe = { signals: (e, t) => { const n = t.name, r = n + M$e, i = L$e.has(t), a = [], o = [], s = []; if (t.translate && !i) { const e = `!event.item || event.item.mark.name !== ${I_e(n + rRe)}`; oRe(t, ((t, n) => { var r; const i = __e(null !== (r = n.between[0].filter) && void 0 !== r ? r : n.between[0].filter = []); return i.indexOf(e) < 0 && i.push(e), t })) } t.project.items.forEach(((n, r) => { const i = n.channel; if (i !== mAe && i !== gAe) return void zEe("Interval selections only support x and y encoding channels."); const u = t.init ? t.init[r] : null, l = function (e, t, n, r) { const i = n.channel, a = n.signals.visual, o = n.signals.data, s = L$e.has(t), u = I_e(e.scaleName(i)), l = e.getScaleComponent(i), c = l ? l.get("type") : void 0, h = e => `scale(${u}, ${e})`, d = e.getSizeSignalRef(i === mAe ? "width" : "height").signal, f = `${i}(unit)`, p = oRe(t, ((e, t) => [...e, { events: t.between[0], update: `[${f}, ${f}]` }, { events: t, update: `[${a}[0], clamp(${f}, 0, ${d})]` }])); return p.push({ events: { signal: t.name + iRe }, update: XNe(c) ? `[${h(`${o}[0]`)}, ${h(`${o}[1]`)}]` : "[0, 0]" }), s ? [{ name: o, on: [] }] : [Object.assign(Object.assign({ name: a }, r ? { init: eRe(r, !0, h) } : { value: [] }), { on: p }), Object.assign(Object.assign({ name: o }, r ? { init: eRe(r) } : {}), { on: [{ events: { signal: a }, update: `${a}[0] === ${a}[1] ? null : invert(${u}, ${a})` }] })] }(e, t, n, u), c = n.signals.data, h = n.signals.visual, d = I_e(e.scaleName(i)), f = XNe(e.getScaleComponent(i).get("type")) ? "+" : ""; a.push(...l), o.push(c), s.push({ scaleName: e.scaleName(i), expr: `(!isArray(${c}) || (${f}invert(${d}, ${h})[0] === ${f}${c}[0] && ${f}invert(${d}, ${h})[1] === ${f}${c}[1]))` }) })), i || a.push({ name: n + iRe, value: {}, on: [{ events: s.map((e => ({ scale: e.scaleName }))), update: s.map((e => e.expr)).join(" && ") + ` ? ${n + iRe} : {}` }] }); const u = t.init, l = `unit: ${gRe(e)}, fields: ${r}, values`; return a.concat(Object.assign(Object.assign({ name: n + hRe }, u ? { init: `{${l}: ${eRe(u)}}` } : {}), { on: [{ events: [{ signal: o.join(" || ") }], update: o.join(" && ") + ` ? {${l}: [${o}]} : null` }] })) }, modifyExpr: (e, t) => t.name + hRe + ", " + ("global" === t.resolve ? "true" : `{unit: ${gRe(e)}}`), marks: (e, t, n) => { const r = t.name, { x: i, y: a } = t.project.hasChannel, o = i && i.signals.visual, s = a && a.signals.visual, u = `data(${I_e(t.name + cRe)})`; if (L$e.has(t)) return n; const l = { x: void 0 !== i ? { signal: `${o}[0]` } : { value: 0 }, y: void 0 !== a ? { signal: `${s}[0]` } : { value: 0 }, x2: void 0 !== i ? { signal: `${o}[1]` } : { field: { group: "width" } }, y2: void 0 !== a ? { signal: `${s}[1]` } : { field: { group: "height" } } }; if ("global" === t.resolve) for (const t of oCe(l)) l[t] = [Object.assign({ test: `${u}.length && ${u}[0].unit === ${gRe(e)}` }, l[t]), { value: 0 }]; const c = t.mark, { fill: h, fillOpacity: d, cursor: f } = c, p = F_e(c, ["fill", "fillOpacity", "cursor"]), m = oCe(p).reduce(((e, t) => (e[t] = [{ test: [void 0 !== i && `${o}[0] !== ${o}[1]`, void 0 !== a && `${s}[0] !== ${s}[1]`].filter((e => e)).join(" && "), value: p[t] }, { value: null }], e)), {}); return [{ name: r + rRe + "_bg", type: "rect", clip: !0, encode: { enter: { fill: { value: h }, fillOpacity: { value: d } }, update: l } }, ...n, { name: r + rRe, type: "rect", clip: !0, encode: { enter: Object.assign(Object.assign({}, f ? { cursor: { value: f } } : {}), { fill: { value: "transparent" } }), update: Object.assign(Object.assign({}, l), m) } }] } }; function oRe(e, t) { return e.events.reduce(((e, n) => n.between ? t(e, n) : (zEe(`${n} is not an ordered event stream for interval selections.`), e)), []) } function sRe(e, t) { const n = t.name, r = n + M$e, i = t.project, a = "(item().isVoronoi ? datum.datum : datum)", o = i.items.map((t => { const n = e.fieldDef(t.channel); return n && n.bin ? `[${a}[${I_e(e.vgField(t.channel, {}))}], ${a}[${I_e(e.vgField(t.channel, { binSuffix: "end" }))}]]` : `${a}[${I_e(t.field)}]` })).join(", "), s = `unit: ${gRe(e)}, fields: ${r}, values`, u = t.events; return [{ name: n + hRe, on: u ? [{ events: u, update: `datum && item().mark.marktype !== 'group' ? {${s}: [${o}]} : null`, force: !0 }] : [] }] } const uRe = { signals: sRe, modifyExpr: (e, t) => t.name + hRe + ", " + ("global" === t.resolve ? "null" : `{unit: ${gRe(e)}}`) }, lRe = { signals: sRe, modifyExpr: (e, t) => t.name + hRe + ", " + ("global" === t.resolve ? "true" : `{unit: ${gRe(e)}}`) }, cRe = "_store", hRe = "_tuple", dRe = "_modify", fRe = "vlSelectionResolve", pRe = { single: lRe, multi: uRe, interval: aRe }; function mRe(e, t) { const n = e.component.selection; if (n) for (const e of sCe(n)) { if (!0 === t(e, pRe[e.type])) break } } function gRe(e, { escape: t } = { escape: !0 }) { let n = t ? I_e(e.name) : e.name; const r = function (e) { let t = e.parent; for (; t && !_Be(t);)t = t.parent; return t }(e); if (r) { const { facet: e } = r; for (const t of QAe) e[t] && (n += ` + '__facet_${t}_' + (facet[${I_e(r.vgField(t))}])`) } return n } function yRe(e) { let t = !1; return mRe(e, (e => { t = t || e.project.items.some((e => e.field === xFe)) })), t } const bRe = "Property", vRe = "ArrayExpression", xRe = "BinaryExpression", wRe = "CallExpression", kRe = "ConditionalExpression", SRe = "LogicalExpression", _Re = "MemberExpression", CRe = "ObjectExpression", ARe = "UnaryExpression"; function TRe(e) { this.type = e } var ERe, NRe, IRe, MRe, FRe; TRe.prototype.visit = function (e) { let t, n, r; if (e(this)) return 1; for (t = function (e) { switch (e.type) { case vRe: return e.elements; case xRe: case SRe: return [e.left, e.right]; case wRe: return [e.callee].concat(e.arguments); case kRe: return [e.test, e.consequent, e.alternate]; case _Re: return [e.object, e.property]; case CRe: return e.properties; case bRe: return [e.key, e.value]; case ARe: return [e.argument]; default: return [] } }(this), n = 0, r = t.length; n < r; ++n)if (t[n].visit(e)) return 1 }; (ERe = {})[1] = "Boolean", ERe[2] = "", ERe[3] = "Identifier", ERe[4] = "Keyword", ERe[5] = "Null", ERe[6] = "Numeric", ERe[7] = "Punctuator", ERe[8] = "String", ERe[9] = "RegularExpression"; var DRe = "Identifier", $Re = "Unexpected token %0", RRe = "Invalid regular expression", ORe = "Invalid regular expression: missing /", zRe = "Octal literals are not allowed in strict mode.", PRe = "ILLEGAL", BRe = "Disabled.", LRe = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), jRe = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"); function URe(e, t) { if (!e) throw new Error("ASSERT: " + t) } function WRe(e) { return e >= 48 && e <= 57 } function VRe(e) { return "0123456789abcdefABCDEF".indexOf(e) >= 0 } function GRe(e) { return "01234567".indexOf(e) >= 0 } function HRe(e) { return 32 === e || 9 === e || 11 === e || 12 === e || 160 === e || e >= 5760 && [5760, 6158, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(e) >= 0 } function qRe(e) { return 10 === e || 13 === e || 8232 === e || 8233 === e } function YRe(e) { return 36 === e || 95 === e || e >= 65 && e <= 90 || e >= 97 && e <= 122 || 92 === e || e >= 128 && LRe.test(String.fromCharCode(e)) } function XRe(e) { return 36 === e || 95 === e || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57 || 92 === e || e >= 128 && jRe.test(String.fromCharCode(e)) } var KRe = { if: 1, in: 1, do: 1, var: 1, for: 1, new: 1, try: 1, let: 1, this: 1, else: 1, case: 1, void: 1, with: 1, enum: 1, while: 1, break: 1, catch: 1, throw: 1, const: 1, yield: 1, class: 1, super: 1, return: 1, typeof: 1, delete: 1, switch: 1, export: 1, import: 1, public: 1, static: 1, default: 1, finally: 1, extends: 1, package: 1, private: 1, function: 1, continue: 1, debugger: 1, interface: 1, protected: 1, instanceof: 1, implements: 1 }; function ZRe() { for (var e; IRe < MRe && (HRe(e = NRe.charCodeAt(IRe)) || qRe(e));)++IRe } function JRe(e) { var t, n, r, i = 0; for (n = "u" === e ? 4 : 2, t = 0; t < n; ++t)IRe < MRe && VRe(NRe[IRe]) ? (r = NRe[IRe++], i = 16 * i + "0123456789abcdef".indexOf(r.toLowerCase())) : pOe({}, $Re, PRe); return String.fromCharCode(i) } function QRe() { var e, t, n, r; for (t = 0, "}" === (e = NRe[IRe]) && pOe({}, $Re, PRe); IRe < MRe && VRe(e = NRe[IRe++]);)t = 16 * t + "0123456789abcdef".indexOf(e.toLowerCase()); return (t > 1114111 || "}" !== e) && pOe({}, $Re, PRe), t <= 65535 ? String.fromCharCode(t) : (n = 55296 + (t - 65536 >> 10), r = 56320 + (t - 65536 & 1023), String.fromCharCode(n, r)) } function eOe() { var e, t; for (e = NRe.charCodeAt(IRe++), t = String.fromCharCode(e), 92 === e && (117 !== NRe.charCodeAt(IRe) && pOe({}, $Re, PRe), ++IRe, (e = JRe("u")) && "\\" !== e && YRe(e.charCodeAt(0)) || pOe({}, $Re, PRe), t = e); IRe < MRe && XRe(e = NRe.charCodeAt(IRe));)++IRe, t += String.fromCharCode(e), 92 === e && (t = t.substr(0, t.length - 1), 117 !== NRe.charCodeAt(IRe) && pOe({}, $Re, PRe), ++IRe, (e = JRe("u")) && "\\" !== e && XRe(e.charCodeAt(0)) || pOe({}, $Re, PRe), t += e); return t } function tOe() { var e, t; return e = IRe, t = 92 === NRe.charCodeAt(IRe) ? eOe() : function () { var e, t; for (e = IRe++; IRe < MRe;) { if (92 === (t = NRe.charCodeAt(IRe))) return IRe = e, eOe(); if (!XRe(t)) break; ++IRe } return NRe.slice(e, IRe) }(), { type: 1 === t.length ? 3 : KRe.hasOwnProperty(t) ? 4 : "null" === t ? 5 : "true" === t || "false" === t ? 1 : 3, value: t, start: e, end: IRe } } function nOe() { var e, t, n, r, i = IRe, a = NRe.charCodeAt(IRe), o = NRe[IRe]; switch (a) { case 46: case 40: case 41: case 59: case 44: case 123: case 125: case 91: case 93: case 58: case 63: case 126: return ++IRe, { type: 7, value: String.fromCharCode(a), start: i, end: IRe }; default: if (61 === (e = NRe.charCodeAt(IRe + 1))) switch (a) { case 43: case 45: case 47: case 60: case 62: case 94: case 124: case 37: case 38: case 42: return IRe += 2, { type: 7, value: String.fromCharCode(a) + String.fromCharCode(e), start: i, end: IRe }; case 33: case 61: return IRe += 2, 61 === NRe.charCodeAt(IRe) && ++IRe, { type: 7, value: NRe.slice(i, IRe), start: i, end: IRe } } }return ">>>=" === (r = NRe.substr(IRe, 4)) ? { type: 7, value: r, start: i, end: IRe += 4 } : ">>>" === (n = r.substr(0, 3)) || "<<=" === n || ">>=" === n ? { type: 7, value: n, start: i, end: IRe += 3 } : o === (t = n.substr(0, 2))[1] && "+-<>&|".indexOf(o) >= 0 || "=>" === t ? { type: 7, value: t, start: i, end: IRe += 2 } : "<>=!+-*%&|^/".indexOf(o) >= 0 ? { type: 7, value: o, start: i, end: ++IRe } : void pOe({}, $Re, PRe) } function rOe() { var e, t, n; if (URe(WRe((n = NRe[IRe]).charCodeAt(0)) || "." === n, "Numeric literal must start with a decimal digit or a decimal point"), t = IRe, e = "", "." !== n) { if (e = NRe[IRe++], n = NRe[IRe], "0" === e) { if ("x" === n || "X" === n) return ++IRe, function (e) { for (var t = ""; IRe < MRe && VRe(NRe[IRe]);)t += NRe[IRe++]; return 0 === t.length && pOe({}, $Re, PRe), YRe(NRe.charCodeAt(IRe)) && pOe({}, $Re, PRe), { type: 6, value: parseInt("0x" + t, 16), start: e, end: IRe } }(t); if (GRe(n)) return function (e) { for (var t = "0" + NRe[IRe++]; IRe < MRe && GRe(NRe[IRe]);)t += NRe[IRe++]; return (YRe(NRe.charCodeAt(IRe)) || WRe(NRe.charCodeAt(IRe))) && pOe({}, $Re, PRe), { type: 6, value: parseInt(t, 8), octal: !0, start: e, end: IRe } }(t); n && WRe(n.charCodeAt(0)) && pOe({}, $Re, PRe) } for (; WRe(NRe.charCodeAt(IRe));)e += NRe[IRe++]; n = NRe[IRe] } if ("." === n) { for (e += NRe[IRe++]; WRe(NRe.charCodeAt(IRe));)e += NRe[IRe++]; n = NRe[IRe] } if ("e" === n || "E" === n) if (e += NRe[IRe++], "+" !== (n = NRe[IRe]) && "-" !== n || (e += NRe[IRe++]), WRe(NRe.charCodeAt(IRe))) for (; WRe(NRe.charCodeAt(IRe));)e += NRe[IRe++]; else pOe({}, $Re, PRe); return YRe(NRe.charCodeAt(IRe)) && pOe({}, $Re, PRe), { type: 6, value: parseFloat(e), start: t, end: IRe } } function iOe() { var e, t, n, r; return FRe = null, ZRe(), e = IRe, t = function () { var e, t, n, r; for (URe("/" === (e = NRe[IRe]), "Regular expression literal must start with a slash"), t = NRe[IRe++], n = !1, r = !1; IRe < MRe;)if (t += e = NRe[IRe++], "\\" === e) qRe((e = NRe[IRe++]).charCodeAt(0)) && pOe({}, ORe), t += e; else if (qRe(e.charCodeAt(0))) pOe({}, ORe); else if (n) "]" === e && (n = !1); else { if ("/" === e) { r = !0; break } "[" === e && (n = !0) } return r || pOe({}, ORe), { value: t.substr(1, t.length - 2), literal: t } }(), n = function () { var e, t, n; for (t = "", n = ""; IRe < MRe && XRe((e = NRe[IRe]).charCodeAt(0));)++IRe, "\\" === e && IRe < MRe ? pOe({}, $Re, PRe) : (n += e, t += e); return n.search(/[^gimuy]/g) >= 0 && pOe({}, RRe, n), { value: n, literal: t } }(), r = function (e, t) { var n = e; t.indexOf("u") >= 0 && (n = n.replace(/\\u\{([0-9a-fA-F]+)\}/g, (function (e, t) { if (parseInt(t, 16) <= 1114111) return "x"; pOe({}, RRe) })).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x")); try { new RegExp(n) } catch (e) { pOe({}, RRe) } try { return new RegExp(e, t) } catch (e) { return null } }(t.value, n.value), { literal: t.literal + n.literal, value: r, regex: { pattern: t.value, flags: n.value }, start: e, end: IRe } } function aOe() { var e; return ZRe(), IRe >= MRe ? { type: 2, start: IRe, end: IRe } : YRe(e = NRe.charCodeAt(IRe)) ? tOe() : 40 === e || 41 === e || 59 === e ? nOe() : 39 === e || 34 === e ? function () { var e, t, n, r, i = "", a = !1; for (URe("'" === (e = NRe[IRe]) || '"' === e, "String literal must starts with a quote"), t = IRe, ++IRe; IRe < MRe;) { if ((n = NRe[IRe++]) === e) { e = ""; break } if ("\\" === n) if ((n = NRe[IRe++]) && qRe(n.charCodeAt(0))) "\r" === n && "\n" === NRe[IRe] && ++IRe; else switch (n) { case "u": case "x": "{" === NRe[IRe] ? (++IRe, i += QRe()) : i += JRe(n); break; case "n": i += "\n"; break; case "r": i += "\r"; break; case "t": i += "\t"; break; case "b": i += "\b"; break; case "f": i += "\f"; break; case "v": i += "\v"; break; default: GRe(n) ? (0 !== (r = "01234567".indexOf(n)) && (a = !0), IRe < MRe && GRe(NRe[IRe]) && (a = !0, r = 8 * r + "01234567".indexOf(NRe[IRe++]), "0123".indexOf(n) >= 0 && IRe < MRe && GRe(NRe[IRe]) && (r = 8 * r + "01234567".indexOf(NRe[IRe++]))), i += String.fromCharCode(r)) : i += n } else { if (qRe(n.charCodeAt(0))) break; i += n } } return "" !== e && pOe({}, $Re, PRe), { type: 8, value: i, octal: a, start: t, end: IRe } }() : 46 === e ? WRe(NRe.charCodeAt(IRe + 1)) ? rOe() : nOe() : WRe(e) ? rOe() : nOe() } function oOe() { var e; return IRe = (e = FRe).end, FRe = aOe(), IRe = e.end, e } function sOe() { var e; e = IRe, FRe = aOe(), IRe = e } function uOe(e, t, n) { var r = new TRe("||" === e || "&&" === e ? "LogicalExpression" : "BinaryExpression"); return r.operator = e, r.left = t, r.right = n, r } function lOe(e, t) { var n = new TRe("CallExpression"); return n.callee = e, n.arguments = t, n } function cOe(e) { var t = new TRe(DRe); return t.name = e, t } function hOe(e) { var t = new TRe("Literal"); return t.value = e.value, t.raw = NRe.slice(e.start, e.end), e.regex && ("//" === t.raw && (t.raw = "/(?:)/"), t.regex = e.regex), t } function dOe(e, t, n) { var r = new TRe("MemberExpression"); return r.computed = "[" === e, r.object = t, r.property = n, r.computed || (n.member = !0), r } function fOe(e, t, n) { var r = new TRe("Property"); return r.key = t, r.value = n, r.kind = e, r } function pOe(e, t) { var n, r = Array.prototype.slice.call(arguments, 2), i = t.replace(/%(\d)/g, (function (e, t) { return URe(t < r.length, "Message reference must be in range"), r[t] })); throw (n = new Error(i)).index = IRe, n.description = i, n } function mOe(e) { 2 === e.type && pOe(e, "Unexpected end of input"), 6 === e.type && pOe(e, "Unexpected number"), 8 === e.type && pOe(e, "Unexpected string"), 3 === e.type && pOe(e, "Unexpected identifier"), 4 === e.type && pOe(e, "Unexpected reserved word"), pOe(e, $Re, e.value) } function gOe(e) { var t = oOe(); 7 === t.type && t.value === e || mOe(t) } function yOe(e) { return 7 === FRe.type && FRe.value === e } function bOe(e) { return 4 === FRe.type && FRe.value === e } function vOe() { var e = []; for (IRe = FRe.start, gOe("["); !yOe("]");)yOe(",") ? (oOe(), e.push(null)) : (e.push(MOe()), yOe("]") || gOe(",")); return oOe(), function (e) { var t = new TRe("ArrayExpression"); return t.elements = e, t }(e) } function xOe() { var e; return IRe = FRe.start, 8 === (e = oOe()).type || 6 === e.type ? (e.octal && pOe(e, zRe), hOe(e)) : cOe(e.value) } function wOe() { var e, t, n; return IRe = FRe.start, 3 === (e = FRe).type ? (n = xOe(), gOe(":"), fOe("init", n, MOe())) : 2 !== e.type && 7 !== e.type ? (t = xOe(), gOe(":"), fOe("init", t, MOe())) : void mOe(e) } function kOe() { var e, t, n = [], r = {}, i = String; for (IRe = FRe.start, gOe("{"); !yOe("}");)t = "$" + ((e = wOe()).key.type === DRe ? e.key.name : i(e.key.value)), Object.prototype.hasOwnProperty.call(r, t) ? pOe({}, "Duplicate data property in object literal not allowed in strict mode") : r[t] = !0, n.push(e), yOe("}") || gOe(","); return gOe("}"), function (e) { var t = new TRe("ObjectExpression"); return t.properties = e, t }(n) } var SOe = { if: 1 }; function _Oe() { var e, t, n; if (yOe("(")) return function () { var e; return gOe("("), e = FOe(), gOe(")"), e }(); if (yOe("[")) return vOe(); if (yOe("{")) return kOe(); if (e = FRe.type, IRe = FRe.start, 3 === e || SOe[FRe.value]) n = cOe(oOe().value); else if (8 === e || 6 === e) FRe.octal && pOe(FRe, zRe), n = hOe(oOe()); else { if (4 === e) throw new Error(BRe); 1 === e ? ((t = oOe()).value = "true" === t.value, n = hOe(t)) : 5 === e ? ((t = oOe()).value = null, n = hOe(t)) : yOe("/") || yOe("/=") ? (n = hOe(iOe()), sOe()) : mOe(oOe()) } return n } function COe() { var e = []; if (gOe("("), !yOe(")")) for (; IRe < MRe && (e.push(MOe()), !yOe(")"));)gOe(","); return gOe(")"), e } function AOe() { return gOe("."), IRe = FRe.start, function (e) { return 3 === e.type || 4 === e.type || 1 === e.type || 5 === e.type }(e = oOe()) || mOe(e), cOe(e.value); var e } function TOe() { var e; return gOe("["), e = FOe(), gOe("]"), e } function EOe() { var e = function () { var e; for (e = _Oe(); ;)if (yOe(".")) e = dOe(".", e, AOe()); else if (yOe("(")) e = lOe(e, COe()); else { if (!yOe("[")) break; e = dOe("[", e, TOe()) } return e }(); if (7 === FRe.type && (yOe("++") || yOe("--"))) throw new Error(BRe); return e } function NOe() { var e, t; if (7 !== FRe.type && 4 !== FRe.type) t = EOe(); else { if (yOe("++") || yOe("--")) throw new Error(BRe); if (yOe("+") || yOe("-") || yOe("~") || yOe("!")) e = oOe(), t = NOe(), t = function (e, t) { var n = new TRe("UnaryExpression"); return n.operator = e, n.argument = t, n.prefix = !0, n }(e.value, t); else { if (bOe("delete") || bOe("void") || bOe("typeof")) throw new Error(BRe); t = EOe() } } return t } function IOe(e) { var t = 0; if (7 !== e.type && 4 !== e.type) return 0; switch (e.value) { case "||": t = 1; break; case "&&": t = 2; break; case "|": t = 3; break; case "^": t = 4; break; case "&": t = 5; break; case "==": case "!=": case "===": case "!==": t = 6; break; case "<": case ">": case "<=": case ">=": case "instanceof": case "in": t = 7; break; case "<<": case ">>": case ">>>": t = 8; break; case "+": case "-": t = 9; break; case "*": case "/": case "%": t = 11 }return t } function MOe() { var e, t; return e = function () { var e, t, n, r, i, a, o, s, u, l; if (e = FRe, u = NOe(), 0 === (i = IOe(r = FRe))) return u; for (r.prec = i, oOe(), t = [e, FRe], a = [u, r, o = NOe()]; (i = IOe(FRe)) > 0;) { for (; a.length > 2 && i <= a[a.length - 2].prec;)o = a.pop(), s = a.pop().value, u = a.pop(), t.pop(), n = uOe(s, u, o), a.push(n); (r = oOe()).prec = i, a.push(r), t.push(FRe), n = NOe(), a.push(n) } for (n = a[l = a.length - 1], t.pop(); l > 1;)t.pop(), n = uOe(a[l - 1].value, a[l - 2], n), l -= 2; return n }(), yOe("?") && (oOe(), t = MOe(), gOe(":"), e = function (e, t, n) { var r = new TRe("ConditionalExpression"); return r.test = e, r.consequent = t, r.alternate = n, r }(e, t, MOe())), e } function FOe() { var e = MOe(); if (yOe(",")) throw new Error(BRe); return e } function DOe(e, t, n) { return e.fields = t || [], e.fname = n, e } function $Oe(e) { return 1 === e.length ? ROe(e[0]) : OOe(e) } const ROe = e => function (t) { return t[e] }, OOe = e => { const t = e.length; return function (n) { for (let r = 0; r < t; ++r)n = n[e[r]]; return n } }; function zOe(e) { throw Error(e) } function POe(e) { const t = [], n = e.length; let r, i, a, o = null, s = 0, u = ""; function l() { t.push(u + e.substring(r, i)), u = "", r = i + 1 } for (e += "", r = i = 0; i < n; ++i)if (a = e[i], "\\" === a) u += e.substring(r, i++), r = i; else if (a === o) l(), o = null, s = -1; else { if (o) continue; r === s && '"' === a || r === s && "'" === a ? (r = i + 1, o = a) : "." !== a || s ? "[" === a ? (i > r && l(), s = r = i + 1) : "]" === a && (s || zOe("Access path missing open bracket: " + e), s > 0 && l(), s = 0, r = i + 1) : i > r ? l() : r = i + 1 } return s && zOe("Access path missing closing bracket: " + e), o && zOe("Access path missing closing quote: " + e), i > r && (i++, l()), t } function BOe(e, t, n) { const r = POe(e); return e = 1 === r.length ? r[0] : e, DOe((n && n.get || $Oe)(r), [e], t || e) } BOe("id"), DOe((e => e), [], "identity"), DOe((() => 0), [], "zero"), DOe((() => 1), [], "one"), DOe((() => !0), [], "true"), DOe((() => !1), [], "false"); Array.isArray; Object.prototype.hasOwnProperty; function LOe(e) { const t = []; return "Identifier" === e.type ? [e.name] : "Literal" === e.type ? [e.value] : ("MemberExpression" === e.type && (t.push(...LOe(e.object)), t.push(...LOe(e.property))), t) } function jOe(e) { return "MemberExpression" === e.object.type ? jOe(e.object) : "datum" === e.object.name } function UOe(e) { const t = function (e) { IRe = 0, MRe = (NRe = e).length, FRe = null, sOe(); var t = FOe(); if (2 !== FRe.type) throw new Error("Unexpect token after expression."); return t }(e), n = new Set; return t.visit((e => { "MemberExpression" === e.type && jOe(e) && n.add(LOe(e).slice(1).join(".")) })), n } class WOe extends E$e { constructor(e, t, n) { super(e), this.model = t, this.filter = n, this.expr = HOe(this.model, this.filter, this), this._dependentFields = UOe(this.expr) } clone() { return new WOe(null, this.model, G_e(this.filter)) } dependentFields() { return this._dependentFields } producedFields() { return new Set } assemble() { return { type: "filter", expr: this.expr } } hash() { return `Filter ${this.expr}` } } function VOe(e, t, n, r = "datum") { const i = []; const a = hCe(t, (function (t) { const a = cCe(t), o = e.getSelectionComponent(a, t), s = I_e(a + cRe); if (o.project.timeUnit) { const t = null != n ? n : e.component.data.raw, r = o.project.timeUnit.clone(); t.parent ? r.insertAsParentOf(t) : t.parent = r } return "none" !== o.empty && i.push(s), `vlSelectionTest(${s}, ${r}` + ("global" === o.resolve ? ")" : `, ${I_e(o.resolve)})`) })); return (i.length ? "!(" + i.map((e => `length(data(${e}))`)).join(" || ") + ") || " : "") + `(${a})` } function GOe(e, t) { const n = t.encoding; let r = t.field; if (n || r) { if (n && !r) { const i = e.project.items.filter((e => e.channel === n)); !i.length || i.length > 1 ? (r = e.project.items[0].field, zEe((i.length ? "Multiple " : "No ") + `matching ${I_e(n)} encoding found for selection ${I_e(t.selection)}. ` + `Using "field": ${I_e(r)}.`)) : r = i[0].field } } else r = e.project.items[0].field, e.project.items.length > 1 && zEe(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${I_e(r)}.`); return `${e.name}[${I_e(r)}]` } function HOe(e, t, n) { return hCe(t, (t => N_e(t) ? t : function (e) { return null == e ? void 0 : e.selection }(t) ? VOe(e, t.selection, n) : mNe(t))) } function qOe(e, t, n, r) { var i, a, o; e.encode = null !== (i = e.encode) && void 0 !== i ? i : {}, e.encode[t] = null !== (a = e.encode[t]) && void 0 !== a ? a : {}, e.encode[t].update = null !== (o = e.encode[t].update) && void 0 !== o ? o : {}, e.encode[t].update[n] = r } function YOe(e, t, n, r = { header: !1 }) { var i, a; const o = e.combine(), { disable: s, orient: u, scale: l, labelExpr: c, title: h, zindex: d } = o, f = F_e(o, ["disable", "orient", "scale", "labelExpr", "title", "zindex"]); if (!s) { for (const e in f) { const n = TCe[e], r = f[e]; if (n && n !== t && "both" !== n) delete f[e]; else if (CCe(r)) { const { condition: t } = r, n = F_e(r, ["condition"]), i = __e(t), a = _Ce[e]; if (a) { const { vgProp: t, part: r } = a, o = [...i.map((e => { const { test: t } = e, n = F_e(e, ["test"]); return Object.assign({ test: HOe(null, t) }, n) })), n]; qOe(f, r, t, o), delete f[e] } else if (null === a) { const t = { signal: i.map((e => { const { test: t } = e, n = F_e(e, ["test"]); return `${HOe(null, t)} ? ${EMe(n)} : ` })).join("") + EMe(n) }; f[e] = t } } else if (eNe(r)) { const t = _Ce[e]; if (t) { const { vgProp: n, part: i } = t; qOe(f, i, n, r), delete f[e] } } } if ("grid" === t) { if (!f.grid) return; if (f.encode) { const { grid: e } = f.encode; f.encode = Object.assign({}, e ? { grid: e } : {}), aCe(f.encode) && delete f.encode } return Object.assign(Object.assign({ scale: l, orient: u }, f), { domain: !1, labels: !1, aria: !1, maxExtent: 0, minExtent: 0, ticks: !1, zindex: xCe(d, 0) }) } { if (!r.header && e.mainExtracted) return; if (void 0 !== c) { let e = c; (null === (a = null === (i = f.encode) || void 0 === i ? void 0 : i.labels) || void 0 === a ? void 0 : a.update) && eNe(f.encode.labels.update.text) && (e = yCe(c, "datum.label", f.encode.labels.update.text.signal)), qOe(f, "labels", "text", { signal: e }) } if (null === f.labelAlign && delete f.labelAlign, f.encode) { for (const t of ACe) e.hasAxisPart(t) || delete f.encode[t]; aCe(f.encode) && delete f.encode } const t = function (e, t) { if (e) return b_e(e) && !AMe(e) ? e.map((e => dMe(e, t))).join(", ") : e }(h, n); return Object.assign(Object.assign(Object.assign(Object.assign({ scale: l, orient: u, grid: !1 }, t ? { title: t } : {}), f), !1 === n.aria ? { aria: !1 } : {}), { zindex: xCe(d, 0) }) } } } function XOe(e) { const { axes: t } = e.component, n = []; for (const r of FTe) if (t[r]) for (const i of t[r]) if (!i.get("disable") && !i.get("gridScale")) { const t = "x" === r ? "height" : "width", i = e.getSizeSignalRef(t).signal; t !== i && n.push({ name: t, update: i }) } return n } const KOe = { titleAlign: "align", titleAnchor: "anchor", titleAngle: "angle", titleBaseline: "baseline", titleColor: "color", titleFont: "font", titleFontSize: "fontSize", titleFontStyle: "fontStyle", titleFontWeight: "fontWeight", titleLimit: "limit", titleLineHeight: "lineHeight", titleOrient: "orient", titlePadding: "offset" }, ZOe = { labelAlign: "align", labelAnchor: "anchor", labelAngle: "angle", labelBaseline: "baseline", labelColor: "color", labelFont: "font", labelFontSize: "fontSize", labelFontStyle: "fontStyle", labelFontWeight: "fontWeight", labelLimit: "limit", labelLineHeight: "lineHeight", labelOrient: "orient", labelPadding: "offset" }, JOe = oCe(KOe), QOe = oCe(ZOe); function eze(e, t, n, r) { return Object.assign.apply(null, [{}, ...e.map((e => { if ("axisOrient" === e) { const e = "x" === n ? "bottom" : "left", i = t["x" === n ? "axisBottom" : "axisLeft"] || {}, a = t["x" === n ? "axisTop" : "axisRight"] || {}, o = new Set([...oCe(i), ...oCe(a)]), s = {}; for (const t of o.values()) s[t] = { signal: `${r.signal} === "${e}" ? ${NMe(i[t])} : ${NMe(a[t])}` }; return s } return t[e] }))]) } function tze(e, t, n, r) { const i = "band" === t ? ["axisDiscrete", "axisBand"] : "point" === t ? ["axisDiscrete", "axisPoint"] : function (e) { return e in VNe }(t) ? ["axisQuantitative"] : "time" === t || "utc" === t ? ["axisTemporal"] : [], a = "x" === e ? "axisX" : "axisY", o = eNe(n) ? "axisOrient" : "axis" + fCe(n), s = [...i, ...i.map((e => a + e.substr(4)))], u = ["axis", o, a]; return { vlOnlyAxisConfig: eze(s, r, e, n), vgAxisConfig: eze(u, r, e, n), axisConfigStyle: nze([...u, ...s], r) } } function nze(e, t) { var n; const r = [{}]; for (const i of e) { let e = null === (n = t[i]) || void 0 === n ? void 0 : n.style; if (e) { e = __e(e); for (const n of e) r.push(t.style[n]) } } return Object.assign.apply(null, r) } function rze(e, t, n, r = {}) { var i; const a = $Me(e, n, t.style); if (void 0 !== a) return { configFrom: "style", configValue: a }; for (const t of ["vlOnlyAxisConfig", "vgAxisConfig", "axisConfigStyle"]) if (void 0 !== (null === (i = r[t]) || void 0 === i ? void 0 : i[e])) return { configFrom: t, configValue: r[t][e] }; return {} } const ize = { scale: ({ model: e, channel: t }) => e.scaleName(t), format: ({ fieldOrDatumDef: e, config: t, axis: n }) => { const { format: r, formatType: i } = n; return _Ie(e, e.type, r, i, t, !0) }, formatType: ({ axis: e, fieldOrDatumDef: t, scaleType: n }) => { const { formatType: r } = e; return CIe(r, t, n) }, grid: ({ fieldOrDatumDef: e, axis: t, scaleType: n }) => { var r; return (!HIe(e) || !rEe(e.bin)) && (null !== (r = t.grid) && void 0 !== r ? r : function (e, t) { return !YNe(e) && HIe(t) && !nEe(null == t ? void 0 : t.bin) }(n, e)) }, gridScale: ({ model: e, channel: t }) => function (e, t) { const n = "x" === t ? "y" : "x"; if (e.getScaleComponent(n)) return e.scaleName(n); return }(e, t), labelAlign: ({ axis: e, labelAngle: t, orient: n, channel: r }) => e.labelAlign || sze(t, n, r), labelAngle: ({ labelAngle: e }) => e, labelBaseline: ({ axis: e, labelAngle: t, orient: n, channel: r }) => e.labelBaseline || oze(t, n, r), labelFlush: ({ axis: e, fieldOrDatumDef: t, channel: n }) => { var r; return null !== (r = e.labelFlush) && void 0 !== r ? r : function (e, t) { if ("x" === t && Z_e(["quantitative", "temporal"], e)) return !0; return }(t.type, n) }, labelOverlap: ({ axis: e, fieldOrDatumDef: t, scaleType: n }) => { var r; return null !== (r = e.labelOverlap) && void 0 !== r ? r : function (e, t) { if ("nominal" !== e) return "log" !== t || "greedy"; return }(t.type, n) }, orient: ({ orient: e }) => e, tickCount: ({ channel: e, model: t, axis: n, fieldOrDatumDef: r, scaleType: i }) => { var a; const o = "x" === e ? "width" : "y" === e ? "height" : void 0, s = o ? t.getSizeSignalRef(o) : void 0; return null !== (a = n.tickCount) && void 0 !== a ? a : function ({ fieldOrDatumDef: e, scaleType: t, size: n, values: r }) { var i; if (!r && !YNe(t) && "log" !== t) { if (HIe(e)) { if (nEe(e.bin)) return { signal: `ceil(${n.signal}/10)` }; if (e.timeUnit && Z_e(["month", "hours", "day", "quarter"], null === (i = QEe(e.timeUnit)) || void 0 === i ? void 0 : i.unit)) return } return { signal: `ceil(${n.signal}/40)` } } return }({ fieldOrDatumDef: r, scaleType: i, size: s, values: n.values }) }, title: ({ axis: e, model: t, channel: n }) => { if (void 0 !== e.title) return e.title; const r = uze(t, n); if (void 0 !== r) return r; const i = t.typedFieldDef(n), a = "x" === n ? "x2" : "y2", o = t.fieldDef(a); return OMe(i ? [BIe(i)] : [], HIe(o) ? [BIe(o)] : []) }, values: ({ axis: e, fieldOrDatumDef: t }) => function (e, t) { const n = e.values; if (b_e(n)) return SMe(t, n); if (eNe(n)) return n; return }(e, t), zindex: ({ axis: e, fieldOrDatumDef: t, mark: n }) => { var r; return null !== (r = e.zindex) && void 0 !== r ? r : function (e, t) { if ("rect" === e && aMe(t)) return 1; return 0 }(n, t) } }; function aze(e) { return `(((${e.signal} % 360) + 360) % 360)` } function oze(e, t, n, r) { if (void 0 !== e) { if ("x" === n) { if (eNe(e)) { const n = aze(e); return { signal: `(45 < ${n} && ${n} < 135) || (225 < ${n} && ${n} < 315) ? "middle" :(${n} <= 45 || 315 <= ${n}) === ${eNe(t) ? `(${t.signal} === "top")` : "top" === t} ? "bottom" : "top"` } } if (45 < e && e < 135 || 225 < e && e < 315) return "middle"; if (eNe(t)) { const n = e <= 45 || 315 <= e ? "===" : "!=="; return { signal: `${t.signal} ${n} "top" ? "bottom" : "top"` } } return (e <= 45 || 315 <= e) == ("top" === t) ? "bottom" : "top" } if (eNe(e)) { const n = aze(e); return { signal: `${n} <= 45 || 315 <= ${n} || (135 <= ${n} && ${n} <= 225) ? ${r ? '"middle"' : "null"} : (45 <= ${n} && ${n} <= 135) === ${eNe(t) ? `(${t.signal} === "left")` : "left" === t} ? "top" : "bottom"` } } if (e <= 45 || 315 <= e || 135 <= e && e <= 225) return r ? "middle" : null; if (eNe(t)) { const n = 45 <= e && e <= 135 ? "===" : "!=="; return { signal: `${t.signal} ${n} "left" ? "top" : "bottom"` } } return (45 <= e && e <= 135) == ("left" === t) ? "top" : "bottom" } } function sze(e, t, n) { if (void 0 === e) return; const r = "x" === n, i = r ? 0 : 90, a = r ? "bottom" : "left"; if (eNe(e)) { const n = aze(e); return { signal: `(${i ? "(" + n + " + 90)" : n} % 180 === 0) ? ${r ? null : '"center"'} :(${i} < ${n} && ${n} < ${180 + i}) === ${eNe(t) ? `(${t.signal} === "${a}")` : t === a} ? "left" : "right"` } } if ((e + i) % 180 == 0) return r ? null : "center"; if (eNe(t)) { const n = i < e && e < 180 + i ? "===" : "!=="; return { signal: `${`${t.signal} ${n} "${a}"`} ? "left" : "right"` } } return (i < e && e < 180 + i) == (t === a) ? "left" : "right" } function uze(e, t) { const n = "x" === t ? "x2" : "y2", r = e.fieldDef(t), i = e.fieldDef(n), a = r ? r.title : void 0, o = i ? i.title : void 0; return a && o ? zMe(a, o) : a || (o || (void 0 !== a ? a : void 0 !== o ? o : void 0)) } class lze extends E$e { constructor(e, t) { super(e), this.transform = t, this._dependentFields = UOe(this.transform.calculate) } clone() { return new lze(null, G_e(this.transform)) } static parseAllForSortIndex(e, t) { return t.forEachFieldDef(((t, n) => { if (eMe(t) && RIe(t.sort)) { const { field: r, timeUnit: i } = t, a = t.sort, o = a.map(((e, t) => `${mNe({ field: r, timeUnit: i, equal: e })} ? ${t} : `)).join("") + a.length; e = new lze(e, { calculate: o, as: cze(t, n, { forAs: !0 }) }) } })), e } producedFields() { return new Set([this.transform.as]) } dependentFields() { return this._dependentFields } assemble() { return { type: "formula", expr: this.transform.calculate, as: this.transform.as } } hash() { return `Calculate ${X_e(this.transform)}` } } function cze(e, t, n) { return iMe(e, Object.assign({ prefix: t, suffix: "sort_index" }, null != n ? n : {})) } function hze(e, t) { return Z_e(["top", "bottom"], t) ? "column" : Z_e(["left", "right"], t) || "row" === e ? "row" : "column" } function dze(e, t, n, r) { const i = "row" === r ? n.headerRow : "column" === r ? n.headerColumn : n.headerFacet; return xCe(((null == t ? void 0 : t.header) || {})[e], i[e], n.header[e]) } function fze(e, t, n, r) { const i = {}; for (const a of e) { const e = dze(a, t, n, r); void 0 !== e && (i[a] = e) } return i } const pze = ["row", "column"], mze = ["header", "footer"]; function gze(e, t) { const n = e.component.layoutHeaders[t].title, r = e.config ? e.config : void 0, i = e.component.layoutHeaders[t].facetFieldDef ? e.component.layoutHeaders[t].facetFieldDef : void 0, { titleAnchor: a, titleAngle: o, titleOrient: s } = fze(["titleAnchor", "titleAngle", "titleOrient"], i, r, t), u = hze(t, s), l = kCe(o); return { name: `${t}-title`, type: "group", role: `${u}-title`, title: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ text: n }, "row" === t ? { orient: "left" } : {}), { style: "guide-title" }), bze(l, u)), yze(u, l, a)), Cze(r, i, t, JOe, KOe)) } } function yze(e, t, n = "middle") { switch (n) { case "start": return { align: "left" }; case "end": return { align: "right" } }const r = sze(t, "row" === e ? "left" : "top", "row" === e ? "y" : "x"); return r ? { align: r } : {} } function bze(e, t) { const n = oze(e, "row" === t ? "left" : "top", "row" === t ? "y" : "x", !0); return n ? { baseline: n } : {} } function vze(e, t) { const n = e.component.layoutHeaders[t], r = []; for (const i of mze) if (n[i]) for (const a of n[i]) { const o = kze(e, t, i, n, a); null != o && r.push(o) } return r } function xze(e, t) { var n; const { sort: r } = e; return $Ie(r) ? { field: iMe(r, { expr: "datum" }), order: null !== (n = r.order) && void 0 !== n ? n : "ascending" } : b_e(r) ? { field: cze(e, t, { expr: "datum" }), order: "ascending" } : { field: iMe(e, { expr: "datum" }), order: null != r ? r : "ascending" } } function wze(e, t, n) { const { format: r, formatType: i, labelAngle: a, labelAnchor: o, labelOrient: s, labelExpr: u } = fze(["format", "formatType", "labelAngle", "labelAnchor", "labelOrient", "labelExpr"], e, n, t), l = wIe({ fieldOrDatumDef: e, format: r, formatType: i, expr: "parent", config: n }).signal, c = hze(t, s); return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ text: { signal: u ? yCe(yCe(u, "datum.label", l), "datum.value", iMe(e, { expr: "parent" })) : l } }, "row" === t ? { orient: "left" } : {}), { style: "guide-label", frame: "group" }), bze(a, c)), yze(c, a, o)), Cze(n, e, t, QOe, ZOe)) } function kze(e, t, n, r, i) { if (i) { let a = null; const { facetFieldDef: o } = r, s = e.config ? e.config : void 0; if (o && i.labels) { const { labelOrient: e } = fze(["labelOrient"], o, s, t); ("row" === t && !Z_e(["top", "bottom"], e) || "column" === t && !Z_e(["left", "right"], e)) && (a = wze(o, t, s)) } const u = _Be(e) && !OIe(e.facet), l = i.axes, c = (null == l ? void 0 : l.length) > 0; if (a || c) { const s = "row" === t ? "height" : "width"; return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name: e.getName(`${t}_${n}`), type: "group", role: `${t}-${n}` }, r.facetFieldDef ? { from: { data: e.getName(t + "_domain") }, sort: xze(o, t) } : {}), c && u ? { from: { data: e.getName(`facet_domain_${t}`) } } : {}), a ? { title: a } : {}), i.sizeSignal ? { encode: { update: { [s]: i.sizeSignal } } } : {}), c ? { axes: l } : {}) } } return null } const Sze = { column: { start: 0, end: 1 }, row: { start: 1, end: 0 } }; function _ze(e, t) { return Sze[t][e] } function Cze(e, t, n, r, i) { const a = {}; for (const o of r) { if (!i[o]) continue; const r = dze(o, t, e, n); void 0 !== r && (a[i[o]] = r) } return a } function Aze(e) { return [...Tze(e, "width"), ...Tze(e, "height"), ...Tze(e, "childWidth"), ...Tze(e, "childHeight")] } function Tze(e, t) { const n = "width" === t ? "x" : "y", r = e.component.layoutSize.get(t); if (!r || "merged" === r) return []; const i = e.getSizeSignalRef(t).signal; if ("step" === r) { const t = e.getScaleComponent(n); if (t) { const r = t.get("type"), a = t.get("range"); if (YNe(r) && tNe(a)) { const r = e.scaleName(n); if (_Be(e.parent)) { if ("independent" === e.parent.component.resolve.scale[n]) return [Eze(r, a)] } return [Eze(r, a), { name: i, update: Nze(r, t, `domain('${r}').length`) }] } } throw new Error("layout size is step although width/height is not step.") } if ("container" == r) { const t = i.endsWith("width"), n = t ? "containerSize()[0]" : "containerSize()[1]", r = `isFinite(${n}) ? ${n} : ${IFe(e.config.view, t ? "width" : "height")}`; return [{ name: i, init: r, on: [{ update: r, events: "window:resize" }] }] } return [{ name: i, value: r }] } function Eze(e, t) { return { name: e + "_step", value: t.step } } function Nze(e, t, n) { const r = t.get("type"), i = t.get("padding"), a = xCe(t.get("paddingOuter"), i); let o = t.get("paddingInner"); return o = "band" === r ? void 0 !== o ? o : i : 1, `bandspace(${n}, ${o}, ${a}) * ${e}_step` } function Ize(e) { return "childWidth" === e ? "width" : "childHeight" === e ? "height" : e } function Mze(e, t) { return oCe(e).reduce(((n, r) => { const i = e[r]; return Object.assign(Object.assign({}, n), JDe(t, i, r, (e => eNe(e) ? e : { value: e.value }))) }), {}) } function Fze(e, t) { if (ABe(t) || _Be(t)) return "shared"; if (CBe(t)) return DTe(e) ? "independent" : "shared"; throw new Error("invalid model type for resolve") } function Dze(e, t) { const n = e.scale[t], r = DTe(t) ? "axis" : "legend"; return "independent" === n ? ("shared" === e[r][t] && zEe(function (e) { return `Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.` }(t)), "independent") : e[r][t] || "shared" } const $ze = Object.assign(Object.assign({}, vFe), { disable: 1, labelExpr: 1, selections: 1, opacity: 1, shape: 1, stroke: 1, fill: 1, size: 1, strokeWidth: 1, strokeDash: 1, encode: 1 }), Rze = oCe($ze); class Oze extends bDe { } const zze = { symbols: function (e, { fieldOrDatumDef: t, model: n, channel: r, legendCmpt: i, legendType: a }) { var o, s, u, l, c; if ("symbol" !== a) return; const { markDef: h, encoding: d, config: f, mark: p } = n, m = h.filled && "trail" !== p; let g = Object.assign(Object.assign({}, function (e, t, n) { for (const r of n) { const n = FMe(r, t.markDef, t.config); void 0 !== n && (e[r] = TMe(n)) } return e }({}, n, KCe)), o$e(n, { filled: m })); const y = null !== (o = Pze(d.opacity)) && void 0 !== o ? o : h.opacity; if (g.fill) if ("fill" === r || m && r === TAe) delete g.fill; else if (g.fill.field) i.get("symbolFillColor") ? delete g.fill : (g.fill = TMe(null !== (s = f.legend.symbolBaseFillColor) && void 0 !== s ? s : "black"), g.fillOpacity = TMe(null != y ? y : 1)); else if (b_e(g.fill)) { const e = null !== (c = null !== (l = Bze(null !== (u = d.fill) && void 0 !== u ? u : d.color)) && void 0 !== l ? l : h.fill) && void 0 !== c ? c : m && h.color; e && (g.fill = TMe(e)) } if (g.stroke) if ("stroke" === r || !m && r === TAe) delete g.stroke; else if (g.stroke.field) delete g.stroke; else if (b_e(g.stroke)) { const e = xCe(Bze(d.stroke || d.color), h.stroke, m ? h.color : void 0); e && (g.stroke = { value: e }) } if (r !== DAe) { const e = HIe(t) && jze(n, i, t); e ? g.opacity = [Object.assign({ test: e }, TMe(null != y ? y : 1)), TMe(f.legend.unselectedOpacity)] : y && (g.opacity = TMe(y)) } return g = Object.assign(Object.assign({}, g), e), aCe(g) ? void 0 : g }, gradient: function (e, { model: t, legendType: n }) { if ("gradient" !== n) return; let r = {}; const i = Pze(t.encoding.opacity) || t.markDef.opacity; i && (r.opacity = TMe(i)); return r = Object.assign(Object.assign({}, r), e), aCe(r) ? void 0 : r }, labels: function (e, { fieldOrDatumDef: t, model: n, channel: r, legendCmpt: i }) { const a = n.legend(r) || {}, o = n.config, s = HIe(t) ? jze(n, i, t) : void 0, u = s ? [{ test: s, value: 1 }, { value: o.legend.unselectedOpacity }] : void 0, { format: l, formatType: c } = a, h = vIe(c) ? SIe({ fieldOrDatumDef: t, field: "datum.value", format: l, formatType: c, config: o }) : void 0, d = Object.assign(Object.assign(Object.assign({}, u ? { opacity: u } : {}), h ? { text: h } : {}), e); return aCe(d) ? void 0 : d }, entries: function (e, { legendCmpt: t }) { const n = t.get("selections"); return (null == n ? void 0 : n.length) ? Object.assign(Object.assign({}, e), { fill: { value: "transparent" } }) : e } }; function Pze(e) { return Lze(e, ((e, t) => Math.max(e, t.value))) } function Bze(e) { return Lze(e, ((e, t) => xCe(e, t.value))) } function Lze(e, t) { return function (e) { const t = e && e.condition; return !!t && (b_e(t) || QIe(t)) }(e) ? __e(e.condition).reduce(t, e.value) : QIe(e) ? e.value : void 0 } function jze(e, t, n) { const r = t.get("selections"); if (!(null == r ? void 0 : r.length)) return; const i = I_e(n.field); return r.map((e => `(!length(data(${I_e(cCe(e) + cRe)})) || (${e}[${i}] && indexof(${e}[${i}], datum.value) >= 0))`)).join(" || ") } const Uze = { direction: ({ direction: e }) => e, format: ({ fieldOrDatumDef: e, legend: t, config: n }) => { const { format: r, formatType: i } = t; return _Ie(e, e.type, r, i, n, !1) }, formatType: ({ legend: e, fieldOrDatumDef: t, scaleType: n }) => { const { formatType: r } = e; return CIe(r, t, n) }, gradientLength: e => { var t, n; const { legend: r, legendConfig: i } = e; return null !== (n = null !== (t = r.gradientLength) && void 0 !== t ? t : i.gradientLength) && void 0 !== n ? n : function ({ legendConfig: e, model: t, direction: n, orient: r, scaleType: i }) { const { gradientHorizontalMaxLength: a, gradientHorizontalMinLength: o, gradientVerticalMaxLength: s, gradientVerticalMinLength: u } = e; if (KNe(i)) return "horizontal" === n ? "top" === r || "bottom" === r ? Gze(t, "width", o, a) : o : Gze(t, "height", u, s); return }(e) }, labelOverlap: ({ legend: e, legendConfig: t, scaleType: n }) => { var r, i; return null !== (i = null !== (r = e.labelOverlap) && void 0 !== r ? r : t.labelOverlap) && void 0 !== i ? i : function (e) { if (Z_e(["quantile", "threshold", "log"], e)) return "greedy"; return }(n) }, symbolType: ({ legend: e, markDef: t, channel: n, encoding: r }) => { var i; return null !== (i = e.symbolType) && void 0 !== i ? i : function (e, t, n, r) { var i; if ("shape" !== t) { const e = null !== (i = Bze(n)) && void 0 !== i ? i : r; if (e) return e } switch (e) { case "bar": case "rect": case "image": case "square": return "square"; case "line": case "trail": case "rule": return "stroke"; case "arc": case "point": case "circle": case "tick": case "geoshape": case "area": case "text": return "circle" } }(t.type, n, r.shape, t.shape) }, title: ({ fieldOrDatumDef: e, config: t }) => cMe(e, t, { allowDisabling: !0 }), type: ({ legendType: e, scaleType: t, channel: n }) => { if (ZAe(n) && KNe(t)) { if ("gradient" === e) return } else if ("symbol" === e) return; return e }, values: ({ fieldOrDatumDef: e, legend: t }) => function (e, t) { const n = e.values; if (b_e(n)) return SMe(t, n); if (eNe(n)) return n; return }(t, e) }; function Wze(e) { const { legend: t } = e; return xCe(t.type, function ({ channel: e, timeUnit: t, scaleType: n }) { if (ZAe(e)) { if (Z_e(["quarter", "month", "day"], t)) return "symbol"; if (KNe(n)) return "gradient" } return "symbol" }(e)) } function Vze({ legendConfig: e, legendType: t, orient: n, legend: r }) { var i, a; return null !== (a = null !== (i = r.direction) && void 0 !== i ? i : e[t ? "gradientDirection" : "symbolDirection"]) && void 0 !== a ? a : function (e, t) { switch (e) { case "top": case "bottom": return "horizontal"; case "left": case "right": case "none": case void 0: return; default: return "gradient" === t ? "horizontal" : void 0 } }(n, t) } function Gze(e, t, n, r) { return { signal: `clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${r})` } } function Hze(e) { const t = SBe(e) ? function (e) { const { encoding: t } = e, n = {}; for (const r of [TAe, ...yFe]) { const i = mMe(t[r]); i && e.getScaleComponent(r) && (r === IAe && HIe(i) && i.type === SNe || (n[r] = Yze(e, r))) } return n }(e) : function (e) { const { legends: t, resolve: n } = e.component; for (const r of e.children) { Hze(r); for (const i of oCe(r.component.legends)) n.legend[i] = Dze(e.component.resolve, i), "shared" === n.legend[i] && (t[i] = Xze(t[i], r.component.legends[i]), t[i] || (n.legend[i] = "independent", delete t[i])) } for (const r of oCe(t)) for (const t of e.children) t.component.legends[r] && "shared" === n.legend[r] && delete t.component.legends[r]; return t }(e); return e.component.legends = t, t } function qze(e, t, n, r) { switch (t) { case "disable": return void 0 !== n; case "values": return !!(null == n ? void 0 : n.values); case "title": if ("title" === t && e === (null == r ? void 0 : r.title)) return !0 }return e === (n || {})[t] } function Yze(e, t) { var n, r, i; let a = e.legend(t); const { markDef: o, encoding: s, config: u } = e, l = u.legend, c = new Oze({}, function (e, t) { const n = e.scaleName(t); if ("trail" === e.mark) { if ("color" === t) return { stroke: n }; if ("size" === t) return { strokeWidth: n } } return "color" === t ? e.markDef.filled ? { fill: n } : { stroke: n } : { [t]: n } }(e, t)); !function (e, t, n) { var r; const i = null === (r = e.fieldDef(t)) || void 0 === r ? void 0 : r.field; mRe(e, (e => { var r, a; const o = null !== (r = e.project.hasField[i]) && void 0 !== r ? r : e.project.hasChannel[t]; if (o && W$e.has(e)) { const t = null !== (a = n.get("selections")) && void 0 !== a ? a : []; t.push(e.name), n.set("selections", t, !1), o.hasLegend = !0 } })) }(e, t, c); const h = void 0 !== a ? !a : l.disable; if (c.set("disable", h, void 0 !== a), h) return c; a = a || {}; const d = e.getScaleComponent(t).get("type"), f = mMe(s[t]), p = HIe(f) ? null === (n = QEe(f.timeUnit)) || void 0 === n ? void 0 : n.unit : void 0, m = a.orient || u.legend.orient || "right", g = Wze({ legend: a, channel: t, timeUnit: p, scaleType: d }), y = { legend: a, channel: t, model: e, markDef: o, encoding: s, fieldOrDatumDef: f, legendConfig: l, config: u, scaleType: d, orient: m, legendType: g, direction: Vze({ legend: a, legendType: g, orient: m, legendConfig: l }) }; for (const n of Rze) { const r = n in Uze ? Uze[n](y) : a[n]; if (void 0 !== r) { const i = qze(r, n, a, e.fieldDef(t)); (i || void 0 === u.legend[n]) && c.set(n, r, i) } } const b = null !== (r = null == a ? void 0 : a.encoding) && void 0 !== r ? r : {}, v = c.get("selections"), x = {}, w = { fieldOrDatumDef: f, model: e, channel: t, legendCmpt: c, legendType: g }; for (const t of ["labels", "legend", "title", "symbols", "gradient", "entries"]) { const n = Mze(null !== (i = b[t]) && void 0 !== i ? i : {}, e), r = t in zze ? zze[t](n, w) : n; void 0 === r || aCe(r) || (x[t] = Object.assign(Object.assign(Object.assign({}, (null == v ? void 0 : v.length) && HIe(f) ? { name: `${cCe(f.field)}_legend_${t}` } : {}), (null == v ? void 0 : v.length) ? { interactive: !!v } : {}), { update: r })) } return aCe(x) || c.set("encode", x, !!(null == a ? void 0 : a.encoding)), c } function Xze(e, t) { var n, r, i, a; if (!e) return t.clone(); const o = e.getWithExplicit("orient"), s = t.getWithExplicit("orient"); if (o.explicit && s.explicit && o.value !== s.value) return; let u = !1; for (const n of Rze) { const r = SDe(e.getWithExplicit(n), t.getWithExplicit(n), n, "legend", ((e, t) => { switch (n) { case "symbolType": return Kze(e, t); case "title": return PMe(e, t); case "type": return u = !0, xDe("symbol") }return kDe(e, t, n, "legend") })); e.setWithExplicit(n, r) } return u && ((null === (r = null === (n = e.implicit) || void 0 === n ? void 0 : n.encode) || void 0 === r ? void 0 : r.gradient) && dCe(e.implicit, ["encode", "gradient"]), (null === (a = null === (i = e.explicit) || void 0 === i ? void 0 : i.encode) || void 0 === a ? void 0 : a.gradient) && dCe(e.explicit, ["encode", "gradient"])), e } function Kze(e, t) { return "circle" === t.value ? t : e } function Zze(e, t, n, r) { var i, a, o; e.encode = null !== (i = e.encode) && void 0 !== i ? i : {}, e.encode[t] = null !== (a = e.encode[t]) && void 0 !== a ? a : {}, e.encode[t].update = null !== (o = e.encode[t].update) && void 0 !== o ? o : {}, e.encode[t].update[n] = r } function Jze(e) { const t = e.component.legends, n = {}; for (const r of oCe(t)) { const i = e.getScaleComponent(r), a = Y_e(i.get("domains")); if (n[a]) for (const e of n[a]) { Xze(e, t[r]) || n[a].push(t[r]) } else n[a] = [t[r].clone()] } const r = sCe(n).flat().map((t => function (e, t) { var n, r, i; const a = e.combine(), { disable: o, labelExpr: s, selections: u } = a, l = F_e(a, ["disable", "labelExpr", "selections"]); if (o) return; !1 === t.aria && null == l.aria && (l.aria = !1); if (null === (n = l.encode) || void 0 === n ? void 0 : n.symbols) { const e = l.encode.symbols.update; !e.fill || "transparent" === e.fill.value || e.stroke || l.stroke || (e.stroke = { value: "transparent" }); for (const t of yFe) l[t] && delete e[t] } l.title || delete l.title; if (void 0 !== s) { let e = s; (null === (i = null === (r = l.encode) || void 0 === r ? void 0 : r.labels) || void 0 === i ? void 0 : i.update) && eNe(l.encode.labels.update.text) && (e = yCe(s, "datum.label", l.encode.labels.update.text.signal)), Zze(l, "labels", "text", { signal: e }) } for (const e in l) { const t = l[e]; if (eNe(t)) { const n = bFe[e]; if (n) { const { vgProp: r, part: i } = n; Zze(l, i, r, t), delete l[e] } } } return l }(t, e.config))).filter((e => void 0 !== e)); return r } function Qze(e) { return ABe(e) || CBe(e) ? function (e) { return e.children.reduce(((e, t) => e.concat(t.assembleProjections())), ePe(e)) }(e) : ePe(e) } function ePe(e) { const t = e.component.projection; if (!t || t.merged) return []; const n = t.combine(), { name: r } = n; if (t.data) { const i = { signal: `[${t.size.map((e => e.signal)).join(", ")}]` }, a = t.data.reduce(((t, n) => { const r = eNe(n) ? n.signal : `data('${e.lookupDataSource(n)}')`; return Z_e(t, r) || t.push(r), t }), []); if (a.length <= 0) throw new Error("Projection's fit didn't find any data sources"); return [Object.assign({ name: r, size: i, fit: { signal: a.length > 1 ? `[${a.join(", ")}]` : a[0] } }, n)] } return [Object.assign(Object.assign({ name: r }, { translate: { signal: "[width / 2, height / 2]" } }), n)] } const tPe = ["type", "clipAngle", "clipExtent", "center", "rotate", "precision", "reflectX", "reflectY", "coefficient", "distance", "fraction", "lobes", "parallel", "radius", "ratio", "spacing", "tilt"]; class nPe extends bDe { constructor(e, t, n, r) { super(Object.assign({}, t), { name: e }), this.specifiedProjection = t, this.size = n, this.data = r, this.merged = !1 } get isFit() { return !!this.data } } function rPe(e) { e.component.projection = SBe(e) ? function (e) { var t; if (e.hasProjection) { const n = e.specifiedProjection, r = !(n && (null != n.scale || null != n.translate)), i = r ? [e.getSizeSignalRef("width"), e.getSizeSignalRef("height")] : void 0, a = r ? function (e) { const t = [], { encoding: n } = e; for (const r of [[_Ae, SAe], [AAe, CAe]]) (mMe(n[r[0]]) || mMe(n[r[1]])) && t.push({ signal: e.getName(`geojson_${t.length}`) }); e.channelHasField(IAe) && e.typedFieldDef(IAe).type === SNe && t.push({ signal: e.getName(`geojson_${t.length}`) }); 0 === t.length && t.push(e.requestDataName(FDe)); return t }(e) : void 0; return new nPe(e.projectionName(!0), Object.assign(Object.assign({}, null !== (t = e.config.projection) && void 0 !== t ? t : {}), null != n ? n : {}), i, a) } return }(e) : function (e) { if (0 === e.children.length) return; let t; for (const t of e.children) rPe(t); const n = Q_e(e.children, (e => { const n = e.component.projection; if (n) { if (t) { const e = function (e, t) { const n = Q_e(tPe, (n => !A_e(e.explicit, n) && !A_e(t.explicit, n) || !(!A_e(e.explicit, n) || !A_e(t.explicit, n) || Y_e(e.get(n)) !== Y_e(t.get(n))))), r = Y_e(e.size) === Y_e(t.size); if (r) { if (n) return e; if (Y_e(e.explicit) === Y_e({})) return t; if (Y_e(t.explicit) === Y_e({})) return e } return null }(t, n); return e && (t = e), !!e } return t = n, !0 } return !0 })); if (t && n) { const n = e.projectionName(!0), r = new nPe(n, t.specifiedProjection, t.size, G_e(t.data)); for (const t of e.children) { const e = t.component.projection; e && (e.isFit && r.data.push(...t.component.projection.data), t.renameProjection(e.get("name"), n), e.merged = !0) } return r } return }(e) } function iPe(e, t) { return `${tEe(e)}_${t}` } function aPe(e, t, n) { var r; const i = iPe(null !== (r = vMe(n, void 0)) && void 0 !== r ? r : {}, t); return e.getName(`${i}_bins`) } function oPe(e, t, n) { let r, i; r = function (e) { return "as" in e }(e) ? N_e(e.as) ? [e.as, `${e.as}_end`] : [e.as[0], e.as[1]] : [iMe(e, { forAs: !0 }), iMe(e, { binSuffix: "end", forAs: !0 })]; const a = Object.assign({}, vMe(t, void 0)), o = iPe(a, e.field), { signal: s, extentSignal: u } = function (e, t) { return { signal: e.getName(`${t}_bins`), extentSignal: e.getName(`${t}_extent`) } }(n, o); if (aEe(a.extent)) { const e = a.extent, t = e.selection; i = GOe(n.getSelectionComponent(cCe(t), t), e), delete a.extent } return { key: o, binComponent: Object.assign(Object.assign(Object.assign({ bin: a, field: e.field, as: [r] }, s ? { signal: s } : {}), u ? { extentSignal: u } : {}), i ? { span: i } : {}) } } class sPe extends E$e { constructor(e, t) { super(e), this.bins = t } clone() { return new sPe(null, G_e(this.bins)) } static makeFromEncoding(e, t) { const n = t.reduceFieldDef(((e, n, r) => { if (JIe(n) && nEe(n.bin)) { const { key: i, binComponent: a } = oPe(n, n.bin, t); e[i] = Object.assign(Object.assign(Object.assign({}, a), e[i]), function (e, t, n, r) { var i, a; if (_Me(t, n)) { const o = SBe(e) && null !== (a = null !== (i = e.axis(n)) && void 0 !== i ? i : e.legend(n)) && void 0 !== a ? a : {}, s = iMe(t, { expr: "datum" }), u = iMe(t, { expr: "datum", binSuffix: "end" }); return { formulaAs: iMe(t, { binSuffix: "range", forAs: !0 }), formula: NIe(s, u, o.format, o.formatType, r) } } return {} }(t, n, r, t.config)) } return e }), {}); return aCe(n) ? null : new sPe(e, n) } static makeFromTransform(e, t, n) { const { key: r, binComponent: i } = oPe(t, t.bin, n); return new sPe(e, { [r]: i }) } merge(e, t) { for (const n of oCe(e.bins)) n in this.bins ? (t(e.bins[n].signal, this.bins[n].signal), this.bins[n].as = tCe([...this.bins[n].as, ...e.bins[n].as], X_e)) : this.bins[n] = e.bins[n]; for (const t of e.children) e.removeChild(t), t.parent = this; e.remove() } producedFields() { return new Set(sCe(this.bins).map((e => e.as)).flat(2)) } dependentFields() { return new Set(sCe(this.bins).map((e => e.field))) } hash() { return `Bin ${X_e(this.bins)}` } assemble() { return sCe(this.bins).flatMap((e => { const t = [], [n, ...r] = e.as, i = e.bin, { extent: a } = i, o = F_e(i, ["extent"]), s = Object.assign(Object.assign(Object.assign({ type: "bin", field: gCe(e.field), as: n, signal: e.signal }, aEe(a) ? { extent: null } : { extent: a }), e.span ? { span: { signal: `span(${e.span})` } } : {}), o); !a && e.extentSignal && (t.push({ type: "extent", field: gCe(e.field), signal: e.extentSignal }), s.extent = { signal: e.extentSignal }), t.push(s); for (const e of r) for (let r = 0; r < 2; r++)t.push({ type: "formula", expr: iMe({ field: n[r] }, { expr: "datum" }), as: e[r] }); return e.formula && t.push({ type: "formula", expr: e.formula, as: e.formulaAs }), t })) } } class uPe extends E$e { constructor(e) { let t; if (super(null), EDe(e = null != e ? e : { name: "source" }) || (t = e.format ? Object.assign({}, q_e(e.format, ["parse"])) : {}), ADe(e)) this._data = { values: e.values }; else if (CDe(e)) { if (this._data = { url: e.url }, !t.type) { let n = /(?:\.([^.]+))?$/.exec(e.url)[1]; Z_e(["json", "csv", "tsv", "dsv", "topojson"], n) || (n = "json"), t.type = n } } else IDe(e) ? this._data = { values: [{ type: "Sphere" }] } : (TDe(e) || EDe(e)) && (this._data = {}); this._generator = EDe(e), e.name && (this._name = e.name), t && !aCe(t) && (this._data.format = t) } dependentFields() { return new Set } producedFields() { } get data() { return this._data } hasName() { return !!this._name } get isGenerator() { return this._generator } get dataName() { return this._name } set dataName(e) { this._name = e } set parent(e) { throw new Error("Source nodes have to be roots.") } remove() { throw new Error("Source nodes are roots and cannot be removed.") } hash() { throw new Error("Cannot hash sources") } assemble() { return Object.assign(Object.assign({ name: this._name }, this._data), { transform: [] }) } } function lPe(e) { for (const t of e) { for (const e of t.children) if (e.parent !== t) return console.error("Dataflow graph is inconsistent.", t, e), !1; if (!lPe(t.children)) return !1 } return !0 } class cPe extends E$e { constructor(e, t) { super(e), this.params = t } clone() { return new cPe(null, this.params) } dependentFields() { return new Set } producedFields() { } hash() { return `Graticule ${X_e(this.params)}` } assemble() { return Object.assign({ type: "graticule" }, !0 === this.params ? {} : this.params) } } class hPe extends E$e { constructor(e, t) { super(e), this.params = t } clone() { return new hPe(null, this.params) } dependentFields() { return new Set } producedFields() { var e; return new Set([null !== (e = this.params.as) && void 0 !== e ? e : "data"]) } hash() { return `Hash ${X_e(this.params)}` } assemble() { return Object.assign({ type: "sequence" }, this.params) } } function dPe(e) { return e instanceof uPe || e instanceof cPe || e instanceof hPe } class fPe { constructor() { this._mutated = !1 } setMutated() { this._mutated = !0 } get mutatedFlag() { return this._mutated } } class pPe extends fPe { constructor() { super(), this._continue = !1 } setContinue() { this._continue = !0 } get continueFlag() { return this._continue } get flags() { return { continueFlag: this.continueFlag, mutatedFlag: this.mutatedFlag } } set flags({ continueFlag: e, mutatedFlag: t }) { e && this.setContinue(), t && this.setMutated() } reset() { } optimizeNextFromLeaves(e) { if (dPe(e)) return !1; const t = e.parent, { continueFlag: n } = this.run(e); return n && this.optimizeNextFromLeaves(t), this.mutatedFlag } } class mPe extends fPe { } function gPe(e, t, n, r) { const i = SBe(r) ? r.encoding[mTe(t)] : void 0; if (JIe(n) && SBe(r) && UIe(t, n, i, r.stack, r.markDef, r.config)) e.add(iMe(n, {})), e.add(iMe(n, { suffix: "end" })), n.bin && _Me(n, t) && e.add(iMe(n, { binSuffix: "range" })); else if (function (e) { return e in YAe }(t)) { const n = function (e) { switch (e) { case SAe: return "y"; case CAe: return "y2"; case _Ae: return "x"; case AAe: return "x2" } }(t); e.add(r.getName(n)) } else e.add(iMe(n)); return e } class yPe extends E$e { constructor(e, t, n) { super(e), this.dimensions = t, this.measures = n } clone() { return new yPe(null, new Set(this.dimensions), G_e(this.measures)) } get groupBy() { return this.dimensions } static makeFromEncoding(e, t) { let n = !1; t.forEachFieldDef((e => { e.aggregate && (n = !0) })); const r = {}, i = new Set; return n ? (t.forEachFieldDef(((e, n) => { var a, o, s, u; const { aggregate: l, field: c } = e; if (l) if ("count" === l) r["*"] = null !== (a = r["*"]) && void 0 !== a ? a : {}, r["*"].count = new Set([iMe(e, { forAs: !0 })]); else { if (aAe(l) || oAe(l)) { const e = aAe(l) ? "argmin" : "argmax", t = l[e]; r[t] = null !== (o = r[t]) && void 0 !== o ? o : {}, r[t][e] = new Set([iMe({ op: e, field: t }, { forAs: !0 })]) } else r[c] = null !== (s = r[c]) && void 0 !== s ? s : {}, r[c][l] = new Set([iMe(e, { forAs: !0 })]); XTe(n) && "unaggregated" === t.scaleDomain(n) && (r[c] = null !== (u = r[c]) && void 0 !== u ? u : {}, r[c].min = new Set([iMe({ field: c, aggregate: "min" }, { forAs: !0 })]), r[c].max = new Set([iMe({ field: c, aggregate: "max" }, { forAs: !0 })])) } else gPe(i, n, e, t) })), i.size + oCe(r).length === 0 ? null : new yPe(e, i, r)) : null } static makeFromTransform(e, t) { var n, r, i; const a = new Set, o = {}; for (const e of t.aggregate) { const { op: t, field: i, as: a } = e; t && ("count" === t ? (o["*"] = null !== (n = o["*"]) && void 0 !== n ? n : {}, o["*"].count = new Set([a || iMe(e, { forAs: !0 })])) : (o[i] = null !== (r = o[i]) && void 0 !== r ? r : {}, o[i][t] = new Set([a || iMe(e, { forAs: !0 })]))) } for (const e of null !== (i = t.groupby) && void 0 !== i ? i : []) a.add(e); return a.size + oCe(o).length === 0 ? null : new yPe(e, a, o) } merge(e) { return function (e, t) { if (e.size !== t.size) return !1; for (const n of e) if (!t.has(n)) return !1; return !0 }(this.dimensions, e.dimensions) ? (function (e, t) { var n; for (const r of oCe(t)) { const i = t[r]; for (const t of oCe(i)) r in e ? e[r][t] = new Set([...null !== (n = e[r][t]) && void 0 !== n ? n : [], ...i[t]]) : e[r] = { [t]: i[t] } } }(this.measures, e.measures), !0) : (function (...e) { REe.debug(...e) }("different dimensions, cannot merge"), !1) } addDimensions(e) { e.forEach(this.dimensions.add, this.dimensions) } dependentFields() { return new Set([...this.dimensions, ...oCe(this.measures)]) } producedFields() { const e = new Set; for (const t of oCe(this.measures)) for (const n of oCe(this.measures[t])) { const r = this.measures[t][n]; 0 === r.size ? e.add(`${n}_${t}`) : r.forEach(e.add, e) } return e } hash() { return `Aggregate ${X_e({ dimensions: this.dimensions, measures: this.measures })}` } assemble() { const e = [], t = [], n = []; for (const r of oCe(this.measures)) for (const i of oCe(this.measures[r])) for (const a of this.measures[r][i]) n.push(a), e.push(i), t.push("*" === r ? null : gCe(r)); return { type: "aggregate", groupby: [...this.dimensions].map(gCe), ops: e, fields: t, as: n } } } class bPe extends E$e { constructor(e, t, n, r) { super(e), this.model = t, this.name = n, this.data = r; for (const e of QAe) { const n = t.facet[e]; if (n) { const { bin: r, sort: i } = n; this[e] = Object.assign({ name: t.getName(`${e}_domain`), fields: [iMe(n), ...nEe(r) ? [iMe(n, { binSuffix: "end" })] : []] }, $Ie(i) ? { sortField: i } : b_e(i) ? { sortIndexField: cze(n, e) } : {}) } } this.childModel = t.child } hash() { let e = "Facet"; for (const t of QAe) this[t] && (e += ` ${t.charAt(0)}:${X_e(this[t])}`); return e } get fields() { var e; const t = []; for (const n of QAe) (null === (e = this[n]) || void 0 === e ? void 0 : e.fields) && t.push(...this[n].fields); return t } dependentFields() { const e = new Set(this.fields); for (const t of QAe) this[t] && (this[t].sortField && e.add(this[t].sortField.field), this[t].sortIndexField && e.add(this[t].sortIndexField)); return e } producedFields() { return new Set } getSource() { return this.name } getChildIndependentFieldsWithStep() { const e = {}; for (const t of FTe) { const n = this.childModel.component.scales[t]; if (n && !n.merged) { const r = n.get("type"), i = n.get("range"); if (YNe(r) && tNe(i)) { const n = nBe(rBe(this.childModel, t)); n ? e[t] = n : zEe(`Unknown field for ${t}. Cannot calculate view size.`) } } } return e } assembleRowColumnHeaderData(e, t, n) { const r = { row: "y", column: "x" }[e], i = [], a = [], o = []; n && n[r] && (t ? (i.push(`distinct_${n[r]}`), a.push("max")) : (i.push(n[r]), a.push("distinct")), o.push(`distinct_${n[r]}`)); const { sortField: s, sortIndexField: u } = this[e]; if (s) { const { op: e = IIe, field: t } = s; i.push(t), a.push(e), o.push(iMe(s, { forAs: !0 })) } else u && (i.push(u), a.push("max"), o.push(u)); return { name: this[e].name, source: null != t ? t : this.data, transform: [Object.assign({ type: "aggregate", groupby: this[e].fields }, i.length ? { fields: i, ops: a, as: o } : {})] } } assembleFacetHeaderData(e) { var t, n; const { columns: r } = this.model.layout, { layoutHeaders: i } = this.model.component, a = [], o = {}; for (const e of pze) { for (const r of mze) { const a = null !== (t = i[e] && i[e][r]) && void 0 !== t ? t : []; for (const t of a) if ((null === (n = t.axes) || void 0 === n ? void 0 : n.length) > 0) { o[e] = !0; break } } if (o[e]) { const t = `length(data("${this.facet.name}"))`, n = "row" === e ? r ? { signal: `ceil(${t} / ${r})` } : 1 : r ? { signal: `min(${t}, ${r})` } : { signal: t }; a.push({ name: `${this.facet.name}_${e}`, transform: [{ type: "sequence", start: 0, stop: n }] }) } } const { row: s, column: u } = o; return (s || u) && a.unshift(this.assembleRowColumnHeaderData("facet", null, e)), a } assemble() { var e, t; const n = []; let r = null; const i = this.getChildIndependentFieldsWithStep(), { column: a, row: o, facet: s } = this; if (a && o && (i.x || i.y)) { r = `cross_${this.column.name}_${this.row.name}`; const a = [].concat(null !== (e = i.x) && void 0 !== e ? e : [], null !== (t = i.y) && void 0 !== t ? t : []), o = a.map((() => "distinct")); n.push({ name: r, source: this.data, transform: [{ type: "aggregate", groupby: this.fields, fields: a, ops: o }] }) } for (const e of [fAe, dAe]) this[e] && n.push(this.assembleRowColumnHeaderData(e, r, i)); if (s) { const e = this.assembleFacetHeaderData(i); e && n.push(...e) } return n } } function vPe(e) { return "'" === e[0] && "'" === e[e.length - 1] || '"' === e[0] && '"' === e[e.length - 1] ? e.slice(1, -1) : e } function xPe(e) { const t = {}; return U_e(e.filter, (e => { var n; if (fNe(e)) { let r = null; oNe(e) ? r = e.equal : hNe(e) ? r = e.range[0] : dNe(e) && (r = (null !== (n = e.oneOf) && void 0 !== n ? n : e.in)[0]), r && (PEe(r) ? t[e.field] = "date" : E_e(r) ? t[e.field] = "number" : N_e(r) && (t[e.field] = "string")), e.timeUnit && (t[e.field] = "date") } })), t } function wPe(e) { const t = {}; function n(e) { var n; wMe(e) ? t[e.field] = "date" : "quantitative" === e.type && (N_e(n = e.aggregate) && Z_e(["min", "max"], n)) ? t[e.field] = "number" : vCe(e.field) > 1 ? e.field in t || (t[e.field] = "flatten") : eMe(e) && $Ie(e.sort) && vCe(e.sort.field) > 1 && (e.sort.field in t || (t[e.sort.field] = "flatten")) } if ((SBe(e) || _Be(e)) && e.forEachFieldDef(((t, r) => { if (JIe(t)) n(t); else { const i = fTe(r), a = e.fieldDef(i); n(Object.assign(Object.assign({}, t), { type: a.type })) } })), SBe(e)) { const { mark: n, markDef: r, encoding: i } = e; if (HCe(n) && !e.encoding.order) { const e = i["horizontal" === r.orient ? "y" : "x"]; HIe(e) && "quantitative" === e.type && !(e.field in t) && (t[e.field] = "number") } } return t } class kPe extends E$e { constructor(e, t) { super(e), this._parse = t } clone() { return new kPe(null, G_e(this._parse)) } hash() { return `Parse ${X_e(this._parse)}` } static makeExplicit(e, t, n) { let r = {}; const i = t.data; return !EDe(i) && i && i.format && i.format.parse && (r = i.format.parse), this.makeWithAncestors(e, r, {}, n) } static makeWithAncestors(e, t, n, r) { for (const e of oCe(n)) { const t = r.getWithExplicit(e); void 0 !== t.value && (t.explicit || t.value === n[e] || "derived" === t.value || "flatten" === n[e] ? delete n[e] : zEe(gEe(e, n[e], t.value))) } for (const e of oCe(t)) { const n = r.get(e); void 0 !== n && (n === t[e] ? delete t[e] : zEe(gEe(e, t[e], n))) } const i = new bDe(t, n); r.copyAll(i); const a = {}; for (const e of oCe(i.combine())) { const t = i.get(e); null !== t && (a[e] = t) } return 0 === oCe(a).length || r.parseNothing ? null : new kPe(e, a) } get parse() { return this._parse } merge(e) { this._parse = Object.assign(Object.assign({}, this._parse), e.parse), e.remove() } assembleFormatParse() { const e = {}; for (const t of oCe(this._parse)) { const n = this._parse[t]; 1 === vCe(t) && (e[t] = n) } return e } producedFields() { return new Set(oCe(this._parse)) } dependentFields() { return new Set(oCe(this._parse)) } assembleTransforms(e = !1) { return oCe(this._parse).filter((t => !e || vCe(t) > 1)).map((e => { const t = function (e, t) { const n = pCe(e); if ("number" === t) return `toNumber(${n})`; if ("boolean" === t) return `toBoolean(${n})`; if ("string" === t) return `toString(${n})`; if ("date" === t) return `toDate(${n})`; if ("flatten" === t) return n; if (0 === t.indexOf("date:")) return `timeParse(${n},'${vPe(t.slice(5, t.length))}')`; if (0 === t.indexOf("utc:")) return `utcParse(${n},'${vPe(t.slice(4, t.length))}')`; return zEe(`Unrecognized parse "${t}".`), null }(e, this._parse[e]); if (!t) return null; return { type: "formula", expr: t, as: bCe(e) } })).filter((e => null !== e)) } } class SPe extends E$e { clone() { return new SPe(null) } constructor(e) { super(e) } dependentFields() { return new Set } producedFields() { return new Set([xFe]) } hash() { return "Identifier" } assemble() { return { type: "identifier", as: xFe } } } class _Pe extends E$e { constructor(e, t) { super(e), this.transform = t } clone() { return new _Pe(null, G_e(this.transform)) } addDimensions(e) { this.transform.groupby = tCe(this.transform.groupby.concat(e), (e => e)) } dependentFields() { const e = new Set; return this.transform.groupby && this.transform.groupby.forEach(e.add, e), this.transform.joinaggregate.map((e => e.field)).filter((e => void 0 !== e)).forEach(e.add, e), e } producedFields() { return new Set(this.transform.joinaggregate.map(this.getDefaultName)) } getDefaultName(e) { var t; return null !== (t = e.as) && void 0 !== t ? t : iMe(e) } hash() { return `JoinAggregateTransform ${X_e(this.transform)}` } assemble() { const e = [], t = [], n = []; for (const r of this.transform.joinaggregate) t.push(r.op), n.push(this.getDefaultName(r)), e.push(void 0 === r.field ? null : r.field); const r = this.transform.groupby; return Object.assign({ type: "joinaggregate", as: n, ops: t, fields: e }, void 0 !== r ? { groupby: r } : {}) } } class CPe extends E$e { constructor(e, t) { super(e), this._stack = t } clone() { return new CPe(null, G_e(this._stack)) } static makeFromTransform(e, t) { const { stack: n, groupby: r, as: i, offset: a = "zero" } = t, o = [], s = []; if (void 0 !== t.sort) for (const e of t.sort) o.push(e.field), s.push(xCe(e.order, "ascending")); const u = { field: o, order: s }; let l; return l = function (e) { return b_e(e) && e.every((e => N_e(e))) && e.length > 1 }(i) ? i : N_e(i) ? [i, i + "_end"] : [t.stack + "_start", t.stack + "_end"], new CPe(e, { stackField: n, groupby: r, offset: a, sort: u, facetby: [], as: l }) } static makeFromEncoding(e, t) { const n = t.stack, { encoding: r } = t; if (!n) return null; const { groupbyChannel: i, fieldChannel: a, offset: o, impute: s } = n; let u; if (i) { u = pMe(r[i]) } const l = function (e) { return e.stack.stackBy.reduce(((e, t) => { const n = iMe(t.fieldDef); return n && e.push(n), e }), []) }(t), c = t.encoding.order; let h; return h = b_e(c) || HIe(c) ? RMe(c) : l.reduce(((e, t) => (e.field.push(t), e.order.push("y" === a ? "descending" : "ascending"), e)), { field: [], order: [] }), new CPe(e, { dimensionFieldDef: u, stackField: t.vgField(a), facetby: [], stackby: l, sort: h, offset: o, impute: s, as: [t.vgField(a, { suffix: "start", forAs: !0 }), t.vgField(a, { suffix: "end", forAs: !0 })] }) } get stack() { return this._stack } addDimensions(e) { this._stack.facetby.push(...e) } dependentFields() { const e = new Set; return e.add(this._stack.stackField), this.getGroupbyFields().forEach(e.add, e), this._stack.facetby.forEach(e.add, e), this._stack.sort.field.forEach(e.add, e), e } producedFields() { return new Set(this._stack.as) } hash() { return `Stack ${X_e(this._stack)}` } getGroupbyFields() { const { dimensionFieldDef: e, impute: t, groupby: n } = this._stack; return e ? e.bin ? t ? [iMe(e, { binSuffix: "mid" })] : [iMe(e, {}), iMe(e, { binSuffix: "end" })] : [iMe(e)] : null != n ? n : [] } assemble() { const e = [], { facetby: t, dimensionFieldDef: n, stackField: r, stackby: i, sort: a, offset: o, impute: s, as: u } = this._stack; if (s && n) { const { band: a = .5, bin: o } = n; o && e.push({ type: "formula", expr: `${a}*` + iMe(n, { expr: "datum" }) + `+${1 - a}*` + iMe(n, { expr: "datum", binSuffix: "end" }), as: iMe(n, { binSuffix: "mid", forAs: !0 }) }), e.push({ type: "impute", field: r, groupby: [...i, ...t], key: iMe(n, { binSuffix: "mid" }), method: "value", value: 0 }) } return e.push({ type: "stack", groupby: [...this.getGroupbyFields(), ...t], field: r, sort: a, as: u, offset: o }), e } } class APe extends E$e { constructor(e, t) { super(e), this.transform = t } clone() { return new APe(null, G_e(this.transform)) } addDimensions(e) { this.transform.groupby = tCe(this.transform.groupby.concat(e), (e => e)) } dependentFields() { var e, t; const n = new Set; return (null !== (e = this.transform.groupby) && void 0 !== e ? e : []).forEach(n.add, n), (null !== (t = this.transform.sort) && void 0 !== t ? t : []).forEach((e => n.add(e.field))), this.transform.window.map((e => e.field)).filter((e => void 0 !== e)).forEach(n.add, n), n } producedFields() { return new Set(this.transform.window.map(this.getDefaultName)) } getDefaultName(e) { var t; return null !== (t = e.as) && void 0 !== t ? t : iMe(e) } hash() { return `WindowTransform ${X_e(this.transform)}` } assemble() { var e; const t = [], n = [], r = [], i = []; for (const e of this.transform.window) n.push(e.op), r.push(this.getDefaultName(e)), i.push(void 0 === e.param ? null : e.param), t.push(void 0 === e.field ? null : e.field); const a = this.transform.frame, o = this.transform.groupby; if (a && null === a[0] && null === a[1] && n.every((e => sAe(e)))) return Object.assign({ type: "joinaggregate", as: r, ops: n, fields: t }, void 0 !== o ? { groupby: o } : {}); const s = [], u = []; if (void 0 !== this.transform.sort) for (const t of this.transform.sort) s.push(t.field), u.push(null !== (e = t.order) && void 0 !== e ? e : "ascending"); const l = { field: s, order: u }, c = this.transform.ignorePeers; return Object.assign(Object.assign(Object.assign({ type: "window", params: i, as: r, ops: n, fields: t, sort: l }, void 0 !== c ? { ignorePeers: c } : {}), void 0 !== o ? { groupby: o } : {}), void 0 !== a ? { frame: a } : {}) } } class TPe extends pPe { run(e) { const t = e.parent; if (e instanceof kPe) { if (dPe(t)) return this.flags; if (t.numChildren() > 1) return this.setContinue(), this.flags; if (t instanceof kPe) this.setMutated(), t.merge(e); else { if (iCe(t.producedFields(), e.dependentFields())) return this.setContinue(), this.flags; this.setMutated(), e.swapWithParent() } } return this.setContinue(), this.flags } } class EPe extends mPe { mergeNodes(e, t) { const n = t.shift(); for (const r of t) e.removeChild(r), r.parent = n, r.remove() } run(e) { const t = e.children.map((e => e.hash())), n = {}; for (let r = 0; r < t.length; r++)void 0 === n[t[r]] ? n[t[r]] = [e.children[r]] : n[t[r]].push(e.children[r]); for (const t of oCe(n)) n[t].length > 1 && (this.setMutated(), this.mergeNodes(e, n[t])); for (const t of e.children) this.run(t); return this.mutatedFlag } } class NPe extends pPe { run(e) { return e instanceof N$e || e.numChildren() > 0 || e instanceof bPe || (this.setMutated(), e.remove()), this.flags } } class IPe extends pPe { constructor() { super(...arguments), this.fields = new Set, this.prev = null } run(e) { if (this.setContinue(), e instanceof I$e) { const t = e.producedFields(); nCe(t, this.fields) ? (this.setMutated(), this.prev.remove()) : this.fields = new Set([...this.fields, ...t]), this.prev = e } return this.flags } reset() { this.fields.clear() } } class MPe extends pPe { run(e) { this.setContinue(); const t = e.parent.children.filter((e => e instanceof I$e)), n = t.pop(); for (const e of t) this.setMutated(), n.merge(e); return this.flags } } function FPe(e) { if (e instanceof bPe) if (1 !== e.numChildren() || e.children[0] instanceof N$e) { const n = e.model.component.data.main; DPe(n); const r = (t = e, function e(n) { if (!(n instanceof bPe)) { const r = n.clone(); if (r instanceof N$e) { const e = LPe + r.getSource(); r.setSource(e), t.model.component.data.outputNodes[e] = r } else (r instanceof yPe || r instanceof CPe || r instanceof APe || r instanceof _Pe) && r.addDimensions(t.fields); for (const t of n.children.flatMap(e)) t.parent = r; return [r] } return n.children.flatMap(e) }), i = e.children.map(r).flat(); for (const e of i) e.parent = n } else { const t = e.children[0]; (t instanceof yPe || t instanceof CPe || t instanceof APe || t instanceof _Pe) && t.addDimensions(e.fields), t.swapWithParent(), FPe(e) } else e.children.map(FPe); var t } function DPe(e) { if (e instanceof N$e && e.type === FDe && 1 === e.numChildren()) { const t = e.children[0]; t instanceof bPe || (t.swapWithParent(), DPe(e)) } } class $Pe extends mPe { constructor() { super() } run(e) { e instanceof N$e && !e.isRequired() && (this.setMutated(), e.remove()); for (const t of e.children) this.run(t); return this.mutatedFlag } } class RPe extends mPe { constructor(e) { super(), this.requiresSelectionId = e && yRe(e) } run(e) { e instanceof SPe && (this.requiresSelectionId && (dPe(e.parent) || e.parent instanceof yPe || e.parent instanceof kPe) || (this.setMutated(), e.remove())); for (const t of e.children) this.run(t); return this.mutatedFlag } } class OPe extends pPe { run(e) { const t = e.parent, n = [...t.children], r = t.children.filter((e => e instanceof kPe)); if (t.numChildren() > 1 && r.length >= 1) { const e = {}, i = new Set; for (const t of r) { const n = t.parse; for (const t of oCe(n)) t in e ? e[t] !== n[t] && i.add(t) : e[t] = n[t] } for (const t of i) delete e[t]; if (!aCe(e)) { this.setMutated(); const r = new kPe(t, e); for (const i of n) { if (i instanceof kPe) for (const t of oCe(e)) delete i.parse[t]; t.removeChild(i), i.parent = r, i instanceof kPe && 0 === oCe(i.parse).length && i.remove() } } } return this.setContinue(), this.flags } } class zPe extends pPe { run(e) { const t = e.parent, n = t.children.filter((e => e instanceof yPe)), r = {}; for (const e of n) { const t = X_e(e.groupBy); t in r || (r[t] = []), r[t].push(e) } for (const e of oCe(r)) { const n = r[e]; if (n.length > 1) { const e = n.pop(); for (const r of n) e.merge(r) && (t.removeChild(r), r.parent = e, r.remove(), this.setMutated()) } } return this.setContinue(), this.flags } } class PPe extends pPe { constructor(e) { super(), this.model = e } run(e) { const t = e.parent, n = !(dPe(t) || t instanceof WOe || t instanceof kPe || t instanceof SPe), r = [], i = []; for (const e of t.children) e instanceof sPe && (n && !iCe(t.producedFields(), e.dependentFields()) ? r.push(e) : i.push(e)); if (r.length > 0) { const e = r.pop(); for (const t of r) e.merge(t, this.model.renameSignal.bind(this.model)); this.setMutated(), t instanceof sPe ? t.merge(e, this.model.renameSignal.bind(this.model)) : e.swapWithParent() } if (i.length > 1) { const e = i.pop(); for (const t of i) e.merge(t, this.model.renameSignal.bind(this.model)); this.setMutated() } return this.setContinue(), this.flags } } class BPe extends pPe { run(e) { const t = e.parent, n = [...t.children]; if (!J_e(n, (e => e instanceof N$e)) || t.numChildren() <= 1) return this.setContinue(), this.flags; const r = []; let i; for (const e of n) if (e instanceof N$e) { let n = e; for (; 1 === n.numChildren();) { const e = n.children[0]; if (!(e instanceof N$e)) break; n = e } r.push(...n.children), i ? (t.removeChild(e), e.parent = i.parent, i.parent.removeChild(i), i.parent = n, this.setMutated()) : i = n } else r.push(e); if (r.length) { this.setMutated(); for (const e of r) e.parent.removeChild(e), e.parent = i } return this.setContinue(), this.flags } } const LPe = "scale_", jPe = 5; function UPe(e) { const t = []; function n(e) { if (0 === e.numChildren()) t.push(e); else for (const t of e.children) n(t) } for (const t of e) n(t); return t } function WPe(e) { return e } function VPe(e, t) { return t.map((t => { if (e instanceof pPe) { const n = e.optimizeNextFromLeaves(t); return e.reset(), n } return e.run(t) })).some(WPe) } function GPe(e, t) { let n = e.sources; const r = new Set; return r.add(VPe(new $Pe, n)), r.add(VPe(new RPe(t), n)), n = n.filter((e => e.numChildren() > 0)), r.add(VPe(new NPe, UPe(n))), n = n.filter((e => e.numChildren() > 0)), r.add(VPe(new TPe, UPe(n))), r.add(VPe(new PPe(t), UPe(n))), r.add(VPe(new IPe, UPe(n))), r.add(VPe(new OPe, UPe(n))), r.add(VPe(new zPe, UPe(n))), r.add(VPe(new MPe, UPe(n))), r.add(VPe(new EPe, n)), r.add(VPe(new BPe, UPe(n))), e.sources = n, r.has(!0) } class HPe { constructor(e) { Object.defineProperty(this, "signal", { enumerable: !0, get: e }) } static fromName(e, t) { return new HPe((() => e(t))) } } function qPe(e) { SBe(e) ? function (e) { const t = e.component.scales; for (const n of oCe(t)) { const r = YPe(e, n); if (t[n].setWithExplicit("domains", r), JPe(e, n), e.component.data.isFaceted) { let t = e; for (; !_Be(t) && t.parent;)t = t.parent; if ("shared" === t.component.resolve.scale[n]) for (const e of r.value) nNe(e) && (e.data = LPe + e.data.replace(LPe, "")) } } }(e) : function (e) { for (const t of e.children) qPe(t); const t = e.component.scales; for (const n of oCe(t)) { let r, i = null; for (const t of e.children) { const e = t.component.scales[n]; if (e) { r = void 0 === r ? e.getWithExplicit("domains") : SDe(r, e.getWithExplicit("domains"), "domains", "scale", eBe); const t = e.get("selectionExtent"); i && t && i.selection !== t.selection && zEe("The same selection must be used to override scale domains in a layered view."), i = t } } t[n].setWithExplicit("domains", r), i && t[n].set("selectionExtent", i, !0) } }(e) } function YPe(e, t) { const n = e.getScaleComponent(t).get("type"), { encoding: r } = e, i = function (e, t, n, r) { if ("unaggregated" === e) { const { valid: e, reason: r } = QPe(t, n); if (!e) return void zEe(r) } else if (void 0 === e && r.useUnaggregatedDomain) { const { valid: e } = QPe(t, n); if (e) return "unaggregated" } return e }(e.scaleDomain(t), e.typedFieldDef(t), n, e.config.scale); return i !== e.scaleDomain(t) && (e.specifiedScales[t] = Object.assign(Object.assign({}, e.specifiedScales[t]), { domain: i })), "x" === t && mMe(r.x2) ? mMe(r.x) ? SDe(KPe(n, i, e, "x"), KPe(n, i, e, "x2"), "domain", "scale", eBe) : KPe(n, i, e, "x2") : "y" === t && mMe(r.y2) ? mMe(r.y) ? SDe(KPe(n, i, e, "y"), KPe(n, i, e, "y2"), "domain", "scale", eBe) : KPe(n, i, e, "y2") : KPe(n, i, e, t) } function XPe(e, t, n) { var r; const i = null === (r = QEe(n)) || void 0 === r ? void 0 : r.unit; return "temporal" === t || i ? function (e, t, n) { return e.map((e => ({ signal: `{data: ${kMe(e, { timeUnit: n, type: t })}}` }))) }(e, t, i) : [e] } function KPe(e, t, n, r) { const { encoding: i } = n, a = mMe(i[r]), { type: o } = a, s = a.timeUnit; if (function (e) { return e && e.unionWith }(t)) { const i = KPe(e, void 0, n, r), a = XPe(t.unionWith, o, s); return vDe([...i.value, ...a]) } if (eNe(t)) return vDe([t]); if (t && "unaggregated" !== t && !JNe(t)) return vDe(XPe(t, o, s)); const u = n.stack; if (u && r === u.fieldChannel) { if ("normalize" === u.offset) return xDe([[0, 1]]); const e = n.requestDataName(FDe); return xDe([{ data: e, field: n.vgField(r, { suffix: "start" }) }, { data: e, field: n.vgField(r, { suffix: "end" }) }]) } const l = XTe(r) && HIe(a) ? function (e, t, n) { if (!YNe(n)) return; const r = e.fieldDef(t), i = r.sort; if (RIe(i)) return { op: "min", field: cze(r, t), order: "ascending" }; const { stack: a } = e, o = a ? [...a.groupbyField ? [a.groupbyField] : [], ...a.stackBy.map((e => e.fieldDef.field))] : void 0; if ($Ie(i)) { return ZPe(i, a && !Z_e(o, i.field)) } if (DIe(i)) { const { encoding: t, order: n } = i, r = e.fieldDef(t), { aggregate: s, field: u } = r, l = a && !Z_e(o, u); if (aAe(s) || oAe(s)) return ZPe({ field: iMe(r), order: n }, l); if (sAe(s) || !s) return ZPe({ op: s, field: u, order: n }, l) } else { if ("descending" === i) return { op: "min", field: e.vgField(t), order: "descending" }; if (Z_e(["ascending", void 0], i)) return !0 } return }(n, r, e) : void 0; if (YIe(a)) { return xDe(XPe([a.datum], o, s)) } const c = a; if ("unaggregated" === t) { const e = n.requestDataName(FDe), { field: t } = a; return xDe([{ data: e, field: iMe({ field: t, aggregate: "min" }) }, { data: e, field: iMe({ field: t, aggregate: "max" }) }]) } if (nEe(c.bin)) { if (YNe(e)) return xDe("bin-ordinal" === e ? [] : [{ data: lCe(l) ? n.requestDataName(FDe) : n.requestDataName(DDe), field: n.vgField(r, _Me(c, r) ? { binSuffix: "range" } : {}), sort: !0 !== l && v_e(l) ? l : { field: n.vgField(r, {}), op: "min" } }]); { const { bin: e } = c; if (nEe(e)) { const t = aPe(n, c.field, e); return xDe([new HPe((() => { const e = n.getSignalName(t); return `[${e}.start, ${e}.stop]` }))]) } return xDe([{ data: n.requestDataName(FDe), field: n.vgField(r, {}) }]) } } if (c.timeUnit && Z_e(["time", "utc"], e) && UIe(r, c, SBe(n) ? n.encoding[mTe(r)] : void 0, n.stack, n.markDef, n.config)) { const e = n.requestDataName(FDe); return xDe([{ data: e, field: n.vgField(r) }, { data: e, field: n.vgField(r, { suffix: "end" }) }]) } return xDe(l ? [{ data: lCe(l) ? n.requestDataName(FDe) : n.requestDataName(DDe), field: n.vgField(r), sort: l }] : [{ data: n.requestDataName(FDe), field: n.vgField(r) }]) } function ZPe(e, t) { const { op: n, field: r, order: i } = e; return Object.assign(Object.assign({ op: null != n ? n : t ? "sum" : IIe }, r ? { field: gCe(r) } : {}), i ? { order: i } : {}) } function JPe(e, t) { var n; const r = e.component.scales[t], i = e.specifiedScales[t].domain, a = null === (n = e.fieldDef(t)) || void 0 === n ? void 0 : n.bin, o = JNe(i) && i, s = iEe(a) && aEe(a.extent) && a.extent; (o || s) && r.set("selectionExtent", null != o ? o : s, !0) } function QPe(e, t) { const { aggregate: n, type: r } = e; return n ? N_e(n) && !hAe[n] ? { valid: !1, reason: AEe(n) } : "quantitative" === r && "log" === t ? { valid: !1, reason: TEe(e) } : { valid: !0 } : { valid: !1, reason: CEe(e) } } function eBe(e, t, n, r) { return e.explicit && t.explicit && zEe(function (e, t, n, r) { return `Conflicting ${t.toString()} property "${e.toString()}" (${Y_e(n)} and ${Y_e(r)}). Using the union of the two domains.` }(n, r, e.value, t.value)), { explicit: e.explicit, value: [...e.value, ...t.value] } } function tBe(e) { const t = tCe(e.map((e => { if (nNe(e)) { const { sort: t } = e; return F_e(e, ["sort"]) } return e })), X_e), n = tCe(e.map((e => { if (nNe(e)) { const t = e.sort; return void 0 === t || lCe(t) || ("op" in t && "count" === t.op && delete t.field, "ascending" === t.order && delete t.order), t } })).filter((e => void 0 !== e)), X_e); if (0 === t.length) return; if (1 === t.length) { const t = e[0]; if (nNe(t) && n.length > 0) { let e = n[0]; if (n.length > 1) zEe(IEe), e = !0; else if (v_e(e) && "field" in e) { const n = e.field; t.field === n && (e = !e.order || { order: e.order }) } return Object.assign(Object.assign({}, t), { sort: e }) } return t } const r = tCe(n.map((e => lCe(e) || !("op" in e) || e.op in iAe ? e : (zEe(function (e) { return `Dropping sort property ${Y_e(e)} as unioned domains only support boolean or op "count", "min", and "max".` }(e)), !0))), X_e); let i; 1 === r.length ? i = r[0] : r.length > 1 && (zEe(IEe), i = !0); const a = tCe(e.map((e => nNe(e) ? e.data : null)), (e => e)); if (1 === a.length && null !== a[0]) { return Object.assign({ data: a[0], fields: t.map((e => e.field)) }, i ? { sort: i } : {}) } return Object.assign({ fields: t }, i ? { sort: i } : {}) } function nBe(e) { if (nNe(e) && N_e(e.field)) return e.field; if (function (e) { return !b_e(e) && "fields" in e && !("data" in e) }(e)) { let t; for (const n of e.fields) if (nNe(n) && N_e(n.field)) if (t) { if (t !== n.field) return zEe("Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect."), t } else t = n.field; return zEe("Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect."), t } if (function (e) { return !b_e(e) && "fields" in e && "data" in e }(e)) { zEe("Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect."); const t = e.fields[0]; return N_e(t) ? t : void 0 } } function rBe(e, t) { const n = e.component.scales[t].get("domains").map((t => (nNe(t) && (t.data = e.lookupDataSource(t.data)), t))); return tBe(n) } function iBe(e) { return ABe(e) || CBe(e) ? e.children.reduce(((e, t) => e.concat(iBe(t))), aBe(e)) : aBe(e) } function aBe(e) { return oCe(e.component.scales).reduce(((t, n) => { const r = e.component.scales[n]; if (r.merged) return t; const i = r.combine(), { name: a, type: o, selectionExtent: s, domains: u, range: l, reverse: c } = i, h = F_e(i, ["name", "type", "selectionExtent", "domains", "range", "reverse"]), d = function (e, t, n) { if (DTe(n) && tNe(e)) return { step: { signal: t + "_step" } }; return e }(i.range, a, n); let f; s && (f = function (e, t) { const n = t.selection; return { signal: GOe(e.getSelectionComponent(n, cCe(n)), t) } }(e, s)); const p = rBe(e, n); return t.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name: a, type: o }, p ? { domain: p } : {}), f ? { domainRaw: f } : {}), { range: d }), void 0 !== c ? { reverse: c } : {}), h)), t }), []) } class oBe extends bDe { constructor(e, t) { super({}, { name: e }), this.merged = !1, this.setWithExplicit("type", t) } domainDefinitelyIncludesZero() { return !1 !== this.get("zero") || J_e(this.get("domains"), (e => b_e(e) && 2 === e.length && e[0] <= 0 && e[1] >= 0)) } } const sBe = ["range", "scheme"]; function uBe(e) { return "x" === e ? "width" : "y" === e ? "height" : void 0 } function lBe(e, t) { const n = e.fieldDef(t); if (n && n.bin && nEe(n.bin)) { const r = aPe(e, n.field, n.bin), i = uBe(t), a = e.getName(i); return new HPe((() => { const t = e.getSignalName(r), n = `(${t}.stop - ${t}.start) / ${t}.step`; return `${e.getSignalName(a)} / (${n})` })) } } function cBe(e, t) { const n = t.specifiedScales[e], { size: r } = t, i = t.getScaleComponent(e).get("type"); for (const r of sBe) if (void 0 !== n[r]) { const a = oIe(i, r), o = sIe(e, r); if (a) if (o) zEe(o); else switch (r) { case "range": return b_e(n.range) && DTe(e) ? vDe(n.range.map((e => { if ("width" === e || "height" === e) { const n = t.getName(e), r = t.getSignalName.bind(t); return HPe.fromName(r, n) } return e }))) : vDe(n.range); case "scheme": return vDe(hBe(n[r])) } else zEe(EEe(i, r, e)) } if (e === mAe || e === gAe) { const t = e === mAe ? "width" : "height", n = r[t]; if (TFe(n)) { if (YNe(i)) return vDe({ step: n.step }); zEe(NEe(t)) } } return xDe(function (e, t) { const { size: n, config: r, mark: i, encoding: a } = t, o = t.getSignalName.bind(t), { type: s } = mMe(a[e]), u = t.getScaleComponent(e), l = u.get("type"), { domain: c, domainMid: h } = t.specifiedScales[e]; switch (e) { case mAe: case gAe: { if (Z_e(["point", "band"], l)) if (e !== mAe || n.width) { if (e === gAe && !n.height) { const e = FFe(r.view, "height"); if (TFe(e)) return e } } else { const e = FFe(r.view, "width"); if (TFe(e)) return e } const i = uBe(e), a = t.getName(i); return e === gAe && XNe(l) ? [HPe.fromName(o, a), 0] : [0, HPe.fromName(o, a)] } case MAe: { const a = dBe(i, t.component.scales[e].get("zero"), r), o = function (e, t, n, r) { const i = { x: lBe(n, "x"), y: lBe(n, "y") }; switch (e) { case "bar": case "tick": { if (void 0 !== r.scale.maxBandSize) return r.scale.maxBandSize; const e = pBe(t, i, r.view); return E_e(e) ? e - 1 : new HPe((() => `${e.signal} - 1`)) } case "line": case "trail": case "rule": return r.scale.maxStrokeWidth; case "text": return r.scale.maxFontSize; case "point": case "square": case "circle": { if (r.scale.maxSize) return r.scale.maxSize; const e = pBe(t, i, r.view); return E_e(e) ? Math.pow(fBe * e, 2) : new HPe((() => `pow(${fBe} * ${e.signal}, 2)`)) } }throw new Error(kEe("size", e)) }(i, n, t, r); return ZNe(l) ? function (e, t, n) { const r = () => { const r = NMe(t), i = NMe(e), a = `(${r} - ${i}) / (${n} - 1)`; return `sequence(${i}, ${r} + ${a}, ${a})` }; return eNe(t) ? new HPe(r) : { signal: r() } }(a, o, function (e, t, n, r) { switch (e) { case "quantile": return t.scale.quantileCount; case "quantize": return t.scale.quantizeCount; case "threshold": return void 0 !== n && b_e(n) ? n.length + 1 : (zEe(function (e) { return `Domain for ${e} is required for threshold scale.` }(r)), 3) } }(l, r, c, e)) : [a, o] } case wAe: return [0, 2 * Math.PI]; case FAe: return [0, 360]; case vAe: return [0, new HPe((() => `min(${t.getSignalName("width")},${t.getSignalName("height")})/2`))]; case OAe: return [r.scale.minStrokeWidth, r.scale.maxStrokeWidth]; case zAe: return [[1, 0], [4, 2], [2, 1], [1, 1], [1, 2, 4, 2]]; case IAe: return "symbol"; case TAe: case EAe: case NAe: return "ordinal" === l ? "nominal" === s ? "category" : "ordinal" : void 0 !== h ? "diverging" : "rect" === i || "geoshape" === i ? "heatmap" : "ramp"; case DAe: case $Ae: case RAe: return [r.scale.minOpacity, r.scale.maxOpacity] }throw new Error(`Scale range undefined for channel ${e}`) }(e, t)) } function hBe(e) { return function (e) { return !N_e(e) && !!e.name }(e) ? Object.assign({ scheme: e.name }, q_e(e, ["name"])) : { scheme: e } } function dBe(e, t, n) { if (t) return eNe(t) ? { signal: `${t.signal} ? 0 : ${dBe(e, !1, n)}` } : 0; switch (e) { case "bar": case "tick": return n.scale.minBandSize; case "line": case "trail": case "rule": return n.scale.minStrokeWidth; case "text": return n.scale.minFontSize; case "point": case "square": case "circle": return n.scale.minSize }throw new Error(kEe("size", e)) } const fBe = .95; function pBe(e, t, n) { const r = TFe(e.width) ? e.width.step : MFe(n, "width"), i = TFe(e.height) ? e.height.step : MFe(n, "height"); return t.x || t.y ? new HPe((() => `min(${[t.x ? t.x.signal : r, t.y ? t.y.signal : i].join(", ")})`)) : Math.min(r, i) } function mBe(e, t) { SBe(e) ? function (e, t) { const n = e.component.scales, { config: r, encoding: i, markDef: a, specifiedScales: o } = e; for (const s of oCe(n)) { const u = o[s], l = n[s], c = e.getScaleComponent(s), h = mMe(i[s]), d = u[t], f = c.get("type"), p = c.get("padding"), m = c.get("paddingInner"), g = oIe(f, t), y = sIe(s, t); if (void 0 !== d && (g ? y && zEe(y) : zEe(EEe(f, t, s))), g && void 0 === y) if (void 0 !== d) l.copyKeyFromObject(t, u); else { const n = t in gBe ? gBe[t]({ model: e, channel: s, fieldOrDatumDef: h, scaleType: f, scalePadding: p, scalePaddingInner: m, domain: u.domain, markDef: a, config: r }) : r.scale[t]; void 0 !== n && l.set(t, n, !1) } } }(e, t) : bBe(e, t) } const gBe = { bins: ({ model: e, fieldOrDatumDef: t }) => HIe(t) ? function (e, t) { const n = t.bin; if (nEe(n)) { const r = aPe(e, t.field, n); return new HPe((() => e.getSignalName(r))) } if (rEe(n) && iEe(n) && void 0 !== n.step) return { step: n.step }; return }(e, t) : void 0, interpolate: ({ channel: e, fieldOrDatumDef: t }) => function (e, t) { if (Z_e([TAe, EAe, NAe], e) && "nominal" !== t) return "hcl"; return }(e, t.type), nice: ({ scaleType: e, channel: t, fieldOrDatumDef: n }) => function (e, t, n) { var r; if ((null === (r = pMe(n)) || void 0 === r ? void 0 : r.bin) || Z_e([INe, MNe], e)) return; return t in MTe || void 0 }(e, t, n), padding: ({ channel: e, scaleType: t, fieldOrDatumDef: n, markDef: r, config: i }) => function (e, t, n, r, i, a) { if (e in MTe) { if (KNe(t)) { if (void 0 !== n.continuousPadding) return n.continuousPadding; const { type: t, orient: o } = i; if ("bar" === t && (!HIe(r) || !r.bin && !r.timeUnit) && ("vertical" === o && "x" === e || "horizontal" === o && "y" === e)) return a.continuousBandSize } if (t === RNe) return n.pointPadding } return }(e, t, i.scale, n, r, i.bar), paddingInner: ({ scalePadding: e, channel: t, markDef: n, config: r }) => function (e, t, n, r) { if (void 0 !== e) return; if (t in MTe) { const { bandPaddingInner: e, barBandPaddingInner: t, rectBandPaddingInner: i } = r; return xCe(e, "bar" === n ? t : i) } return }(e, t, n.type, r.scale), paddingOuter: ({ scalePadding: e, channel: t, scaleType: n, markDef: r, scalePaddingInner: i, config: a }) => function (e, t, n, r, i, a) { if (void 0 !== e) return; if (t in MTe && n === ONe) { const { bandPaddingOuter: e } = a; return xCe(e, eNe(i) ? { signal: `${i.signal}/2` } : i / 2) } return }(e, t, n, r.type, i, a.scale), reverse: ({ fieldOrDatumDef: e, scaleType: t, channel: n, config: r }) => function (e, t, n, r) { if ("x" === n && void 0 !== r.xReverse) return XNe(e) && "descending" === t ? eNe(r.xReverse) ? { signal: `!${r.xReverse.signal}` } : !r.xReverse : r.xReverse; if (XNe(e) && "descending" === t) return !0; return }(t, HIe(e) ? e.sort : void 0, n, r.scale), zero: ({ channel: e, fieldOrDatumDef: t, domain: n, markDef: r, scaleType: i }) => function (e, t, n, r, i) { if (n && "unaggregated" !== n && XNe(i)) { if (b_e(n)) { const e = n[0], t = n[n.length - 1]; if (e <= 0 && t >= 0) return !0 } return !1 } if ("size" === e && "quantitative" === t.type && !ZNe(i)) return !0; if ((!HIe(t) || !t.bin) && Z_e([...FTe, ...RTe], e)) { const { orient: t, type: n } = r; return !Z_e(["bar", "area", "line", "trail"], n) || !("horizontal" === t && "y" === e || "vertical" === t && "x" === e) } return !1 }(e, t, n, r, i) }; function yBe(e) { SBe(e) ? function (e) { const t = e.component.scales; for (const n of YTe) { const r = t[n]; if (!r) continue; const i = cBe(n, e); r.setWithExplicit("range", i) } }(e) : bBe(e, "range") } function bBe(e, t) { const n = e.component.scales; for (const n of e.children) "range" === t ? yBe(n) : mBe(n, t); for (const r of oCe(n)) { let i; for (const n of e.children) { const e = n.component.scales[r]; if (e) { i = SDe(i, e.getWithExplicit(t), t, "scale", wDe(((e, n) => "range" === t && e.step && n.step ? e.step - n.step : 0))) } } n[r].setWithExplicit(t, i) } } function vBe(e, t, n, r) { const i = function (e, t, n) { var r; switch (t.type) { case "nominal": case "ordinal": if (ZAe(e) || "discrete" === eEe(e)) return "shape" === e && "ordinal" === t.type && zEe(_Ee(e, "ordinal")), "ordinal"; if (e in MTe) { if (Z_e(["rect", "bar", "image", "rule"], n)) return "band" } else if ("arc" === n && e in $Te) return "band"; return void 0 !== t.band || tMe(t) && (null === (r = t.axis) || void 0 === r ? void 0 : r.tickBand) ? "band" : "point"; case "temporal": return ZAe(e) ? "time" : "discrete" === eEe(e) ? (zEe(_Ee(e, "temporal")), "ordinal") : HIe(t) && t.timeUnit && QEe(t.timeUnit).utc ? "utc" : "time"; case "quantitative": return ZAe(e) ? HIe(t) && nEe(t.bin) ? "bin-ordinal" : "linear" : "discrete" === eEe(e) ? (zEe(_Ee(e, "quantitative")), "ordinal") : "linear"; case "geojson": return }throw new Error(vEe(t.type)) }(t, n, r), { type: a } = e; return XTe(t) ? void 0 !== a ? lIe(t, a) ? HIe(n) && !uIe(a, n.type) ? (zEe(function (e, t) { return `FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.` }(a, i)), i) : a : (zEe(function (e, t, n) { return `Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.` }(t, a, i)), i) : i : null } function xBe(e) { SBe(e) ? e.component.scales = function (e) { const { encoding: t, mark: n } = e; return YTe.reduce(((r, i) => { const a = mMe(t[i]); if (a && n === GCe && i === IAe && a.type === SNe) return r; let o = a && a.scale; if (a && null !== o && !1 !== o) { o = null != o ? o : {}; const t = vBe(o, i, a, n); r[i] = new oBe(e.scaleName(i + "", !0), { value: t, explicit: o.type === t }) } return r }), {}) }(e) : e.component.scales = function (e) { var t; const n = e.component.scales = {}, r = {}, i = e.component.resolve; for (const n of e.children) { xBe(n); for (const a of oCe(n.component.scales)) if (i.scale[a] = null !== (t = i.scale[a]) && void 0 !== t ? t : Fze(a, e), "shared" === i.scale[a]) { const e = r[a], t = n.component.scales[a].getWithExplicit("type"); e ? BNe(e.value, t.value) ? r[a] = SDe(e, t, "type", "scale", wBe) : (i.scale[a] = "independent", delete r[a]) : r[a] = t } } for (const t of oCe(r)) { const i = e.scaleName(t, !0), a = r[t]; n[t] = new oBe(i, a); for (const n of e.children) { const e = n.component.scales[t]; e && (n.renameScale(e.get("name"), i), e.merged = !0) } } return n }(e) } const wBe = wDe(((e, t) => jNe(e) - jNe(t))); class kBe { constructor() { this.nameMap = {} } rename(e, t) { this.nameMap[e] = t } has(e) { return void 0 !== this.nameMap[e] } get(e) { for (; this.nameMap[e] && e !== this.nameMap[e];)e = this.nameMap[e]; return e } } function SBe(e) { return "unit" === (null == e ? void 0 : e.type) } function _Be(e) { return "facet" === (null == e ? void 0 : e.type) } function CBe(e) { return "concat" === (null == e ? void 0 : e.type) } function ABe(e) { return "layer" === (null == e ? void 0 : e.type) } class TBe { constructor(e, t, n, r, i, a, o) { var s, u; this.type = t, this.parent = n, this.config = i, this.view = o, this.children = [], this.correctDataNames = e => (e.from && e.from.data && (e.from.data = this.lookupDataSource(e.from.data)), e.from && e.from.facet && e.from.facet.data && (e.from.facet.data = this.lookupDataSource(e.from.facet.data)), e), this.parent = n, this.config = i, this.name = null !== (s = e.name) && void 0 !== s ? s : r, this.title = AMe(e.title) ? { text: e.title } : e.title, this.scaleNameMap = n ? n.scaleNameMap : new kBe, this.projectionNameMap = n ? n.projectionNameMap : new kBe, this.signalNameMap = n ? n.signalNameMap : new kBe, this.data = e.data, this.description = e.description, this.transforms = function (e) { return e.map((e => $De(e) ? { filter: W_e(e.filter, yNe) } : e)) }(null !== (u = e.transform) && void 0 !== u ? u : []), this.layout = "layer" === t || "unit" === t ? {} : function (e, t, n) { var r, i; const a = n[t], o = {}, { spacing: s, columns: u } = a; void 0 !== s && (o.spacing = s), void 0 !== u && (PIe(e) && !OIe(e.facet) || _Fe(e)) && (o.columns = u), CFe(e) && (o.columns = 1); for (const t of NFe) if (void 0 !== e[t]) if ("spacing" === t) { const n = e[t]; o[t] = E_e(n) ? n : { row: null !== (r = n.row) && void 0 !== r ? r : s, column: null !== (i = n.column) && void 0 !== i ? i : s } } else o[t] = e[t]; return o }(e, t, i), this.component = { data: { sources: n ? n.component.data.sources : [], outputNodes: n ? n.component.data.outputNodes : {}, outputNodeRefCounts: n ? n.component.data.outputNodeRefCounts : {}, isFaceted: PIe(e) || n && n.component.data.isFaceted && void 0 === e.data }, layoutSize: new bDe, layoutHeaders: { row: {}, column: {}, facet: {} }, mark: null, resolve: Object.assign({ scale: {}, axis: {}, legend: {} }, a ? G_e(a) : {}), selection: null, scales: null, projection: null, axes: {}, legends: {} } } get width() { return this.getSizeSignalRef("width") } get height() { return this.getSizeSignalRef("height") } parse() { this.parseScale(), this.parseLayoutSize(), this.renameTopLevelLayoutSizeSignal(), this.parseSelections(), this.parseProjection(), this.parseData(), this.parseAxesAndHeaders(), this.parseLegends(), this.parseMarkGroup() } parseScale() { !function (e, { ignoreRange: t } = {}) { xBe(e), qPe(e); for (const t of aIe) mBe(e, t); t || yBe(e) }(this) } parseProjection() { rPe(this) } renameTopLevelLayoutSizeSignal() { "width" !== this.getName("width") && this.renameSignal(this.getName("width"), "width"), "height" !== this.getName("height") && this.renameSignal(this.getName("height"), "height") } parseLegends() { Hze(this) } assembleGroupStyle() { var e, t; if ("unit" === this.type || "layer" === this.type) return null !== (t = null === (e = this.view) || void 0 === e ? void 0 : e.style) && void 0 !== t ? t : "cell" } assembleEncodeFromView(e) { const { style: t } = e, n = F_e(e, ["style"]), r = {}; for (const e of oCe(n)) { const t = n[e]; void 0 !== t && (r[e] = TMe(t)) } return r } assembleGroupEncodeEntry(e) { let t = {}; return this.view && (t = this.assembleEncodeFromView(this.view)), e || (this.description && (t.description = TMe(this.description)), "unit" !== this.type && "layer" !== this.type) ? aCe(t) ? void 0 : t : Object.assign({ width: this.getSizeSignalRef("width"), height: this.getSizeSignalRef("height") }, null != t ? t : {}) } assembleLayout() { if (!this.layout) return; const e = this.layout, { spacing: t } = e, n = F_e(e, ["spacing"]), { component: r, config: i } = this, a = function (e, t) { const n = {}; for (const r of QAe) { const i = e[r]; if (null == i ? void 0 : i.facetFieldDef) { const { titleAnchor: e, titleOrient: a } = fze(["titleAnchor", "titleOrient"], i.facetFieldDef, t, r), o = hze(r, a), s = _ze(e, o); void 0 !== s && (n[o] = s) } } return aCe(n) ? void 0 : n }(r.layoutHeaders, i); return Object.assign(Object.assign(Object.assign({ padding: t }, this.assembleDefaultLayout()), n), a ? { titleBand: a } : {}) } assembleDefaultLayout() { return {} } assembleHeaderMarks() { const { layoutHeaders: e } = this.component; let t = []; for (const n of QAe) e[n].title && t.push(gze(this, n)); for (const e of pze) t = t.concat(vze(this, e)); return t } assembleAxes() { return function (e, t) { const { x: n = [], y: r = [] } = e; return [...n.map((e => YOe(e, "grid", t))), ...r.map((e => YOe(e, "grid", t))), ...n.map((e => YOe(e, "main", t))), ...r.map((e => YOe(e, "main", t)))].filter((e => e)) }(this.component.axes, this.config) } assembleLegends() { return Jze(this) } assembleProjections() { return Qze(this) } assembleTitle() { var e, t, n; const r = null !== (e = this.title) && void 0 !== e ? e : {}, { encoding: i } = r, a = F_e(r, ["encoding"]), o = Object.assign(Object.assign(Object.assign({}, CMe(this.config.title).nonMark), a), i ? { encode: { update: i } } : {}); if (o.text) return Z_e(["unit", "layer"], this.type) ? Z_e(["middle", void 0], o.anchor) && (o.frame = null !== (t = o.frame) && void 0 !== t ? t : "group") : o.anchor = null !== (n = o.anchor) && void 0 !== n ? n : "start", aCe(o) ? void 0 : o } assembleGroup(e = []) { const t = {}; (e = e.concat(this.assembleSignals())).length > 0 && (t.signals = e); const n = this.assembleLayout(); n && (t.layout = n), t.marks = [].concat(this.assembleHeaderMarks(), this.assembleMarks()); const r = !this.parent || _Be(this.parent) ? iBe(this) : []; r.length > 0 && (t.scales = r); const i = this.assembleAxes(); i.length > 0 && (t.axes = i); const a = this.assembleLegends(); return a.length > 0 && (t.legends = a), t } getName(e) { return cCe((this.name ? this.name + "_" : "") + e) } requestDataName(e) { var t; const n = this.getName(e), r = this.component.data.outputNodeRefCounts; return r[n] = (null !== (t = r[n]) && void 0 !== t ? t : 0) + 1, n } getSizeSignalRef(e) { if (_Be(this.parent)) { const t = OTe(Ize(e)), n = this.component.scales[t]; if (n && !n.merged) { const e = n.get("type"), r = n.get("range"); if (YNe(e) && tNe(r)) { const e = n.get("name"), r = nBe(rBe(this, t)); if (r) { return { signal: Nze(e, n, iMe({ aggregate: "distinct", field: r }, { expr: "datum" })) } } return zEe(`Unknown field for ${t}. Cannot calculate view size.`), null } } } return { signal: this.signalNameMap.get(this.getName(e)) } } lookupDataSource(e) { const t = this.component.data.outputNodes[e]; return t ? t.getSource() : e } getSignalName(e) { return this.signalNameMap.get(e) } renameSignal(e, t) { this.signalNameMap.rename(e, t) } renameScale(e, t) { this.scaleNameMap.rename(e, t) } renameProjection(e, t) { this.projectionNameMap.rename(e, t) } scaleName(e, t) { return t ? this.getName(e) : cTe(e) && XTe(e) && this.component.scales[e] || this.scaleNameMap.has(this.getName(e)) ? this.scaleNameMap.get(this.getName(e)) : void 0 } projectionName(e) { return e ? this.getName("projection") : this.component.projection && !this.component.projection.merged || this.projectionNameMap.has(this.getName("projection")) ? this.projectionNameMap.get(this.getName("projection")) : void 0 } getScaleComponent(e) { if (!this.component.scales) throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale()."); const t = this.component.scales[e]; return t && !t.merged ? t : this.parent ? this.parent.getScaleComponent(e) : void 0 } getSelectionComponent(e, t) { let n = this.component.selection[e]; if (!n && this.parent && (n = this.parent.getSelectionComponent(e, t)), !n) throw new Error(`Cannot find a selection named "${t}".`); return n } hasAxisOrientSignalRef() { var e, t; return (null === (e = this.component.axes.x) || void 0 === e ? void 0 : e.some((e => e.hasOrientSignalRef()))) || (null === (t = this.component.axes.y) || void 0 === t ? void 0 : t.some((e => e.hasOrientSignalRef()))) } } class EBe extends TBe { vgField(e, t = {}) { const n = this.fieldDef(e); if (n) return iMe(n, t) } reduceFieldDef(e, t) { return GMe(this.getMapping(), ((t, n, r) => { const i = pMe(n); return i ? e(t, i, r) : t }), t) } forEachFieldDef(e, t) { VMe(this.getMapping(), ((t, n) => { const r = pMe(t); r && e(r, n) }), t) } } class NBe extends E$e { constructor(e, t) { var n, r, i; super(e), this.transform = t, this.transform = G_e(t); const a = null !== (n = this.transform.as) && void 0 !== n ? n : [void 0, void 0]; this.transform.as = [null !== (r = a[0]) && void 0 !== r ? r : "value", null !== (i = a[1]) && void 0 !== i ? i : "density"] } clone() { return new NBe(null, G_e(this.transform)) } dependentFields() { var e; return new Set([this.transform.density, ...null !== (e = this.transform.groupby) && void 0 !== e ? e : []]) } producedFields() { return new Set(this.transform.as) } hash() { return `DensityTransform ${X_e(this.transform)}` } assemble() { const e = this.transform, { density: t } = e, n = F_e(e, ["density"]); return Object.assign({ type: "kde", field: t }, n) } } class IBe extends E$e { constructor(e, t) { super(e), this.filter = t } clone() { return new IBe(null, Object.assign({}, this.filter)) } static make(e, t) { const { config: n, mark: r, markDef: i } = t; if ("filter" !== MMe("invalid", i, n)) return null; const a = t.reduceFieldDef(((e, n, i) => { const a = XTe(i) && t.getScaleComponent(i); if (a) { XNe(a.get("type")) && "count" !== n.aggregate && !HCe(r) && (e[n.field] = n) } return e }), {}); return oCe(a).length ? new IBe(e, a) : null } dependentFields() { return new Set(oCe(this.filter)) } producedFields() { return new Set } hash() { return `FilterInvalid ${X_e(this.filter)}` } assemble() { const e = oCe(this.filter).reduce(((e, t) => { const n = this.filter[t], r = iMe(n, { expr: "datum" }); return null !== n && ("temporal" === n.type ? e.push(`(isDate(${r}) || (isValid(${r}) && isFinite(+${r})))`) : "quantitative" === n.type && (e.push(`isValid(${r})`), e.push(`isFinite(+${r})`))), e }), []); return e.length > 0 ? { type: "filter", expr: e.join(" && ") } : null } } class MBe extends E$e { constructor(e, t) { super(e), this.transform = t, this.transform = G_e(t); const { flatten: n, as: r = [] } = this.transform; this.transform.as = n.map(((e, t) => { var n; return null !== (n = r[t]) && void 0 !== n ? n : e })) } clone() { return new MBe(this.parent, G_e(this.transform)) } dependentFields() { return new Set(this.transform.flatten) } producedFields() { return new Set(this.transform.as) } hash() { return `FlattenTransform ${X_e(this.transform)}` } assemble() { const { flatten: e, as: t } = this.transform; return { type: "flatten", fields: e, as: t } } } class FBe extends E$e { constructor(e, t) { var n, r, i; super(e), this.transform = t, this.transform = G_e(t); const a = null !== (n = this.transform.as) && void 0 !== n ? n : [void 0, void 0]; this.transform.as = [null !== (r = a[0]) && void 0 !== r ? r : "key", null !== (i = a[1]) && void 0 !== i ? i : "value"] } clone() { return new FBe(null, G_e(this.transform)) } dependentFields() { return new Set(this.transform.fold) } producedFields() { return new Set(this.transform.as) } hash() { return `FoldTransform ${X_e(this.transform)}` } assemble() { const { fold: e, as: t } = this.transform; return { type: "fold", fields: e, as: t } } } class DBe extends E$e { constructor(e, t, n, r) { super(e), this.fields = t, this.geojson = n, this.signal = r } clone() { return new DBe(null, G_e(this.fields), this.geojson, this.signal) } static parseAll(e, t) { if (t.component.projection && !t.component.projection.isFit) return e; let n = 0; for (const r of [[_Ae, SAe], [AAe, CAe]]) { const i = r.map((e => { const n = mMe(t.encoding[e]); return HIe(n) ? n.field : YIe(n) ? { expr: `${n.datum}` } : QIe(n) ? { expr: `${n.value}` } : void 0 })); (i[0] || i[1]) && (e = new DBe(e, i, null, t.getName("geojson_" + n++))) } if (t.channelHasField(IAe)) { const r = t.typedFieldDef(IAe); r.type === SNe && (e = new DBe(e, null, r.field, t.getName("geojson_" + n++))) } return e } dependentFields() { var e; const t = (null !== (e = this.fields) && void 0 !== e ? e : []).filter(N_e); return new Set([...this.geojson ? [this.geojson] : [], ...t]) } producedFields() { return new Set } hash() { return `GeoJSON ${this.geojson} ${this.signal} ${X_e(this.fields)}` } assemble() { return Object.assign(Object.assign(Object.assign({ type: "geojson" }, this.fields ? { fields: this.fields } : {}), this.geojson ? { geojson: this.geojson } : {}), { signal: this.signal }) } } class $Be extends E$e { constructor(e, t, n, r) { super(e), this.projection = t, this.fields = n, this.as = r } clone() { return new $Be(null, this.projection, G_e(this.fields), G_e(this.as)) } static parseAll(e, t) { if (!t.projectionName()) return e; for (const n of [[_Ae, SAe], [AAe, CAe]]) { const r = n.map((e => { const n = mMe(t.encoding[e]); return HIe(n) ? n.field : YIe(n) ? { expr: `${n.datum}` } : QIe(n) ? { expr: `${n.value}` } : void 0 })), i = n[0] === AAe ? "2" : ""; (r[0] || r[1]) && (e = new $Be(e, t.projectionName(), r, [t.getName("x" + i), t.getName("y" + i)])) } return e } dependentFields() { return new Set(this.fields.filter(N_e)) } producedFields() { return new Set(this.as) } hash() { return `Geopoint ${this.projection} ${X_e(this.fields)} ${X_e(this.as)}` } assemble() { return { type: "geopoint", projection: this.projection, fields: this.fields, as: this.as } } } class RBe extends E$e { constructor(e, t) { super(e), this.transform = t } clone() { return new RBe(null, G_e(this.transform)) } dependentFields() { var e; return new Set([this.transform.impute, this.transform.key, ...null !== (e = this.transform.groupby) && void 0 !== e ? e : []]) } producedFields() { return new Set([this.transform.impute]) } processSequence(e) { const { start: t = 0, stop: n, step: r } = e; return { signal: `sequence(${[t, n, ...r ? [r] : []].join(",")})` } } static makeFromTransform(e, t) { return new RBe(e, t) } static makeFromEncoding(e, t) { const n = t.encoding, r = n.x, i = n.y; if (HIe(r) && HIe(i)) { const a = r.impute ? r : i.impute ? i : void 0; if (void 0 === a) return; const o = r.impute ? i : i.impute ? r : void 0, { method: s, value: u, frame: l, keyvals: c } = a.impute, h = HMe(t.mark, n); return new RBe(e, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ impute: a.field, key: o.field }, s ? { method: s } : {}), void 0 !== u ? { value: u } : {}), l ? { frame: l } : {}), void 0 !== c ? { keyvals: c } : {}), h.length ? { groupby: h } : {})) } return null } hash() { return `Impute ${X_e(this.transform)}` } assemble() { const { impute: e, key: t, keyvals: n, method: r, groupby: i, value: a, frame: o = [null, null] } = this.transform, s = Object.assign(Object.assign(Object.assign(Object.assign({ type: "impute", field: e, key: t }, n ? { keyvals: (u = n, void 0 !== (null == u ? void 0 : u.stop) ? this.processSequence(n) : n) } : {}), { method: "value" }), i ? { groupby: i } : {}), { value: r && "value" !== r ? null : a }); var u; if (r && "value" !== r) { return [s, Object.assign({ type: "window", as: [`imputed_${e}_value`], ops: [r], fields: [e], frame: o, ignorePeers: !1 }, i ? { groupby: i } : {}), { type: "formula", expr: `datum.${e} === null ? datum.imputed_${e}_value : datum.${e}`, as: e }] } return [s] } } class OBe extends E$e { constructor(e, t) { var n, r, i; super(e), this.transform = t, this.transform = G_e(t); const a = null !== (n = this.transform.as) && void 0 !== n ? n : [void 0, void 0]; this.transform.as = [null !== (r = a[0]) && void 0 !== r ? r : t.on, null !== (i = a[1]) && void 0 !== i ? i : t.loess] } clone() { return new OBe(null, G_e(this.transform)) } dependentFields() { var e; return new Set([this.transform.loess, this.transform.on, ...null !== (e = this.transform.groupby) && void 0 !== e ? e : []]) } producedFields() { return new Set(this.transform.as) } hash() { return `LoessTransform ${X_e(this.transform)}` } assemble() { const e = this.transform, { loess: t, on: n } = e, r = F_e(e, ["loess", "on"]); return Object.assign({ type: "loess", x: n, y: t }, r) } } class zBe extends E$e { constructor(e, t, n) { super(e), this.transform = t, this.secondary = n } clone() { return new zBe(null, G_e(this.transform), this.secondary) } static make(e, t, n, r) { const i = t.component.data.sources, { from: a } = n; let o = null; if (function (e) { return "data" in e }(a)) { let e = QBe(a.data, i); e || (e = new uPe(a.data), i.push(e)); const n = t.getName(`lookup_${r}`); o = new N$e(e, n, "lookup", t.component.data.outputNodeRefCounts), t.component.data.outputNodes[n] = o } else if (function (e) { return "selection" in e }(a)) { const e = a.selection; if (n = Object.assign({ as: e }, n), o = t.getSelectionComponent(cCe(e), e).materialized, !o) throw new Error(`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`) } return new zBe(e, n, o.getSource()) } dependentFields() { return new Set([this.transform.lookup]) } producedFields() { return new Set(this.transform.as ? __e(this.transform.as) : this.transform.from.fields) } hash() { return `Lookup ${X_e({ transform: this.transform, secondary: this.secondary })}` } assemble() { let e; if (this.transform.from.fields) e = Object.assign({ values: this.transform.from.fields }, this.transform.as ? { as: __e(this.transform.as) } : {}); else { let t = this.transform.as; N_e(t) || (zEe('If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.'), t = "_lookup"), e = { as: [t] } } return Object.assign(Object.assign({ type: "lookup", from: this.secondary, key: this.transform.from.key, fields: [this.transform.lookup] }, e), this.transform.default ? { default: this.transform.default } : {}) } } class PBe extends E$e { constructor(e, t) { var n, r, i; super(e), this.transform = t, this.transform = G_e(t); const a = null !== (n = this.transform.as) && void 0 !== n ? n : [void 0, void 0]; this.transform.as = [null !== (r = a[0]) && void 0 !== r ? r : "prob", null !== (i = a[1]) && void 0 !== i ? i : "value"] } clone() { return new PBe(null, G_e(this.transform)) } dependentFields() { var e; return new Set([this.transform.quantile, ...null !== (e = this.transform.groupby) && void 0 !== e ? e : []]) } producedFields() { return new Set(this.transform.as) } hash() { return `QuantileTransform ${X_e(this.transform)}` } assemble() { const e = this.transform, { quantile: t } = e, n = F_e(e, ["quantile"]); return Object.assign({ type: "quantile", field: t }, n) } } class BBe extends E$e { constructor(e, t) { var n, r, i; super(e), this.transform = t, this.transform = G_e(t); const a = null !== (n = this.transform.as) && void 0 !== n ? n : [void 0, void 0]; this.transform.as = [null !== (r = a[0]) && void 0 !== r ? r : t.on, null !== (i = a[1]) && void 0 !== i ? i : t.regression] } clone() { return new BBe(null, G_e(this.transform)) } dependentFields() { var e; return new Set([this.transform.regression, this.transform.on, ...null !== (e = this.transform.groupby) && void 0 !== e ? e : []]) } producedFields() { return new Set(this.transform.as) } hash() { return `RegressionTransform ${X_e(this.transform)}` } assemble() { const e = this.transform, { regression: t, on: n } = e, r = F_e(e, ["regression", "on"]); return Object.assign({ type: "regression", x: n, y: t }, r) } } class LBe extends E$e { constructor(e, t) { super(e), this.transform = t } clone() { return new LBe(null, G_e(this.transform)) } addDimensions(e) { var t; this.transform.groupby = tCe((null !== (t = this.transform.groupby) && void 0 !== t ? t : []).concat(e), (e => e)) } producedFields() { } dependentFields() { var e; return new Set([this.transform.pivot, this.transform.value, ...null !== (e = this.transform.groupby) && void 0 !== e ? e : []]) } hash() { return `PivotTransform ${X_e(this.transform)}` } assemble() { const { pivot: e, value: t, groupby: n, limit: r, op: i } = this.transform; return Object.assign(Object.assign(Object.assign({ type: "pivot", field: e, value: t }, void 0 !== r ? { limit: r } : {}), void 0 !== i ? { op: i } : {}), void 0 !== n ? { groupby: n } : {}) } } class jBe extends E$e { constructor(e, t) { super(e), this.transform = t } clone() { return new jBe(null, G_e(this.transform)) } dependentFields() { return new Set } producedFields() { return new Set } hash() { return `SampleTransform ${X_e(this.transform)}` } assemble() { return { type: "sample", size: this.transform.sample } } } function UBe(e) { let t = 0; return function n(r, i) { var a; if (r instanceof uPe && !r.isGenerator && !CDe(r.data)) { e.push(i); i = { name: null, source: i.name, transform: [] } } if (r instanceof kPe && (r.parent instanceof uPe && !i.source ? (i.format = Object.assign(Object.assign({}, null !== (a = i.format) && void 0 !== a ? a : {}), { parse: r.assembleFormatParse() }), i.transform.push(...r.assembleTransforms(!0))) : i.transform.push(...r.assembleTransforms())), r instanceof bPe) { i.name || (i.name = "data_" + t++), !i.source || i.transform.length > 0 ? (e.push(i), r.data = i.name) : r.data = i.source; for (const t of r.assemble()) e.push(t) } else { if ((r instanceof cPe || r instanceof hPe || r instanceof IBe || r instanceof WOe || r instanceof lze || r instanceof $Be || r instanceof DBe || r instanceof yPe || r instanceof zBe || r instanceof APe || r instanceof _Pe || r instanceof FBe || r instanceof MBe || r instanceof NBe || r instanceof OBe || r instanceof PBe || r instanceof BBe || r instanceof SPe || r instanceof jBe || r instanceof LBe) && i.transform.push(r.assemble()), (r instanceof sPe || r instanceof I$e || r instanceof RBe || r instanceof CPe) && i.transform.push(...r.assemble()), r instanceof N$e) if (i.source && 0 === i.transform.length) r.setSource(i.source); else if (r.parent instanceof N$e) r.setSource(i.name); else if (i.name || (i.name = "data_" + t++), r.setSource(i.name), 1 === r.numChildren()) { e.push(i); i = { name: null, source: i.name, transform: [] } } switch (r.numChildren()) { case 0: r instanceof N$e && (!i.source || i.transform.length > 0) && e.push(i); break; case 1: n(r.children[0], i); break; default: { i.name || (i.name = "data_" + t++); let a = i.name; !i.source || i.transform.length > 0 ? e.push(i) : a = i.source; for (const e of r.children) { n(e, { name: null, source: a, transform: [] }) } break } } } } } function WBe(e) { return "top" === e || "left" === e || eNe(e) ? "header" : "footer" } function VBe(e, t) { var n; const { facet: r, config: i, child: a, component: o } = e; if (e.channelHasField(t)) { const s = r[t], u = dze("title", null, i, t); let l = cMe(s, i, { allowDisabling: !0, includeDefault: void 0 === u || !!u }); a.component.layoutHeaders[t].title && (l = b_e(l) ? l.join(", ") : l, l += " / " + a.component.layoutHeaders[t].title, a.component.layoutHeaders[t].title = null); const c = dze("labelOrient", s, i, t), h = xCe((null !== (n = s.header) && void 0 !== n ? n : {}).labels, i.header.labels, !0), d = Z_e(["bottom", "right"], c) ? "footer" : "header"; o.layoutHeaders[t] = { title: l, facetFieldDef: s, [d]: "facet" === t ? [] : [GBe(e, t, h)] } } } function GBe(e, t, n) { const r = "row" === t ? "height" : "width"; return { labels: n, sizeSignal: e.child.component.layoutSize.get(r) ? e.child.getSizeSignalRef(r) : void 0, axes: [] } } function HBe(e, t) { var n; const { child: r } = e; if (r.component.axes[t]) { const { layoutHeaders: i, resolve: a } = e.component; if (a.axis[t] = Dze(a, t), "shared" === a.axis[t]) { const a = "x" === t ? "column" : "row", o = i[a]; for (const i of r.component.axes[t]) { const t = WBe(i.get("orient")); o[t] = null !== (n = o[t]) && void 0 !== n ? n : [GBe(e, a, !1)]; const r = YOe(i, "main", e.config, { header: !0 }); r && o[t][0].axes.push(r), i.mainExtracted = !0 } } } } function qBe(e) { YBe(e); const t = 1 === e.layout.columns ? "width" : "childWidth", n = void 0 === e.layout.columns ? "height" : "childHeight"; XBe(e, t), XBe(e, n) } function YBe(e) { for (const t of e.children) t.parseLayoutSize() } function XBe(e, t) { const n = Ize(t), r = OTe(n), i = e.component.resolve, a = e.component.layoutSize; let o; for (const t of e.children) { const e = t.component.layoutSize.getWithExplicit(n), a = i.scale[r]; if ("independent" === a && "step" === e.value) { o = void 0; break } if (o) { if ("independent" === a && o.value !== e.value) { o = void 0; break } o = SDe(o, e, n, "") } else o = e } if (o) { for (const r of e.children) e.renameSignal(r.getName(n), e.getName(t)), r.component.layoutSize.set(n, "merged", !1); a.setWithExplicit(t, o) } else a.setWithExplicit(t, { explicit: !1, value: void 0 }) } function KBe(e, t) { const n = "width" === t ? "x" : "y", r = e.config, i = e.getScaleComponent(n); if (i) { const e = i.get("type"), n = i.get("range"); if (YNe(e)) { const e = FFe(r.view, t); return tNe(n) || TFe(e) ? "step" : e } return IFe(r.view, t) } if (e.hasProjection || "arc" === e.mark) return IFe(r.view, t); { const e = FFe(r.view, t); return TFe(e) ? e.step : e } } function ZBe(e, t, n) { return iMe(t, Object.assign({ suffix: `by_${iMe(e)}` }, null != n ? n : {})) } class JBe extends EBe { constructor(e, t, n, r) { super(e, "facet", t, n, r, e.resolve), this.child = CLe(e.spec, this, this.getName("child"), void 0, r), this.children = [this.child], this.facet = this.initFacet(e.facet, r) } initFacet(e, t) { return OIe(e) ? GMe(e, ((e, n, r) => Z_e([dAe, fAe], r) ? void 0 === n.field ? (zEe(wEe(n, r)), e) : (e[r] = gMe(n, r, t), e) : (zEe(kEe(r, "facet")), e)), {}) : { facet: gMe(e, "facet", t) } } channelHasField(e) { return !!this.facet[e] } fieldDef(e) { return this.facet[e] } parseData() { this.component.data = tLe(this), this.child.parseData() } parseLayoutSize() { YBe(this) } parseSelections() { this.child.parseSelections(), this.component.selection = this.child.component.selection } parseMarkGroup() { this.child.parseMarkGroup() } parseAxesAndHeaders() { this.child.parseAxesAndHeaders(), function (e) { for (const t of QAe) VBe(e, t); HBe(e, "x"), HBe(e, "y") }(this) } assembleSelectionTopLevelSignals(e) { return this.child.assembleSelectionTopLevelSignals(e) } assembleSignals() { return this.child.assembleSignals(), [] } assembleSelectionData(e) { return this.child.assembleSelectionData(e) } getHeaderLayoutMixins() { var e, t, n; const r = {}; for (const i of QAe) for (const a of mze) { const o = this.component.layoutHeaders[i], s = o[a], { facetFieldDef: u } = o; if (u) { const t = dze("titleOrient", u, this.config, i); if (Z_e(["right", "bottom"], t)) { const n = hze(i, t); r.titleAnchor = null !== (e = r.titleAnchor) && void 0 !== e ? e : {}, r.titleAnchor[n] = "end" } } if (null == s ? void 0 : s[0]) { const e = "row" === i ? "height" : "width", s = "header" === a ? "headerBand" : "footerBand"; "facet" === i || this.child.component.layoutSize.get(e) || (r[s] = null !== (t = r[s]) && void 0 !== t ? t : {}, r[s][i] = .5), o.title && (r.offset = null !== (n = r.offset) && void 0 !== n ? n : {}, r.offset["row" === i ? "rowTitle" : "columnTitle"] = 10) } } return r } assembleDefaultLayout() { const { column: e, row: t } = this.facet, n = e ? this.columnDistinctSignal() : t ? 1 : void 0; let r = "all"; return (t || "independent" !== this.component.resolve.scale.x) && (e || "independent" !== this.component.resolve.scale.y) || (r = "none"), Object.assign(Object.assign(Object.assign({}, this.getHeaderLayoutMixins()), n ? { columns: n } : {}), { bounds: "full", align: r }) } assembleLayoutSignals() { return this.child.assembleLayoutSignals() } columnDistinctSignal() { if (!(this.parent && this.parent instanceof JBe)) { return { signal: `length(data('${this.getName("column_domain")}'))` } } } assembleGroup(e) { return this.parent && this.parent instanceof JBe ? Object.assign(Object.assign({}, this.channelHasField("column") ? { encode: { update: { columns: { field: iMe(this.facet.column, { prefix: "distinct" }) } } } } : {}), super.assembleGroup(e)) : super.assembleGroup(e) } getCardinalityAggregateForChild() { const e = [], t = [], n = []; if (this.child instanceof JBe) { if (this.child.channelHasField("column")) { const r = iMe(this.child.facet.column); e.push(r), t.push("distinct"), n.push(`distinct_${r}`) } } else for (const r of FTe) { const i = this.child.component.scales[r]; if (i && !i.merged) { const a = i.get("type"), o = i.get("range"); if (YNe(a) && tNe(o)) { const i = nBe(rBe(this.child, r)); i ? (e.push(i), t.push("distinct"), n.push(`distinct_${i}`)) : zEe(`Unknown field for ${r}. Cannot calculate view size.`) } } } return { fields: e, ops: t, as: n } } assembleFacet() { const { name: e, data: t } = this.component.data.facetRoot, { row: n, column: r } = this.facet, { fields: i, ops: a, as: o } = this.getCardinalityAggregateForChild(), s = []; for (const e of QAe) { const t = this.facet[e]; if (t) { s.push(iMe(t)); const { bin: u, sort: l } = t; if (nEe(u) && s.push(iMe(t, { binSuffix: "end" })), $Ie(l)) { const { field: e, op: s = IIe } = l, u = ZBe(t, l); n && r ? (i.push(u), a.push("max"), o.push(u)) : (i.push(e), a.push(s), o.push(u)) } else if (b_e(l)) { const n = cze(t, e); i.push(n), a.push("max"), o.push(n) } } } const u = !!n && !!r; return Object.assign({ name: e, data: t, groupby: s }, u || i.length > 0 ? { aggregate: Object.assign(Object.assign({}, u ? { cross: u } : {}), i.length ? { fields: i, ops: a, as: o } : {}) } : {}) } facetSortFields(e) { const { facet: t } = this, n = t[e]; return n ? $Ie(n.sort) ? [ZBe(n, n.sort, { expr: "datum" })] : b_e(n.sort) ? [cze(n, e, { expr: "datum" })] : [iMe(n, { expr: "datum" })] : [] } facetSortOrder(e) { const { facet: t } = this, n = t[e]; if (n) { const { sort: e } = n; return [($Ie(e) ? e.order : !b_e(e) && e) || "ascending"] } return [] } assembleLabelTitle() { const { facet: e, config: t } = this; if (e.facet) return wze(e.facet, "facet", t); const n = { row: ["top", "bottom"], column: ["left", "right"] }; for (const r of pze) if (e[r]) { const i = dze("labelOrient", e[r], t, r); if (Z_e(n[r], i)) return wze(e[r], r, t) } } assembleMarks() { const { child: e } = this, t = function (e) { const t = [], n = UBe(t); for (const t of e.children) n(t, { source: e.name, name: null, transform: [] }); return t }(this.component.data.facetRoot), n = e.assembleGroupEncodeEntry(!1), r = this.assembleLabelTitle() || e.assembleTitle(), i = e.assembleGroupStyle(), a = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name: this.getName("cell"), type: "group" }, r ? { title: r } : {}), i ? { style: i } : {}), { from: { facet: this.assembleFacet() }, sort: { field: QAe.map((e => this.facetSortFields(e))).flat(), order: QAe.map((e => this.facetSortOrder(e))).flat() } }), t.length > 0 ? { data: t } : {}), n ? { encode: { update: n } } : {}), e.assembleGroup(function (e, t) { if (e.component.selection && oCe(e.component.selection).length) { const n = I_e(e.getName("cell")); t.unshift({ name: "facet", value: {}, on: [{ events: r_e("mousemove", "scope"), update: `isTuple(facet) ? facet : group(${n}).datum` }] }) } return nRe(t) }(this, []))); return [a] } getMapping() { return this.facet } } function QBe(e, t) { var n, r, i, a, o, s, u, l, c, h; for (const d of t) { const t = d.data; if ((!e.name || !d.hasName() || e.name === d.dataName) && !((null === (n = e.format) || void 0 === n ? void 0 : n.mesh) && (null === (r = t.format) || void 0 === r ? void 0 : r.feature) || ((null === (i = e.format) || void 0 === i ? void 0 : i.feature) || (null === (a = t.format) || void 0 === a ? void 0 : a.feature)) && (null === (o = e.format) || void 0 === o ? void 0 : o.feature) !== (null === (s = t.format) || void 0 === s ? void 0 : s.feature) || ((null === (u = e.format) || void 0 === u ? void 0 : u.mesh) || (null === (l = t.format) || void 0 === l ? void 0 : l.mesh)) && (null === (c = e.format) || void 0 === c ? void 0 : c.mesh) !== (null === (h = t.format) || void 0 === h ? void 0 : h.mesh))) if (ADe(e) && ADe(t)) { if (V_e(e.values, t.values)) return d } else if (CDe(e) && CDe(t)) { if (e.url === t.url) return d } else if (TDe(e) && e.name === d.dataName) return d } return null } function eLe(e, t) { if (e.data || !e.parent) { if (null === e.data) { const e = new uPe({ values: [] }); return t.push(e), e } const n = QBe(e.data, t); if (n) return EDe(e.data) || (n.data.format = function (e, ...t) { for (const n of t) eCe(e, null != n ? n : {}); return e }({}, e.data.format, n.data.format)), !n.hasName() && e.data.name && (n.dataName = e.data.name), n; { const n = new uPe(e.data); return t.push(n), n } } return e.parent.component.data.facetRoot ? e.parent.component.data.facetRoot : e.parent.component.data.main } function tLe(e) { var t, n, r, i, a, o, s, u, l, c; let h = eLe(e, e.component.data.sources); const { outputNodes: d, outputNodeRefCounts: f } = e.component.data, p = e.parent ? e.parent.component.data.ancestorParse.clone() : new _De, m = e.data; EDe(m) ? (NDe(m) ? h = new hPe(h, m.sequence) : MDe(m) && (h = new cPe(h, m.graticule)), p.parseNothing = !0) : null === (null === (t = null == m ? void 0 : m.format) || void 0 === t ? void 0 : t.parse) && (p.parseNothing = !0), h = null !== (n = kPe.makeExplicit(h, e, p)) && void 0 !== n ? n : h, h = new SPe(h); const g = e.parent && ABe(e.parent); (SBe(e) || _Be(e)) && g && (h = null !== (r = sPe.makeFromEncoding(h, e)) && void 0 !== r ? r : h), e.transforms.length > 0 && (h = function (e, t, n) { var r, i; let a = 0; for (const o of t.transforms) { let s, u; if (GDe(o)) u = e = new lze(e, o), s = "derived"; else if ($De(o)) { const i = xPe(o); u = e = null !== (r = kPe.makeWithAncestors(e, {}, i, n)) && void 0 !== r ? r : e, e = new WOe(e, t, o.filter) } else if (HDe(o)) u = e = sPe.makeFromTransform(e, o, t), s = "number"; else if (YDe(o)) s = "date", void 0 === n.getWithExplicit(o.field).value && (e = new kPe(e, { [o.field]: s }), n.set(o.field, s, !1)), u = e = I$e.makeFromTransform(e, o); else if (XDe(o)) u = e = yPe.makeFromTransform(e, o), s = "number", yRe(t) && (e = new SPe(e)); else if (RDe(o)) u = e = zBe.make(e, t, o, a++), s = "derived"; else if (UDe(o)) u = e = new APe(e, o), s = "number"; else if (WDe(o)) u = e = new _Pe(e, o), s = "number"; else if (KDe(o)) u = e = CPe.makeFromTransform(e, o), s = "derived"; else if (ZDe(o)) u = e = new FBe(e, o), s = "derived"; else if (VDe(o)) u = e = new MBe(e, o), s = "derived"; else if (ODe(o)) u = e = new LBe(e, o), s = "derived"; else if (jDe(o)) e = new jBe(e, o); else if (qDe(o)) u = e = RBe.makeFromTransform(e, o), s = "derived"; else if (zDe(o)) u = e = new NBe(e, o), s = "derived"; else if (PDe(o)) u = e = new PBe(e, o), s = "derived"; else if (BDe(o)) u = e = new BBe(e, o), s = "derived"; else { if (!LDe(o)) { zEe(yEe(o)); continue } u = e = new OBe(e, o), s = "derived" } if (u && void 0 !== s) for (const e of null !== (i = u.producedFields()) && void 0 !== i ? i : []) n.set(e, s, !1) } return e }(h, e, p)); const y = function (e) { const t = {}; if (SBe(e) && e.component.selection) for (const n of oCe(e.component.selection)) { const r = e.component.selection[n]; for (const e of r.project.items) !e.channel && vCe(e.field) > 1 && (t[e.field] = "flatten") } return t }(e), b = wPe(e); h = null !== (i = kPe.makeWithAncestors(h, {}, Object.assign(Object.assign({}, y), b), p)) && void 0 !== i ? i : h, SBe(e) && (h = DBe.parseAll(h, e), h = $Be.parseAll(h, e)), (SBe(e) || _Be(e)) && (g || (h = null !== (a = sPe.makeFromEncoding(h, e)) && void 0 !== a ? a : h), h = null !== (o = I$e.makeFromEncoding(h, e)) && void 0 !== o ? o : h, h = lze.parseAllForSortIndex(h, e)); const v = e.getName(DDe), x = new N$e(h, v, DDe, f); if (d[v] = x, h = x, SBe(e)) { const t = yPe.makeFromEncoding(h, e); t && (h = t, yRe(e) && (h = new SPe(h))), h = null !== (s = RBe.makeFromEncoding(h, e)) && void 0 !== s ? s : h, h = null !== (u = CPe.makeFromEncoding(h, e)) && void 0 !== u ? u : h } SBe(e) && (h = null !== (l = IBe.make(h, e)) && void 0 !== l ? l : h); const w = e.getName(FDe), k = new N$e(h, w, FDe, f); d[w] = k, h = k, SBe(e) && function (e, t) { mRe(e, (n => { const r = n.name, i = e.getName(`lookup_${r}`); e.component.data.outputNodes[i] = n.materialized = new N$e(new WOe(t, e, { selection: r }), i, "lookup", e.component.data.outputNodeRefCounts) })) }(e, k); let S = null; if (_Be(e)) { const t = e.getName("facet"); h = null !== (c = function (e, t) { const { row: n, column: r } = t; if (n && r) { let t = null; for (const i of [n, r]) if ($Ie(i.sort)) { const { field: n, op: r = IIe } = i.sort; e = t = new _Pe(e, { joinaggregate: [{ op: r, field: n, as: ZBe(i, i.sort, { forAs: !0 }) }], groupby: [iMe(i)] }) } return t } return null }(h, e.facet)) && void 0 !== c ? c : h, S = new bPe(h, e, t, k.getSource()), d[t] = S } return Object.assign(Object.assign({}, e.component.data), { outputNodes: d, outputNodeRefCounts: f, raw: x, main: k, facetRoot: S, ancestorParse: p }) } class nLe extends TBe { constructor(e, t, n, r) { var i, a, o, s; super(e, "concat", t, n, r, e.resolve), "shared" !== (null === (a = null === (i = e.resolve) || void 0 === i ? void 0 : i.axis) || void 0 === a ? void 0 : a.x) && "shared" !== (null === (s = null === (o = e.resolve) || void 0 === o ? void 0 : o.axis) || void 0 === s ? void 0 : s.y) || zEe("Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415)."), this.children = this.getChildren(e).map(((e, t) => CLe(e, this, this.getName("concat_" + t), void 0, r))) } parseData() { this.component.data = tLe(this); for (const e of this.children) e.parseData() } parseSelections() { this.component.selection = {}; for (const e of this.children) { e.parseSelections(); for (const t of oCe(e.component.selection)) this.component.selection[t] = e.component.selection[t] } } parseMarkGroup() { for (const e of this.children) e.parseMarkGroup() } parseAxesAndHeaders() { for (const e of this.children) e.parseAxesAndHeaders() } getChildren(e) { return CFe(e) ? e.vconcat : AFe(e) ? e.hconcat : e.concat } parseLayoutSize() { qBe(this) } parseAxisGroup() { return null } assembleSelectionTopLevelSignals(e) { return this.children.reduce(((e, t) => t.assembleSelectionTopLevelSignals(e)), e) } assembleSignals() { return this.children.forEach((e => e.assembleSignals())), [] } assembleLayoutSignals() { const e = Aze(this); for (const t of this.children) e.push(...t.assembleLayoutSignals()); return e } assembleSelectionData(e) { return this.children.reduce(((e, t) => t.assembleSelectionData(e)), e) } assembleMarks() { return this.children.map((e => { const t = e.assembleTitle(), n = e.assembleGroupStyle(), r = e.assembleGroupEncodeEntry(!1); return Object.assign(Object.assign(Object.assign(Object.assign({ type: "group", name: e.getName("group") }, t ? { title: t } : {}), n ? { style: n } : {}), r ? { encode: { update: r } } : {}), e.assembleGroup()) })) } assembleDefaultLayout() { const e = this.layout.columns; return Object.assign(Object.assign({}, null != e ? { columns: e } : {}), { bounds: "full", align: "each" }) } } const rLe = Object.assign(Object.assign({ disable: 1, gridScale: 1, scale: 1 }, ECe), { labelExpr: 1, encode: 1 }), iLe = oCe(rLe); class aLe extends bDe { constructor(e = {}, t = {}, n = !1) { super(), this.explicit = e, this.implicit = t, this.mainExtracted = n } clone() { return new aLe(G_e(this.explicit), G_e(this.implicit), this.mainExtracted) } hasAxisPart(e) { return "axis" === e || ("grid" === e || "title" === e ? !!this.get(e) : !(!1 === (t = this.get(e)) || null === t)); var t } hasOrientSignalRef() { return eNe(this.explicit.orient) } } const oLe = { bottom: "top", top: "bottom", left: "right", right: "left" }; function sLe(e, t) { if (!e) return t.map((e => e.clone())); { if (e.length !== t.length) return; const n = e.length; for (let r = 0; r < n; r++) { const n = e[r], i = t[r]; if (!!n != !!i) return; if (n && i) { const t = n.getWithExplicit("orient"), a = i.getWithExplicit("orient"); if (t.explicit && a.explicit && t.value !== a.value) return; e[r] = uLe(n, i) } } } return e } function uLe(e, t) { for (const n of iLe) { const r = SDe(e.getWithExplicit(n), t.getWithExplicit(n), n, "axis", ((e, t) => { switch (n) { case "title": return PMe(e, t); case "gridScale": return { explicit: e.explicit, value: xCe(e.value, t.value) } }return kDe(e, t, n, "axis") })); e.setWithExplicit(n, r) } return e } function lLe(e, t, n, r, i) { if ("disable" === t) return void 0 !== n; switch (n = n || {}, t) { case "titleAngle": case "labelAngle": return e === (eNe(n.labelAngle) ? n.labelAngle : kCe(n.labelAngle)); case "values": return !!n.values; case "encode": return !!n.encoding || !!n.labelAngle; case "title": if (e === uze(r, i)) return !0 }return e === n[t] } const cLe = new Set(["grid", "translate", "format", "formatType", "orient", "labelExpr", "tickCount", "position", "tickMinStep"]); function hLe(e, t) { var n, r, i; let a = t.axis(e); const o = new aLe, s = mMe(t.encoding[e]), { mark: u, config: l } = t, c = (null == a ? void 0 : a.orient) || (null === (n = l["x" === e ? "axisX" : "axisY"]) || void 0 === n ? void 0 : n.orient) || (null === (r = l.axis) || void 0 === r ? void 0 : r.orient) || function (e) { return "x" === e ? "bottom" : "left" }(e), h = t.getScaleComponent(e).get("type"), d = tze(e, h, c, t.config), f = void 0 !== a ? !a : rze("disable", l, null == a ? void 0 : a.style, d).configValue; if (o.set("disable", f, void 0 !== a), f) return o; a = a || {}; const p = function (e, t, n, r, i) { const a = null == t ? void 0 : t.labelAngle; if (void 0 !== a) return eNe(a) ? a : kCe(a); { const { configValue: a } = rze("labelAngle", e.config, null == t ? void 0 : t.style, i); return void 0 !== a ? kCe(a) : n === mAe && Z_e([kNe, xNe], r.type) ? 270 : void 0 } }(t, a, e, s, d), m = { fieldOrDatumDef: s, axis: a, channel: e, model: t, scaleType: h, orient: c, labelAngle: p, mark: u, config: l }; for (const n of iLe) { const r = n in ize ? ize[n](m) : ICe(n) ? a[n] : void 0, i = void 0 !== r, s = lLe(r, n, a, t, e); if (i && s) o.set(n, r, s); else { const { configValue: e, configFrom: u } = ICe(n) && "values" !== n ? rze(n, t.config, a.style, d) : {}, l = void 0 !== e; i && !l ? o.set(n, r, s) : ("vgAxisConfig" !== u || cLe.has(n) && l || CCe(e) || eNe(e)) && o.set(n, e, !1) } } const g = null !== (i = a.encoding) && void 0 !== i ? i : {}, y = ACe.reduce(((n, r) => { var i; if (!o.hasAxisPart(r)) return n; const a = Mze(null !== (i = g[r]) && void 0 !== i ? i : {}, t), s = "labels" === r ? function (e, t, n) { var r; const { encoding: i, config: a } = e, o = null !== (r = mMe(i[t])) && void 0 !== r ? r : mMe(i[mTe(t)]), s = e.axis(t) || {}, { format: u, formatType: l } = s; return vIe(l) ? Object.assign({ text: SIe({ fieldOrDatumDef: o, field: "datum.value", format: u, formatType: l, config: a }) }, n) : n }(t, e, a) : a; return void 0 === s || aCe(s) || (n[r] = { update: s }), n }), {}); return aCe(y) || o.set("encode", y, !!a.encoding || void 0 !== a.labelAngle), o } function dLe(e, t, n, { graticule: r }) { const i = XCe(e) ? Object.assign({}, e) : { type: e }, a = MMe("orient", i, n); if (i.orient = function (e, t, n) { switch (e) { case zCe: case WCe: case VCe: case LCe: case PCe: case RCe: return }const { x: r, y: i, x2: a, y2: o } = t; switch (e) { case $Ce: if (HIe(r) && (rEe(r.bin) || HIe(i) && i.aggregate && !r.aggregate)) return "vertical"; if (HIe(i) && (rEe(i.bin) || HIe(r) && r.aggregate && !i.aggregate)) return "horizontal"; if (o || a) { if (n) return n; if (!a && (HIe(r) && r.type === vNe && !nEe(r.bin) || KIe(r))) return "horizontal"; if (!o && (HIe(i) && i.type === vNe && !nEe(i.bin) || KIe(i))) return "vertical" } case BCe: if (a && (!HIe(r) || !rEe(r.bin)) && o && (!HIe(i) || !rEe(i.bin))) return; case DCe: if (o) return HIe(i) && rEe(i.bin) ? "horizontal" : "vertical"; if (a) return HIe(r) && rEe(r.bin) ? "vertical" : "horizontal"; if (e === BCe) { if (r && !i) return "vertical"; if (i && !r) return "horizontal" } case OCe: case jCe: { const t = XIe(r), a = XIe(i); if (t && !a) return "tick" !== e ? "horizontal" : "vertical"; if (!t && a) return "tick" !== e ? "vertical" : "horizontal"; if (t && a) { const t = r, a = i, o = t.type === wNe, s = a.type === wNe; return o && !s ? "tick" !== e ? "vertical" : "horizontal" : !o && s ? "tick" !== e ? "horizontal" : "vertical" : !t.aggregate && a.aggregate ? "tick" !== e ? "vertical" : "horizontal" : t.aggregate && !a.aggregate ? "tick" !== e ? "horizontal" : "vertical" : n || "vertical" } return n || void 0 } }return "vertical" }(i.type, t, a), void 0 !== a && a !== i.orient && zEe(`Specified orient "${i.orient}" overridden with "${a}".`), "bar" === i.type && i.orient) { const e = MMe("cornerRadiusEnd", i, n); if (void 0 !== e) { const n = "horizontal" === i.orient && t.x2 || "vertical" === i.orient && t.y2 ? ["cornerRadius"] : JCe[i.orient]; for (const t of n) i[t] = e; void 0 !== i.cornerRadiusEnd && delete i.cornerRadiusEnd } } void 0 === MMe("opacity", i, n) && (i.opacity = function (e, t) { if (Z_e([zCe, jCe, WCe, VCe], e) && !LMe(t)) return .7; return }(i.type, t)); void 0 === i.filled && (i.filled = !r && function (e, t) { const n = FMe("filled", e, t), r = e.type; return xCe(n, r !== zCe && r !== OCe && r !== BCe) }(i, n)); return void 0 === MMe("cursor", i, n) && (i.cursor = function (e, t, n) { if (t.href || e.href || MMe("href", e, n)) return "pointer"; return e.cursor }(i, t, n)), i } function fLe(e, t) { const { config: n } = e; return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", size: "include", orient: "ignore", theta: "ignore" })), u$e("x", e, { defaultPos: "mid" })), u$e("y", e, { defaultPos: "mid" })), a$e("size", e)), a$e("angle", e)), function (e, t, n) { if (n) return { shape: { value: n } }; return a$e("shape", e) }(e, 0, t)) } const pLe = { vgMark: "rule", encodeEntry: e => { const { markDef: t } = e, n = t.orient; return e.encoding.x || e.encoding.y || e.encoding.latitude || e.encoding.longitude ? Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", orient: "ignore", size: "ignore", theta: "ignore" })), f$e("x", e, { defaultPos: "horizontal" === n ? "zeroOrMax" : "mid", defaultPos2: "zeroOrMin", range: "vertical" !== n })), f$e("y", e, { defaultPos: "vertical" === n ? "zeroOrMax" : "mid", defaultPos2: "zeroOrMin", range: "horizontal" !== n })), a$e("size", e, { vgChannel: "strokeWidth" })) : {} } }, mLe = { vgMark: "text", encodeEntry: e => { const { config: t, encoding: n } = e; return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "include", baseline: "include", color: "include", size: "ignore", orient: "ignore", theta: "include" })), u$e("x", e, { defaultPos: "mid" })), u$e("y", e, { defaultPos: "mid" })), QDe(e)), a$e("size", e, { vgChannel: "fontSize" })), a$e("angle", e)), _$e("align", function (e, t, n) { const r = MMe("align", e, n); if (void 0 === r) return "center"; return }(e.markDef, 0, t))), _$e("baseline", function (e, t, n) { const r = MMe("baseline", e, n); if (void 0 === r) return "middle"; return }(e.markDef, 0, t))), u$e("radius", e, { defaultPos: null, isMidPoint: !0 })), u$e("theta", e, { defaultPos: null, isMidPoint: !0 })) } }; const gLe = { vgMark: "rect", encodeEntry: e => { const { config: t, markDef: n } = e, r = n.orient, i = "horizontal" === r ? "width" : "height", a = "horizontal" === r ? "height" : "width"; return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", orient: "ignore", size: "ignore", theta: "ignore" })), u$e("x", e, { defaultPos: "mid", vgChannel: "xc" })), u$e("y", e, { defaultPos: "mid", vgChannel: "yc" })), a$e("size", e, { defaultValue: yLe(e), vgChannel: i })), { [a]: TMe(MMe("thickness", n, t)) }) } }; function yLe(e) { var t; const { config: n, markDef: r } = e, { orient: i } = r, a = "horizontal" === i ? "width" : "height", o = e.getScaleComponent("horizontal" === i ? "x" : "y"), s = null !== (t = MMe("size", r, n, { vgChannel: a })) && void 0 !== t ? t : n.tick.bandSize; if (void 0 !== s) return s; { const e = o ? o.get("range") : void 0; if (e && tNe(e) && E_e(e.step)) return 3 * e.step / 4; return 3 * MFe(n.view, a) / 4 } } const bLe = { arc: { vgMark: "arc", encodeEntry: e => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", size: "ignore", orient: "ignore", theta: "ignore" })), u$e("x", e, { defaultPos: "mid" })), u$e("y", e, { defaultPos: "mid" })), g$e(e, "radius", "arc")), g$e(e, "theta", "arc")) }, area: { vgMark: "area", encodeEntry: e => Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", orient: "include", size: "ignore", theta: "ignore" })), f$e("x", e, { defaultPos: "zeroOrMin", defaultPos2: "zeroOrMin", range: "horizontal" === e.markDef.orient })), f$e("y", e, { defaultPos: "zeroOrMin", defaultPos2: "zeroOrMin", range: "vertical" === e.markDef.orient })), S$e(e)) }, bar: { vgMark: "rect", encodeEntry: e => Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", orient: "ignore", size: "ignore", theta: "ignore" })), g$e(e, "x", "bar")), g$e(e, "y", "bar")) }, circle: { vgMark: "symbol", encodeEntry: e => fLe(e, "circle") }, geoshape: { vgMark: "shape", encodeEntry: e => Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", size: "ignore", orient: "ignore", theta: "ignore" })), postEncodingTransform: e => { const { encoding: t } = e, n = t.shape; return [Object.assign({ type: "geoshape", projection: e.projectionName() }, n && HIe(n) && n.type === SNe ? { field: iMe(n, { expr: "datum" }) } : {})] } }, image: { vgMark: "image", encodeEntry: e => Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "ignore", orient: "ignore", size: "ignore", theta: "ignore" })), g$e(e, "x", "image")), g$e(e, "y", "image")), QDe(e, "url")) }, line: { vgMark: "line", encodeEntry: e => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", size: "ignore", orient: "ignore", theta: "ignore" })), u$e("x", e, { defaultPos: "mid" })), u$e("y", e, { defaultPos: "mid" })), a$e("size", e, { vgChannel: "strokeWidth" })), S$e(e)) }, point: { vgMark: "symbol", encodeEntry: e => fLe(e) }, rect: { vgMark: "rect", encodeEntry: e => Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", orient: "ignore", size: "ignore", theta: "ignore" })), g$e(e, "x", "rect")), g$e(e, "y", "rect")) }, rule: pLe, square: { vgMark: "symbol", encodeEntry: e => fLe(e, "square") }, text: mLe, tick: gLe, trail: { vgMark: "trail", encodeEntry: e => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, w$e(e, { align: "ignore", baseline: "ignore", color: "include", size: "include", orient: "ignore", theta: "ignore" })), u$e("x", e, { defaultPos: "mid" })), u$e("y", e, { defaultPos: "mid" })), a$e("size", e)), S$e(e)) } }; function vLe(e) { return Z_e([OCe, DCe, UCe], e.mark) ? function (e) { const t = HMe(e.mark, e.encoding), n = kLe(e, { fromPrefix: t.length > 0 ? xLe : "" }); return t.length > 0 ? [{ name: e.getName("pathgroup"), type: "group", from: { facet: { name: xLe + e.requestDataName(FDe), data: e.requestDataName(FDe), groupby: t } }, encode: { update: { width: { field: { group: "width" } }, height: { field: { group: "height" } } } }, marks: n }] : n }(e) : Z_e([$Ce], e.mark) ? function (e) { const t = aNe.some((t => MMe(t, e.markDef, e.config))); if (e.stack && !e.fieldDef("size") && t) { const [t] = kLe(e, { fromPrefix: wLe }), n = e.scaleName(e.stack.fieldChannel), r = (t = {}) => e.vgField(e.stack.fieldChannel, t), i = (e, t) => `${e}(${[r({ prefix: "min", suffix: "start", expr: t }), r({ prefix: "max", suffix: "start", expr: t }), r({ prefix: "min", suffix: "end", expr: t }), r({ prefix: "max", suffix: "end", expr: t })].map((e => `scale('${n}',${e})`)).join(",")})`; let a, o; "x" === e.stack.fieldChannel ? (a = Object.assign(Object.assign({}, H_e(t.encode.update, ["y", "yc", "y2", "height", ...aNe])), { x: { signal: i("min", "datum") }, x2: { signal: i("max", "datum") }, clip: { value: !0 } }), o = { x: { field: { group: "x" }, mult: -1 }, height: { field: { group: "height" } } }, t.encode.update = Object.assign(Object.assign({}, q_e(t.encode.update, ["y", "yc", "y2"])), { height: { field: { group: "height" } } })) : (a = Object.assign(Object.assign({}, H_e(t.encode.update, ["x", "xc", "x2", "width"])), { y: { signal: i("min", "datum") }, y2: { signal: i("max", "datum") }, clip: { value: !0 } }), o = { y: { field: { group: "y" }, mult: -1 }, width: { field: { group: "width" } } }, t.encode.update = Object.assign(Object.assign({}, q_e(t.encode.update, ["x", "xc", "x2"])), { width: { field: { group: "width" } } })); for (const n of aNe) { const r = FMe(n, e.markDef, e.config); t.encode.update[n] ? (a[n] = t.encode.update[n], delete t.encode.update[n]) : r && (a[n] = TMe(r)), r && (t.encode.update[n] = { value: 0 }) } const s = e.fieldDef(e.stack.groupbyChannel), u = iMe(s) ? [iMe(s)] : []; ((null == s ? void 0 : s.bin) || (null == s ? void 0 : s.timeUnit)) && u.push(iMe(s, { binSuffix: "end" })); return a = ["stroke", "strokeWidth", "strokeJoin", "strokeCap", "strokeDash", "strokeDashOffset", "strokeMiterLimit", "strokeOpacity"].reduce(((n, r) => { if (t.encode.update[r]) return Object.assign(Object.assign({}, n), { [r]: t.encode.update[r] }); { const t = FMe(r, e.markDef, e.config); return void 0 !== t ? Object.assign(Object.assign({}, n), { [r]: TMe(t) }) : n } }), a), a.stroke && (a.strokeForeground = { value: !0 }, a.strokeOffset = { value: 0 }), [{ type: "group", from: { facet: { data: e.requestDataName(FDe), name: wLe + e.requestDataName(FDe), groupby: u, aggregate: { fields: [r({ suffix: "start" }), r({ suffix: "start" }), r({ suffix: "end" }), r({ suffix: "end" })], ops: ["min", "max", "min", "max"] } } }, encode: { update: a }, marks: [{ type: "group", encode: { update: o }, marks: [t] }] }] } return kLe(e) }(e) : kLe(e) } const xLe = "faceted_path_"; const wLe = "stack_group_"; function kLe(e, t = { fromPrefix: "" }) { const { mark: n, markDef: r, config: i } = e, a = xCe(r.clip, function (e) { const t = e.getScaleComponent("x"), n = e.getScaleComponent("y"); return !!(t && t.get("selectionExtent") || n && n.get("selectionExtent")) || void 0 }(e), function (e) { const t = e.component.projection; return !(!t || t.isFit) || void 0 }(e)), o = IMe(r), s = e.encoding.key, u = function (e) { const { encoding: t, stack: n, mark: r, markDef: i, config: a } = e, o = t.order; if (!(!b_e(o) && QIe(o) && K_e(o.value) || !o && K_e(MMe("order", i, a)))) { if ((b_e(o) || HIe(o)) && !n) return RMe(o, { expr: "datum" }); if (HCe(r)) { const n = "horizontal" === i.orient ? "y" : "x", r = t[n]; if (HIe(r)) { const t = r.sort; return b_e(t) ? { field: iMe(r, { prefix: n, suffix: "sort_index", expr: "datum" }) } : $Ie(t) ? { field: iMe({ aggregate: LMe(e.encoding) ? t.op : void 0, field: t.field }, { expr: "datum" }) } : DIe(t) ? { field: iMe(e.fieldDef(t.encoding), { expr: "datum" }), order: t.order } : null === t ? void 0 : { field: iMe(r, { binSuffix: e.stack && e.stack.impute ? "mid" : void 0, expr: "datum" }) } } } } }(e), l = function (e) { if (!e.component.selection) return null; const t = oCe(e.component.selection).length; let n = t, r = e.parent; for (; r && 0 === n;)n = oCe(r.component.selection).length, r = r.parent; return n ? { interactive: t > 0 } : null }(e), c = MMe("aria", r, i), h = bLe[n].postEncodingTransform ? bLe[n].postEncodingTransform(e) : null; return [Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name: e.getName("marks"), type: bLe[n].vgMark }, a ? { clip: !0 } : {}), o ? { style: o } : {}), s ? { key: s.field } : {}), u ? { sort: u } : {}), l || {}), !1 === c ? { aria: c } : {}), { from: { data: t.fromPrefix + e.requestDataName(FDe) }, encode: { update: bLe[n].encodeEntry(e) } }), h ? { transform: h } : {})] } class SLe extends EBe { constructor(e, t, n, r = {}, i) { var a, o; super(e, "unit", t, n, i, void 0, EFe(e) ? e.view : void 0), this.specifiedScales = {}, this.specifiedAxes = {}, this.specifiedLegends = {}, this.specifiedProjection = {}, this.selection = {}, this.children = []; const s = XCe(e.mark) ? e.mark.type : e.mark; this.markDef = dLe(e.mark, null !== (a = e.encoding) && void 0 !== a ? a : {}, i, { graticule: e.data && MDe(e.data) }); const u = this.encoding = UMe(null !== (o = e.encoding) && void 0 !== o ? o : {}, this.markDef, i); this.size = function ({ encoding: e, size: t }) { for (const n of FTe) { const r = gTe(n); TFe(t[r]) && XIe(e[n]) && (delete t[r], zEe(NEe(r))) } return t }({ encoding: u, size: EFe(e) ? Object.assign(Object.assign(Object.assign({}, r), e.width ? { width: e.width } : {}), e.height ? { height: e.height } : {}) : r }), this.stack = KFe(s, u), this.specifiedScales = this.initScales(s, u), this.specifiedAxes = this.initAxes(u), this.specifiedLegends = this.initLegend(u), this.specifiedProjection = e.projection, this.selection = e.selection } get hasProjection() { const { encoding: e } = this, t = this.mark === GCe, n = e && XAe.some((t => ZIe(e[t]))); return t || n } scaleDomain(e) { const t = this.specifiedScales[e]; return t ? t.domain : void 0 } axis(e) { return this.specifiedAxes[e] } legend(e) { return this.specifiedLegends[e] } initScales(e, t) { return YTe.reduce(((e, n) => { var r; const i = mMe(t[n]); return i && (e[n] = null !== (r = i.scale) && void 0 !== r ? r : {}), e }), {}) } initAxes(e) { return FTe.reduce(((t, n) => { const r = e[n]; if (ZIe(r) || n === mAe && ZIe(e.x2) || n === gAe && ZIe(e.y2)) { const e = ZIe(r) ? r.axis : void 0; t[n] = e ? Object.assign({}, e) : e } return t }), {}) } initLegend(e) { return HTe.reduce(((t, n) => { const r = mMe(e[n]); if (r && function (e) { switch (e) { case TAe: case EAe: case NAe: case MAe: case IAe: case DAe: case OAe: case zAe: return !0; case $Ae: case RAe: case FAe: return !1 } }(n)) { const e = r.legend; t[n] = e ? Object.assign({}, e) : e } return t }), {}) } parseData() { this.component.data = tLe(this) } parseLayoutSize() { !function (e) { const { size: t, component: n } = e; for (const r of FTe) { const i = gTe(r); if (t[i]) { const e = t[i]; n.layoutSize.set(i, TFe(e) ? "step" : e, !0) } else { const t = KBe(e, i); n.layoutSize.set(i, t, !1) } } }(this) } parseSelections() { this.component.selection = function (e, t) { var n; const r = {}, i = e.config.selection; for (const a of oCe(null != t ? t : {})) { const o = G_e(t[a]), s = i[o.type], { fields: u, encodings: l } = s, c = F_e(s, ["fields", "encodings"]); for (const e in c) "encodings" === e && o.fields || "fields" === e && o.encodings || ("mark" === e && (o[e] = Object.assign(Object.assign({}, c[e]), o[e])), void 0 !== o[e] && !0 !== o[e] || (o[e] = null !== (n = c[e]) && void 0 !== n ? n : o[e])); const h = cCe(a), d = r[h] = Object.assign(Object.assign({}, o), { name: h, events: N_e(o.on) ? r_e(o.on, "scope") : G_e(o.on) }); Q$e(d, (n => { n.has(d) && n.parse && n.parse(e, d, o, t[a]) })) } return r }(this, this.selection) } parseMarkGroup() { this.component.mark = vLe(this) } parseAxesAndHeaders() { var e; this.component.axes = (e = this, FTe.reduce(((t, n) => (e.component.scales[n] && (t[n] = [hLe(n, e)]), t)), {})) } assembleSelectionTopLevelSignals(e) { return function (e, t) { let n = !1; if (mRe(e, ((r, i) => { const a = r.name, o = I_e(a + cRe), s = t.filter((e => e.name === a)); if (0 === s.length) { const e = "global" === r.resolve ? "union" : r.resolve, n = "multi" === r.type ? ", true)" : ")"; t.push({ name: r.name, update: `${fRe}(${o}, ${I_e(e)}${n}` }) } n = !0, i.topLevelSignals && (t = i.topLevelSignals(e, r, t)), Q$e(r, (n => { n.topLevelSignals && (t = n.topLevelSignals(e, r, t)) })) })), n) { const e = t.filter((e => "unit" === e.name)); 0 === e.length && t.unshift({ name: "unit", value: {}, on: [{ events: "mousemove", update: "isTuple(group()) ? group() : unit" }] }) } return nRe(t) }(this, e) } assembleSignals() { return [...XOe(this), ...(e = this, t = [], mRe(e, ((n, r) => { const i = n.name; let a = r.modifyExpr(e, n); t.push(...r.signals(e, n)), Q$e(n, (r => { r.signals && (t = r.signals(e, n, t)), r.modifyExpr && (a = r.modifyExpr(e, n, a)) })), t.push({ name: i + dRe, on: [{ events: { signal: n.name + hRe }, update: `modify(${I_e(n.name + cRe)}, ${a})` }] }) })), nRe(t))]; var e, t } assembleSelectionData(e) { return function (e, t) { const n = [...t]; return mRe(e, (t => { const r = { name: t.name + cRe }; if (t.init) { const n = t.project.items.map((e => { const { signals: t } = e; return F_e(e, ["signals"]) })), i = t.init.map((e => eRe(e, !1))); r.values = "interval" === t.type ? [{ unit: gRe(e, { escape: !1 }), fields: n, values: i }] : i.map((t => ({ unit: gRe(e, { escape: !1 }), fields: n, values: t }))) } n.filter((e => e.name === t.name + cRe)).length || n.push(r) })), n }(this, e) } assembleLayout() { return null } assembleLayoutSignals() { return Aze(this) } assembleMarks() { var e; let t = null !== (e = this.component.mark) && void 0 !== e ? e : []; return this.parent && ABe(this.parent) || (t = tRe(this, t)), t.map(this.correctDataNames) } getMapping() { return this.encoding } get mark() { return this.markDef.type } channelHasField(e) { return BMe(this.encoding, e) } fieldDef(e) { return pMe(this.encoding[e]) } typedFieldDef(e) { const t = this.fieldDef(e); return JIe(t) ? t : null } } class _Le extends TBe { constructor(e, t, n, r, i) { super(e, "layer", t, n, i, e.resolve, e.view); const a = Object.assign(Object.assign(Object.assign({}, r), e.width ? { width: e.width } : {}), e.height ? { height: e.height } : {}); this.children = e.layer.map(((e, t) => { if (VFe(e)) return new _Le(e, this, this.getName("layer_" + t), a, i); if (tAe(e)) return new SLe(e, this, this.getName("layer_" + t), a, i); throw new Error(sEe(e)) })) } parseData() { this.component.data = tLe(this); for (const e of this.children) e.parseData() } parseLayoutSize() { var e; YBe(e = this), XBe(e, "width"), XBe(e, "height") } parseSelections() { this.component.selection = {}; for (const e of this.children) { e.parseSelections(); for (const t of oCe(e.component.selection)) this.component.selection[t] = e.component.selection[t] } } parseMarkGroup() { for (const e of this.children) e.parseMarkGroup() } parseAxesAndHeaders() { !function (e) { var t; const { axes: n, resolve: r } = e.component, i = { top: 0, bottom: 0, right: 0, left: 0 }; for (const t of e.children) { t.parseAxesAndHeaders(); for (const i of oCe(t.component.axes)) r.axis[i] = Dze(e.component.resolve, i), "shared" === r.axis[i] && (n[i] = sLe(n[i], t.component.axes[i]), n[i] || (r.axis[i] = "independent", delete n[i])) } for (const a of FTe) { for (const o of e.children) if (o.component.axes[a]) { if ("independent" === r.axis[a]) { n[a] = (null !== (t = n[a]) && void 0 !== t ? t : []).concat(o.component.axes[a]); for (const e of o.component.axes[a]) { const { value: t, explicit: n } = e.getWithExplicit("orient"); if (!eNe(t)) { if (i[t] > 0 && !n) { const n = oLe[t]; i[t] > i[n] && e.set("orient", n, !1) } i[t]++ } } } delete o.component.axes[a] } if ("independent" === r.axis[a] && n[a] && n[a].length > 1) for (const e of n[a]) e.get("grid") && !e.explicit.grid && (e.implicit.grid = !1) } }(this) } assembleSelectionTopLevelSignals(e) { return this.children.reduce(((e, t) => t.assembleSelectionTopLevelSignals(e)), e) } assembleSignals() { return this.children.reduce(((e, t) => e.concat(t.assembleSignals())), XOe(this)) } assembleLayoutSignals() { return this.children.reduce(((e, t) => e.concat(t.assembleLayoutSignals())), Aze(this)) } assembleSelectionData(e) { return this.children.reduce(((e, t) => t.assembleSelectionData(e)), e) } assembleTitle() { let e = super.assembleTitle(); if (e) return e; for (const t of this.children) if (e = t.assembleTitle(), e) return e } assembleLayout() { return null } assembleMarks() { return function (e, t) { for (const n of e.children) SBe(n) && (t = tRe(n, t)); return t }(this, this.children.flatMap((e => e.assembleMarks()))) } assembleLegends() { return this.children.reduce(((e, t) => e.concat(t.assembleLegends())), Jze(this)) } } function CLe(e, t, n, r, i) { if (PIe(e)) return new JBe(e, t, n, i); if (VFe(e)) return new _Le(e, t, n, r, i); if (tAe(e)) return new SLe(e, t, n, r, i); if (function (e) { return CFe(e) || AFe(e) || _Fe(e) }(e)) return new nLe(e, t, n, i); throw new Error(sEe(e)) } function ALe(e, t = {}) { var n; t.logger && (n = t.logger, REe = n), t.fieldTitle && lMe(t.fieldTitle); try { const n = PFe(w_e(t.config, e.config)), r = fDe(e, n), i = CLe(r, null, "", void 0, n); i.parse(), function (e, t) { lPe(e.sources); let n = 0, r = 0; for (let r = 0; r < jPe && GPe(e, t); r++)n++; e.sources.map(FPe); for (let n = 0; n < jPe && GPe(e, t); n++)r++; lPe(e.sources), Math.max(n, r) === jPe && zEe(`Maximum optimization runs(${jPe}) reached.`) }(i.component.data, i); const a = function (e, t, n = {}, r) { const i = e.config ? UFe(e.config) : void 0, a = [].concat(e.assembleSelectionData([]), function (e, t) { var n, r; const i = [], a = UBe(i); let o = 0; for (const t of e.sources) { t.hasName() || (t.dataName = "source_" + o++); const e = t.assemble(); a(t, e) } for (const e of i) 0 === e.transform.length && delete e.transform; let s = 0; for (const [e, t] of i.entries()) 0 !== (null !== (n = t.transform) && void 0 !== n ? n : []).length || t.source || i.splice(s++, 0, i.splice(e, 1)[0]); for (const t of i) for (const n of null !== (r = t.transform) && void 0 !== r ? r : []) "lookup" === n.type && (n.from = e.outputNodes[n.from].getSource()); for (const e of i) e.name in t && (e.values = t[e.name]); return i }(e.component.data, n)), o = e.assembleProjections(), s = e.assembleTitle(), u = e.assembleGroupStyle(), l = e.assembleGroupEncodeEntry(!0); let c = e.assembleLayoutSignals(); return c = c.filter((e => "width" !== e.name && "height" !== e.name || void 0 === e.value || (t[e.name] = +e.value, !1))), Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ $schema: "https://vega.github.io/schema/vega/v5.json" }, e.description ? { description: e.description } : {}), t), s ? { title: s } : {}), u ? { style: u } : {}), l ? { encode: { update: l } } : {}), { data: a }), o.length > 0 ? { projections: o } : {}), e.assembleGroup([...c, ...e.assembleSelectionTopLevelSignals([])])), i ? { config: i } : {}), r ? { usermeta: r } : {}) }(i, function (e, t, n, r) { const i = r.component.layoutSize.get("width"), a = r.component.layoutSize.get("height"); void 0 === t ? (t = { type: "pad" }, r.hasAxisOrientSignalRef() && (t.resize = !0)) : N_e(t) && (t = { type: t }); if (i && a && (o = t.type, "fit" === o || "fit-x" === o || "fit-y" === o)) if ("step" === i && "step" === a) zEe(hEe()), t.type = "pad"; else if ("step" === i || "step" === a) { const e = "step" === i ? "width" : "height"; zEe(hEe(OTe(e))); const n = "width" === e ? "height" : "width"; t.type = function (e) { return e ? `fit-${OTe(e)}` : "fit" }(n) } var o; return Object.assign(Object.assign(Object.assign({}, 1 === oCe(t).length && t.type ? "pad" === t.type ? {} : { autosize: t.type } : { autosize: t }), yDe(n)), yDe(e)) }(e, r.autosize, n, i), e.datasets, e.usermeta); return { spec: a, normalized: r } } finally { t.logger && OEe(), t.fieldTitle && lMe(sMe) } } const TLe = new class extends GFe { mapUnit(e, { config: t }) { if (e.encoding) { const { encoding: n, transform: r } = e, { bins: i, timeUnits: a, aggregate: o, groupby: s, encoding: u } = jMe(n, t), l = [...r || [], ...i, ...a, ...0 === o.length ? [] : [{ aggregate: o, groupby: s }]]; return Object.assign(Object.assign(Object.assign({}, e), l.length > 0 ? { transform: l } : {}), { encoding: u }) } return e } }; function ELe(e, t) { return TLe.map(e, { config: t }) } const NLe = "4.13.1"; const ILe = function (e) { const [t, n] = /schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1, 3); return { library: t, version: n } }; var MLe = "2.15.0"; const FLe = "#fff", DLe = "#888", $Le = { background: "#333", view: { stroke: DLe }, title: { color: FLe, subtitleColor: FLe }, style: { "guide-label": { fill: FLe }, "guide-title": { fill: FLe } }, axis: { domainColor: FLe, gridColor: DLe, tickColor: FLe } }, RLe = "#4572a7", OLe = { background: "#fff", arc: { fill: RLe }, area: { fill: RLe }, line: { stroke: RLe, strokeWidth: 2 }, path: { stroke: RLe }, rect: { fill: RLe }, shape: { stroke: RLe }, symbol: { fill: RLe, strokeWidth: 1.5, size: 50 }, axis: { bandPosition: .5, grid: !0, gridColor: "#000000", gridOpacity: 1, gridWidth: .5, labelPadding: 10, tickSize: 5, tickWidth: .5 }, axisBand: { grid: !1, tickExtra: !0 }, legend: { labelBaseline: "middle", labelFontSize: 11, symbolSize: 50, symbolType: "square" }, range: { category: ["#4572a7", "#aa4643", "#8aa453", "#71598e", "#4598ae", "#d98445", "#94aace", "#d09393", "#b9cc98", "#a99cbc"] } }, zLe = "#30a2da", PLe = "#cbcbcb", BLe = "#f0f0f0", LLe = "#333", jLe = { arc: { fill: zLe }, area: { fill: zLe }, axis: { domainColor: PLe, grid: !0, gridColor: PLe, gridWidth: 1, labelColor: "#999", labelFontSize: 10, titleColor: "#333", tickColor: PLe, tickSize: 10, titleFontSize: 14, titlePadding: 10, labelPadding: 4 }, axisBand: { grid: !1 }, background: BLe, group: { fill: BLe }, legend: { labelColor: LLe, labelFontSize: 11, padding: 1, symbolSize: 30, symbolType: "square", titleColor: LLe, titleFontSize: 14, titlePadding: 10 }, line: { stroke: zLe, strokeWidth: 2 }, path: { stroke: zLe, strokeWidth: .5 }, rect: { fill: zLe }, range: { category: ["#30a2da", "#fc4f30", "#e5ae38", "#6d904f", "#8b8b8b", "#b96db8", "#ff9e27", "#56cc60", "#52d2ca", "#52689e", "#545454", "#9fe4f8"], diverging: ["#cc0020", "#e77866", "#f6e7e1", "#d6e8ed", "#91bfd9", "#1d78b5"], heatmap: ["#d6e8ed", "#cee0e5", "#91bfd9", "#549cc6", "#1d78b5"] }, point: { filled: !0, shape: "circle" }, shape: { stroke: zLe }, bar: { binSpacing: 2, fill: zLe, stroke: null }, title: { anchor: "start", fontSize: 24, fontWeight: 600, offset: 20 } }, ULe = "#000", WLe = { group: { fill: "#e5e5e5" }, arc: { fill: ULe }, area: { fill: ULe }, line: { stroke: ULe }, path: { stroke: ULe }, rect: { fill: ULe }, shape: { stroke: ULe }, symbol: { fill: ULe, size: 40 }, axis: { domain: !1, grid: !0, gridColor: "#FFFFFF", gridOpacity: 1, labelColor: "#7F7F7F", labelPadding: 4, tickColor: "#7F7F7F", tickSize: 5.67, titleFontSize: 16, titleFontWeight: "normal" }, legend: { labelBaseline: "middle", labelFontSize: 11, symbolSize: 40 }, range: { category: ["#000000", "#7F7F7F", "#1A1A1A", "#999999", "#333333", "#B0B0B0", "#4D4D4D", "#C9C9C9", "#666666", "#DCDCDC"] } }, VLe = "Benton Gothic, sans-serif", GLe = "#82c6df", HLe = "Benton Gothic Bold, sans-serif", qLe = "normal", YLe = { "category-6": ["#ec8431", "#829eb1", "#c89d29", "#3580b1", "#adc839", "#ab7fb4"], "fire-7": ["#fbf2c7", "#f9e39c", "#f8d36e", "#f4bb6a", "#e68a4f", "#d15a40", "#ab4232"], "fireandice-6": ["#e68a4f", "#f4bb6a", "#f9e39c", "#dadfe2", "#a6b7c6", "#849eae"], "ice-7": ["#edefee", "#dadfe2", "#c4ccd2", "#a6b7c6", "#849eae", "#607785", "#47525d"] }, XLe = { background: "#ffffff", title: { anchor: "start", color: "#000000", font: HLe, fontSize: 22, fontWeight: "normal" }, arc: { fill: GLe }, area: { fill: GLe }, line: { stroke: GLe, strokeWidth: 2 }, path: { stroke: GLe }, rect: { fill: GLe }, shape: { stroke: GLe }, symbol: { fill: GLe, size: 30 }, axis: { labelFont: VLe, labelFontSize: 11.5, labelFontWeight: "normal", titleFont: HLe, titleFontSize: 13, titleFontWeight: qLe }, axisX: { labelAngle: 0, labelPadding: 4, tickSize: 3 }, axisY: { labelBaseline: "middle", maxExtent: 45, minExtent: 45, tickSize: 2, titleAlign: "left", titleAngle: 0, titleX: -45, titleY: -11 }, legend: { labelFont: VLe, labelFontSize: 11.5, symbolType: "square", titleFont: HLe, titleFontSize: 13, titleFontWeight: qLe }, range: { category: YLe["category-6"], diverging: YLe["fireandice-6"], heatmap: YLe["fire-7"], ordinal: YLe["fire-7"], ramp: YLe["fire-7"] } }, KLe = "#ab5787", ZLe = "#979797", JLe = { background: "#f9f9f9", arc: { fill: KLe }, area: { fill: KLe }, line: { stroke: KLe }, path: { stroke: KLe }, rect: { fill: KLe }, shape: { stroke: KLe }, symbol: { fill: KLe, size: 30 }, axis: { domainColor: ZLe, domainWidth: .5, gridWidth: .2, labelColor: ZLe, tickColor: ZLe, tickWidth: .2, titleColor: ZLe }, axisBand: { grid: !1 }, axisX: { grid: !0, tickSize: 10 }, axisY: { domain: !1, grid: !0, tickSize: 0 }, legend: { labelFontSize: 11, padding: 1, symbolSize: 30, symbolType: "square" }, range: { category: ["#ab5787", "#51b2e5", "#703c5c", "#168dd9", "#d190b6", "#00609f", "#d365ba", "#154866", "#666666", "#c4c4c4"] } }, QLe = "#3e5c69", eje = { background: "#fff", arc: { fill: QLe }, area: { fill: QLe }, line: { stroke: QLe }, path: { stroke: QLe }, rect: { fill: QLe }, shape: { stroke: QLe }, symbol: { fill: QLe }, axis: { domainWidth: .5, grid: !0, labelPadding: 2, tickSize: 5, tickWidth: .5, titleFontWeight: "normal" }, axisBand: { grid: !1 }, axisX: { gridWidth: .2 }, axisY: { gridDash: [3], gridWidth: .4 }, legend: { labelFontSize: 11, padding: 1, symbolType: "square" }, range: { category: ["#3e5c69", "#6793a6", "#182429", "#0570b0", "#3690c0", "#74a9cf", "#a6bddb", "#e2ddf2"] } }, tje = "#1696d2", nje = "#000000", rje = "Lato", ije = "Lato", aje = { "main-colors": ["#1696d2", "#d2d2d2", "#000000", "#fdbf11", "#ec008b", "#55b748", "#5c5859", "#db2b27"], "shades-blue": ["#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"], "shades-gray": ["#F5F5F5", "#ECECEC", "#E3E3E3", "#DCDBDB", "#D2D2D2", "#9D9D9D", "#696969", "#353535"], "shades-yellow": ["#FFF2CF", "#FCE39E", "#FDD870", "#FCCB41", "#FDBF11", "#E88E2D", "#CA5800", "#843215"], "shades-magenta": ["#F5CBDF", "#EB99C2", "#E46AA7", "#E54096", "#EC008B", "#AF1F6B", "#761548", "#351123"], "shades-green": ["#DCEDD9", "#BCDEB4", "#98CF90", "#78C26D", "#55B748", "#408941", "#2C5C2D", "#1A2E19"], "shades-black": ["#D5D5D4", "#ADABAC", "#848081", "#5C5859", "#332D2F", "#262223", "#1A1717", "#0E0C0D"], "shades-red": ["#F8D5D4", "#F1AAA9", "#E9807D", "#E25552", "#DB2B27", "#A4201D", "#6E1614", "#370B0A"], "one-group": ["#1696d2", "#000000"], "two-groups-cat-1": ["#1696d2", "#000000"], "two-groups-cat-2": ["#1696d2", "#fdbf11"], "two-groups-cat-3": ["#1696d2", "#db2b27"], "two-groups-seq": ["#a2d4ec", "#1696d2"], "three-groups-cat": ["#1696d2", "#fdbf11", "#000000"], "three-groups-seq": ["#a2d4ec", "#1696d2", "#0a4c6a"], "four-groups-cat-1": ["#000000", "#d2d2d2", "#fdbf11", "#1696d2"], "four-groups-cat-2": ["#1696d2", "#ec0008b", "#fdbf11", "#5c5859"], "four-groups-seq": ["#cfe8f3", "#73bf42", "#1696d2", "#0a4c6a"], "five-groups-cat-1": ["#1696d2", "#fdbf11", "#d2d2d2", "#ec008b", "#000000"], "five-groups-cat-2": ["#1696d2", "#0a4c6a", "#d2d2d2", "#fdbf11", "#332d2f"], "five-groups-seq": ["#cfe8f3", "#73bf42", "#1696d2", "#0a4c6a", "#000000"], "six-groups-cat-1": ["#1696d2", "#ec008b", "#fdbf11", "#000000", "#d2d2d2", "#55b748"], "six-groups-cat-2": ["#1696d2", "#d2d2d2", "#ec008b", "#fdbf11", "#332d2f", "#0a4c6a"], "six-groups-seq": ["#cfe8f3", "#a2d4ec", "#73bfe2", "#46abdb", "#1696d2", "#12719e"], "diverging-colors": ["#ca5800", "#fdbf11", "#fdd870", "#fff2cf", "#cfe8f3", "#73bfe2", "#1696d2", "#0a4c6a"] }, oje = { background: "#FFFFFF", title: { anchor: "start", fontSize: 18, font: rje }, axisX: { domain: !0, domainColor: nje, domainWidth: 1, grid: !1, labelFontSize: 12, labelFont: ije, labelAngle: 0, tickColor: nje, tickSize: 5, titleFontSize: 12, titlePadding: 10, titleFont: rje }, axisY: { domain: !1, domainWidth: 1, grid: !0, gridColor: "#DEDDDD", gridWidth: 1, labelFontSize: 12, labelFont: ije, labelPadding: 8, ticks: !1, titleFontSize: 12, titlePadding: 10, titleFont: rje, titleAngle: 0, titleY: -10, titleX: 18 }, legend: { labelFontSize: 12, labelFont: ije, symbolSize: 100, titleFontSize: 12, titlePadding: 10, titleFont: rje, orient: "right", offset: 10 }, view: { stroke: "transparent" }, range: { category: aje["six-groups-cat-1"], diverging: aje["diverging-colors"], heatmap: aje["diverging-colors"], ordinal: aje["six-groups-seq"], ramp: aje["shades-blue"] }, area: { fill: tje }, rect: { fill: tje }, line: { color: tje, stroke: tje, strokeWidth: 5 }, trail: { color: tje, stroke: tje, strokeWidth: 0, size: 1 }, path: { stroke: tje, strokeWidth: .5 }, point: { filled: !0 }, text: { font: "Lato", color: tje, fontSize: 11, align: "center", fontWeight: 400, size: 11 }, style: { bar: { fill: tje, stroke: null } }, arc: { fill: tje }, shape: { stroke: tje }, symbol: { fill: tje, size: 30 } }, sje = "#3366CC", uje = "#ccc", lje = "Arial, sans-serif", cje = { arc: { fill: sje }, area: { fill: sje }, path: { stroke: sje }, rect: { fill: sje }, shape: { stroke: sje }, symbol: { stroke: sje }, circle: { fill: sje }, background: "#fff", padding: { top: 10, right: 10, bottom: 10, left: 10 }, style: { "guide-label": { font: lje, fontSize: 12 }, "guide-title": { font: lje, fontSize: 12 }, "group-title": { font: lje, fontSize: 12 } }, title: { font: lje, fontSize: 14, fontWeight: "bold", dy: -3, anchor: "start" }, axis: { gridColor: uje, tickColor: uje, domain: !1, grid: !0 }, range: { category: ["#4285F4", "#DB4437", "#F4B400", "#0F9D58", "#AB47BC", "#00ACC1", "#FF7043", "#9E9D24", "#5C6BC0", "#F06292", "#00796B", "#C2185B"], heatmap: ["#c6dafc", "#5e97f6", "#2a56c6"] } }, hje = e => e * (1 / 3 + 1), dje = hje(9), fje = hje(10), pje = hje(12), mje = "Segoe UI", gje = "wf_standard-font, helvetica, arial, sans-serif", yje = "#252423", bje = "#605E5C", vje = "transparent", xje = "#118DFF", wje = "#DEEFFF", kje = [wje, xje], Sje = { view: { stroke: vje }, background: vje, font: mje, header: { titleFont: gje, titleFontSize: pje, titleColor: yje, labelFont: mje, labelFontSize: fje, labelColor: bje }, axis: { ticks: !1, grid: !1, domain: !1, labelColor: bje, labelFontSize: dje, titleFont: gje, titleColor: yje, titleFontSize: pje, titleFontWeight: "normal" }, axisQuantitative: { tickCount: 3, grid: !0, gridColor: "#C8C6C4", gridDash: [1, 5], labelFlush: !1 }, axisBand: { tickExtra: !0 }, axisX: { labelPadding: 5 }, axisY: { labelPadding: 10 }, bar: { fill: xje }, line: { stroke: xje, strokeWidth: 3, strokeCap: "round", strokeJoin: "round" }, text: { font: mje, fontSize: dje, fill: bje }, arc: { fill: xje }, area: { fill: xje, line: !0, opacity: .6 }, path: { stroke: xje }, rect: { fill: xje }, point: { fill: xje, filled: !0, size: 75 }, shape: { stroke: xje }, symbol: { fill: xje, strokeWidth: 1.5, size: 50 }, legend: { titleFont: mje, titleFontWeight: "bold", titleColor: bje, labelFont: mje, labelFontSize: fje, labelColor: bje, symbolType: "circle", symbolSize: 75 }, range: { category: [xje, "#12239E", "#E66C37", "#6B007B", "#E044A7", "#744EC2", "#D9B300", "#D64550"], diverging: kje, heatmap: kje, ordinal: [wje, "#c7e4ff", "#b0d9ff", "#9aceff", "#83c3ff", "#6cb9ff", "#55aeff", "#3fa3ff", "#2898ff", xje] } }, _je = 'IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif', Cje = { textPrimary: { g90: "#f4f4f4", g100: "#f4f4f4", white: "#161616", g10: "#161616" }, textSecondary: { g90: "#c6c6c6", g100: "#c6c6c6", white: "#525252", g10: "#525252" }, layerAccent01: { white: "#e0e0e0", g10: "#e0e0e0", g90: "#525252", g100: "#393939" }, gridBg: { white: "#ffffff", g10: "#ffffff", g90: "#161616", g100: "#161616" } }, Aje = ["#8a3ffc", "#33b1ff", "#007d79", "#ff7eb6", "#fa4d56", "#fff1f1", "#6fdc8c", "#4589ff", "#d12771", "#d2a106", "#08bdba", "#bae6ff", "#ba4e00", "#d4bbff"], Tje = ["#6929c4", "#1192e8", "#005d5d", "#9f1853", "#fa4d56", "#570408", "#198038", "#002d9c", "#ee538b", "#b28600", "#009d9a", "#012749", "#8a3800", "#a56eff"]; function Eje({ theme: e, background: t }) { const n = ["white", "g10"].includes(e) ? "light" : "dark", r = Cje.gridBg[e], i = Cje.textPrimary[e], a = Cje.textSecondary[e], o = "dark" === n ? Aje : Tje, s = "dark" === n ? "#d4bbff" : "#6929c4"; return { background: t, arc: { fill: s }, area: { fill: s }, path: { stroke: s }, rect: { fill: s }, shape: { stroke: s }, symbol: { stroke: s }, circle: { fill: s }, view: { fill: r, stroke: r }, group: { fill: r }, title: { color: i, anchor: "start", dy: -15, fontSize: 16, font: _je, fontWeight: 600 }, axis: { labelColor: a, labelFontSize: 12, labelFont: 'IBM Plex Sans Condensed, system-ui, -apple-system, BlinkMacSystemFont, ".SFNSText-Regular", sans-serif', labelFontWeight: 400, titleColor: i, titleFontWeight: 600, titleFontSize: 12, grid: !0, gridColor: Cje.layerAccent01[e], labelAngle: 0 }, axisX: { titlePadding: 10 }, axisY: { titlePadding: 2.5 }, style: { "guide-label": { font: _je, fill: a, fontWeight: 400 }, "guide-title": { font: _je, fill: a, fontWeight: 400 } }, range: { category: o, diverging: ["#750e13", "#a2191f", "#da1e28", "#fa4d56", "#ff8389", "#ffb3b8", "#ffd7d9", "#fff1f1", "#e5f6ff", "#bae6ff", "#82cfff", "#33b1ff", "#1192e8", "#0072c3", "#00539a", "#003a6d"], heatmap: ["#f6f2ff", "#e8daff", "#d4bbff", "#be95ff", "#a56eff", "#8a3ffc", "#6929c4", "#491d8b", "#31135e", "#1c0f30"] } } } const Nje = Eje({ theme: "white", background: "#ffffff" }), Ije = Eje({ theme: "g10", background: "#f4f4f4" }), Mje = Eje({ theme: "g90", background: "#262626" }), Fje = Eje({ theme: "g100", background: "#161616" }), Dje = MLe; var $je = "#vg-tooltip-element {\n visibility: hidden;\n padding: 8px;\n position: fixed;\n z-index: 1000;\n font-family: sans-serif;\n font-size: 11px;\n border-radius: 3px;\n box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);\n /* The default theme is the light theme. */\n background-color: rgba(255, 255, 255, 0.95);\n border: 1px solid #d9d9d9;\n color: black; }\n #vg-tooltip-element.visible {\n visibility: visible; }\n #vg-tooltip-element h2 {\n margin-top: 0;\n margin-bottom: 10px;\n font-size: 13px; }\n #vg-tooltip-element img {\n max-width: 200px;\n max-height: 200px; }\n #vg-tooltip-element table {\n border-spacing: 0; }\n #vg-tooltip-element table tr {\n border: none; }\n #vg-tooltip-element table tr td {\n overflow: hidden;\n text-overflow: ellipsis;\n padding-top: 2px;\n padding-bottom: 2px; }\n #vg-tooltip-element table tr td.key {\n color: #808080;\n max-width: 150px;\n text-align: right;\n padding-right: 4px; }\n #vg-tooltip-element table tr td.value {\n display: block;\n max-width: 300px;\n max-height: 7em;\n text-align: left; }\n #vg-tooltip-element.dark-theme {\n background-color: rgba(32, 32, 32, 0.9);\n border: 1px solid #f5f5f5;\n color: white; }\n #vg-tooltip-element.dark-theme td.key {\n color: #bfbfbf; }\n"; const Rje = "vg-tooltip-element", Oje = { offsetX: 10, offsetY: 10, id: Rje, styleId: "vega-tooltip-style", theme: "light", disableDefaultStyle: !1, sanitize: function (e) { return String(e).replace(/&/g, "&").replace(/ t(Vn(e) ? e : Pje(e, n)))).join(", ")}]`; if (sn(e)) { + let r = ""; const i = e, { title: a, image: o } = i, s = + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + function (e, t) { var n = {}; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (null != e && "function" == typeof Object.getOwnPropertySymbols) { var i = 0; for (r = Object.getOwnPropertySymbols(e); i < r.length; i++)t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]) } return n }(i, ["title", "image"]); a && (r += `

${t(a)}

`), o && (r += ``); const u = Object.keys(s); if (u.length > 0) { r += ""; for (const e of u) { let i = s[e]; void 0 !== i && (sn(i) && (i = Pje(i, n)), r += ``) } r += "
${t(e)}:${t(i)}
" } return r || "{}" + } return t(e) + } function Pje(e, t) { return JSON.stringify(e, function (e) { const t = []; return function (n, r) { if ("object" != typeof r || null === r) return r; const i = t.indexOf(this) + 1; return t.length = i, t.length > e ? "[Object]" : t.indexOf(r) >= 0 ? "[Circular]" : (t.push(r), r) } }(t)) } class Bje { constructor(e) { this.options = Object.assign(Object.assign({}, Oje), e); const t = this.options.id; if (this.el = null, this.call = this.tooltipHandler.bind(this), !this.options.disableDefaultStyle && !document.getElementById(this.options.styleId)) { const e = document.createElement("style"); e.setAttribute("id", this.options.styleId), e.innerHTML = function (e) { if (!/^[A-Za-z]+[-:.\w]*$/.test(e)) throw new Error("Invalid HTML ID"); return $je.toString().replace(Rje, e) }(t); const n = document.head; n.childNodes.length > 0 ? n.insertBefore(e, n.childNodes[0]) : n.appendChild(e) } } tooltipHandler(e, t, n, r) { this.el = document.getElementById(this.options.id), this.el || (this.el = document.createElement("div"), this.el.setAttribute("id", this.options.id), this.el.classList.add("vg-tooltip"), document.body.appendChild(this.el)); if ((null != document.fullscreenElement ? document.fullscreenElement : document.body).appendChild(this.el), null == r || "" === r) return void this.el.classList.remove("visible", `${this.options.theme}-theme`); this.el.innerHTML = zje(r, this.options.sanitize, this.options.maxDepth), this.el.classList.add("visible", `${this.options.theme}-theme`); const { x: i, y: a } = function (e, t, n, r) { let i = e.clientX + n; i + t.width > window.innerWidth && (i = +e.clientX - n - t.width); let a = e.clientY + r; return a + t.height > window.innerHeight && (a = +e.clientY - r - t.height), { x: i, y: a } }(t, this.el.getBoundingClientRect(), this.options.offsetX, this.options.offsetY); this.el.setAttribute("style", `top: ${a}px; left: ${i}px`) } } + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + function Lje(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : function (e) { return e instanceof n ? e : new n((function (t) { t(e) })) }(e.value).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } var jje, Uje = '.vega-embed {\n position: relative;\n display: inline-block;\n box-sizing: border-box; }\n .vega-embed.has-actions {\n padding-right: 38px; }\n .vega-embed details:not([open]) > :not(summary) {\n display: none !important; }\n .vega-embed summary {\n list-style: none;\n position: absolute;\n top: 0;\n right: 0;\n padding: 6px;\n z-index: 1000;\n background: white;\n box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);\n color: #1b1e23;\n border: 1px solid #aaa;\n border-radius: 999px;\n opacity: 0.2;\n transition: opacity 0.4s ease-in;\n outline: none;\n cursor: pointer;\n line-height: 0px; }\n .vega-embed summary::-webkit-details-marker {\n display: none; }\n .vega-embed summary:active {\n box-shadow: #aaa 0px 0px 0px 1px inset; }\n .vega-embed summary svg {\n width: 14px;\n height: 14px; }\n .vega-embed details[open] summary {\n opacity: 0.7; }\n .vega-embed:hover summary,\n .vega-embed:focus summary {\n opacity: 1 !important;\n transition: opacity 0.2s ease; }\n .vega-embed .vega-actions {\n position: absolute;\n z-index: 1001;\n top: 35px;\n right: -9px;\n display: flex;\n flex-direction: column;\n padding-bottom: 8px;\n padding-top: 8px;\n border-radius: 4px;\n box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);\n border: 1px solid #d9d9d9;\n background: white;\n animation-duration: 0.15s;\n animation-name: scale-in;\n animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5);\n text-align: left; }\n .vega-embed .vega-actions a {\n padding: 8px 16px;\n font-family: sans-serif;\n font-size: 14px;\n font-weight: 600;\n white-space: nowrap;\n color: #434a56;\n text-decoration: none; }\n .vega-embed .vega-actions a:hover {\n background-color: #f7f7f9;\n color: black; }\n .vega-embed .vega-actions::before, .vega-embed .vega-actions::after {\n content: "";\n display: inline-block;\n position: absolute; }\n .vega-embed .vega-actions::before {\n left: auto;\n right: 14px;\n top: -16px;\n border: 8px solid #0000;\n border-bottom-color: #d9d9d9; }\n .vega-embed .vega-actions::after {\n left: auto;\n right: 15px;\n top: -14px;\n border: 7px solid #0000;\n border-bottom-color: #fff; }\n .vega-embed .chart-wrapper {\n width: 100%;\n height: 100%; }\n\n.vega-embed-wrapper {\n max-width: 100%;\n overflow: auto;\n padding-right: 14px; }\n\n@keyframes scale-in {\n from {\n opacity: 0;\n transform: scale(0.6); }\n to {\n opacity: 1;\n transform: scale(1); } }\n'; function Wje(e, ...t) { for (const n of t) Vje(e, n); return e } function Vje(e, t) { for (const n of Object.keys(t)) Ee(e, n, t[n], !0) } String.prototype.startsWith || (String.prototype.startsWith = function (e, t) { return this.substr(!t || t < 0 ? 0 : +t, e.length) === e }); const Gje = x; let Hje = w; const qje = "undefined" != typeof window ? window : void 0; void 0 === Hje && (null === (jje = null == qje ? void 0 : qje.vl) || void 0 === jje ? void 0 : jje.compile) && (Hje = qje.vl); const Yje = { export: { svg: !0, png: !0 }, source: !0, compiled: !0, editor: !0 }, Xje = { CLICK_TO_VIEW_ACTIONS: "Click to view actions", COMPILED_ACTION: "View Compiled Vega", EDITOR_ACTION: "Open in Vega Editor", PNG_ACTION: "Save as PNG", SOURCE_ACTION: "View Source", SVG_ACTION: "Save as SVG" }, Kje = { vega: "Vega", "vega-lite": "Vega-Lite" }, Zje = { vega: Gje.version, "vega-lite": Hje ? Hje.version : "not available" }, Jje = { vega: e => e, "vega-lite": (e, t) => Hje.compile(e, { config: t }).spec }, Qje = '\n\n \n \n \n', eUe = "chart-wrapper"; function tUe(e, t, n, r) { const i = `${t}
`, a = `
${n}`, o = window.open(""); o.document.write(i + e + a), o.document.title = `${Kje[r]} JSON Source` } function nUe(e, t) { var n; if (e.$schema) { const r = ILe(e.$schema); t && t !== r.library && console.warn(`The given visualization spec is written in ${Kje[r.library]}, but mode argument sets ${null !== (n = Kje[t]) && void 0 !== n ? n : t}.`); const i = r.library; return (0, te.satisfies)(Zje[i], `^${r.version.slice(1)}`) || console.warn(`The input spec uses ${Kje[i]} ${r.version}, but the current version of ${Kje[i]} is v${Zje[i]}.`), i } return "mark" in e || "encoding" in e || "layer" in e || "hconcat" in e || "vconcat" in e || "facet" in e || "repeat" in e ? "vega-lite" : "marks" in e || "signals" in e || "scales" in e || "axes" in e ? "vega" : null != t ? t : "vega" } function rUe(e) { return (t = e) && "load" in t ? e : Gje.loader(e); var t } function iUe(e) { var t; return null !== (t = e.usermeta && e.usermeta.embedOptions) && void 0 !== t ? t : {} } function aUe(e, t) { var n; return Lje(this, void 0, void 0, (function* () { const r = wt(e.config) ? JSON.parse(yield t.load(e.config)) : null !== (n = e.config) && void 0 !== n ? n : {}, i = wt(e.patch) ? JSON.parse(yield t.load(e.patch)) : e.patch; return Object.assign(Object.assign(Object.assign({}, e), i ? { patch: i } : {}), r ? { config: r } : {}) })) } const oUe = function (e, t, n = {}) { var r, i, a; return Lje(this, void 0, void 0, (function* () { let o, s; wt(t) ? (s = rUe(n.loader), o = JSON.parse(yield s.load(t))) : o = t; const u = iUe(o).loader; s && !u || (s = rUe(null !== (r = n.loader) && void 0 !== r ? r : u)); const l = yield aUe(iUe(o), s), c = yield aUe(n, s), h = Object.assign(Object.assign({}, Wje(c, l)), { config: Te(null !== (i = c.config) && void 0 !== i ? i : {}, null !== (a = l.config) && void 0 !== a ? a : {}) }); return yield function (e, t, n = {}, r) { var i, a, o, s, u, l; return Lje(this, void 0, void 0, (function* () { const c = n.theme ? Te(k[n.theme], null !== (i = n.config) && void 0 !== i ? i : {}) : n.config, h = gt(n.actions) ? n.actions : Wje({}, Yje, null !== (a = n.actions) && void 0 !== a ? a : {}), d = Object.assign(Object.assign({}, Xje), n.i18n), f = null !== (o = n.renderer) && void 0 !== o ? o : "canvas", p = null !== (s = n.logLevel) && void 0 !== s ? s : Gje.Warn, m = null !== (u = n.downloadFileName) && void 0 !== u ? u : "visualization", g = "string" == typeof e ? document.querySelector(e) : e; if (!g) throw new Error(`${e} does not exist`); if (!1 !== n.defaultStyle) { const e = "vega-embed-style", { root: t, rootContainer: r } = function (e) { var t; const n = e.getRootNode ? e.getRootNode() : document; return n instanceof ShadowRoot ? { root: n, rootContainer: n } : { root: document, rootContainer: null !== (t = document.head) && void 0 !== t ? t : document.body } }(g); if (!t.getElementById(e)) { const t = document.createElement("style"); t.id = e, t.innerText = void 0 === n.defaultStyle || !0 === n.defaultStyle ? Uje.toString() : n.defaultStyle, r.appendChild(t) } } const y = nUe(t, n.mode); let b = Jje[y](t, c); if ("vega-lite" === y && b.$schema) { const e = ILe(b.$schema); (0, te.satisfies)(Zje.vega, `^${e.version.slice(1)}`) || console.warn(`The compiled spec uses Vega ${e.version}, but current version is v${Zje.vega}.`) } g.classList.add("vega-embed"), h && g.classList.add("has-actions"), g.innerHTML = ""; let v = g; if (h) { const e = document.createElement("div"); e.classList.add(eUe), g.appendChild(e), v = e } const x = n.patch; x && (b = x instanceof Function ? x(b) : L(b, x, !0, !1).newDocument), n.formatLocale && Gje.formatLocale(n.formatLocale), n.timeFormatLocale && Gje.timeFormatLocale(n.timeFormatLocale); const { ast: w } = n, S = Gje.parse(b, "vega-lite" === y ? {} : c, { ast: w }), _ = new (n.viewClass || Gje.View)(S, Object.assign({ loader: r, logLevel: p, renderer: f }, w ? { expr: Gje.expressionInterpreter } : {})); if (!1 !== n.tooltip) { let e; e = function (e) { return "function" == typeof e }(n.tooltip) ? n.tooltip : new Bje(!0 === n.tooltip ? {} : n.tooltip).call, _.tooltip(e) } let C, { hover: A } = n; if (void 0 === A && (A = "vega" === y), A) { const { hoverSet: e, updateSet: t } = "boolean" == typeof A ? {} : A; _.hover(e, t) } if (n && (null != n.width && _.width(n.width), null != n.height && _.height(n.height), null != n.padding && _.padding(n.padding)), yield _.initialize(v, n.bind).runAsync(), !1 !== h) { let e = g; if (!1 !== n.defaultStyle) { const t = document.createElement("details"); t.title = d.CLICK_TO_VIEW_ACTIONS, g.append(t), e = t; const n = document.createElement("summary"); n.innerHTML = Qje, t.append(n), C = e => { t.contains(e.target) || t.removeAttribute("open") }, document.addEventListener("click", C) } const r = document.createElement("div"); if (e.append(r), r.classList.add("vega-actions"), !0 === h || !1 !== h.export) for (const e of ["svg", "png"]) if (!0 === h || !0 === h.export || h.export[e]) { const t = d[`${e.toUpperCase()}_ACTION`], i = document.createElement("a"); i.text = t, i.href = "#", i.target = "_blank", i.download = `${m}.${e}`, i.addEventListener("mousedown", (function (t) { return Lje(this, void 0, void 0, (function* () { t.preventDefault(); const r = yield _.toImageURL(e, n.scaleFactor); this.href = r })) })), r.append(i) } if (!0 === h || !1 !== h.source) { const e = document.createElement("a"); e.text = d.SOURCE_ACTION, e.href = "#", e.addEventListener("click", (function (e) { var r, i; tUe(ee()(t), null !== (r = n.sourceHeader) && void 0 !== r ? r : "", null !== (i = n.sourceFooter) && void 0 !== i ? i : "", y), e.preventDefault() })), r.append(e) } if ("vega-lite" === y && (!0 === h || !1 !== h.compiled)) { const e = document.createElement("a"); e.text = d.COMPILED_ACTION, e.href = "#", e.addEventListener("click", (function (e) { var t, r; tUe(ee()(b), null !== (t = n.sourceHeader) && void 0 !== t ? t : "", null !== (r = n.sourceFooter) && void 0 !== r ? r : "", "vega"), e.preventDefault() })), r.append(e) } if (!0 === h || !1 !== h.editor) { const e = null !== (l = n.editorUrl) && void 0 !== l ? l : "https://vega.github.io/editor/", i = document.createElement("a"); i.text = d.EDITOR_ACTION, i.href = "#", i.addEventListener("click", (function (n) { !function (e, t, n) { const r = e.open(t), { origin: i } = new URL(t); let a = 40; e.addEventListener("message", (function t(n) { n.source === r && (a = 0, e.removeEventListener("message", t, !1)) }), !1), setTimeout((function e() { a <= 0 || (r.postMessage(n, i), setTimeout(e, 250), a -= 1) }), 250) }(window, e, { config: c, mode: y, renderer: f, spec: ee()(t) }), n.preventDefault() })), r.append(i) } } function T() { C && document.removeEventListener("click", C), _.finalize() } return { view: _, spec: t, vgSpec: b, finalize: T } })) }(e, o, h, s) })) } + }, 147: (e, t, n) => { const r = Symbol("SemVer ANY"); class i { static get ANY() { return r } constructor(e, t) { if (t = a(t), e instanceof i) { if (e.loose === !!t.loose) return e; e = e.value } e = e.trim().split(/\s+/).join(" "), l("comparator", e, t), this.options = t, this.loose = !!t.loose, this.parse(e), this.semver === r ? this.value = "" : this.value = this.operator + this.semver.version, l("comp", this) } parse(e) { const t = this.options.loose ? o[s.COMPARATORLOOSE] : o[s.COMPARATOR], n = e.match(t); if (!n) throw new TypeError(`Invalid comparator: ${e}`); this.operator = void 0 !== n[1] ? n[1] : "", "=" === this.operator && (this.operator = ""), n[2] ? this.semver = new c(n[2], this.options.loose) : this.semver = r } toString() { return this.value } test(e) { if (l("Comparator.test", e, this.options.loose), this.semver === r || e === r) return !0; if ("string" == typeof e) try { e = new c(e, this.options) } catch (e) { return !1 } return u(e, this.operator, this.semver, this.options) } intersects(e, t) { if (!(e instanceof i)) throw new TypeError("a Comparator is required"); return "" === this.operator ? "" === this.value || new h(e.value, t).test(this.value) : "" === e.operator ? "" === e.value || new h(this.value, t).test(e.semver) : (!(t = a(t)).includePrerelease || "<0.0.0-0" !== this.value && "<0.0.0-0" !== e.value) && (!(!t.includePrerelease && (this.value.startsWith("<0.0.0") || e.value.startsWith("<0.0.0"))) && (!(!this.operator.startsWith(">") || !e.operator.startsWith(">")) || (!(!this.operator.startsWith("<") || !e.operator.startsWith("<")) || (!(this.semver.version !== e.semver.version || !this.operator.includes("=") || !e.operator.includes("=")) || (!!(u(this.semver, "<", e.semver, t) && this.operator.startsWith(">") && e.operator.startsWith("<")) || !!(u(this.semver, ">", e.semver, t) && this.operator.startsWith("<") && e.operator.startsWith(">"))))))) } } e.exports = i; const a = n(8324), { safeRe: o, t: s } = n(6063), u = n(4806), l = n(9847), c = n(6283), h = n(2894) }, 2894: (e, t, n) => { const r = /\s+/g; class i { constructor(e, t) { if (t = o(t), e instanceof i) return e.loose === !!t.loose && e.includePrerelease === !!t.includePrerelease ? e : new i(e.raw, t); if (e instanceof s) return this.raw = e.value, this.set = [[e]], this.formatted = void 0, this; if (this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease, this.raw = e.trim().replace(r, " "), this.set = this.raw.split("||").map((e => this.parseRange(e.trim()))).filter((e => e.length)), !this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`); if (this.set.length > 1) { const e = this.set[0]; if (this.set = this.set.filter((e => !y(e[0]))), 0 === this.set.length) this.set = [e]; else if (this.set.length > 1) for (const e of this.set) if (1 === e.length && b(e[0])) { this.set = [e]; break } } this.formatted = void 0 } get range() { if (void 0 === this.formatted) { this.formatted = ""; for (let e = 0; e < this.set.length; e++) { e > 0 && (this.formatted += "||"); const t = this.set[e]; for (let e = 0; e < t.length; e++)e > 0 && (this.formatted += " "), this.formatted += t[e].toString().trim() } } return this.formatted } format() { return this.range } toString() { return this.range } parseRange(e) { const t = ((this.options.includePrerelease && m) | (this.options.loose && g)) + ":" + e, n = a.get(t); if (n) return n; const r = this.options.loose, i = r ? c[h.HYPHENRANGELOOSE] : c[h.HYPHENRANGE]; e = e.replace(i, I(this.options.includePrerelease)), u("hyphen replace", e), e = e.replace(c[h.COMPARATORTRIM], d), u("comparator trim", e), e = e.replace(c[h.TILDETRIM], f), u("tilde trim", e), e = e.replace(c[h.CARETTRIM], p), u("caret trim", e); let o = e.split(" ").map((e => x(e, this.options))).join(" ").split(/\s+/).map((e => N(e, this.options))); r && (o = o.filter((e => (u("loose invalid filter", e, this.options), !!e.match(c[h.COMPARATORLOOSE]))))), u("range list", o); const l = new Map, b = o.map((e => new s(e, this.options))); for (const e of b) { if (y(e)) return [e]; l.set(e.value, e) } l.size > 1 && l.has("") && l.delete(""); const v = [...l.values()]; return a.set(t, v), v } intersects(e, t) { if (!(e instanceof i)) throw new TypeError("a Range is required"); return this.set.some((n => v(n, t) && e.set.some((e => v(e, t) && n.every((n => e.every((e => n.intersects(e, t))))))))) } test(e) { if (!e) return !1; if ("string" == typeof e) try { e = new l(e, this.options) } catch (e) { return !1 } for (let t = 0; t < this.set.length; t++)if (M(this.set[t], e, this.options)) return !0; return !1 } } e.exports = i; const a = new (n(4967)), o = n(8324), s = n(147), u = n(9847), l = n(6283), { safeRe: c, t: h, comparatorTrimReplace: d, tildeTrimReplace: f, caretTrimReplace: p } = n(6063), { FLAG_INCLUDE_PRERELEASE: m, FLAG_LOOSE: g } = n(3101), y = e => "<0.0.0-0" === e.value, b = e => "" === e.value, v = (e, t) => { let n = !0; const r = e.slice(); let i = r.pop(); for (; n && r.length;)n = r.every((e => i.intersects(e, t))), i = r.pop(); return n }, x = (e, t) => (u("comp", e, t), e = _(e, t), u("caret", e), e = k(e, t), u("tildes", e), e = A(e, t), u("xrange", e), e = E(e, t), u("stars", e), e), w = e => !e || "x" === e.toLowerCase() || "*" === e, k = (e, t) => e.trim().split(/\s+/).map((e => S(e, t))).join(" "), S = (e, t) => { const n = t.loose ? c[h.TILDELOOSE] : c[h.TILDE]; return e.replace(n, ((t, n, r, i, a) => { let o; return u("tilde", e, t, n, r, i, a), w(n) ? o = "" : w(r) ? o = `>=${n}.0.0 <${+n + 1}.0.0-0` : w(i) ? o = `>=${n}.${r}.0 <${n}.${+r + 1}.0-0` : a ? (u("replaceTilde pr", a), o = `>=${n}.${r}.${i}-${a} <${n}.${+r + 1}.0-0`) : o = `>=${n}.${r}.${i} <${n}.${+r + 1}.0-0`, u("tilde return", o), o })) }, _ = (e, t) => e.trim().split(/\s+/).map((e => C(e, t))).join(" "), C = (e, t) => { u("caret", e, t); const n = t.loose ? c[h.CARETLOOSE] : c[h.CARET], r = t.includePrerelease ? "-0" : ""; return e.replace(n, ((t, n, i, a, o) => { let s; return u("caret", e, t, n, i, a, o), w(n) ? s = "" : w(i) ? s = `>=${n}.0.0${r} <${+n + 1}.0.0-0` : w(a) ? s = "0" === n ? `>=${n}.${i}.0${r} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.0${r} <${+n + 1}.0.0-0` : o ? (u("replaceCaret pr", o), s = "0" === n ? "0" === i ? `>=${n}.${i}.${a}-${o} <${n}.${i}.${+a + 1}-0` : `>=${n}.${i}.${a}-${o} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.${a}-${o} <${+n + 1}.0.0-0`) : (u("no pr"), s = "0" === n ? "0" === i ? `>=${n}.${i}.${a}${r} <${n}.${i}.${+a + 1}-0` : `>=${n}.${i}.${a}${r} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.${a} <${+n + 1}.0.0-0`), u("caret return", s), s })) }, A = (e, t) => (u("replaceXRanges", e, t), e.split(/\s+/).map((e => T(e, t))).join(" ")), T = (e, t) => { e = e.trim(); const n = t.loose ? c[h.XRANGELOOSE] : c[h.XRANGE]; return e.replace(n, ((n, r, i, a, o, s) => { u("xRange", e, n, r, i, a, o, s); const l = w(i), c = l || w(a), h = c || w(o), d = h; return "=" === r && d && (r = ""), s = t.includePrerelease ? "-0" : "", l ? n = ">" === r || "<" === r ? "<0.0.0-0" : "*" : r && d ? (c && (a = 0), o = 0, ">" === r ? (r = ">=", c ? (i = +i + 1, a = 0, o = 0) : (a = +a + 1, o = 0)) : "<=" === r && (r = "<", c ? i = +i + 1 : a = +a + 1), "<" === r && (s = "-0"), n = `${r + i}.${a}.${o}${s}`) : c ? n = `>=${i}.0.0${s} <${+i + 1}.0.0-0` : h && (n = `>=${i}.${a}.0${s} <${i}.${+a + 1}.0-0`), u("xRange return", n), n })) }, E = (e, t) => (u("replaceStars", e, t), e.trim().replace(c[h.STAR], "")), N = (e, t) => (u("replaceGTE0", e, t), e.trim().replace(c[t.includePrerelease ? h.GTE0PRE : h.GTE0], "")), I = e => (t, n, r, i, a, o, s, u, l, c, h, d) => `${n = w(r) ? "" : w(i) ? `>=${r}.0.0${e ? "-0" : ""}` : w(a) ? `>=${r}.${i}.0${e ? "-0" : ""}` : o ? `>=${n}` : `>=${n}${e ? "-0" : ""}`} ${u = w(l) ? "" : w(c) ? `<${+l + 1}.0.0-0` : w(h) ? `<${l}.${+c + 1}.0-0` : d ? `<=${l}.${c}.${h}-${d}` : e ? `<${l}.${c}.${+h + 1}-0` : `<=${u}`}`.trim(), M = (e, t, n) => { for (let n = 0; n < e.length; n++)if (!e[n].test(t)) return !1; if (t.prerelease.length && !n.includePrerelease) { for (let n = 0; n < e.length; n++)if (u(e[n].semver), e[n].semver !== s.ANY && e[n].semver.prerelease.length > 0) { const r = e[n].semver; if (r.major === t.major && r.minor === t.minor && r.patch === t.patch) return !0 } return !1 } return !0 } }, 6283: (e, t, n) => { const r = n(9847), { MAX_LENGTH: i, MAX_SAFE_INTEGER: a } = n(3101), { safeRe: o, t: s } = n(6063), u = n(8324), { compareIdentifiers: l } = n(8884); class c { constructor(e, t) { if (t = u(t), e instanceof c) { if (e.loose === !!t.loose && e.includePrerelease === !!t.includePrerelease) return e; e = e.version } else if ("string" != typeof e) throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`); if (e.length > i) throw new TypeError(`version is longer than ${i} characters`); r("SemVer", e, t), this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease; const n = e.trim().match(t.loose ? o[s.LOOSE] : o[s.FULL]); if (!n) throw new TypeError(`Invalid Version: ${e}`); if (this.raw = e, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > a || this.major < 0) throw new TypeError("Invalid major version"); if (this.minor > a || this.minor < 0) throw new TypeError("Invalid minor version"); if (this.patch > a || this.patch < 0) throw new TypeError("Invalid patch version"); n[4] ? this.prerelease = n[4].split(".").map((e => { if (/^[0-9]+$/.test(e)) { const t = +e; if (t >= 0 && t < a) return t } return e })) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format() } format() { return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version } toString() { return this.version } compare(e) { if (r("SemVer.compare", this.version, this.options, e), !(e instanceof c)) { if ("string" == typeof e && e === this.version) return 0; e = new c(e, this.options) } return e.version === this.version ? 0 : this.compareMain(e) || this.comparePre(e) } compareMain(e) { return e instanceof c || (e = new c(e, this.options)), l(this.major, e.major) || l(this.minor, e.minor) || l(this.patch, e.patch) } comparePre(e) { if (e instanceof c || (e = new c(e, this.options)), this.prerelease.length && !e.prerelease.length) return -1; if (!this.prerelease.length && e.prerelease.length) return 1; if (!this.prerelease.length && !e.prerelease.length) return 0; let t = 0; do { const n = this.prerelease[t], i = e.prerelease[t]; if (r("prerelease compare", t, n, i), void 0 === n && void 0 === i) return 0; if (void 0 === i) return 1; if (void 0 === n) return -1; if (n !== i) return l(n, i) } while (++t) } compareBuild(e) { e instanceof c || (e = new c(e, this.options)); let t = 0; do { const n = this.build[t], i = e.build[t]; if (r("build compare", t, n, i), void 0 === n && void 0 === i) return 0; if (void 0 === i) return 1; if (void 0 === n) return -1; if (n !== i) return l(n, i) } while (++t) } inc(e, t, n) { switch (e) { case "premajor": this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", t, n); break; case "preminor": this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", t, n); break; case "prepatch": this.prerelease.length = 0, this.inc("patch", t, n), this.inc("pre", t, n); break; case "prerelease": 0 === this.prerelease.length && this.inc("patch", t, n), this.inc("pre", t, n); break; case "major": 0 === this.minor && 0 === this.patch && 0 !== this.prerelease.length || this.major++, this.minor = 0, this.patch = 0, this.prerelease = []; break; case "minor": 0 === this.patch && 0 !== this.prerelease.length || this.minor++, this.patch = 0, this.prerelease = []; break; case "patch": 0 === this.prerelease.length && this.patch++, this.prerelease = []; break; case "pre": { const e = Number(n) ? 1 : 0; if (!t && !1 === n) throw new Error("invalid increment argument: identifier is empty"); if (0 === this.prerelease.length) this.prerelease = [e]; else { let r = this.prerelease.length; for (; --r >= 0;)"number" == typeof this.prerelease[r] && (this.prerelease[r]++, r = -2); if (-1 === r) { if (t === this.prerelease.join(".") && !1 === n) throw new Error("invalid increment argument: identifier already exists"); this.prerelease.push(e) } } if (t) { let r = [t, e]; !1 === n && (r = [t]), 0 === l(this.prerelease[0], t) ? isNaN(this.prerelease[1]) && (this.prerelease = r) : this.prerelease = r } break } default: throw new Error(`invalid increment argument: ${e}`) }return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this } } e.exports = c }, 9479: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e.trim().replace(/^[=v]+/, ""), t); return n ? n.version : null } }, 4806: (e, t, n) => { const r = n(2314), i = n(6638), a = n(4311), o = n(2228), s = n(528), u = n(7645); e.exports = (e, t, n, l) => { switch (t) { case "===": return "object" == typeof e && (e = e.version), "object" == typeof n && (n = n.version), e === n; case "!==": return "object" == typeof e && (e = e.version), "object" == typeof n && (n = n.version), e !== n; case "": case "=": case "==": return r(e, n, l); case "!=": return i(e, n, l); case ">": return a(e, n, l); case ">=": return o(e, n, l); case "<": return s(e, n, l); case "<=": return u(e, n, l); default: throw new TypeError(`Invalid operator: ${t}`) } } }, 5177: (e, t, n) => { const r = n(6283), i = n(7262), { safeRe: a, t: o } = n(6063); e.exports = (e, t) => { if (e instanceof r) return e; if ("number" == typeof e && (e = String(e)), "string" != typeof e) return null; let n = null; if ((t = t || {}).rtl) { const r = t.includePrerelease ? a[o.COERCERTLFULL] : a[o.COERCERTL]; let i; for (; (i = r.exec(e)) && (!n || n.index + n[0].length !== e.length);)n && i.index + i[0].length === n.index + n[0].length || (n = i), r.lastIndex = i.index + i[1].length + i[2].length; r.lastIndex = -1 } else n = e.match(t.includePrerelease ? a[o.COERCEFULL] : a[o.COERCE]); if (null === n) return null; const s = n[2], u = n[3] || "0", l = n[4] || "0", c = t.includePrerelease && n[5] ? `-${n[5]}` : "", h = t.includePrerelease && n[6] ? `+${n[6]}` : ""; return i(`${s}.${u}.${l}${c}${h}`, t) } }, 4320: (e, t, n) => { const r = n(6283); e.exports = (e, t, n) => { const i = new r(e, n), a = new r(t, n); return i.compare(a) || i.compareBuild(a) } }, 6330: (e, t, n) => { const r = n(9349); e.exports = (e, t) => r(e, t, !0) }, 9349: (e, t, n) => { const r = n(6283); e.exports = (e, t, n) => new r(e, n).compare(new r(t, n)) }, 9127: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e, null, !0), i = r(t, null, !0), a = n.compare(i); if (0 === a) return null; const o = a > 0, s = o ? n : i, u = o ? i : n, l = !!s.prerelease.length; if (!!u.prerelease.length && !l) return u.patch || u.minor ? s.patch ? "patch" : s.minor ? "minor" : "major" : "major"; const c = l ? "pre" : ""; return n.major !== i.major ? c + "major" : n.minor !== i.minor ? c + "minor" : n.patch !== i.patch ? c + "patch" : "prerelease" } }, 2314: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => 0 === r(e, t, n) }, 4311: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) > 0 }, 2228: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) >= 0 }, 5810: (e, t, n) => { const r = n(6283); e.exports = (e, t, n, i, a) => { "string" == typeof n && (a = i, i = n, n = void 0); try { return new r(e instanceof r ? e.version : e, n).inc(t, i, a).version } catch (e) { return null } } }, 528: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) < 0 }, 7645: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) <= 0 }, 9823: (e, t, n) => { const r = n(6283); e.exports = (e, t) => new r(e, t).major }, 3915: (e, t, n) => { const r = n(6283); e.exports = (e, t) => new r(e, t).minor }, 6638: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => 0 !== r(e, t, n) }, 7262: (e, t, n) => { const r = n(6283); e.exports = (e, t, n = !1) => { if (e instanceof r) return e; try { return new r(e, t) } catch (e) { if (!n) return null; throw e } } }, 3236: (e, t, n) => { const r = n(6283); e.exports = (e, t) => new r(e, t).patch }, 7810: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e, t); return n && n.prerelease.length ? n.prerelease : null } }, 4989: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(t, e, n) }, 6920: (e, t, n) => { const r = n(4320); e.exports = (e, t) => e.sort(((e, n) => r(n, e, t))) }, 5435: (e, t, n) => { const r = n(2894); e.exports = (e, t, n) => { try { t = new r(t, n) } catch (e) { return !1 } return t.test(e) } }, 3616: (e, t, n) => { const r = n(4320); e.exports = (e, t) => e.sort(((e, n) => r(e, n, t))) }, 2348: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e, t); return n ? n.version : null } }, 6392: (e, t, n) => { const r = n(6063), i = n(3101), a = n(6283), o = n(8884), s = n(7262), u = n(2348), l = n(9479), c = n(5810), h = n(9127), d = n(9823), f = n(3915), p = n(3236), m = n(7810), g = n(9349), y = n(4989), b = n(6330), v = n(4320), x = n(3616), w = n(6920), k = n(4311), S = n(528), _ = n(2314), C = n(6638), A = n(2228), T = n(7645), E = n(4806), N = n(5177), I = n(147), M = n(2894), F = n(5435), D = n(6718), $ = n(5753), R = n(7939), O = n(3802), z = n(7569), P = n(8584), B = n(7508), L = n(4285), j = n(5929), U = n(6076), W = n(1969); e.exports = { parse: s, valid: u, clean: l, inc: c, diff: h, major: d, minor: f, patch: p, prerelease: m, compare: g, rcompare: y, compareLoose: b, compareBuild: v, sort: x, rsort: w, gt: k, lt: S, eq: _, neq: C, gte: A, lte: T, cmp: E, coerce: N, Comparator: I, Range: M, satisfies: F, toComparators: D, maxSatisfying: $, minSatisfying: R, minVersion: O, validRange: z, outside: P, gtr: B, ltr: L, intersects: j, simplifyRange: U, subset: W, SemVer: a, re: r.re, src: r.src, tokens: r.t, SEMVER_SPEC_VERSION: i.SEMVER_SPEC_VERSION, RELEASE_TYPES: i.RELEASE_TYPES, compareIdentifiers: o.compareIdentifiers, rcompareIdentifiers: o.rcompareIdentifiers } }, 3101: e => { const t = Number.MAX_SAFE_INTEGER || 9007199254740991; e.exports = { MAX_LENGTH: 256, MAX_SAFE_COMPONENT_LENGTH: 16, MAX_SAFE_BUILD_LENGTH: 250, MAX_SAFE_INTEGER: t, RELEASE_TYPES: ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"], SEMVER_SPEC_VERSION: "2.0.0", FLAG_INCLUDE_PRERELEASE: 1, FLAG_LOOSE: 2 } }, 9847: e => { const t = "object" == typeof process && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => { }; e.exports = t }, 8884: e => { const t = /^[0-9]+$/, n = (e, n) => { const r = t.test(e), i = t.test(n); return r && i && (e = +e, n = +n), e === n ? 0 : r && !i ? -1 : i && !r ? 1 : e < n ? -1 : 1 }; e.exports = { compareIdentifiers: n, rcompareIdentifiers: (e, t) => n(t, e) } }, 4967: e => { e.exports = class { constructor() { this.max = 1e3, this.map = new Map } get(e) { const t = this.map.get(e); return void 0 === t ? void 0 : (this.map.delete(e), this.map.set(e, t), t) } delete(e) { return this.map.delete(e) } set(e, t) { if (!this.delete(e) && void 0 !== t) { if (this.map.size >= this.max) { const e = this.map.keys().next().value; this.delete(e) } this.map.set(e, t) } return this } } }, 8324: e => { const t = Object.freeze({ loose: !0 }), n = Object.freeze({}); e.exports = e => e ? "object" != typeof e ? t : e : n }, 6063: (e, t, n) => { const { MAX_SAFE_COMPONENT_LENGTH: r, MAX_SAFE_BUILD_LENGTH: i, MAX_LENGTH: a } = n(3101), o = n(9847), s = (t = e.exports = {}).re = [], u = t.safeRe = [], l = t.src = [], c = t.t = {}; let h = 0; const d = "[a-zA-Z0-9-]", f = [["\\s", 1], ["\\d", a], [d, i]], p = (e, t, n) => { const r = (e => { for (const [t, n] of f) e = e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`); return e })(t), i = h++; o(e, i, t), c[e] = i, l[i] = t, s[i] = new RegExp(t, n ? "g" : void 0), u[i] = new RegExp(r, n ? "g" : void 0) }; p("NUMERICIDENTIFIER", "0|[1-9]\\d*"), p("NUMERICIDENTIFIERLOOSE", "\\d+"), p("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${d}*`), p("MAINVERSION", `(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})`), p("MAINVERSIONLOOSE", `(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})`), p("PRERELEASEIDENTIFIER", `(?:${l[c.NUMERICIDENTIFIER]}|${l[c.NONNUMERICIDENTIFIER]})`), p("PRERELEASEIDENTIFIERLOOSE", `(?:${l[c.NUMERICIDENTIFIERLOOSE]}|${l[c.NONNUMERICIDENTIFIER]})`), p("PRERELEASE", `(?:-(${l[c.PRERELEASEIDENTIFIER]}(?:\\.${l[c.PRERELEASEIDENTIFIER]})*))`), p("PRERELEASELOOSE", `(?:-?(${l[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[c.PRERELEASEIDENTIFIERLOOSE]})*))`), p("BUILDIDENTIFIER", `${d}+`), p("BUILD", `(?:\\+(${l[c.BUILDIDENTIFIER]}(?:\\.${l[c.BUILDIDENTIFIER]})*))`), p("FULLPLAIN", `v?${l[c.MAINVERSION]}${l[c.PRERELEASE]}?${l[c.BUILD]}?`), p("FULL", `^${l[c.FULLPLAIN]}$`), p("LOOSEPLAIN", `[v=\\s]*${l[c.MAINVERSIONLOOSE]}${l[c.PRERELEASELOOSE]}?${l[c.BUILD]}?`), p("LOOSE", `^${l[c.LOOSEPLAIN]}$`), p("GTLT", "((?:<|>)?=?)"), p("XRANGEIDENTIFIERLOOSE", `${l[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), p("XRANGEIDENTIFIER", `${l[c.NUMERICIDENTIFIER]}|x|X|\\*`), p("XRANGEPLAIN", `[v=\\s]*(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:${l[c.PRERELEASE]})?${l[c.BUILD]}?)?)?`), p("XRANGEPLAINLOOSE", `[v=\\s]*(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:${l[c.PRERELEASELOOSE]})?${l[c.BUILD]}?)?)?`), p("XRANGE", `^${l[c.GTLT]}\\s*${l[c.XRANGEPLAIN]}$`), p("XRANGELOOSE", `^${l[c.GTLT]}\\s*${l[c.XRANGEPLAINLOOSE]}$`), p("COERCEPLAIN", `(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`), p("COERCE", `${l[c.COERCEPLAIN]}(?:$|[^\\d])`), p("COERCEFULL", l[c.COERCEPLAIN] + `(?:${l[c.PRERELEASE]})?` + `(?:${l[c.BUILD]})?(?:$|[^\\d])`), p("COERCERTL", l[c.COERCE], !0), p("COERCERTLFULL", l[c.COERCEFULL], !0), p("LONETILDE", "(?:~>?)"), p("TILDETRIM", `(\\s*)${l[c.LONETILDE]}\\s+`, !0), t.tildeTrimReplace = "$1~", p("TILDE", `^${l[c.LONETILDE]}${l[c.XRANGEPLAIN]}$`), p("TILDELOOSE", `^${l[c.LONETILDE]}${l[c.XRANGEPLAINLOOSE]}$`), p("LONECARET", "(?:\\^)"), p("CARETTRIM", `(\\s*)${l[c.LONECARET]}\\s+`, !0), t.caretTrimReplace = "$1^", p("CARET", `^${l[c.LONECARET]}${l[c.XRANGEPLAIN]}$`), p("CARETLOOSE", `^${l[c.LONECARET]}${l[c.XRANGEPLAINLOOSE]}$`), p("COMPARATORLOOSE", `^${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]})$|^$`), p("COMPARATOR", `^${l[c.GTLT]}\\s*(${l[c.FULLPLAIN]})$|^$`), p("COMPARATORTRIM", `(\\s*)${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]}|${l[c.XRANGEPLAIN]})`, !0), t.comparatorTrimReplace = "$1$2$3", p("HYPHENRANGE", `^\\s*(${l[c.XRANGEPLAIN]})\\s+-\\s+(${l[c.XRANGEPLAIN]})\\s*$`), p("HYPHENRANGELOOSE", `^\\s*(${l[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[c.XRANGEPLAINLOOSE]})\\s*$`), p("STAR", "(<|>)?=?\\s*\\*"), p("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), p("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$") }, 7508: (e, t, n) => { const r = n(8584); e.exports = (e, t, n) => r(e, t, ">", n) }, 5929: (e, t, n) => { const r = n(2894); e.exports = (e, t, n) => (e = new r(e, n), t = new r(t, n), e.intersects(t, n)) }, 4285: (e, t, n) => { const r = n(8584); e.exports = (e, t, n) => r(e, t, "<", n) }, 5753: (e, t, n) => { const r = n(6283), i = n(2894); e.exports = (e, t, n) => { let a = null, o = null, s = null; try { s = new i(t, n) } catch (e) { return null } return e.forEach((e => { s.test(e) && (a && -1 !== o.compare(e) || (a = e, o = new r(a, n))) })), a } }, 7939: (e, t, n) => { const r = n(6283), i = n(2894); e.exports = (e, t, n) => { let a = null, o = null, s = null; try { s = new i(t, n) } catch (e) { return null } return e.forEach((e => { s.test(e) && (a && 1 !== o.compare(e) || (a = e, o = new r(a, n))) })), a } }, 3802: (e, t, n) => { const r = n(6283), i = n(2894), a = n(4311); e.exports = (e, t) => { e = new i(e, t); let n = new r("0.0.0"); if (e.test(n)) return n; if (n = new r("0.0.0-0"), e.test(n)) return n; n = null; for (let t = 0; t < e.set.length; ++t) { const i = e.set[t]; let o = null; i.forEach((e => { const t = new r(e.semver.version); switch (e.operator) { case ">": 0 === t.prerelease.length ? t.patch++ : t.prerelease.push(0), t.raw = t.format(); case "": case ">=": o && !a(t, o) || (o = t); break; case "<": case "<=": break; default: throw new Error(`Unexpected operation: ${e.operator}`) } })), !o || n && !a(n, o) || (n = o) } return n && e.test(n) ? n : null } }, 8584: (e, t, n) => { const r = n(6283), i = n(147), { ANY: a } = i, o = n(2894), s = n(5435), u = n(4311), l = n(528), c = n(7645), h = n(2228); e.exports = (e, t, n, d) => { let f, p, m, g, y; switch (e = new r(e, d), t = new o(t, d), n) { case ">": f = u, p = c, m = l, g = ">", y = ">="; break; case "<": f = l, p = h, m = u, g = "<", y = "<="; break; default: throw new TypeError('Must provide a hilo val of "<" or ">"') }if (s(e, t, d)) return !1; for (let n = 0; n < t.set.length; ++n) { const r = t.set[n]; let o = null, s = null; if (r.forEach((e => { e.semver === a && (e = new i(">=0.0.0")), o = o || e, s = s || e, f(e.semver, o.semver, d) ? o = e : m(e.semver, s.semver, d) && (s = e) })), o.operator === g || o.operator === y) return !1; if ((!s.operator || s.operator === g) && p(e, s.semver)) return !1; if (s.operator === y && m(e, s.semver)) return !1 } return !0 } }, 6076: (e, t, n) => { const r = n(5435), i = n(9349); e.exports = (e, t, n) => { const a = []; let o = null, s = null; const u = e.sort(((e, t) => i(e, t, n))); for (const e of u) { r(e, t, n) ? (s = e, o || (o = e)) : (s && a.push([o, s]), s = null, o = null) } o && a.push([o, null]); const l = []; for (const [e, t] of a) e === t ? l.push(e) : t || e !== u[0] ? t ? e === u[0] ? l.push(`<=${t}`) : l.push(`${e} - ${t}`) : l.push(`>=${e}`) : l.push("*"); const c = l.join(" || "), h = "string" == typeof t.raw ? t.raw : String(t); return c.length < h.length ? c : t } }, 1969: (e, t, n) => { const r = n(2894), i = n(147), { ANY: a } = i, o = n(5435), s = n(9349), u = [new i(">=0.0.0-0")], l = [new i(">=0.0.0")], c = (e, t, n) => { if (e === t) return !0; if (1 === e.length && e[0].semver === a) { if (1 === t.length && t[0].semver === a) return !0; e = n.includePrerelease ? u : l } if (1 === t.length && t[0].semver === a) { if (n.includePrerelease) return !0; t = l } const r = new Set; let i, c, f, p, m, g, y; for (const t of e) ">" === t.operator || ">=" === t.operator ? i = h(i, t, n) : "<" === t.operator || "<=" === t.operator ? c = d(c, t, n) : r.add(t.semver); if (r.size > 1) return null; if (i && c) { if (f = s(i.semver, c.semver, n), f > 0) return null; if (0 === f && (">=" !== i.operator || "<=" !== c.operator)) return null } for (const e of r) { if (i && !o(e, String(i), n)) return null; if (c && !o(e, String(c), n)) return null; for (const r of t) if (!o(e, String(r), n)) return !1; return !0 } let b = !(!c || n.includePrerelease || !c.semver.prerelease.length) && c.semver, v = !(!i || n.includePrerelease || !i.semver.prerelease.length) && i.semver; b && 1 === b.prerelease.length && "<" === c.operator && 0 === b.prerelease[0] && (b = !1); for (const e of t) { if (y = y || ">" === e.operator || ">=" === e.operator, g = g || "<" === e.operator || "<=" === e.operator, i) if (v && e.semver.prerelease && e.semver.prerelease.length && e.semver.major === v.major && e.semver.minor === v.minor && e.semver.patch === v.patch && (v = !1), ">" === e.operator || ">=" === e.operator) { if (p = h(i, e, n), p === e && p !== i) return !1 } else if (">=" === i.operator && !o(i.semver, String(e), n)) return !1; if (c) if (b && e.semver.prerelease && e.semver.prerelease.length && e.semver.major === b.major && e.semver.minor === b.minor && e.semver.patch === b.patch && (b = !1), "<" === e.operator || "<=" === e.operator) { if (m = d(c, e, n), m === e && m !== c) return !1 } else if ("<=" === c.operator && !o(c.semver, String(e), n)) return !1; if (!e.operator && (c || i) && 0 !== f) return !1 } return !(i && g && !c && 0 !== f) && (!(c && y && !i && 0 !== f) && (!v && !b)) }, h = (e, t, n) => { if (!e) return t; const r = s(e.semver, t.semver, n); return r > 0 ? e : r < 0 || ">" === t.operator && ">=" === e.operator ? t : e }, d = (e, t, n) => { if (!e) return t; const r = s(e.semver, t.semver, n); return r < 0 ? e : r > 0 || "<" === t.operator && "<=" === e.operator ? t : e }; e.exports = (e, t, n = {}) => { if (e === t) return !0; e = new r(e, n), t = new r(t, n); let i = !1; e: for (const r of e.set) { for (const e of t.set) { const t = c(r, e, n); if (i = i || null !== t, t) continue e } if (i) return !1 } return !0 } }, 6718: (e, t, n) => { const r = n(2894); e.exports = (e, t) => new r(e, t).set.map((e => e.map((e => e.value)).join(" ").trim().split(" "))) }, 7569: (e, t, n) => { const r = n(2894); e.exports = (e, t) => { try { return new r(e, t).range || "*" } catch (e) { return null } } }, 7571: () => { }, 7006: () => { }, 5817: () => { }, 8590: () => { }, 4530: () => { }, 8108: () => { }, 551: () => { }, 1234: () => { }, 8487: e => { "use strict"; var t = /("(?:[^\\"]|\\.)*")|[:,]/g; e.exports = function (e, n) { var r, i, a; return n = n || {}, r = JSON.stringify([1], void 0, void 0 === n.indent ? 2 : n.indent).slice(2, -3), i = "" === r ? 1 / 0 : void 0 === n.maxLength ? 80 : n.maxLength, a = n.replacer, function e(n, o, s) { var u, l, c, h, d, f, p, m, g, y, b, v; if (n && "function" == typeof n.toJSON && (n = n.toJSON()), void 0 === (b = JSON.stringify(n, a))) return b; if (p = i - o.length - s, b.length <= p && (g = b.replace(t, (function (e, t) { return t || e + " " }))).length <= p) return g; if (null != a && (n = JSON.parse(b), a = void 0), "object" == typeof n && null !== n) { if (m = o + r, c = [], l = 0, Array.isArray(n)) for (y = "[", u = "]", p = n.length; l < p; l++)c.push(e(n[l], m, l === p - 1 ? 0 : 1) || "null"); else for (y = "{", u = "}", p = (f = Object.keys(n)).length; l < p; l++)h = f[l], d = JSON.stringify(h) + ": ", void 0 !== (v = e(n[h], m, d.length + (l === p - 1 ? 0 : 1))) && c.push(d + v); if (c.length > 0) return [y, r + c.join(",\n" + m), u].join("\n" + o) } return b }(e, "", 0) } } + }, t = {}; function n(r) { var i = t[r]; if (void 0 !== i) return i.exports; var a = t[r] = { id: r, loaded: !1, exports: {} }; return e[r].call(a.exports, a, a.exports, n), a.loaded = !0, a.exports } n.amdD = function () { throw new Error("define cannot be used indirect") }, n.amdO = {}, n.n = e => { var t = e && e.__esModule ? () => e.default : () => e; return n.d(t, { a: t }), t }, n.d = (e, t) => { for (var r in t) n.o(t, r) && !n.o(e, r) && Object.defineProperty(e, r, { enumerable: !0, get: t[r] }) }, n.g = function () { if ("object" == typeof globalThis) return globalThis; try { return this || new Function("return this")() } catch (e) { if ("object" == typeof window) return window } }(), n.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), n.r = e => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.nmd = e => (e.paths = [], e.children || (e.children = []), e); var r = {}; return (() => { + "use strict"; n.d(r, { default: () => OK }); var e = {}; n.r(e), n.d(e, { maxNorm: () => va, minMaxNorm: () => ka, nonNeg: () => wa, unitNorm: () => xa }); var t = {}; n.r(t), n.d(t, { constant: () => Ca, glorotNormal: () => Fa, glorotUniform: () => Ma, heNormal: () => Da, heUniform: () => $a, identity: () => Na, leCunNormal: () => Ra, leCunUniform: () => Oa, ones: () => _a, orthogonal: () => za, randomNormal: () => Ta, randomUniform: () => Aa, truncatedNormal: () => Ea, varianceScaling: () => Ia, zeros: () => Sa }); var i = {}; n.r(i), n.d(i, { Layer: () => Ji, RNN: () => uu, RNNCell: () => lu, activation: () => Ul, add: () => Zl, alphaDropout: () => jc, average: () => Jl, averagePooling1d: () => sc, averagePooling2d: () => cc, averagePooling3d: () => fc, avgPool1d: () => uc, avgPool2d: () => hc, avgPool3d: () => pc, avgPooling1d: () => lc, avgPooling2d: () => dc, avgPooling3d: () => mc, batchNormalization: () => ic, bidirectional: () => Dc, categoryEncoding: () => Hc, centerCrop: () => Vc, concatenate: () => Ql, conv1d: () => Dl, conv2d: () => $l, conv2dTranspose: () => Rl, conv3d: () => Ol, conv3dTranspose: () => zl, convLstm2d: () => Nc, convLstm2dCell: () => Ic, cropping2D: () => Bl, dense: () => Wl, depthwiseConv2d: () => jl, dot: () => rc, dropout: () => Vl, elu: () => Tl, embedding: () => Kl, flatten: () => Hl, gaussianDropout: () => Lc, gaussianNoise: () => Bc, globalAveragePooling1d: () => gc, globalAveragePooling2d: () => yc, globalMaxPool1d: () => Rc, globalMaxPool2d: () => Oc, globalMaxPooling1d: () => bc, globalMaxPooling2d: () => vc, gru: () => Sc, gruCell: () => _c, input: () => as, inputLayer: () => Al, layerNormalization: () => ac, leakyReLU: () => Nl, lstm: () => Cc, lstmCell: () => Ac, masking: () => Uc, maxPool1d: () => zc, maxPool2d: () => Pc, maxPooling1d: () => xc, maxPooling2d: () => wc, maxPooling3d: () => kc, maximum: () => ec, minimum: () => tc, multiply: () => nc, permute: () => Xl, prelu: () => Il, randomWidth: () => qc, reLU: () => El, repeatVector: () => ql, rescaling: () => Wc, reshape: () => Yl, resizing: () => Gc, rnn: () => Mc, separableConv2d: () => Pl, simpleRNN: () => Tc, simpleRNNCell: () => Ec, softmax: () => Ml, spatialDropout1d: () => Gl, stackedRNNCells: () => Fc, thresholdedReLU: () => Fl, timeDistributed: () => $c, upSampling2d: () => Ll, zeroPadding2d: () => oc }); var a = {}; n.r(a), n.d(a, { MAPE: () => ih, MSE: () => sh, binaryAccuracy: () => Yc, binaryCrossentropy: () => Xc, categoricalAccuracy: () => Zc, categoricalCrossentropy: () => Jc, cosineProximity: () => th, mape: () => ah, meanAbsoluteError: () => nh, meanAbsolutePercentageError: () => rh, meanSquaredError: () => oh, mse: () => uh, precision: () => Qc, r2Score: () => lh, recall: () => eh, sparseCategoricalAccuracy: () => Kc }); var o = {}; n.r(o), n.d(o, { modelFromJSON: () => es }); var s = {}; n.r(s), n.d(s, { l1: () => hh, l1l2: () => ch, l2: () => dh }); var u = {}; n.r(u), n.d(u, { json: () => Dh }); var l = {}; n.r(l), n.d(l, { json: () => $h }); var c = {}; n.r(c), n.d(c, { json: () => Rh }); var h = {}; n.r(h), n.d(h, { json: () => Oh }); var d = {}; n.r(d), n.d(d, { json: () => zh }); var f = {}; n.r(f), n.d(f, { json: () => Ph }); var p = {}; n.r(p), n.d(p, { json: () => Bh }); var m = {}; n.r(m), n.d(m, { json: () => Lh }); var g = {}; n.r(g), n.d(g, { json: () => jh }); var y = {}; n.r(y), n.d(y, { json: () => Uh }); var b = {}; n.r(b), n.d(b, { json: () => Wh }); var v = {}; n.r(v), n.d(v, { json: () => Vh }); var x = {}; n.r(x), n.d(x, { json: () => Gh }); var w = {}; n.r(w), n.d(w, { json: () => Hh }); var k = {}; n.r(k), n.d(k, { json: () => qh }); var S = {}; n.r(S), n.d(S, { json: () => Yh }); var _ = {}; n.r(_), n.d(_, { json: () => Xh }); var C = {}; n.r(C), n.d(C, { json: () => Kh }); var A = {}; n.r(A), n.d(A, { json: () => Zh }); var T = {}; n.r(T), n.d(T, { OP_SCOPE_SUFFIX: () => pd.BTT, abs: () => pd.tnl, acos: () => pd.HQu, acosh: () => pd.FqL, add: () => pd.WQq, addN: () => pd.QiD, all: () => pd.Q7R, any: () => pd.bzn, argMax: () => pd.FLi, argMin: () => pd.XRg, asin: () => pd.qRo, asinh: () => pd.yHs, atan: () => pd.rYl, atan2: () => pd.FPz, atanh: () => pd.rfv, avgPool: () => pd.$jT, avgPool3d: () => pd.sub, basicLSTMCell: () => pd.lZX, batchNorm: () => pd.$v7, batchNorm2d: () => pd.BFc, batchNorm3d: () => pd.kSi, batchNorm4d: () => pd.T5N, batchToSpaceND: () => pd.GTe, bincount: () => pd.HbZ, bitwiseAnd: () => pd.vjT, booleanMaskAsync: () => pd.ftb, broadcastArgs: () => pd.ROE, broadcastTo: () => pd.hOW, buffer: () => pd.ra8, cast: () => pd.wgE, ceil: () => pd.mkO, clipByValue: () => pd.zQh, clone: () => pd.o8B, complex: () => pd.faB, concat: () => pd.xWs, concat1d: () => pd.I1m, concat2d: () => pd.RPU, concat3d: () => pd.O5O, concat4d: () => pd.P1l, conv1d: () => pd.kA9, conv2d: () => pd.Xtf, conv2dTranspose: () => pd.wX9, conv3d: () => pd.IPL, conv3dTranspose: () => pd.jIJ, cos: () => pd.gnS, cosh: () => pd.yIG, cosineWindow: () => pd._jP, cumprod: () => pd.Lp0, cumsum: () => pd.rCv, denseBincount: () => pd.aOp, depthToSpace: () => pd.Rj8, depthwiseConv2d: () => pd.Gl3, diag: () => pd.smy, dilation2d: () => pd.X7t, div: () => pd.y4m, divNoNan: () => pd.ek5, dot: () => pd.Omf, dropout: () => pd.EZY, einsum: () => pd._3C, elu: () => pd.Pqc, enclosingPowerOfTwo: () => pd.FJY, ensureShape: () => pd.QP2, equal: () => pd.LCg, erf: () => pd.Y12, euclideanNorm: () => pd.p4S, exp: () => pd.oNF, expandDims: () => pd.UG6, expm1: () => pd.IYd, eye: () => pd.y5U, fft: () => pd.hVP, fill: () => pd.GSj, floor: () => pd.RIf, floorDiv: () => pd.wh_, fused: () => pd.cZk, gather: () => pd.kgh, gatherND: () => pd.SY9, greater: () => pd.rhj, greaterEqual: () => pd.DQN, ifft: () => pd.KGM, imag: () => pd.ngS, image: () => pd.Slp, inTopKAsync: () => pd.U4u, irfft: () => pd.ggX, isFinite: () => pd.MIs, isInf: () => pd.EN4, isNaN: () => pd.yrW, leakyRelu: () => pd.H8d, less: () => pd.M7h, lessEqual: () => pd.InN, linalg: () => pd.mPL, linspace: () => pd.mT8, localResponseNormalization: () => pd.Kgs, log: () => pd.Rm2, log1p: () => pd.Kko, logSigmoid: () => pd.nqI, logSoftmax: () => pd.HPB, logSumExp: () => pd.VZ, logicalAnd: () => pd.n76, logicalNot: () => pd.NSZ, logicalOr: () => pd.ztW, logicalXor: () => pd.rxB, losses: () => pd.YYh, lowerBound: () => pd.yzS, matMul: () => pd.NoW, max: () => pd.T9B, maxPool: () => pd.jgi, maxPool3d: () => pd.NYV, maxPoolWithArgmax: () => pd.RO, maximum: () => pd.PhQ, mean: () => pd.i2o, meshgrid: () => pd.OYQ, min: () => pd.jkA, minimum: () => pd.BpO, mirrorPad: () => pd.FFZ, mod: () => pd.ziu, moments: () => pd.Clk, movingAverage: () => pd.CRk, mul: () => pd.lKK, multiRNNCell: () => pd.YDF, multinomial: () => pd.OjQ, neg: () => pd.HZy, norm: () => pd.xbf, notEqual: () => pd.Ec, oneHot: () => pd.Mw0, ones: () => pd.SaS, onesLike: () => pd.P61, op: () => pd.op, outerProduct: () => pd.X4o, pad: () => pd.eVF, pad1d: () => pd.BZs, pad2d: () => pd.grY, pad3d: () => pd.XHu, pad4d: () => pd.WLX, pool: () => pd.dzn, pow: () => pd.n7C, prelu: () => pd.NsG, print: () => pd.yyV, prod: () => pd._eU, raggedGather: () => pd.whe, raggedRange: () => pd.iyU, raggedTensorToTensor: () => pd.Q0_, rand: () => pd._9M, randomGamma: () => pd.pR9, randomNormal: () => pd.FE$, randomStandardNormal: () => pd.m0H, randomUniform: () => pd.YeY, randomUniformInt: () => pd.HYA, range: () => pd.y17, real: () => pd.xav, reciprocal: () => pd.VOZ, relu: () => pd.VVh, relu6: () => pd.j__, reshape: () => pd.tQQ, reverse: () => pd.BEg, reverse1d: () => pd.QD2, reverse2d: () => pd.LMr, reverse3d: () => pd.I2l, reverse4d: () => pd.JYU, rfft: () => pd.z8$, round: () => pd.LIG, rsqrt: () => pd.Z$r, scalar: () => pd.d_2, scatterND: () => pd.NFr, searchSorted: () => pd.sZg, selu: () => pd.WfX, separableConv2d: () => pd.wdz, setdiff1dAsync: () => pd.F12, sigmoid: () => pd.ry7, sign: () => pd._SZ, signal: () => pd.vPA, sin: () => pd.F8e, sinh: () => pd.L0l, slice: () => pd.dik, slice1d: () => pd.Q$M, slice2d: () => pd.zAd, slice3d: () => pd.wck, slice4d: () => pd.R0O, softmax: () => pd.Vs9, softplus: () => pd.lw0, spaceToBatchND: () => pd.eDJ, sparse: () => pd.lMo, sparseToDense: () => pd.Zhr, spectral: () => pd.lOn, split: () => pd.lDo, sqrt: () => pd.RZD, square: () => pd.EwI, squaredDifference: () => pd.Pbu, squeeze: () => pd.r2V, stack: () => pd.t$z, step: () => pd.PMw, stridedSlice: () => pd.Ym9, string: () => pd.YjP, sub: () => pd.jbE, sum: () => pd.czq, tan: () => pd.Mlm, tanh: () => pd.ymU, tensor: () => pd.OEK, tensor1d: () => pd.tGX, tensor2d: () => pd.KtR, tensor3d: () => pd.$_$, tensor4d: () => pd.g9W, tensor5d: () => pd.Lpo, tensor6d: () => pd.yxw, tensorScatterUpdate: () => pd.NNh, tile: () => pd.Vsq, topk: () => pd.rfw, transpose: () => pd.mgz, truncatedNormal: () => pd.efE, unique: () => pd.AmM, unsortedSegmentSum: () => pd.zAU, unstack: () => pd.K$i, upperBound: () => pd.rni, variable: () => pd.bvq, where: () => pd._M9, whereAsync: () => pd.YJN, zeros: () => pd.Ul9, zerosLike: () => pd.POl }); var E = {}; n.r(E), n.d(E, { CSVDataset: () => zf, Dataset: () => Cf, FileDataSource: () => Kf, TextLineDataset: () => If, URLDataSource: () => Zf, array: () => Tf, csv: () => Jf, func: () => Qf, generator: () => ep, microphone: () => np, version_data: () => rp, webcam: () => tp, zip: () => Ef }); var N = {}; n.r(N), n.d(N, { addImpl: () => kp, bincountImpl: () => Ap, bincountReduceImpl: () => Tp, bitwiseAndImpl: () => Ep, castImpl: () => yp, ceilImpl: () => $p, concatImpl: () => zp, equalImpl: () => Pp, expImpl: () => jp, expm1Impl: () => Vp, floorDivImpl: () => Kp, floorImpl: () => qp, gatherNdImpl: () => Qp, gatherV2Impl: () => em, greaterEqualImpl: () => im, greaterImpl: () => tm, lessEqualImpl: () => cm, lessImpl: () => sm, linSpaceImpl: () => fm, logImpl: () => pm, maxImpl: () => ym, maximumImpl: () => bm, minimumImpl: () => wm, multiplyImpl: () => _m, negImpl: () => Em, notEqualImpl: () => Im, prodImpl: () => Om, raggedGatherImpl: () => jm, raggedRangeImpl: () => Wm, raggedTensorToTensorImpl: () => Ym, rangeImpl: () => Xm, rsqrtImpl: () => Km, scatterImpl: () => Qm, sigmoidImpl: () => eg, simpleAbsImpl: () => sp, sliceImpl: () => rg, sparseFillEmptyRowsImpl: () => og, sparseReshapeImpl: () => sg, sparseSegmentReductionImpl: () => ug, sqrtImpl: () => lg, squaredDifferenceImpl: () => dg, staticRegexReplaceImpl: () => mg, stridedSliceImpl: () => bg, stringNGramsImpl: () => xg, stringSplitImpl: () => kg, stringToHashBucketFastImpl: () => Sg, subImpl: () => _g, tileImpl: () => Eg, topKImpl: () => Mg, transposeImpl: () => Dm, uniqueImpl: () => Fg }); var I = {}; n.r(I), n.d(I, { assertNotComplex: () => Zw, bindCanvasToFramebuffer: () => Cw, bindColorTextureToFramebuffer: () => Aw, bindTextureToProgramUniformSampler: () => _w, bindTextureUnit: () => xw, bindVertexBufferToProgramAttribute: () => vw, callAndCheck: () => ew, canBeRepresented: () => rw, createFragmentShader: () => sw, createFramebuffer: () => bw, createProgram: () => cw, createStaticIndexBuffer: () => pw, createStaticVertexBuffer: () => fw, createTexture: () => gw, createVertexShader: () => ow, getBatchDim: () => Fw, getExtensionOrThrow: () => aw, getFramebufferErrorMessage: () => Nw, getMaxTexturesInShader: () => Ww, getNumChannels: () => mw, getProgramUniformLocation: () => Sw, getProgramUniformLocationOrThrow: () => kw, getRowsCols: () => Dw, getShapeAs3D: () => $w, getTextureShapeFromLogicalShape: () => Rw, getWebGLDisjointQueryTimerVersion: () => Vw, getWebGLErrorMessage: () => iw, getWebGLMaxTextureSize: () => Lw, hasExtension: () => Gw, isCapableOfRenderingToFloatTexture: () => qw, isDownloadFloatTextureEnabled: () => Yw, isReshapeFree: () => zw, isWebGLFenceEnabled: () => Kw, isWebGLVersionEnabled: () => Hw, linkProgram: () => hw, logShaderSourceAndInfoLog: () => lw, resetMaxTextureSize: () => jw, resetMaxTexturesInShader: () => Uw, unbindColorTextureFromFramebuffer: () => Tw, unbindTextureUnit: () => ww, validateFramebuffer: () => Ew, validateProgram: () => dw, validateTextureSize: () => yw }); var M = {}; n.r(M), n.d(M, { bindVertexProgramAttributeStreams: () => Vk, createBufferFromOutputTexture: () => qk, createFloat16MatrixTexture: () => zk, createFloat16PackedMatrixTexture: () => Wk, createFloat32MatrixTexture: () => Rk, createIndexBuffer: () => Fk, createPackedMatrixTexture: () => jk, createUnsignedBytesMatrixTexture: () => Bk, createVertexBuffer: () => Mk, createVertexShader: () => Ik, downloadByteEncodedFloatMatrixFromOutputTexture: () => Xk, downloadFloat32MatrixFromBuffer: () => Yk, downloadMatrixFromPackedOutputTexture: () => Zk, downloadPackedMatrixFromBuffer: () => Kk, getInternalFormatForFloat16MatrixTexture: () => Ok, getInternalFormatForFloat16PackedMatrixTexture: () => Uk, getInternalFormatForFloat32MatrixTexture: () => $k, getInternalFormatForPackedMatrixTexture: () => Lk, getInternalFormatForUnsignedBytesMatrixTexture: () => Pk, uploadDenseMatrixToTexture: () => Gk, uploadPixelDataToTexture: () => Hk }); var F = {}; n.r(F), n.d(F, { Abs: () => P.Abs, Acos: () => P.Acos, Acosh: () => P.Acosh, AdadeltaOptimizer: () => P.AdadeltaOptimizer, AdagradOptimizer: () => P.AdagradOptimizer, AdamOptimizer: () => P.AdamOptimizer, AdamaxOptimizer: () => P.AdamaxOptimizer, Add: () => P.Add, AddN: () => P.AddN, All: () => P.All, Any: () => P.Any, ArgMax: () => P.ArgMax, ArgMin: () => P.ArgMin, Asin: () => P.Asin, Asinh: () => P.Asinh, Atan: () => P.Atan, Atan2: () => P.Atan2, Atanh: () => P.Atanh, AvgPool: () => P.AvgPool, AvgPool3D: () => P.AvgPool3D, AvgPool3DGrad: () => P.AvgPool3DGrad, AvgPoolGrad: () => P.AvgPoolGrad, BatchMatMul: () => P.BatchMatMul, BatchToSpaceND: () => P.BatchToSpaceND, Bincount: () => P.Bincount, BitwiseAnd: () => P.BitwiseAnd, BroadcastArgs: () => P.BroadcastArgs, BroadcastTo: () => P.BroadcastTo, Callback: () => fh, CallbackList: () => Wa, Cast: () => P.Cast, Ceil: () => P.Ceil, ClipByValue: () => P.ClipByValue, Complex: () => P.Complex, ComplexAbs: () => P.ComplexAbs, Concat: () => P.Concat, Conv2D: () => P.Conv2D, Conv2DBackpropFilter: () => P.Conv2DBackpropFilter, Conv2DBackpropInput: () => P.Conv2DBackpropInput, Conv3D: () => P.Conv3D, Conv3DBackpropFilterV2: () => P.Conv3DBackpropFilterV2, Conv3DBackpropInputV2: () => P.Conv3DBackpropInputV2, Cos: () => P.Cos, Cosh: () => P.Cosh, CropAndResize: () => P.CropAndResize, Cumprod: () => P.Cumprod, Cumsum: () => P.Cumsum, CustomCallback: () => Ha, DataStorage: () => P.DataStorage, DenseBincount: () => P.DenseBincount, DepthToSpace: () => P.DepthToSpace, DepthwiseConv2dNative: () => P.DepthwiseConv2dNative, DepthwiseConv2dNativeBackpropFilter: () => P.DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropInput: () => P.DepthwiseConv2dNativeBackpropInput, Diag: () => P.Diag, Dilation2D: () => P.Dilation2D, Dilation2DBackpropFilter: () => P.Dilation2DBackpropFilter, Dilation2DBackpropInput: () => P.Dilation2DBackpropInput, Draw: () => P.Draw, ENV: () => P.ENV, EarlyStopping: () => gh, Einsum: () => P.Einsum, Elu: () => P.Elu, EluGrad: () => P.EluGrad, Environment: () => P.Environment, Equal: () => P.Equal, Erf: () => P.Erf, Exp: () => P.Exp, ExpandDims: () => P.ExpandDims, Expm1: () => P.Expm1, FFT: () => P.FFT, Fill: () => P.Fill, FlipLeftRight: () => P.FlipLeftRight, Floor: () => P.Floor, FloorDiv: () => P.FloorDiv, FromPixels: () => P.FromPixels, FusedBatchNorm: () => P.FusedBatchNorm, FusedConv2D: () => P.FusedConv2D, FusedDepthwiseConv2D: () => P.FusedDepthwiseConv2D, GPGPUContext: () => Jk, GatherNd: () => P.GatherNd, GatherV2: () => P.GatherV2, GraphModel: () => jd, Greater: () => P.Greater, GreaterEqual: () => P.GreaterEqual, History: () => Ga, IFFT: () => P.IFFT, Identity: () => P.Identity, Imag: () => P.Imag, InputSpec: () => qi, IsFinite: () => P.IsFinite, IsInf: () => P.IsInf, IsNan: () => P.IsNan, KernelBackend: () => P.KernelBackend, LRN: () => P.LRN, LRNGrad: () => P.LRNGrad, LayerVariable: () => Vi, LayersModel: () => Jo, LeakyRelu: () => P.LeakyRelu, Less: () => P.Less, LessEqual: () => P.LessEqual, LinSpace: () => P.LinSpace, Log: () => P.Log, Log1p: () => P.Log1p, LogSoftmax: () => P.LogSoftmax, LogicalAnd: () => P.LogicalAnd, LogicalNot: () => P.LogicalNot, LogicalOr: () => P.LogicalOr, LogicalXor: () => P.LogicalXor, LowerBound: () => P.LowerBound, MathBackendCPU: () => op, MathBackendWebGL: () => f_, MatrixBandPart: () => P.MatrixBandPart, Max: () => P.Max, MaxPool: () => P.MaxPool, MaxPool3D: () => P.MaxPool3D, MaxPool3DGrad: () => P.MaxPool3DGrad, MaxPoolGrad: () => P.MaxPoolGrad, MaxPoolWithArgmax: () => P.MaxPoolWithArgmax, Maximum: () => P.Maximum, Mean: () => P.Mean, Min: () => P.Min, Minimum: () => P.Minimum, MirrorPad: () => P.MirrorPad, Mod: () => P.Mod, MomentumOptimizer: () => P.MomentumOptimizer, Multinomial: () => P.Multinomial, Multiply: () => P.Multiply, Neg: () => P.Neg, NonMaxSuppressionV3: () => P.NonMaxSuppressionV3, NonMaxSuppressionV4: () => P.NonMaxSuppressionV4, NonMaxSuppressionV5: () => P.NonMaxSuppressionV5, NotEqual: () => P.NotEqual, OP_SCOPE_SUFFIX: () => P.OP_SCOPE_SUFFIX, OneHot: () => P.OneHot, OnesLike: () => P.OnesLike, Optimizer: () => P.Optimizer, OptimizerConstructors: () => P.OptimizerConstructors, Pack: () => P.Pack, PadV2: () => P.PadV2, Pool: () => P.Pool, Pow: () => P.Pow, Prelu: () => P.Prelu, Prod: () => P.Prod, RMSPropOptimizer: () => P.RMSPropOptimizer, RNN: () => uu, RaggedGather: () => P.RaggedGather, RaggedRange: () => P.RaggedRange, RaggedTensorToTensor: () => P.RaggedTensorToTensor, Range: () => P.Range, Rank: () => P.Rank, Real: () => P.Real, RealDiv: () => P.RealDiv, Reciprocal: () => P.Reciprocal, Reduction: () => P.Reduction, Relu: () => P.Relu, Relu6: () => P.Relu6, Reshape: () => P.Reshape, ResizeBilinear: () => P.ResizeBilinear, ResizeBilinearGrad: () => P.ResizeBilinearGrad, ResizeNearestNeighbor: () => P.ResizeNearestNeighbor, ResizeNearestNeighborGrad: () => P.ResizeNearestNeighborGrad, Reverse: () => P.Reverse, RotateWithOffset: () => P.RotateWithOffset, Round: () => P.Round, Rsqrt: () => P.Rsqrt, SGDOptimizer: () => P.SGDOptimizer, ScatterNd: () => P.ScatterNd, SearchSorted: () => P.SearchSorted, Select: () => P.Select, Selu: () => P.Selu, Sequential: () => ns, Sigmoid: () => P.Sigmoid, Sign: () => P.Sign, Sin: () => P.Sin, Sinh: () => P.Sinh, Slice: () => P.Slice, Softmax: () => P.Softmax, Softplus: () => P.Softplus, SpaceToBatchND: () => P.SpaceToBatchND, SparseFillEmptyRows: () => P.SparseFillEmptyRows, SparseReshape: () => P.SparseReshape, SparseSegmentMean: () => P.SparseSegmentMean, SparseSegmentSum: () => P.SparseSegmentSum, SparseToDense: () => P.SparseToDense, SplitV: () => P.SplitV, Sqrt: () => P.Sqrt, Square: () => P.Square, SquaredDifference: () => P.SquaredDifference, StaticRegexReplace: () => P.StaticRegexReplace, Step: () => P.Step, StridedSlice: () => P.StridedSlice, StringNGrams: () => P.StringNGrams, StringSplit: () => P.StringSplit, StringToHashBucketFast: () => P.StringToHashBucketFast, Sub: () => P.Sub, Sum: () => P.Sum, SymbolicTensor: () => Yi, Tan: () => P.Tan, Tanh: () => P.Tanh, Tensor: () => P.Tensor, TensorBuffer: () => P.TensorBuffer, TensorScatterUpdate: () => P.TensorScatterUpdate, Tile: () => P.Tile, TopK: () => P.TopK, Transform: () => P.Transform, Transpose: () => P.Transpose, Unique: () => P.Unique, Unpack: () => P.Unpack, UnsortedSegmentSum: () => P.UnsortedSegmentSum, UpperBound: () => P.UpperBound, Variable: () => P.Variable, ZerosLike: () => P.ZerosLike, _FusedMatMul: () => P._FusedMatMul, abs: () => P.abs, acos: () => P.acos, acosh: () => P.acosh, add: () => P.add, addN: () => P.addN, all: () => P.all, any: () => P.any, argMax: () => P.argMax, argMin: () => P.argMin, asin: () => P.asin, asinh: () => P.asinh, atan: () => P.atan, atan2: () => P.atan2, atanh: () => P.atanh, avgPool: () => P.avgPool, avgPool3d: () => P.avgPool3d, backend: () => P.backend, backend_util: () => P.backend_util, basicLSTMCell: () => P.basicLSTMCell, batchNorm: () => P.batchNorm, batchNorm2d: () => P.batchNorm2d, batchNorm3d: () => P.batchNorm3d, batchNorm4d: () => P.batchNorm4d, batchToSpaceND: () => P.batchToSpaceND, bincount: () => P.bincount, bitwiseAnd: () => P.bitwiseAnd, booleanMaskAsync: () => P.booleanMaskAsync, broadcastArgs: () => P.broadcastArgs, broadcastTo: () => P.broadcastTo, broadcast_util: () => P.broadcast_util, browser: () => P.browser, buffer: () => P.buffer, callbacks: () => yh, cast: () => P.cast, ceil: () => P.ceil, clipByValue: () => P.clipByValue, clone: () => P.clone, complex: () => P.complex, concat: () => P.concat, concat1d: () => P.concat1d, concat2d: () => P.concat2d, concat3d: () => P.concat3d, concat4d: () => P.concat4d, constraints: () => e, conv1d: () => P.conv1d, conv2d: () => P.conv2d, conv2dTranspose: () => P.conv2dTranspose, conv3d: () => P.conv3d, conv3dTranspose: () => P.conv3dTranspose, copyRegisteredKernels: () => P.copyRegisteredKernels, cos: () => P.cos, cosh: () => P.cosh, cosineWindow: () => P.cosineWindow, cumprod: () => P.cumprod, cumsum: () => P.cumsum, customGrad: () => P.customGrad, data: () => E, denseBincount: () => P.denseBincount, deprecationWarn: () => P.deprecationWarn, depthToSpace: () => P.depthToSpace, depthwiseConv2d: () => P.depthwiseConv2d, deregisterOp: () => _h, device_util: () => P.device_util, diag: () => P.diag, dilation2d: () => P.dilation2d, disableDeprecationWarnings: () => P.disableDeprecationWarnings, dispose: () => P.dispose, disposeVariables: () => P.disposeVariables, div: () => P.div, divNoNan: () => P.divNoNan, dot: () => P.dot, dropout: () => P.dropout, einsum: () => P.einsum, elu: () => P.elu, enableDebugMode: () => P.enableDebugMode, enableProdMode: () => P.enableProdMode, enclosingPowerOfTwo: () => P.enclosingPowerOfTwo, engine: () => P.engine, ensureShape: () => P.ensureShape, env: () => P.env, equal: () => P.equal, erf: () => P.erf, euclideanNorm: () => P.euclideanNorm, exp: () => P.exp, expandDims: () => P.expandDims, expm1: () => P.expm1, eye: () => P.eye, fft: () => P.fft, fill: () => P.fill, findBackend: () => P.findBackend, findBackendFactory: () => P.findBackendFactory, floor: () => P.floor, floorDiv: () => P.floorDiv, forceHalfFloat: () => m_, fused: () => P.fused, gather: () => P.gather, gatherND: () => P.gatherND, gather_util: () => P.gather_util, getBackend: () => P.getBackend, getGradient: () => P.getGradient, getKernel: () => P.getKernel, getKernelsForBackend: () => P.getKernelsForBackend, gpgpu_util: () => M, grad: () => P.grad, grads: () => P.grads, greater: () => P.greater, greaterEqual: () => P.greaterEqual, ifft: () => P.ifft, imag: () => P.imag, image: () => P.image, inTopKAsync: () => P.inTopKAsync, initializers: () => t, input: () => as, io: () => P.io, irfft: () => P.irfft, isFinite: () => P.isFinite, isInf: () => P.isInf, isNaN: () => P.isNaN, keep: () => P.keep, kernel_impls: () => P.kernel_impls, layers: () => i, leakyRelu: () => P.leakyRelu, less: () => P.less, lessEqual: () => P.lessEqual, linalg: () => P.linalg, linspace: () => P.linspace, loadGraphModel: () => Ud, loadGraphModelSync: () => Wd, loadLayersModel: () => ts, localResponseNormalization: () => P.localResponseNormalization, log: () => P.log, log1p: () => P.log1p, logSigmoid: () => P.logSigmoid, logSoftmax: () => P.logSoftmax, logSumExp: () => P.logSumExp, logicalAnd: () => P.logicalAnd, logicalNot: () => P.logicalNot, logicalOr: () => P.logicalOr, logicalXor: () => P.logicalXor, losses: () => P.losses, lowerBound: () => P.lowerBound, matMul: () => P.matMul, math: () => P.math, max: () => P.max, maxPool: () => P.maxPool, maxPool3d: () => P.maxPool3d, maxPoolWithArgmax: () => P.maxPoolWithArgmax, maximum: () => P.maximum, mean: () => P.mean, memory: () => P.memory, meshgrid: () => P.meshgrid, metrics: () => a, min: () => P.min, minimum: () => P.minimum, mirrorPad: () => P.mirrorPad, mod: () => P.mod, model: () => rs, models: () => o, moments: () => P.moments, movingAverage: () => P.movingAverage, mul: () => P.mul, multiRNNCell: () => P.multiRNNCell, multinomial: () => P.multinomial, neg: () => P.neg, nextFrame: () => P.nextFrame, norm: () => P.norm, notEqual: () => P.notEqual, oneHot: () => P.oneHot, ones: () => P.ones, onesLike: () => P.onesLike, op: () => P.op, outerProduct: () => P.outerProduct, pad: () => P.pad, pad1d: () => P.pad1d, pad2d: () => P.pad2d, pad3d: () => P.pad3d, pad4d: () => P.pad4d, pool: () => P.pool, pow: () => P.pow, prelu: () => P.prelu, print: () => P.print, prod: () => P.prod, profile: () => P.profile, raggedGather: () => P.raggedGather, raggedRange: () => P.raggedRange, raggedTensorToTensor: () => P.raggedTensorToTensor, rand: () => P.rand, randomGamma: () => P.randomGamma, randomNormal: () => P.randomNormal, randomStandardNormal: () => P.randomStandardNormal, randomUniform: () => P.randomUniform, randomUniformInt: () => P.randomUniformInt, range: () => P.range, ready: () => P.ready, real: () => P.real, reciprocal: () => P.reciprocal, registerBackend: () => P.registerBackend, registerCallbackConstructor: () => os, registerGradient: () => P.registerGradient, registerKernel: () => P.registerKernel, registerOp: () => kh, regularizers: () => s, relu: () => P.relu, relu6: () => P.relu6, removeBackend: () => P.removeBackend, reshape: () => P.reshape, reverse: () => P.reverse, reverse1d: () => P.reverse1d, reverse2d: () => P.reverse2d, reverse3d: () => P.reverse3d, reverse4d: () => P.reverse4d, rfft: () => P.rfft, round: () => P.round, rsqrt: () => P.rsqrt, scalar: () => P.scalar, scatterND: () => P.scatterND, scatter_util: () => P.scatter_util, searchSorted: () => P.searchSorted, selu: () => P.selu, separableConv2d: () => P.separableConv2d, sequential: () => is, serialization: () => P.serialization, setBackend: () => P.setBackend, setPlatform: () => P.setPlatform, setWebGLContext: () => Ux, setdiff1dAsync: () => P.setdiff1dAsync, shared: () => N, sigmoid: () => P.sigmoid, sign: () => P.sign, signal: () => P.signal, sin: () => P.sin, sinh: () => P.sinh, slice: () => P.slice, slice1d: () => P.slice1d, slice2d: () => P.slice2d, slice3d: () => P.slice3d, slice4d: () => P.slice4d, slice_util: () => P.slice_util, softmax: () => P.softmax, softplus: () => P.softplus, spaceToBatchND: () => P.spaceToBatchND, sparse: () => P.sparse, sparseToDense: () => P.sparseToDense, spectral: () => P.spectral, split: () => P.split, sqrt: () => P.sqrt, square: () => P.square, squaredDifference: () => P.squaredDifference, squeeze: () => P.squeeze, stack: () => P.stack, step: () => P.step, stridedSlice: () => P.stridedSlice, string: () => P.string, sub: () => P.sub, sum: () => P.sum, sumOutType: () => P.sumOutType, tan: () => P.tan, tanh: () => P.tanh, tensor: () => P.tensor, tensor1d: () => P.tensor1d, tensor2d: () => P.tensor2d, tensor3d: () => P.tensor3d, tensor4d: () => P.tensor4d, tensor5d: () => P.tensor5d, tensor6d: () => P.tensor6d, tensorScatterUpdate: () => P.tensorScatterUpdate, tensor_util: () => P.tensor_util, test_util: () => P.test_util, tidy: () => P.tidy, tile: () => P.tile, time: () => P.time, topk: () => P.topk, train: () => P.train, transpose: () => P.transpose, truncatedNormal: () => P.truncatedNormal, unique: () => P.unique, unregisterGradient: () => P.unregisterGradient, unregisterKernel: () => P.unregisterKernel, unsortedSegmentSum: () => P.unsortedSegmentSum, unstack: () => P.unstack, upcastType: () => P.upcastType, upperBound: () => P.upperBound, util: () => P.util, valueAndGrad: () => P.valueAndGrad, valueAndGrads: () => P.valueAndGrads, variable: () => P.variable, variableGrads: () => P.variableGrads, version: () => cM, version_converter: () => Vd, version_core: () => P.version_core, version_cpu: () => Dg, version_layers: () => Fo, version_webgl: () => p_, webgl: () => g_, webgl_util: () => I, where: () => P.where, whereAsync: () => P.whereAsync, zeros: () => P.zeros, zerosLike: () => P.zerosLike }); var D = {}; n.r(D), n.d(D, { hasBrowserEnv: () => jF, hasStandardBrowserEnv: () => WF, hasStandardBrowserWebWorkerEnv: () => VF, navigator: () => UF, origin: () => GF }); var $ = {}; n.r($), n.d($, { load: () => Eq, version: () => _q }); var R = {}; n.r(R), n.d(R, { Darknet: () => zq, load: () => Pq }); var O = {}; n.r(O), n.d(O, { Doodlenet: () => Uq, load: () => Wq }); var z = {}; n.r(z), n.d(z, { SpeechCommands: () => IY, load: () => MY }); var P = n(5838), B = n(5441), L = n(9809), j = n(9258), U = n(700); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const W = { kernelName: B.ljI, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, U.P)((0, L.w)(n, "float32"), -1)) } } }; var V = n(9359), G = n(6522), H = n(5702), q = n(9348), Y = n(5793), X = n(7126); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const K = { kernelName: B.Vvy, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, Y.E)((0, L.w)(n, "float32")), r = (0, q.R)((0, X.j)((0, H.d)(1), t)); return (0, G.H)((0, V.y)(e, r)) } } } }, Z = { kernelName: B.PH8, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, q.R)((0, X.j)((0, Y.E)((0, L.w)(n, "float32")), 1)); return (0, V.y)(e, t) } } } }; var J = n(2198), Q = n(2302), ee = n(3791); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const te = { kernelName: B.OMN, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = J.assertAndGetBroadcastShape(n.shape, r.shape); return { a: () => { let t = e; const r = J.getReductionAxes(n.shape, i); return r.length > 0 && (t = (0, ee.c)(t, r)), (0, Q.t)(t, n.shape) }, b: () => { let t = e; const n = J.getReductionAxes(r.shape, i); return n.length > 0 && (t = (0, ee.c)(t, n)), (0, Q.t)(t, r.shape) } } } }, ne = { kernelName: B.EkD, saveAllInputs: !0, gradFunc: (e, t) => { const n = {}; return t.forEach(((t, r) => { n[r] = () => e.clone() })), n } }; var re = n(5537); + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const ie = { kernelName: B.Jp_, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, re.P)(n) } } }, ae = { kernelName: B.p_m, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, re.P)(n) } } }, oe = { kernelName: B.QKF, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, q.R)((0, X.j)((0, H.d)(1), (0, Y.E)((0, L.w)(n, "float32"))))) } } }; var se = n(7523); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const ue = { kernelName: B.epO, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, q.R)((0, se.W)((0, H.d)(1), (0, Y.E)((0, L.w)(n, "float32")))); return (0, V.y)(e, t) } } } }, le = { kernelName: B.lxb, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, se.W)((0, Y.E)(n), (0, Y.E)(r)); let a = (0, j.l)(e, (0, V.y)(r, t)); const o = (0, J.getReductionAxes)(n.shape, i); return o.length > 0 && (a = (0, ee.c)(a, o)), (0, Q.t)(a, n.shape) }, b: () => { const t = (0, se.W)((0, Y.E)(n), (0, Y.E)(r)); let a = (0, G.H)((0, j.l)(e, (0, V.y)(n, t))); const o = (0, J.getReductionAxes)(r.shape, i); return o.length > 0 && (a = (0, ee.c)(a, o)), (0, Q.t)(a, r.shape) } } } }, ce = { kernelName: B.TyE, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, se.W)((0, Y.E)((0, L.w)(n, "float32")), 1)) } } }, he = { kernelName: B.zP9, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, X.j)((0, H.d)(1), (0, Y.E)((0, L.w)(n, "float32")))) } } }; var de = n(1585), fe = n(8189), pe = n(5119), me = n(7195), ge = n(929); const ye = (0, ge.op)({ + avgPool3dGrad_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i, a) { const o = (0, fe.YT)(e, "dy", "avgPool3dGrad"), s = (0, fe.YT)(t, "input", "avgPool3dGrad"); let u = o, l = s, c = !1; 4 === s.rank && (c = !0, u = (0, Q.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]]), l = (0, Q.t)(s, [1, s.shape[0], s.shape[1], s.shape[2], s.shape[3]])), pe.vA(5 === u.rank, (() => `Error in avgPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)), pe.vA(5 === l.rank, (() => `Error in avgPool3dGrad: input must be rank 5 but got rank ${l.rank}.`)), (0, me.s_)("avgPool3dGrad", i, a); const h = { dy: u, input: l }, d = { filterSize: n, strides: r, pad: i, dimRoundingMode: a }, f = de.T2.runKernel(B.wwC, h, d); return c ? (0, Q.t)(f, [f.shape[1], f.shape[2], f.shape[3], f.shape[4]]) : f } + }), be = { kernelName: B.cS, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { filterSize: i, strides: a, pad: o, dimRoundingMode: s } = n; return { x: () => ye(e, r, i, a, o, s) } } }; const ve = (0, ge.op)({ + avgPoolGrad_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i) { const a = (0, fe.YT)(e, "dy", "avgPoolGrad"), o = (0, fe.YT)(t, "input", "avgPoolGrad"); pe.vA(o.rank === a.rank, (() => `Rank of input (${o.rank}) does not match rank of dy (${a.rank})`)); let s = o, u = a, l = !1; 3 === o.rank && (l = !0, s = (0, Q.t)(o, [1, o.shape[0], o.shape[1], o.shape[2]]), u = (0, Q.t)(a, [1, a.shape[0], a.shape[1], a.shape[2]])), pe.vA(4 === u.rank, (() => `Error in avgPoolGrad: dy must be rank 4 but got rank ${u.rank}.`)), pe.vA(4 === s.rank, (() => `Error in avgPoolGrad: input must be rank 4 but got rank ${s.rank}.`)); const c = { dy: u, input: s }, h = { filterSize: n, strides: r, pad: i }, d = de.T2.runKernel(B.VCH, c, h); return l ? (0, Q.t)(d, [d.shape[1], d.shape[2], d.shape[3]]) : d } + }), xe = { kernelName: B.ho8, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { filterSize: i, strides: a, pad: o } = n; return { x: () => ve(e, r, i, a, o) } } }; var we = n(5703); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const ke = { kernelName: B.jAQ, inputsToSave: ["a", "b"], gradFunc: (e, t, n) => { const [r, i] = t, { transposeA: a, transposeB: o } = n; return a || o ? !a && o ? { a: () => (0, we.N)(e, i, !1, !1), b: () => (0, we.N)(e, r, !0, !1) } : a && !o ? { a: () => (0, we.N)(i, e, !1, !0), b: () => (0, we.N)(r, e, !1, !1) } : { a: () => (0, we.N)(i, e, !0, !0), b: () => (0, we.N)(e, r, !0, !0) } : { a: () => (0, we.N)(e, i, !1, !0), b: () => (0, we.N)(r, e, !0, !1) } } }; var Se = n(776); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const _e = { kernelName: B.Ik2, gradFunc: (e, t, n) => { const { blockShape: r, crops: i } = n; return { x: () => (0, Se.e)(e, r, i) } } }, Ce = { kernelName: B.LB5, gradFunc: (e, t, n) => { const r = n, i = r.inputShape, a = r.shape, o = Array.from(a); for (let e = i.length - 1; e >= 0; e--)if (i[e] === a[e]) o[e] = 1; else if (1 !== i[e]) throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${a}].`); const s = []; for (let e = 0; e < o.length; e++)o[e] > 1 && s.push(e); return { x: () => (0, ee.c)(e, s, !0) } } }, Ae = { kernelName: B.KXH, gradFunc: e => ({ x: () => e.clone() }) }, Te = { kernelName: B.QDP, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var Ee = n(3337), Ne = n(6508), Ie = n(3789), Me = n(2151); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Fe = { kernelName: B.vaV, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { clipValueMin: i, clipValueMax: a } = n; return { x: () => (0, Me._)((0, Ie.n)((0, Ee.D)(r, i), (0, Ne.I)(r, a)), e, (0, re.P)(e)) } } }, De = { kernelName: B.$zE, inputsToSave: ["x"], gradFunc: W.gradFunc }; var $e = n(6512); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Re = { kernelName: B.$dB, saveAllInputs: !0, gradFunc: (e, t, n) => { const r = t.map((e => e.shape)), { axis: i } = n, a = (0, pe.Y6)(i, t[0].shape)[0], o = r.map((e => e[a])); return (0, $e.l)(e, o, a).map((e => () => e)) } }; var Oe = n(5248), ze = n(252); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Pe = { kernelName: B.p2J, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const [r, i] = t, { dilations: a, strides: o, pad: s, dataFormat: u } = n; return pe.vA(me.Dh(a), (() => `Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`)), { x: () => (0, ze.v)(r.shape, e, i, o, s, u), filter: () => (0, Oe.H)(r, e, i.shape, o, s, u) } } }; var Be = n(8794); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Le = { kernelName: B.jfg, inputsToSave: ["dy", "filter"], gradFunc: (e, t, n) => { const [r, i] = t, { strides: a, pad: o, dataFormat: s, dimRoundingMode: u } = n; return { dy: () => (0, Be.X)(e, i, a, o, s, 1, u), filter: () => (0, Oe.H)(e, r, i.shape, a, o, s, u) } } }; const je = (0, ge.op)({ + conv3DBackpropFilter_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i) { let a = e; 4 === e.rank && (a = (0, Q.t)(e, [1, e.shape[0], e.shape[1], e.shape[2], e.shape[3]])); let o = t; 4 === o.rank && (o = (0, Q.t)(t, [1, t.shape[0], t.shape[1], t.shape[2], t.shape[3]])), pe.vA(5 === a.rank, (() => `Error in conv3dDerFilter: input must be rank 5, but got shape ${a.shape}.`)), pe.vA(5 === o.rank, (() => `Error in conv3dDerFilter: dy must be rank 5, but got shape ${o.shape}.`)), pe.vA(5 === n.length, (() => `Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)), pe.vA(a.shape[4] === n[3], (() => `Error in conv3dDerFilter: depth of input ${a.shape[4]}) must match input depth in filter (${n[3]}.`)), pe.vA(o.shape[4] === n[4], (() => `Error in conv3dDerFilter: depth of dy (${o.shape[4]}) must match output depth for filter (${n[4]}).`)); const s = { x: a, dy: o }, u = { strides: r, pad: i, filterShape: n }; return de.T2.runKernel(B.iGz, s, u) } + }); var Ue = n(1895); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const We = { kernelName: B.A1h, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const { dilations: r, strides: i, pad: a } = n; pe.vA((0, me.Dh)(r), (() => `Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`)); const [o, s] = t; return { x: () => (0, Ue.c)(o.shape, e, s, i, a), filter: () => je(o, e, s.shape, i, a) } } }; var Ve = n(3726); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ge = { kernelName: B.Mn0, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, G.H)((0, Ve.F)((0, L.w)(n, "float32"))), e) } } }; var He = n(8276); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const qe = { kernelName: B.MnK, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, He.L)((0, L.w)(n, "float32")), e) } } }; var Ye = n(1078), Xe = n(6808), Ke = n(7703); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ze = { kernelName: B.nY8, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { axis: i, exclusive: a, reverse: o } = n; return { x: () => { const t = (0, Ye.Em)([i], r.rank); let n = (0, Xe.r)(e, i, a, !o); return null != t && (n = (0, Ke.m)(n, t)), n } } } }; var Je = n(1890), Qe = n(3134); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const et = { kernelName: B.tGH, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const { dilations: r, strides: i, pad: a, dimRoundingMode: o } = n, s = null == r ? [1, 1] : r; pe.vA(me.Dh(s), (() => `Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`)); const [u, l] = t; return pe.vA(4 === u.rank, (() => `Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`)), pe.vA(4 === l.rank, (() => `Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${l.rank}.`)), pe.vA(u.shape[3] === l.shape[2], (() => `Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`)), pe.vA(me.G0(i, s), (() => `Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${s}'.`)), me.s_("depthwiseConv2d", a, o), { x: () => (0, Qe.l)(u.shape, e, l, i, a, s, o), filter: () => (0, Je.x)(u, e, l.shape, i, a, s, o) } } }, tt = { kernelName: B.jxD, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const [r, i] = t, a = { x: r, filter: i, dy: e }, o = { x: r, filter: i, dy: e }; return { x: () => de.T2.runKernel(B.bP9, a, n), filter: () => de.T2.runKernel(B.pk0, o, n) } } }, nt = { kernelName: B.Pah, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t, r = { dy: e, y: n }; return { x: () => de.T2.runKernel(B.rsH, r) } } }; var rt = n(8631); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const it = { kernelName: B._s9, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t, r = (0, j.l)((0, rt.o)((0, G.H)((0, Y.E)(n))), 2 / Math.sqrt(Math.PI)); return { x: () => (0, j.l)(e, r) } } }, at = { kernelName: B.ox3, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, n) } } }, ot = { kernelName: B.ybN, inputsToSave: ["input"], gradFunc: (e, t) => { const [n] = t; return { input: () => (0, Q.t)(e, n.shape) } } }, st = { kernelName: B.ybj, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, rt.o)(n)) } } }, ut = { kernelName: B.ZgB, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, lt = { kernelName: B.ElG, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, V.y)(e, (0, L.w)(r, "float32")), a = (0, J.getReductionAxes)(n.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), n.shape) : t }, b: () => { let t = (0, j.l)(e, (0, L.w)(n, "float32")); const a = (0, J.getReductionAxes)(r.shape, i); a.length > 0 && (t = (0, Q.t)((0, ee.c)(t, a), r.shape)); const o = (0, Y.E)(r); return (0, G.H)((0, V.y)(t, (0, L.w)(o, "float32"))) } } } }; var ct = n(7820), ht = n(4826); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const dt = { kernelName: B.i5R, inputsToSave: ["x", "mean", "variance", "scale"], gradFunc: (e, t, n) => { const { varianceEpsilon: r } = n, [i, a, o, s] = t, u = null == s ? (0, H.d)(1) : s, l = (0, J.getReductionAxes)(a.shape, i.shape), c = []; if (1 === a.rank) { for (let e = 0; e < i.shape.length - 1; ++e)c.push(i.shape[e]); c.push(1) } const h = (0, X.j)(i, a), d = (0, j.l)(e, u), f = (0, ct.Z)((0, se.W)(o, (0, H.d)(r))), p = (0, j.l)((0, j.l)((0, j.l)(f, f), f), (0, H.d)(-.5)); return { x: () => 1 === a.rank ? (0, Q.t)((0, j.l)((0, j.l)(e, (0, ht.V)((0, Q.t)(f, [1, 1, 1, a.shape[0]]), c)), u), i.shape) : (0, Q.t)((0, j.l)((0, j.l)(e, f), u), i.shape), mean: () => { let e = (0, j.l)((0, j.l)(f, (0, H.d)(-1)), d); return 1 === a.rank && (e = (0, ee.c)(e, l)), (0, Q.t)(e, a.shape) }, variance: () => { let e = (0, j.l)((0, j.l)(p, h), d); return 1 === a.rank && (e = (0, ee.c)(e, l)), (0, Q.t)(e, a.shape) }, scale: () => { const t = (0, j.l)(h, f); let n = (0, j.l)(e, t); return 1 === a.rank && (n = (0, ee.c)(n, l)), (0, Q.t)(n, a.shape) }, offset: () => { let t = e; return 1 === a.rank && (t = (0, ee.c)(t, l)), (0, Q.t)(t, a.shape) } } } }; var ft = n(4268), pt = n(7706); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const mt = { kernelName: B.mxL, inputsToSave: ["x", "indices"], gradFunc: (e, t, n) => { const [r, i] = t, { axis: a, batchDims: o } = n, s = (0, pe.Y6)(a, r.shape)[0], u = (e, t, n) => () => { const r = e.shape, i = t.size, o = r.slice(0, s), u = o.length, l = r.slice(a, r.length).slice(1), c = l.length, h = gt(0, u), d = gt(u + 1, u + 1 + c), f = yt([o, [i], l]), p = (0, Q.t)(n, f), m = (0, Q.t)(t, [i]), g = yt([[u], h, d]), y = (0, Ke.m)(p, g); let b = (0, pt.z)(y, m, e.shape[s]); const v = (0, Ye.gx)(g); return b = (0, Ke.m)(b, v), b }; if (1 === o) { const t = r.shape[0], n = r.split(t, 0); return { x: () => { const t = (0, ft.t)(n.map(((t, n) => u(t, i.slice(n, 1), e.slice(n, 1))()))); return t.reshape(r.shape) }, indices: () => i } } return { x: u(r, i, e), indices: () => i } } }; function gt(e, t) { const n = []; for (let r = e; r < t; ++r)n.push(r); return n } function yt(e) { const t = []; for (let n = 0; n < e.length; ++n)for (let r = 0; r < e[n].length; ++r)t.push(e[n][r]); return t } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const bt = { kernelName: B.lLS, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t; return { a: () => (0, re.P)(n), b: () => (0, re.P)(r) } } }, vt = { kernelName: B.lzr, gradFunc: e => ({ x: () => (0, L.w)(e, "float32") }) }, xt = { kernelName: B.gIW, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, wt = { kernelName: B.E3$, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, kt = { kernelName: B.iPs, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var St = n(2058); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const _t = { kernelName: B.X0$, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { alpha: i } = n, a = (0, St.r)(r, 0); return { x: () => (0, Me._)(a, e, (0, j.l)(e, i)) } } }, Ct = { kernelName: B.Cg$, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, se.W)(n, 1)) } } }, At = { kernelName: B.tG8, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, L.w)(n, "float32")) } } }, Tt = { kernelName: B.zfU, inputsToSave: [], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r] = t, { axis: i } = n; return { logits: () => { const t = (0, rt.o)(r); return (0, X.j)(e, (0, j.l)((0, ee.c)(e, i, !0), t)) } } } }; const Et = (0, ge.op)({ + localResponseNormalizationBackprop_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r = 5, i = 1, a = 1, o = .5) { const s = { x: e, y: t, dy: n }, u = { depthRadius: r, bias: i, alpha: a, beta: o }; return de.T2.runKernel(B.ToN, s, u) } + }), Nt = { kernelName: B.jM4, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r, i] = t, { depthRadius: a, bias: o, alpha: s, beta: u } = n; return { x: () => Et(r, i, e, a, o, s, u) } } }; var It = n(3020); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Mt(e, t, n, r) { return t.rank < n.rank && (t = (0, Q.t)(t, Ye.SM(t.shape, r))), e.rank < n.rank && (e = (0, Q.t)(e, Ye.SM(e.shape, r))), { x: () => (0, j.l)(e, (0, L.w)((0, It.L)(n, t), e.dtype)) } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ft = { kernelName: B.VAI, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const r = n, { reductionIndices: i } = r, a = t[0], o = Mt(e, t[1], a, pe.Y6(i, a.shape)); return { x: () => o.x() } } }; var Dt = n(1303); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const $t = { kernelName: B.LDN, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t; return { a: () => (0, j.l)(e, (0, L.w)((0, Ee.D)(n, r), "float32")), b: () => (0, j.l)(e, (0, L.w)((0, Dt.M)(n, r), "float32")) } } }; const Rt = (0, ge.op)({ + maxPool3dGrad_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i, a, o) { const s = (0, fe.YT)(e, "dy", "maxPool3dGrad"), u = (0, fe.YT)(t, "input", "maxPool3dGrad"), l = (0, fe.YT)(n, "output", "maxPool3dGrad"); let c = s, h = u, d = l, f = !1; 4 === u.rank && (f = !0, c = (0, Q.t)(s, [1, s.shape[0], s.shape[1], s.shape[2], s.shape[3]]), h = (0, Q.t)(u, [1, u.shape[0], u.shape[1], u.shape[2], u.shape[3]]), d = (0, Q.t)(l, [1, l.shape[0], l.shape[1], l.shape[2], l.shape[3]])), pe.vA(5 === c.rank, (() => `Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`)), pe.vA(5 === h.rank, (() => `Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`)), pe.vA(5 === d.rank, (() => `Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`)), (0, me.s_)("maxPool3dGrad", a, o); const p = { dy: c, input: h, output: d }, m = { filterSize: r, strides: i, pad: a, dimRoundingMode: o }, g = de.T2.runKernel(B.cHb, p, m); return f ? (0, Q.t)(g, [g.shape[1], g.shape[2], g.shape[3], g.shape[4]]) : g } + }), Ot = { kernelName: B.ySp, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r, i] = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = n; return { x: () => Rt(e, r, i, a, o, s, u) } } }; const zt = (0, ge.op)({ + maxPoolGrad_: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i, a, o) { const s = (0, fe.YT)(e, "dy", "maxPoolGrad"), u = (0, fe.YT)(t, "input", "maxPoolGrad"), l = (0, fe.YT)(n, "output", "maxPoolGrad"); pe.vA(u.rank === s.rank, (() => `Rank of input (${u.rank}) does not match rank of dy (${s.rank})`)), pe.vA(4 === s.rank, (() => `Error in maxPoolGrad: dy must be rank 4 but got rank ${s.rank}.`)), pe.vA(4 === u.rank, (() => `Error in maxPoolGrad: input must be rank 4 but got rank ${u.rank}.`)), me.s_("maxPoolGrad", a, o); const c = { dy: s, input: u, output: l }, h = { filterSize: r, strides: i, pad: a, dimRoundingMode: o }; return de.T2.runKernel(B.RXX, c, h) } + }), Pt = { kernelName: B.t3d, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r, i] = t, { filterSize: a, strides: o, pad: s } = n; return { x: () => zt(e, r, i, a, o, s) } } }; var Bt = n(1411); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Lt = { kernelName: B.g5A, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { axis: i } = n, a = pe.Y6(i, r.shape), o = (0, Ye.lb)(r.shape, a)[1], s = pe.Ze(o); return { x: () => { const t = r.shape.slice(); a.forEach((e => { t[e] = 1 })); const n = (0, Q.t)(e, t); return (0, V.y)((0, j.l)(n, (0, Bt.S)(r.shape, "float32")), s) } } } }, jt = { kernelName: B.lNG, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const r = n, { axis: i } = r, [a, o] = t, s = Mt(e, o, a, pe.Y6(i, a.shape)); return { x: () => s.x() } } }, Ut = { kernelName: B.LG0, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t; return { a: () => (0, j.l)(e, (0, L.w)((0, Ne.I)(n, r), "float32")), b: () => (0, j.l)(e, (0, L.w)((0, St.r)(n, r), "float32")) } } }; var Wt = n(7986); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Vt = { kernelName: B.x7F, inputsToSave: ["x"], gradFunc: (e, t, n) => { const r = t[0], { paddings: i } = n, a = i.map((e => e[0])); return { x: () => (0, Wt.d)(e, a, r.shape) } } }; var Gt = n(5606); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ht = { kernelName: B.BLA, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, J.getReductionAxes)(n.shape, i); return t.length > 0 ? (0, Q.t)((0, ee.c)(e, t), n.shape) : e }, b: () => { const t = (0, j.l)(e, (0, G.H)((0, Gt.R)((0, V.y)(n, r)))), a = (0, J.getReductionAxes)(r.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), r.shape) : t } } } }, qt = { kernelName: B.xu7, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, j.l)(e, (0, L.w)(r, "float32")), a = (0, J.getReductionAxes)(n.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), n.shape) : t }, b: () => { const t = (0, j.l)(e, (0, L.w)(n, "float32")), a = (0, J.getReductionAxes)(r.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), r.shape) : t } } } }, Yt = { kernelName: B.l0G, gradFunc: e => ({ x: () => (0, G.H)(e) }) }; var Xt = n(2855); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Kt = { kernelName: B.urI, inputsToSave: ["indices"], gradFunc: (e, t) => { const n = t[0]; return { indices: () => (0, Xt.U)(n.shape, "float32") } } }, Zt = { kernelName: B.LWX, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var Jt = n(7261); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Qt = { kernelName: B.mM$, saveAllInputs: !0, gradFunc: (e, t, n) => { const { axis: r } = n; return (0, Jt.K)(e, r).map((e => () => e)) } }, en = { kernelName: B.ODT, inputsToSave: ["x"], gradFunc: (e, t, n) => { const r = t[0], { paddings: i } = n, a = i.map((e => e[0])); return { x: () => (0, Wt.d)(e, a, r.shape) } } }; var tn = n(4010), nn = n(8990); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const rn = { kernelName: B.pyJ, inputsToSave: ["a", "b"], outputsToSave: [!0], gradFunc: (e, t) => { const [n, r, i] = t, a = n, o = r, s = J.assertAndGetBroadcastShape(a.shape, o.shape); return { a: () => { const t = (0, L.w)(o, "float32"); let n = (0, j.l)(e, (0, j.l)(t, (0, nn.n)(a, (0, X.j)(t, (0, H.d)(1))))); const r = J.getReductionAxes(a.shape, s); return r.length > 0 && (n = (0, ee.c)(n, r)), (0, Q.t)(n, a.shape) }, b: () => { const t = (0, St.r)(a, 0), n = (0, Me._)(t, (0, tn.R)(a), (0, re.P)(a)); let r = (0, j.l)(e, (0, j.l)(i, n)); const u = J.getReductionAxes(o.shape, s); return u.length > 0 && (r = (0, ee.c)(r, u)), (0, Q.t)(r, o.shape) } } } }, an = { kernelName: B.Ncv, inputsToSave: ["x", "alpha"], gradFunc: (e, t) => { const [n, r] = t, i = (0, St.r)(n, 0); return { x: () => (0, Me._)(i, e, (0, j.l)(e, r)), alpha: () => { let t = (0, Me._)(i, (0, re.P)(e), (0, j.l)(e, n)); const a = (0, J.getReductionAxes)(r.shape, e.shape); return a.length > 0 && (t = (0, ee.c)(t, a)), (0, Q.t)(t, r.shape) } } } }; var on = n(302); function sn(e, t, n) { + const r = e.shape.length, i = r - n.length, a = Ye.Em(n, r); let o = e; null != a && (o = (0, Ke.m)(e, a)); const s = o.shape.slice(), u = s.splice(r - n.length, n.length).reduce(((e, t) => e * t), 1); s.push(u); let l = + /** + * @license + * Copyright 2022 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = e.shape.slice(); r[n] = 1; const i = (0, Q.t)(t, r), a = (0, on.L)(e, n, !0, !1), o = (0, on.L)(e, n, !0, !0), s = (0, j.l)(a, o); return (0, j.l)(i, s) }(o.reshape(s), t, i); if (l = l.reshape(o.shape), null != a) { const e = Ye.gx(a); l = (0, Ke.m)(l, e) } return l + } const un = { kernelName: B.kdj, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { axis: i } = n; let a = []; return a = null == i ? r.shape.map(((e, t) => t)) : "number" == typeof i ? [i] : i, { x: () => sn(r, e, a) } } }, ln = { kernelName: B.sDr, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = J.assertAndGetBroadcastShape(n.shape, r.shape); return { a: () => { const t = (0, V.y)(e, (0, L.w)(r, "float32")), a = J.getReductionAxes(n.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), n.shape) : t }, b: () => { let t = (0, j.l)(e, (0, L.w)(n, "float32")); const a = J.getReductionAxes(r.shape, i); a.length > 0 && (t = (0, Q.t)((0, ee.c)(t, a), r.shape)); const o = (0, Y.E)(r); return (0, G.H)((0, V.y)(t, (0, L.w)(o, "float32"))) } } } }, cn = { kernelName: B.huO, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, G.H)((0, Y.E)(n))) } } }, hn = { kernelName: B.P_L, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t, r = (0, j.l)((0, Ne.I)(n, 6), (0, U.P)(n)); return { x: () => (0, j.l)(e, (0, L.w)(r, "float32")) } } }, dn = { kernelName: B.fUj, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, L.w)((0, U.P)(n), "float32")) } } }, fn = { kernelName: B.R23, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, Q.t)(e, n.shape) } } }, pn = { kernelName: B.hgw, inputsToSave: ["images"], gradFunc: (e, t, n) => { const [r] = t, i = { dy: e, images: r }; return { images: () => de.T2.runKernel(B.FCQ, i, n) } } }, mn = { kernelName: B.jOE, inputsToSave: ["images"], gradFunc: (e, t, n) => { const [r] = t, i = { dy: e, images: r }; return { images: () => de.T2.runKernel(B.XQy, i, n) } } }; var gn = n(3262); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const yn = { kernelName: B.D7i, gradFunc: (e, t, n) => { const { dims: r } = n, i = (0, pe.Y6)(r, e.shape); return { x: () => (0, gn.B)(e, i) } } }, bn = { kernelName: B.hVg, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, vn = { kernelName: B.TOR, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, G.H)((0, V.y)(e, (0, j.l)((0, nn.n)(n, 1.5), 2))) } } }; var xn = n(9881); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const wn = { kernelName: B.l6P, inputsToSave: ["condition"], gradFunc: (e, t) => { const [n] = t; return { condition: () => (0, L.w)((0, re.P)(n), "float32"), t: () => (0, j.l)(e, (0, L.w)(n, e.dtype)), e: () => (0, j.l)(e, (0, L.w)((0, xn.N)(n), e.dtype)) } } }; var kn = n(8576); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Sn = { kernelName: B.u$b, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, St.r)(n, (0, H.d)(0)), r = (0, H.d)(kn.j), i = (0, H.d)(kn.X), a = (0, j.l)(e, i), o = (0, j.l)((0, j.l)(e, r), (0, rt.o)((0, L.w)(n, "float32"))); return (0, Me._)(t, a, o) } } } }, _n = { kernelName: B.vI1, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, j.l)(n, (0, X.j)((0, H.d)(1), n))) } } }, Cn = { kernelName: B.YVe, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var An = n(9907); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Tn = { kernelName: B.hql, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, An.g)((0, L.w)(n, "float32")), e) } } }; var En = n(7451); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Nn = { kernelName: B.J3C, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, En.y)((0, L.w)(n, "float32")), e) } } }; var In = n(5661), Mn = n(4969); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Fn = { kernelName: B.JiE, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { begin: i, size: a } = n, o = r.shape, [s, u] = (0, Mn.parseSliceParams)(r, i, a), l = []; for (let t = 0; t < e.rank; t++)l.push([s[t], o[t] - s[t] - u[t]]); return { x: () => (0, In.e)(e, l) } } }, Dn = { kernelName: B.rFG, outputsToSave: [!0], gradFunc: (e, t, n) => { const [r] = t, { dim: i } = n, a = (0, j.l)(e, r); return { logits: () => (0, X.j)(a, (0, j.l)((0, ee.c)(a, [i], true), r)) } } }; var $n = n(8968); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Rn = { kernelName: B.Fin, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, $n.r)(n)) } } }; var On = n(9772); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const zn = { kernelName: B.A8B, gradFunc: (e, t, n) => { const { blockShape: r, paddings: i } = n; return { x: () => (0, On.G)(e, r, i) } } }; var Pn = n(5030); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Bn = { kernelName: B.Blb, gradFunc: (e, t, n) => { const { axis: r } = n; return { x: () => (0, Pn.x)(e, r) } } }, Ln = { kernelName: B.dFH, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, j.l)((0, q.R)((0, L.w)(n, "float32")), 2)) } } }, jn = { kernelName: B.M6A, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, j.l)((0, L.w)(n, "float32"), 2)) } } }, Un = { kernelName: B.Ddj, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, H.d)(2); return { a: () => (0, j.l)(e, (0, j.l)(i, (0, X.j)(n, r))), b: () => (0, j.l)(e, (0, j.l)(i, (0, X.j)(r, n))) } } }, Wn = { kernelName: B.pnw, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, Vn = { kernelName: B.PbM, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = J.assertAndGetBroadcastShape(n.shape, r.shape); return { a: () => { let t = e; const r = J.getReductionAxes(n.shape, i); return r.length > 0 && (t = (0, ee.c)(t, r)), (0, Q.t)(t, n.shape) }, b: () => { let t = e; const n = J.getReductionAxes(r.shape, i); return n.length > 0 && (t = (0, ee.c)(t, n)), (0, Q.t)((0, G.H)(t), r.shape) } } } }, Gn = { kernelName: B.WuN, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, i = r.shape.slice(), { axis: a } = n; (0, pe.Y6)(a, r.shape).forEach((e => { i[e] = 1 })); const o = (0, Q.t)(e, i), s = (0, j.l)(o, (0, Bt.S)(r.shape, "float32")); return { x: () => s } } }, Hn = { kernelName: B.oFs, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, Y.E)((0, An.g)(n))) } } }, qn = { kernelName: B.iuW, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, X.j)((0, H.d)(1), (0, Y.E)(n)), e) } } }, Yn = { kernelName: B.FAs, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { reps: i } = n; return { x: () => { let t = (0, re.P)(r); if (1 === r.rank) for (let n = 0; n < i[0]; ++n)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0]], [r.shape[0]])); else if (2 === r.rank) for (let n = 0; n < i[0]; ++n)for (let a = 0; a < i[1]; ++a)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0], a * r.shape[1]], [r.shape[0], r.shape[1]])); else if (3 === r.rank) for (let n = 0; n < i[0]; ++n)for (let a = 0; a < i[1]; ++a)for (let o = 0; o < i[2]; ++o)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0], a * r.shape[1], o * r.shape[2]], [r.shape[0], r.shape[1], r.shape[2]])); else { if (4 !== r.rank) throw new Error(`Gradient for tile operation is not implemented for rank-${r.rank} tensors yet.`); for (let n = 0; n < i[0]; ++n)for (let a = 0; a < i[1]; ++a)for (let o = 0; o < i[2]; ++o)for (let s = 0; s < i[3]; ++s)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0], a * r.shape[1], o * r.shape[2], s * r.shape[3]], [r.shape[0], r.shape[1], r.shape[2], r.shape[3]])) } return t } } } }, Xn = { kernelName: B.wx0, gradFunc: (e, t, n) => { const r = n, { perm: i } = r, a = Ye.gx(i); return { x: () => (0, Ke.m)(e, a) } } }, Kn = { kernelName: B.dXR, gradFunc: (e, t, n) => { const r = n, { axis: i } = r; return { value: () => (0, ft.t)(e, i) } } }; var Zn = n(8710), Jn = n(8229), Qn = n(178); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const er = { kernelName: B.pPe, inputsToSave: ["segmentIds"], gradFunc: (e, t) => { const [n] = t; return { x: () => function (e, t) { const n = (0, Qn.P)(t, (0, re.P)(t)), r = (0, Jn.k)(e, n); let i = (0, Ee.D)(t, (0, H.d)(0, "int32")); const a = r.rank - i.rank; for (let e = 0; e < a; ++e)i = (0, Zn.U)(i, e + 1); i = (0, Ie.n)(i, (0, Bt.S)(r.shape, "bool")); const o = (0, re.P)(r); return (0, Me._)(i, r, o) }(e, n) } } }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const tr = { kernelName: B.xJ3, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var nr = n(7074); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const rr = [W, K, Z, te, ne, ie, ae, oe, ue, le, ce, he, be, xe, ke, _e, Ce, Ae, Te, Fe, De, Re, Le, Pe, We, Ge, qe, Ze, et, tt, ln, nt, it, at, ot, st, lt, ut, dt, mt, bt, vt, xt, wt, kt, _t, Ct, At, Tt, Nt, Ft, Ft, $t, Ot, Pt, Lt, jt, Ut, Vt, Ht, qt, Yt, Kt, Zt, Qt, en, en, rn, an, un, cn, hn, dn, fn, pn, mn, yn, bn, vn, wn, Sn, _n, Cn, Tn, Nn, Fn, Dn, Rn, zn, zn, Bn, Bn, Ln, Un, jn, Wn, Vn, Gn, Hn, qn, Yn, Xn, Kn, er, tr]; for (const e of rr) (0, nr.kr)(e); n(455); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class ir extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, ir.prototype) } } class ar extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, ar.prototype) } } class or extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, or.prototype) } } class sr extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, sr.prototype) } } class ur extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, ur.prototype) } } Error; + /** + * @license + * Copyright 2022 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class lr { constructor(e) { this.maxEntries = e || 100, this.cache = new Map } get(e) { let t; return this.cache.has(e) && (t = this.cache.get(e), this.cache.delete(e), this.cache.set(e, t)), t } put(e, t) { if (this.cache.has(e)) this.cache.delete(e); else if (this.cache.size >= this.maxEntries) { const e = this.cache.keys().next().value; this.cache.delete(e) } this.cache.set(e, t) } getMaxEntries() { return this.maxEntries } setMaxEntries(e) { if (e < 0) throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`); if (this.maxEntries > e) for (let t = 0; t < this.maxEntries - e; t++) { const e = this.cache.keys().next().value; this.cache.delete(e) } this.maxEntries = e } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function cr(e, t) { if (Array.isArray(e)) { let n = []; for (let r = 0; r < t; r++)n = n.concat(e); return n } { const n = new Array(t); return n.fill(e), n } } function hr(e, t) { if (!e) throw new ur(t) } function dr(e, t) { let n = 0; for (const r of e) r === t && n++; return n } function fr(e) { return 1 === e.length ? e[0] : e } function pr(e) { return Array.isArray(e) ? e : [e] } function mr(e) { const t = e.replace(/(.)([A-Z][a-z0-9]+)/g, "$1_$2").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase(); return "_" !== t[0] ? t : "private" + t } function gr(e) { return e.length <= 1 || -1 === e.indexOf("_") ? e : e.replace(/[_]+(\w|$)/g, ((e, t) => t.toUpperCase())) } let yr = {}; function br(e) { if (null == e) return null; const t = {}; return t.className = e.getClassName(), t.config = e.getConfig(), t } function vr(e) { if (null != e && "object" == typeof e) if (Array.isArray(e)) e.forEach((e => vr(e))); else { const t = Object.keys(e); for (const n of t) { const t = e[n]; null != t && "object" == typeof t && (Array.isArray(t) || "ndarray" !== t.type || "number" != typeof t.value ? vr(t) : e[n] = t.value) } } } function xr(e, t = {}, n = {}, r = "object", i = !1) { if ("string" == typeof e) { const i = e; let a; if (i in n) a = n[i]; else if (i in yr) a = yr[i]; else if (a = t[i], null == a) throw new or(`Unknown ${r}: ${e}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`); return a } { const a = e; if (null == a.className || null == a.config) throw new or(`${r}: Improper config format: ${JSON.stringify(a)}.\n'className' and 'config' must set.`); const o = a.className; let s, u; if (o in n ? [s, u] = n[o] : o in yr ? [s, u] = yr.className : o in t && ([s, u] = t[o]), null == s) throw new or(`Unknown ${r}: ${o}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`); if (null != u) { const e = {}; for (const t of Object.keys(yr)) e[t] = yr[t]; for (const t of Object.keys(n)) e[t] = n[t]; a.config.customObjects = e; const t = Object.assign({}, yr); for (const e of Object.keys(n)) yr[e] = n[e]; vr(a.config); const r = u(s, a.config, n, i); return yr = Object.assign({}, t), r } { const e = Object.assign({}, yr); for (const e of Object.keys(n)) yr[e] = n[e]; const t = new s(a.config); return yr = Object.assign({}, e), t } } } function wr(e, t) { return -1 * function (e, t) { return e < t ? -1 : e > t ? 1 : 0 }(e, t) } function kr(e) { if (null == e) return e; const t = []; for (const n of e) -1 === t.indexOf(n) && t.push(n); return t } function Sr(e) { if (null == e) throw new or(`Invalid value in obj: ${JSON.stringify(e)}`); for (const t in e) if (e.hasOwnProperty(t)) return !1; return !0 } function _r(e, t, n) { if (null != n && e.indexOf(n) < 0) throw new or(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`) } function Cr(e, t, n = 0, r = 1 / 0) { return hr(n >= 0), hr(r >= n), Array.isArray(e) && e.length >= n && e.length <= r && e.every((e => typeof e === t)) } function Ar(e, t) { Array.isArray(e) ? (P.util.assert(e.length > 0, (() => `${t} is unexpectedly an empty array.`)), e.forEach(((e, n) => Ar(e, `element ${n + 1} of ${t}`)))) : P.util.assert(Number.isInteger(e) && e > 0, (() => `Expected ${t} to be a positive integer, but got ${Tr(e)}.`)) } function Tr(e) { return null === e ? "null" : Array.isArray(e) ? "[" + e.map((e => Tr(e))).join(",") + "]" : "string" == typeof e ? `"${e}"` : `${e}` } function Er(e) { return "relu" === e ? "relu" : "linear" === e ? "linear" : "elu" === e ? "elu" : null } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + let Nr = 0; function Ir() { return Nr++ } const Mr = {}; function Fr(e = "") { return e in Mr || (Mr[e] = 0), Mr[e] += 1, e + Mr[e].toString() } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const Dr = ["channelsFirst", "channelsLast"], $r = ["nearest", "bilinear"], Rr = ["valid", "same", "causal"], Or = ["max", "avg"], zr = ["sum", "mul", "concat", "ave"], Pr = new Map; function Br(e) { _r(Dr, "DataFormat", e) } function Lr(e) { _r(Rr, "PaddingMode", e) } function jr(e) { _r(Or, "PoolMode", e) } const Ur = []; function Wr(e, t) { Ur.push(e); try { const e = t(); return Ur.pop(), e } catch (e) { throw Ur.pop(), e } } function Vr(e) { if (!qr(e)) throw new Error("Not a valid tensor name: '" + e + "'"); return (0 === Ur.length ? "" : Ur.join("/") + "/") + e } function Gr(e) { if (!qr(e)) throw new Error("Not a valid tensor name: '" + e + "'"); Pr.has(e) || Pr.set(e, 0); const t = Pr.get(e); if (Pr.set(e, Pr.get(e) + 1), t > 0) { const n = `${e}_${t}`; return Pr.set(n, 1), n } return e } const Hr = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/); function qr(e) { return !!e.match(Hr) } function Yr(e, t, n) { null == t && (t = 0), null == n && (n = e.length); let r = 1; for (let i = t; i < n; ++i)r *= e[i]; return r } function Xr(e) { if (0 === e.length) return Number.NaN; let t = Number.POSITIVE_INFINITY; for (let n = 0; n < e.length; n++) { const r = e[n]; r < t && (t = r) } return t } function Kr(e) { if (0 === e.length) return Number.NaN; let t = Number.NEGATIVE_INFINITY; for (let n = 0; n < e.length; n++) { const r = e[n]; r > t && (t = r) } return t } function Zr(e, t) { if (t < e) throw new or(`end (${t}) < begin (${e}) is forbidden.`); const n = []; for (let r = e; r < t; ++r)n.push(r); return n } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + let Jr; function Qr() { return null == Jr && (Jr = (0, P.backend)().epsilon()), Jr } function ei(e, t) { return P.cast(e, t) } function ti(e, t = -1) { const n = e.shape.slice(); return t < 0 && (t = n.length + t + 1), n.splice(t, 0, 1), P.reshape(e, n) } function ni(e, t, n) { return (0, P.tidy)((() => { switch (e.rank) { case 1: return P.slice1d(e, t, n); case 2: return P.slice2d(e, [t, 0], [n, e.shape[1]]); case 3: return P.slice3d(e, [t, 0, 0], [n, e.shape[1], e.shape[2]]); case 4: return P.slice4d(e, [t, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3]]); case 5: return P.slice(e, [t, 0, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3], e.shape[4]]); case 6: return P.slice(e, [t, 0, 0, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3], e.shape[4], e.shape[5]]); default: throw new or(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`) } })) } function ri(e, t, n) { return (0, P.tidy)((() => { switch (e.rank) { case 1: return P.slice1d(e, t, n); case 2: return P.slice2d(e, [0, t], [e.shape[0], n]); case 3: return P.slice3d(e, [0, 0, t], [e.shape[0], e.shape[1], n]); case 4: return P.slice4d(e, [0, 0, 0, t], [e.shape[0], e.shape[1], e.shape[2], n]); default: throw new or(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`) } })) } function ii(e, t, n, r) { return (0, P.tidy)((() => { switch (e.rank) { case 1: return P.slice1d(e, t, n); case 2: switch (r) { case 1: return ni(e, t, n); case 2: return ri(e, t, n); default: throw new or(`The axis is not within the rank of the tensor ${r}`) }case 3: switch (r) { case 1: return ni(e, t, n); case 2: return P.slice3d(e, [0, t, 0], [e.shape[0], n, e.shape[2]]); case 3: return ri(e, t, n); default: throw new or(`The axis is not within the rank of the tensor ${r}`) }case 4: switch (r) { case 1: return ni(e, t, n); case 2: return P.slice4d(e, [0, t, 0, 0], [e.shape[0], n, e.shape[2], e.shape[3]]); case 3: return P.slice4d(e, [0, 0, t, 0], [e.shape[0], e.shape[1], n, e.shape[3]]); case 4: return ri(e, t, n); default: throw new or(`The axis is not within the rank of the tensor ${r}`) }default: throw new or(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`) } })) } function ai(e, t = -1) { let n; return t < 0 && (n = e[0].rank, t = 0 !== n ? n : 0), t === e[0].rank && (t = -1), P.concat(e, t) } function oi(e, t) { switch (e.rank) { case 1: return P.concat1d([e, t]); case 2: return P.concat2d([e, t], 0); case 3: return P.concat3d([e, t], 0); case 4: return P.concat4d([e, t], 0); default: throw new or(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`) } } function si(e, t) { if (Array.isArray(t) || (t = [t]), e.rank !== t.length) throw new or(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`); return P.tile(e, t) } function ui(e, t = 0, n = 1, r, i) { return P.randomNormal(e, t, n, r, i) } function li(e, t, n, r) { if (e.rank < 2 || t.rank < 2) throw new sr(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`); if (t.rank >= 3) { if (e.shape.slice(-1)[0] !== t.shape.slice(-2)[0]) throw new sr(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`) } if (2 === e.rank && 2 === t.rank) { const i = !1, a = !1; return P.fused.matMul({ a: e, b: t, transposeA: i, transposeB: a, bias: r ? di(e.rank, r, "channelsLast") : null, activation: n }) } { const i = e.shape.slice(), a = i.pop(); e = P.reshape(e, [-1, a]); const o = t.shape.slice(), s = o.pop(), u = o.pop(), l = [...o, s], c = Array.from({ length: t.rank }, ((e, n) => 0 === n ? t.rank - 2 : n <= t.rank - 2 ? n - 1 : n)); t = P.reshape(P.transpose(t, c), [u, -1]); const h = [...i, ...l], d = !1, f = !1; return P.reshape(P.fused.matMul({ a: e, b: t, transposeA: d, transposeB: f, bias: r ? di(e.rank, r, "channelsLast") : null, activation: n }), h) } } function ci(e, t, n) { return (0, P.tidy)((() => (t = Array.isArray(t) ? (0, P.tensor1d)(t, "int32") : P.cast(t, "int32"), P.gather(e, t, n)))) } function hi(e) { return P.mul(e, e) } function di(e, t, n) { const r = t.shape; if (1 !== t.rank && t.rank !== e) throw new or(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`); if (5 === e) { if ("channelsFirst" === n) return 1 === r.length ? P.reshape(t, [1, r[0], 1, 1, 1]) : P.reshape(t, [1, r[3], r[0], r[1], r[2]]); if ("channelsLast" === n) return 1 === r.length ? P.reshape(t, [1, 1, 1, 1, r[0]]) : P.reshape(t, [1].concat(r)) } else if (4 === e) { if ("channelsFirst" === n) return 1 === r.length ? P.reshape(t, [1, r[0], 1, 1]) : P.reshape(t, [1, r[2], r[0], r[1]]); if ("channelsLast" === n) return 1 === r.length ? P.reshape(t, [1, 1, 1, r[0]]) : P.reshape(t, [1].concat(r)) } else if (3 === e) { if ("channelsFirst" === n) return 1 === r.length ? P.reshape(t, [1, r[0], 1]) : P.reshape(t, [1, r[1], r[0]]); if ("channelsLast" === n) return 1 === r.length ? P.reshape(t, [1, 1, r[0]]) : P.reshape(t, [1].concat(r)) } else if (e < 3) return t; throw new or(`Unsupported input rank by biasAdd: ${t.rank}`) } function fi(e, t, n) { return (0, P.tidy)((() => (null == n && (n = "channelsLast"), Br(n), P.add(e, di(e.rank, t, n))))) } function pi(e, t, n, r) { return (0, P.tidy)((() => P.dropout(e, t, n, r))) } function mi(e, t, n = !1) { return n ? e() : t() } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const gi = ["fanIn", "fanOut", "fanAvg"], yi = ["normal", "uniform", "truncatedNormal"]; class bi extends P.serialization.Serializable { fromConfigUsesCustomObjects() { return !1 } getConfig() { return {} } } class vi extends bi { apply(e, t) { return (0, P.zeros)(e, t) } } vi.className = "Zeros", P.serialization.registerClass(vi); class xi extends bi { apply(e, t) { return (0, P.ones)(e, t) } } xi.className = "Ones", P.serialization.registerClass(xi); class wi extends bi { constructor(e) { if (super(), "object" != typeof e) throw new or(`Expected argument of type ConstantConfig but got ${e}`); if (void 0 === e.value) throw new or(`config must have value set but got ${e}`); this.value = e.value } apply(e, t) { return (0, P.tidy)((() => (0, P.mul)((0, P.scalar)(this.value), (0, P.ones)(e, t)))) } getConfig() { return { value: this.value } } } wi.className = "Constant", P.serialization.registerClass(wi); class ki extends bi { constructor(e) { super(), this.DEFAULT_MINVAL = -.05, this.DEFAULT_MAXVAL = .05, this.minval = e.minval || this.DEFAULT_MINVAL, this.maxval = e.maxval || this.DEFAULT_MAXVAL, this.seed = e.seed } apply(e, t) { return (0, P.randomUniform)(e, this.minval, this.maxval, t, this.seed) } getConfig() { return { minval: this.minval, maxval: this.maxval, seed: this.seed } } } ki.className = "RandomUniform", P.serialization.registerClass(ki); class Si extends bi { constructor(e) { super(), this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = .05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed } apply(e, t) { if ("float32" !== (t = t || "float32") && "int32" !== t) throw new sr(`randomNormal does not support dType ${t}.`); return ui(e, this.mean, this.stddev, t, this.seed) } getConfig() { return { mean: this.mean, stddev: this.stddev, seed: this.seed } } } Si.className = "RandomNormal", P.serialization.registerClass(Si); class _i extends bi { constructor(e) { super(), this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = .05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed } apply(e, t) { if ("float32" !== (t = t || "float32") && "int32" !== t) throw new sr(`truncatedNormal does not support dType ${t}.`); return (0, P.truncatedNormal)(e, this.mean, this.stddev, t, this.seed) } getConfig() { return { mean: this.mean, stddev: this.stddev, seed: this.seed } } } _i.className = "TruncatedNormal", P.serialization.registerClass(_i); class Ci extends bi { constructor(e) { super(), this.gain = null != e.gain ? e.gain : 1 } apply(e, t) { return (0, P.tidy)((() => { if (2 !== e.length || e[0] !== e[1]) throw new or("Identity matrix initializer can only be used for 2D square matrices."); return (0, P.mul)(this.gain, (0, P.eye)(e[0])) })) } getConfig() { return { gain: this.gain } } } Ci.className = "Identity", P.serialization.registerClass(Ci); class Ai extends bi { + constructor(e) { + if (super(), e.scale < 0) throw new or(`scale must be a positive float. Got: ${e.scale}`); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + var t; this.scale = null == e.scale ? 1 : e.scale, this.mode = null == e.mode ? "fanIn" : e.mode, t = this.mode, _r(gi, "FanMode", t), this.distribution = null == e.distribution ? "normal" : e.distribution, function (e) { _r(yi, "Distribution", e) }(this.distribution), this.seed = e.seed + } apply(e, t) { const n = function (e, t = "channelsLast") { let n, r; if (Br(t), 2 === e.length) n = e[0], r = e[1]; else if (-1 !== [3, 4, 5].indexOf(e.length)) { if ("channelsFirst" === t) { const t = Yr(e, 2); n = e[1] * t, r = e[0] * t } else if ("channelsLast" === t) { const t = Yr(e, 0, e.length - 2); n = e[e.length - 2] * t, r = e[e.length - 1] * t } } else { const t = Yr(e); n = Math.sqrt(t), r = Math.sqrt(t) } return [n, r] }(e), r = n[0], i = n[1]; let a = this.scale; if ("fanIn" === this.mode ? a /= Math.max(1, r) : "fanOut" === this.mode ? a /= Math.max(1, i) : a /= Math.max(1, (r + i) / 2), "normal" === this.distribution) { const n = Math.sqrt(a); if ("float32" !== (t = t || "float32") && "int32" !== t) throw new sr(`${this.getClassName()} does not support dType ${t}.`); return (0, P.truncatedNormal)(e, 0, n, t, this.seed) } { const n = Math.sqrt(3 * a); return (0, P.randomUniform)(e, -n, n, t, this.seed) } } getConfig() { return { scale: this.scale, mode: this.mode, distribution: this.distribution, seed: this.seed } } + } Ai.className = "VarianceScaling", P.serialization.registerClass(Ai); class Ti extends Ai { constructor(e) { super({ scale: 1, mode: "fanAvg", distribution: "uniform", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ti.className = "GlorotUniform", P.serialization.registerClass(Ti); class Ei extends Ai { constructor(e) { super({ scale: 1, mode: "fanAvg", distribution: "normal", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ei.className = "GlorotNormal", P.serialization.registerClass(Ei); class Ni extends Ai { constructor(e) { super({ scale: 2, mode: "fanIn", distribution: "normal", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ni.className = "HeNormal", P.serialization.registerClass(Ni); class Ii extends Ai { constructor(e) { super({ scale: 2, mode: "fanIn", distribution: "uniform", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ii.className = "HeUniform", P.serialization.registerClass(Ii); class Mi extends Ai { constructor(e) { super({ scale: 1, mode: "fanIn", distribution: "normal", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Mi.className = "LeCunNormal", P.serialization.registerClass(Mi); class Fi extends Ai { constructor(e) { super({ scale: 1, mode: "fanIn", distribution: "uniform", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Fi.className = "LeCunUniform", P.serialization.registerClass(Fi); class Di extends bi { constructor(e) { super(), this.DEFAULT_GAIN = 1, this.ELEMENTS_WARN_SLOW = 2e3, this.gain = null == e.gain ? this.DEFAULT_GAIN : e.gain, this.seed = e.seed } apply(e, t) { return (0, P.tidy)((() => { if (e.length < 2) throw new sr("Shape must be at least 2D."); if ("int32" !== t && "float32" !== t && void 0 !== t) throw new TypeError(`Unsupported data type ${t}.`); const n = P.util.sizeFromShape(e.slice(0, -1)), r = e[e.length - 1], i = n * r; i > this.ELEMENTS_WARN_SLOW && console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${i}) elements: Slowness may result.`); const a = ui([Math.max(r, n), Math.min(r, n)], 0, 1, t, this.seed), o = P.linalg.qr(a, !1); let s = o[0]; const u = o[1].flatten().stridedSlice([0], [Math.min(r, n) * Math.min(r, n)], [Math.min(r, n) + 1]); return s = (0, P.mul)(s, u.sign()), n < r && (s = s.transpose()), (0, P.mul)((0, P.scalar)(this.gain), s.reshape(e)) })) } getConfig() { return { gain: this.gain, seed: this.seed } } } Di.className = "Orthogonal", P.serialization.registerClass(Di); const $i = { constant: "Constant", glorotNormal: "GlorotNormal", glorotUniform: "GlorotUniform", heNormal: "HeNormal", heUniform: "HeUniform", identity: "Identity", leCunNormal: "LeCunNormal", leCunUniform: "LeCunUniform", ones: "Ones", orthogonal: "Orthogonal", randomNormal: "RandomNormal", randomUniform: "RandomUniform", truncatedNormal: "TruncatedNormal", varianceScaling: "VarianceScaling", zeros: "Zeros" }; function Ri(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "initializer") } function Oi(e) { return br(e) } function zi(e) { if ("string" == typeof e) { const t = e in $i ? $i[e] : e; if ("GlorotNormal" === t) return new Ei; if ("GlorotUniform" === t) return new Ti; if ("HeNormal" === t) return new Ni; if ("HeUniform" === t) return new Ii; if ("LeCunNormal" === t) return new Mi; if ("LeCunUniform" === t) return new Fi; { const e = {}; return e.className = t, e.config = {}, Ri(e) } } return e instanceof bi ? e : Ri(e) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Pi(e) { return Array.isArray(e) && Array.isArray(e[0]) } function Bi(e) { return 0 === e.length ? [] : Array.isArray(e[0]) ? e : [e] } function Li(e) { let t; if (Array.isArray(e)) { if (1 !== e.length) throw new or(`Expected Tensor length to be 1; got ${e.length}`); t = e[0] } else t = e; return t } function ji(e) { if (Array.isArray(e) && Array.isArray(e[0])) { if (1 === e.length) return e[0]; throw new or(`Expected exactly 1 Shape; got ${e.length}`) } return e } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Ui(e) { let t = 0; for (const n of e) 0 === n.shape.length ? t += 1 : t += n.shape.reduce(((e, t) => e * t)); return t } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const Wi = "Variable"; class Vi { constructor(e, t = "float32", n = Wi, r = !0, i = null) { this.dtype = null == t ? "float32" : t, this.shape = e.shape, this.id = Ir(), n = null == n ? Wi : n, this.originalName = Vr(n), this.name = Gr(this.originalName), this.trainable_ = r, this.constraint = i, this.val = P.variable(e, this.trainable_, this.name, this.dtype) } read() { return this.assertNotDisposed(), this.val } write(e) { return this.assertNotDisposed(), function (e, t) { if (e.shape.toString() !== t.shape.toString()) throw new Error("Shape mismatch: " + JSON.stringify(e.shape) + " vs. " + JSON.stringify(t.shape)) }(this.val, e), this.val.id !== e.id && (this.val.assign(e), null != this.constraint && this.val.assign(this.constraint.apply(this.val))), this } dispose() { this.assertNotDisposed(), this.val.dispose() } assertNotDisposed() { if (this.val.isDisposed) throw new Error(`LayersVariable ${this.name} is already disposed.`) } get trainable() { return this.trainable_ } set trainable(e) { this.trainable_ = e, this.val.trainable = e } } function Gi(e) { return e.map((e => e.read())) } function Hi(e) { e.forEach((e => { e[0].write(e[1]) })) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class qi { constructor(e) { this.dtype = e.dtype, this.shape = e.shape, null != e.shape ? this.ndim = e.shape.length : this.ndim = e.ndim, this.maxNDim = e.maxNDim, this.minNDim = e.minNDim, this.axes = e.axes || {} } } class Yi { constructor(e, t, n, r, i, a, o) { this.dtype = e, this.shape = t, this.sourceLayer = n, this.inputs = r, this.callArgs = i, this.outputTensorIndex = o, this.id = Ir(), null != a && (this.originalName = Vr(a), this.name = Gr(this.originalName)), this.rank = t.length } } let Xi = 0; class Ki { constructor(e, t) { this.callArgs = t, this.id = Xi++, this.outboundLayer = e.outboundLayer, this.inboundLayers = e.inboundLayers, this.nodeIndices = e.nodeIndices, this.tensorIndices = e.tensorIndices, this.inputTensors = e.inputTensors, this.outputTensors = e.outputTensors, this.inputMasks = e.inputMasks, this.outputMasks = e.outputMasks, this.inputShapes = e.inputShapes, this.outputShapes = e.outputShapes; for (const t of e.inboundLayers) null != t && t.outboundNodes.push(this); e.outboundLayer.inboundNodes.push(this) } getConfig() { const e = []; for (const t of this.inboundLayers) null != t ? e.push(t.name) : e.push(null); return { outboundLayer: this.outboundLayer ? this.outboundLayer.name : null, inboundLayers: e, nodeIndices: this.nodeIndices, tensorIndices: this.tensorIndices } } } let Zi = 0; class Ji extends P.serialization.Serializable { constructor(e = {}) { super(), this._callHook = null, this._addedWeightNames = [], this._stateful = !1, this.id = Zi++, this.activityRegularizer = null, this.inputSpec = null, this.supportsMasking = !1, this._trainableWeights = [], this._nonTrainableWeights = [], this._losses = [], this._updates = [], this._built = !1, this.inboundNodes = [], this.outboundNodes = []; let t = e.name; if (!t) { const e = this.getClassName(); t = mr(e) + "_" + Fr(e) } if (this.name = t, this.trainable_ = null == e.trainable || e.trainable, null != e.inputShape || null != e.batchInputShape) { let t; if (null != e.batchInputShape) t = e.batchInputShape; else if (null != e.inputShape) { let n = null; null != e.batchSize && (n = e.batchSize), t = [n].concat(e.inputShape) } this.batchInputShape = t; let n = e.dtype; null == n && (n = e.inputDType), null == n && (n = "float32"), this.dtype = n } null != e.weights ? this.initialWeights = e.weights : this.initialWeights = null, this._refCount = null, this.fastWeightInitDuringBuild = !1 } static nodeKey(e, t) { return e.name + "_ib-" + t.toString() } getNodeAtIndex(e, t) { if (0 === this.inboundNodes.length) throw new ar(`The layer has never been called and thus has no defined ${t}.`); if (this.inboundNodes.length <= e) throw new or(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`); return this.inboundNodes[e] } getInputAt(e) { return fr(this.getNodeAtIndex(e, "input").inputTensors) } getOutputAt(e) { return fr(this.getNodeAtIndex(e, "output").outputTensors) } get input() { if (this.inboundNodes.length > 1) throw new ir(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`); if (0 === this.inboundNodes.length) throw new ir(`Layer ${this.name} is not connected, no input to return.`); return fr(this.getNodeAtIndex(0, "input").inputTensors) } get output() { if (0 === this.inboundNodes.length) throw new ir(`Layer ${this.name} has no inbound nodes.`); if (this.inboundNodes.length > 1) throw new ir(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`); return fr(this.getNodeAtIndex(0, "output").outputTensors) } get losses() { return this._losses } calculateLosses() { return this.losses.map((e => e())) } get updates() { return this._updates } get built() { return this._built } set built(e) { this._built = e } get trainable() { return this.trainable_ } set trainable(e) { this._trainableWeights.forEach((t => t.trainable = e)), this.trainable_ = e } get trainableWeights() { return this.trainable_ ? this._trainableWeights.filter((e => e.trainable)) : [] } set trainableWeights(e) { this._trainableWeights = e } get nonTrainableWeights() { return this.trainable ? this._trainableWeights.filter((e => !e.trainable)).concat(this._nonTrainableWeights) : this._trainableWeights.concat(this._nonTrainableWeights) } set nonTrainableWeights(e) { this._nonTrainableWeights = e } get weights() { return this.trainableWeights.concat(this.nonTrainableWeights) } get stateful() { return this._stateful } resetStates() { if (!this.stateful) throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.") } assertInputCompatibility(e) { const t = pr(e); if (null == this.inputSpec || 0 === this.inputSpec.length) return; const n = pr(this.inputSpec); if (t.length !== n.length) throw new or(`Layer ${this.name} expects ${n.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`); for (let e = 0; e < t.length; e++) { const r = t[e], i = n[e]; if (null == i) continue; const a = r.rank; if (null != i.ndim && a !== i.ndim) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected ndim=${i.ndim}, found ndim=${a}`); if (null != i.maxNDim && a > i.maxNDim) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`); if (null != i.minNDim && a < i.minNDim) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected min_ndim=${i.minNDim}, found ndim=${a}.`); if (null != i.dtype && r.dtype !== i.dtype) throw new or(`Input ${e} is incompatible with layer ${this.name} : expected dtype=${i.dtype}, found dtype=${r.dtype}.`); if (i.axes) { const t = r.shape; for (const n in i.axes) { const r = Number(n), a = i.axes[n], o = r >= 0 ? t[r] : t[t.length + r]; if (null != a && -1 === [a, null].indexOf(o)) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${a} but got shape ${t}.`) } } if (null != i.shape) for (let t = 0; t < i.shape.length; ++t) { const n = i.shape[t], a = r.shape[t]; if (null != n && null != a && n !== a) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected shape=${i.shape}, found shape=${r.shape}.`) } } } call(e, t) { return e } invokeCallHook(e, t) { null != this._callHook && this._callHook(e, t) } setCallHook(e) { this._callHook = e } clearCallHook() { this._callHook = null } apply(e, t) { t = t || {}, this.assertNotDisposed(); const n = pr(e), r = function (e) { let t = !0; for (const n of pr(e)) if (!(n instanceof Yi)) { t = !1; break } return t }(e), i = function (e) { let t = !0; for (const n of pr(e)) if (n instanceof Yi) { t = !1; break } return t }(e); if (r === i) throw new or("Arguments to apply() must be all SymbolicTensors or all Tensors"); return Wr(this.name, (() => { if (!this.built) { this.assertInputCompatibility(e); const t = []; for (const n of pr(e)) t.push(n.shape); this.build(fr(t)), this.built = !0, this.initialWeights && this.setWeights(this.initialWeights), null === this._refCount && i && (this._refCount = 1) } if (this.assertInputCompatibility(e), i) { let r = this.call(e, t); this.supportsMasking && this.setMaskMetadata(e, r); const i = pr(r), a = []; for (let e of i) -1 !== n.indexOf(e) && (e = e.clone()), a.push(e); if (r = fr(a), null != this.activityRegularizer) throw new sr("Layer invocation in the presence of activity regularizer(s) is not supported yet."); return r } { const n = function (e) { e = pr(e); const t = []; for (const n of e) t.push(n.shape); return fr(t) }(e), r = this.computeOutputShape(n); let i; const a = "float32"; if (this.warnOnIncompatibleInputShape(Array.isArray(e) ? n[0] : n), i = null != r && r.length > 0 && Array.isArray(r[0]) ? r.map(((n, r) => new Yi(a, n, this, pr(e), t, this.name, r))) : new Yi(a, r, this, pr(e), t, this.name), this.addInboundNode(e, i, null, null, n, r, t), this._refCount++, null != this.activityRegularizer) throw new sr("Layer invocation in the presence of activity regularizer(s) is not supported yet."); return i } })) } warnOnIncompatibleInputShape(e) { if (null != this.batchInputShape) if (e.length !== this.batchInputShape.length) console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`); else { let t = !1; this.batchInputShape.forEach(((n, r) => { null != n && null != e[r] && e[r] !== n && (t = !0) })), t && console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`) } } get outputShape() { if (null == this.inboundNodes || 0 === this.inboundNodes.length) throw new ir(`The layer ${this.name} has never been called and thus has no defined output shape.`); const e = []; for (const t of this.inboundNodes) { const n = JSON.stringify(t.outputShapes); -1 === e.indexOf(n) && e.push(n) } if (1 === e.length) { const e = this.inboundNodes[0].outputShapes; return Array.isArray(e) && Array.isArray(e[0]) && 1 === e.length ? e[0] : e } throw new ir(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`) } countParams() { if (!this.built) throw new ar(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`); return Ui(this.weights) } build(e) { this.built = !0 } getWeights(e = !1) { return Gi(e ? this.trainableWeights : this.weights) } setWeights(e) { (0, P.tidy)((() => { const t = this.weights; if (t.length !== e.length) throw new or(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`); if (0 === t.length) return; const n = [], r = Gi(t); for (let i = 0; i < r.length; ++i) { const a = r[i], o = t[i], s = e[i]; if (!P.util.arraysEqual(a.shape, s.shape)) throw new or(`Layer weight shape ${a.shape} not compatible with provided weight shape ${s.shape}`); n.push([o, s]) } Hi(n) })) } addWeight(e, t, n, r, i, a, o, s) { if (-1 !== this._addedWeightNames.indexOf(e)) throw new or(`Duplicate weight name ${e} for layer ${this.name}`); this._addedWeightNames.push(e), null == n && (n = "float32"), this.fastWeightInitDuringBuild && (r = null != s ? s() : zi("zeros")); const u = r.apply(t, n), l = new Vi(u, n, e, a, o); return u.dispose(), null != i && this.addLoss((() => i.apply(l.read()))), null == a && (a = !0), a ? this._trainableWeights.push(l) : this._nonTrainableWeights.push(l), l } setFastWeightInitDuringBuild(e) { this.fastWeightInitDuringBuild = e } addLoss(e) { null == e || Array.isArray(e) && 0 === e.length || (e = pr(e), void 0 !== this._losses && null !== this._losses && this.losses.push(...e)) } computeOutputShape(e) { return e } computeMask(e, t) { if (!this.supportsMasking) { if (null != t) { if (!Array.isArray(t)) throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`); t.forEach((e => { if (null != e) throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`) })) } return null } return t } setMaskMetadata(e, t, n) { if (!this.supportsMasking) return; const r = this.computeMask(e, n), i = pr(t), a = pr(r); if (i.length !== a.length) throw new Error(`${this.name} outputs ${i.length} tensors but ${i.length} masks for those tensors`); for (let e = 0; e < i.length; e++)i[e].kerasMask = a[e] } addInboundNode(e, t, n, r, i, a, o = null) { const s = pr(e); t = pr(t), n = pr(n), r = pr(r), i = Bi(i), a = Bi(a); const u = [], l = [], c = []; for (const e of s) u.push(e.sourceLayer), l.push(e.nodeIndex), c.push(e.tensorIndex); new Ki({ outboundLayer: this, inboundLayers: u, nodeIndices: l, tensorIndices: c, inputTensors: s, outputTensors: t, inputMasks: n, outputMasks: r, inputShapes: i, outputShapes: a }, o); for (let e = 0; e < t.length; e++)t[e].sourceLayer = this, t[e].nodeIndex = this.inboundNodes.length - 1, t[e].tensorIndex = e } getConfig() { const e = { name: this.name, trainable: this.trainable }; return null != this.batchInputShape && (e.batchInputShape = this.batchInputShape), null != this.dtype && (e.dtype = this.dtype), e } disposeWeights() { return this.weights.forEach((e => e.dispose())), this.weights.length } assertNotDisposed() { if (0 === this._refCount) throw new Error(`Layer '${this.name}' is already disposed.`) } dispose() { if (!this.built) throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`); if (null === this._refCount) throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`); this.assertNotDisposed(); let e = 0; return 0 == --this._refCount && (e = this.disposeWeights()), { refCountAfterDispose: this._refCount, numDisposedVariables: e } } } function Qi(e, t, n) { if ((null == t || null != n && n > 0) && (t = e.sourceLayer, n = e.nodeIndex), 0 === t.inboundNodes.length) return [e]; { const e = t.inboundNodes[n]; if (0 === e.inboundLayers.length) return e.inputTensors; { const t = []; for (let n = 0; n < e.inboundLayers.length; n++) { const r = Qi(e.inputTensors[n], e.inboundLayers[n], e.nodeIndices[n]); for (const e of r) -1 === t.indexOf(e) && t.push(e) } return t } } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class ea extends Ji { constructor(e) { if (super({ dtype: e.dtype, name: null != e.name ? e.name : Fr("input").toString() }), null == e.batchSize && (e.batchSize = null), null == e.sparse && (e.sparse = !1), this.trainable = !1, this.built = !0, this.sparse = e.sparse, null != e.inputShape && null != e.batchInputShape) throw new or("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time."); let t = e.batchInputShape; if (null == t) { if (null == e.inputShape) throw new or("An InputLayer should be passed either a `batchInputShape` or an `inputShape`."); t = [e.batchSize].concat(e.inputShape) } else if (null != e.batchSize) throw new or("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer."); const n = e.dtype || "float32"; this.batchInputShape = t, this.dtype = n, this.inputSpec = [{ shape: t }]; const r = new Yi(this.dtype, this.batchInputShape, this, [], {}, this.name); r.nodeIndex = 0, r.tensorIndex = 0, new Ki({ outboundLayer: this, inboundLayers: [], nodeIndices: [], tensorIndices: [], inputTensors: [r], outputTensors: [r], inputMasks: [null], outputMasks: [null], inputShapes: [t], outputShapes: [t] }) } apply(e, t) { throw new or(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`) } dispose() { return { refCountAfterDispose: this._refCount, numDisposedVariables: 0 } } getConfig() { return { batchInputShape: this.batchInputShape, dtype: this.dtype, sparse: this.sparse, name: this.name } } } function ta(e) { if (null == e.batchShape && null == e.shape) throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension."); if (null != e.batchShape && null != e.shape) throw new or("Please provide either a `shape` or `batchShape` argument to Input, but not both."); let t = e.batchShape; null != e.shape && null == t && (t = [null].concat(e.shape)); let n = e.dtype; null == n && (n = "float32"); return new ea({ batchInputShape: t, name: e.name, dtype: n, sparse: e.sparse }).inboundNodes[0].outputTensors[0] } ea.className = "InputLayer", P.serialization.registerClass(ea); class na { + constructor(e) { if (this.id2Value = {}, this.id2Mask = {}, this.name2Id = {}, e instanceof na) for (const t in e.id2Value) this.id2Value[t] = e.id2Value[t], t in e.id2Mask && (this.id2Mask[t] = e.id2Mask[t]); else { if (null == e) return; for (const t of e) this.add(t.key, t.value) } } add(e, t, n) { + if (null != this.id2Value[e.id]) throw new or(`Duplicate key: name=${e.name}, id=${e.id}`); return this.id2Value[e.id] = + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function (e, t) { if (null == e.dtype || e.dtype === t.dtype) return t; try { return (0, P.cast)(t, e.dtype) } catch (n) { throw new or(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`) } }(e, t), this.name2Id[e.name] = e.id, null != n && (this.id2Mask[e.id] = n), this + } addFeed(e) { this.add(e.key, e.value) } hasKey(e) { return null != this.id2Value[e.id] } names() { return Object.keys(this.name2Id) } getValue(e) { if (e instanceof Yi) { if (null == this.id2Value[e.id]) throw new or(`Nonexistent key: ${e.name}`); return this.id2Value[e.id] } { const t = this.name2Id[e]; if (null == t) throw new or(`Feed dict has no SymbolicTensor name: ${e}`); return this.id2Value[t] } } getMask(e) { if (e instanceof Yi) { if (null == this.id2Value[e.id]) throw new or(`Nonexistent key: ${e.name}`); return this.id2Mask[e.id] } { const t = this.name2Id[e]; if (null == t) throw new or(`Feed dict has no SymbolicTensor name: ${e}`); return this.id2Mask[t] } } disposeMasks() { null != this.id2Mask && (0, P.dispose)(this.id2Mask) } + } const ra = new lr, ia = new lr; function aa(e, t, n, r) { const i = null != n && n.training, a = Array.isArray(e), o = a ? e : [e], s = o.map((e => e.name)), u = [], l = t.names(); for (const e of s) -1 !== l.indexOf(e) ? u.push(t.getValue(e)) : u.push(null); null != r && (r.maxNumTensors = -1 / 0, r.minNumTensors = 1 / 0); const c = s.join(",") + "|" + t.names().sort().join(","); let h, d = ra.get(c); if (null == d) { const e = function (e, t) { P.util.assert(null != e && e.length > 0, (() => "Expected at least one fetch, got none")); let n = [], r = {}; if (1 === e.length) { const i = sa(e[0], t); n = i.sorted, r = i.recipientMap } else { const i = new Set; for (const a of e) { const { sorted: e, recipientMap: o } = sa(a, t); for (const t of e) i.has(t.name) || (n.push(t), i.add(t.name)); for (const e in o) null == r[e] && (r[e] = new Set), o[e].forEach((t => r[e].add(t))) } } return { sorted: n, recipientCounts: oa(r) } }(o, t); d = e.sorted, h = e.recipientCounts, ra.put(c, d), ia.put(c, h) } h = {}, i || Object.assign(h, ia.get(c)); const f = new na(t); for (let e = 0; e < d.length; ++e) { if (null != r) { const e = (0, P.memory)().numTensors; e > r.maxNumTensors && (r.maxNumTensors = e), e < r.minNumTensors && (r.minNumTensors = e) } const a = d[e], o = a.sourceLayer; if (o instanceof ea) continue; const l = [], c = [], p = []; let m = !1; for (const e of a.inputs) { const n = f.getValue(e), r = f.getMask(e); l.push(n), c.push(r), null != r && (m = !0), i || (h[e.name]--, 0 !== h[e.name] || t.hasKey(e) || -1 !== s.indexOf(e.name) || n.isDisposed || !0 === e.sourceLayer.stateful || p.push(n)) } m && ((n = n || {}).mask = c[0]); const g = pr(o.apply(l, n)); let y = null; o.supportsMasking && (y = o.computeMask(l, c)); const b = ua(a), v = Array.isArray(b) ? b : [b]; for (let e = 0; e < v.length; ++e) { f.hasKey(v[e]) || f.add(v[e], g[e], Array.isArray(y) ? y[0] : y); const t = s.indexOf(v[e].name); -1 !== t && (u[t] = g[e]) } i || (0, P.dispose)(p) } return f.disposeMasks(), a ? u : u[0] } function oa(e) { const t = {}; for (const n in e) t[n] = e[n].size; return t } function sa(e, t) { const n = new Set, r = [], i = {}; for (const e of t.names()) n.add(e); const a = [], o = []; for (a.push(e); a.length > 0;) { const e = a[a.length - 1]; if (n.has(e.name)) { a.pop(); continue } const t = o[o.length - 1] === a.length - 1; if (0 === e.inputs.length || t) a.pop(), r.push(e), n.add(e.name), t && o.pop(); else { o.push(a.length - 1); for (const t of e.inputs) null == i[t.name] && (i[t.name] = new Set), i[t.name].add(e.name), n.has(t.name) || a.push(t) } } return { sorted: r, recipientMap: i } } function ua(e) { let t; if (1 === e.sourceLayer.inboundNodes.length) t = e.sourceLayer.output; else { let n = null; for (let t = 0; t < e.sourceLayer.inboundNodes.length; ++t)for (const r of e.sourceLayer.inboundNodes[t].outputTensors) if (r.id === e.id) { n = t; break } t = e.sourceLayer.getOutputAt(n) } return t } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function la(e, t) { return (0, P.tidy)((() => P.sqrt(P.sum(P.mul(e, e), t, !0)))) } (0, P.env)().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES", (() => 100), (function (e) { null != ra && ra.setMaxEntries(e), null != ia && ia.setMaxEntries(e) })); class ca extends P.serialization.Serializable { getConfig() { return {} } } class ha extends ca { constructor(e) { super(), this.defaultMaxValue = 2, this.defaultAxis = 0, this.maxValue = null != e.maxValue ? e.maxValue : this.defaultMaxValue, this.axis = null != e.axis ? e.axis : this.defaultAxis } apply(e) { return (0, P.tidy)((() => { const t = la(e, this.axis), n = P.clipByValue(t, 0, this.maxValue); return P.mul(e, P.div(n, P.add(Qr(), t))) })) } getConfig() { return { maxValue: this.maxValue, axis: this.axis } } } ha.className = "MaxNorm", P.serialization.registerClass(ha); class da extends ca { constructor(e) { super(), this.defaultAxis = 0, this.axis = null != e.axis ? e.axis : this.defaultAxis } apply(e) { return (0, P.tidy)((() => P.div(e, P.add(Qr(), la(e, this.axis))))) } getConfig() { return { axis: this.axis } } } da.className = "UnitNorm", P.serialization.registerClass(da); class fa extends ca { apply(e) { return P.relu(e) } } fa.className = "NonNeg", P.serialization.registerClass(fa); class pa extends ca { constructor(e) { super(), this.defaultMinValue = 0, this.defaultMaxValue = 1, this.defaultRate = 1, this.defaultAxis = 0, this.minValue = null != e.minValue ? e.minValue : this.defaultMinValue, this.maxValue = null != e.maxValue ? e.maxValue : this.defaultMaxValue, this.rate = null != e.rate ? e.rate : this.defaultRate, this.axis = null != e.axis ? e.axis : this.defaultAxis } apply(e) { return (0, P.tidy)((() => { const t = la(e, this.axis), n = P.add(P.mul(this.rate, P.clipByValue(t, this.minValue, this.maxValue)), P.mul(1 - this.rate, t)); return P.mul(e, P.div(n, P.add(Qr(), t))) })) } getConfig() { return { minValue: this.minValue, maxValue: this.maxValue, rate: this.rate, axis: this.axis } } } pa.className = "MinMaxNorm", P.serialization.registerClass(pa); const ma = { maxNorm: "MaxNorm", minMaxNorm: "MinMaxNorm", nonNeg: "NonNeg", unitNorm: "UnitNorm" }; function ga(e) { return br(e) } function ya(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "constraint") } function ba(e) { if (null == e) return null; if ("string" == typeof e) { return ya({ className: e in ma ? ma[e] : e, config: {} }) } return e instanceof ca ? e : ya(e) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function va(e) { return new ha(e) } function xa(e) { return new da(e) } function wa() { return new fa } function ka(e) { return new pa(e) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Sa() { return new vi } function _a() { return new xi } function Ca(e) { return new wi(e) } function Aa(e) { return new ki(e) } function Ta(e) { return new Si(e) } function Ea(e) { return new _i(e) } function Na(e) { return new Ci(e) } function Ia(e) { return new Ai(e) } function Ma(e) { return new Ti(e) } function Fa(e) { return new Ei(e) } function Da(e) { return new Ni(e) } function $a(e) { return new Ii(e) } function Ra(e) { return new Mi(e) } function Oa(e) { return new Fi(e) } function za(e) { return new Di(e) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + async function Pa(e) { if (null == e) return; const t = [], n = [], r = []; for (const i in e) { const a = e[i]; if ("number" != typeof a) { const e = a; t.push(e.data()), n.push(i), r.push(e) } } if (t.length > 0) { const i = await Promise.all(t); for (let t = 0; t < i.length; ++t)e[n[t]] = i[t][0]; (0, P.dispose)(r) } } function Ba(e) { if (null != e) for (const t in e) { const n = e[t]; "number" != typeof n && n.dispose() } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + var La, ja; (ja = La || (La = {}))[ja.SILENT = 0] = "SILENT", ja[ja.VERBOSE = 1] = "VERBOSE"; class Ua { constructor() { this.validationData = null } setParams(e) { this.params = e } async onEpochBegin(e, t) { } async onEpochEnd(e, t) { } async onBatchBegin(e, t) { } async onBatchEnd(e, t) { } async onTrainBegin(e) { } async onTrainEnd(e) { } setModel(e) { } } class Wa { constructor(e, t = 10) { null == e && (e = []), this.callbacks = e, this.queueLength = t } append(e) { this.callbacks.push(e) } setParams(e) { for (const t of this.callbacks) t.setParams(e) } setModel(e) { for (const t of this.callbacks) t.setModel(e) } async onEpochBegin(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onEpochBegin(e, t) } async onEpochEnd(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onEpochEnd(e, t) } async onBatchBegin(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onBatchBegin(e, t) } async onBatchEnd(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onBatchEnd(e, t) } async onTrainBegin(e) { null == e && (e = {}); for (const t of this.callbacks) await t.onTrainBegin(e) } async onTrainEnd(e) { null == e && (e = {}); for (const t of this.callbacks) await t.onTrainEnd(e) } } class Va extends Ua { constructor() { super() } async onEpochBegin(e) { this.seen = 0, this.totals = {} } async onBatchEnd(e, t) { null == t && (t = {}); const n = null == t.size ? 0 : t.size; this.seen += n; for (const e in t) { const r = t[e]; if ("number" == typeof r) this.totals.hasOwnProperty(e) || (this.totals[e] = 0), this.totals[e] = this.totals[e] + r * n; else { let t; e in this.totals ? t = this.totals[e] : this.totals[e] = 0; const i = (0, P.tidy)((() => (0, P.add)(this.totals[e], (0, P.mul)(r, n)))); this.totals[e] = i, null != t && t.dispose() } } } async onEpochEnd(e, t) { if (null != t) for (const e of this.params.metrics) null != this.totals[e] && ("number" == typeof this.totals[e] ? t[e] = this.totals[e] / this.seen : (0, P.tidy)((() => { const n = (0, P.mul)((0, P.div)(1, this.seen), this.totals[e]); t[e] = n, this.totals[e].dispose(), (0, P.keep)(t[e]) }))) } } class Ga extends Ua { async onTrainBegin(e) { this.epoch = [], this.history = {} } async onEpochEnd(e, t) { null == t && (t = {}), this.epoch.push(e); for (const e in t) null == this.history[e] && (this.history[e] = []), this.history[e].push(t[e]) } async syncData() { const e = [], t = [], n = []; for (const r in this.history) { const i = this.history[r]; for (let a = 0; a < i.length; ++a)if ("number" != typeof i[a]) { const o = i[a]; e.push(o.data()), t.push(r), n.push(a) } } const r = await Promise.all(e); for (let e = 0; e < r.length; ++e) { this.history[t[e]][n[e]].dispose(), this.history[t[e]][n[e]] = r[e][0] } } } class Ha extends Ua { constructor(e, t) { if (super(), this.currentEpoch = 0, this.nowFunc = e.nowFunc, this.nextFrameFunc = e.nextFrameFunc || P.nextFrame, this.yieldEvery = t || "auto", "auto" === this.yieldEvery && (this.yieldEvery = 125), "never" === this.yieldEvery && null != e.onYield) throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback"); P.util.isNumber(this.yieldEvery) && (this.maybeWait = function (e, t, n) { let r, i = null != n ? n() : P.util.now(); return (...a) => { const o = null != n ? n() : P.util.now(); return o - i < t || (i = o, r = e(...a)), r } }(this.maybeWait.bind(this), this.yieldEvery, this.nowFunc)), this.trainBegin = e.onTrainBegin, this.trainEnd = e.onTrainEnd, this.epochBegin = e.onEpochBegin, this.epochEnd = e.onEpochEnd, this.batchBegin = e.onBatchBegin, this.batchEnd = e.onBatchEnd, this.yield = e.onYield } async maybeWait(e, t, n) { const r = []; null != this.yield && (await Pa(n), r.push(this.yield(e, t, n))), r.push(this.nextFrameFunc()), await Promise.all(r) } async onEpochBegin(e, t) { this.currentEpoch = e, null != this.epochBegin && (await Pa(t), await this.epochBegin(e, t)) } async onEpochEnd(e, t) { const n = []; null != this.epochEnd && (await Pa(t), n.push(this.epochEnd(e, t))), "epoch" === this.yieldEvery && n.push(this.nextFrameFunc()), await Promise.all(n) } async onBatchBegin(e, t) { null != this.batchBegin && (await Pa(t), await this.batchBegin(e, t)) } async onBatchEnd(e, t) { const n = []; null != this.batchEnd && (await Pa(t), n.push(this.batchEnd(e, t))), "batch" === this.yieldEvery ? n.push(this.nextFrameFunc()) : P.util.isNumber(this.yieldEvery) && n.push(this.maybeWait(this.currentEpoch, e, t)), await Promise.all(n) } async onTrainBegin(e) { null != this.trainBegin && (await Pa(e), await this.trainBegin(e)) } async onTrainEnd(e) { null != this.trainEnd && (await Pa(e), await this.trainEnd(e)) } } function qa(e, t) { if (null == e && (e = {}), e instanceof Ua) return [e]; if (Array.isArray(e) && e[0] instanceof Ua) return e; return pr(e).map((e => new Ha(e, t))) } class Ya { constructor() { } static registerCallbackConstructor(e, t) { P.util.assert(e >= 0 && Number.isInteger(e), (() => `Verbosity level is expected to be an integer >= 0, but got ${e}`)), Ya.checkForDuplicate(t), null == Ya.constructors[e] && (Ya.constructors[e] = []), Ya.constructors[e].push(t) } static checkForDuplicate(e) { for (const t in Ya.constructors) { Ya.constructors[+t].forEach((t => { if (t === e) throw new or("Duplicate callback constructor.") })) } } static clear() { Ya.constructors = {} } static createCallbacks(e) { const t = []; for (const n in Ya.constructors) { const r = +n; e >= r && t.push(...Ya.constructors[r]) } return t.map((e => new e)) } } function Xa(e, t, n, r, i, a, o, s, u) { const l = new Ga, c = [new Va, ...Ya.createCallbacks(t)]; null != e && c.push(...e), c.push(l); const h = new Wa(c); return h.setParams({ epochs: n, initialEpoch: r, samples: i, steps: a, batchSize: o, verbose: t, doValidation: s, metrics: u }), { callbackList: h, history: l } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Ka(e, t = {}, n = !1) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "layer", n) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Za(e, t) { return (0, P.tidy)((() => { "float32" !== e.dtype && (e = P.cast(e, "float32")); const n = P.sum(hi(e), t, !0), r = P.fill(n.shape, Qr()), i = P.sqrt(P.maximum(n, r)); return P.div(e, i) })) } function Ja(e, t) { return (0, P.tidy)((() => P.mean(hi(P.sub(t, e)), -1))) } function Qa(e, t) { return (0, P.tidy)((() => P.mean(P.abs(P.sub(t, e)), -1))) } function eo(e, t) { return (0, P.tidy)((() => { const n = P.sub(e, t), r = P.clipByValue(P.abs(e), Qr(), Number.MAX_VALUE), i = P.abs(P.div(n, r)); return P.mul(100, P.mean(i, -1)) })) } function to(e, t) { return (0, P.tidy)((() => { const n = P.clipByValue(t, Qr(), Number.MAX_VALUE), r = P.log(P.add(1, n)), i = P.clipByValue(e, Qr(), Number.MAX_VALUE), a = P.log(P.add(1, i)); return P.mean(hi(P.sub(r, a)), -1) })) } function no(e, t, n = !1) { return (0, P.tidy)((() => { if (n) t = P.softmax(t); else { const e = P.sum(t, t.shape.length - 1, !0); t = P.div(t, e) } return t = P.clipByValue(t, Qr(), 1 - Qr()), P.neg(P.sum(P.mul(P.cast(e, "float32"), P.log(t)), t.shape.length - 1)) })) } function ro(e, t, n = !1) { return (0, P.tidy)((() => { const r = P.cast(P.floor(function (e) { const t = [Yr(e.shape)]; return P.reshape(e, t) }(e)), "int32"), i = (t = P.clipByValue(t, Qr(), 1 - Qr())).shape; return no(P.reshape(P.oneHot(r, i[i.length - 1]), i), t, n) })) } function io(e, t) { return (0, P.tidy)((() => { let n; return n = P.clipByValue(t, Qr(), 1 - Qr()), n = P.log(P.div(n, P.sub(1, n))), P.mean(function (e, t) { if (!P.util.arraysEqual(e.shape, t.shape)) throw new or(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`); return (0, P.tidy)((() => { const n = P.relu(t), r = P.neg(P.abs(t)); return P.add(P.sub(n, P.mul(t, e)), P.log1p(P.exp(r))) })) }(e, n), -1) })) } function ao(e, t) { return (0, P.tidy)((() => { const n = P.clipByValue(e, Qr(), 1), r = P.clipByValue(t, Qr(), 1); return P.sum(P.mul(e, P.log(P.div(n, r))), -1) })) } function oo(e, t) { return (0, P.tidy)((() => { const n = Za(e, -1), r = Za(t, -1), i = P.mul(n, r); return P.neg(P.sum(i, -1)) })) } Ya.constructors = {}; const so = { meanSquaredError: Ja, meanAbsoluteError: Qa, meanAbsolutePercentageError: eo, meanSquaredLogarithmicError: to, squaredHinge: function (e, t) { return (0, P.tidy)((() => { const n = P.maximum(0, P.sub(1, P.mul(e, t))); return P.mean(hi(n), -1) })) }, hinge: function (e, t) { return (0, P.tidy)((() => { const n = P.maximum(0, P.sub(1, P.mul(e, t))); return P.mean(n, -1) })) }, categoricalHinge: function (e, t) { return (0, P.tidy)((() => { const n = P.sum(P.mul(e, t), -1), r = P.max(P.mul(P.sub(1, e), t), -1); return P.maximum(0, P.add(1, P.sub(r, n))) })) }, logcosh: function (e, t) { return (0, P.tidy)((() => { const n = Math.log(2), r = P.sub(t, e), i = P.sub(P.add(r, P.softplus(P.mul(-2, r))), n); return P.mean(i, -1) })) }, categoricalCrossentropy: no, sparseCategoricalCrossentropy: ro, binaryCrossentropy: io, kullbackLeiblerDivergence: ao, poisson: function (e, t) { return (0, P.tidy)((() => { const n = P.log(P.add(Qr(), t)); return P.mean(P.sub(t, P.mul(e, n)), -1) })) }, cosineProximity: oo }; function uo(e) { if ("string" == typeof e) { if (e in so) return so[e]; let t = `Unknown loss ${e}`; throw e.toLowerCase().includes("softmaxcrossentropy") && (t = `Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`), new or(t) } return e } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function lo(e, t) { return (0, P.tidy)((() => { const n = P.mul(.5, P.onesLike(t)), r = ei(P.greater(t, n), e.dtype); return P.mean(P.equal(e, r), -1) })) } function co(e, t) { return (0, P.tidy)((() => ei(P.equal(P.argMax(e, -1), P.argMax(t, -1)), "float32"))) } function ho(e, t) { return (0, P.tidy)((() => P.cast(P.sum(P.logicalAnd(P.equal(e, 1), P.equal(t, 1))), "float32"))) } function fo(e, t) { return (0, P.tidy)((() => { const n = ho(e, t), r = function (e, t) { return (0, P.tidy)((() => P.cast(P.sum(P.logicalAnd(P.equal(e, 0), P.equal(t, 1))), "float32"))) }(e, t), i = P.add(n, r); return P.cast(P.where(P.greater(i, 0), P.div(n, i), 0), "float32") })) } function po(e, t) { return (0, P.tidy)((() => { const n = ho(e, t), r = function (e, t) { return (0, P.tidy)((() => P.cast(P.sum(P.logicalAnd(P.equal(e, 1), P.equal(t, 0))), "float32"))) }(e, t), i = P.add(n, r); return P.cast(P.where(P.greater(i, 0), P.div(n, i), 0), "float32") })) } function mo(e, t) { return io(e, t) } function go(e, t) { return e.rank === t.rank && (e = P.squeeze(e, [e.rank - 1])), (t = P.argMax(t, -1)).dtype !== e.dtype && (t = P.cast(t, e.dtype)), P.cast(P.equal(e, t), "float32") } const yo = no, bo = ro, vo = { binaryAccuracy: lo, categoricalAccuracy: co, precision: fo, categoricalCrossentropy: yo, sparseCategoricalCrossentropy: bo, mse: Ja, MSE: Ja, mae: Qa, MAE: Qa, mape: eo, MAPE: eo, cosine: oo }; function xo(e) { if ("string" == typeof e && e in vo) return vo[e]; if ("string" != typeof e && null != e) return e; throw new or(`Unknown metric ${e}`) } function wo(e) { if (hr(null !== e, `Unknown LossOrMetricFn ${e}`), "string" == typeof e) return e; { let t; for (const n of Object.keys(so)) if (so[n] === e) { t = n; break } if (void 0 !== t) return t; for (const n of Object.keys(vo)) if (vo[n] === e) { t = n; break } return void 0 !== t ? t : e.name } } + /** + * @license + * Copyright 2019 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const ko = 1048576; function So(e, t, n = !1) { if (null == e || "object" != typeof e || Object.getPrototypeOf(e) !== Object.prototype || !_o(e)) throw new Error("User-defined metadata is expected to be a JSON object, but is not."); if (n) { const n = JSON.stringify(e); n.length > ko && console.warn(`User-defined metadata of model "${t}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`) } } function _o(e) { if (null === e) return !0; if ("object" == typeof e) { if (Object.getPrototypeOf(e) === Object.prototype) { const t = Object.keys(e); for (const n of t) { if ("string" != typeof n) return !1; if (!_o(e[n])) return !1 } return !0 } if (Array.isArray(e)) { for (const t of e) if (!_o(t)) return !1; return !0 } return !1 } { const t = typeof e; return "string" === t || "number" === t || "boolean" === t } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Co(e, t, n, r = console.log) { const i = function (e) { let t = !0; const n = [], r = []; for (const t in e.nodesByDepth) n.push(e.nodesByDepth[t]); for (const e of n) { if (e.length > 1 || 1 === e.length && e[0].inboundLayers.length > 1) { t = !1; break } r.push(...e) } if (t) for (const n of e.layers) { let e = !1; for (const i of n.inboundNodes) if (-1 !== r.indexOf(i)) { if (e) { t = !1; break } e = !0 } if (!t) break } return t }(e), a = ["Layer (type)", "Input Shape", "Output shape", "Param #"]; let o; if (i ? (t = t || 90, n = n || [.32, .61, .89, 1]) : (t = t || 115, n = n || [.24, .48, .7, .8, 1]), n[n.length - 1] <= 1 && (n = n.map((e => Math.floor(t * e)))), !i) { a.push("Receives inputs"), o = []; for (const t in e.nodesByDepth) o.push(...e.nodesByDepth[t]) } r("_".repeat(t)), Ao(a, n, r), r("=".repeat(t)); const s = e.layers; for (let e = 0; e < s.length; ++e)i ? To(s[e], n, r) : Eo(s[e], n, o, r), r((e === s.length - 1 ? "=" : "_").repeat(t)); e.checkTrainableWeightsConsistency(); const u = function (e) { let t; t = null != e.collectedTrainableWeights ? Ui(e.collectedTrainableWeights) : Ui(e.trainableWeights); return t }(e), l = Ui(e.nonTrainableWeights); r(`Total params: ${u + l}`), r(`Trainable params: ${u}`), r(`Non-trainable params: ${l}`), r("_".repeat(t)) } function Ao(e, t, n = console.log) { let r = ""; for (let n = 0; n < e.length; ++n)n > 0 && (r = r.slice(0, r.length - 1) + " "), r += e[n], r = r.slice(0, t[n]), r += " ".repeat(t[n] - r.length); n(r) } function To(e, t, n) { let r, i; try { i = e.inboundNodes.map((e => JSON.stringify(e.inputShapes))).join(",") } catch (e) { i = "multiple" } try { r = JSON.stringify(e.outputShape) } catch (e) { r = "multiple" } Ao([`${e.name} (${e.getClassName()})`, i, r, e.countParams().toString()], t, n) } function Eo(e, t, n, r) { let i, a; try { a = e.inboundNodes.map((e => JSON.stringify(e.inputShapes))).join(",") } catch (e) { a = "multiple" } try { i = JSON.stringify(e.outputShape) } catch (e) { i = "multiple" } const o = []; for (const t of e.inboundNodes) if (!(null != n && n.length > 0 && -1 === n.indexOf(t))) for (let e = 0; e < t.inboundLayers.length; ++e) { const n = t.inboundLayers[e].name, r = t.nodeIndices[e], i = t.tensorIndices[e]; o.push(`${n}[${r}][${i}]`) } const s = e.name, u = e.getClassName(), l = 0 === o.length ? "" : o[0]; Ao([`${s} (${u})`, a, i, e.countParams().toString(), l], t, r); for (let e = 1; e < o.length; ++e)Ao(["", "", "", "", o[e]], t, r) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function No(e, t, n) { return ("inboundNodes" === e || "outputLayers" === e || "inputLayers" === e) && 0 === t && "string" == typeof n } function Io(e, t) { if (null === e) return null; if ("string" == typeof e) return gr(e); if ("number" == typeof e || "boolean" == typeof e) return e; if (e instanceof Array) { const n = [], r = e.length; for (let i = 0; i < r; ++i) { const r = e[i]; No(t, i, r) ? n.push(r) : n.push(Io(r, t)) } return n } { const t = {}; for (const n of Object.keys(e)) { const r = e[n]; if ("name" === n && "string" == typeof r) t[n] = r; else { const e = gr(n); t[e] = Io(r, e) } } return t } } function Mo(e, t) { if (null == e) return null; if ("string" == typeof e) return mr(e); if ("number" == typeof e || "boolean" == typeof e) return e; if (e instanceof Array) { const n = [], r = e.length; for (let i = 0; i < r; ++i) { const r = e[i]; No(t, i, r) ? n.push(r) : n.push(Mo(r, t)) } return n } { const t = {}; for (const n of Object.keys(e)) { const r = e[n], i = mr(n); t[i] = "name" !== n && "className" !== n || "string" != typeof r ? Mo(r, n) : r } return t } } + /** @license See the LICENSE file. */ + const Fo = "4.22.0"; class Do extends Ji { constructor(e) { if (super({}), this.containerNodes = new Set, this.name = e.name, null == this.name) { const e = this.getClassName().toLowerCase(); this.name = Fr(e) } if (this.supportsMasking = !1, this.trainable_ = !0, Array.isArray(e.inputs) ? this.inputs = e.inputs.slice() : this.inputs = [e.inputs], Array.isArray(e.outputs) ? this.outputs = e.outputs.slice() : this.outputs = [e.outputs], kr(this.inputs).length !== this.inputs.length) throw new or(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map((e => e.name))}`); kr(this.outputs).length !== this.outputs.length && console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map((e => e.name))}`), this.inputLayers = [], this.inputLayersNodeIndices = [], this.inputLayersTensorIndices = [], this.outputLayers = [], this.outputLayersNodeIndices = [], this.outputLayersTensorIndices = [], this.layers = [], this.internalContainerRefs = []; for (const e of this.outputs) { const t = e.sourceLayer, n = e.nodeIndex, r = e.tensorIndex; this.outputLayers.push(t), this.outputLayersNodeIndices.push(n), this.outputLayersTensorIndices.push(r) } for (const e of this.inputs) { const t = e.sourceLayer, n = e.nodeIndex, r = e.tensorIndex; hr(0 === n, "input layer has >1 nodes"), hr(0 === r, "input layer has >1 tensors"), this.inputLayers.push(t), this.inputLayersNodeIndices.push(n), this.inputLayersTensorIndices.push(r) } this.inputNames = [], this.outputNames = [], this.feedInputShapes = [], this.feedInputNames = [], this.feedOutputNames = []; for (let t = 0; t < this.inputLayers.length; t++) { const n = this.inputLayers[t]; if (!(n instanceof ea)) throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${t} (0-based) originates from layer type ${n.getClassName()}.`); this.inputNames.push(n.name), this.feedInputShapes.push(n.batchInputShape), this.feedInputNames.push(n.name) } for (const e of this.outputLayers) this.outputNames.push(e.name); this.internalInputShapes = this.inputs.map((e => e.shape)), this.internalOutputShapes = this.outputs.map((e => e.shape)); const t = {}, n = {}, r = {}, i = {}, a = {}, o = [], s = (e, t, n, r, i, u) => { null != r && null != i && null != u || (r = e.sourceLayer, i = e.nodeIndex, u = e.tensorIndex); const l = r.inboundNodes[i]; if (-1 !== n.indexOf(l)) throw new ar(`The tensor ${e.name} at layer "${r.name}" is part of a cycle.`); if (-1 !== t.indexOf(l)) return; this.containerNodes.add(Do.nodeKey(r, i)), r.id in a || (a[r.id] = Object.keys(a).length), -1 === n.indexOf(l) && n.push(l); const c = l.inboundLayers.length; for (let e = 0; e < c; e++) { const r = l.inputTensors[e], i = l.inboundLayers[e], a = l.nodeIndices[e], o = l.tensorIndices[e]; s(r, t, n, i, a, o) } for (t.push(l); n.indexOf(l) >= 0;)n.splice(n.indexOf(l), 1); o.push(l) }, u = [], l = []; for (const e of this.outputs) s(e, u, l); const c = o.slice().reverse(); for (const e of c) { n[e.id] = e, e.id in t || (t[e.id] = 0); let a = t[e.id]; const o = null == r[e.outboundLayer.id] ? 0 : r[e.outboundLayer.id]; a = Math.max(a, o), r[e.outboundLayer.id] = a, i[e.outboundLayer.id] = e.outboundLayer, t[e.id] = a; for (let r = 0; r < e.inboundLayers.length; r++) { const i = e.inboundLayers[r], o = e.nodeIndices[r], s = i.inboundNodes[o], u = null == t[s.id] ? 0 : t[s.id]; t[s.id] = Math.max(a + 1, u), n[s.id] = s } } const h = {}; for (const e in t) { const r = t[e]; r in h || (h[r] = []), h[r].push(n[e]) } const d = {}; for (const e in r) { const t = r[e]; t in d || (d[t] = []), d[t].push(i[e]) } let f = Object.keys(d).map((e => parseInt(e, 10))).sort(wr); this.layers = []; for (const e of f) { const t = d[e]; t.sort(((e, t) => { const n = a[e.id], r = a[t.id]; return n < r ? -1 : n > r ? 1 : 0 })); for (const e of t) e instanceof Do && this.internalContainerRefs.push(e), this.layers.push(e) } this.layersByDepth = d, f = Object.keys(h).map((e => parseInt(e, 10))).sort(wr); const p = this.inputs.slice(), m = []; for (const e of f) for (const t of h[e]) { const e = t.outboundLayer; if (null != e) { for (const n of t.inputTensors) if (-1 === p.indexOf(n)) throw new ar(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${e.name}". The following previous layers were accessed without issue: ${m}`); for (const e of t.outputTensors) p.push(e); m.push(e.name) } } this.nodesByDepth = h; const g = this.layers.map((e => e.name)); for (const e of g) { const t = g.filter((t => t === e)).length; if (1 !== t) throw new ar(`The name "${e}" is used ${t} times in the model. All layer names should be unique. Layer names: ` + JSON.stringify(g)) } this.outboundNodes = [], this.inboundNodes = [], new Ki({ outboundLayer: this, inboundLayers: [], nodeIndices: [], tensorIndices: [], inputTensors: this.inputs, outputTensors: this.outputs, inputMasks: this.inputs.map((e => null)), outputMasks: this.outputs.map((e => null)), inputShapes: this.inputs.map((e => e.shape)), outputShapes: this.outputs.map((e => e.shape)) }), this.built = !0, this._refCount = 1 } assertNotDisposed() { if (0 === this._refCount) throw new Error(`Container '${this.name}' is already disposed.`) } dispose() { this.assertNotDisposed(); const e = { refCountAfterDispose: null, numDisposedVariables: 0 }; if (0 == --this._refCount) { for (const t of this.layers) e.numDisposedVariables += t.dispose().numDisposedVariables; for (const t of this.internalContainerRefs) e.numDisposedVariables += t.dispose().numDisposedVariables } return e.refCountAfterDispose = this._refCount, e } get trainable() { return this.trainable_ } set trainable(e) { this.layers.forEach((t => { t._trainableWeights.forEach((t => t.trainable = e)) })), this.trainable_ = e } get trainableWeights() { if (this._trainableWeights.length > 0) throw new or("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array."); if (!this.trainable) return []; let e = []; for (const t of this.layers) e = e.concat(t.trainableWeights); return e } get nonTrainableWeights() { const e = []; for (const t of this.layers) e.push(...t.nonTrainableWeights); if (!this.trainable) { const t = []; for (const e of this.layers) t.push(...e.trainableWeights); return t.concat(e) } return e } get weights() { return this.trainableWeights.concat(this.nonTrainableWeights) } loadWeights(e, t = !0) { const n = {}; let r = 0; const i = (e => { const t = Object.keys(e); if (0 === t.length) return !1; const n = t[0].split("/"); return !isNaN(parseInt(n[n.length - 1], 10)) })(e); i && this.parseWeights(e); for (const e of this.layers) for (const [t, a] of e.weights.entries()) { const e = i ? `${a.name.split("/").slice(0, -1).join("/") + "/"}${t}` : a.originalName; if (null != n[e]) throw new or(`Duplicate weight name: ${e}`); n[e] = a, r++ } const a = []; for (const r in e) { let i = r; if (null == n[r]) { const e = r.split("/"); i = e.slice(0, -2).concat([e[e.length - 1]]).join("/") } if (null != n[i]) a.push([n[i], e[r]]); else if (t) throw new or(`Provided weight data has no target variable: ${r}`); delete n[i] } if (t) { const e = []; for (const t in n) e.push(t); if (e.length > 0) throw new or(`${e.length} of ${r} weights are not set: ${e}`) } Hi(a) } parseWeights(e) { for (const t in Object.keys(e)) { const n = t.split("/"), r = ["vars", "layer_checkpoint_dependencies"], i = n.map((e => e.startsWith("_") ? e.slice(1) : e)).filter((e => !r.includes(e))).join("/"); i !== t && (e[i] = e[t], delete e[t]) } } updatedConfig() { const e = this.getConfig(), t = {}; return t.className = this.getClassName(), t.config = e, t.kerasVersion = `tfjs-layers ${Fo}`, t.backend = "TensorFlow.js", t } toJSON(e, t = !0) { const n = Mo(this.updatedConfig()); return t ? JSON.stringify(n) : n } call(e, t) { return (0, P.tidy)((() => { e = pr(e); const n = new na; for (let t = 0; t < this.inputs.length; ++t)n.add(this.inputs[t], e[t]); return aa(this.outputs, n, t) })) } computeMask(e, t) { return (0, P.tidy)((() => { let n; return e = pr(e), n = null == t ? cr(null, e.length) : pr(t), this.runInternalGraph(e, n)[1] })) } computeOutputShape(e) { const t = Bi(e); if (t.length !== this.inputLayers.length) throw new or(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`); const n = {}; for (let e = 0; e < t.length; e++) { const r = this.inputLayers[e], i = t[e]; n[r.name + "_0_0"] = i } const r = Object.keys(this.nodesByDepth).map((e => parseInt(e, 10))).sort(wr); if (r.length > 1) for (const e of r) { const t = this.nodesByDepth[e]; for (const e of t) { const t = e.outboundLayer; if (-1 !== this.inputLayers.map((e => e.id)).indexOf(t.id)) continue; const r = []; for (let t = 0; t < e.inboundLayers.length; t++) { const i = e.inboundLayers[t], a = e.nodeIndices[t], o = e.tensorIndices[t], s = n[`${i.name}_${a}_${o}`]; r.push(s) } const i = Bi(t.computeOutputShape(fr(r))), a = t.inboundNodes.indexOf(e); for (let e = 0; e < i.length; e++) { n[`${t.name}_${a}_${e}`] = i[e] } } } const i = [], a = []; for (let e = 0; e < this.outputLayers.length; e++) { const t = this.outputLayers[e], n = this.outputLayersNodeIndices[e], r = this.outputLayersTensorIndices[e], i = `${t.name}_${n}_${r}`; a.push(i) } for (let e = 0; e < a.length; e++) { const t = a[e]; hr(t in n), i.push(n[t]) } return fr(i) } runInternalGraph(e, t) { null == t && (t = cr(null, e.length)); const n = {}; for (let r = 0; r < this.inputs.length; ++r) { const i = this.inputs[r], a = e[r], o = t[r]; n[i.id] = [a, o] } const r = Object.keys(this.nodesByDepth).map((e => parseInt(e, 10))).sort(wr); for (const e of r) { const t = this.nodesByDepth[e]; for (const e of t) { const t = e.outboundLayer, r = e.inputTensors, i = e.outputTensors, a = new Array; for (const e of r) e.id in n && a.push(n[e.id]); if (a.length === r.length) { let r, o, s, u, l = {}; if (null != e.callArgs && (l = e.callArgs), 1 === a.length) { const [e, n] = a[0]; null == l.mask && (l.mask = n), s = pr(t.call(e, l)), u = pr(t.computeMask(e, n)), r = [e], o = [n] } else r = a.map((e => e[0])), o = a.map((e => e[1])), null == l.mask && (l.mask = o), s = pr(t.call(r, l)), u = pr(t.computeMask(r, o)); if (t.activityRegularizer) throw new sr("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet."); for (let e = 0; e < i.length; ++e) { const t = i[e], r = s[e], a = u[e]; n[t.id] = [r, a] } } } } const i = [], a = [], o = []; for (const e of this.outputs) { hr(e.id in n, `Could not compute output ${e.name} : ${e.id}`); const [t, r] = n[e.id]; o.push(t.shape), i.push(t), a.push(r) } return [i, a, o] } buildNodeConversionMap(e) { const t = {}; let n; for (const e of this.layers) { n = e instanceof Do ? 1 : 0; for (let r = 0; r < e.inboundNodes.length; r++) { const i = Do.nodeKey(e, r); this.containerNodes.has(i) && (t[i] = n, n += 1) } } return t } getLayer(e, t) { if (null != t) return this.findLayer(t); if (null == e) throw new or("Provide either a layer name or layer index"); if ("number" == typeof e) return this.findLayer(e); for (const t of this.layers) if (t.name === e) return t; throw new or(`No such layer: ${e}`) } findLayer(e) { if (this.layers.length <= e) throw new or(`Was asked to retrieve layer at index ${e}, but model only has ${this.layers.length} layer(s).`); return this.layers[e] } calculateLosses() { return (0, P.tidy)((() => { const e = []; for (const t of this.layers) for (let n = 0; n < t.inboundNodes.length; ++n) { const r = Do.nodeKey(t, n); this.containerNodes.has(r) && e.push(...t.calculateLosses()) } return e })) } getConfig() { const e = { name: this.name }, t = this.buildNodeConversionMap(this.layers), n = []; for (const e of this.layers) { const r = e.getClassName(), i = e.getConfig(), a = []; for (let n = 0; n < e.inboundNodes.length; n++) { const r = e.inboundNodes[n], i = Do.nodeKey(e, n); let o = {}; if (this.containerNodes.has(i)) { if (r.callArgs) try { JSON.stringify(r.callArgs), o = r.callArgs } catch (t) { console.warn(`Layer ${e.name} was passed non-serializable keyword arguments: ${r.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`), o = {} } if (r.inboundLayers.length > 0) { const e = []; for (let n = 0; n < r.inboundLayers.length; n++) { const i = r.inboundLayers[n], a = r.nodeIndices[n], s = r.tensorIndices[n]; let u = t[Do.nodeKey(i, a)]; null == u && (u = 0), e.push([i.name, u, s, o]) } a.push(e) } } } const o = {}; o.name = e.name, o.className = r, o.config = i, o.inboundNodes = a, n.push(o) } e.layers = n; const r = []; for (let e = 0; e < this.inputLayers.length; e++) { const n = this.inputLayers[e], i = this.inputLayersNodeIndices[e], a = Do.nodeKey(n, i); if (!this.containerNodes.has(a)) continue; let o = t[a]; null == o && (o = 0); const s = this.inputLayersTensorIndices[e]; r.push([n.name, o, s]) } e.inputLayers = r; const i = []; for (let e = 0; e < this.outputLayers.length; e++) { const n = this.outputLayers[e], r = this.outputLayersNodeIndices[e], a = Do.nodeKey(n, r); if (!this.containerNodes.has(a)) continue; let o = t[a]; null == o && (o = 0); const s = this.outputLayersTensorIndices[e]; i.push([n.name, o, s]) } return e.outputLayers = i, e } static fromConfig(e, t, n = {}, r = !1) { const i = {}, a = {}; function o(e, t) { e.name in a ? a[e.name].push(t) : a[e.name] = [t] } function s(e, t) { const n = []; let r; for (const a of t) { const s = a[0], u = a[1], l = a[2]; if (r = null == a[3] ? {} : a[3], !(s in i)) return void o(e, t); const c = i[s]; if (c.inboundNodes.length <= u) return void o(e, t); const h = c.inboundNodes[u]; n.push(h.outputTensors[l]) } n.length > 0 && e.apply(fr(n), r) } function u(e) { const n = e.name, a = Ka(e, null != t.customObjects ? t.customObjects : {}); a.setFastWeightInitDuringBuild(r), i[n] = a; e.inboundNodes.forEach((e => { if (!(e instanceof Array)) throw new or(`Corrupted configuration, expected array for nodeData: ${e}`); o(a, e) })) } const l = t.name, c = t.layers; for (const e of c) u(e); for (; !Sr(a);)for (const e of c) { const t = i[e.name]; if (t.name in a) { const e = a[t.name]; delete a[t.name]; for (const n of e) s(t, n) } } const h = [], d = [], f = t.inputLayers; for (const e of f) { const t = e[0], n = e[1], r = e[2]; hr(t in i); const a = i[t].inboundNodes[n].outputTensors; h.push(a[r]) } const p = t.outputLayers; for (const e of p) { const t = e[0], n = e[1], r = e[2]; hr(t in i); const a = i[t].inboundNodes[n].outputTensors; d.push(a[r]) } return new e({ inputs: h, outputs: d, name: l }) } get stateful() { if (this._stateful) throw new or("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false."); for (const e of this.layers) if (e.stateful) return !0; return !1 } resetStates() { (0, P.tidy)((() => { this.layers.forEach((e => { e.stateful && e.resetStates() })) })) } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function $o(e, t, n) { const r = t.length; if (null == e || Array.isArray(e) && 0 === e.length) return t.map((e => null)); if (1 === r) return Array.isArray(e) && 1 === e.length ? e : "object" == typeof e && t[0] in e ? [e[t[0]]] : [e]; if (Array.isArray(e)) { if (e.length !== r) throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`); return e } if ("object" == typeof e && Object.keys(e).length > 0 && "object" == typeof e[Object.keys(e)[0]]) { const n = []; return t.forEach((t => { t in e ? n.push(e[t]) : n.push(null) })), n } throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`) } function Ro(e, t) { return $o(e, t, "classWeight") } async function Oo(e, t, n, r) { if (null != t || null != r) throw new Error("Support sampleWeight is not implemented yet"); if (null != n) { const t = (0, P.tidy)((() => { if (1 === e.shape.length) return (0, P.clone)(e); if (2 === e.shape.length) { if (e.shape[1] > 1) { const t = 1; return (0, P.argMax)(e, t) } if (1 === e.shape[1]) return (0, P.reshape)(e, [e.shape[0]]); throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`) } throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`) })), r = Array.from(await t.data()); (0, P.dispose)(t); const i = []; return r.forEach((e => { if (null == n[e]) throw new Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`); i.push(n[e]) })), (0, P.tensor1d)(i, "float32") } return null } function zo(e, t) { return (0, P.mul)(e, t) } function Po(e, t) { let n, r; const i = t; n = i.xs, r = i.ys, P.util.assert(null != n && null != r, (() => `A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`)); const a = Bo("input", e.inputNames, n), o = Bo("output", e.outputNames, r), s = a[0].shape[0]; P.util.assert(a.length === e.inputs.length, (() => `LayersModel has ${e.inputs.length} inputs, but the dataset provides ${a.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`)), P.util.assert(o.length === e.outputs.length, (() => `LayersModel has ${e.outputs.length} outputs, but the dataset provides ${o.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`)); for (let t = 0; t < a.length; t++)P.util.assert(a[t].shape[0] === s, (() => `Batch size mismatch: input ${e.inputNames[t]} has ${a[t].shape[0]}; expected ${s} based on input ${e.inputNames[0]}.`)); for (let t = 0; t < o.length; t++)P.util.assert(o[t].shape[0] === s, (() => `Batch size mismatch: output ${e.outputNames[t]} has ${o[t].shape[0]}; expected ${s} based on input ${e.inputNames[0]}.`)); return { xs: a, ys: o } } function Bo(e, t, n) { if (n instanceof P.Tensor) return [n]; if (Array.isArray(n)) return P.util.assert(n.length === t.length, (() => `Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`)), n; { const r = []; for (const i of t) { if (null == n[i]) throw new or(`The feature data generated by the dataset lacks the required ${e} key '${i}'.`); r.push(n[i]) } return r } } async function Lo(e, t, n) { const r = null != n.batchesPerEpoch; if (P.util.assert(null != e.optimizer, (() => "You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")), P.util.assert(null != n, (() => "For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")), P.util.assert(null != n.epochs && n.epochs > 0 && Number.isInteger(n.epochs), (() => `For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)), P.util.assert(!r || n.batchesPerEpoch > 0 && Number.isInteger(n.batchesPerEpoch), (() => `For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)), P.util.assert(null == n.validationSplit, (() => "`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")), e.isTraining) throw new Error("Cannot start training because another fit() call is ongoing."); e.isTraining = !0; try { const i = null != n.validationData; let a, o; if (i) if (jo(n.validationData)) P.util.assert(null == n.validationBatches || n.validationBatches > 0 && Number.isInteger(n.validationBatches), (() => `For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`)); else { const e = function (e) { if (3 === e.length) throw new sr("Validation with sample weights is not implemented yet."); return { xs: e[0], ys: e[1] } }(n.validationData); a = e.xs, o = e.ys } const s = e.makeTrainFunction(), u = e.getDedupedMetricsNames(); let l; l = i ? u.slice().concat(u.map((e => "val_" + e))) : u.slice(); const c = qa(n.callbacks, n.yieldEvery), h = null == n.verbose ? 1 : n.verbose, { callbackList: d, history: f } = Xa(c, h, n.epochs, null, null, function (e, t) { let n = null; null != t.batchesPerEpoch ? n = t.batchesPerEpoch : Number.isFinite(e.size) && (n = e.size); return n }(t, n), null, i, l); d.setModel(e), e.history = f, await d.onTrainBegin(), e.stopTraining_ = !1; let p = null == n.initialEpoch ? 0 : n.initialEpoch, m = await t.iterator(); for (; p < n.epochs;) { const l = {}; await d.onEpochBegin(p); let c = 0, h = 0; for (r || (m = await t.iterator()); !r || c < n.batchesPerEpoch;) { const t = await m.next(); if (r && t.done) { console.warn(`You provided \`batchesPerEpoch\` as ${n.batchesPerEpoch}, but your dataset iterator ran out of data after ${c} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ` + n.batchesPerEpoch * n.epochs + " batches). You may need to use the repeat() function when building your dataset."); break } if (null != t.value) { const { xs: r, ys: i } = Po(e, t.value), a = {}; a.batch = h, a.size = r[0].shape[0], await d.onBatchBegin(h, a); const o = []; if (null != n.classWeight) { const t = Ro(n.classWeight, e.outputNames); for (let e = 0; e < t.length; ++e)o.push(await Oo(i[e], null, t[e])) } const l = r.concat(i).concat(o), f = s(l); P.dispose(l); for (let e = 0; e < u.length; ++e) { const t = u[e], n = f[e]; a[t] = n, P.keep(n) } await d.onBatchEnd(h, a), Ba(a), h++, c++ } if (r ? c >= n.batchesPerEpoch : t.done) { if (i) { let t; t = jo(n.validationData) ? pr(await e.evaluateDataset(n.validationData, { batches: n.validationBatches })) : pr(e.evaluate(a, o, { batchSize: null == n.validationBatchSize ? 32 : n.validationBatchSize, verbose: 0 })); for (let n = 0; n < e.metricsNames.length; ++n)l[`val_${e.metricsNames[n]}`] = t[n] } break } if (e.stopTraining_) break } if (await d.onEpochEnd(p, l), p++, e.stopTraining_) break } return await d.onTrainEnd(), await e.history.syncData(), e.history } finally { e.isTraining = !1 } } function jo(e) { return "function" == typeof e.iterator } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Uo(e) { P.util.assert(e > 0 && Number.isInteger(e), (() => `batchSize is required to be a positive integer, but got ${e}`)) } function Wo(e, t, n) { return null == e ? [null] : Array.isArray(e) ? e.map((e => ni(e, t, n - t))) : ni(e, t, n - t) } function Vo(e, t) { return P.tidy((() => null == e ? null : Array.isArray(e) ? e.map((e => Vo(e, t))) : ci(e, "int32" === t.dtype ? t : P.cast(t, "int32")))) } function Go(e, t) { const n = []; let r = 0, i = null; for (; r < e;)i = r + t, i >= e && (i = e), n.push([r, i]), r = i; return n } function Ho(e) { const t = []; e instanceof P.Tensor && (e = [e]); for (let n = 0; n < e.length; ++n) { const r = e[n]; if (1 === r.rank) t.push(ti(r, 1)); else { if (0 === r.rank) throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar)."); t.push(r) } } return t } function qo(e, t) { if (null == e) return; const n = []; if (t instanceof P.Tensor) n.push(t.id); else if (Array.isArray(t)) t.forEach((e => n.push(e.id))); else if (null != t) for (const e in t) { const r = t[e]; n.push(r.id) } const r = []; if (e instanceof P.Tensor) -1 === n.indexOf(e.id) && r.push(e); else if (Array.isArray(e)) e.forEach((e => { -1 === n.indexOf(e.id) && r.push(e) })); else if (null != e) for (const t in e) { const i = e[t]; -1 === n.indexOf(i.id) && r.push(i) } r.forEach((e => { e.isDisposed || e.dispose() })) } function Yo(e) { return Array.isArray(e) } function Xo(e) { + return ! + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function (e) { return e instanceof P.Tensor }(e) && !Yo(e) + } function Ko(e, t, n, r = !0, i = "") { if (null == t || 0 === t.length) { if (null != e) { let t = !1; if (Yo(e) && e.length > 0) t = !0; else if (Xo(e)) { for (const n in e) if (e.hasOwnProperty(n)) { t = !0; break } } else t = !0; if (t) throw new or(`Error when checking model ${i} expected no data, but got ${e}`) } return [] } if (null == e) return t.map((e => null)); let a; if (Xo(e)) { a = []; for (const n of t) { if (null == e[n]) throw new or(`No data provided for "${n}". Need data for each key in: ${t}`); a.push(e[n]) } } else if (Yo(e)) { if (e.length !== t.length) throw new or(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`); a = e } else { if (t.length > 1) throw new or(`The model ${i} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`); a = [e] } if (a = Ho(a), null != n) for (let e = 0; e < t.length; ++e) { if (null == n[e]) continue; const o = a[e]; if (o.shape.length !== n[e].length) throw new or(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s). but got array with shape ${o.shape}`); for (let t = 0; t < n[e].length; ++t) { if (0 === t && !r) continue; const a = o.shape[t], s = n[e][t]; if (null != s && s >= 0 && a !== s) throw new or(`${i} expected a batch of elements where each example has shape [${n[e].slice(1, n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1, n[e].length)}]) but the ${i} received an input with ${o.shape[0]} examples, each with shape [${o.shape.slice(1, o.shape.length)}] (tensor shape [${o.shape}])`) } } return a } function Zo(e, t, n, r = !0, i = "") { let a; if (Array.isArray(e)) { if (e.length !== t.length) throw new or(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`); a = e } else { if (t.length > 1) throw new or(`The model expects ${t.length} ${i} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`); a = [e] } if (null != n) for (let e = 0; e < t.length; ++e) { if (null == n[e]) continue; const o = a[e]; if (o.shape.length !== n[e].length) throw new or(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s), but got array with shape ${JSON.stringify(o.shape)}`); for (let a = 0; a < n[e].length; ++a) { if (0 === a && !r) continue; const s = o.shape[a], u = n[e][a]; if (null != u && u !== s) throw new or(`Error when checking ${i}: expected ${t[e]} to have shape ${JSON.stringify(n[e])} but got array with shape ${JSON.stringify(o.shape)}.`) } } } class Jo extends Do { + constructor(e) { super(e), this.isTraining = !1 } summary(e, t, n = console.log) { if (!this.built) throw new or("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data)."); Co(this, e, t, n) } compile(e) { + if (null == e.loss && (e.loss = []), this.loss = e.loss, "string" == typeof e.optimizer) this.optimizer_ = + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function (e) { const t = { Adagrad: () => P.train.adagrad(.01), Adadelta: () => P.train.adadelta(1, .95, Qr()), Adam: () => P.train.adam(.001, .9, .999, Qr()), Adamax: () => P.train.adamax(.002, .9, .999, Qr(), 0), RMSProp: () => P.train.rmsprop(.001, .9, 0, Qr()), SGD: () => P.train.sgd(.01) }; if (t.adagrad = t.Adagrad, t.adadelta = t.Adadelta, t.adam = t.Adam, t.adamax = t.Adamax, t.rmsprop = t.RMSProp, t.sgd = t.SGD, e in t) return t[e](); throw new or(`Unknown Optimizer ${e}`) }(e.optimizer), this.isOptimizerOwned = !0; else { if (!(e.optimizer instanceof P.Optimizer)) throw new or("User-defined optimizer must be an instance of tf.Optimizer."); this.optimizer_ = e.optimizer, this.isOptimizerOwned = !1 } let t = []; if (Array.isArray(e.loss) || "string" == typeof e.loss || "function" == typeof e.loss) if (Array.isArray(e.loss)) { if (e.loss.length !== this.outputs.length) throw new or(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`); const n = e.loss; t = n.map((e => uo(e))) } else { const n = uo(e.loss); this.outputs.forEach((e => { t.push(n) })) } else { e.loss = e.loss; for (const t in e.loss) if (-1 === this.outputNames.indexOf(t)) throw new or(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`); for (const n of this.outputNames) null == e.loss[n] && console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`), t.push(uo(e.loss[n])) } this.lossFunctions = t, this.feedOutputNames = [], this.feedOutputShapes = [], this.feedLossFns = []; for (let e = 0; e < this.outputs.length; ++e) { const t = this.internalOutputShapes[e], n = this.outputNames[e]; this.feedOutputNames.push(n), this.feedOutputShapes.push(t), this.feedLossFns.push(this.lossFunctions[e]) } const n = []; this.metrics = e.metrics, this.metricsNames = ["loss"], this.metricsTensors = [], Wr("loss", (() => { for (let e = 0; e < this.outputs.length; ++e) { if (-1 !== n.indexOf(e)) continue; const t = this.lossFunctions[e]; this.outputs.length > 1 && (this.metricsTensors.push([t, e]), this.metricsNames.push(this.outputNames[e] + "_loss")) } })); const r = function (e, t) { if (null == e || Array.isArray(e) && 0 === e.length) return t.map((e => [])); let n; if ("string" == typeof e || "function" == typeof e) n = [e]; else { if (!Array.isArray(e) && "object" != typeof e) throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`); n = e } if (Array.isArray(n)) return t.map((e => n)); { const e = []; for (const r of t) { let t = n.hasOwnProperty(r) ? n[r] : []; Array.isArray(t) || (t = [t]), e.push(t) } return e } }(e.metrics, this.outputNames), i = (e, t, n) => { this.outputNames.length > 1 && (t = this.outputNames[e] + "_" + t), this.metricsNames.push(t), this.metricsTensors.push([n, e]) }; Wr("metric", (() => { for (let e = 0; e < this.outputs.length; ++e) { if (-1 !== n.indexOf(e)) continue; (t => { let n, r, a; for (const o of t) { if ("string" == typeof o && -1 !== ["accuracy", "acc", "crossentropy", "ce"].indexOf(o)) { const t = this.internalOutputShapes[e]; let i; 1 === t[t.length - 1] || this.lossFunctions[e] === io ? -1 !== ["accuracy", "acc"].indexOf(o) ? r = lo : -1 !== ["crossentropy", "ce"].indexOf(o) && (r = mo) : this.lossFunctions[e] === ro ? -1 !== ["accuracy", "acc"].indexOf(o) ? r = go : -1 !== ["crossentropy", "ce"].indexOf(o) && (r = bo) : -1 !== ["accuracy", "acc"].indexOf(o) ? r = co : -1 !== ["crossentropy", "ce"].indexOf(o) && (r = yo), -1 !== ["accuracy", "acc"].indexOf(o) ? i = "acc" : -1 !== ["crossentropy", "ce"].indexOf(o) && (i = "ce"), a = r, n = "" + i } else { const e = xo(o); a = e, n = "" + wo(o) } let t; Wr(n, (() => { t = a })), i(e, n, t) } })(r[e]) } })), this.collectedTrainableWeights = this.trainableWeights + } checkTrainableWeightsConsistency() { null != this.collectedTrainableWeights && this.trainableWeights.length !== this.collectedTrainableWeights.length && console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?") } evaluate(e, t, n = {}) { const r = null == n.batchSize ? 32 : n.batchSize; Uo(r); const i = this.standardizeUserDataXY(e, t, !0, r); try { const e = i[0].concat(i[1]); this.makeTestFunction(); const t = this.testFunction; return fr(this.testLoop(t, e, r, n.verbose, n.steps)) } finally { qo(i[0], e), qo(i[1], t) } } async evaluateDataset(e, t) { return this.makeTestFunction(), async function (e, t, n) { const r = null != (n = n || {}).batches, i = e.testFunction; let a = []; if (n.verbose > 0) throw new sr("Verbose mode is not implemented yet."); P.util.assert(!r || n.batches > 0 && Number.isInteger(n.batches), (() => `Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`)); const o = "function" == typeof t.next ? t : await t.iterator(); let s = 0, u = 0; for (; !r || u < n.batches;) { const t = await o.next(); if (a = P.tidy((() => { if (t.value) { const { xs: n, ys: r } = Po(e, t.value), o = n.concat(r), l = P.tidy((() => i(o))); if (P.dispose(o), 0 === u) for (let e = 0; e < l.length; ++e)a.push((0, P.scalar)(0)); const c = o[0].shape[0]; for (let e = 0; e < l.length; ++e) { const t = l[e], n = a[e]; a[e] = P.tidy((() => P.add(a[e], P.mul(c, t)))), u > 0 && P.dispose(n) } P.dispose(l), s += c, ++u } return a })), t.done) { r && console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`); break } } for (let e = 0; e < a.length; ++e) { const t = a[e]; a[e] = P.div(a[e], s), P.dispose(t) } return fr(a) }(this, e, t) } checkNumSamples(e, t, n, r = "steps") { let i; if (null != n) { if (i = null, null != t) throw new or(`If ${r} is set, batchSize must be null or undefined.Got batchSize = ${t}`) } else { if (null == e) throw new or(`Either the input data should have a defined shape, or ${r} shoud be specified.`); i = Array.isArray(e) ? e[0].shape[0] : e.shape[0] } return i } execute(e, t) { if (Array.isArray(t) && 0 === t.length) throw new or("`outputs` is an empty Array, which is not allowed."); const n = Array.isArray(t), r = n ? t : [t], i = this.retrieveSymbolicTensors(r), a = new na; if (e instanceof P.Tensor && (e = [e]), Array.isArray(e)) { if (e.length !== this.inputs.length) throw new or(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`); for (let t = 0; t < this.inputs.length; ++t)a.add(this.inputs[t], e[t]) } else for (const t of this.inputs) { const n = e[t.name]; if (null == n) throw new or(`No value is provided for the model's input ${t.name}`); a.add(t, n) } const o = aa(i, a); return n ? o : o[0] } retrieveSymbolicTensors(e) { const t = cr(null, e.length); let n = e.length; for (const r of this.layers) { const i = Array.isArray(r.output) ? r.output : [r.output], a = i.map((e => e.name)); for (let r = 0; r < e.length; ++r) { const o = a.indexOf(e[r]); if (-1 !== o && (t[r] = i[o], n--), 0 === n) break } if (0 === n) break } if (n > 0) { const n = []; throw t.forEach(((t, r) => { null == t && n.push(e[r]) })), new or(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`) } return t } predictLoop(e, t = 32, n = !1) { return P.tidy((() => { const r = this.checkNumSamples(e); if (n) throw new sr("Verbose predictLoop() is not implemented yet."); const i = Go(r, t), a = this.outputs.map((e => [])); for (let t = 0; t < i.length; ++t) { P.tidy((() => { const n = i[t][0], r = i[t][1], a = Wo(e, n, r), o = []; if (Array.isArray(a)) for (let e = 0; e < a.length; ++e)o.push({ key: this.inputs[e], value: a[e] }); else o.push({ key: this.inputs[0], value: a }); const s = new na(o); return aa(this.outputs, s) })).forEach(((e, t) => a[t].push(e))) } return fr(a.map((e => P.concat(e, 0)))) })) } predict(e, t = {}) { const n = Ho(e); Zo(n, this.inputNames, this.feedInputShapes, !1); try { const e = null == t.batchSize ? 32 : t.batchSize; return Uo(e), this.predictLoop(n, e) } finally { qo(n, e) } } predictOnBatch(e) { Zo(e, this.inputNames, this.feedInputShapes, !0); const t = (Array.isArray(e) ? e[0] : e).shape[0]; return this.predictLoop(e, t) } standardizeUserDataXY(e, t, n = !0, r) { if (null == this.optimizer_) throw new ar("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs)."); const i = []; for (let e = 0; e < this.feedOutputShapes.length; ++e) { const t = this.feedOutputShapes[e]; this.feedLossFns[e] === ro ? i.push(t.slice(0, t.length - 1).concat([1])) : i.push(t) } if (function (e, t) { const n = kr(e.map((e => e.shape[0]))); n.sort(); const r = kr(t.map((e => e.shape[0]))); if (r.sort(), n.length > 1) throw new or(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e => e.shape)))}`); if (r.length > 1) throw new or(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e => e.shape)))}`); if (n.length > 0 && r.length > 0 && !P.util.arraysEqual(n, r)) throw new or(`Input Tensors should have the same number of samples as target Tensors. Found ${n[0]} input sample(s) and ${r[0]} target sample(s).`) }(e = Ko(e, this.feedInputNames, this.feedInputShapes, !1, "input"), t = Ko(t, this.feedOutputNames, i, !1, "target")), function (e, t, n) { const r = [Ja, io, no]; for (let i = 0; i < e.length; ++i) { const a = e[i], o = t[i], s = n[i]; if (null != o) { if (o === no && 1 === a.shape[a.shape.length - 1]) throw new or(`You are passing a target array of shape ${a.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`); if (-1 !== r.indexOf(o)) { const e = a.shape.slice(1), t = s.slice(1); for (let n = 0; n < e.length; ++n) { const r = e[n], i = t[n]; if (null != i && r !== i) throw new or(`A target Tensor with shape ${a.shape} was passed for an output of shape ${s}, while using a loss function that expects targets to have the same shape as the output.`) } } } } }(t, this.feedLossFns, this.feedOutputShapes), this.stateful && null != r && r > 0 && e[0].shape[0] % r != 0) throw new or(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`); return [e, t] } async standardizeUserData(e, t, n, r, i = !0, a) { const [o, s] = this.standardizeUserDataXY(e, t, i, a); if (null != n) throw new Error("sample weight is not supported yet."); let u = null; if (null != r) { const e = Ro(r, this.outputNames); u = []; for (let t = 0; t < e.length; ++t)u.push(await Oo(s[t], null, e[t])) } return [o, s, u] } testLoop(e, t, n, r = 0, i) { return P.tidy((() => { const a = this.checkNumSamples(t, n, i, "steps"), o = []; if (r > 0) throw new sr("Verbose mode is not implemented yet."); if (null != i) throw new sr("steps mode in testLoop() is not implemented yet"); { const r = Go(a, n), i = (0, P.tensor1d)(Zr(0, a)); for (let n = 0; n < r.length; ++n) { const a = r[n][0], s = r[n][1], u = ni(i, a, s - a), l = Vo(t, u), c = e(l); if (0 === n) for (let e = 0; e < c.length; ++e)o.push((0, P.scalar)(0)); for (let e = 0; e < c.length; ++e) { const t = c[e]; o[e] = P.add(o[e], P.mul(s - a, t)) } } for (let e = 0; e < o.length; ++e)o[e] = P.div(o[e], a) } return o })) } getDedupedMetricsNames() { const e = this.metricsNames, t = []; for (let n = 0; n < e.length; ++n) { const r = e[n]; let i = r; if (dr(e, r) > 1) { i += `_${dr(e.slice(0, n), r)}` } t.push(i) } return t } makeTrainFunction() { return e => { const t = [], n = e.slice(0, this.inputs.length), r = e.slice(this.inputs.length, this.inputs.length + this.outputs.length), i = e.slice(this.inputs.length + this.outputs.length, this.inputs.length + 2 * this.outputs.length), a = [], o = this.collectedTrainableWeights.map((e => e.read())); return [this.optimizer_.minimize((() => { const e = []; for (let t = 0; t < this.inputs.length; ++t)e.push({ key: this.inputs[t], value: n[t] }); const o = new na(e), s = aa(this.outputs, o, { training: !0 }); let u; for (let e = 0; e < this.lossFunctions.length; ++e) { let n = (0, this.lossFunctions[e])(r[e], s[e]); null != i[e] && (n = zo(n, i[e])); const a = P.mean(n); t.push(a), u = 0 === e ? n : P.add(u, n) } for (let e = 0; e < this.metricsTensors.length; ++e) { let n; if (this.outputs.length > 1 && e < this.outputs.length) n = t[e]; else { const t = this.metricsTensors[e][0], i = this.metricsTensors[e][1]; n = P.mean(t(r[i], s[i])) } P.keep(n), a.push(n) } return u = P.mean(u), this.calculateLosses().forEach((e => { u = P.add(u, e) })), u }), !0, o)].concat(a) } } makeTestFunction() { this.testFunction = e => P.tidy((() => { const t = []; let n; const r = e.slice(0, this.inputs.length), i = e.slice(this.inputs.length, this.inputs.length + this.outputs.length), a = []; for (let e = 0; e < this.inputs.length; ++e)a.push({ key: this.inputs[e], value: r[e] }); const o = new na(a), s = aa(this.outputs, o); for (let e = 0; e < this.lossFunctions.length; ++e) { const r = this.lossFunctions[e], a = P.mean(r(i[e], s[e])); n = 0 === e ? a : P.add(n, a), t.push(n) } for (let e = 0; e < this.metricsTensors.length; ++e) { const n = this.metricsTensors[e][0], r = this.metricsTensors[e][1], a = P.mean(n(i[r], s[r])); t.push(a) } return t })) } async fit(e, t, n = {}) { if (this.isTraining) throw new Error("Cannot start training because another fit() call is ongoing."); let r, i, a, o, s, u, l, c, h; this.isTraining = !0; try { const d = null == n.batchSize ? 32 : n.batchSize; Uo(d); const f = !1, p = await this.standardizeUserData(e, t, n.sampleWeight, n.classWeight, f, d); r = p[0], i = p[1], h = p[2]; let m, g = !1; if (null != n.validationData && n.validationData.length > 0) { if (g = !0, 2 !== n.validationData.length) throw 3 === n.validationData.length ? new sr("validationData including sample weights is not supported yet.") : new or(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${n.validationData} is invalid.`); s = n.validationData[0], u = n.validationData[1]; const e = !0, t = await this.standardizeUserData(s, u, null, null, e, d); l = t[0], c = t[1], m = l.concat(c) } else if (null != n.validationSplit && n.validationSplit > 0 && n.validationSplit < 1) { g = !0; const e = Math.floor(r[0].shape[0] * (1 - n.validationSplit)), t = r[0].shape[0]; l = Wo(r, e, t), a = r, r = Wo(r, 0, e), c = Wo(i, e, t), o = i, i = Wo(i, 0, e), m = l.concat(c) } else null != n.validationSteps && (g = !0); const y = r.concat(i).concat(h); this.checkTrainableWeightsConsistency(); const b = this.makeTrainFunction(), v = this.getDedupedMetricsNames(); let x, w; g ? (this.makeTestFunction(), x = this.testFunction, w = v.slice().concat(v.map((e => "val_" + e)))) : (x = null, m = [], w = v.slice()); const k = qa(n.callbacks, n.yieldEvery); return await this.fitLoop(b, y, v, d, n.epochs, n.verbose, k, x, m, n.shuffle, w, n.initialEpoch, null, null) } finally { this.isTraining = !1, qo(r, e), qo(i, t), qo(a, e), qo(o, t), qo(l, s), qo(c, u), null != h && P.dispose(h) } } async fitLoop(e, t, n, r, i, a, o, s, u, l, c, h, d, f) { null == r && (r = 32), null == i && (i = 1), null == l && (l = !0), null == h && (h = 0); let p = !1; if (null != s && null != u && (p = !0), null != f && (p = !0, null == d)) throw new or("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set."); const m = this.checkNumSamples(t, r, d, "steps_per_epoch"); let g; null != m && (g = Zr(0, m)), null == a && (a = 1); const { callbackList: y, history: b } = Xa(o, a, i, h, m, d, r, p, c); y.setModel(this), this.history = b, await y.onTrainBegin(), this.stopTraining_ = !1; for (let a = h; a < i; ++a) { await y.onEpochBegin(a); const i = {}; if (null != d) throw new sr("stepsPerEpoch mode is not implemented yet."); { if ("batch" === l) throw new sr("batch shuffling is not implemneted yet"); l && P.util.shuffle(g); const a = (0, P.tensor1d)(g), o = Go(m, r); for (let l = 0; l < o.length; ++l) { const c = {}; if (await y.onBatchBegin(l, c), P.tidy((() => { const h = o[l][0], d = o[l][1], f = ni(a, h, d - h); c.batch = l, c.size = d - h; const m = Vo(t, f), g = e(m); for (let e = 0; e < n.length; ++e) { const t = n[e], r = g[e]; c[t] = r, P.keep(r) } if (l === o.length - 1 && p) { const e = this.testLoop(s, u, r); for (let t = 0; t < n.length; ++t) { const r = n[t], a = e[t]; P.keep(a), i["val_" + r] = a } } })), await y.onBatchEnd(l, c), Ba(c), this.stopTraining_) break } a.dispose() } if (await y.onEpochEnd(a, i), this.stopTraining_) break } return await y.onTrainEnd(), await this.history.syncData(), this.history } async fitDataset(e, t) { return Lo(this, e, t) } async trainOnBatch(e, t) { const n = await this.standardizeUserData(e, t), r = n[0], i = n[1], a = this.makeTrainFunction()(r.concat(i)), o = []; for (const e of a) { const t = await e.data(); o.push(t[0]) } return P.dispose(a), qo(n[0], e), qo(n[1], t), fr(o) } getNamedWeights(e) { const t = [], n = null != e && e.trainableOnly, r = n ? this.trainableWeights : this.weights, i = this.getWeights(n); for (let e = 0; e < r.length; ++e)n && !r[e].trainable || t.push({ name: r[e].originalName, tensor: i[e] }); return t } set stopTraining(e) { this.stopTraining_ = e } get stopTraining() { return this.stopTraining_ } get optimizer() { return this.optimizer_ } set optimizer(e) { this.optimizer_ !== e && (this.optimizer_ = e, this.isOptimizerOwned = !1) } dispose() { const e = super.dispose(); if (0 === e.refCountAfterDispose && null != this.optimizer && this.isOptimizerOwned) { const t = P.memory().numTensors; this.optimizer_.dispose(), e.numDisposedVariables += t - P.memory().numTensors } return e } getLossIdentifiers() { let e; if ("string" == typeof this.loss) e = mr(this.loss); else if (Array.isArray(this.loss)) { for (const e of this.loss) if ("string" != typeof e) throw new Error("Serialization of non-string loss is not supported."); e = this.loss.map((e => mr(e))) } else { const t = Object.keys(this.loss); e = {}; const n = this.loss; for (const r of t) { if ("string" != typeof n[r]) throw new Error("Serialization of non-string loss is not supported."); e[r] = mr(n[r]) } } return e } getMetricIdentifiers() { if ("string" == typeof this.metrics || "function" == typeof this.metrics) return [mr(wo(this.metrics))]; if (Array.isArray(this.metrics)) return this.metrics.map((e => mr(wo(e)))); { const e = {}; for (const t in this.metrics) e[t] = mr(wo(this.metrics[t])); return e } } getTrainingConfig() { return { loss: this.getLossIdentifiers(), metrics: this.getMetricIdentifiers(), optimizer_config: { class_name: this.optimizer.getClassName(), config: this.optimizer.getConfig() } } } loadTrainingConfig(e) { if (null != e.weighted_metrics) throw new Error("Loading weight_metrics is not supported yet."); if (null != e.loss_weights) throw new Error("Loading loss_weights is not supported yet."); if (null != e.sample_weight_mode) throw new Error("Loading sample_weight_mode is not supported yet."); const t = Ka(Io(e.optimizer_config)); let n, r; if ("string" == typeof e.loss) n = gr(e.loss); else if (Array.isArray(e.loss)) n = e.loss.map((e => gr(e))); else if (null != e.loss) { n = {}; for (const t in e.loss) n[t] = gr(e.loss[t]) } if (Array.isArray(e.metrics)) r = e.metrics.map((e => gr(e))); else if (null != e.metrics) { r = {}; for (const t in e.metrics) r[t] = gr(e.metrics[t]) } this.compile({ loss: n, metrics: r, optimizer: t }) } async save(e, t) { if ("string" == typeof e) { const t = P.io.getSaveHandlers(e); if (0 === t.length) throw new or(`Cannot find any save handlers for URL '${e}'`); if (t.length > 1) throw new or(`Found more than one (${t.length}) save handlers for URL '${e}'`); e = t[0] } if (null == e.save) throw new or("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined."); const n = await P.io.encodeWeights(this.getNamedWeights(t)), r = { modelTopology: this.toJSON(null, !1), format: "layers-model", generatedBy: `TensorFlow.js tfjs-layers v${Fo}`, convertedBy: null }; if (null != t && t.includeOptimizer && null != this.optimizer) { r.trainingConfig = this.getTrainingConfig(); const e = "optimizer", { data: t, specs: i } = await P.io.encodeWeights(await this.optimizer.getWeights(), e); n.specs.push(...i), n.data = P.io.concatenateArrayBuffers([n.data, t]) } if (null != this.userDefinedMetadata) { const e = !0; So(this.userDefinedMetadata, this.name, e), r.userDefinedMetadata = this.userDefinedMetadata } return r.weightData = n.data, r.weightSpecs = n.specs, e.save(r) } setUserDefinedMetadata(e) { So(e, this.name), this.userDefinedMetadata = e } getUserDefinedMetadata() { return this.userDefinedMetadata } + } Jo.className = "Model", P.serialization.registerClass(Jo); class Qo extends Jo { } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + async function es(e, t) { "modelTopology" in e || (e = { modelTopology: e }); let n = e.modelTopology; null != n.model_config && (n = n.model_config); const r = Ka(Io(n), t); if (null != e.weightsManifest) { const t = await P.io.loadWeights(e.weightsManifest, e.pathPrefix, r.weights.map((e => e.originalName))), n = {}; for (const e of r.weights) n[e.originalName] = t[e.originalName]; r.loadWeights(n), (0, P.dispose)(t) } return r } async function ts(e, t) { if (null == t && (t = {}), "string" == typeof e) { const n = P.io.getLoadHandlers(e, t); if (0 === n.length) n.push(P.io.browserHTTPRequest(e, t)); else if (n.length > 1) throw new or(`Found more than one (${n.length}) load handlers for URL '${e}'`); e = n[0] } return async function (e, t, n) { null == n && (n = {}); if (null == e.load) throw new or("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented."); const r = await e.load(); let i = r.modelTopology; null != i.model_config && (i = i.model_config); const a = null == n.strict || n.strict, o = null != r.weightData && null != r.weightSpecs && a, s = Ka(Io(i), t, o), u = r.trainingConfig; null != u && s.loadTrainingConfig(u); null != r.userDefinedMetadata && s.setUserDefinedMetadata(r.userDefinedMetadata); if (null != r.weightData) { if (null == r.weightSpecs) throw new or("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed."); const { modelWeights: e, optimizerWeights: t } = function (e, t) { const n = P.io.decodeWeights(e, t), r = {}, i = []; return t.forEach((e => { "optimizer" === e.group ? i.push({ name: e.name, tensor: n[e.name] }) : r[e.name] = n[e.name] })), { modelWeights: r, optimizerWeights: i } }(r.weightData, r.weightSpecs); s.loadWeights(e, a), null != s.optimizer && t.length > 0 && await s.optimizer.setWeights(t), (0, P.dispose)(e), (0, P.dispose)(t.map((e => e.tensor))) } return s }(e, void 0, t) } Qo.className = "Functional", P.serialization.registerClass(Qo); class ns extends Jo { constructor(e) { if (super({ inputs: [], outputs: [] }), e = e || {}, this.trainable = !0, this.built = !1, this.name = null != e.name ? e.name : Fr("sequential_"), null != e.layers) for (const t of e.layers) this.add(t) } checkShape(e) { if (e.inboundNodes[0].outputTensors[0].shape.some((e => e < 0))) throw new or(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`) } add(e) { const t = e instanceof ns || e instanceof Jo; let n; if (t) { if (n = e, 1 !== n.outputs.length) throw new or("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API."); if (1 !== n.inputs.length) throw new or("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.") } if (0 === this.outputs.length) { if (0 === e.inboundNodes.length) { if (null == e.batchInputShape) throw new or("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument."); const t = ta({ batchShape: e.batchInputShape, dtype: e.dtype, name: e.name + "_input" }); e.apply(t) } if (t) this.outputs = n.outputs, this.inputs = n.inputs; else { if (1 !== e.inboundNodes.length) throw new or(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`); if (1 !== e.inboundNodes[0].outputTensors.length) throw new or("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API."); this.checkShape(e), this.outputs = [e.inboundNodes[0].outputTensors[0]], this.inputs = Qi(this.outputs[0]) } this.inboundNodes = [], new Ki({ outboundLayer: this, inboundLayers: [], nodeIndices: [], tensorIndices: [], inputTensors: this.inputs, outputTensors: this.outputs, inputMasks: cr(null, this.inputs.length), outputMasks: [null], inputShapes: this.inputs.map((e => e.shape)), outputShapes: this.outputs[0].shape }) } else { const t = e.apply(this.outputs[0]); if (Array.isArray(t)) throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API."); this.checkShape(e), this.outputs = [t], this.inboundNodes[0].outputTensors = this.outputs, this.inboundNodes[0].outputShapes = [this.outputs[0].shape] } this.layers.push(e), this.built = !1 } pop() { if (0 === this.layers.length) throw new TypeError("There are no layers in the model."); if (this.layers.pop(), 0 === this.layers.length) this.outputs = [], this.inboundNodes = [], this.outboundNodes = []; else { const e = this.layers.length - 1; this.layers[e].outboundNodes = [], this.outputs = [this.layers[e].output], this.inboundNodes[0].outputTensors = this.outputs, this.inboundNodes[0].outputShapes = [this.outputs[0].shape] } } call(e, t) { return null == this.model && this.build(), this.model.call(e, t) } build(e) { if (ji(e), 0 === this.inputs.length || 0 === this.outputs.length) throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first."); this.model = new Jo({ inputs: this.inputs, outputs: this.outputs[0], name: this.name + "_model" }), this.model.trainable = this.trainable, this.supportsMasking = this.model.supportsMasking, this.inputLayers = this.model.inputLayers, this.inputLayersNodeIndices = this.model.inputLayersNodeIndices, this.inputLayersTensorIndices = this.model.inputLayersTensorIndices, this.outputLayers = this.model.outputLayers, this.outputLayersNodeIndices = this.model.outputLayersNodeIndices, this.outputLayersTensorIndices = this.model.outputLayersTensorIndices, this.nodesByDepth = this.model.nodesByDepth, this.containerNodes = this.model.containerNodes, this.outputNames = this.model.outputNames, this.inputNames = this.model.inputNames, this.built = !0 } countParams() { return this.built || this.build(), super.countParams() } summary(e, t, n = console.log) { this.built || this.build(), super.summary(e, t, n) } setWeights(e) { null == this.model && this.build(), this.model.setWeights(e) } evaluate(e, t, n = {}) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.evaluate(e, t, n) } async evaluateDataset(e, t) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.evaluateDataset(e, t) } predict(e, t = {}) { return null == this.model && this.build(), this.model.predict(e, t) } predictOnBatch(e) { return null == this.model && this.build(), this.model.predictOnBatch(e) } compile(e) { this.build(), this.model.compile(e), this.optimizer_ = this.model.optimizer, this.isOptimizerOwned = this.model.isOptimizerOwned, this.loss = this.model.loss, this.metrics = this.model.metrics, this.metricsTensors = this.model.metricsTensors, this.metricsNames = this.model.metricsNames } get optimizer() { return null == this.model ? void 0 : this.model.optimizer } set optimizer(e) { this.model.optimizer = e } async fit(e, t, n = {}) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.fit(e, t, n) } async fitDataset(e, t) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.fitDataset(e, t) } async trainOnBatch(e, t) { return this.model.trainOnBatch(e, t) } static fromConfig(e, t, n = {}, r = !1) { let i, a = {}; if (t instanceof Array) { if (null == t[0].className || "Merge" === t[0].className) throw new or("Legacy serialization format not supported yet."); i = t } else P.util.assert(null != t.layers, (() => "When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")), i = t.layers, delete t.layers, a = t; const o = new e(a); if (!(o instanceof ns)) throw new sr(`Sequential.fromConfig called on non-Sequential input: ${o}`); for (const e of i) { const t = Ka(e, void 0, r); r && t.setFastWeightInitDuringBuild(!0), o.add(t) } return o } set stopTraining(e) { if (null == this.model) throw new or("Cannot set the stopTraining property of a sequential model before it is compiled."); this.model.stopTraining = e } get stopTraining() { if (null == this.model) throw new or("Cannot get the stopTraining property of a sequential model before it is compiled."); return this.model.stopTraining } getConfig() { const e = []; for (const t of this.layers) { const n = {}; n.className = t.getClassName(), n.config = t.getConfig(), e.push(n) } return { name: this.name, layers: e } } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function rs(e) { return new Jo(e) } function is(e) { return new ns(e) } function as(e) { return ta(e) } function os(e, t) { Ya.registerCallbackConstructor(e, t) } ns.className = "Sequential", P.serialization.registerClass(ns); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class ss extends P.serialization.Serializable { getConfig() { return {} } } class us extends ss { apply(e, t = 1) { return function (e, t = 1) { if (1 !== t) throw new sr(`Support for alpha values other than 1 (${t}) is not implemented yet.`); return P.elu(e) }(e, t) } } us.className = "elu", P.serialization.registerClass(us); class ls extends ss { apply(e) { return P.selu(e) } } ls.className = "selu", P.serialization.registerClass(ls); class cs extends ss { apply(e) { return P.relu(e) } } cs.className = "relu", P.serialization.registerClass(cs); class hs extends ss { apply(e) { return (0, P.tidy)((() => P.minimum(6, P.relu(e)))) } } hs.className = "relu6", P.serialization.registerClass(hs); class ds extends ss { apply(e) { return e } } ds.className = "linear", P.serialization.registerClass(ds); class fs extends ss { apply(e) { return P.sigmoid(e) } } fs.className = "sigmoid", P.serialization.registerClass(fs); class ps extends ss { apply(e) { return function (e) { return (0, P.tidy)((() => { const t = P.add(.5, P.mul(.2, e)); return P.clipByValue(t, 0, 1) })) }(e) } } ps.className = "hardSigmoid", P.serialization.registerClass(ps); class ms extends ss { apply(e) { return P.softplus(e) } } ms.className = "softplus", P.serialization.registerClass(ms); class gs extends ss { apply(e) { return function (e) { return (0, P.tidy)((() => P.div(e, P.add(P.abs(e), 1)))) }(e) } } gs.className = "softsign", P.serialization.registerClass(gs); class ys extends ss { apply(e) { return P.tanh(e) } } ys.className = "tanh", P.serialization.registerClass(ys); class bs extends ss { apply(e, t = -1) { return P.softmax(e, t) } } bs.className = "softmax", P.serialization.registerClass(bs); class vs extends ss { apply(e, t = -1) { return P.logSoftmax(e, t) } } vs.className = "logSoftmax", P.serialization.registerClass(vs); class xs extends ss { apply(e) { return (0, P.tidy)((() => P.tidy((() => { const t = Math.sqrt(2), n = P.mul(.5, P.add(1, P.erf(P.div(e, t)))); return P.mul(e, n) })))) } } xs.className = "gelu", P.serialization.registerClass(xs); class ws extends ss { apply(e) { return (0, P.tidy)((() => P.mul(.5, P.mul(e, P.add(1, P.tanh(P.mul(P.sqrt(P.div(2, Math.PI)), P.add(e, P.mul(.044715, P.pow(e, 3)))))))))) } } ws.className = "gelu_new", P.serialization.registerClass(ws); class ks extends ss { apply(e) { return (0, P.tidy)((() => P.mul(e, P.tanh(P.softplus(e))))) } } ks.className = "mish", P.serialization.registerClass(ks); class Ss extends ss { apply(e, t = 1) { return (0, P.tidy)((() => P.mul(P.sigmoid(P.mul(e, t)), e))) } } function _s(e) { return e.getClassName() } function Cs(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "activation") } function As(e) { if (null == e) { const e = { className: "linear", config: {} }; return Cs(e) } if ("string" == typeof e) { const t = {}; return t.className = e, t.config = {}, Cs(t) } return e instanceof ss ? e : Cs(e) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Ts(e) { if (null != e && "object" != typeof e) throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`) } Ss.className = "swish", P.serialization.registerClass(Ss); class Es extends P.serialization.Serializable { } class Ns extends Es { constructor(e) { super(), Ts(e), this.l1 = null == e || null == e.l1 ? .01 : e.l1, this.l2 = null == e || null == e.l2 ? .01 : e.l2, this.hasL1 = 0 !== this.l1, this.hasL2 = 0 !== this.l2 } apply(e) { return (0, P.tidy)((() => { let t = (0, P.zeros)([1]); return this.hasL1 && (t = (0, P.add)(t, (0, P.sum)(P.mul(this.l1, (0, P.abs)(e))))), this.hasL2 && (t = (0, P.add)(t, (0, P.sum)(P.mul(this.l2, hi(e))))), P.reshape(t, []) })) } getConfig() { return { l1: this.l1, l2: this.l2 } } static fromConfig(e, t) { return new e({ l1: t.l1, l2: t.l2 }) } } Ns.className = "L1L2", P.serialization.registerClass(Ns); const Is = { l1l2: "L1L2" }; function Ms(e) { return br(e) } function Fs(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "regularizer") } function Ds(e) { if (null == e) return null; if ("string" == typeof e) { return Fs({ className: e in Is ? Is[e] : e, config: {} }) } return e instanceof Es ? e : Fs(e) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class $s extends Ji { constructor(e) { super(null == e ? {} : e), this.supportsMasking = !0, null != e && (this.maxValue = e.maxValue) } call(e, t) { e = Li(e); let n = (0, P.relu)(e); return null != this.maxValue && (n = (0, P.clipByValue)(n, 0, this.maxValue)), n } computeOutputShape(e) { return e } getConfig() { const e = { maxValue: this.maxValue }, t = super.getConfig(); return Object.assign(e, t), e } } $s.className = "ReLU", P.serialization.registerClass($s); class Rs extends Ji { constructor(e) { super(null == e ? {} : e), this.DEFAULT_ALPHA = .3, null == e && (e = {}), this.alpha = null == e.alpha ? this.DEFAULT_ALPHA : e.alpha } call(e, t) { const n = Li(e); return (0, P.leakyRelu)(n, this.alpha) } computeOutputShape(e) { return e } getConfig() { const e = { alpha: this.alpha }, t = super.getConfig(); return Object.assign(e, t), e } } Rs.className = "LeakyReLU", P.serialization.registerClass(Rs); class Os extends Ji { constructor(e) { if (super(null == e ? {} : e), this.DEFAULT_ALPHA_INITIALIZER = "zeros", null == e && (e = {}), this.supportsMasking = !0, this.alphaInitializer = zi(e.alphaInitializer || this.DEFAULT_ALPHA_INITIALIZER), this.alphaRegularizer = Ds(e.alphaRegularizer), this.alphaConstraint = ba(e.alphaConstraint), null == e.sharedAxes) this.sharedAxes = null; else if (Array.isArray(e.sharedAxes)) this.sharedAxes = e.sharedAxes; else { if ("number" != typeof e.sharedAxes) throw new or(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`); this.sharedAxes = [e.sharedAxes] } } build(e) { const t = (e = ji(e)).slice(1); if (null != this.sharedAxes) for (const e of this.sharedAxes) t[e - 1] = 1; this.alpha = this.addWeight("alpha", t, "float32", this.alphaInitializer, this.alphaRegularizer, !0, this.alphaConstraint); const n = {}; if (null != this.sharedAxes) for (let t = 1; t < e.length; ++t)n[t] = e[t]; this.inputSpec = [new qi({ ndim: e.length, axes: n })], this.built = !0 } call(e, t) { return e = Li(e), (0, P.prelu)(e, this.alpha.read()) } getConfig() { const e = { alphaInitializer: Oi(this.alphaInitializer), alphaRegularizer: Ms(this.alphaRegularizer), alphaConstraint: ga(this.alphaConstraint), sharedAxes: this.sharedAxes }, t = super.getConfig(); return Object.assign(e, t), e } } Os.className = "PReLU", P.serialization.registerClass(Os); class zs extends Ji { constructor(e) { if (super(null == e ? {} : e), this.DEFAULT_ALPHA = 1, null == e && (e = {}), null != e.alpha && e.alpha !== this.DEFAULT_ALPHA) throw new sr(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`); this.alpha = null == e.alpha ? this.DEFAULT_ALPHA : e.alpha } call(e, t) { const n = Li(e); return (0, P.elu)(n) } computeOutputShape(e) { return e } getConfig() { const e = { alpha: this.alpha }, t = super.getConfig(); return Object.assign(e, t), e } } zs.className = "ELU", P.serialization.registerClass(zs); class Ps extends Ji { constructor(e) { super(null == e ? {} : e), this.DEFAULT_THETA = 1, null == e && (e = {}), this.theta = null == e.theta ? this.DEFAULT_THETA : e.theta } call(e, t) { const n = Li(e); return (0, P.mul)(n, (0, P.cast)((0, P.greater)(n, this.theta), "float32")) } computeOutputShape(e) { return e } getConfig() { const e = { theta: this.theta }, t = super.getConfig(); return Object.assign(e, t), e } } Ps.className = "ThresholdedReLU", P.serialization.registerClass(Ps); class Bs extends Ji { constructor(e) { super(null == e ? {} : e), this.DEFAULT_AXIS = 1, null == e && (e = {}), this.softmax = (new bs).apply, this.axis = null == e.axis ? this.DEFAULT_AXIS : e.axis } call(e, t) { return (0, P.tidy)((() => { let n = Li(e); const r = t.mask; if (null != r) { const e = (0, P.mul)((0, P.sub)((0, P.ones)(n.shape), (0, P.cast)(r, n.dtype)), (0, P.scalar)(-1e9)); n = (0, P.add)(n, e) } return this.axis instanceof Array ? this.axis.length > 1 ? (0, P.exp)((0, P.sub)(n, (0, P.logSumExp)(n, this.axis, !0))) : this.softmax(n, this.axis[0]) : this.softmax(n, this.axis) })) } computeOutputShape(e) { return e } getConfig() { const e = { axis: this.axis }, t = super.getConfig(); return Object.assign(e, t), e } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Ls(e, t, n) { + if ("number" == typeof e) return cr(e, t); if (e.length !== t) throw new or(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${e.length} elements.`); for (let i = 0; i < t; ++i) { const a = e[i]; if ((r = a) !== parseInt(r.toString(), 10)) throw new or(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${JSON.stringify(e)} including a non-integer number ${a}`) } return e; + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + var r + } function js(e, t, n, r, i = 1) { if (null == e) return e; let a; return a = "same" === n ? e : e - (t + (t - 1) * (i - 1)) + 1, Math.floor((a + r - 1) / r) } function Us(e, t, n, r) { if (null == e) return null; if ("valid" === r) e = e * t + Kr([n - t, 0]); else { if ("same" !== r) throw new or(`Unsupport padding mode: ${r}.`); e *= t } return e } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Ws(e, t) { return (0, P.tidy)((() => (Br(t), "channelsFirst" === t ? P.transpose(e, [0, 2, 3, 1]) : e))) } function Vs(e, t) { return (0, P.tidy)((() => (Br(t), "channelsFirst" === t ? P.transpose(e, [0, 2, 3, 4, 1]) : e))) } function Gs(e, t, n, r = 1, i = "valid", a, o = 1) { return (0, P.tidy)((() => { if (null == a && (a = "channelsLast"), Br(a), 3 !== e.shape.length) throw new or(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`); if (3 !== t.shape.length) throw new or(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`); if (null != n && 1 !== n.shape.length) throw new or(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`); if ("channelsFirst" === a && (e = P.transpose(e, [0, 2, 1])), "causal" === i) throw new sr("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet."); let s = P.conv1d(e, t, r, "same" === i ? "same" : "valid", "NWC", o); return null != n && (s = fi(s, n)), s })) } function Hs(e, t, n, r = [1, 1], i = "valid", a, o, s = null) { return (0, P.tidy)((() => { if (null == a && (a = "channelsLast"), Br(a), 3 !== e.rank && 4 !== e.rank) throw new or(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`); if (3 !== t.rank && 4 !== t.rank) throw new or(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`); let u = Ws(e, a); if ("causal" === i) throw new sr("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet."); return u = P.fused.conv2d({ x: u, filter: t, strides: r, pad: "same" === i ? "same" : "valid", dilations: o, dataFormat: "NHWC", bias: n, activation: s }), "channelsFirst" === a && (u = P.transpose(u, [0, 3, 1, 2])), u })) } function qs(e, t, n, r = [1, 1, 1], i = "valid", a, o) { return (0, P.tidy)((() => { if (null == a && (a = "channelsLast"), Br(a), 4 !== e.rank && 5 !== e.rank) throw new or(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`); if (4 !== t.rank && 5 !== t.rank) throw new or(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`); let s = Vs(e, a); if ("causal" === i) throw new sr("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet."); return s = P.conv3d(s, t, r, "same" === i ? "same" : "valid", "NDHWC", o), null != n && (s = fi(s, n)), "channelsFirst" === a && (s = P.transpose(s, [0, 4, 1, 2, 3])), s })) } Bs.className = "Softmax", P.serialization.registerClass(Bs); class Ys extends Ji { constructor(e, t) { if (super(t), this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", Ys.verifyArgs(t), this.rank = e, Ar(this.rank, "rank"), 1 !== this.rank && 2 !== this.rank && 3 !== this.rank) throw new sr(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`); if (this.kernelSize = Ls(t.kernelSize, e, "kernelSize"), this.strides = Ls(null == t.strides ? 1 : t.strides, e, "strides"), this.padding = null == t.padding ? "valid" : t.padding, Lr(this.padding), this.dataFormat = null == t.dataFormat ? "channelsLast" : t.dataFormat, Br(this.dataFormat), this.activation = As(t.activation), this.useBias = null == t.useBias || t.useBias, this.biasInitializer = zi(t.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.biasConstraint = ba(t.biasConstraint), this.biasRegularizer = Ds(t.biasRegularizer), this.activityRegularizer = Ds(t.activityRegularizer), this.dilationRate = Ls(null == t.dilationRate ? 1 : t.dilationRate, e, "dilationRate"), 1 === this.rank && Array.isArray(this.dilationRate) && 1 !== this.dilationRate.length) throw new or(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`); if (2 === this.rank) { if ("number" == typeof this.dilationRate) this.dilationRate = [this.dilationRate, this.dilationRate]; else if (2 !== this.dilationRate.length) throw new or(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`) } else if (3 === this.rank) if ("number" == typeof this.dilationRate) this.dilationRate = [this.dilationRate, this.dilationRate, this.dilationRate]; else if (3 !== this.dilationRate.length) throw new or(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`) } static verifyArgs(e) { if (hr("kernelSize" in e, "required key 'kernelSize' not in config"), "number" != typeof e.kernelSize && !Cr(e.kernelSize, "number", 1, 3)) throw new or(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`) } getConfig() { const e = { kernelSize: this.kernelSize, strides: this.strides, padding: this.padding, dataFormat: this.dataFormat, dilationRate: this.dilationRate, activation: _s(this.activation), useBias: this.useBias, biasInitializer: Oi(this.biasInitializer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), biasConstraint: ga(this.biasConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } } class Xs extends Ys { constructor(e, t) { super(e, t), this.kernel = null, Xs.verifyArgs(t), this.filters = t.filters, Ar(this.filters, "filters"), this.kernelInitializer = zi(t.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.kernelConstraint = ba(t.kernelConstraint), this.kernelRegularizer = Ds(t.kernelRegularizer) } build(e) { e = ji(e); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t]) throw new or(`The channel dimension of the input should be defined. Found ${e[t]}`); const n = e[t], r = this.kernelSize.concat([n, this.filters]); this.kernel = this.addWeight("kernel", r, null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [{ ndim: this.rank + 2, axes: { [t]: n } }], this.built = !0 } call(e, t) { return (0, P.tidy)((() => { let t; e = Li(e); const n = null == this.bias ? null : this.bias.read(), r = Er(this.activation.getClassName()); if (null != r && 2 === this.rank) t = Hs(e, this.kernel.read(), n, this.strides, this.padding, this.dataFormat, this.dilationRate, r); else { if (1 === this.rank) t = Gs(e, this.kernel.read(), n, this.strides[0], this.padding, this.dataFormat, this.dilationRate[0]); else if (2 === this.rank) t = Hs(e, this.kernel.read(), n, this.strides, this.padding, this.dataFormat, this.dilationRate); else { if (3 !== this.rank) throw new sr("convolutions greater than 3D are not implemented yet."); t = qs(e, this.kernel.read(), n, this.strides, this.padding, this.dataFormat, this.dilationRate) } null != this.activation && (t = this.activation.apply(t)) } return t })) } computeOutputShape(e) { e = ji(e); const t = [], n = "channelsLast" === this.dataFormat ? e.slice(1, e.length - 1) : e.slice(2); for (let e = 0; e < n.length; ++e) { const r = js(n[e], this.kernelSize[e], this.padding, this.strides[e], "number" == typeof this.dilationRate ? this.dilationRate : this.dilationRate[e]); t.push(r) } let r = [e[0]]; return "channelsLast" === this.dataFormat ? (r = r.concat(t), r.push(this.filters)) : (r.push(this.filters), r = r.concat(t)), r } getConfig() { const e = { filters: this.filters, kernelInitializer: Oi(this.kernelInitializer), kernelRegularizer: Ms(this.kernelRegularizer), kernelConstraint: ga(this.kernelConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } static verifyArgs(e) { if (!("filters" in e) || "number" != typeof e.filters || e.filters < 1) throw new or(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`) } } class Ks extends Xs { constructor(e) { super(2, e), Ks.verifyArgs(e) } getConfig() { const e = super.getConfig(); return delete e.rank, e } static verifyArgs(e) { if ("number" != typeof e.kernelSize && !Cr(e.kernelSize, "number", 1, 2)) throw new or(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`) } } Ks.className = "Conv2D", P.serialization.registerClass(Ks); class Zs extends Xs { constructor(e) { super(3, e), Zs.verifyArgs(e) } getConfig() { const e = super.getConfig(); return delete e.rank, e } static verifyArgs(e) { if ("number" != typeof e.kernelSize && (!Array.isArray(e.kernelSize) || 1 !== e.kernelSize.length && 3 !== e.kernelSize.length)) throw new or(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`) } } Zs.className = "Conv3D", P.serialization.registerClass(Zs); class Js extends Ks { constructor(e) { if (super(e), this.inputSpec = [new qi({ ndim: 4 })], "same" !== this.padding && "valid" !== this.padding) throw new or(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`) } build(e) { if (4 !== (e = ji(e)).length) throw new or("Input should have rank 4; Received input shape: " + JSON.stringify(e)); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t]) throw new or("The channel dimension of the inputs should be defined. Found `None`."); const n = e[t], r = this.kernelSize.concat([this.filters, n]); this.kernel = this.addWeight("kernel", r, "float32", this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [new qi({ ndim: 4, axes: { [t]: n } })], this.built = !0 } call(e, t) { return P.tidy((() => { let t = Li(e); if (4 !== t.shape.length) throw new or(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`); const n = t.shape, r = n[0]; let i, a; "channelsFirst" === this.dataFormat ? (i = 2, a = 3) : (i = 1, a = 2); const o = n[i], s = n[a], u = this.kernelSize[0], l = this.kernelSize[1], c = this.strides[0], h = this.strides[1], d = [r, Us(o, c, u, this.padding), Us(s, h, l, this.padding), this.filters]; "channelsLast" !== this.dataFormat && (t = P.transpose(t, [0, 2, 3, 1])); let f = P.conv2dTranspose(t, this.kernel.read(), d, this.strides, this.padding); return "channelsLast" !== this.dataFormat && (f = P.transpose(f, [0, 3, 1, 2])), null != this.bias && (f = fi(f, this.bias.read(), this.dataFormat)), null != this.activation && (f = this.activation.apply(f)), f })) } computeOutputShape(e) { const t = (e = ji(e)).slice(); let n, r, i; "channelsFirst" === this.dataFormat ? (n = 1, r = 2, i = 3) : (n = 3, r = 1, i = 2); const a = this.kernelSize[0], o = this.kernelSize[1], s = this.strides[0], u = this.strides[1]; return t[n] = this.filters, t[r] = Us(t[r], s, a, this.padding), t[i] = Us(t[i], u, o, this.padding), t } getConfig() { const e = super.getConfig(); return delete e.dilationRate, e } } Js.className = "Conv2DTranspose", P.serialization.registerClass(Js); class Qs extends Zs { constructor(e) { if (super(e), this.inputSpec = [new qi({ ndim: 5 })], "same" !== this.padding && "valid" !== this.padding) throw new or(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`) } build(e) { if (5 !== (e = ji(e)).length) throw new or("Input should have rank 5; Received input shape: " + JSON.stringify(e)); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t]) throw new or("The channel dimension of the inputs should be defined. Found `None`."); const n = e[t], r = this.kernelSize.concat([this.filters, n]); this.kernel = this.addWeight("kernel", r, "float32", this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [new qi({ ndim: 5, axes: { [t]: n } })], this.built = !0 } call(e, t) { return P.tidy((() => { let t = Li(e); if (5 !== t.shape.length) throw new or(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`); const n = t.shape, r = n[0]; let i, a, o; "channelsFirst" === this.dataFormat ? (o = 2, i = 3, a = 4) : (o = 1, i = 2, a = 3); const s = n[o], u = n[i], l = n[a], c = this.kernelSize[0], h = this.kernelSize[1], d = this.kernelSize[2], f = this.strides[0], p = this.strides[1], m = this.strides[2], g = [r, Us(s, f, c, this.padding), Us(u, p, h, this.padding), Us(l, m, d, this.padding), this.filters]; "channelsLast" !== this.dataFormat && (t = P.transpose(t, [0, 2, 3, 4, 1])); let y = P.conv3dTranspose(t, this.kernel.read(), g, this.strides, this.padding); return "channelsLast" !== this.dataFormat && (y = P.transpose(y, [0, 4, 1, 2, 3])), null !== this.bias && (y = fi(y, this.bias.read(), this.dataFormat)), null !== this.activation && (y = this.activation.apply(y)), y })) } computeOutputShape(e) { const t = (e = ji(e)).slice(); let n, r, i, a; "channelsFirst" === this.dataFormat ? (n = 1, r = 2, i = 3, a = 4) : (n = 4, r = 1, i = 2, a = 3); const o = this.kernelSize[0], s = this.kernelSize[1], u = this.kernelSize[2], l = this.strides[0], c = this.strides[1], h = this.strides[2]; return t[n] = this.filters, t[r] = Us(t[r], l, o, this.padding), t[i] = Us(t[i], c, s, this.padding), t[a] = Us(t[a], h, u, this.padding), t } getConfig() { const e = super.getConfig(); return delete e.dilationRate, e } } Qs.className = "Conv3DTranspose", P.serialization.registerClass(Qs); class eu extends Xs { constructor(e, t) { if (super(e, t), this.DEFAULT_DEPTHWISE_INITIALIZER = "glorotUniform", this.DEFAULT_POINTWISE_INITIALIZER = "glorotUniform", this.depthwiseKernel = null, this.pointwiseKernel = null, null == t.filters) throw new or("The `filters` configuration field is required by SeparableConv, but is unspecified."); if (null != t.kernelInitializer || null != t.kernelRegularizer || null != t.kernelConstraint) throw new or("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead."); if (null != t.padding && "same" !== t.padding && "valid" !== t.padding) throw new or(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`); this.depthMultiplier = null == t.depthMultiplier ? 1 : t.depthMultiplier, this.depthwiseInitializer = zi(t.depthwiseInitializer || this.DEFAULT_DEPTHWISE_INITIALIZER), this.depthwiseRegularizer = Ds(t.depthwiseRegularizer), this.depthwiseConstraint = ba(t.depthwiseConstraint), this.pointwiseInitializer = zi(t.depthwiseInitializer || this.DEFAULT_POINTWISE_INITIALIZER), this.pointwiseRegularizer = Ds(t.pointwiseRegularizer), this.pointwiseConstraint = ba(t.pointwiseConstraint) } build(e) { if ((e = ji(e)).length < this.rank + 2) throw new or(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank + 2}, but received input shape: ${JSON.stringify(e)}`); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t] || e[t] < 0) throw new or(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`); const n = e[t], r = this.kernelSize.concat([n, this.depthMultiplier]), i = []; for (let e = 0; e < this.rank; ++e)i.push(1); i.push(n * this.depthMultiplier, this.filters); const a = !0; this.depthwiseKernel = this.addWeight("depthwise_kernel", r, "float32", this.depthwiseInitializer, this.depthwiseRegularizer, a, this.depthwiseConstraint), this.pointwiseKernel = this.addWeight("pointwise_kernel", i, "float32", this.pointwiseInitializer, this.pointwiseRegularizer, a, this.pointwiseConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, a, this.biasConstraint) : this.bias = null, this.inputSpec = [new qi({ ndim: this.rank + 2, axes: { [t]: n } })], this.built = !0 } call(e, t) { return (0, P.tidy)((() => { let t; if (e = Li(e), 1 === this.rank) throw new sr("1D separable convolution is not implemented yet."); return 2 === this.rank && ("channelsFirst" === this.dataFormat && (e = P.transpose(e, [0, 2, 3, 1])), t = P.separableConv2d(e, this.depthwiseKernel.read(), this.pointwiseKernel.read(), this.strides, this.padding, this.dilationRate, "NHWC")), this.useBias && (t = fi(t, this.bias.read(), this.dataFormat)), null != this.activation && (t = this.activation.apply(t)), "channelsFirst" === this.dataFormat && (t = P.transpose(t, [0, 3, 1, 2])), t })) } getConfig() { const e = super.getConfig(); return delete e.rank, delete e.kernelInitializer, delete e.kernelRegularizer, delete e.kernelConstraint, e.depthwiseInitializer = Oi(this.depthwiseInitializer), e.pointwiseInitializer = Oi(this.pointwiseInitializer), e.depthwiseRegularizer = Ms(this.depthwiseRegularizer), e.pointwiseRegularizer = Ms(this.pointwiseRegularizer), e.depthwiseConstraint = ga(this.depthwiseConstraint), e.pointwiseConstraint = ga(this.pointwiseConstraint), e } } eu.className = "SeparableConv"; class tu extends eu { constructor(e) { super(2, e) } } tu.className = "SeparableConv2D", P.serialization.registerClass(tu); class nu extends Xs { constructor(e) { super(1, e), nu.verifyArgs(e), this.inputSpec = [{ ndim: 3 }] } getConfig() { const e = super.getConfig(); return delete e.rank, delete e.dataFormat, e } static verifyArgs(e) { if ("number" != typeof e.kernelSize && !Cr(e.kernelSize, "number", 1, 1)) throw new or(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`) } } nu.className = "Conv1D", P.serialization.registerClass(nu); class ru extends Ji { constructor(e) { super(e), "number" == typeof e.cropping ? this.cropping = [[e.cropping, e.cropping], [e.cropping, e.cropping]] : "number" == typeof e.cropping[0] ? this.cropping = [[e.cropping[0], e.cropping[0]], [e.cropping[1], e.cropping[1]]] : this.cropping = e.cropping, this.dataFormat = void 0 === e.dataFormat ? "channelsLast" : e.dataFormat, this.inputSpec = [{ ndim: 4 }] } computeOutputShape(e) { return "channelsFirst" === this.dataFormat ? [e[0], e[1], e[2] - this.cropping[0][0] - this.cropping[0][1], e[3] - this.cropping[1][0] - this.cropping[1][1]] : [e[0], e[1] - this.cropping[0][0] - this.cropping[0][1], e[2] - this.cropping[1][0] - this.cropping[1][1], e[3]] } call(e, t) { return (0, P.tidy)((() => { if (e = Li(e), "channelsLast" === this.dataFormat) { const t = ii(e, this.cropping[0][0], e.shape[1] - this.cropping[0][0] - this.cropping[0][1], 2); return ii(t, this.cropping[1][0], e.shape[2] - this.cropping[1][1] - this.cropping[1][0], 3) } { const t = ii(e, this.cropping[0][0], e.shape[2] - this.cropping[0][0] - this.cropping[0][1], 3); return ii(t, this.cropping[1][0], e.shape[3] - this.cropping[1][1] - this.cropping[1][0], 4) } })) } getConfig() { const e = { cropping: this.cropping, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } ru.className = "Cropping2D", P.serialization.registerClass(ru); class iu extends Ji { constructor(e) { var t; super(e), this.DEFAULT_SIZE = [2, 2], this.inputSpec = [{ ndim: 4 }], this.size = null == e.size ? this.DEFAULT_SIZE : e.size, this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), this.interpolation = null == e.interpolation ? "nearest" : e.interpolation, t = this.interpolation, _r($r, "InterpolationFormat", t) } computeOutputShape(e) { if ("channelsFirst" === this.dataFormat) { const t = null == e[2] ? null : this.size[0] * e[2], n = null == e[3] ? null : this.size[1] * e[3]; return [e[0], e[1], t, n] } { const t = null == e[1] ? null : this.size[0] * e[1], n = null == e[2] ? null : this.size[1] * e[2]; return [e[0], t, n, e[3]] } } call(e, t) { return P.tidy((() => { let t = Li(e); const n = t.shape; if ("channelsFirst" === this.dataFormat) { t = P.transpose(t, [0, 2, 3, 1]); const e = this.size[0] * n[2], r = this.size[1] * n[3], i = "nearest" === this.interpolation ? P.image.resizeNearestNeighbor(t, [e, r]) : P.image.resizeBilinear(t, [e, r]); return P.transpose(i, [0, 3, 1, 2]) } { const e = this.size[0] * n[1], r = this.size[1] * n[2]; return "nearest" === this.interpolation ? P.image.resizeNearestNeighbor(t, [e, r]) : P.image.resizeBilinear(t, [e, r]) } })) } getConfig() { const e = { size: this.size, dataFormat: this.dataFormat, interpolation: this.interpolation }, t = super.getConfig(); return Object.assign(e, t), e } } iu.className = "UpSampling2D", P.serialization.registerClass(iu); class au extends Ys { + constructor(e) { super(2, e), this.depthwiseKernel = null, this.depthMultiplier = null == e.depthMultiplier ? 1 : e.depthMultiplier, this.depthwiseInitializer = zi(e.depthwiseInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.depthwiseConstraint = ba(e.depthwiseConstraint), this.depthwiseRegularizer = Ds(e.depthwiseRegularizer) } build(e) { if ((e = ji(e)).length < 4) throw new or(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`); const t = "channelsFirst" === this.dataFormat ? 1 : 3; if (null == e[t] || e[t] < 0) throw new or(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`); const n = e[t], r = [this.kernelSize[0], this.kernelSize[1], n, this.depthMultiplier]; this.depthwiseKernel = this.addWeight("depthwise_kernel", r, null, this.depthwiseInitializer, this.depthwiseRegularizer, !0, this.depthwiseConstraint), this.useBias ? this.bias = this.addWeight("bias", [n * this.depthMultiplier], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0 } call(e, t) { + return (0, P.tidy)((() => { + let t = + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function (e, t, n = [1, 1], r = "valid", i, a) { return (0, P.tidy)((() => { null == i && (i = "channelsLast"), Br(i); let o = Ws(e, i); if (4 !== e.rank) throw new or(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`); if (4 !== t.rank) throw new or(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`); return o = P.depthwiseConv2d(o, t, n, "same" === r ? "same" : "valid", "NHWC", a), "channelsFirst" === i && (o = P.transpose(o, [0, 3, 1, 2])), o })) }(e = Li(e), this.depthwiseKernel.read(), this.strides, this.padding, this.dataFormat, null); return this.useBias && (t = fi(t, this.bias.read(), this.dataFormat)), null != this.activation && (t = this.activation.apply(t)), t + })) + } computeOutputShape(e) { e = ji(e); const t = "channelsFirst" === this.dataFormat ? e[2] : e[1], n = "channelsFirst" === this.dataFormat ? e[3] : e[2], r = "channelsFirst" === this.dataFormat ? e[1] * this.depthMultiplier : e[3] * this.depthMultiplier, i = js(t, this.kernelSize[0], this.padding, this.strides[0]), a = js(n, this.kernelSize[1], this.padding, this.strides[1]); return "channelsFirst" === this.dataFormat ? [e[0], r, i, a] : [e[0], i, a, r] } getConfig() { const e = super.getConfig(); return e.depthMultiplier = this.depthMultiplier, e.depthwiseInitializer = Oi(this.depthwiseInitializer), e.depthwiseRegularizer = Ms(this.depthwiseRegularizer), e.depthwiseConstraint = ga(this.depthwiseRegularizer), e } + } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function ou(e, t, n, r) { if (Array.isArray(e)) { if (null != t || null != n) throw new or("When inputs is an array, neither initialState or constants should be provided"); null != r && (n = e.slice(e.length - r, e.length), e = e.slice(0, e.length - r)), e.length > 1 && (t = e.slice(1, e.length)), e = e[0] } function i(e) { return null == e || Array.isArray(e) ? e : [e] } return { inputs: e, initialState: t = i(t), constants: n = i(n) } } function su(e, t, n, r = !1, i, a, o = !1, s = !1) { return P.tidy((() => { const u = t.shape.length; if (u < 3) throw new or(`Input should be at least 3D, but is ${u}D.`); const l = [1, 0].concat(Zr(2, u)); if (t = P.transpose(t, l), null != a) throw new sr("The rnn() functoin of the deeplearn.js backend does not support constants yet."); o && console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."), null != i && ((i = P.cast(P.cast(i, "bool"), "float32")).rank === u - 1 && (i = P.expandDims(i, -1)), i = P.transpose(i, l)), r && (t = P.reverse(t, 0), null != i && (i = P.reverse(i, 0))); const c = []; let h, d = n; const f = t.shape[0], p = P.unstack(t); let m, g; null != i && (m = P.unstack(i)); for (let t = 0; t < f; ++t) { const n = p[t], r = P.tidy((() => e(n, d))); if (null == i) h = r[0], d = r[1]; else { const e = P.tidy((() => { const e = m[t], n = P.sub(P.onesLike(e), e); return { output: P.add(P.mul(r[0], e), P.mul(d[0], n)), newStates: d.map(((t, i) => P.add(P.mul(r[1][i], e), P.mul(t, n)))) } })); h = e.output, d = e.newStates } s && c.push(h) } if (s) { const e = 1; g = P.stack(c, e) } return [h, g, d] })) } au.className = "DepthwiseConv2D", P.serialization.registerClass(au); class uu extends Ji { constructor(e) { let t; if (super(e), null == e.cell) throw new or("cell property is missing for the constructor of RNN."); if (t = Array.isArray(e.cell) ? new gu({ cells: e.cell }) : e.cell, null == t.stateSize) throw new or("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state)."); this.cell = t, this.returnSequences = null != e.returnSequences && e.returnSequences, this.returnState = null != e.returnState && e.returnState, this.goBackwards = null != e.goBackwards && e.goBackwards, this._stateful = null != e.stateful && e.stateful, this.unroll = null != e.unroll && e.unroll, this.supportsMasking = !0, this.inputSpec = [new qi({ ndim: 3 })], this.stateSpec = null, this.states_ = null, this.numConstants = null, this.keptStates = [] } getStates() { if (null == this.states_) { return Zr(0, Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1).map((e => null)) } return this.states_ } setStates(e) { this.states_ = e } computeOutputShape(e) { Pi(e) && (e = e[0]); let t = this.cell.stateSize; Array.isArray(t) || (t = [t]); const n = t[0]; let r; if (r = this.returnSequences ? [e[0], e[1], n] : [e[0], n], this.returnState) { const n = []; for (const r of t) n.push([e[0], r]); return [r].concat(n) } return r } computeMask(e, t) { return P.tidy((() => { Array.isArray(t) && (t = t[0]); const e = this.returnSequences ? t : null; if (this.returnState) { const t = this.states.map((e => null)); return [e].concat(t) } return e })) } get states() { if (null == this.states_) { const e = Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1, t = []; for (let n = 0; n < e; ++n)t.push(null); return t } return this.states_ } set states(e) { this.states_ = e } build(e) { if (null != this.numConstants) throw new sr("Constants support is not implemented in RNN yet."); Pi(e) && (e = e[0]); const t = this.stateful ? e[0] : null, n = e.slice(2); this.inputSpec[0] = new qi({ shape: [t, null, ...n] }); const r = [e[0]].concat(e.slice(2)); let i; if (this.cell.build(r), i = Array.isArray(this.cell.stateSize) ? this.cell.stateSize : [this.cell.stateSize], null != this.stateSpec) { if (!P.util.arraysEqual(this.stateSpec.map((e => e.shape[e.shape.length - 1])), i)) throw new or(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`) } else this.stateSpec = i.map((e => new qi({ shape: [null, e] }))); this.stateful && this.resetStates() } resetStates(e, t = !1) { (0, P.tidy)((() => { if (!this.stateful) throw new ir("Cannot call resetStates() on an RNN Layer that is not stateful."); const n = this.inputSpec[0].shape[0]; if (null == n) throw new or("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer."); if (null == this.states_) Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((e => P.zeros([n, e]))) : this.states_ = [P.zeros([n, this.cell.stateSize])]; else if (null == e) P.dispose(this.states_), null != this.keptStates && (P.dispose(this.keptStates), this.keptStates = []), Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((e => P.zeros([n, e]))) : this.states_[0] = P.zeros([n, this.cell.stateSize]); else { if (Array.isArray(e) || (e = [e]), e.length !== this.states_.length) throw new or(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`); !0 === t ? this.keptStates.push(this.states_.slice()) : P.dispose(this.states_); for (let t = 0; t < this.states_.length; ++t) { const r = e[t], i = Array.isArray(this.cell.stateSize) ? this.cell.stateSize[t] : this.cell.stateSize, a = [n, i]; if (!P.util.arraysEqual(r.shape, a)) throw new or(`State ${t} is incompatible with layer ${this.name}: expected shape=${a}, received shape=${r.shape}`); this.states_[t] = r } } this.states_ = this.states_.map((e => P.keep(e.clone()))) })) } apply(e, t) { let n = null == t ? null : t.initialState, r = null == t ? null : t.constants; null == t && (t = {}); const i = ou(e, n, r, this.numConstants); e = i.inputs, n = i.initialState, r = i.constants; let a = [], o = []; if (null != n) { t.initialState = n, a = a.concat(n), this.stateSpec = []; for (const e of n) this.stateSpec.push(new qi({ shape: e.shape })); o = o.concat(this.stateSpec) } null != r && (t.constants = r, a = a.concat(r), this.numConstants = r.length); if (a[0] instanceof Yi) { const n = [e].concat(a), r = this.inputSpec.concat(o), i = this.inputSpec; this.inputSpec = r; const s = super.apply(n, t); return this.inputSpec = i, s } return super.apply(e, t) } call(e, t) { return (0, P.tidy)((() => { const n = null == t ? null : t.mask, r = null == t ? null : t.training; let i = null == t ? null : t.initialState; e = Li(e), null == i && (i = this.stateful ? this.states_ : this.getInitialState(e)); const a = Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1; if (i.length !== a) throw new or(`RNN Layer has ${a} state(s) but was passed ${i.length} initial state(s).`); this.unroll && console.warn("Ignoring unroll = true for RNN layer, due to imperative backend."); const o = { training: r }, s = su(((e, t) => { const n = this.cell.call([e].concat(t), o); return [n[0], n.slice(1)] }), e, i, this.goBackwards, n, null, this.unroll, this.returnSequences), u = s[0], l = s[1], c = s[2]; this.stateful && this.resetStates(c, r); const h = this.returnSequences ? l : u; return this.returnState ? [h].concat(c) : h })) } getInitialState(e) { return (0, P.tidy)((() => { let t = P.zeros(e.shape); return t = P.sum(t, [1, 2]), t = ti(t), Array.isArray(this.cell.stateSize) ? this.cell.stateSize.map((e => e > 1 ? si(t, [1, e]) : t)) : this.cell.stateSize > 1 ? [si(t, [1, this.cell.stateSize])] : [t] })) } get trainableWeights() { return this.trainable ? this.cell.trainableWeights : [] } get nonTrainableWeights() { return this.trainable ? this.cell.nonTrainableWeights : this.cell.weights } setFastWeightInitDuringBuild(e) { super.setFastWeightInitDuringBuild(e), null != this.cell && this.cell.setFastWeightInitDuringBuild(e) } getConfig() { const e = super.getConfig(), t = { returnSequences: this.returnSequences, returnState: this.returnState, goBackwards: this.goBackwards, stateful: this.stateful, unroll: this.unroll }; null != this.numConstants && (t.numConstants = this.numConstants); const n = this.cell.getConfig(); return this.getClassName() === uu.className && (t.cell = { className: this.cell.getClassName(), config: n }), Object.assign(Object.assign(Object.assign({}, n), e), t) } static fromConfig(e, t, n = {}) { const r = Ka(t.cell, n); return new e(Object.assign(t, { cell: r })) } } uu.className = "RNN", P.serialization.registerClass(uu); class lu extends Ji { } class cu extends lu { constructor(e) { super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Ar(this.units, "units"), this.activation = As(null == e.activation ? this.DEFAULT_ACTIVATION : e.activation), this.useBias = null == e.useBias || e.useBias, this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = zi(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = Ds(e.kernelRegularizer), this.recurrentRegularizer = Ds(e.recurrentRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.kernelConstraint = ba(e.kernelConstraint), this.recurrentConstraint = ba(e.recurrentConstraint), this.biasConstraint = ba(e.biasConstraint), this.dropout = Xr([1, Kr([0, null == e.dropout ? 0 : e.dropout])]), this.recurrentDropout = Xr([1, Kr([0, null == e.recurrentDropout ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null } build(e) { e = ji(e), this.kernel = this.addWeight("kernel", [e[e.length - 1], this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0 } call(e, t) { return (0, P.tidy)((() => { if (2 !== e.length) throw new or(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`); let n = e[1]; e = e[0]; const r = null != t.training && t.training; let i; 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(e), rate: this.dropout, training: r, dropoutFunc: this.dropoutFunc })), 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(n), rate: this.recurrentDropout, training: r, dropoutFunc: this.dropoutFunc })); const a = this.dropoutMask, o = this.recurrentDropoutMask; i = li(null != a ? P.mul(e, a) : e, this.kernel.read()), null != this.bias && (i = fi(i, this.bias.read())), null != o && (n = P.mul(n, o)); let s = P.add(i, li(n, this.recurrentKernel.read())); return null != this.activation && (s = this.activation.apply(s)), [s, s] })) } getConfig() { const e = super.getConfig(), t = { units: this.units, activation: _s(this.activation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), recurrentInitializer: Oi(this.recurrentInitializer), biasInitializer: Oi(this.biasInitializer), kernelRegularizer: Ms(this.kernelRegularizer), recurrentRegularizer: Ms(this.recurrentRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), recurrentConstraint: ga(this.recurrentConstraint), biasConstraint: ga(this.biasConstraint), dropout: this.dropout, recurrentDropout: this.recurrentDropout }; return Object.assign(Object.assign({}, e), t) } } cu.className = "SimpleRNNCell", P.serialization.registerClass(cu); class hu extends uu { constructor(e) { e.cell = new cu(e), super(e) } call(e, t) { return (0, P.tidy)((() => { null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } static fromConfig(e, t) { return new e(t) } } hu.className = "SimpleRNN", P.serialization.registerClass(hu); class du extends lu { constructor(e) { if (super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", e.resetAfter) throw new or("GRUCell does not support reset_after parameter set to true."); this.units = e.units, Ar(this.units, "units"), this.activation = As(void 0 === e.activation ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = As(void 0 === e.recurrentActivation ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = null == e.useBias || e.useBias, this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = zi(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = Ds(e.kernelRegularizer), this.recurrentRegularizer = Ds(e.recurrentRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.kernelConstraint = ba(e.kernelConstraint), this.recurrentConstraint = ba(e.recurrentConstraint), this.biasConstraint = ba(e.biasConstraint), this.dropout = Xr([1, Kr([0, null == e.dropout ? 0 : e.dropout])]), this.recurrentDropout = Xr([1, Kr([0, null == e.recurrentDropout ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null } build(e) { const t = (e = ji(e))[e.length - 1]; this.kernel = this.addWeight("kernel", [t, 3 * this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, 3 * this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [3 * this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0 } call(e, t) { return (0, P.tidy)((() => { if (2 !== e.length) throw new or(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`); const n = null != t.training && t.training; let r = e[1]; e = e[0], 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(e), rate: this.dropout, training: n, count: 3, dropoutFunc: this.dropoutFunc })), 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(r), rate: this.recurrentDropout, training: n, count: 3, dropoutFunc: this.dropoutFunc })); const i = this.dropoutMask, a = this.recurrentDropoutMask; let o, s, u; 0 < this.dropout && this.dropout < 1 && (e = P.mul(e, i[0])); let l = li(e, this.kernel.read()); this.useBias && (l = fi(l, this.bias.read())), 0 < this.recurrentDropout && this.recurrentDropout < 1 && (r = P.mul(r, a[0])); const c = this.recurrentKernel.read(), [h, d] = P.split(c, [2 * this.units, this.units], c.rank - 1), f = li(r, h), [p, m, g] = P.split(l, 3, l.rank - 1), [y, b] = P.split(f, 2, f.rank - 1); o = this.recurrentActivation.apply(P.add(p, y)), s = this.recurrentActivation.apply(P.add(m, b)); const v = li(P.mul(s, r), d); u = this.activation.apply(P.add(g, v)); const x = P.add(P.mul(o, r), P.mul(P.add(1, P.neg(o)), u)); return [x, x] })) } getConfig() { const e = super.getConfig(), t = { units: this.units, activation: _s(this.activation), recurrentActivation: _s(this.recurrentActivation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), recurrentInitializer: Oi(this.recurrentInitializer), biasInitializer: Oi(this.biasInitializer), kernelRegularizer: Ms(this.kernelRegularizer), recurrentRegularizer: Ms(this.recurrentRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), recurrentConstraint: ga(this.recurrentConstraint), biasConstraint: ga(this.biasConstraint), dropout: this.dropout, recurrentDropout: this.recurrentDropout, implementation: this.implementation, resetAfter: !1 }; return Object.assign(Object.assign({}, e), t) } } du.className = "GRUCell", P.serialization.registerClass(du); class fu extends uu { constructor(e) { 0 === e.implementation && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new du(e), super(e) } call(e, t) { return (0, P.tidy)((() => { null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } static fromConfig(e, t) { return 0 === t.implmentation && (t.implementation = 1), new e(t) } } fu.className = "GRU", P.serialization.registerClass(fu); class pu extends lu { constructor(e) { super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Ar(this.units, "units"), this.activation = As(void 0 === e.activation ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = As(void 0 === e.recurrentActivation ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = null == e.useBias || e.useBias, this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = zi(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.unitForgetBias = e.unitForgetBias, this.kernelRegularizer = Ds(e.kernelRegularizer), this.recurrentRegularizer = Ds(e.recurrentRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.kernelConstraint = ba(e.kernelConstraint), this.recurrentConstraint = ba(e.recurrentConstraint), this.biasConstraint = ba(e.biasConstraint), this.dropout = Xr([1, Kr([0, null == e.dropout ? 0 : e.dropout])]), this.recurrentDropout = Xr([1, Kr([0, null == e.recurrentDropout ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = [this.units, this.units], this.dropoutMask = null, this.recurrentDropoutMask = null } build(e) { var t; const n = (e = ji(e))[e.length - 1]; let r; if (this.kernel = this.addWeight("kernel", [n, 4 * this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, 4 * this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias) { if (this.unitForgetBias) { const e = this.biasInitializer, n = this.units; r = new ((t = class extends bi { apply(t, r) { const i = e.apply([n]), a = (new xi).apply([n]), o = e.apply([2 * n]); return oi(oi(i, a), o) } }).className = "CustomInit", t) } else r = this.biasInitializer; this.bias = this.addWeight("bias", [4 * this.units], null, r, this.biasRegularizer, !0, this.biasConstraint) } else this.bias = null; this.built = !0 } call(e, t) { return (0, P.tidy)((() => { const n = null != t.training && t.training; if (3 !== e.length) throw new or(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`); let r = e[1]; const i = e[2]; e = e[0], 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(e), rate: this.dropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })), 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(r), rate: this.recurrentDropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })); const a = this.dropoutMask, o = this.recurrentDropoutMask; let s, u, l, c; 0 < this.dropout && this.dropout < 1 && (e = P.mul(e, a[0])); let h = li(e, this.kernel.read()); 0 < this.recurrentDropout && this.recurrentDropout < 1 && (r = P.mul(r, o[0])), h = P.add(h, li(r, this.recurrentKernel.read())), this.useBias && (h = fi(h, this.bias.read())); const [d, f, p, m] = P.split(h, 4, h.rank - 1); s = this.recurrentActivation.apply(d), u = this.recurrentActivation.apply(f), l = P.add(P.mul(u, i), P.mul(s, this.activation.apply(p))), c = this.recurrentActivation.apply(m); const g = P.mul(c, this.activation.apply(l)); return [g, g, l] })) } getConfig() { const e = super.getConfig(), t = { units: this.units, activation: _s(this.activation), recurrentActivation: _s(this.recurrentActivation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), recurrentInitializer: Oi(this.recurrentInitializer), biasInitializer: Oi(this.biasInitializer), unitForgetBias: this.unitForgetBias, kernelRegularizer: Ms(this.kernelRegularizer), recurrentRegularizer: Ms(this.recurrentRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), recurrentConstraint: ga(this.recurrentConstraint), biasConstraint: ga(this.biasConstraint), dropout: this.dropout, recurrentDropout: this.recurrentDropout, implementation: this.implementation }; return Object.assign(Object.assign({}, e), t) } } pu.className = "LSTMCell", P.serialization.registerClass(pu); class mu extends uu { constructor(e) { 0 === e.implementation && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new pu(e), super(e) } call(e, t) { return (0, P.tidy)((() => { null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } static fromConfig(e, t) { return 0 === t.implmentation && (t.implementation = 1), new e(t) } } mu.className = "LSTM", P.serialization.registerClass(mu); class gu extends lu { constructor(e) { super(e), this.cells = e.cells } get stateSize() { const e = []; for (const t of this.cells.slice().reverse()) Array.isArray(t.stateSize) ? e.push(...t.stateSize) : e.push(t.stateSize); return e } call(e, t) { return (0, P.tidy)((() => { let n = e.slice(1); const r = []; for (const e of this.cells.slice().reverse()) Array.isArray(e.stateSize) ? r.push(n.splice(0, e.stateSize.length)) : r.push(n.splice(0, 1)); r.reverse(); const i = []; let a; for (let o = 0; o < this.cells.length; ++o) { const s = this.cells[o]; n = r[o], a = 0 === o ? [e[0]].concat(n) : [a[0]].concat(n), a = s.call(a, t), i.push(a.slice(1)) } n = []; for (const e of i.slice().reverse()) n.push(...e); return [a[0]].concat(n) })) } build(e) { let t; Pi(e) && (e = e[0]), this.cells.forEach(((n, r) => { Wr(`RNNCell_${r}`, (() => { n.build(e), t = Array.isArray(n.stateSize) ? n.stateSize[0] : n.stateSize, e = [e[0], t] })) })), this.built = !0 } getConfig() { const e = super.getConfig(), t = { cells: this.cells.map((e => ({ className: e.getClassName(), config: e.getConfig() }))) }; return Object.assign(Object.assign({}, e), t) } static fromConfig(e, t, n = {}) { const r = []; for (const e of t.cells) r.push(Ka(e, n)); return new e({ cells: r }) } get trainableWeights() { if (!this.trainable) return []; const e = []; for (const t of this.cells) e.push(...t.trainableWeights); return e } get nonTrainableWeights() { const e = []; for (const t of this.cells) e.push(...t.nonTrainableWeights); if (!this.trainable) { const t = []; for (const e of this.cells) t.push(...e.trainableWeights); return t.concat(e) } return e } getWeights() { const e = []; for (const t of this.cells) e.push(...t.weights); return Gi(e) } setWeights(e) { const t = []; for (const n of this.cells) { const r = n.weights.length, i = e.splice(r); for (let e = 0; e < n.weights.length; ++e)t.push([n.weights[e], i[e]]) } Hi(t) } } function yu(e) { const { ones: t, rate: n, training: r = !1, count: i = 1, dropoutFunc: a } = e, o = () => null != a ? a(t(), n) : pi(t(), n), s = () => mi(o, t, r); if (!i || i <= 1) return P.keep(s().clone()); return Array(i).fill(void 0).map(s).map((e => P.keep(e.clone()))) } gu.className = "StackedRNNCells", P.serialization.registerClass(gu); + /** + * @license + * Copyright 2020 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + var bu = function (e, t) { var n = {}; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (null != e && "function" == typeof Object.getOwnPropertySymbols) { var i = 0; for (r = Object.getOwnPropertySymbols(e); i < r.length; i++)t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]) } return n }; class vu extends uu { constructor(e) { if (e.unroll) throw new sr("Unrolling is not possible with convolutional RNNs."); if (Array.isArray(e.cell)) throw new sr("It is not possible at the moment to stack convolutional cells."); super(e), this.inputSpec = [new qi({ ndim: 5 })] } call(e, t) { return P.tidy((() => { if (null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null), t && t.constants) throw new or("ConvRNN2D cell does not support constants"); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } computeOutputShape(e) { let t = this.computeSingleOutputShape(e); return this.returnSequences || (t = [t[0], ...t.slice(2)]), this.returnState && (t = [t, ...Array(2).fill([e[0], ...t.slice(-3)])]), t } getInitialState(e) { return P.tidy((() => { const { stateSize: t } = this.cell, n = e.shape, r = this.computeSingleOutputShape(n), i = [r[0], ...r.slice(2)], a = P.zeros(i); return Array.isArray(t) ? Array(t.length).fill(a) : [a] })) } resetStates(e, t = !1) { P.tidy((() => { if (!this.stateful) throw new ir("Cannot call resetStates() on an RNN Layer that is not stateful."); const n = this.inputSpec[0].shape, r = this.computeSingleOutputShape(n), i = [r[0], ...r.slice(2)]; if (null == n[0]) throw new or("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer."); if (null == this.getStates()) Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((() => P.zeros(i))) : this.states_ = [P.zeros(i)]; else if (null == e) P.dispose(this.states_), null != this.keptStates && (P.dispose(this.keptStates), this.keptStates = []), Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((() => P.zeros(i))) : this.states_[0] = P.zeros(i); else { if (Array.isArray(e) || (e = [e]), e.length !== this.states_.length) throw new or(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`); t ? this.keptStates.push(this.states_.slice()) : P.dispose(this.states_); for (let t = 0; t < this.states_.length; ++t) { const n = e[t], r = i; if (!P.util.arraysEqual(n.shape, r)) throw new or(`State ${t} is incompatible with layer ${this.name}: expected shape=${r}, received shape=${n.shape}`); this.states_[t] = n } } this.states_ = this.states_.map((e => P.keep(e.clone()))) })) } computeSingleOutputShape(e) { const { dataFormat: t, filters: n, kernelSize: r, padding: i, strides: a, dilationRate: o } = this.cell, s = "channelsFirst" === t, u = e[s ? 3 : 2], l = e[s ? 4 : 3], c = js(u, r[0], i, a[0], o[0]), h = js(l, r[1], i, a[1], o[1]); return [...e.slice(0, 2), ...s ? [n, c, h] : [c, h, n]] } } vu.className = "ConvRNN2D"; class xu extends pu { constructor(e) { const { filters: t, kernelSize: n, strides: r, padding: i, dataFormat: a, dilationRate: o } = e; super(Object.assign(Object.assign({}, e), { units: t })), this.filters = t, Ar(this.filters, "filters"), this.kernelSize = Ls(n, 2, "kernelSize"), this.kernelSize.forEach((e => Ar(e, "kernelSize"))), this.strides = Ls(r || 1, 2, "strides"), this.strides.forEach((e => Ar(e, "strides"))), this.padding = i || "valid", Lr(this.padding), this.dataFormat = a || "channelsLast", Br(this.dataFormat), this.dilationRate = Ls(o || 1, 2, "dilationRate"), this.dilationRate.forEach((e => Ar(e, "dilationRate"))) } build(e) { var t; e = ji(e); const n = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[n]) throw new or(`The channel dimension of the input should be defined. Found ${e[n]}`); const r = e[n], i = this.kernelSize.concat([r, 4 * this.filters]); this.kernel = this.addWeight("kernel", i, null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint); const a = this.kernelSize.concat([this.filters, 4 * this.filters]); if (this.recurrentKernel = this.addWeight("recurrent_kernel", a, null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias) { let e; if (this.unitForgetBias) { const n = this.biasInitializer, r = this.filters; e = new ((t = class extends bi { apply(e, t) { return ai([n.apply([r]), P.ones([r]), n.apply([2 * r])]) } }).className = "CustomInit", t) } else e = this.biasInitializer; this.bias = this.addWeight("bias", [4 * this.filters], null, e, this.biasRegularizer, !0, this.biasConstraint) } this.built = !0 } call(e, t) { return P.tidy((() => { if (3 !== e.length) throw new or(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`); const n = t.training || !1, r = e[0], i = e[1], a = e[2]; 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(r), rate: this.dropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })); const o = this.dropoutMask, s = (e, t, n) => t && t[n] ? P.mul(t[n], e) : e; let u = s(r, o, 0), l = s(r, o, 1), c = s(r, o, 2), h = s(r, o, 3); 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(i), rate: this.recurrentDropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })); const d = this.recurrentDropoutMask; let f = s(i, d, 0), p = s(i, d, 1), m = s(i, d, 2), g = s(i, d, 3); const [y, b, v, x] = P.split(this.kernel.read(), 4, 3), [w, k, S, _] = this.useBias ? P.split(this.bias.read(), 4) : [null, null, null, null]; u = this.inputConv(u, y, w, this.padding), l = this.inputConv(l, b, k, this.padding), c = this.inputConv(c, v, S, this.padding), h = this.inputConv(h, x, _, this.padding); const [C, A, T, E] = P.split(this.recurrentKernel.read(), 4, 3); f = this.recurrentConv(f, C), p = this.recurrentConv(p, A), m = this.recurrentConv(m, T), g = this.recurrentConv(g, E); const N = this.recurrentActivation.apply(P.add(u, f)), I = this.recurrentActivation.apply(P.add(l, p)), M = P.add(P.mul(I, a), P.mul(N, this.activation.apply(P.add(c, m)))), F = P.mul(this.recurrentActivation.apply(P.add(h, g)), this.activation.apply(M)); return [F, F, M] })) } getConfig() { const e = super.getConfig(), { units: t } = e, n = bu(e, ["units"]), r = { filters: this.filters, kernelSize: this.kernelSize, padding: this.padding, dataFormat: this.dataFormat, dilationRate: this.dilationRate, strides: this.strides }; return Object.assign(Object.assign({}, n), r) } inputConv(e, t, n, r) { const i = P.conv2d(e, t, this.strides, r || "valid", "channelsFirst" === this.dataFormat ? "NCHW" : "NHWC", this.dilationRate); return n ? fi(i, n, this.dataFormat) : i } recurrentConv(e, t) { return P.conv2d(e, t, 1, "same", "channelsFirst" === this.dataFormat ? "NCHW" : "NHWC") } } xu.className = "ConvLSTM2DCell", P.serialization.registerClass(xu); class wu extends vu { constructor(e) { const t = new xu(e); super(Object.assign(Object.assign({}, e), { cell: t })) } static fromConfig(e, t) { return new e(t) } } wu.className = "ConvLSTM2D", P.serialization.registerClass(wu); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class ku extends Ji { constructor(e) { super(e), this.rate = Math.max(Math.min(e.rate, 1), 0), this.noiseShape = e.noiseShape, this.seed = e.seed, this.supportsMasking = !0 } getNoiseShape(e) { if (null == this.noiseShape) return this.noiseShape; const t = e.shape, n = []; for (let e = 0; e < this.noiseShape.length; ++e)n.push(null == this.noiseShape[e] ? t[e] : this.noiseShape[e]); return n } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); if (0 < this.rate && this.rate < 1) { const e = null != t.training && t.training, r = this.getNoiseShape(n); return mi((() => pi(n, this.rate, r, this.seed)), (() => n), e) } return e })) } getConfig() { const e = { rate: this.rate, noiseShape: this.noiseShape, seed: this.seed }, t = super.getConfig(); return Object.assign(e, t), e } dispose() { return super.dispose() } } ku.className = "Dropout", P.serialization.registerClass(ku); class Su extends ku { constructor(e) { super(e), this.inputSpec = [{ ndim: 3 }] } getNoiseShape(e) { const t = e.shape; return [t[0], 1, t[2]] } } Su.className = "SpatialDropout1D", P.serialization.registerClass(Su); class _u extends Ji { constructor(e) { if (super(e), this.activation = null, this.useBias = !0, this.kernel = null, this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", null == e.batchInputShape && null == e.inputShape && null != e.inputDim) { let t = null; null != e.batchSize && (t = e.batchSize), this.batchInputShape = [t, e.inputDim] } this.units = e.units, Ar(this.units, "units"), this.activation = As(e.activation), null != e.useBias && (this.useBias = e.useBias), this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelConstraint = ba(e.kernelConstraint), this.biasConstraint = ba(e.biasConstraint), this.kernelRegularizer = Ds(e.kernelRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.activityRegularizer = Ds(e.activityRegularizer), this.supportsMasking = !0, this.inputSpec = [{ minNDim: 2 }] } build(e) { const t = (e = ji(e))[e.length - 1]; null == this.kernel && (this.kernel = this.addWeight("kernel", [t, this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint))), this.inputSpec = [{ minNDim: 2, axes: { [-1]: t } }], this.built = !0 } computeOutputShape(e) { const t = (e = ji(e)).slice(); return t[t.length - 1] = this.units, t } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e), r = Er(this.activation.getClassName()); let i; return null != r ? i = li(n, this.kernel.read(), r, this.bias ? this.bias.read() : null) : (i = li(n, this.kernel.read()), null != this.bias && (i = fi(i, this.bias.read())), null != this.activation && (i = this.activation.apply(i))), i })) } getConfig() { const e = { units: this.units, activation: _s(this.activation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), biasInitializer: Oi(this.biasInitializer), kernelRegularizer: Ms(this.kernelRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), biasConstraint: ga(this.biasConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } } _u.className = "Dense", P.serialization.registerClass(_u); class Cu extends Ji { constructor(e) { super(e = e || {}), this.inputSpec = [{ minNDim: 3 }], this.dataFormat = e.dataFormat } computeOutputShape(e) { e = ji(e); for (const t of e.slice(1)) if (null == t) throw new or(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`); return [e[0], Yr(e, 1)] } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); let n = Li(e); if ("channelsFirst" === this.dataFormat && n.rank > 1) { const e = [0]; for (let t = 2; t < n.rank; ++t)e.push(t); e.push(1), n = (0, P.transpose)(n, e) } return function (e) { if (e.rank <= 1) throw new or(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`); const t = [e.shape[0], Yr(e.shape, 1)]; return P.reshape(e, t) }(n) })) } getConfig() { const e = {}; null != this.dataFormat && (e.dataFormat = this.dataFormat); const t = super.getConfig(); return Object.assign(e, t), e } } Cu.className = "Flatten", P.serialization.registerClass(Cu); class Au extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.activation = As(e.activation) } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); return this.activation.apply(n) })) } getConfig() { const e = { activation: _s(this.activation) }, t = super.getConfig(); return Object.assign(e, t), e } } Au.className = "Activation", P.serialization.registerClass(Au); class Tu extends Ji { constructor(e) { super(e), this.n = e.n, this.inputSpec = [{ ndim: 2 }] } computeOutputShape(e) { return [e[0], this.n, e[1]] } call(e, t) { return (0, P.tidy)((() => function (e, t) { return (0, P.tidy)((() => { if (2 !== e.shape.length) throw new or(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`); return si(ti(e, 1), [1, t, 1]) })) }(e = Li(e), this.n))) } getConfig() { const e = { n: this.n }, t = super.getConfig(); return Object.assign(e, t), e } } Tu.className = "RepeatVector", P.serialization.registerClass(Tu); class Eu extends Ji { constructor(e) { super(e), this.targetShape = e.targetShape; for (let e = 0; e < this.targetShape.length; ++e)this.isUnknown(this.targetShape[e]) && (this.targetShape[e] = null) } isUnknown(e) { return e < 0 || null == e } fixUnknownDimension(e, t) { const n = "Total size of new array must be unchanged.", r = t.slice(); let i = 1, a = null; for (let e = 0; e < r.length; ++e) { const t = r[e]; if (this.isUnknown(t)) { if (null !== a) throw new or("Can only specifiy one unknown dimension."); a = e } else i *= t } const o = Yr(e); if (null !== a) { if (0 === i || o % i != 0) throw new or(n); r[a] = o / i } else if (o !== i) throw new or(n); return r } computeOutputShape(e) { let t = !1; for (let n = 0; n < e.length; ++n)if (this.isUnknown(e[n])) { t = !0; break } return t ? e.slice(0, 1).concat(this.targetShape) : e.slice(0, 1).concat(this.fixUnknownDimension(e.slice(1), this.targetShape)) } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e), r = n.shape, i = r.slice(0, 1).concat(this.fixUnknownDimension(r.slice(1), this.targetShape)); return (0, P.reshape)(n, i) })) } getConfig() { const e = { targetShape: this.targetShape }, t = super.getConfig(); return Object.assign(e, t), e } } Eu.className = "Reshape", P.serialization.registerClass(Eu); class Nu extends Ji { constructor(e) { if (super(e), null == e.dims) throw new Error("Required configuration field `dims` is missing during Permute constructor call."); if (!Array.isArray(e.dims)) throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`); const t = Zr(1, e.dims.length + 1); if (!P.util.arraysEqual(e.dims.slice().sort(), t)) throw new Error("Invalid permutation `dims`: " + JSON.stringify(e.dims) + " `dims` must contain consecutive integers starting from 1."); this.dims = e.dims, this.dimsIncludingBatch = [0].concat(this.dims), this.inputSpec = [new qi({ ndim: this.dims.length + 1 })] } computeOutputShape(e) { const t = (e = ji(e)).slice(); return this.dims.forEach(((n, r) => { t[r + 1] = e[n] })), t } call(e, t) { return (0, P.transpose)(Li(e), this.dimsIncludingBatch) } getConfig() { const e = { dims: this.dims }, t = super.getConfig(); return Object.assign(e, t), e } } Nu.className = "Permute", P.serialization.registerClass(Nu); class Iu extends Ji { constructor(e) { super(null == e ? {} : e), this.supportsMasking = !0, this.maskValue = null != e ? null == e.maskValue ? 0 : e.maskValue : 0 } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { maskValue: this.maskValue }; return Object.assign(t, e), t } computeMask(e, t) { const n = Li(e); return (0, P.any)((0, P.notEqual)(n, this.maskValue), -1) } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e), r = (0, P.any)((0, P.notEqual)(n, this.maskValue), -1, !0); return (0, P.mul)(n, (0, P.cast)(r, n.dtype)) })) } } Iu.className = "Masking", P.serialization.registerClass(Iu); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class Mu extends Ji { constructor(e) { if (super(e), this.embeddings = null, this.DEFAULT_EMBEDDINGS_INITIALIZER = "randomUniform", null == e.batchInputShape && null == e.inputShape) { let t = null; null != e.batchSize && (t = e.batchSize), null == e.inputLength ? this.batchInputShape = [t, null] : this.batchInputShape = [t].concat(pr(e.inputLength)) } this.inputDim = e.inputDim, Ar(this.inputDim, "inputDim"), this.outputDim = e.outputDim, Ar(this.outputDim, "outputDim"), this.embeddingsInitializer = zi(e.embeddingsInitializer || this.DEFAULT_EMBEDDINGS_INITIALIZER), this.embeddingsRegularizer = Ds(e.embeddingsRegularizer), this.activityRegularizer = Ds(e.activityRegularizer), this.embeddingsConstraint = ba(e.embeddingsConstraint), this.maskZero = e.maskZero, this.supportsMasking = e.maskZero, this.inputLength = e.inputLength } build(e) { this.embeddings = this.addWeight("embeddings", [this.inputDim, this.outputDim], this.dtype, this.embeddingsInitializer, this.embeddingsRegularizer, !0, this.embeddingsConstraint), this.built = !0 } warnOnIncompatibleInputShape(e) { } computeMask(e, t) { return (0, P.tidy)((() => this.maskZero ? (e = Li(e), (0, P.notEqual)(e, (0, P.zerosLike)(e))) : null)) } computeOutputShape(e) { if (e = ji(e), null == this.inputLength) return [...e, this.outputDim]; const t = pr(this.inputLength); if (t.length !== e.length - 1) throw new or(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`); { let n = 0; for (let r = 0; r < t.length; ++r) { const i = t[r], a = e[r + 1]; if (null != i && null != a && i !== a) throw new or(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`); null == i && (t[n] = a), n++ } } return [e[0], ...t, this.outputDim] } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); let n = Li(e); "int32" !== n.dtype && (n = ei(n, "int32")); const r = ci(this.embeddings.read(), (0, P.reshape)(n, [n.size])); return (0, P.reshape)(r, ji(this.computeOutputShape(n.shape))) })) } getConfig() { const e = { inputDim: this.inputDim, outputDim: this.outputDim, embeddingsInitializer: Oi(this.embeddingsInitializer), embeddingsRegularizer: Ms(this.embeddingsRegularizer), activityRegularizer: Ms(this.activityRegularizer), embeddingsConstraint: ga(this.embeddingsConstraint), maskZero: this.maskZero, inputLength: this.inputLength }, t = super.getConfig(); return Object.assign(e, t), e } } Mu.className = "Embedding", P.serialization.registerClass(Mu); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class Fu extends Ji { constructor(e) { super(e || {}), this.supportsMasking = !0 } mergeFunction(e) { throw new sr } computeElementwiseOpOutputShape(e, t) { if (null == e || null == t) return null; if (e.length < t.length) return this.computeElementwiseOpOutputShape(t, e); if (0 === t.length) return e; const n = e.slice(0, e.length - t.length); for (let r = 0; r < t.length; ++r) { const i = e[e.length - t.length + r], a = t[r]; if (null == i || null == a || i < 0 || a < 0) n.push(null); else if (1 === i) n.push(a); else if (1 === a) n.push(i); else { if (i !== a) throw new or("Operands could not be broadcast together with shapes " + JSON.stringify(e) + " " + JSON.stringify(t)); n.push(i) } } return n } build(e) { if (Array.isArray(e) && !Array.isArray(e[0]) && (e = [ji(e)]), e.length < 2) throw new or(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`); let t = []; for (const n of e) null != n && null !== n[0] && t.push(n[0]); if (t = kr(t), t.length > 1) throw new or(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`); let n = null == e[0] ? null : e[0].slice(1); for (let t = 1; t < e.length; ++t) { const r = null == e[t] ? null : e[t].slice(1); n = this.computeElementwiseOpOutputShape(n, r) } const r = e.map((e => e.length)); -1 === e.indexOf(null) && 1 === kr(r).length ? this.reshapeRequired = !1 : this.reshapeRequired = !0 } call(e, t) { return (0, P.tidy)((() => { if (this.reshapeRequired) { const t = [], n = e.map((e => e.rank)); if (-1 === n.indexOf(null)) { const r = Kr(n); for (let n of e) { const e = n.rank; for (let t = 0; t < r - e; ++t)n = ti(n, 1); t.push(n) } return this.mergeFunction(t) } { let n = !1; for (const r of e) { const e = r.rank; if (null == e) { const e = r.shape, i = e[0], a = e.slice(1).concat([i]); let o = P.reshape(r, [i].concat(Yr(e.slice(1)))); o = P.transpose(o, [1, 0]), o = P.reshape(o, a), t.push(o), n = !0 } else if (e > 1) { const i = Zr(1, e).concat([0]); t.push(P.transpose(r, i)), n = !0 } else t.push(r) } let r = this.mergeFunction(t); const i = r.rank; if (n) if (null == i) { const e = r.shape, t = e[e.length - 1], n = [t].concat(e.slice(0, e.length - 1)); r = P.reshape(P.transpose(P.reshape(r, [-1, t]), [1, 0]), n) } else if (i > 1) { const e = [i - 1].concat(Zr(0, i - 1)); r = P.transpose(r, e) } return r } } return this.mergeFunction(e) })) } computeOutputShape(e) { let t; t = null == e[0] ? null : e[0].slice(1); for (let n = 1; n < e.length; ++n) { const r = null == e[n] ? null : e[n].slice(1); t = this.computeElementwiseOpOutputShape(t, r) } let n = []; for (const t of e) null != t && null !== t[0] && n.push(t[0]); return n = kr(n), t = 1 === n.length ? n.concat(t) : [null].concat(t), t } computeMask(e, t) { return P.tidy((() => { if (null == t) return null; if (!Array.isArray(t)) throw new or("`mask` should be an Array"); if (!Array.isArray(e)) throw new or("`inputs` should be an Array"); if (t.length !== e.length) throw new or(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`); if (t.every((e => null == e))) return null; let n = (t = t.map((e => null == e ? e : P.expandDims(e, 0))))[0]; for (let e = 1; e < t.length - 1; ++e)n = P.logicalAnd(n, t[e]); return n })) } } class Du extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0].clone(); for (let n = 1; n < e.length; ++n)t = P.add(t, e[n]); return t })) } } Du.className = "Add", P.serialization.registerClass(Du); class $u extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0].clone(); for (let n = 1; n < e.length; ++n)t = P.mul(t, e[n]); return t })) } } $u.className = "Multiply", P.serialization.registerClass($u); class Ru extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0].clone(); for (let n = 1; n < e.length; ++n)t = P.add(t, e[n]); return P.mul(1 / e.length, t) })) } } Ru.className = "Average", P.serialization.registerClass(Ru); class Ou extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0]; for (let n = 1; n < e.length; ++n)t = P.maximum(t, e[n]); return t })) } } Ou.className = "Maximum", P.serialization.registerClass(Ou); class zu extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0]; for (let n = 1; n < e.length; ++n)t = P.minimum(t, e[n]); return t })) } } zu.className = "Minimum", P.serialization.registerClass(zu); class Pu extends Fu { constructor(e) { super(e), this.DEFAULT_AXIS = -1, null == e && (e = {}), this.axis = null == e.axis ? this.DEFAULT_AXIS : e.axis, this.supportsMasking = !0, this.reshapeRequired = !1 } build(e) { if (!Array.isArray(e) || !Array.isArray(e[0]) || 1 === e.length) throw new or("A `Concatenate` layer should be called on a list of at least 2 inputs"); let t = !0; for (const n of e) if (null != n) { t = !1; break } if (t) return; const n = []; for (let t = 0; t < e.length; ++t) { const r = e[t].slice(); r.splice(this.axis, 1); let i = !1; for (const e of n) if (P.util.arraysEqual(e, r)) { i = !0; break } i || n.push(r) } if (n.length > 1) throw new or("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: " + JSON.stringify(e)) } mergeFunction(e) { return (0, P.tidy)((() => ai(e, this.axis))) } computeOutputShape(e) { if (!Array.isArray(e) || !Array.isArray(e[0])) throw new or("A `Concatenate` layer should be called on a list of inputs."); const t = e, n = t[0].slice(), r = this.axis < 0 ? n.length + this.axis : this.axis; for (const e of t.slice(1)) { if (null == n[r] || null == e[r]) { n[r] = null; break } n[r] += e[r] } return n } computeMask(e, t) { if (null == t) return null; if (!Array.isArray(t)) throw new or("`mask` should be an array for Concatenate"); if (!Array.isArray(e)) throw new or("`inputs` should be an array for Concatenate"); if (t.length !== e.length) throw new or(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`); return P.tidy((() => { let n = !0; if (t.forEach((e => { null == e || (n = !1) })), n) return null; const r = []; for (let n = 0; n < e.length; ++n)null == t[n] ? r.push(P.cast(P.onesLike(e[n]), "bool")) : t[n].rank < e[n].rank ? r.push(P.expandDims(t[n], -1)) : r.push(t[n]); const i = P.concat(r, this.axis); return P.all(i, -1, !1) })) } getConfig() { const e = { axis: this.axis }, t = super.getConfig(); return Object.assign(e, t), e } } function Bu(e, t) { for (; e < 0;)e += t; return e } Pu.className = "Concatenate", P.serialization.registerClass(Pu); class Lu extends Fu { constructor(e) { super(e), this.axes = e.axes, this.normalize = null != e.normalize && e.normalize, this.supportsMasking = !0, this.reshapeRequired = !1 } build(e) { P.util.assert(Array.isArray(e) && 2 === e.length && Array.isArray(e[0]) && Array.isArray(e[1]), (() => "A `Dot` layer should be called on a list of exactly 2 inputs.")); const t = e[0], n = e[1]; if (t.length > 3 || n.length > 3) throw new sr("Dot layer does not support tensors of 4D or higher rank yet."); const r = this.interpretAxes(t, n); if (t[r[0]] !== n[r[1]]) throw new or(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`) } mergeFunction(e) { if (2 !== e.length) throw new or(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`); let t, n = e[0], r = e[1]; return t = Array.isArray(this.axes) ? this.axes.map(((t, n) => Bu(t, e[n].shape.length))) : [Bu(this.axes, n.shape.length), Bu(this.axes, r.shape.length)], this.normalize && (n = Za(n, t[0]), r = Za(r, t[1])), function (e, t, n) { if (e.shape.length > 3 || t.shape.length > 3) throw new sr("batchDot is not implemented for tensors of 4D or higher rank yet"); if (P.util.assert(e.shape.length >= 2, (() => `batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)), P.util.assert(e.shape.length >= 2, (() => `batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)), "number" == typeof n && (n = [n, n]), "complex64" === e.dtype || "complex64" === t.dtype) throw new sr("batchDot is not implemented for complex64-type Tensors yet."); const r = e.shape.length, i = t.shape.length; null == n && (n = [r - 1, i - 2]); const a = n; return P.tidy((() => { let n, o; if (r > i) { n = r - i; const e = []; for (let t = 0; t < n; ++t)e.push(1); t = P.reshape(t, t.shape.concat(e)) } else if (i > r) { n = i - r; const t = []; for (let e = 0; e < n; ++e)t.push(1); e = P.reshape(e, e.shape.concat(t)) } else n = 0; if (2 === e.shape.length && 2 === t.shape.length) o = a[0] === a[1] ? P.sum(P.mul(e, t), a[0]) : P.sum(P.mul(P.transpose(e, [1, 0]), t), a[1]); else { const n = a[0] !== e.shape.length - 1, r = a[1] === t.shape.length - 1; o = P.matMul(e, t, n, r) } if (n > 0) { let e; e = r > i ? r + i - 3 : r - 1; const t = []; for (let r = e; r < e + n; ++r)t.push(r); o = P.squeeze(o, t) } return 1 === o.shape.length && (o = P.expandDims(o, 1)), o })) }(n, r, t) } interpretAxes(e, t) { let n; return n = Array.isArray(this.axes) ? this.axes : [Bu(this.axes, e.length), Bu(this.axes, t.length)], n } computeOutputShape(e) { P.util.assert(Array.isArray(e) && 2 === e.length && Array.isArray(e[0]) && Array.isArray(e[1]), (() => "A `Dot` layer should be called on a list of exactly 2 inputs.")); const t = e[0].slice(), n = e[1].slice(); if (t.length > 3 || n.length > 3) throw new sr("Dot layer does not support tensors of 4D or higher rank yet."); const r = this.interpretAxes(t, n); t.splice(r[0], 1), n.splice(r[1], 1), n.splice(0, 1); const i = t.concat(n); return 1 === i.length && i.push(1), i } computeMask(e, t) { return null } getConfig() { const e = { axes: this.axes, normalize: this.normalize }, t = super.getConfig(); return Object.assign(e, t), e } } Lu.className = "Dot", P.serialization.registerClass(Lu); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class ju extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.stddev = e.stddev } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { stddev: this.stddev }; return Object.assign(t, e), t } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); return mi((() => (0, P.add)(ui(n.shape, 0, this.stddev), n)), (() => n), t.training || !1) })) } } ju.className = "GaussianNoise", P.serialization.registerClass(ju); class Uu extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.rate = e.rate } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { rate: this.rate }; return Object.assign(t, e), t } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); if (this.rate > 0 && this.rate < 1) { return mi((() => { const e = Math.sqrt(this.rate / (1 - this.rate)); return (0, P.mul)(n, ui(n.shape, 1, e)) }), (() => n), t.training || !1) } return n })) } } Uu.className = "GaussianDropout", P.serialization.registerClass(Uu); class Wu extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.rate = e.rate, this.noiseShape = e.noiseShape } _getNoiseShape(e) { return this.noiseShape || Li(e).shape } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { rate: this.rate }; return Object.assign(t, e), t } call(e, t) { return (0, P.tidy)((() => { if (this.rate < 1 && this.rate > 0) { const n = this._getNoiseShape(e); return mi((() => { const t = Li(e), r = -1.7580993408473766; let i = (0, P.greaterEqual)((0, P.randomUniform)(n), this.rate); i = ei(i, "float32"); const a = ((1 - this.rate) * (1 + this.rate * r ** 2)) ** -.5, o = -a * r * this.rate, s = (0, P.add)((0, P.mul)(t, i), (0, P.mul)((0, P.add)(i, -1), r)); return (0, P.add)((0, P.mul)(s, a), o) }), (() => Li(e)), t.training || !1) } return e })) } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Vu(e, t, n, r, i, a = .001) { let o; if (2 === e.rank) o = P.batchNorm2d(e, t, n, r, i, a); else if (3 === e.rank) o = P.batchNorm3d(e, t, n, r, i, a); else { if (4 !== e.rank) throw new sr(`batchNormalization is not implemented for array of rank ${e.rank} yet`); o = P.batchNorm4d(e, t, n, r, i, a) } return o } function Gu(e, t, n, r, i = .001) { return P.util.arraysEqual(r.slice().sort(), Zr(0, e.rank - 1)) ? function (e, t, n, r, i = .001) { return (0, P.tidy)((() => { const a = P.moments(e, r), o = a.mean, s = a.variance; return [Vu(e, o, s, n, t, i), o, s] })) }(e, t, n, r, i) : function (e, t, n, r, i = .001) { return (0, P.tidy)((() => { const a = P.moments(e, r), o = a.mean, s = a.variance, u = []; for (const t of Zr(0, e.rank)) -1 !== r.indexOf(t) ? u.push(1) : u.push(e.shape[t]); const l = (0, P.reshape)(o, u), c = (0, P.reshape)(s, u), h = null == t ? null : (0, P.reshape)(t, u), d = null == n ? null : (0, P.reshape)(n, u); return [Vu(e, l, c, d, h, i), o, s] })) }(e, t, n, r, i) } Wu.className = "AlphaDropout", P.serialization.registerClass(Wu); class Hu extends Ji { constructor(e) { null == e && (e = {}), super(e), this.supportsMasking = !0, this.axis = null == e.axis ? -1 : e.axis, this.momentum = null == e.momentum ? .99 : e.momentum, this.epsilon = null == e.epsilon ? .001 : e.epsilon, this.center = null == e.center || e.center, this.scale = null == e.scale || e.scale, this.betaInitializer = zi(e.betaInitializer || "zeros"), this.gammaInitializer = zi(e.gammaInitializer || "ones"), this.movingMeanInitializer = zi(e.movingMeanInitializer || "zeros"), this.movingVarianceInitializer = zi(e.movingVarianceInitializer || "ones"), this.betaConstraint = ba(e.betaConstraint), this.gammaConstraint = ba(e.gammaConstraint), this.betaRegularizer = Ds(e.betaRegularizer), this.gammaRegularizer = Ds(e.gammaRegularizer) } build(e) { e = ji(e); const t = this.axis >= 0 ? this.axis : this.axis + e.length, n = e[t]; if (null == n) throw new or(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`); this.inputSpec = [new qi({ ndim: e.length, axes: { [t]: n } })]; const r = [n]; this.scale && (this.gamma = this.addWeight("gamma", r, null, this.gammaInitializer, this.gammaRegularizer, !0, this.gammaConstraint)), this.center && (this.beta = this.addWeight("beta", r, null, this.betaInitializer, this.betaRegularizer, !0, this.betaConstraint)), this.movingMean = this.addWeight("moving_mean", r, null, this.movingMeanInitializer, null, !1), this.movingVariance = this.addWeight("moving_variance", r, null, this.movingVarianceInitializer, null, !1), this.built = !0 } call(e, t) { return (0, P.tidy)((() => { const n = null != t.training && t.training, r = Li(e), i = r.shape, a = i.length, o = Zr(0, a), s = this.axis >= 0 ? this.axis : this.axis + a; o.splice(s, 1); const u = cr(1, a); u[s] = i[s]; const l = o.slice(); l.sort(); const c = !P.util.arraysEqual(l, Zr(0, a).slice(0, a - 1)); if (!n) return (() => { if (c) { const e = (0, P.reshape)(this.movingMean.read(), u), t = (0, P.reshape)(this.movingVariance.read(), u), n = this.center ? (0, P.reshape)(this.beta.read(), u) : null, i = this.scale ? (0, P.reshape)(this.gamma.read(), u) : null; return Vu(r, e, t, n, i, this.epsilon) } return Vu(r, this.movingMean.read(), this.movingVariance.read(), null == this.beta ? null : this.beta.read(), null == this.gamma ? null : this.gamma.read(), this.epsilon) })(); const [h, d, f] = Gu(r, this.gamma.read(), this.beta.read(), o, this.epsilon), p = (e, t, n) => { P.tidy((() => { const r = 1 - n, i = e.read(), a = P.mul(P.sub(i, t), r); e.write(P.sub(i, a)) })) }; return (() => { p(this.movingMean, d, this.momentum), p(this.movingVariance, f, this.momentum) })(), h })) } getConfig() { const e = { axis: this.axis, momentum: this.momentum, epsilon: this.epsilon, center: this.center, scale: this.scale, betaInitializer: Oi(this.betaInitializer), gammaInitializer: Oi(this.gammaInitializer), movingMeanInitializer: Oi(this.movingMeanInitializer), movingVarianceInitializer: Oi(this.movingVarianceInitializer), betaRegularizer: Ms(this.betaRegularizer), gammaRegularizer: Ms(this.gammaRegularizer), betaConstraint: ga(this.betaConstraint), gammaConstraint: ga(this.gammaConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } } Hu.className = "BatchNormalization", P.serialization.registerClass(Hu); class qu extends Ji { constructor(e) { if (null == e && (e = {}), super(e), this.axis = null == e.axis ? -1 : e.axis, "number" == typeof this.axis) { if (!Number.isInteger(this.axis)) throw new Error(`Expected axis to be an integer, but received ${this.axis}`) } else { if (!Array.isArray(this.axis)) throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`); for (const e of this.axis) if (!Number.isInteger(e)) throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`) } this.epsilon = null == e.epsilon ? .001 : e.epsilon, this.center = null == e.center || e.center, this.scale = null == e.scale || e.scale, this.betaInitializer = zi(e.betaInitializer || "zeros"), this.gammaInitializer = zi(e.gammaInitializer || "ones"), this.betaRegularizer = Ds(e.betaRegularizer), this.gammaRegularizer = Ds(e.gammaRegularizer), this.supportsMasking = !0 } build(e) { const t = (e = ji(e)).length; "number" == typeof this.axis && (this.axis = [this.axis]); for (let e = 0; e < this.axis.length; ++e)this.axis[e] < 0 && (this.axis[e] += t); for (const e of this.axis) if (e < 0 || e >= t) throw new Error(`Invalid axis: ${e}`); if (this.axis.length !== kr(this.axis).length) throw new Error(`Found duplicate axes in: ${this.axis}`); const n = this.axis.map((t => e[t])), r = !0; this.scale ? this.gamma = this.addWeight("gamma", n, "float32", this.gammaInitializer, this.gammaRegularizer, r) : this.gamma = null, this.center ? this.beta = this.addWeight("beta", n, "float32", this.betaInitializer, this.betaRegularizer, r) : this.beta = null, this.built = !0 } call(e, t) { const n = Li(e), r = n.shape, i = r.length; return (0, P.tidy)((() => { let { mean: e, variance: t } = (0, P.moments)(n, this.axis, !0); const a = cr(1, i); for (const e of this.axis) a[e] = r[e]; const o = e => null != e && e.shape.length !== i ? P.reshape(e, a) : e; let s = this.scale ? o(this.gamma.read()) : null, u = this.center ? o(this.beta.read()) : null; const l = [], c = []; for (let e = 0; e < i; ++e)-1 !== this.axis.indexOf(e) ? (l.push(r[e]), c.push(1)) : (l.push(1), c.push(r[e])); return e = P.tile(e, l), t = P.tile(t, l), null != s && (s = P.tile(s, c)), null != u && (u = P.tile(u, c)), Vu(n, e, t, u, s, this.epsilon) })) } getConfig() { const e = { axis: this.axis, epsilon: this.epsilon, center: this.center, scale: this.scale, betaInitializer: Oi(this.betaInitializer), gammaInitializer: Oi(this.gammaInitializer), betaRegularizer: Ms(this.betaRegularizer), gammaRegularizer: Ms(this.gammaRegularizer) }, t = super.getConfig(); return Object.assign(e, t), e } } qu.className = "LayerNormalization", P.serialization.registerClass(qu); class Yu extends Ji { constructor(e) { if (null == e && (e = {}), super(e), this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, null == e.padding) this.padding = [[1, 1], [1, 1]]; else if ("number" == typeof e.padding) this.padding = [[e.padding, e.padding], [e.padding, e.padding]]; else { if (e.padding = e.padding, 2 !== e.padding.length) throw new or(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`); let t, n; if ("number" == typeof e.padding[0]) t = [e.padding[0], e.padding[0]], n = [e.padding[1], e.padding[1]]; else { if (e.padding = e.padding, 2 !== e.padding[0].length) throw new or(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`); if (t = e.padding[0], 2 !== e.padding[1].length) throw new or(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`); n = e.padding[1] } this.padding = [t, n] } this.inputSpec = [new qi({ ndim: 4 })] } computeOutputShape(e) { let t, n; return e = ji(e), "channelsFirst" === this.dataFormat ? (t = null != e[2] && e[2] >= 0 ? e[2] + this.padding[0][0] + this.padding[0][1] : null, n = null != e[3] && e[3] >= 0 ? e[3] + this.padding[1][0] + this.padding[1][1] : null, [e[0], e[1], t, n]) : (t = null != e[1] && e[1] >= 0 ? e[1] + this.padding[0][0] + this.padding[0][1] : null, n = null != e[2] && e[2] >= 0 ? e[2] + this.padding[1][0] + this.padding[1][1] : null, [e[0], t, n, e[3]]) } call(e, t) { return (0, P.tidy)((() => { return t = Li(e), n = this.padding, r = this.dataFormat, (0, P.tidy)((() => { if (4 !== t.rank) throw new or(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`); if (null == n && (n = [[1, 1], [1, 1]]), 2 !== n.length || 2 !== n[0].length || 2 !== n[1].length) throw new or("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers."); if (null == r && (r = "channelsLast"), "channelsLast" !== r && "channelsFirst" !== r) throw new or(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`); let e; return e = "channelsFirst" === r ? [[0, 0], [0, 0], n[0], n[1]] : [[0, 0], n[0], n[1], [0, 0]], P.pad(t, e) })); var t, n, r })) } getConfig() { const e = { padding: this.padding, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Xu(e, t, n, r, i, a) { return (0, P.tidy)((() => { let o; Br(i), jr(a), Lr(r), null == n && (n = [1, 1]), null == r && (r = "valid"), null == i && (i = "channelsLast"), null == a && (a = "max"), e = Ws(e, i); const s = "same" === r ? "same" : "valid"; return o = "max" === a ? P.maxPool(e, t, n, s) : P.avgPool(e, t, n, s), "channelsFirst" === i && (o = P.transpose(o, [0, 3, 1, 2])), o })) } function Ku(e, t, n, r, i, a) { return (0, P.tidy)((() => { let o; Br(i), jr(a), Lr(r), null == n && (n = [1, 1, 1]), null == r && (r = "valid"), null == i && (i = "channelsLast"), null == a && (a = "max"), e = Vs(e, i); const s = "same" === r ? "same" : "valid"; return o = "max" === a ? P.maxPool3d(e, t, n, s) : P.avgPool3d(e, t, n, s), "channelsFirst" === i && (o = P.transpose(o, [0, 4, 1, 2, 3])), o })) } Yu.className = "ZeroPadding2D", P.serialization.registerClass(Yu); class Zu extends Ji { constructor(e) { if (null == e.poolSize && (e.poolSize = 2), super(e), "number" == typeof e.poolSize) this.poolSize = [e.poolSize]; else { if (!Array.isArray(e.poolSize) || 1 !== e.poolSize.length || "number" != typeof e.poolSize[0]) throw new or(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`); this.poolSize = e.poolSize } if (Ar(this.poolSize, "poolSize"), null == e.strides) this.strides = this.poolSize; else if ("number" == typeof e.strides) this.strides = [e.strides]; else { if (!Array.isArray(e.strides) || 1 !== e.strides.length || "number" != typeof e.strides[0]) throw new or(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`); this.strides = e.strides } Ar(this.strides, "strides"), this.padding = null == e.padding ? "valid" : e.padding, Lr(this.padding), this.inputSpec = [new qi({ ndim: 3 })] } computeOutputShape(e) { const t = js((e = ji(e))[1], this.poolSize[0], this.padding, this.strides[0]); return [e[0], t, e[2]] } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t), e = ti(Li(e), 2); const n = this.poolingFunction(Li(e), [this.poolSize[0], 1], [this.strides[0], 1], this.padding, "channelsLast"); return P.squeeze(n, [2]) })) } getConfig() { const e = { poolSize: this.poolSize, padding: this.padding, strides: this.strides }, t = super.getConfig(); return Object.assign(e, t), e } } class Ju extends Zu { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "max") } } Ju.className = "MaxPooling1D", P.serialization.registerClass(Ju); class Qu extends Zu { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "avg") } } Qu.className = "AveragePooling1D", P.serialization.registerClass(Qu); class el extends Ji { constructor(e) { if (null == e.poolSize && (e.poolSize = [2, 2]), super(e), this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize], null == e.strides) this.strides = this.poolSize; else if (Array.isArray(e.strides)) { if (2 !== e.strides.length) throw new or(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`); this.strides = e.strides } else this.strides = [e.strides, e.strides]; Ar(this.poolSize, "poolSize"), Ar(this.strides, "strides"), this.padding = null == e.padding ? "valid" : e.padding, this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), Lr(this.padding), this.inputSpec = [new qi({ ndim: 4 })] } computeOutputShape(e) { e = ji(e); let t = "channelsFirst" === this.dataFormat ? e[2] : e[1], n = "channelsFirst" === this.dataFormat ? e[3] : e[2]; return t = js(t, this.poolSize[0], this.padding, this.strides[0]), n = js(n, this.poolSize[1], this.padding, this.strides[1]), "channelsFirst" === this.dataFormat ? [e[0], e[1], t, n] : [e[0], t, n, e[3]] } call(e, t) { return (0, P.tidy)((() => (this.invokeCallHook(e, t), this.poolingFunction(Li(e), this.poolSize, this.strides, this.padding, this.dataFormat)))) } getConfig() { const e = { poolSize: this.poolSize, padding: this.padding, strides: this.strides, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } class tl extends el { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "max") } } tl.className = "MaxPooling2D", P.serialization.registerClass(tl); class nl extends el { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "avg") } } nl.className = "AveragePooling2D", P.serialization.registerClass(nl); class rl extends Ji { constructor(e) { if (null == e.poolSize && (e.poolSize = [2, 2, 2]), super(e), this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize, e.poolSize], null == e.strides) this.strides = this.poolSize; else if (Array.isArray(e.strides)) { if (3 !== e.strides.length) throw new or(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`); this.strides = e.strides } else this.strides = [e.strides, e.strides, e.strides]; Ar(this.poolSize, "poolSize"), Ar(this.strides, "strides"), this.padding = null == e.padding ? "valid" : e.padding, this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), Lr(this.padding), this.inputSpec = [new qi({ ndim: 5 })] } computeOutputShape(e) { e = ji(e); let t = "channelsFirst" === this.dataFormat ? e[2] : e[1], n = "channelsFirst" === this.dataFormat ? e[3] : e[2], r = "channelsFirst" === this.dataFormat ? e[4] : e[3]; return t = js(t, this.poolSize[0], this.padding, this.strides[0]), n = js(n, this.poolSize[1], this.padding, this.strides[1]), r = js(r, this.poolSize[2], this.padding, this.strides[2]), "channelsFirst" === this.dataFormat ? [e[0], e[1], t, n, r] : [e[0], t, n, r, e[4]] } call(e, t) { return (0, P.tidy)((() => (this.invokeCallHook(e, t), this.poolingFunction(Li(e), this.poolSize, this.strides, this.padding, this.dataFormat)))) } getConfig() { const e = { poolSize: this.poolSize, padding: this.padding, strides: this.strides, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } class il extends rl { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Ku(e, t, n, r, i, "max") } } il.className = "MaxPooling3D", P.serialization.registerClass(il); class al extends rl { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Ku(e, t, n, r, i, "avg") } } al.className = "AveragePooling3D", P.serialization.registerClass(al); class ol extends Ji { constructor(e) { super(e), this.inputSpec = [new qi({ ndim: 3 })] } computeOutputShape(e) { return [e[0], e[2]] } call(e, t) { throw new sr } } class sl extends ol { constructor(e) { super(e || {}) } call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return P.mean(t, 1) })) } } sl.className = "GlobalAveragePooling1D", P.serialization.registerClass(sl); class ul extends ol { constructor(e) { super(e || {}) } call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return P.max(t, 1) })) } } ul.className = "GlobalMaxPooling1D", P.serialization.registerClass(ul); class ll extends Ji { constructor(e) { super(e), this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), this.inputSpec = [new qi({ ndim: 4 })] } computeOutputShape(e) { return "channelsLast" === this.dataFormat ? [e[0], e[3]] : [e[0], e[1]] } call(e, t) { throw new sr } getConfig() { const e = { dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } class cl extends ll { call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return "channelsLast" === this.dataFormat ? P.mean(t, [1, 2]) : P.mean(t, [2, 3]) })) } } cl.className = "GlobalAveragePooling2D", P.serialization.registerClass(cl); class hl extends ll { call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return "channelsLast" === this.dataFormat ? P.max(t, [1, 2]) : P.max(t, [2, 3]) })) } } hl.className = "GlobalMaxPooling2D", P.serialization.registerClass(hl); + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class dl extends Ji { constructor(e) { super(e), this.layer = e.layer } build(e) { this.built = !0 } get trainable() { return null != this.layer && this.layer.trainable } set trainable(e) { null != this.layer && (this.layer.trainable = e) } get trainableWeights() { return this.layer.trainableWeights } get nonTrainableWeights() { return this.layer.nonTrainableWeights } get updates() { return this.layer._updates } get losses() { return this.layer.losses } getWeights() { return this.layer.getWeights() } setWeights(e) { this.layer.setWeights(e) } getConfig() { const e = { layer: { className: this.layer.getClassName(), config: this.layer.getConfig() } }, t = super.getConfig(); return Object.assign(e, t), e } setFastWeightInitDuringBuild(e) { super.setFastWeightInitDuringBuild(e), null != this.layer && this.layer.setFastWeightInitDuringBuild(e) } static fromConfig(e, t, n = {}) { const r = Ka(t.layer, n); delete t.layer; const i = { layer: r }; return Object.assign(i, t), new e(i) } } class fl extends dl { constructor(e) { super(e), this.supportsMasking = !0 } build(e) { if ((e = ji(e)).length < 3) throw new or(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`); this.inputSpec = [{ shape: e }]; const t = [e[0]].concat(e.slice(2)); this.layer.built || (this.layer.build(t), this.layer.built = !0), super.build(e) } computeOutputShape(e) { const t = [(e = ji(e))[0]].concat(e.slice(2)), n = this.layer.computeOutputShape(t), r = e[1]; return [n[0], r].concat(n.slice(1)) } call(e, t) { return (0, P.tidy)((() => su(((e, n) => [Li(this.layer.call(e, t)), []]), e = Li(e), [], !1, null, null, !1, !0)[1])) } } fl.className = "TimeDistributed", P.serialization.registerClass(fl); class pl extends dl { constructor(e) { super(e); const t = e.layer.getConfig(), n = {}; n.className = e.layer.getClassName(), n.config = t, this.forwardLayer = Ka(n), t.goBackwards = !0 !== t.goBackwards; const r = {}; var i; if (r.className = e.layer.getClassName(), r.config = t, this.backwardLayer = Ka(r), this.forwardLayer.name = "forward_" + this.forwardLayer.name, this.backwardLayer.name = "backward_" + this.backwardLayer.name, this.mergeMode = void 0 === e.mergeMode ? "concat" : e.mergeMode, i = this.mergeMode, _r(zr, "BidirectionalMergeMode", i), e.weights) throw new sr("weights support is not implemented for Bidirectional layer yet."); this._stateful = e.layer.stateful, this.returnSequences = e.layer.returnSequences, this.returnState = e.layer.returnState, this.supportsMasking = !0, this._trainable = !0, this.inputSpec = e.layer.inputSpec, this.numConstants = null } get trainable() { return this._trainable } set trainable(e) { this._trainable = e, null != this.forwardLayer && (this.forwardLayer.trainable = e), null != this.backwardLayer && (this.backwardLayer.trainable = e) } getWeights() { return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights()) } setWeights(e) { const t = e.length, n = Math.floor(t / 2); this.forwardLayer.setWeights(e.slice(0, n)), this.backwardLayer.setWeights(e.slice(n)) } computeOutputShape(e) { let t, n, r, i = this.forwardLayer.computeOutputShape(e); return Array.isArray(i) && Array.isArray(i[0]) || (i = [i]), this.returnState ? (r = i.slice(1), t = i[0]) : t = i[0], "concat" === this.mergeMode ? (t[t.length - 1] *= 2, n = [t]) : n = null == this.mergeMode ? [t, t.slice()] : [t], this.returnState ? null == this.mergeMode ? n.concat(r).concat(r.slice()) : [t].concat(r).concat(r.slice()) : fr(n) } apply(e, t) { let n = null == t ? null : t.initialState, r = null == t ? null : t.constants; null == t && (t = {}); const i = ou(e, n, r, this.numConstants); if (e = i.inputs, n = i.initialState, r = i.constants, Array.isArray(e) && (n = e.slice(1), e = e[0]), (null == n || 0 === n.length) && null == r) return super.apply(e, t); const a = [], o = []; if (null != n) { const e = n.length; if (e % 2 > 0) throw new or("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs."); t.initialState = n, a.push(...n); const r = n.map((e => new qi({ shape: e.shape }))); this.forwardLayer.stateSpec = r.slice(0, e / 2), this.backwardLayer.stateSpec = r.slice(e / 2), o.push(...r) } if (null != r) throw new sr("Support for constants in Bidirectional layers is not implemented yet."); const s = a[0] instanceof Yi; for (const e of a) if (e instanceof Yi !== s) throw new or("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors"); if (s) { const n = [e].concat(a), r = this.inputSpec.concat(o), i = this.inputSpec; this.inputSpec = r; const s = super.apply(n, t); return this.inputSpec = i, s } return super.apply(e, t) } call(e, t) { return (0, P.tidy)((() => { const n = t.initialState; let r, i, a, o; if (null == n) r = this.forwardLayer.call(e, t), i = this.backwardLayer.call(e, t); else { const a = n.slice(0, n.length / 2), o = n.slice(n.length / 2); r = this.forwardLayer.call(e, Object.assign(t, { initialState: a })), i = this.backwardLayer.call(e, Object.assign(t, { initialState: o })) } return this.returnState && (Array.isArray(r) && (a = r.slice(1).concat(i.slice(1))), r = r[0], i = i[0]), this.returnSequences && (i = P.reverse(i, 1)), "concat" === this.mergeMode ? o = ai([r, i]) : "sum" === this.mergeMode ? o = P.add(r, i) : "ave" === this.mergeMode ? o = P.mul(.5, P.add(r, i)) : "mul" === this.mergeMode ? o = P.mul(r, i) : null == this.mergeMode && (o = [r, i]), this.returnState ? null == this.mergeMode ? o.concat(a) : [o].concat(a) : o })) } resetStates(e) { this.forwardLayer.resetStates(), this.backwardLayer.resetStates() } build(e) { Wr(this.forwardLayer.name, (() => { this.forwardLayer.build(e) })), Wr(this.backwardLayer.name, (() => { this.backwardLayer.build(e) })), this.built = !0 } computeMask(e, t) { let n; if (Array.isArray(t) && (t = t[0]), n = this.returnSequences ? null == this.mergeMode ? [t, t] : t : null == this.mergeMode ? [null, null] : null, this.returnState) { const e = this.forwardLayer.states.map((e => null)); return Array.isArray(n) ? n.concat(e).concat(e) : [n].concat(e).concat(e) } return n } get trainableWeights() { return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights) } get nonTrainableWeights() { return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights) } setFastWeightInitDuringBuild(e) { super.setFastWeightInitDuringBuild(e), null != this.forwardLayer && this.forwardLayer.setFastWeightInitDuringBuild(e), null != this.backwardLayer && this.backwardLayer.setFastWeightInitDuringBuild(e) } getConfig() { const e = { mergeMode: this.mergeMode }, t = super.getConfig(); return Object.assign(e, t), e } static fromConfig(e, t) { const n = Ka(t.layer); if (delete t.layer, null != t.numConstants) throw new sr("Deserialization of a Bidirectional layer with numConstants present is not supported yet."); const r = t; return r.layer = n, new e(r) } } pl.className = "Bidirectional", P.serialization.registerClass(pl); + /** + * @license + * Copyright 2022 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class ml extends Ji { constructor(e) { super(e), this.scale = e.scale, e.offset ? this.offset = e.offset : this.offset = 0 } getConfig() { const e = { scale: this.scale, offset: this.offset }, t = super.getConfig(); return Object.assign(e, t), e } call(e, t) { return (0, P.tidy)((() => ("float32" !== (e = Li(e)).dtype && (e = ei(e, "float32")), (0, P.add)((0, P.mul)(e, this.scale), this.offset)))) } } ml.className = "Rescaling", P.serialization.registerClass(ml); + /** + * @license + * Copyright 2022 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const { resizeBilinear: gl, cropAndResize: yl } = P.image; class bl extends Ji { constructor(e) { super(e), this.height = e.height, this.width = e.width } centerCrop(e, t, n, r, i, a, o, s) { return (0, P.tidy)((() => { let u, l = !1; const c = [t / a, n / o, (r + t) / a, (i + n) / o], h = []; 3 === e.rank ? (l = !0, u = (0, P.stack)([e])) : u = e; for (let e = 0; e < u.shape[0]; e++)h.push(c); const d = (0, P.tensor)(h, [h.length, 4]), f = (0, P.range)(0, h.length, 1, "int32"), p = yl(u, d, f, [r, i], "nearest"); return ei(l ? Li((0, P.unstack)(p)) : p, s) })) } upsize(e, t, n, r) { return (0, P.tidy)((() => ei(gl(e, [t, n]), r))) } call(e, t) { return (0, P.tidy)((() => { const t = Li(e), n = t.dtype, r = t.shape, i = r[r.length - 3], a = r[r.length - 2]; let o = 0; i !== this.height && (o = Math.floor((i - this.height) / 2)); let s = 0; return a !== this.width && (s = Math.floor((a - this.width) / 2), 0 === s && (s = 1)), o >= 0 && s >= 0 ? this.centerCrop(t, o, s, this.height, this.width, i, a, n) : this.upsize(e, this.height, this.width, n) })) } getConfig() { const e = { height: this.height, width: this.width }, t = super.getConfig(); return Object.assign(e, t), e } computeOutputShape(e) { const t = (e = ji(e)).length - 3, n = e.length - 2; return e[t] = this.height, e[n] = this.width, e } } bl.className = "CenterCrop", P.serialization.registerClass(bl); + /** + * @license + * Copyright 2022 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class vl extends Ji { + constructor(e) { super(e), this.numTokens = e.numTokens, e.outputMode ? this.outputMode = e.outputMode : this.outputMode = "multiHot" } getConfig() { const e = { numTokens: this.numTokens, outputMode: this.outputMode }, t = super.getConfig(); return Object.assign(e, t), e } computeOutputShape(e) { return null == (e = ji(e)) ? [this.numTokens] : "oneHot" === this.outputMode && 1 !== e[e.length - 1] ? (e.push(this.numTokens), e) : (e[e.length - 1] = this.numTokens, e) } call(e, t) { + return (0, P.tidy)((() => { + let n; if ("int32" !== (e = Li(e)).dtype && (e = ei(e, "int32")), void 0 !== t.countWeights) { if ("count" !== this.outputMode) throw new or(`countWeights is not used when outputMode !== count.\n Received countWeights=${t.countWeights}`); n = Li(t.countWeights) } const r = (0, P.max)(e), i = (0, P.min)(e), a = (0, P.greater)(this.numTokens, r).bufferSync().get(0), o = (0, P.greaterEqual)(i, 0).bufferSync().get(0); if (!a || !o) throw new or(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`); + /** + * @license + * Copyright 2022 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + return function (e, t, n, r) { let i = Li(e); if ("int32" !== i.dtype && (i = ei(i, "int32")), "int" === t) return i; const a = i.shape; if (0 === i.rank && (i = (0, P.expandDims)(i, -1)), "oneHot" === t && 1 !== i.shape[i.shape.length - 1] && (i = (0, P.expandDims)(i, -1)), i.rank > 2) throw new or(`When outputMode is not int, maximum output rank is 2 Received outputMode ${t} and input shape ${a} which would result in output rank ${i.rank}.`); const o = ["multiHot", "oneHot"].includes(t), s = i; let u; if (u = void 0 !== r && "count" === t ? (0, P.denseBincount)(s, r, n, o) : (0, P.denseBincount)(s, [], n, o), "tfIdf" !== t) return u; if (r) return (0, P.mul)(u, r); throw new or("When outputMode is 'tfIdf', weights must be provided.") }(e, this.outputMode, this.numTokens, n) + })) + } + } vl.className = "CategoryEncoding", P.serialization.registerClass(vl); + /** + * @license + * Copyright 2022 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const xl = new Set(["bilinear", "nearest"]); class wl extends Ji { constructor(e) { if (super(e), this.height = e.height, this.width = e.width, e.interpolation) { if (!xl.has(e.interpolation)) throw new or(`Invalid interpolation parameter: ${e.interpolation} is not implemented`); this.interpolation = e.interpolation } else this.interpolation = "bilinear"; this.cropToAspectRatio = Boolean(e.cropToAspectRatio) } computeOutputShape(e) { const t = (e = ji(e))[2]; return [this.height, this.width, t] } getConfig() { const e = { height: this.height, width: this.width, interpolation: this.interpolation, cropToAspectRatio: this.cropToAspectRatio }, t = super.getConfig(); return Object.assign(e, t), e } call(e, t) { return (0, P.tidy)((() => { const t = [this.height, this.width]; if ("bilinear" === this.interpolation) return P.image.resizeBilinear(e, t, !this.cropToAspectRatio); if ("nearest" === this.interpolation) return P.image.resizeNearestNeighbor(e, t, !this.cropToAspectRatio); throw new Error(`Interpolation is ${this.interpolation} but only ${[...xl]} are supported`) })) } } wl.className = "Resizing", P.serialization.registerClass(wl); + /** + * @license + * Copyright 2023 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class kl { constructor(e) { this.seed = e } next() { if (void 0 !== this.seed) return this.seed++ } } kl.className = "RandomSeed"; + /** + * @license + * Copyright 2023 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class Sl extends Ji { constructor(e) { super(e), this.randomGenerator = new kl(e.seed) } getConfig() { const e = { seed: this.randomGenerator.seed }, t = super.getConfig(); return Object.assign(e, t), e } } Sl.className = "BaseRandomLayer"; + /** + * @license + * Copyright 2023 CodeSmith LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + const _l = new Set(["bilinear", "nearest"]); class Cl extends Sl { constructor(e) { super(e); const { factor: t, interpolation: n = "bilinear" } = e; if (this.factor = t, Array.isArray(this.factor) && 2 === this.factor.length) this.widthLower = this.factor[0], this.widthUpper = this.factor[1]; else { if (Array.isArray(this.factor) || !(this.factor > 0)) throw new or(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`); this.widthLower = -this.factor, this.widthUpper = this.factor } if (this.widthLower < -1 || this.widthUpper < -1) throw new or(`factor must have values larger than -1. Got: ${this.factor}`); if (this.widthUpper < this.widthLower) throw new or(`factor cannot have upper bound less than lower bound.\n Got upper bound: ${this.widthUpper}.\n Got lower bound: ${this.widthLower}\n `); if (n) { if (!_l.has(n)) throw new or(`Invalid interpolation parameter: ${n} is not implemented`); this.interpolation = n } } getConfig() { const e = { factor: this.factor, interpolation: this.interpolation }, t = super.getConfig(); return Object.assign(e, t), e } computeOutputShape(e) { const t = (e = ji(e))[2]; return [this.imgHeight, -1, t] } call(e, t) { return (0, P.tidy)((() => { const t = Li(e); this.imgHeight = t.shape[t.shape.length - 3]; const n = t.shape[t.shape.length - 2]; this.widthFactor = (0, P.randomUniform)([1], 1 + this.widthLower, 1 + this.widthUpper, "float32", this.randomGenerator.next()); let r = this.widthFactor.dataSync()[0] * n; r = Math.round(r); const i = [this.imgHeight, r]; switch (this.interpolation) { case "bilinear": return P.image.resizeBilinear(e, i); case "nearest": return P.image.resizeNearestNeighbor(e, i); default: throw new Error(`Interpolation is ${this.interpolation}\n but only ${[..._l]} are supported`) } })) } } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function Al(e) { return new ea(e) } function Tl(e) { return new zs(e) } function El(e) { return new $s(e) } function Nl(e) { return new Rs(e) } function Il(e) { return new Os(e) } function Ml(e) { return new Bs(e) } function Fl(e) { return new Ps(e) } function Dl(e) { return new nu(e) } function $l(e) { return new Ks(e) } function Rl(e) { return new Js(e) } function Ol(e) { return new Zs(e) } function zl(e) { return new Qs(e) } function Pl(e) { return new tu(e) } function Bl(e) { return new ru(e) } function Ll(e) { return new iu(e) } function jl(e) { return new au(e) } function Ul(e) { return new Au(e) } function Wl(e) { return new _u(e) } function Vl(e) { return new ku(e) } function Gl(e) { return new Su(e) } function Hl(e) { return new Cu(e) } function ql(e) { return new Tu(e) } function Yl(e) { return new Eu(e) } function Xl(e) { return new Nu(e) } function Kl(e) { return new Mu(e) } function Zl(e) { return new Du(e) } function Jl(e) { return new Ru(e) } function Ql(e) { return new Pu(e) } function ec(e) { return new Ou(e) } function tc(e) { return new zu(e) } function nc(e) { return new $u(e) } function rc(e) { return new Lu(e) } function ic(e) { return new Hu(e) } function ac(e) { return new qu(e) } function oc(e) { return new Yu(e) } function sc(e) { return new Qu(e) } function uc(e) { return sc(e) } function lc(e) { return sc(e) } function cc(e) { return new nl(e) } function hc(e) { return cc(e) } function dc(e) { return cc(e) } function fc(e) { return new al(e) } function pc(e) { return fc(e) } function mc(e) { return fc(e) } function gc(e) { return new sl(e) } function yc(e) { return new cl(e) } function bc(e) { return new ul(e) } function vc(e) { return new hl(e) } function xc(e) { return new Ju(e) } function wc(e) { return new tl(e) } function kc(e) { return new il(e) } function Sc(e) { return new fu(e) } function _c(e) { return new du(e) } function Cc(e) { return new mu(e) } function Ac(e) { return new pu(e) } function Tc(e) { return new hu(e) } function Ec(e) { return new cu(e) } function Nc(e) { return new wu(e) } function Ic(e) { return new xu(e) } function Mc(e) { return new uu(e) } function Fc(e) { return new gu(e) } function Dc(e) { return new pl(e) } function $c(e) { return new fl(e) } Cl.className = "RandomWidth", P.serialization.registerClass(Cl); const Rc = bc, Oc = vc, zc = xc, Pc = wc; function Bc(e) { return new ju(e) } function Lc(e) { return new Uu(e) } function jc(e) { return new Wu(e) } function Uc(e) { return new Iu(e) } function Wc(e) { return new ml(e) } function Vc(e) { return new bl(e) } function Gc(e) { return new wl(e) } function Hc(e) { return new vl(e) } function qc(e) { return new Cl(e) } function Yc(e, t) { return lo(e, t) } function Xc(e, t) { return mo(e, t) } function Kc(e, t) { return go(e, t) } function Zc(e, t) { return co(e, t) } function Jc(e, t) { return yo(e, t) } function Qc(e, t) { return fo(e, t) } function eh(e, t) { return po(e, t) } function th(e, t) { return oo(e, t) } function nh(e, t) { return Qa(e, t) } function rh(e, t) { return eo(e, t) } function ih(e, t) { return eo(e, t) } function ah(e, t) { return eo(e, t) } function oh(e, t) { return Ja(e, t) } function sh(e, t) { return Ja(e, t) } function uh(e, t) { return Ja(e, t) } function lh(e, t) { return function (e, t) { return (0, P.tidy)((() => { const n = e.sub(t).square().sum(), r = e.sub(e.mean()).square().sum(); return P.scalar(1).sub(n.div(r)) })) }(e, t) } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + function ch(e) { return new Ns(e) } function hh(e) { return Ts(t = e), new Ns({ l1: null != t ? t.l1 : null, l2: 0 }); var t } function dh(e) { return Ts(t = e), new Ns({ l2: null != t ? t.l2 : null, l1: 0 }); var t } + /** + * @license + * Copyright 2018 Google LLC + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + * ============================================================================= + */ + class fh extends Ua { constructor() { super(...arguments), this.model = null } setModel(e) { if (!(e instanceof Jo)) throw new Error("model must be a LayersModel, not some other Container"); this.model = e } } function ph(e, t) { return e < t } function mh(e, t) { return e > t } class gh extends fh { constructor(e) { if (super(), null == e && (e = {}), e.restoreBestWeights) throw new sr("restoreBestWeights = True is not implemented in EarlyStopping yet."); this.monitor = e.monitor || "val_loss", this.minDelta = Math.abs(e.minDelta || 0), this.patience = e.patience || 0, this.verbose = e.verbose || 0, this.mode = e.mode || "auto", this.baseline = e.baseline, -1 === ["auto", "min", "max"].indexOf(this.mode) && (console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`), this.mode = "auto"), "min" === this.mode ? this.monitorFunc = ph : "max" === this.mode || -1 !== this.monitor.indexOf("acc") ? this.monitorFunc = mh : this.monitorFunc = ph, this.monitorFunc === ph && (this.minDelta *= -1) } async onTrainBegin(e) { this.wait = 0, this.stoppedEpoch = 0, null != this.baseline ? this.best = this.baseline : this.best = this.monitorFunc === ph ? 1 / 0 : -1 / 0 } async onEpochEnd(e, t) { await Pa(t); const n = this.getMonitorValue(t); null != n && (this.monitorFunc(n - this.minDelta, this.best) ? (this.best = n, this.wait = 0) : (this.wait++, this.wait >= this.patience && (this.stoppedEpoch = e, this.model.stopTraining = !0))) } async onTrainEnd(e) { this.stoppedEpoch > 0 && this.verbose && console.log(`Epoch ${this.stoppedEpoch}: early stopping.`) } getMonitorValue(e) { null == e && (e = {}); const t = e[this.monitor]; return null == t && console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`), t } } const yh = { earlyStopping: function (e) { return new gh(e) } }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + var bh, vh, xh; (0, P.env)().registerFlag("KEEP_INTERMEDIATE_TENSORS", (() => !1), (e => { e && console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.") })), (vh = bh || (bh = {}))[vh.DT_INVALID = 0] = "DT_INVALID", vh[vh.DT_FLOAT = 1] = "DT_FLOAT", vh[vh.DT_DOUBLE = 2] = "DT_DOUBLE", vh[vh.DT_INT32 = 3] = "DT_INT32", vh[vh.DT_UINT8 = 4] = "DT_UINT8", vh[vh.DT_INT16 = 5] = "DT_INT16", vh[vh.DT_INT8 = 6] = "DT_INT8", vh[vh.DT_STRING = 7] = "DT_STRING", vh[vh.DT_COMPLEX64 = 8] = "DT_COMPLEX64", vh[vh.DT_INT64 = 9] = "DT_INT64", vh[vh.DT_BOOL = 10] = "DT_BOOL", vh[vh.DT_QINT8 = 11] = "DT_QINT8", vh[vh.DT_QUINT8 = 12] = "DT_QUINT8", vh[vh.DT_QINT32 = 13] = "DT_QINT32", vh[vh.DT_BFLOAT16 = 14] = "DT_BFLOAT16", vh[vh.DT_QINT16 = 15] = "DT_QINT16", vh[vh.DT_QUINT16 = 16] = "DT_QUINT16", vh[vh.DT_UINT16 = 17] = "DT_UINT16", vh[vh.DT_COMPLEX128 = 18] = "DT_COMPLEX128", vh[vh.DT_HALF = 19] = "DT_HALF", vh[vh.DT_RESOURCE = 20] = "DT_RESOURCE", vh[vh.DT_VARIANT = 21] = "DT_VARIANT", vh[vh.DT_UINT32 = 22] = "DT_UINT32", vh[vh.DT_UINT64 = 23] = "DT_UINT64", vh[vh.DT_FLOAT_REF = 101] = "DT_FLOAT_REF", vh[vh.DT_DOUBLE_REF = 102] = "DT_DOUBLE_REF", vh[vh.DT_INT32_REF = 103] = "DT_INT32_REF", vh[vh.DT_UINT8_REF = 104] = "DT_UINT8_REF", vh[vh.DT_INT16_REF = 105] = "DT_INT16_REF", vh[vh.DT_INT8_REF = 106] = "DT_INT8_REF", vh[vh.DT_STRING_REF = 107] = "DT_STRING_REF", vh[vh.DT_COMPLEX64_REF = 108] = "DT_COMPLEX64_REF", vh[vh.DT_INT64_REF = 109] = "DT_INT64_REF", vh[vh.DT_BOOL_REF = 110] = "DT_BOOL_REF", vh[vh.DT_QINT8_REF = 111] = "DT_QINT8_REF", vh[vh.DT_QUINT8_REF = 112] = "DT_QUINT8_REF", vh[vh.DT_QINT32_REF = 113] = "DT_QINT32_REF", vh[vh.DT_BFLOAT16_REF = 114] = "DT_BFLOAT16_REF", vh[vh.DT_QINT16_REF = 115] = "DT_QINT16_REF", vh[vh.DT_QUINT16_REF = 116] = "DT_QUINT16_REF", vh[vh.DT_UINT16_REF = 117] = "DT_UINT16_REF", vh[vh.DT_COMPLEX128_REF = 118] = "DT_COMPLEX128_REF", vh[vh.DT_HALF_REF = 119] = "DT_HALF_REF", vh[vh.DT_RESOURCE_REF = 120] = "DT_RESOURCE_REF", vh[vh.DT_VARIANT_REF = 121] = "DT_VARIANT_REF", vh[vh.DT_UINT32_REF = 122] = "DT_UINT32_REF", vh[vh.DT_UINT64_REF = 123] = "DT_UINT64_REF", function (e) { let t; !function (e) { e[e.LEGACY = 0] = "LEGACY", e[e.V1 = 1] = "V1", e[e.V2 = 2] = "V2" }(t = e.CheckpointFormatVersion || (e.CheckpointFormatVersion = {})) }(xh || (xh = {})); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const wh = {}; function kh(e, t) { const n = { tfOpName: e, category: "custom", inputs: [], attrs: [], customExecutor: t }; wh[e] = n } function Sh(e) { return wh[e] } function _h(e) { delete wh[e] } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Ch(e, t, n, r, i) { const a = t.inputParams[e]; if (a && void 0 !== a.inputIndexStart) { const e = a.inputIndexStart, o = 0 === a.inputIndexEnd ? void 0 : void 0 === a.inputIndexEnd ? e + 1 : a.inputIndexEnd, s = e < 0 ? t.inputNames.length + e : e; if ("tensor" === a.type) return Ah(t.inputNames[s], n, r, i); if ("tensors" === a.type) { const a = t.inputs.slice(e, o); return t.inputNames.slice(e, o).filter(((e, t) => { var n; return "NoOp" !== (null === (n = a[t]) || void 0 === n ? void 0 : n.op) })).map((e => Ah(e, n, r, i))) } const u = Ah(t.inputNames[s], n, r, i), l = u.dataSync(); return "number" === a.type ? l[0] : P.util.toNestedArray(u.shape, l) } const o = t.attrParams[e]; return o && o.value } function Ah(e, t, n, r) { const [i, a] = Ih(e, n); if (null != r) { const e = r.getHashTableHandleByName(i); if (null != e) return e } const o = n.currentContextIds.find((e => !!t[Nh(i, e)])); return void 0 !== o ? t[Nh(i, o)][a] : void 0 } function Th(e, t, n) { return t[Nh(e, n.currentContextId)] } function Eh(e, t) { const [n, r, i] = Ih(e, t); return [Nh(n, t && t.currentContextId), r, i] } function Nh(e, t) { return t ? `${e}-${t}` : e } function Ih(e, t) { if ("" === e) return ["", 0, void 0]; const n = null != t && null != t.parseNodeNameCache; if (n) { const n = t.parseNodeNameCache.get(e); if (null != n) return n } const r = e.split(":"); let i; if (1 === r.length) i = [e, 0, void 0]; else { const e = r[0], t = 3 === r.length ? r[1] : void 0; i = [e, Number(r[r.length - 1]), t] } return n && t.parseNodeNameCache.set(e, i), i } function Mh(e, t, n) { let r = Ch("pad", e, t, n); if ("explicit" === r) { r = Ch("explicitPaddings", e, t, n); const i = [[0, 0], [0, 0], [0, 0], [0, 0]]; for (let e = 0; e < 4; e++)i[e][0] = r[2 * e], i[e][1] = r[2 * e + 1]; return i } return r } function Fh(e) { return e.kept ? e : (0, P.clone)(e) } + /** + * @license + * Copyright 2023 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Dh = [{ tfOpName: "Add", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "AddV2", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "AddN", category: "arithmetic", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "BiasAdd", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "Sub", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "RealDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Div", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "DivNoNan", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "FloorDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Mul", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Maximum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Minimum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Pow", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "SquaredDifference", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Mod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "FloorMod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }], $h = [{ tfOpName: "Abs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Acos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Asin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Atan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Atan2", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Ceil", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ClipByValue", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "clipValueMin", type: "number" }, { start: 2, name: "clipValueMax", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Complex", category: "basic_math", inputs: [{ start: 0, name: "real", type: "tensor" }, { start: 1, name: "imag", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ComplexAbs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Cos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Cosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Elu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Exp", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Floor", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Log", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Imag", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: !0 }] }, { tfOpName: "Neg", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Real", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: !0 }] }, { tfOpName: "Prelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "alpha", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Relu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Relu6", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Selu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sigmoid", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Rsqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Square", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Tan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Tanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sign", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Round", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Expm1", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Log1p", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Reciprocal", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Softplus", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Asinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Acosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Atanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Erf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LeakyRelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "alpha", name: "alpha", type: "number", defaultValue: .2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "IsNan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "IsFinite", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "IsInf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }], Rh = [{ tfOpName: "EmptyTensorList", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "maxNumElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "LoopCond", category: "control", inputs: [{ start: 0, name: "pred", type: "tensor" }] }, { tfOpName: "Switch", category: "control", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "pred", type: "tensor" }] }, { tfOpName: "Merge", category: "control", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "Enter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "frame_name", name: "frameName", type: "string" }, { tfName: "is_constant", name: "isConstant", type: "bool" }] }, { tfOpName: "Exit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "NextIteration", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "TensorArrayV3", category: "control", inputs: [{ start: 0, name: "size", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "dynamic_size", name: "dynamicSize", type: "bool" }, { tfName: "clear_after_read", name: "clearAfterRead", type: "bool" }, { tfName: "identical_element_shapes", name: "identicalElementShapes", type: "bool" }, { tfName: "tensor_array_name", name: "name", type: "string" }] }, { tfOpName: "TensorArrayWriteV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "TensorArrayReadV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "TensorArrayGatherV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }] }, { tfOpName: "TensorArrayScatterV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArrayConcatV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape_except0", name: "elementShapeExcept0", type: "shape", notSupported: !0 }] }, { tfOpName: "TensorArraySplitV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }, { start: 2, name: "lengths", type: "number[]" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArraySizeV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }] }, { tfOpName: "TensorArrayCloseV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }] }, { tfOpName: "StatelessIf", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "If", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "StatelessWhile", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "While", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "TensorListScatter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListScatterV2", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }, { start: 3, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGather", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListSetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListReserve", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListFromTensor", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListStack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }, { tfName: "num_elements", name: "numElements", type: "dtype" }] }, { tfOpName: "TensorListSplit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }, { start: 2, name: "lengths", type: "number[]" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcat", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcatV2", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPopBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPushBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListLength", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }] }, { tfOpName: "TensorListResize", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "size", type: "number" }] }], Oh = [{ tfOpName: "AvgPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MaxPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [], notSupported: !0 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MaxPoolWithArgmax", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "include_batch_in_index", name: "includeBatchInIndex", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "AvgPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MaxPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Conv1D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "stride", name: "stride", type: "number" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NWC" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "dilation", name: "dilation", type: "number", defaultValue: 1 }] }, { tfOpName: "Conv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "useCudnnOnGpu", name: "useCudnnOnGpu", type: "bool" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "_FusedConv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "use_cudnn_on_gpu", name: "useCudnnOnGpu", type: "bool", defaultValue: !0 }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: .2 }] }, { tfOpName: "Conv2DBackpropInput", category: "convolution", inputs: [{ start: 2, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 0, name: "outputShape", type: "number[]" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]", notSupported: !0 }] }, { tfOpName: "DepthwiseConv2d", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "DepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "FusedDepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }] }, { tfOpName: "Conv3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "Dilation2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "rates", name: "dilations", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }] }], zh = [{ tfOpName: "Fill", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }, { start: 1, name: "value", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "LinSpace", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "num", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "OneHot", category: "creation", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "depth", type: "number" }, { start: 2, name: "onValue", type: "number", defaultValue: 1 }, { start: 3, name: "offValue", type: "number", defaultValue: 0 }], attrs: [{ tfName: "axis", name: "axis", type: "number", notSupported: !0 }, { tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Ones", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "OnesLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "RandomStandardNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: !0 }] }, { tfOpName: "RandomUniform", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "minval", name: "minval", type: "number", defaultValue: 0 }, { tfName: "maxval", name: "maxval", type: "number", defaultValue: 1 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }, { tfName: "T", name: "T", type: "number", notSupported: !0 }] }, { tfOpName: "RandomUniformInt", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "minval", name: "minval", type: "number" }, { tfName: "maxval", name: "maxval", type: "number" }, { tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }] }, { tfOpName: "Range", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "step", type: "number", defaultValue: 0 }], attrs: [{ tfName: "Tidx", name: "dtype", type: "dtype" }] }, { tfOpName: "TruncatedNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "means", name: "mean", type: "number", defaultValue: 0 }, { tfName: "stddev", name: "stdDev", type: "number", defaultValue: 1 }, { tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: !0 }] }, { tfOpName: "Zeros", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "ZerosLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Multinomial", category: "creation", inputs: [{ start: 0, name: "logits", type: "tensor" }, { start: 1, name: "numSamples", type: "number" }], attrs: [{ tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number" }, { tfName: "T", name: "dtype", type: "dtype" }, { tfName: "output_dtype", name: "output_dtype", type: "dtype" }] }], Ph = [{ tfOpName: "NonMaxSuppressionV2", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV3", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV4", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "T_threshold", name: "threshold", type: "dtype", notSupported: !0 }, { tfName: "pad_to_max_output_size", name: "padToMaxOutputSize", type: "bool" }] }, { tfOpName: "NonMaxSuppressionV5", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }, { start: 5, name: "softNmsSigma", type: "number" }] }, { tfOpName: "Where", category: "dynamic", inputs: [{ start: 0, name: "condition", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ListDiff", category: "dynamic", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }], Bh = [{ tfOpName: "LowerBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "TopKV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "k", type: "number" }], attrs: [{ tfName: "sorted", name: "sorted", type: "bool" }] }, { tfOpName: "UpperBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "Unique", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "UniqueV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }], Lh = [{ tfOpName: "PlaceholderWithDefault", category: "graph", inputs: [{ start: 0, name: "default", type: "tensor" }], attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Placeholder", category: "graph", attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Const", category: "graph" }, { tfOpName: "Identity", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IdentityN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Snapshot", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Rank", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Size", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Shape", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "ShapeN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Print", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "data", type: "tensors" }], attrs: [{ tfName: "message", name: "message", type: "string" }, { tfName: "first_n", name: "firstN", type: "number", notSupported: !0 }, { tfName: "summarize", name: "summarize", type: "number", defaultValue: 3 }] }, { tfOpName: "NoOp", category: "graph", inputs: [] }, { tfOpName: "StopGradient", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "FakeQuantWithMinMaxVars", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "min", name: "min", type: "number" }, { tfName: "max", name: "max", type: "number" }] }], jh = [{ tfOpName: "HashTable", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "HashTableV2", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "LookupTableImport", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableImportV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableFind", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableFindV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableSize", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "LookupTableSizeV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "InitializeTable", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }, { tfOpName: "InitializeTableV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }], Uh = [{ tfOpName: "ResizeBilinear", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ResizeNearestNeighbor", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "CropAndResize", category: "image", inputs: [{ start: 0, name: "image", type: "tensor" }, { start: 1, name: "boxes", type: "tensor" }, { start: 2, name: "boxInd", type: "tensor" }, { start: 3, name: "cropSize", type: "number[]" }], attrs: [{ tfName: "method", name: "method", type: "string" }, { tfName: "extrapolation_value", name: "extrapolationValue", type: "number" }] }, { tfOpName: "ImageProjectiveTransformV3", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "transforms", type: "tensor" }, { start: 2, name: "outputShape", type: "number[]" }, { start: 3, name: "fillValue", type: "number" }], attrs: [{ tfName: "interpolation", name: "interpolation", type: "string" }, { tfName: "fill_mode", name: "fillMode", type: "string" }] }], Wh = [{ tfOpName: "Equal", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "NotEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Greater", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "GreaterEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Less", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LessEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LogicalAnd", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LogicalNot", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LogicalOr", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Select", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "SelectV2", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "BitwiseAnd", category: "logical", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }] }], Vh = [{ tfOpName: "_FusedMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: .2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "BatchMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "BatchMatMulV2", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Transpose", category: "matrices", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "perm", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Einsum", category: "matrices", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "equation", name: "equation", type: "string" }, { tfName: "N", name: "n", type: "number", defaultValue: 2 }, { tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "MatrixBandPart", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "numLower", type: "tensor" }, { start: 1, name: "numUpper", type: "tensor" }] }], Gh = [{ tfOpName: "EuclideanNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", defaultValue: !1 }] }, { tfOpName: "FusedBatchNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: .001 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "FusedBatchNormV2", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: .001 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "FusedBatchNormV3", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: .001 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "LRN", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "depth_radius", name: "radius", type: "number", defaultValue: 5 }, { tfName: "bias", name: "bias", type: "number", defaultValue: 1 }, { tfName: "alpha", name: "alpha", type: "number", defaultValue: 1 }, { tfName: "beta", name: "beta", type: "number", defaultValue: .5 }] }, { tfOpName: "Softmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "LogSoftmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }], Hh = [{ tfOpName: "Bincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }] }, { tfOpName: "DenseBincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }], attrs: [{ tfName: "binary_output", name: "binaryOutput", type: "bool" }] }, { tfOpName: "Max", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Mean", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Min", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Sum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "All", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Any", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "ArgMax", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "ArgMin", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "Prod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Cumprod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }, { tfOpName: "Cumsum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }], qh = [{ tfOpName: "ConcatV2", category: "slice_join", inputs: [{ start: 0, end: -1, name: "tensors", type: "tensors" }, { start: -1, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "Concat", category: "slice_join", inputs: [{ start: 1, end: 0, name: "tensors", type: "tensors" }, { start: 0, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "GatherV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }], attrs: [{ tfName: "batch_dims", name: "batchDims", type: "number", defaultValue: 0 }] }, { tfOpName: "Gather", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", notSupported: !0 }] }, { tfOpName: "Reverse", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "dims", type: "bool[]" }] }, { tfOpName: "ReverseV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }] }, { tfOpName: "Slice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "size", type: "number[]" }] }, { tfOpName: "StridedSlice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "end", type: "number[]" }, { start: 3, name: "strides", type: "number[]" }], attrs: [{ tfName: "begin_mask", name: "beginMask", type: "number", defaultValue: 0 }, { tfName: "end_mask", name: "endMask", type: "number", defaultValue: 0 }, { tfName: "new_axis_mask", name: "newAxisMask", type: "number", defaultValue: 0 }, { tfName: "ellipsis_mask", name: "ellipsisMask", type: "number", defaultValue: 0 }, { tfName: "shrink_axis_mask", name: "shrinkAxisMask", type: "number", defaultValue: 0 }] }, { tfOpName: "Pack", category: "slice_join", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "Unpack", category: "slice_join", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }, { tfName: "num", name: "num", type: "number", defaultValue: 0, notSupported: !0 }] }, { tfOpName: "Tile", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "reps", type: "number[]" }] }, { tfOpName: "Split", category: "slice_join", inputs: [{ start: 0, name: "axis", type: "number", defaultValue: 0 }, { start: 1, name: "x", type: "tensor" }], attrs: [{ tfName: "num_split", name: "numOrSizeSplits", type: "number", defaultValue: 1 }] }, { tfOpName: "SplitV", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "numOrSizeSplits", type: "number[]" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "ScatterNd", category: "slice_join", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "shape", type: "number[]" }] }, { tfOpName: "GatherNd", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }] }, { tfOpName: "SparseToDense", category: "slice_join", inputs: [{ start: 0, name: "sparseIndices", type: "tensor" }, { start: 1, name: "outputShape", type: "number[]" }, { start: 2, name: "sparseValues", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", defaultValue: !1, notSupported: !0 }] }, { tfOpName: "TensorScatterUpdate", category: "slice_join", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }], Yh = [{ tfOpName: "SparseFillEmptyRows", category: "sparse", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "denseShape", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }] }, { tfOpName: "SparseReshape", category: "sparse", inputs: [{ start: 0, name: "inputIndices", type: "tensor" }, { start: 1, name: "inputShape", type: "tensor" }, { start: 2, name: "newShape", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "SparseSegmentMean", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }, { tfOpName: "SparseSegmentSum", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }], Xh = [{ tfOpName: "FFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "RFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: !0 }] }, { tfOpName: "IRFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: !0 }] }], Kh = [{ tfOpName: "StaticRegexReplace", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }], attrs: [{ tfName: "pattern", name: "pattern", type: "string" }, { tfName: "rewrite", name: "rewrite", type: "string" }, { tfName: "replace_global", name: "replaceGlobal", type: "bool" }] }, { tfOpName: "StringNGrams", category: "string", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "dataSplits", type: "tensor" }], attrs: [{ tfName: "separator", name: "separator", type: "string" }, { tfName: "ngram_widths", name: "nGramWidths", type: "number[]" }, { tfName: "left_pad", name: "leftPad", type: "string" }, { tfName: "right_pad", name: "rightPad", type: "string" }, { tfName: "pad_width", name: "padWidth", type: "number" }, { tfName: "preserve_short_sequences", name: "preserveShortSequences", type: "bool" }], outputs: ["ngrams", "ngrams_splits"] }, { tfOpName: "StringSplit", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "delimiter", type: "tensor" }], attrs: [{ tfName: "skip_empty", name: "skipEmpty", type: "bool" }], outputs: ["indices", "values", "shape"] }, { tfOpName: "StringToHashBucketFast", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }], attrs: [{ tfName: "num_buckets", name: "numBuckets", type: "number" }] }], Zh = [{ tfOpName: "Cast", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "SrcT", name: "sdtype", type: "dtype", notSupported: !0 }, { tfName: "DstT", name: "dtype", type: "dtype" }] }, { tfOpName: "ExpandDims", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "MirrorPad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "mode", name: "mode", type: "string" }] }, { tfOpName: "Pad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "constant_value", name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "PadV2", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }, { start: 2, name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "Reshape", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }] }, { tfOpName: "EnsureShape", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }] }, { tfOpName: "Squeeze", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "axis", tfDeprecatedName: "squeeze_dims", name: "axis", type: "number[]" }] }, { tfOpName: "SpaceToBatchND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "paddings", type: "number[]" }] }, { tfOpName: "BatchToSpaceND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "crops", type: "number[]" }] }, { tfOpName: "DepthToSpace", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "block_size", name: "blockSize", type: "number" }, { tfName: "data_format", name: "dataFormat", type: "string" }] }, { tfOpName: "BroadcastTo", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }], attrs: [] }, { tfOpName: "BroadcastArgs", category: "transformation", inputs: [{ start: 0, name: "s0", type: "tensor" }, { start: 1, name: "s1", type: "tensor" }], attrs: [] }]; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Jh { static get Instance() { return this._instance || (this._instance = new this) } constructor() { const e = [].concat(...[u, l, c, h, d, f, p, m, g, y, b, v, x, w, k, S, _, C, A].map((e => e.json))); this.opMappers = e.reduce(((e, t) => (e[t.tfOpName] = t, e)), {}) } transformGraph(e, t = {}) { const n = e.node, r = [], i = [], a = [], o = n.reduce(((e, t) => (e[t.name] = this.mapNode(t), t.op.startsWith("Placeholder") ? r.push(e[t.name]) : "Const" === t.op ? i.push(e[t.name]) : null != t.input && 0 !== t.input.length || a.push(e[t.name]), e)), {}); let s = []; const u = []; let l = {}, c = {}; null != t && (l = this.mapSignatureEntries(t.inputs), c = this.mapSignatureEntries(t.outputs)); const h = Object.keys(o); h.forEach((e => { const t = o[e]; t.inputNames.forEach(((e, n) => { const [r, , i] = Eh(e), a = o[r]; if (null != a.outputs) { const e = a.outputs.indexOf(i); if (-1 !== e) { const i = `${r}:${e}`; t.inputNames[n] = i } } t.inputs.push(a), a.children.push(t) })) })), 0 === Object.keys(c).length ? h.forEach((e => { const t = o[e]; 0 === t.children.length && u.push(t) })) : Object.keys(c).forEach((e => { const [t] = Eh(e), n = o[t]; null != n && (n.signatureKey = c[e], u.push(n)) })), Object.keys(l).length > 0 ? Object.keys(l).forEach((e => { const [t] = Eh(e), n = o[t]; n && (n.signatureKey = l[e], s.push(n)) })) : s = r; let d = {}; null != e.library && null != e.library.function && (d = e.library.function.reduce(((e, t) => (e[t.signature.name] = this.mapFunction(t), e)), {})); const f = { nodes: o, inputs: s, outputs: u, weights: i, placeholders: r, signature: t, functions: d }; return a.length > 0 && (f.initNodes = a), f } mapSignatureEntries(e) { return Object.keys(e || {}).reduce(((t, n) => (t[e[n].name] = n, t)), {}) } mapNode(e) { const t = Sh(e.op) || this.opMappers[e.op] || {}; null == e.attr && (e.attr = {}); const n = { name: e.name, op: e.op, category: t.category, inputNames: (e.input || []).map((e => e.startsWith("^") ? e.slice(1) : e)), inputs: [], children: [], inputParams: {}, attrParams: {}, rawAttrs: e.attr, outputs: t.outputs }; return null != t.inputs && (n.inputParams = t.inputs.reduce(((e, t) => (e[t.name] = { type: t.type, inputIndexStart: t.start, inputIndexEnd: t.end }, e)), {})), null != t.attrs && (n.attrParams = t.attrs.reduce(((t, n) => { const r = n.type; let i; switch (n.type) { case "string": i = ed(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ed(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "string[]": i = cd(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = cd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "number": i = nd(e.attr, n.tfName, n.defaultValue || 0), void 0 === i && n.tfDeprecatedName && (i = nd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "number[]": i = ld(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ld(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "bool": i = td(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = td(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "bool[]": i = dd(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = dd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "shape": i = ud(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ud(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "shape[]": i = hd(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = hd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "dtype": i = ad(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ad(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "dtype[]": i = od(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = od(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "func": i = id(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = id(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "tensor": case "tensors": break; default: throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`) }return t[n.name] = { value: i, type: r }, t }), {})), n } mapFunction(e) { const t = e.nodeDef, n = []; let r = {}; null != t && (r = t.reduce(((e, t) => (e[t.name] = this.mapNode(t), "Const" === t.op && n.push(e[t.name]), e)), {})); const i = [], a = []; e.signature.inputArg.forEach((e => { const [t] = Eh(e.name), n = { name: t, op: "Placeholder", inputs: [], inputNames: [], category: "graph", inputParams: {}, attrParams: { dtype: { value: rd(e.type), type: "dtype" } }, children: [] }; n.signatureKey = e.name, i.push(n), r[t] = n })); Object.keys(r).forEach((e => { const t = r[e]; t.inputNames.forEach(((e, n) => { const [i, , a] = Eh(e), o = r[i]; if (null != o.outputs) { const e = o.outputs.indexOf(a); if (-1 !== e) { const r = `${i}:${e}`; t.inputNames[n] = r } } t.inputs.push(o), o.children.push(t) })) })); const o = e.ret; e.signature.outputArg.forEach((e => { const [t, n] = Eh(o[e.name]), i = r[t]; null != i && (i.defaultOutput = n, a.push(i)) })); const s = this.mapArgsToSignature(e); return { nodes: r, inputs: i, outputs: a, weights: n, placeholders: [], signature: s } } mapArgsToSignature(e) { return { methodName: e.signature.name, inputs: e.signature.inputArg.reduce(((e, t) => (e[t.name] = this.mapArgToTensorInfo(t), e)), {}), outputs: e.signature.outputArg.reduce(((t, n) => (t[n.name] = this.mapArgToTensorInfo(n, e.ret), t)), {}) } } mapArgToTensorInfo(e, t) { let n = e.name; return null != t && (n = t[n]), { name: n, dtype: e.type } } } function Qh(e, t) { const n = Array.isArray(e) ? String.fromCharCode.apply(null, e) : function (e) { const t = (0, P.env)().global; if (void 0 !== t.atob) return t.atob(e); if ("undefined" != typeof Buffer) return new Buffer(e, "base64").toString(); throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()") }(e); return t ? n : n.toLowerCase() } function ed(e, t, n, r = !1) { const i = e[t]; return null != i ? Qh(i.s, r) : n } function td(e, t, n) { const r = e[t]; return r ? r.b : n } function nd(e, t, n) { const r = e[t] || {}, i = null != r.i ? r.i : null != r.f ? r.f : n; return "number" == typeof i ? i : parseInt(i, 10) } function rd(e) { switch ("string" == typeof e && (e = bh[e]), e) { case bh.DT_FLOAT: case bh.DT_HALF: return "float32"; case bh.DT_INT32: case bh.DT_INT64: case bh.DT_INT8: case bh.DT_UINT8: return "int32"; case bh.DT_BOOL: return "bool"; case bh.DT_DOUBLE: return "float32"; case bh.DT_STRING: return "string"; case bh.DT_COMPLEX64: case bh.DT_COMPLEX128: return "complex64"; default: return null } } function id(e, t, n) { const r = e[t]; return r && r.func ? r.func.name : n } function ad(e, t, n) { const r = e[t]; return r && r.type ? rd(r.type) : n } function od(e, t, n) { const r = e[t]; return r && r.list && r.list.type ? r.list.type.map((e => rd(e))) : n } function sd(e) { if (!e.unknownRank) return null != e.dim ? e.dim.map((e => "number" == typeof e.size ? e.size : parseInt(e.size, 10))) : [] } function ud(e, t, n) { const r = e[t]; return r && r.shape ? sd(r.shape) : n } function ld(e, t, n) { const r = e[t]; return r ? ((r.list.f && r.list.f.length ? r.list.f : r.list.i) || []).map((e => "number" == typeof e ? e : parseInt(e, 10))) : n } function cd(e, t, n, r = !1) { const i = e[t]; return i && i.list && i.list.s ? i.list.s.map((e => Qh(e, r))) : n } function hd(e, t, n) { const r = e[t]; return r && r.list && r.list.shape ? r.list.shape.map((e => sd(e))) : n } function dd(e, t, n) { const r = e[t]; return r && r.list && r.list.b ? r.list.b : n } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class fd { constructor(e, t, n) { this.node = e, this.tensorMap = t, this.context = n, this.inputs = [], this.attrs = {}, this.inputs = e.inputNames.map((e => this.getInput(e))), null != e.rawAttrs && (this.attrs = Object.keys(e.rawAttrs).reduce(((e, t) => (e[t] = this.getAttr(t), e)), {})) } getInput(e) { return Ah(e, this.tensorMap, this.context) } getAttr(e, t) { const n = this.node.rawAttrs[e]; if (null != n.tensor) return Ah(e, this.tensorMap, this.context); if (null != n.i || null != n.f) return nd(this.node.rawAttrs, e, t); if (null != n.s) return ed(this.node.rawAttrs, e, t); if (null != n.b) return td(this.node.rawAttrs, e, t); if (null != n.shape) return ud(this.node.rawAttrs, e, t); if (null != n.type) return ad(this.node.rawAttrs, e, t); if (null != n.list) { if (null != n.list.i || null != n.list.f) return ld(this.node.rawAttrs, e, t); if (null != n.list.s) return cd(this.node.rawAttrs, e, t); if (null != n.list.shape) return hd(this.node.rawAttrs, e, t); if (null != n.list.b) return dd(this.node.rawAttrs, e, t); if (null != n.list.type) return od(this.node.rawAttrs, e, t) } return t } } var pd = n(7270); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function md(e, t, n = "") { if ("number" != typeof e && "number" != typeof t) { P.util.assert(e.length === t.length, (() => n + ` Shapes ${e} and ${t} must match`)); for (let r = 0; r < e.length; r++) { const i = e[r], a = t[r]; P.util.assert(i < 0 || a < 0 || i === a, (() => n + ` Shapes ${e} and ${t} must match`)) } } } function gd(e) { return "number" != typeof e && !e.some((e => e < 0)) } function yd(e, t, n) { let r = bd(e, n); const i = !gd(r); if (i && 0 === t.length) throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`); if (i && t.forEach((e => { r = bd(e.shape, r) })), !gd(r)) throw new Error(`Non-fully-defined elementShape: ${r}`); return r } function bd(e, t) { if ("number" == typeof e) return t; if ("number" == typeof t) return e; if (e.length !== t.length) throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`); const n = []; for (let r = 0; r < e.length; ++r) { const i = e[r], a = t[r]; if (i >= 0 && a >= 0 && i !== a) throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`); n[r] = i >= 0 ? i : a } return n } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class vd { constructor(e, t, n, r, i, a, o) { this.name = e, this.dtype = t, this.maxSize = n, this.elementShape = r, this.identicalElementShapes = i, this.dynamicSize = a, this.clearAfterRead = o, this.tensors = [], this.closed_ = !1, this.idTensor = (0, P.scalar)(0), (0, P.keep)(this.idTensor) } get id() { return this.idTensor.id } get closed() { return this.closed_ } clearAndClose(e) { this.tensors.forEach((t => { null != e && e.has(t.tensor.id) || t.tensor.dispose() })), this.tensors = [], this.closed_ = !0, this.idTensor.dispose() } size() { return this.tensors.length } read(e) { if (this.closed_) throw new Error(`TensorArray ${this.name} has already been closed.`); if (e < 0 || e >= this.size()) throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`); const t = this.tensors[e]; if (t.cleared) throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`); return this.clearAfterRead && (t.cleared = !0), t.read = !0, t.tensor } readMany(e) { return e.map((e => this.read(e))) } write(e, t) { if (this.closed_) throw new Error(`TensorArray ${this.name} has already been closed.`); if (e < 0 || !this.dynamicSize && e >= this.maxSize) throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`); const n = this.tensors[e] || {}; if (t.dtype !== this.dtype) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`); if (0 !== this.size() || null != this.elementShape && 0 !== this.elementShape.length || (this.elementShape = t.shape), md(this.elementShape, t.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${e}.`), n.read) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`); if (n.written) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`); n.tensor = t, (0, P.keep)(t), n.written = !0, this.tensors[e] = n } writeMany(e, t) { if (e.length !== t.length) throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`); e.forEach(((e, n) => this.write(e, t[n]))) } gather(e, t) { if (t && t !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`); if (e) e = e.slice(0, this.size()); else { e = []; for (let t = 0; t < this.size(); t++)e.push(t) } if (0 === e.length) return (0, P.tensor)([], [0].concat(this.elementShape)); const n = this.readMany(e); return md(this.elementShape, n[0].shape, "TensorArray shape mismatch: "), (0, P.stack)(n, 0) } concat(e) { if (e && e !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`); if (0 === this.size()) return (0, P.tensor)([], [0].concat(this.elementShape)); const t = []; for (let e = 0; e < this.size(); e++)t.push(e); const n = this.readMany(t); return md(this.elementShape, n[0].shape, `TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`), (0, P.concat)(n, 0) } scatter(e, t) { if (t.dtype !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`); if (e.length !== t.shape[0]) throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`); const n = Math.max(...e); if (!this.dynamicSize && n >= this.maxSize) throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`); this.writeMany(e, (0, P.unstack)(t, 0)) } split(e, t) { if (t.dtype !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`); let n = 0; const r = e.map((e => (n += e, n))); if (n !== t.shape[0]) throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`); if (!this.dynamicSize && e.length !== this.maxSize) throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`); const i = 0 === n ? 0 : t.size / n, a = []; (0, P.tidy)((() => { t = (0, P.reshape)(t, [1, n, i]); for (let n = 0; n < e.length; ++n) { const o = [0, 0 === n ? 0 : r[n - 1], 0], s = [1, e[n], i]; a[n] = (0, P.reshape)((0, P.slice)(t, o, s), this.elementShape) } return a })); const o = []; for (let t = 0; t < e.length; t++)o[t] = t; this.writeMany(o, a) } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class xd { get id() { return this.idTensor.id } constructor(e, t, n, r = -1) { this.tensors = e, this.elementShape = t, this.elementDtype = n, null != e && e.forEach((e => { if (n !== e.dtype) throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`); md(t, e.shape, "TensorList shape mismatch: "), (0, P.keep)(e) })), this.idTensor = (0, P.scalar)(0), this.maxNumElements = r, (0, P.keep)(this.idTensor) } copy() { return new xd([...this.tensors], this.elementShape, this.elementDtype) } clearAndClose(e) { this.tensors.forEach((t => { null != e && e.has(t.id) || t.dispose() })), this.tensors.length = 0, this.idTensor.dispose() } size() { return this.tensors.length } stack(e, t, n = -1) { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); if (-1 !== n && this.tensors.length !== n) throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`); md(e, this.elementShape, "TensorList shape mismatch: "); const r = yd(this.elementShape, this.tensors, e); return (0, P.tidy)((() => { const e = this.tensors.map((e => (0, P.reshape)(e, r))); return (0, P.stack)(e, 0) })) } popBack(e, t) { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); if (0 === this.size()) throw new Error("Trying to pop from an empty list."); const n = yd(this.elementShape, this.tensors, e), r = this.tensors.pop(); return r.kept = !1, md(r.shape, e, "TensorList shape mismatch: "), (0, P.reshape)(r, n) } pushBack(e) { if (e.dtype !== this.elementDtype) throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`); if (md(e.shape, this.elementShape, "TensorList shape mismatch: "), this.maxNumElements === this.size()) throw new Error("Trying to push element into a full list."); (0, P.keep)(e), this.tensors.push(e) } resize(e) { if (e < 0) throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`); if (-1 !== this.maxNumElements && e > this.maxNumElements) throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`); const t = new xd([], this.elementShape, this.elementDtype, this.maxNumElements); t.tensors.length = e; for (let n = 0; n < Math.min(this.tensors.length, e); ++n)t.tensors[n] = this.tensors[n]; return t } getItem(e, t, n) { if (n !== this.elementDtype) throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`); if (e < 0 || e > this.tensors.length) throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`); if (null == this.tensors[e]) throw new Error(`element at index ${e} is null.`); md(this.tensors[e].shape, t, "TensorList shape mismatch: "); const r = yd(this.elementShape, this.tensors, t); return (0, P.reshape)(this.tensors[e], r) } setItem(e, t) { if (t.dtype !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`); if (e < 0 || -1 !== this.maxNumElements && e >= this.maxNumElements) throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`); md(this.elementShape, t.shape, "TensorList shape mismatch: "), (0, P.keep)(t), null != this.tensors[e] && (this.tensors[e].kept = !1), this.tensors[e] = t } gather(e, t, n) { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); md(this.elementShape, n, "TensorList shape mismatch: "), e = e.slice(0, this.size()); const r = yd(this.elementShape, this.tensors, n); return 0 === e.length ? (0, P.tensor)([], [0].concat(r)) : (0, P.tidy)((() => { const t = e.map((e => (0, P.reshape)(this.tensors[e], r))); return (0, P.stack)(t, 0) })) } concat(e, t) { if (e && e !== this.elementDtype) throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`); md(this.elementShape, t, "TensorList shape mismatch: "); const n = yd(this.elementShape, this.tensors, t); return 0 === this.size() ? (0, P.tensor)([], [0].concat(n)) : (0, P.tidy)((() => { const e = this.tensors.map((e => (0, P.reshape)(e, n))); return (0, P.concat)(e, 0) })) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const wd = async (e, t, n) => { switch (e.op) { case "If": case "StatelessIf": { const r = Ch("thenBranch", e, t, n), i = Ch("elseBranch", e, t, n), a = Ch("cond", e, t, n), o = Ch("args", e, t, n); return (await a.data())[0] ? n.functionMap[r].executeFunctionAsync(o, n.tensorArrayMap, n.tensorListMap) : n.functionMap[i].executeFunctionAsync(o, n.tensorArrayMap, n.tensorListMap) } case "While": case "StatelessWhile": { const r = Ch("body", e, t, n), i = Ch("cond", e, t, n), a = Ch("args", e, t, n), o = await n.functionMap[i].executeFunctionAsync(a, n.tensorArrayMap, n.tensorListMap), s = a.map((e => e.id)); let u = await o[0].data(); o.forEach((e => { e.kept || -1 !== s.indexOf(e.id) || e.dispose() })); let l = a; for (; u[0];) { const e = l; l = await n.functionMap[r].executeFunctionAsync(l, n.tensorArrayMap, n.tensorListMap); const t = l.map((e => e.id)); e.forEach((e => { e.kept || -1 !== s.indexOf(e.id) || -1 !== t.indexOf(e.id) || e.dispose() })); const a = await n.functionMap[i].executeFunctionAsync(l, n.tensorArrayMap, n.tensorListMap); u = await a[0].data(), a.forEach((e => { e.kept || -1 !== s.indexOf(e.id) || -1 !== t.indexOf(e.id) || e.dispose() })) } return l } case "LoopCond": return [Fh(Ch("pred", e, t, n))]; case "Switch": { const r = Ch("pred", e, t, n); let i = Ch("data", e, t, n); return i.kept || (i = Fh(i)), (await r.data())[0] ? [void 0, i] : [i, void 0] } case "Merge": { const r = e.inputNames.find((e => void 0 !== Ah(e, t, n))); if (r) { return [Fh(Ah(r, t, n))] } return } case "Enter": { const r = Ch("frameName", e, t, n), i = Ch("tensor", e, t, n); return n.enterFrame(r), [Fh(i)] } case "Exit": { const r = Ch("tensor", e, t, n); return n.exitFrame(), [Fh(r)] } case "NextIteration": { const r = Ch("tensor", e, t, n); return n.nextIteration(), [Fh(r)] } case "TensorArrayV3": { const r = Ch("size", e, t, n), i = Ch("dtype", e, t, n), a = Ch("elementShape", e, t, n), o = Ch("dynamicSize", e, t, n), s = Ch("clearAfterRead", e, t, n), u = Ch("identicalElementShapes", e, t, n), l = Ch("name", e, t, n), c = new vd(l, i, r, a, u, o, s); return n.addTensorArray(c), [c.idTensor, (0, P.scalar)(1)] } case "TensorArrayWriteV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("index", e, t, n), a = Ch("tensor", e, t, n), o = n.getTensorArray(r.id); return o.write(i, a), [o.idTensor] } case "TensorArrayReadV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("index", e, t, n); return [n.getTensorArray(r.id).read(i)] } case "TensorArrayGatherV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("indices", e, t, n), a = Ch("dtype", e, t, n); return [n.getTensorArray(r.id).gather(i, a)] } case "TensorArrayScatterV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("indices", e, t, n), a = Ch("tensor", e, t, n), o = n.getTensorArray(r.id); return o.scatter(i, a), [o.idTensor] } case "TensorArrayConcatV3": { const r = Ch("tensorArrayId", e, t, n), i = n.getTensorArray(r.id), a = Ch("dtype", e, t, n); return [i.concat(a)] } case "TensorArraySplitV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("tensor", e, t, n), a = Ch("lengths", e, t, n), o = n.getTensorArray(r.id); return o.split(a, i), [o.idTensor] } case "TensorArraySizeV3": { const r = Ch("tensorArrayId", e, t, n), i = n.getTensorArray(r.id); return [(0, P.scalar)(i.size(), "int32")] } case "TensorArrayCloseV3": { const r = Ch("tensorArrayId", e, t, n), i = n.getTensorArray(r.id); return i.clearAndClose(), [i.idTensor] } case "TensorListSetItem": { const r = Ch("tensorListId", e, t, n), i = Ch("index", e, t, n), a = Ch("tensor", e, t, n), o = n.getTensorList(r.id); return o.setItem(i, a), [o.idTensor] } case "TensorListGetItem": { const r = Ch("tensorListId", e, t, n), i = Ch("index", e, t, n), a = Ch("elementShape", e, t, n), o = Ch("elementDType", e, t, n); return [n.getTensorList(r.id).getItem(i, a, o)] } case "TensorListScatterV2": case "TensorListScatter": { const r = Ch("indices", e, t, n), i = function (e, t, n, r) { if (t.length !== e.shape[0]) throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`); const i = Math.max(...t); if (null != r && -1 !== r && i >= r) throw new Error(`Max index must be < array size (${i} vs. ${r})`); const a = new xd([], n, e.dtype, r), o = (0, P.unstack)(e, 0); return t.forEach(((e, t) => { a.setItem(e, o[t]) })), a }(Ch("tensor", e, t, n), r, Ch("elementShape", e, t, n), Ch("numElements", e, t, n)); return n.addTensorList(i), [i.idTensor] } case "TensorListReserve": case "EmptyTensorList": { const r = Ch("elementShape", e, t, n), i = Ch("elementDType", e, t, n); let a; a = "TensorListReserve" === e.op ? "numElements" : "maxNumElements"; const o = Ch(a, e, t, n), s = function (e, t, n, r) { return new xd([], e, t, r) }(r, i, 0, "TensorListReserve" === e.op ? -1 : o); return n.addTensorList(s), [s.idTensor] } case "TensorListGather": { const r = Ch("tensorListId", e, t, n), i = Ch("indices", e, t, n), a = Ch("elementShape", e, t, n), o = Ch("elementDType", e, t, n); return [n.getTensorList(r.id).gather(i, o, a)] } case "TensorListStack": { const r = Ch("tensorListId", e, t, n), i = Ch("elementShape", e, t, n), a = Ch("elementDType", e, t, n), o = Ch("numElements", e, t, n); return [n.getTensorList(r.id).stack(i, a, o)] } case "TensorListFromTensor": { const r = function (e, t, n) { const r = e.dtype; if (e.shape.length < 1) throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`); if (e.dtype !== n) throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`); md(e.shape.slice(1), t, "TensorList shape mismatch: "); const i = (0, P.unstack)(e); return new xd(i, t, r) }(Ch("tensor", e, t, n), Ch("elementShape", e, t, n), Ch("elementDType", e, t, n)); return n.addTensorList(r), [r.idTensor] } case "TensorListConcat": case "TensorListConcatV2": { const r = Ch("tensorListId", e, t, n), i = n.getTensorList(r.id), a = Ch("dtype", e, t, n), o = Ch("elementShape", e, t, n); return [i.concat(a, o)] } case "TensorListPushBack": { const r = Ch("tensorListId", e, t, n), i = Ch("tensor", e, t, n), a = n.getTensorList(r.id); return a.pushBack(i), [a.idTensor] } case "TensorListPopBack": { const r = Ch("tensorListId", e, t, n), i = Ch("elementShape", e, t, n), a = Ch("elementDType", e, t, n); return [n.getTensorList(r.id).popBack(i, a)] } case "TensorListSplit": { const r = Ch("tensor", e, t, n), i = Ch("elementShape", e, t, n), a = function (e, t, n) { let r = 0; const i = t.map((e => (r += e, r))); if (r !== e.shape[0]) throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`); const a = bd(e.shape.slice(1), n), o = 0 === r ? 0 : e.size / r, s = (0, P.tidy)((() => { const n = []; e = (0, P.reshape)(e, [1, r, o]); for (let r = 0; r < t.length; ++r) { const s = [0, 0 === r ? 0 : i[r - 1], 0], u = [1, t[r], o]; n[r] = (0, P.reshape)((0, P.slice)(e, s, u), a) } return e.dispose(), n })), u = new xd([], n, e.dtype, t.length); for (let e = 0; e < s.length; e++)u.setItem(e, s[e]); return u }(r, Ch("lengths", e, t, n), i); return n.addTensorList(a), [a.idTensor] } case "TensorListLength": { const r = Ch("tensorListId", e, t, n), i = n.getTensorList(r.id); return [(0, P.scalar)(i.size(), "int32")] } case "TensorListResize": { const r = Ch("tensorListId", e, t, n), i = Ch("size", e, t, n), a = n.getTensorList(r.id).resize(i); return n.addTensorList(a), [a.idTensor] } default: throw TypeError(`Node type ${e.op} is not implemented`) } }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function kd(e, t, n) { const [r, i] = Ch("fusedOps", e, t, n), a = "biasadd" === r, o = !a, s = "prelu" === i, u = "fusedbatchnorm" === r, l = Ch("numArgs", e, t, n); if (a) { if (s && 2 !== l) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha."); if (!s && a && 1 !== l) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.") } if (u) throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported"); const c = Ch("strides", e, t, n), h = Mh(e, t, n), d = Ch("dataFormat", e, t, n).toUpperCase(), f = Ch("dilations", e, t, n); let [p, m] = Ch("args", e, t, n); o && (m = p, p = void 0); return { stride: c, pad: h, dataFormat: d, dilations: f, biasArg: p, preluArg: m, activationFunc: i, leakyreluAlpha: Ch("leakyreluAlpha", e, t, n) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Sd(e, t, n) { return { boxes: Ch("boxes", e, t, n), scores: Ch("scores", e, t, n), maxOutputSize: Ch("maxOutputSize", e, t, n), iouThreshold: Ch("iouThreshold", e, t, n), scoreThreshold: Ch("scoreThreshold", e, t, n), softNmsSigma: Ch("softNmsSigma", e, t, n) } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class _d { get id() { return this.handle.id } constructor(e, t) { this.keyDType = e, this.valueDType = t, this.handle = (0, P.scalar)(0), this.tensorMap = new Map, (0, P.keep)(this.handle) } clearAndClose() { this.tensorMap.forEach((e => e.dispose())), this.tensorMap.clear(), this.handle.dispose() } size() { return this.tensorMap.size } tensorSize() { return H.d(this.size(), "int32") } async import(e, t) { this.checkKeyAndValueTensor(e, t); const n = await e.data(); return this.tensorMap.forEach((e => e.dispose())), this.tensorMap.clear(), (0, P.tidy)((() => { const e = (0, P.unstack)(t), r = n.length, i = e.length; P.util.assert(r === i, (() => `The number of elements doesn't match, keys has ${r} elements, the values has ${i} elements.`)); for (let t = 0; t < r; t++) { const r = n[t], i = e[t]; (0, P.keep)(i), this.tensorMap.set(r, i) } return this.handle })) } async find(e, t) { this.checkKeyAndValueTensor(e, t); const n = await e.data(); return (0, P.tidy)((() => { const e = []; for (let r = 0; r < n.length; r++) { const i = n[r], a = this.findWithDefault(i, t); e.push(a) } return (0, P.stack)(e) })) } findWithDefault(e, t) { const n = this.tensorMap.get(e); return null != n ? n : t } checkKeyAndValueTensor(e, t) { if (e.dtype !== this.keyDType) throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`); if (t.dtype !== this.valueDType) throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Cd(e, t, n, r, i = P.tidy) { const a = ((e, t, n) => { switch (e.category) { case "arithmetic": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "BiasAdd": case "AddV2": case "Add": return [r.add(Ch("a", e, t, n), Ch("b", e, t, n))]; case "AddN": return [r.addN(Ch("tensors", e, t, n))]; case "FloorMod": case "Mod": return [r.mod(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Mul": return [r.mul(Ch("a", e, t, n), Ch("b", e, t, n))]; case "RealDiv": case "Div": return [r.div(Ch("a", e, t, n), Ch("b", e, t, n))]; case "DivNoNan": return [r.divNoNan(Ch("a", e, t, n), Ch("b", e, t, n))]; case "FloorDiv": return [r.floorDiv(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Sub": return [r.sub(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Minimum": return [r.minimum(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Maximum": return [r.maximum(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Pow": return [r.pow(Ch("a", e, t, n), Ch("b", e, t, n))]; case "SquaredDifference": return [r.squaredDifference(Ch("a", e, t, n), Ch("b", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "basic_math": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Abs": case "ComplexAbs": return [r.abs(Ch("x", e, t, n))]; case "Acos": return [r.acos(Ch("x", e, t, n))]; case "Acosh": return [r.acosh(Ch("x", e, t, n))]; case "Asin": return [r.asin(Ch("x", e, t, n))]; case "Asinh": return [r.asinh(Ch("x", e, t, n))]; case "Atan": return [r.atan(Ch("x", e, t, n))]; case "Atan2": return [r.atan2(Ch("x", e, t, n), Ch("y", e, t, n))]; case "Atanh": return [r.atanh(Ch("x", e, t, n))]; case "Ceil": return [r.ceil(Ch("x", e, t, n))]; case "Complex": return [r.complex(Ch("real", e, t, n), Ch("imag", e, t, n))]; case "Cos": return [r.cos(Ch("x", e, t, n))]; case "Cosh": return [r.cosh(Ch("x", e, t, n))]; case "Elu": return [r.elu(Ch("x", e, t, n))]; case "Erf": return [r.erf(Ch("x", e, t, n))]; case "Exp": return [r.exp(Ch("x", e, t, n))]; case "Expm1": return [r.expm1(Ch("x", e, t, n))]; case "Floor": return [r.floor(Ch("x", e, t, n))]; case "Log": return [r.log(Ch("x", e, t, n))]; case "Log1p": return [r.log1p(Ch("x", e, t, n))]; case "Imag": return [r.imag(Ch("x", e, t, n))]; case "Neg": return [r.neg(Ch("x", e, t, n))]; case "Reciprocal": return [r.reciprocal(Ch("x", e, t, n))]; case "Real": return [r.real(Ch("x", e, t, n))]; case "Relu": return [r.relu(Ch("x", e, t, n))]; case "Round": return [r.round(Ch("x", e, t, n))]; case "Selu": return [r.selu(Ch("x", e, t, n))]; case "Sigmoid": return [r.sigmoid(Ch("x", e, t, n))]; case "Sin": return [r.sin(Ch("x", e, t, n))]; case "Sign": return [r.sign(Ch("x", e, t, n))]; case "Sinh": return [r.sinh(Ch("x", e, t, n))]; case "Softplus": return [r.softplus(Ch("x", e, t, n))]; case "Sqrt": return [r.sqrt(Ch("x", e, t, n))]; case "Square": return [r.square(Ch("x", e, t, n))]; case "Tanh": return [r.tanh(Ch("x", e, t, n))]; case "Tan": return [r.tan(Ch("x", e, t, n))]; case "ClipByValue": return [r.clipByValue(Ch("x", e, t, n), Ch("clipValueMin", e, t, n), Ch("clipValueMax", e, t, n))]; case "Relu6": return [r.relu6(Ch("x", e, t, n))]; case "Rsqrt": return [r.rsqrt(Ah(e.inputNames[0], t, n))]; case "LeakyRelu": return [r.leakyRelu(Ch("x", e, t, n), Ch("alpha", e, t, n))]; case "Prelu": return [r.prelu(Ch("x", e, t, n), Ch("alpha", e, t, n))]; case "IsNan": return [r.isNaN(Ah(e.inputNames[0], t, n))]; case "IsInf": return [r.isInf(Ah(e.inputNames[0], t, n))]; case "IsFinite": return [r.isFinite(Ah(e.inputNames[0], t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "control": return wd(e, t, n); case "convolution": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Conv1D": { const i = Ch("stride", e, t, n), a = Ch("pad", e, t, n), o = Ch("dataFormat", e, t, n).toUpperCase(), s = Ch("dilation", e, t, n); return [r.conv1d(Ch("x", e, t, n), Ch("filter", e, t, n), i, a, o, s)] } case "Conv2D": { const i = Ch("strides", e, t, n), a = Mh(e, t, n), o = Ch("dataFormat", e, t, n).toUpperCase(), s = Ch("dilations", e, t, n); return [r.conv2d(Ch("x", e, t, n), Ch("filter", e, t, n), [i[1], i[2]], a, o, [s[1], s[2]])] } case "_FusedConv2D": { const { stride: i, pad: a, dataFormat: o, dilations: s, biasArg: u, preluArg: l, activationFunc: c, leakyreluAlpha: h } = kd(e, t, n); return [r.fused.conv2d({ x: Ch("x", e, t, n), filter: Ch("filter", e, t, n), strides: [i[1], i[2]], pad: a, dataFormat: o, dilations: [s[1], s[2]], bias: u, activation: c, preluActivationWeights: l, leakyreluAlpha: h })] } case "FusedDepthwiseConv2dNative": { const { stride: i, pad: a, dataFormat: o, dilations: s, biasArg: u, preluArg: l, activationFunc: c, leakyreluAlpha: h } = kd(e, t, n); return [r.fused.depthwiseConv2d({ x: Ch("x", e, t, n), filter: Ch("filter", e, t, n), strides: [i[1], i[2]], pad: a, dataFormat: o, dilations: [s[1], s[2]], bias: u, activation: c, preluActivationWeights: l, leakyreluAlpha: h })] } case "Conv2DBackpropInput": case "Conv2dTranspose": { const i = Ch("outputShape", e, t, n), a = Ch("strides", e, t, n), o = Mh(e, t, n); return [r.conv2dTranspose(Ch("x", e, t, n), Ch("filter", e, t, n), i, [a[1], a[2]], o)] } case "DepthwiseConv2dNative": case "DepthwiseConv2d": { const i = Ch("strides", e, t, n), a = Mh(e, t, n), o = Ch("dilations", e, t, n), s = Ch("dataFormat", e, t, n).toUpperCase(); return [r.depthwiseConv2d(Ch("input", e, t, n), Ch("filter", e, t, n), [i[1], i[2]], a, s, [o[1], o[2]])] } case "Conv3D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("dataFormat", e, t, n).toUpperCase(), s = Ch("dilations", e, t, n); return [r.conv3d(Ch("x", e, t, n), Ch("filter", e, t, n), [i[1], i[2], i[3]], a, o, [s[1], s[2], s[3]])] } case "AvgPool": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.avgPool(Ch("x", e, t, n), [o[1], o[2]], [i[1], i[2]], a)] } case "MaxPool": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.maxPool(Ch("x", e, t, n), [o[1], o[2]], [i[1], i[2]], a)] } case "MaxPoolWithArgmax": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n), s = Ch("includeBatchInIndex", e, t, n), { result: u, indexes: l } = r.maxPoolWithArgmax(Ch("x", e, t, n), [o[1], o[2]], [i[1], i[2]], a, s); return [u, l] } case "AvgPool3D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.avgPool3d(Ch("x", e, t, n), [o[1], o[2], o[3]], [i[1], i[2], i[3]], a)] } case "MaxPool3D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.maxPool3d(Ch("x", e, t, n), [o[1], o[2], o[3]], [i[1], i[2], i[3]], a)] } case "Dilation2D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("dilations", e, t, n), s = i[1], u = i[2], l = o[1], c = o[2]; return [r.dilation2d(Ch("x", e, t, n), Ch("filter", e, t, n), [s, u], a, [l, c], "NHWC")] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "creation": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Fill": { const i = Ch("shape", e, t, n), a = Ch("dtype", e, t, n), o = Ch("value", e, t, n); return [r.fill(i, o, a)] } case "LinSpace": { const i = Ch("start", e, t, n), a = Ch("stop", e, t, n), o = Ch("num", e, t, n); return [r.linspace(i, a, o)] } case "Multinomial": { const i = Ch("logits", e, t, n), a = Ch("numSamples", e, t, n), o = Ch("seed", e, t, n); return [r.multinomial(i, a, o)] } case "OneHot": { const i = Ch("indices", e, t, n), a = Ch("depth", e, t, n), o = Ch("onValue", e, t, n), s = Ch("offValue", e, t, n), u = Ch("dtype", e, t, n); return [r.oneHot(i, a, o, s, u)] } case "Ones": return [r.ones(Ch("shape", e, t, n), Ch("dtype", e, t, n))]; case "OnesLike": return [r.onesLike(Ch("x", e, t, n))]; case "RandomStandardNormal": return [r.randomStandardNormal(Ch("shape", e, t, n), Ch("dtype", e, t, n), Ch("seed", e, t, n))]; case "RandomUniform": return [r.randomUniform(Ch("shape", e, t, n), Ch("minval", e, t, n), Ch("maxval", e, t, n), Ch("dtype", e, t, n))]; case "RandomUniformInt": return [r.randomUniformInt(Ch("shape", e, t, n), Ch("minval", e, t, n), Ch("maxval", e, t, n), Ch("seed", e, t, n))]; case "Range": { const i = Ch("start", e, t, n), a = Ch("stop", e, t, n), o = Ch("step", e, t, n); return [r.range(i, a, o, Ch("dtype", e, t, n))] } case "TruncatedNormal": { const i = Ch("shape", e, t, n), a = Ch("mean", e, t, n), o = Ch("stdDev", e, t, n), s = Ch("seed", e, t, n); return [r.truncatedNormal(i, a, o, Ch("dtype", e, t, n), s)] } case "Zeros": return [r.zeros(Ch("shape", e, t, n), Ch("dtype", e, t, n))]; case "ZerosLike": return [r.zerosLike(Ch("x", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "dynamic": return (async (e, t, n, r, i = T) => { switch (e.op) { case "NonMaxSuppressionV5": { const { boxes: r, scores: a, maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = Sd(e, t, n), c = await i.image.nonMaxSuppressionWithScoreAsync(r, a, o, s, u, l); return [c.selectedIndices, c.selectedScores] } case "NonMaxSuppressionV4": { const { boxes: r, scores: a, maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = Sd(e, t, n), l = Ch("padToMaxOutputSize", e, t, n), c = await i.image.nonMaxSuppressionPaddedAsync(r, a, o, s, u, l); return [c.selectedIndices, c.validOutputs] } case "NonMaxSuppressionV3": case "NonMaxSuppressionV2": { const { boxes: r, scores: a, maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = Sd(e, t, n); return [await i.image.nonMaxSuppressionAsync(r, a, o, s, u)] } case "Where": { const r = i.cast(Ch("condition", e, t, n), "bool"), a = [await i.whereAsync(r)]; return r.dispose(), a } case "ListDiff": return i.setdiff1dAsync(Ch("x", e, t, n), Ch("y", e, t, n)); default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n); case "evaluation": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "LowerBound": { const i = Ch("sortedSequence", e, t, n), a = Ch("values", e, t, n); return [r.lowerBound(i, a)] } case "TopKV2": { const i = Ch("x", e, t, n), a = Ch("k", e, t, n), o = Ch("sorted", e, t, n), s = r.topk(i, a, o); return [s.values, s.indices] } case "UpperBound": { const i = Ch("sortedSequence", e, t, n), a = Ch("values", e, t, n); return [r.upperBound(i, a)] } case "Unique": { const i = Ch("x", e, t, n), a = r.unique(i); return [a.values, a.indices] } case "UniqueV2": { const i = Ch("x", e, t, n), a = Ch("axis", e, t, n), o = r.unique(i, a); return [o.values, o.indices] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "image": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "ResizeBilinear": { const i = Ch("images", e, t, n), a = Ch("size", e, t, n), o = Ch("alignCorners", e, t, n), s = Ch("halfPixelCenters", e, t, n); return [r.image.resizeBilinear(i, [a[0], a[1]], o, s)] } case "ResizeNearestNeighbor": { const i = Ch("images", e, t, n), a = Ch("size", e, t, n), o = Ch("alignCorners", e, t, n), s = Ch("halfPixelCenters", e, t, n); return [r.image.resizeNearestNeighbor(i, [a[0], a[1]], o, s)] } case "CropAndResize": { const i = Ch("image", e, t, n), a = Ch("boxes", e, t, n), o = Ch("boxInd", e, t, n), s = Ch("cropSize", e, t, n), u = Ch("method", e, t, n), l = Ch("extrapolationValue", e, t, n); return [r.image.cropAndResize(i, a, o, s, u, l)] } case "ImageProjectiveTransformV3": { const i = Ch("images", e, t, n), a = Ch("transforms", e, t, n), o = Ch("outputShape", e, t, n), s = Ch("fillValue", e, t, n), u = Ch("interpolation", e, t, n), l = Ch("fillMode", e, t, n); return [r.image.transform(i, a, u.toLowerCase(), l.toLowerCase(), s, o)] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "graph": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Const": return t[e.name]; case "PlaceholderWithDefault": const i = Ch("default", e, t, n); return [Ah(e.name, t, n) || i]; case "Placeholder": return [Ah(e.name, t, n)]; case "Identity": case "StopGradient": case "FakeQuantWithMinMaxVars": case "Snapshot": return [Fh(Ch("x", e, t, n))]; case "IdentityN": return Ch("x", e, t, n).map((e => Fh(e))); case "Shape": return [r.tensor1d(Ch("x", e, t, n).shape, "int32")]; case "ShapeN": return Ch("x", e, t, n).map((e => r.tensor1d(e.shape))); case "Size": return [r.scalar(Ch("x", e, t, n).size, "int32")]; case "Rank": return [r.scalar(Ch("x", e, t, n).rank, "int32")]; case "NoOp": return [r.scalar(1)]; case "Print": const a = Ch("x", e, t, n), o = Ch("data", e, t, n), s = Ch("message", e, t, n), u = Ch("summarize", e, t, n); console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."), console.log(s); for (let e = 0; e < o.length; e++)console.log(Array.prototype.slice.call(o[e].dataSync()).slice(0, u)); return [a]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "logical": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Equal": return [r.equal(Ch("a", e, t, n), Ch("b", e, t, n))]; case "NotEqual": return [r.notEqual(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Greater": return [r.greater(Ch("a", e, t, n), Ch("b", e, t, n))]; case "GreaterEqual": return [r.greaterEqual(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Less": return [r.less(Ch("a", e, t, n), Ch("b", e, t, n))]; case "LessEqual": return [r.lessEqual(Ch("a", e, t, n), Ch("b", e, t, n))]; case "LogicalAnd": return [r.logicalAnd(Ch("a", e, t, n), Ch("b", e, t, n))]; case "LogicalNot": return [r.logicalNot(Ch("a", e, t, n))]; case "LogicalOr": return [r.logicalOr(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Select": case "SelectV2": return [r.where(Ch("condition", e, t, n), Ch("a", e, t, n), Ch("b", e, t, n))]; case "BitwiseAnd": return [r.bitwiseAnd(Ch("a", e, t, n), Ch("b", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "matrices": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "BatchMatMul": case "BatchMatMulV2": case "MatMul": return [r.matMul(Ch("a", e, t, n), Ch("b", e, t, n), Ch("transposeA", e, t, n), Ch("transposeB", e, t, n))]; case "Einsum": return [r.einsum(Ch("equation", e, t, n), ...Ch("tensors", e, t, n))]; case "Transpose": return [r.transpose(Ch("x", e, t, n), Ch("perm", e, t, n))]; case "_FusedMatMul": const [i, a] = Ch("fusedOps", e, t, n), o = "biasadd" === i, s = "prelu" === a, u = Ch("numArgs", e, t, n), l = Ch("leakyreluAlpha", e, t, n); if (o) { if (s && 2 !== u) throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha."); if (!s && 1 !== u) throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.") } const [c, h] = Ch("args", e, t, n); return [r.fused.matMul({ a: Ch("a", e, t, n), b: Ch("b", e, t, n), transposeA: Ch("transposeA", e, t, n), transposeB: Ch("transposeB", e, t, n), bias: c, activation: a, preluActivationWeights: h, leakyreluAlpha: l })]; case "MatrixBandPart": return [r.linalg.bandPart(Ch("a", e, t, n), Ch("numLower", e, t, n), Ch("numUpper", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "normalization": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "EuclideanNorm": return [r.euclideanNorm(Ch("x", e, t, n), Ch("axis", e, t, n), Ch("keepDims", e, t, n))]; case "FusedBatchNorm": case "FusedBatchNormV2": case "FusedBatchNormV3": return [r.batchNorm(Ch("x", e, t, n), Ch("mean", e, t, n), Ch("variance", e, t, n), Ch("offset", e, t, n), Ch("scale", e, t, n), Ch("epsilon", e, t, n))]; case "LRN": return [r.localResponseNormalization(Ch("x", e, t, n), Ch("radius", e, t, n), Ch("bias", e, t, n), Ch("alpha", e, t, n), Ch("beta", e, t, n))]; case "Softmax": return [r.softmax(Ch("x", e, t, n))]; case "LogSoftmax": return [r.logSoftmax(Ch("x", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "ragged": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "RaggedGather": { const { outputNestedSplits: i, outputDenseValues: a } = r.raggedGather(Ch("paramsNestedSplits", e, t, n), Ch("paramsDenseValues", e, t, n), Ch("indices", e, t, n), Ch("outputRaggedRank", e, t, n)); return i.concat(a) } case "RaggedRange": { const { rtNestedSplits: i, rtDenseValues: a } = r.raggedRange(Ch("starts", e, t, n), Ch("limits", e, t, n), Ch("splits", e, t, n)); return [i, a] } case "RaggedTensorToTensor": return [r.raggedTensorToTensor(Ch("shape", e, t, n), Ch("values", e, t, n), Ch("defaultValue", e, t, n), Ch("rowPartitionTensors", e, t, n), Ch("rowPartitionTypes", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "reduction": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Max": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.max(Ch("x", e, t, n), i, a)] } case "Mean": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.mean(Ch("x", e, t, n), i, a)] } case "Min": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.min(Ch("x", e, t, n), i, a)] } case "Sum": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.sum(Ch("x", e, t, n), i, a)] } case "All": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.all(Ch("x", e, t, n), i, a)] } case "Any": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.any(Ch("x", e, t, n), i, a)] } case "ArgMax": { const i = Ch("axis", e, t, n); return [r.argMax(Ch("x", e, t, n), i)] } case "ArgMin": { const i = Ch("axis", e, t, n); return [r.argMin(Ch("x", e, t, n), i)] } case "Prod": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.prod(Ch("x", e, t, n), i, a)] } case "Cumprod": { const i = Ch("axis", e, t, n), a = Ch("exclusive", e, t, n), o = Ch("reverse", e, t, n); return [r.cumprod(Ch("x", e, t, n), i, a, o)] } case "Cumsum": { const i = Ch("axis", e, t, n), a = Ch("exclusive", e, t, n), o = Ch("reverse", e, t, n); return [r.cumsum(Ch("x", e, t, n), i, a, o)] } case "Bincount": const i = Ch("x", e, t, n), a = Ch("weights", e, t, n), o = Ch("size", e, t, n); return [r.bincount(i, a, o)]; case "DenseBincount": { const i = Ch("x", e, t, n), a = Ch("weights", e, t, n), o = Ch("size", e, t, n), s = Ch("binaryOutput", e, t, n); return [r.denseBincount(i, a, o, s)] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "slice_join": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "ConcatV2": case "Concat": { const i = Ch("n", e, t, n), a = Ch("axis", e, t, n); let o = Ch("tensors", e, t, n); return o = o.slice(0, i), [r.concat(o, a)] } case "Gather": { const i = Ch("x", e, t, n), a = Ch("indices", e, t, n); return [r.gather(i, r.cast(a, "int32"), 0)] } case "GatherV2": { const i = Ch("axis", e, t, n), a = Ch("batchDims", e, t, n), o = Ch("x", e, t, n), s = Ch("indices", e, t, n); return [r.gather(o, r.cast(s, "int32"), i, a)] } case "Reverse": { const i = Ch("dims", e, t, n), a = []; for (let e = 0; e < i.length; e++)i[e] && a.push(e); const o = Ch("x", e, t, n); return [r.reverse(o, a)] } case "ReverseV2": { const i = Ch("axis", e, t, n), a = Ch("x", e, t, n); return [r.reverse(a, i)] } case "Slice": { const i = Ch("begin", e, t, n), a = Ch("size", e, t, n); return [r.slice(Ch("x", e, t, n), i, a)] } case "StridedSlice": { const i = Ch("begin", e, t, n), a = Ch("end", e, t, n), o = Ch("strides", e, t, n), s = Ch("beginMask", e, t, n), u = Ch("endMask", e, t, n), l = Ch("ellipsisMask", e, t, n), c = Ch("newAxisMask", e, t, n), h = Ch("shrinkAxisMask", e, t, n), d = Ch("x", e, t, n); return [r.stridedSlice(d, i, a, o, s, u, l, c, h)] } case "Pack": return (0, P.tidy)((() => { const i = Ch("axis", e, t, n), a = Ch("tensors", e, t, n), o = a[0].shape, s = r.squeeze(a[0]).shape, u = a.map((e => { const t = P.util.arraysEqual(e.shape, o); if (!t && !P.util.arraysEqual(r.squeeze(e).shape, s)) throw new Error("the input tensors shape does not match"); return t ? e : r.reshape(e, o) })); return [r.stack(u, i)] })); case "Unpack": { const i = Ch("axis", e, t, n), a = Ch("tensor", e, t, n); return r.unstack(a, i) } case "Tile": { const i = Ch("reps", e, t, n); return [r.tile(Ch("x", e, t, n), i)] } case "Split": case "SplitV": { const i = Ch("axis", e, t, n), a = Ch("numOrSizeSplits", e, t, n), o = Ch("x", e, t, n); return r.split(o, a, i) } case "ScatterNd": { const i = Ch("indices", e, t, n), a = Ch("values", e, t, n), o = Ch("shape", e, t, n); return [r.scatterND(i, a, o)] } case "GatherNd": { const i = Ch("x", e, t, n), a = Ch("indices", e, t, n); return [r.gatherND(i, a)] } case "SparseToDense": { const i = Ch("sparseIndices", e, t, n), a = Ch("outputShape", e, t, n), o = Ch("sparseValues", e, t, n), s = Ch("defaultValue", e, t, n); return [r.sparseToDense(i, o, a, o.dtype === s.dtype ? s : r.cast(s, o.dtype))] } case "TensorScatterUpdate": { const i = Ch("indices", e, t, n), a = Ch("values", e, t, n), o = Ch("tensor", e, t, n); return [r.tensorScatterUpdate(o, i, a)] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "sparse": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "SparseFillEmptyRows": { const { outputIndices: i, outputValues: a, emptyRowIndicator: o, reverseIndexMap: s } = r.sparse.sparseFillEmptyRows(Ch("indices", e, t, n), Ch("values", e, t, n), Ch("denseShape", e, t, n), Ch("defaultValue", e, t, n)); return [i, a, o, s] } case "SparseReshape": { const { outputIndices: i, outputShape: a } = r.sparse.sparseReshape(Ch("inputIndices", e, t, n), Ch("inputShape", e, t, n), Ch("newShape", e, t, n)); return [i, a] } case "SparseSegmentMean": return [r.sparse.sparseSegmentMean(Ch("data", e, t, n), Ch("indices", e, t, n), Ch("segmentIds", e, t, n))]; case "SparseSegmentSum": return [r.sparse.sparseSegmentSum(Ch("data", e, t, n), Ch("indices", e, t, n), Ch("segmentIds", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "spectral": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "FFT": return [r.fft(Ch("x", e, t, n))]; case "IFFT": return [r.ifft(Ch("x", e, t, n))]; case "RFFT": return [r.rfft(Ch("x", e, t, n))]; case "IRFFT": return [r.irfft(Ch("x", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "string": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "StaticRegexReplace": return [r.string.staticRegexReplace(Ch("input", e, t, n), Ch("pattern", e, t, n), Ch("rewrite", e, t, n), Ch("replaceGlobal", e, t, n))]; case "StringNGrams": { const { nGrams: i, nGramsSplits: a } = r.string.stringNGrams(Ch("data", e, t, n), Ch("dataSplits", e, t, n), Ch("separator", e, t, n), Ch("nGramWidths", e, t, n), Ch("leftPad", e, t, n), Ch("rightPad", e, t, n), Ch("padWidth", e, t, n), Ch("preserveShortSequences", e, t, n)); return [i, a] } case "StringSplit": { const { indices: i, values: a, shape: o } = r.string.stringSplit(Ch("input", e, t, n), Ch("delimiter", e, t, n), Ch("skipEmpty", e, t, n)); return [i, a, o] } case "StringToHashBucketFast": return [r.string.stringToHashBucketFast(Ch("input", e, t, n), Ch("numBuckets", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "transformation": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Cast": return [r.cast(Ch("x", e, t, n), Ch("dtype", e, t, n))]; case "ExpandDims": { const i = Ch("axis", e, t, n); return [r.expandDims(Ch("x", e, t, n), i)] } case "Squeeze": { const i = Ch("axis", e, t, n); return [r.squeeze(Ch("x", e, t, n), i)] } case "Reshape": return [r.reshape(Ch("x", e, t, n), Ch("shape", e, t, n))]; case "EnsureShape": return [r.ensureShape(Ch("x", e, t, n), Ch("shape", e, t, n))]; case "MirrorPad": return [r.mirrorPad(Ch("x", e, t, n), Ch("padding", e, t, n), Ch("mode", e, t, n))]; case "PadV2": case "Pad": return [r.pad(Ch("x", e, t, n), Ch("padding", e, t, n), Ch("constantValue", e, t, n))]; case "SpaceToBatchND": { const i = Ch("blockShape", e, t, n), a = Ch("paddings", e, t, n); return [r.spaceToBatchND(Ch("x", e, t, n), i, a)] } case "BatchToSpaceND": { const i = Ch("blockShape", e, t, n), a = Ch("crops", e, t, n); return [r.batchToSpaceND(Ch("x", e, t, n), i, a)] } case "DepthToSpace": { const i = Ch("blockSize", e, t, n), a = Ch("dataFormat", e, t, n).toUpperCase(); return [r.depthToSpace(Ch("x", e, t, n), i, a)] } case "BroadcastTo": return [r.broadcastTo(Ch("x", e, t, n), Ch("shape", e, t, n))]; case "BroadcastArgs": return [r.broadcastArgs(Ch("s0", e, t, n), Ch("s1", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "hash_table": return (async (e, t, n, r) => { switch (e.op) { case "HashTable": case "HashTableV2": { const i = r.getHashTableHandleByName(e.name); if (null != i) return [i]; { const i = Ch("keyDType", e, t, n), a = Ch("valueDType", e, t, n), o = new _d(i, a); return r.addHashTable(e.name, o), [o.handle] } } case "InitializeTable": case "InitializeTableV2": case "LookupTableImport": case "LookupTableImportV2": { const i = Ch("tableHandle", e, t, n, r), a = Ch("keys", e, t, n), o = Ch("values", e, t, n), s = r.getHashTableById(i.id); return [await s.import(a, o)] } case "LookupTableFind": case "LookupTableFindV2": { const i = Ch("tableHandle", e, t, n, r), a = Ch("keys", e, t, n), o = Ch("defaultValue", e, t, n), s = r.getHashTableById(i.id); return [await s.find(a, o)] } case "LookupTableSize": case "LookupTableSizeV2": { const i = Ch("tableHandle", e, t, n, r); return [r.getHashTableById(i.id).tensorSize()] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n, r); case "custom": const a = Sh(e.op); if (a && a.customExecutor) return a.customExecutor(new fd(e, t, n)); throw TypeError(`Custom op ${e.op} is not registered.`); default: throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`) } })(e, t, n); return P.util.isPromise(a) ? a.then((e => [].concat(e))) : [].concat(a) } class Ad { constructor(e = {}, t = {}, n = {}, r = {}, i) { this.weightMap = e, this.tensorArrayMap = t, this.tensorListMap = n, this.functionMap = r, this.parseNodeNameCache = i, this.rootContext = { id: 0, frameName: "", iterationId: 0 }, this.contexts = [this.rootContext], this.lastId = 0, this.generateCurrentContextIds() } newFrame(e, t) { return { id: e, frameName: t, iterationId: 0 } } set currentContext(e) { this.contexts !== e && (this.contexts = e, this.generateCurrentContextIds()) } get currentContext() { return this.contexts } get currentContextId() { return this._currentContextIds[0] } get currentContextIds() { return this._currentContextIds } generateCurrentContextIds() { const e = []; for (let t = 0; t < this.contexts.length - 1; t++) { const n = this.contexts.slice(0, this.contexts.length - t); e.push(this.contextIdforContexts(n)) } e.push(""), this._currentContextIds = e } contextIdforContexts(e) { return e ? e.map((e => 0 === e.id && 0 === e.iterationId ? "" : `${e.frameName}-${e.iterationId}`)).join("/") : "" } enterFrame(e) { this.contexts && (this.lastId++, this.contexts = this.contexts.slice(), this.contexts.push(this.newFrame(this.lastId, e)), this._currentContextIds.unshift(this.contextIdforContexts(this.contexts))) } exitFrame() { if (!(this.contexts && this.contexts.length > 1)) throw new Error("Cannot exit frame, the context is empty"); this.contexts = this.contexts.slice(), this.contexts.splice(-1), this.currentContextIds.shift() } nextIteration() { if (!(this.contexts && this.contexts.length > 0)) throw new Error("Cannot increase frame iteration, the context is empty"); { this.contexts = this.contexts.slice(), this.lastId++; const e = Object.assign({}, this.contexts[this.contexts.length - 1]); e.iterationId += 1, e.id = this.lastId, this.contexts.splice(-1, 1, e), this._currentContextIds.splice(0, 1, this.contextIdforContexts(this.contexts)) } } getWeight(e) { return this.weightMap[e] } addTensorArray(e) { this.tensorArrayMap[e.id] = e } getTensorArray(e) { return this.tensorArrayMap[e] } addTensorList(e) { this.tensorListMap[e.id] = e } getTensorList(e) { return this.tensorListMap[e] } dispose(e) { for (const t in this.tensorArrayMap) this.tensorArrayMap[t].clearAndClose(e); for (const t in this.tensorListMap) this.tensorListMap[t].clearAndClose(e) } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Td(e, t, n, r) { const i = new Set, a = []; let o = null, s = null; const u = new Set, l = new Set(Object.keys(e).map((e => Ih(e)[0]))); r = r || []; const c = new Set(r.map((e => Ih(e.name)[0]))), h = [...t]; for (; h.length > 0;) { const e = h.pop(); (Dd(e) || $d(e) || Rd(e)) && null == o && (o = e, s = o.children.map((e => e.name)).filter((e => i.has(e)))), i.add(e.name), null == n[e.name] && (l.has(e.name) || c.has(e.name) || (0 !== e.inputs.length ? e.inputs.forEach((e => { u.has(e.name) || (u.add(e.name), h.push(e)) })) : a.push(e.name))) } return { inputs: e, outputs: t, usedNodes: i, missingInputs: a, dynamicNode: o, syncInputs: s } } function Ed(e, t) { const { usedNodes: n, inputs: r } = t, i = Object.keys(r).map((e => Ih(e)[0])).map((t => e.nodes[t])), a = e.initNodes || [], o = e => n.has("string" == typeof e ? e : e.name); function s(e) { return [...new Map(e.map((e => [e.name, e]))).values()] } const u = s([...i, ...e.weights, ...a]).filter(o), l = s([...u, ...Object.values(e.nodes)]).filter(o), c = new Map(l.map((e => [e.name, e]))), h = {}; for (const e of l) { h[e.name] = h[e.name] || 0; for (const t of e.children) o(t) || (h[t.name] = Number.POSITIVE_INFINITY), h[t.name] = (h[t.name] || 0) + 1 } const d = Object.entries(h).filter((([, e]) => 0 === e)).map((([e]) => e)), f = [...d]; for (; d.length > 0;) { const e = d.pop(), t = c.get(e); for (const e of t.children.filter(o)) 0 == --h[e.name] && (f.push(e.name), d.push(e.name)) } const p = function (e, t) { const n = new Map(e.map((e => [e.name, e]))), r = t.map((e => e.name)), i = new Set(r); for (; r.length > 0;) { const e = r.pop(), t = n.get(e); for (const e of t.children) n.has(e.name) && !i.has(e.name) && (i.add(e.name), r.push(e.name)) } const a = e.filter((e => i.has(e.name))); return a }(f.map((e => c.get(e))), u); return function (e, t) { const n = new Map(e.map(((e, t) => [e.name, t]))), r = new Set(t.map((e => e.name))), i = e => r.has("string" == typeof e ? e : e.name), a = new Set(e.map((e => e.name))), o = e => a.has("string" == typeof e ? e : e.name); for (const t of e) { for (const e of t.children.filter(o)) { if (!n.has(e.name)) throw new Nd(`Child ${e.name} of node ${t.name} is unreachable.`); if (n.get(t.name) > n.get(e.name)) throw new Nd(`Node ${t.name} is scheduled to run after its child ${e.name}.`) } if (!i(t)) for (const e of t.inputs) { if (!n.has(e.name)) throw new Nd(`Input ${e.name} of node ${t.name} is unreachable.`); if (n.get(e.name) > n.get(t.name)) throw new Nd(`Node ${t.name} is scheduled to run before its input ${e.name}.`) } } }(p, u), p } class Nd extends Error { constructor(e) { super(`NodesExecutionOrderError: ${e}`) } } const Id = new Set(["Switch", "Merge", "Enter", "Exit", "NextIteration", "StatelessIf", "StatelessWhile", "if", "While"]), Md = new Set(["NonMaxSuppressionV2", "NonMaxSuppressionV3", "NonMaxSuppressionV5", "Where"]), Fd = new Set(["HashTable", "HashTableV2", "LookupTableImport", "LookupTableImportV2", "LookupTableFind", "LookupTableFindV2", "LookupTableSize", "LookupTableSizeV2"]); function Dd(e) { return Id.has(e.op) } function $d(e) { return Md.has(e.op) } function Rd(e) { return Fd.has(e.op) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Od { get weightIds() { return this.parent ? this.parent.weightIds : this._weightIds } get functionExecutorMap() { return this.parent ? this.parent.functionExecutorMap : this._functionExecutorMap } get weightMap() { return this.parent ? this.parent.weightMap : this._weightMap } set weightMap(e) { const t = Object.keys(e).map((t => e[t].map((e => e.id)))); this._weightIds = [].concat(...t), this._weightMap = e } set resourceManager(e) { this._resourceManager = e } get inputs() { return this._inputs.map((e => ({ name: e.name, shape: e.attrParams.shape ? e.attrParams.shape.value : void 0, dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0 }))) } get outputs() { return this._outputs.map((e => ({ name: e.name, shape: e.attrParams.shape ? e.attrParams.shape.value : void 0, dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0 }))) } get inputNodes() { return this._inputs.map((e => e.signatureKey || e.name)) } get outputNodes() { return this._outputs.map((e => { const t = e.signatureKey || e.name; return e.defaultOutput ? `${t}:${e.defaultOutput}` : t })) } get functions() { return Object.keys(this._functions).reduce(((e, t) => (e[t] = this._functions[t].signature, e)), {}) } constructor(e, t) { this.graph = e, this.parent = t, this.compiledMap = new Map, this.parseNodeNameCache = new Map, this._weightMap = {}, this.SEPARATOR = ",", this._functions = {}, this._functionExecutorMap = {}, this.keepIntermediateTensors = !1, this._outputs = e.outputs, this._inputs = e.inputs, this._initNodes = e.initNodes, this._signature = e.signature, this._functions = e.functions, null != e.functions && Object.keys(e.functions).forEach((t => { this._functionExecutorMap[t] = new Od(e.functions[t], this) })) } getCompilationKey(e, t) { const n = e.map((e => e.name)).sort(), r = t.map((e => e.name)).sort(); return n.join(this.SEPARATOR) + "--" + r.join(this.SEPARATOR) } compile(e, t) { const n = Td(e, t, this.weightMap, this._initNodes), { missingInputs: r, dynamicNode: i, syncInputs: a } = n; if (null != i) throw new Error(`This execution contains the node '${i.name}', which has the dynamic op '${i.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${a}]`); if (r.length > 0) { const n = t.map((e => e.name)), i = Object.keys(e); throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${i}]. Missing the following inputs: [${r}]`) } const o = Ed(this.graph, n), s = function (e) { const t = new Map(e.map(((e, t) => [e.name, t]))), n = Number.MAX_SAFE_INTEGER, r = e.map(((e, t) => Dd(e) ? n : t)), i = e => { const n = r[t.get(e.name)]; return null == n ? -1 : n }, a = e.map(((e, t) => e.children.map(i).reduce(((e, t) => Math.max(e, t)), r[t]))), o = new Map; for (let t = 0; t < e.length; ++t) { const r = a[t]; if (r === n) continue; const i = e[t], s = e[r]; o.has(s.name) || o.set(s.name, []), o.get(s.name).push(i) } return o }(o); return { orderedNodes: o, nodeLiveUntilMap: s } } cloneAndKeepTensor(e) { if (null == e) return null; const t = e.clone(); return (0, P.keep)(t), t } cloneTensorList(e) { if (!e) return null; return e.map((e => this.cloneAndKeepTensor(e))) } cloneTensorMap(e) { return Object.fromEntries(Object.entries(e).map((([e, t]) => [e, this.cloneTensorList(t)]))) } execute(e, t) { this.disposeIntermediateTensors(), e = this.mapInputs(e); const n = Object.keys(e).sort(); this.checkInputs(e), this.checkInputShapeAndType(e), t = this.mapOutputs(t), this.checkOutputs(t); const r = n.map((e => this.graph.nodes[Ih(e)[0]])), i = t.map((e => Ih(e)[0])), a = new Set(i); let o = i.map((e => this.graph.nodes[e])); 0 === o.length && (o = this._outputs); const s = this.getCompilationKey(r, o); let u = this.compiledMap.get(s); null == u && (u = this.compile(e, o), this.compiledMap.set(s, u)); try { this.keepIntermediateTensors = (0, P.env)().getBool("KEEP_INTERMEDIATE_TENSORS") } catch (e) { this.keepIntermediateTensors = !1, console.warn(e.message) } const l = {}, c = {}; return (0, P.tidy)((() => { const n = new Ad(this.weightMap, l, c, this.functionExecutorMap, this.parseNodeNameCache), r = Object.assign({}, this.weightMap); this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap)), Object.keys(e).forEach((t => { const [i, a] = Ih(t, n), o = []; o[a] = e[t], r[i] = o, this.keepIntermediateTensors && (this.clonedTensorsMap[i] = this.cloneTensorList(o)) })); const i = this.getFrozenTensorIds(r), { orderedNodes: o, nodeLiveUntilMap: s } = u; for (const e of o) { if (r[e.name]) continue; const t = Cd(e, r, n, this._resourceManager); if (P.util.isPromise(t)) throw new Error(`The execution of the op '${e.op}' returned a promise. Please use model.executeAsync() instead.`); r[e.name] = t, this.keepIntermediateTensors && (this.clonedTensorsMap[e.name] = this.cloneTensorList(t)), this.checkTensorForDisposalWithNodeLiveUntilInfo(e, r, n, i, a, s.get(e.name)) } return null == this.parent && n.dispose(i), t.map((e => Ah(e, r, n))) })) } getFrozenTensorIds(e) { const t = [].concat.apply([], Object.keys(e).map((t => e[t])).map((e => e.map((e => e.id))))); return new Set(t) } checkTensorForDisposal(e, t, n, r, i, a, o) { if (!Dd(t) && !a.has(e)) { for (const r of n[e]) null != r && (o[r.id] = (o[r.id] || 0) + t.children.length); for (const e of t.inputs) { if (Dd(e)) continue; const t = Th(e.name, n, r); if (null != t) for (const e of t) { if (!e || e.kept || i.has(e.id)) continue; const t = o[e.id]; 1 === t ? (e.dispose(), delete o[e.id]) : null != t && o[e.id]-- } } } } checkTensorForDisposalWithNodeLiveUntilInfo(e, t, n, r, i, a) { function o(e) { return Dd(e) || i.has(e.name) } if (!Dd(e) && null != a) for (const e of a) { if (o(e)) continue; const i = Th(e.name, t, n); for (const e of i) !e || e.kept || r.has(e.id) || e.dispose() } } async executeAsync(e, t) { return this._executeAsync(e, t) } disposeIntermediateTensors() { this.clonedTensorsMap && (Object.values(this.clonedTensorsMap).forEach((e => { for (const t of e) t && !t.isDisposed && t.dispose() })), this.clonedTensorsMap = null) } getIntermediateTensors() { return this.clonedTensorsMap } async _executeAsync(e, t, n = !1, r = {}, i = {}) { this.disposeIntermediateTensors(), n || (e = this.mapInputs(e), this.checkInputs(e), this.checkInputShapeAndType(e), t = this.mapOutputs(t), this.checkOutputs(t)); try { this.keepIntermediateTensors = (0, P.env)().getBool("KEEP_INTERMEDIATE_TENSORS") } catch (e) { this.keepIntermediateTensors = !1, console.warn(e.message) } const a = new Ad(this.weightMap, r, i, this.functionExecutorMap, this.parseNodeNameCache); this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap)); const o = await this.executeWithControlFlow(e, a, t, n), s = t.map((e => Ah(e, o, a))), u = s.map((e => e.id)), l = Object.keys(e).map((t => e[t].id)), c = new Set([...u, ...l, ...this.weightIds]); return Object.values(o).forEach((e => { e.forEach((e => { !e || e.isDisposed || c.has(e.id) || e.dispose() })) })), null == this.parent && a.dispose(c), s } async executeFunctionAsync(e, t, n) { const r = e.reduce(((e, t, n) => (e[this.inputs[n].name] = t, e)), {}); return this._executeAsync(r, this.outputNodes, !0, t, n) } async executeWithControlFlow(e, t, n, r) { const i = Object.keys(e), a = i.map((e => this.graph.nodes[Ih(e)[0]])), o = n.map((e => Ih(e)[0])), s = new Set(o); let u = o.map((e => this.graph.nodes[e])); 0 === u.length && (u = this._outputs); const { usedNodes: l, missingInputs: c, dynamicNode: h, syncInputs: d } = Td(e, u, this.weightMap, this._initNodes), f = [...a, ...this.graph.weights, ...this._initNodes || []].map((e => ({ node: e, contexts: t.currentContext }))), p = Object.assign({}, this.weightMap); Object.keys(e).forEach((t => { const [n, r] = Ih(t), i = []; i[r] = e[t], p[n] = i })); const m = {}, g = this.getFrozenTensorIds(p), y = {}; for (; f.length > 0;) { const e = this.processStack(a, f, t, p, y, g, s, m, l); await Promise.all(e) } null != h || r || console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."); const b = u.filter((e => !Dd(e) && !Ah(e.name, p, t))).map((e => e.name)); if (b.length > 0) { let e = ""; throw null != h && (e = `Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`), new Error(`Cannot compute the outputs [${b}] from the provided inputs [${i}]. Consider providing the following inputs: [${c}]. ${e}`) } return p } processStack(e, t, n, r, i, a, o, s, u) { const l = []; for (; t.length > 0;) { const e = t.pop(); n.currentContext = e.contexts; let c = ""; if ("Enter" === e.node.op && Ch("isConstant", e.node, r, n) && ([c] = Eh(e.node.name, n)), null == r[e.node.name]) { const h = Cd(e.node, r, n, this._resourceManager); c || ([c] = Eh(e.node.name, n)); const d = n.currentContext; P.util.isPromise(h) ? l.push(h.then((l => (r[c] = l, this.keepIntermediateTensors && (this.clonedTensorsMap[c] = this.cloneTensorList(l)), n.currentContext = d, this.checkTensorForDisposal(c, e.node, r, n, a, o, s), this.processChildNodes(e.node, t, n, r, i, u), l)))) : (r[c] = h, this.keepIntermediateTensors && (this.clonedTensorsMap[c] = this.cloneTensorList(h)), this.checkTensorForDisposal(c, e.node, r, n, a, o, s), this.processChildNodes(e.node, t, n, r, i, u)) } else this.processChildNodes(e.node, t, n, r, i, u) } return l } processChildNodes(e, t, n, r, i, a) { e.children.forEach((e => { const [o] = Eh(e.name, n); !i[o] && a.has(e.name) && ("Merge" === e.op ? e.inputNames.some((e => !!Ah(e, r, n))) && (i[o] = !0, t.push({ contexts: n.currentContext, node: e })) : e.inputNames.every((e => !!Ah(e, r, n))) && (i[o] = !0, t.push({ contexts: n.currentContext, node: e }))) })) } dispose() { Object.keys(this.weightMap).forEach((e => this.weightMap[e].forEach((e => e.dispose())))) } checkInputShapeAndType(e) { Object.keys(e).forEach((t => { const n = e[t], [r] = Ih(t), i = this.graph.nodes[r]; if (i.attrParams.shape && i.attrParams.shape.value) { const e = i.attrParams.shape.value, t = e.length === n.shape.length && n.shape.every(((t, n) => -1 === e[n] || e[n] === t)); P.util.assert(t, (() => `The shape of dict['${i.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`)) } i.attrParams.dtype && i.attrParams.dtype.value && P.util.assert(n.dtype === i.attrParams.dtype.value, (() => `The dtype of dict['${i.name}'] provided in model.execute(dict) must be ${i.attrParams.dtype.value}, but was ${n.dtype}`)) })) } mapInputs(e) { var t, n; const r = {}; for (const i in e) { const a = null === (n = null === (t = this._signature) || void 0 === t ? void 0 : t.inputs) || void 0 === n ? void 0 : n[i]; null != a ? r[a.name] = e[i] : r[i] = e[i] } return r } checkInputs(e) { const t = Object.keys(e).filter((e => { const [t] = Ih(e); return null == this.graph.nodes[t] })); if (t.length > 0) throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`) } mapOutputs(e) { return e.map((e => { var t, n; const r = null === (n = null === (t = this._signature) || void 0 === t ? void 0 : t.outputs) || void 0 === n ? void 0 : n[e]; return null != r ? r.name : e }), {}) } checkOutputs(e) { e.forEach((e => { const [t] = Ih(e); if (!this.graph.nodes[t]) throw new Error(`The output '${e}' is not found in the graph`) })) } } class zd { constructor(e = {}, t = {}) { this.hashTableNameToHandle = e, this.hashTableMap = t } addHashTable(e, t) { this.hashTableNameToHandle[e] = t.handle, this.hashTableMap[t.id] = t } getHashTableHandleByName(e) { return this.hashTableNameToHandle[e] } getHashTableById(e) { return this.hashTableMap[e] } dispose() { for (const e in this.hashTableMap) this.hashTableMap[e].clearAndClose(), delete this.hashTableMap[e]; for (const e in this.hashTableNameToHandle) this.hashTableNameToHandle[e].dispose(), delete this.hashTableNameToHandle[e] } } var Pd = n(7084); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Bd = "?tfjs-format=file", Ld = "model.json"; class jd { get modelVersion() { return this.version } get inputNodes() { return this.executor.inputNodes } get outputNodes() { return this.executor.outputNodes } get inputs() { return this.executor.inputs } get outputs() { return this.executor.outputs } get weights() { return this.executor.weightMap } get metadata() { return this.artifacts.userDefinedMetadata } get modelSignature() { return this.signature } get modelStructuredOutputKeys() { return this.structuredOutputKeys } constructor(e, t = {}, n = P.io) { this.modelUrl = e, this.loadOptions = t, this.version = "n/a", this.io = n, null == t && (this.loadOptions = {}), this.resourceManager = new zd } findIOHandler() { const e = this.modelUrl; if (null != e.load) this.handler = e; else if (null != this.loadOptions.requestInit) this.handler = this.io.browserHTTPRequest(e, this.loadOptions); else { const t = this.io.getLoadHandlers(e, this.loadOptions); if (0 === t.length) t.push(this.io.browserHTTPRequest(e, this.loadOptions)); else if (t.length > 1) throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`); this.handler = t[0] } } load() { if (this.findIOHandler(), null == this.handler.load) throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented."); const e = this.handler.load(); return P.util.isPromise(e) ? e.then((e => null == e.getWeightStream ? this.loadSync(e) : this.loadStreaming(e))) : this.loadSync(e) } loadSync(e) { const t = this.io.decodeWeights(e.weightData, e.weightSpecs); return this.loadWithWeightMap(e, t) } async loadStreaming(e) { if (null == e.getWeightStream) throw new Error("Model artifacts missing streamWeights function"); const t = await (0, Pd.s5)(e.getWeightStream(), e.weightSpecs); return this.loadWithWeightMap(e, t) } loadWithWeightMap(e, t) { this.artifacts = e; const n = this.artifacts.modelTopology; let r = this.artifacts.signature; if (null != this.artifacts.userDefinedMetadata) { const e = this.artifacts.userDefinedMetadata; null != e.signature && (r = e.signature), null != e.structuredOutputKeys && (this.structuredOutputKeys = e.structuredOutputKeys) } if (this.signature = r, this.version = `${n.versions.producer}.${n.versions.minConsumer}`, this.executor = new Od(Jh.Instance.transformGraph(n, this.signature)), this.executor.weightMap = this.convertTensorMapToTensorsMap(t), this.executor.resourceManager = this.resourceManager, null != e.modelInitializer && null != e.modelInitializer.node) { const t = Jh.Instance.transformGraph(e.modelInitializer); this.initializer = new Od(t), this.initializer.weightMap = this.executor.weightMap, this.initializer.resourceManager = this.resourceManager, this.initializerSignature = e.initializerSignature } return !0 } async save(e, t) { if ("string" == typeof e) { const t = this.io.getSaveHandlers(e); if (0 === t.length) throw new Error(`Cannot find any save handlers for URL '${e}'`); if (t.length > 1) throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`); e = t[0] } if (null == e.save) throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined."); return e.save(this.artifacts) } addStructuredOutputNames(e) { if (this.structuredOutputKeys) { const t = e instanceof P.Tensor ? [e] : e, n = {}; return t.forEach(((e, t) => n[this.structuredOutputKeys[t]] = e)), n } return e } predict(e, t) { const n = this.execute(e, this.outputNodes); return this.addStructuredOutputNames(n) } async predictAsync(e, t) { const n = await this.executeAsync(e, this.outputNodes); return this.addStructuredOutputNames(n) } normalizeInputs(e) { var t; if (!(e instanceof P.Tensor || Array.isArray(e))) { const n = null === (t = this.signature) || void 0 === t ? void 0 : t.inputs; if (null != n) for (const t in n) { const r = n[t]; null != r.resourceId && (e[t] = this.resourceIdToCapturedInput[r.resourceId]) } return e } e = Array.isArray(e) ? e : [e]; const n = Object.keys(this.resourceIdToCapturedInput).length; if (e.length + n !== this.inputNodes.length) throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length - n} non-resource placeholders, while there are ${e.length} input tensors provided.`); let r = 0; return this.inputNodes.reduce(((t, n) => { var i, a, o; const s = null === (o = null === (a = null === (i = this.signature) || void 0 === i ? void 0 : i.inputs) || void 0 === a ? void 0 : a[n]) || void 0 === o ? void 0 : o.resourceId; return t[n] = null != s ? this.resourceIdToCapturedInput[s] : e[r++], t }), {}) } normalizeOutputs(e) { return e = e || this.outputNodes, Array.isArray(e) ? e : [e] } executeInitializerGraph() { return null == this.initializer ? [] : null == this.initializerSignature ? this.initializer.execute({}, []) : this.initializer.execute({}, Object.keys(this.initializerSignature.outputs)) } async executeInitializerGraphAsync() { return null == this.initializer ? [] : null == this.initializerSignature ? this.initializer.executeAsync({}, []) : this.initializer.executeAsync({}, Object.keys(this.initializerSignature.outputs)) } setResourceIdToCapturedInput(e) { if (this.resourceIdToCapturedInput = {}, this.initializerSignature) { const t = this.initializerSignature.outputs, n = Object.keys(t); for (let r = 0; r < n.length; r++) { const i = t[n[r]]; this.resourceIdToCapturedInput[i.resourceId] = e[r] } } } execute(e, t) { null == this.resourceIdToCapturedInput && this.setResourceIdToCapturedInput(this.executeInitializerGraph()), e = this.normalizeInputs(e), t = this.normalizeOutputs(t); const n = this.executor.execute(e, t); return n.length > 1 ? n : n[0] } async executeAsync(e, t) { null == this.resourceIdToCapturedInput && this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()), e = this.normalizeInputs(e), t = this.normalizeOutputs(t); const n = await this.executor.executeAsync(e, t); return n.length > 1 ? n : n[0] } getIntermediateTensors() { return this.executor.getIntermediateTensors() } disposeIntermediateTensors() { this.executor.disposeIntermediateTensors() } convertTensorMapToTensorsMap(e) { return Object.keys(e).reduce(((t, n) => (t[n] = [e[n]], t)), {}) } dispose() { this.executor.dispose(), this.initializer && (this.initializer.dispose(), this.resourceIdToCapturedInput && (0, P.dispose)(this.resourceIdToCapturedInput)), this.resourceManager.dispose() } } async function Ud(e, t = {}, n = P.io) { if (null == e) throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model"); null == t && (t = {}), t.fromTFHub && "string" == typeof e && (e = function (e) { e.endsWith("/") || (e += "/"); return `${e}${Ld}${Bd}` }(e)); const r = new jd(e, t, n); return await r.load(), r } function Wd(e) { if (null == e) throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model"); let t; if (e instanceof Array) { const [n, r] = e; if (!n) throw new Error("modelJSON must be the first element of the array"); if (!(r && r instanceof ArrayBuffer)) throw new Error("An ArrayBuffer of weights must be the second element of the array"); if (!("modelTopology" in n)) throw new Error("Model JSON is missing 'modelTopology'"); if (!("weightsManifest" in n)) throw new Error("Model JSON is missing 'weightsManifest'"); const i = P.io.getWeightSpecs(n.weightsManifest), a = P.io.getModelArtifactsForJSONSync(n, i, r); t = P.io.fromMemorySync(a) } else if ("load" in e) t = e; else { if (!("modelTopology" in e && "weightSpecs" in e && "weightData" in e)) throw new Error("Unknown model format"); t = P.io.fromMemorySync(e) } const n = new jd(t); return n.load(), n } + /** @license See the LICENSE file. */ + const Vd = "4.22.0"; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var Gd, Hd, qd = n(7391); function Yd(e, t, n = new Map, r = new Set) { if (null == e) return null; if ("function" == typeof Blob && e instanceof Blob) return e.slice(); if (r.has(e)) throw new Error("Circular references are not supported."); if (n.has(e)) return n.get(e); const i = t(e); if (i.recurse && null !== i.value) throw new Error("A deep map function may not return both a value and recurse=true."); if (i.recurse) { if (Qd(e)) { const i = Array.isArray(e) ? [] : {}; r.add(e); for (const a in e) { const o = Yd(e[a], t, n, r); i[a] = o } return r.delete(e), e.__proto__ && (i.__proto__ = e.__proto__), i } throw new Error(`Can't recurse into non-iterable type: ${e}`) } return n.set(e, i.value), i.value } function Xd(e, t = Zd) { return Kd(e, t) } function Kd(e, t, n = new Set) { const r = e[0]; if (n.has(r)) throw new Error("Circular references are not supported."); const i = t(e); if (i.recurse && null !== i.value) throw new Error("A deep zip function may not return both a value and recurse=true."); if (i.recurse) { if (Qd(r)) { const i = Array.isArray(r) ? [] : {}; n.add(r); for (const a in r) { const r = Kd(e.map((e => e[a])), t, n); i[a] = r } return n.delete(r), i } throw new Error(`Can't recurse into non-iterable type: ${r}`) } return i.value } function Zd(e) { return null === e ? null : Qd(e[0]) ? { value: null, recurse: !0 } : { value: e, recurse: !1 } } async function Jd(e, t) { const n = new Map; Yd(e, t, n); for (const e of Array.from(n.keys())) { const t = n.get(e); if (P.util.isPromise(t)) { const r = await t; n.set(e, r) } } return Yd(e, t, n) } function Qd(e) { let t = !1; if (P.env().get("IS_BROWSER")) t = e instanceof TextDecoder; else { const { StringDecoder: r } = n(551); t = e instanceof r } return null != e && !ArrayBuffer.isView(e) && (Array.isArray(e) || "object" == typeof e && !(e instanceof P.Tensor) && !(e instanceof Promise) && !t) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + function ef(e) { return Yd(e, tf) } function tf(e) { return e instanceof P.Tensor ? { value: e.clone(), recurse: !1 } : Qd(e) ? { value: null, recurse: !0 } : { value: e, recurse: !1 } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class nf { constructor(e) { if (this.capacity = e, this.begin = 0, this.end = 0, null == e) throw new RangeError("Can't create a ring buffer of unknown capacity."); if (e < 1) throw new RangeError("Can't create ring buffer of capacity < 1."); this.data = new Array(e), this.doubledCapacity = 2 * e } wrap(e) { for (; e < 0;)e += this.doubledCapacity; return e % this.doubledCapacity } get(e) { if (e < 0) throw new RangeError("Can't get item at a negative index."); return this.data[e % this.capacity] } set(e, t) { if (e < 0) throw new RangeError("Can't set item at a negative index."); this.data[e % this.capacity] = t } length() { let e = this.end - this.begin; return e < 0 && (e = this.doubledCapacity + e), e } isFull() { return this.length() === this.capacity } isEmpty() { return 0 === this.length() } push(e) { if (this.isFull()) throw new RangeError("Ring buffer is full."); this.set(this.end, e), this.end = this.wrap(this.end + 1) } pushAll(e) { for (const t of e) this.push(t) } pop() { if (this.isEmpty()) throw new RangeError("Ring buffer is empty."); this.end = this.wrap(this.end - 1); const e = this.get(this.end); return this.set(this.end, void 0), e } unshift(e) { if (this.isFull()) throw new RangeError("Ring buffer is full."); this.begin = this.wrap(this.begin - 1), this.set(this.begin, e) } shift() { if (this.isEmpty()) throw new RangeError("Ring buffer is empty."); const e = this.get(this.begin); return this.set(this.begin, void 0), this.begin = this.wrap(this.begin + 1), e } shuffleExcise(e) { if (this.isEmpty()) throw new RangeError("Ring buffer is empty."); const t = this.wrap(this.begin + e), n = this.get(t); return this.set(t, this.pop()), n } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class rf extends nf { constructor() { super(rf.INITIAL_CAPACITY) } isFull() { return !1 } push(e) { super.isFull() && this.expand(), super.push(e) } unshift(e) { super.isFull() && this.expand(), super.unshift(e) } expand() { const e = 2 * this.capacity, t = new Array(e), n = this.length(); for (let e = 0; e < n; e++)t[e] = this.get(this.wrap(this.begin + e)); this.data = t, this.capacity = e, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = n } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + function af(e) { return new lf(e) } function of(e) { return new cf(e) } function sf(e, t) { return new wf(e, t) } rf.INITIAL_CAPACITY = 32; class uf { async toArray() { const e = []; let t = await this.next(); for (; !t.done;)e.push(t.value), t = await this.next(); return e } async toArrayForTest() { const e = this.prefetch(100), t = []; let n = await e.next(); for (; !n.done;)t.push(n.value), n = await e.next(); return t } async resolveFully() { let e = await this.next(); for (; !e.done;)e = await this.next() } async resolveWhile(e) { let t = await this.next(), n = e(t.value); for (; !t.done && n;)t = await this.next(), n = e(t.value) } handleErrors(e) { return new yf(this, e) } filter(e) { return new mf(this, e) } map(e) { return new gf(this, e) } mapAsync(e) { return new bf(this, e) } serialMapAsync(e) { return new bf(this, e).serial() } flatmap(e) { return new xf(this, e) } async forEachAsync(e) { return this.map(e).resolveFully() } async serialForEach(e) { return this.serialMapAsync(e).resolveWhile((e => !0 === e)) } rowMajorBatch(e, t = !0) { return new pf(this, e, t) } columnMajorBatch(e, t = !0, n = Zd) { return this.rowMajorBatch(e, t).map((e => Xd(e, n))) } concatenate(e, t) { return new wf(af([this, e]), t) } take(e) { return e < 0 || null == e ? this : new ff(this, e) } skip(e) { return e < 0 || null == e ? this : new df(this, e) } prefetch(e) { return new Sf(this, e) } shuffle(e, t) { return new _f(this, e, t) } serial() { return new hf(this) } } class lf extends uf { constructor(e) { super(), this.items = e, this.trav = 0 } summary() { return `Array of ${this.items.length} items` } async next() { if (this.trav >= this.items.length) return { value: null, done: !0 }; const e = this.items[this.trav]; return this.trav++, { value: ef(e), done: !1 } } } class cf extends uf { constructor(e) { super(), this.nextFn = e } summary() { return "Function call" } async next() { try { return this.nextFn() } catch (e) { throw e.message = `Error thrown while iterating through a dataset: ${e.message}`, e } } } class hf extends uf { constructor(e) { super(), this.upstream = e, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> Serial` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { return this.upstream.next() } } class df extends uf { constructor(e, t) { super(), this.upstream = e, this.maxCount = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> Skip` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; this.count++ < this.maxCount;) { const e = await this.upstream.next(); if (e.done) return e; P.dispose(e.value) } return this.upstream.next() } } class ff extends uf { constructor(e, t) { super(), this.upstream = e, this.maxCount = t, this.count = 0 } summary() { return `${this.upstream.summary()} -> Take` } async next() { return this.count++ >= this.maxCount ? { value: null, done: !0 } : this.upstream.next() } } class pf extends uf { constructor(e, t, n = !0) { super(), this.upstream = e, this.batchSize = t, this.enableSmallLastBatch = n, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> RowMajorBatch` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { const e = []; for (; e.length < this.batchSize;) { const t = await this.upstream.next(); if (t.done) return this.enableSmallLastBatch && e.length > 0 ? { value: e, done: !1 } : { value: null, done: !0 }; e.push(t.value) } return { value: e, done: !1 } } } class mf extends uf { constructor(e, t) { super(), this.upstream = e, this.predicate = t, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> Filter` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; ;) { const e = await this.upstream.next(); if (e.done || this.predicate(e.value)) return e; P.dispose(e.value) } } } class gf extends uf { constructor(e, t) { super(), this.upstream = e, this.transform = t } summary() { return `${this.upstream.summary()} -> Map` } async next() { const e = await this.upstream.next(); if (e.done) return { value: null, done: !0 }; const t = P.tensor_util.getTensorsInContainer(e.value), n = this.transform(e.value), r = P.tensor_util.getTensorsInContainer(n); for (const e of t) P.tensor_util.isTensorInList(e, r) || e.dispose(); return { value: n, done: !1 } } } class yf extends uf { constructor(e, t) { super(), this.upstream = e, this.handler = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> handleErrors` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; ;)try { return await this.upstream.next() } catch (e) { if (!this.handler(e)) return { value: null, done: !0 } } } } class bf extends uf { constructor(e, t) { super(), this.upstream = e, this.transform = t } summary() { return `${this.upstream.summary()} -> AsyncMap` } async next() { const e = await this.upstream.next(); if (e.done) return { value: null, done: !0 }; const t = P.tensor_util.getTensorsInContainer(e.value), n = await this.transform(e.value), r = P.tensor_util.getTensorsInContainer(n); for (const e of t) P.tensor_util.isTensorInList(e, r) || e.dispose(); return { value: n, done: !1 } } } class vf extends uf { constructor() { super(), this.outputQueue = new rf, this.lastRead = Promise.resolve({ value: null, done: !1 }) } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; 0 === this.outputQueue.length();)if (!await this.pump()) return { value: null, done: !0 }; return { value: this.outputQueue.shift(), done: !1 } } } class xf extends vf { constructor(e, t) { super(), this.upstream = e, this.transform = t } summary() { return `${this.upstream.summary()} -> Flatmap` } async pump() { const e = await this.upstream.next(); if (e.done) return !1; const t = P.tensor_util.getTensorsInContainer(e.value), n = this.transform(e.value), r = P.tensor_util.getTensorsInContainer(n); this.outputQueue.pushAll(n); for (const e of t) P.tensor_util.isTensorInList(e, r) || e.dispose(); return !0 } } class wf extends uf { constructor(e, t) { super(), this.baseErrorHandler = t, this.lastRead = null, this.iterator = null, this.moreIterators = e } summary() { return "TODO: fill in upstream of chained summaries -> Chained" } async next() { return this.lastRead = this.readFromChain(this.lastRead), this.lastRead } async readFromChain(e) { if (await e, null == this.iterator) { const e = await this.moreIterators.next(); if (e.done) return { value: null, done: !0 }; this.iterator = e.value, null != this.baseErrorHandler && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler)) } const t = await this.iterator.next(); return t.done ? (this.iterator = null, this.readFromChain(e)) : t } } (Hd = Gd || (Gd = {}))[Hd.FAIL = 0] = "FAIL", Hd[Hd.SHORTEST = 1] = "SHORTEST", Hd[Hd.LONGEST = 2] = "LONGEST"; class kf extends uf { constructor(e, t = Gd.FAIL) { super(), this.iterators = e, this.mismatchMode = t, this.count = 0, this.currentPromise = null } summary() { return "{TODO: fill in upstream of zip summaries} -> Zip" } async nextState(e) { await e; let t = 0, n = 0; const r = await Jd(this.iterators, (function (e) { if (e instanceof uf) { return { value: e.next().then((e => (t++, e.done && n++, e.value))), recurse: !1 } } return { value: null, recurse: !0 } })); if (t === n) return { value: null, done: !0 }; if (n > 0) switch (this.mismatchMode) { case Gd.FAIL: throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`); case Gd.SHORTEST: return { value: null, done: !0 }; case Gd.LONGEST: }return this.count++, { value: r, done: !1 } } async next() { return this.currentPromise = this.nextState(this.currentPromise), this.currentPromise } } class Sf extends uf { constructor(e, t) { super(), this.upstream = e, this.bufferSize = t, this.buffer = new nf(t) } summary() { return `${this.upstream.summary()} -> Prefetch` } refill() { for (; !this.buffer.isFull();) { const e = this.upstream.next(); this.buffer.push(e) } } next() { return this.refill(), this.buffer.shift() } } class _f extends Sf { constructor(e, t, n) { super(e, t), this.upstream = e, this.windowSize = t, this.upstreamExhausted = !1, this.random = qd.alea(n || P.util.now().toString()), this.lastRead = Promise.resolve({ value: null, done: !1 }) } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } randomInt(e) { return Math.floor(this.random() * e) } chooseIndex() { return this.randomInt(this.buffer.length()) } async serialNext() { for (this.upstreamExhausted || this.refill(); !this.buffer.isEmpty();) { const e = this.chooseIndex(), t = await this.buffer.shuffleExcise(e); if (!t.done) return this.refill(), t; this.upstreamExhausted = !0 } return { value: null, done: !0 } } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Cf { constructor() { this.size = null } batch(e, t = !0) { const n = this; let r; return P.util.assert(e > 0, (() => `batchSize needs to be positive, but it is\n ${e}`)), r = this.size === 1 / 0 || null == this.size ? this.size : t ? Math.ceil(this.size / e) : Math.floor(this.size / e), Af((async () => (await n.iterator()).columnMajorBatch(e, t, Nf)), r) } concatenate(e) { const t = this; let n; return n = this.size === 1 / 0 || e.size === 1 / 0 ? 1 / 0 : null != this.size && null != e.size ? this.size + e.size : null, Af((async () => (await t.iterator()).concatenate(await e.iterator())), n) } filter(e) { const t = this; let n; return n = this.size === 1 / 0 ? 1 / 0 : null, Af((async () => (await t.iterator()).filter((t => P.tidy((() => e(t)))))), n) } async forEachAsync(e) { return (await this.iterator()).forEachAsync(e) } map(e) { const t = this; return Af((async () => (await t.iterator()).map((t => P.tidy((() => e(t)))))), this.size) } mapAsync(e) { const t = this; return Af((async () => (await t.iterator()).mapAsync(e)), this.size) } prefetch(e) { if (null == e) throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified."); const t = this; return Af((async () => (await t.iterator()).prefetch(e)), this.size) } repeat(e) { const t = this; let n; return n = null != this.size && e > 0 ? this.size * e : 0 === e ? 0 : null != this.size && (void 0 === e || e < 0) ? 1 / 0 : null, Af((async () => sf(of((async () => ({ value: await t.iterator(), done: !1 }))).take(e))), n) } skip(e) { const t = this; let n; return n = null != this.size && e >= 0 && this.size >= e ? this.size - e : null != this.size && (this.size < e || void 0 === e || e < 0) ? 0 : null, Af((async () => (await t.iterator()).skip(e)), n) } shuffle(e, t, n = !0) { if (null == e || e < 0) throw null == this.size ? new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.") : new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`); const r = this, i = qd.alea(t || P.util.now().toString()); return Af((async () => { let t = i.int32(); return n && (t += i.int32()), (await r.iterator()).shuffle(e, t.toString()) }), this.size) } take(e) { const t = this; let n; return n = null != this.size && this.size > e ? e : null != this.size && this.size <= e ? this.size : null, Af((async () => (await t.iterator()).take(e)), n) } async toArray() { if (this.size === 1 / 0) throw new Error("Can not convert infinite data stream to array."); return (await this.iterator()).toArray() } async toArrayForTest() { if (this.size === 1 / 0) throw new Error("Can not convert infinite data stream to array."); return (await this.iterator()).toArrayForTest() } } function Af(e, t = null) { return new class extends Cf { constructor() { super(...arguments), this.size = t } async iterator() { return e() } } } function Tf(e) { return Af((async () => af(e)), e.length) } function Ef(e) { if (!Qd(e)) throw new Error("The argument to zip() must be an object or array."); let t; if (Array.isArray(e)) for (let n = 0; n < e.length; n++)t = null == t ? e[n].size : Math.min(t, e[n].size); else if (e instanceof Object) for (const n in e) t = null == t ? e[n].size : Math.min(t, e[n].size); return Af((async () => function (e, t = Gd.FAIL) { return new kf(e, t) }(await Jd(e, (e => { if (e instanceof Cf) return { value: e.iterator(), recurse: !1 }; if (Qd(e)) return { value: null, recurse: !0 }; throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.") })), Gd.SHORTEST)), t) } function Nf(e) { if (null === e) return null; const t = e[0]; if (null == (n = t) || null === (r = n) || "object" != typeof r && "function" != typeof r || Array.isArray(n) || "object" == typeof n && n instanceof P.Tensor || P.util.isTypedArray(n)) { return { value: function (e) { if (0 === e.length) throw new Error("Can't make a batch of zero elements."); return e[0] instanceof P.Tensor ? P.stack(e) : P.tensor(e) }(e), recurse: !1 } } var n, r; return { value: null, recurse: !0 } } Cf.MAX_BUFFER_SIZE = 1e4; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class If extends Cf { constructor(e) { super(), this.input = e } async iterator() { return (await this.input.iterator()).decodeUTF8().split("\n").map((e => (e.endsWith("\r") && (e = e.slice(0, -1)), e))) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + const Mf = '"', Ff = Symbol("out"), Df = Symbol("field"), $f = Symbol("quote"), Rf = Symbol("quoteafterquote"), Of = Symbol("quoteinquote"); class zf extends Cf { async columnNames() { return this.columnNamesValidated || await this.setColumnNames(), this.configuredColumnsOnly ? Object.keys(this.columnConfigs) : this.fullColumnNames } async setColumnNames() { const e = await this.maybeReadHeaderLine(); if (!this.fullColumnNames && !e) throw new Error("Column names must be provided if there is no header line."); this.fullColumnNames && e && P.util.assert(e.length === this.fullColumnNames.length, (() => "The length of provided columnNames (" + this.fullColumnNames.length.toString() + ") does not match the length of the header line read from file (" + e.length.toString() + ").")), this.fullColumnNames || (this.fullColumnNames = e); const t = this.fullColumnNames.reduce(((e, t) => (e[t] = e[t] + 1 || 1, e)), {}), n = Object.keys(t).filter((e => t[e] > 1)); if (P.util.assert(0 === n.length, (() => "Duplicate column names found: " + n.toString())), this.columnConfigs) for (const e of Object.keys(this.columnConfigs)) { if (-1 === this.fullColumnNames.indexOf(e)) throw new Error('The key "' + e + '" provided in columnConfigs does not match any of the column names (' + this.fullColumnNames.toString() + ").") } this.columnNamesValidated = !0 } async maybeReadHeaderLine() { if (this.hasHeader) { const e = await this.base.iterator(), t = await e.next(); if (t.done) throw new Error("No data was found for CSV parsing."); const n = t.value; return this.parseRow(n, !1) } return null } constructor(e, t) { super(), this.input = e, this.hasHeader = !0, this.fullColumnNames = null, this.columnNamesValidated = !1, this.columnConfigs = null, this.configuredColumnsOnly = !1, this.delimiter = ",", this.delimWhitespace = !1, this.base = new If(e), t || (t = {}), this.hasHeader = !1 !== t.hasHeader, this.fullColumnNames = t.columnNames, this.columnConfigs = t.columnConfigs, this.configuredColumnsOnly = t.configuredColumnsOnly, t.delimWhitespace ? (P.util.assert(null == t.delimiter, (() => "Delimiter should not be provided when delimWhitespace is true.")), this.delimWhitespace = !0, this.delimiter = " ") : this.delimiter = t.delimiter ? t.delimiter : "," } async iterator() { this.columnNamesValidated || await this.setColumnNames(); let e = await this.base.iterator(); return this.hasHeader && (e = e.skip(1)), e.map((e => this.makeDataElement(e))) } makeDataElement(e) { const t = this.parseRow(e), n = {}, r = {}; for (let i = 0; i < this.fullColumnNames.length; i++) { const a = this.fullColumnNames[i], o = this.columnConfigs ? this.columnConfigs[a] : null; if (!this.configuredColumnsOnly || o) { const s = t[i]; let u = null; if ("" === s) if (o && void 0 !== o.default) u = o.default; else { if (o && (o.required || o.isLabel)) throw new Error(`Required column ${a} is empty in this line: ${e}`); u = void 0 } else { const e = Number(s); if (isNaN(e)) u = o && "bool" === o.dtype ? this.getBoolean(s) : s; else if (o && o.dtype) switch (o.dtype) { case "float32": default: u = e; break; case "int32": u = Math.floor(e); break; case "bool": u = this.getBoolean(s) } else u = e } o && o.isLabel ? r[a] = u : n[a] = u } } return 0 === Object.keys(r).length ? n : { xs: n, ys: r } } getBoolean(e) { return "1" === e || "true" === e.toLowerCase() ? 1 : 0 } parseRow(e, t = !0) { const n = []; let r = 0; const i = e.length; let a = Ff; for (let t = 0; t < i; t++)switch (a) { case Ff: switch (e.charAt(t)) { case Mf: r = t + 1, a = $f; break; case this.delimiter: if (r = t + 1, " " === this.delimiter && this.delimWhitespace) break; n.push(""), a = Ff; break; default: a = Df, r = t }break; case Df: if (e.charAt(t) === this.delimiter) n.push(e.substring(r, t)), a = Ff, r = t + 1; break; case $f: if (e.charAt(t) === Mf) a = Rf; break; case Rf: switch (e.charAt(t)) { case this.delimiter: n.push(e.substring(r, t - 1)), a = Ff, r = t + 1; break; case Mf: a = $f; break; default: a = Of }break; case Of: if (e.charAt(t) === Mf) a = $f }if (a === Rf ? n.push(e.substring(r, i - 1)) : n.push(e.substring(r)), t && n.length !== this.fullColumnNames.length) throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${n}`); return n } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Pf extends uf { constructor(e) { super(), this.microphoneConfig = e, this.isClosed = !1, this.fftSize = e.fftSize || 1024; const t = Math.log2(this.fftSize); if (this.fftSize < 0 || t < 4 || t > 14 || !Number.isInteger(t)) throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`); if (this.numFrames = e.numFramesPerSpectrogram || 43, this.sampleRateHz = e.sampleRateHz, this.columnTruncateLength = e.columnTruncateLength || this.fftSize, this.audioTrackConstraints = e.audioTrackConstraints, this.smoothingTimeConstant = e.smoothingTimeConstant || 0, this.includeSpectrogram = !1 !== e.includeSpectrogram, this.includeWaveform = !0 === e.includeWaveform, !this.includeSpectrogram && !this.includeWaveform) throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.") } summary() { return "microphone" } static async create(e = {}) { if (!(0, P.env)().get("IS_BROWSER")) throw new Error("microphone API is only supported in browser environment."); const t = new Pf(e); return await t.start(), t } async start() { try { this.stream = await navigator.mediaDevices.getUserMedia({ audio: null == this.audioTrackConstraints || this.audioTrackConstraints, video: !1 }) } catch (e) { throw new Error(`Error thrown while initializing video stream: ${e.message}`) } if (!this.stream) throw new Error("Could not obtain audio from microphone."); const e = window.AudioContext || window.webkitAudioContext; if (this.audioContext = new e, this.sampleRateHz) { if (this.audioContext.sampleRate !== this.sampleRateHz) throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`) } else this.sampleRateHz = this.audioContext.sampleRate; const t = this.audioContext.createMediaStreamSource(this.stream); this.analyser = this.audioContext.createAnalyser(), this.analyser.fftSize = 2 * this.fftSize, this.analyser.smoothingTimeConstant = this.smoothingTimeConstant, t.connect(this.analyser), this.freqData = new Float32Array(this.fftSize), this.timeData = new Float32Array(this.fftSize) } async next() { if (this.isClosed) return { value: null, done: !0 }; let e, t; const n = await this.getAudioData(); if (this.includeSpectrogram) { const t = this.flattenQueue(n.freqDataQueue); e = this.getTensorFromAudioDataArray(t, [this.numFrames, this.columnTruncateLength, 1]) } if (this.includeWaveform) { const e = this.flattenQueue(n.timeDataQueue); t = this.getTensorFromAudioDataArray(e, [this.numFrames * this.fftSize, 1]) } return { value: { spectrogram: e, waveform: t }, done: !1 } } async capture() { return (await this.next()).value } async getAudioData() { const e = [], t = []; let n = 0; return new Promise((r => { const i = setInterval((() => { this.includeSpectrogram && (this.analyser.getFloatFrequencyData(this.freqData), this.freqData[0] === -1 / 0 && r({ freqDataQueue: e, timeDataQueue: t }), e.push(this.freqData.slice(0, this.columnTruncateLength))), this.includeWaveform && (this.analyser.getFloatTimeDomainData(this.timeData), t.push(this.timeData.slice())), ++n === this.numFrames && (clearInterval(i), r({ freqDataQueue: e, timeDataQueue: t })) }), this.fftSize / this.sampleRateHz * 1e3) })) } stop() { this.isClosed || (this.isClosed = !0, this.analyser.disconnect(), this.audioContext.close(), null != this.stream && this.stream.getTracks().length > 0 && this.stream.getTracks()[0].stop()) } toArray() { throw new Error("Can not convert infinite audio stream to array.") } getSampleRate() { return this.sampleRateHz } flattenQueue(e) { const t = e[0].length, n = new Float32Array(e.length * t); return e.forEach(((e, r) => n.set(e, r * t))), n } getTensorFromAudioDataArray(e, t) { const n = new Float32Array(P.util.sizeFromShape(t)); return n.set(e, n.length - e.length), (0, P.tensor)(n, t) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Bf extends uf { constructor(e, t) { if (super(), this.webcamVideoElement = e, this.webcamConfig = t, this.isClosed = !0, this.resize = !1, this.needToResize()) if (this.resize = !0, this.cropSize = [this.webcamConfig.resizeHeight, this.webcamConfig.resizeWidth], this.cropBoxInd = (0, P.tensor1d)([0], "int32"), this.webcamConfig.centerCrop) { const e = 1 * this.webcamConfig.resizeWidth / this.webcamVideoElement.width, t = 1 * this.webcamConfig.resizeHeight / this.webcamVideoElement.height, n = (1 - e) / 2, r = (1 - t) / 2, i = n + e, a = t + r; this.cropBox = (0, P.tensor2d)([r, n, a, i], [1, 4]) } else this.cropBox = (0, P.tensor2d)([0, 0, 1, 1], [1, 4]) } summary() { return "webcam" } static async create(e, t = {}) { if (!(0, P.env)().get("IS_BROWSER")) throw new Error("tf.data.webcam is only supported in browser environment."); if (!e) { if (e = document.createElement("video"), !t.resizeWidth || !t.resizeHeight) throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element."); e.width = t.resizeWidth, e.height = t.resizeHeight } const n = new Bf(e, t); return await n.start(), n } async start() { this.webcamConfig.facingMode && P.util.assert("user" === this.webcamConfig.facingMode || "environment" === this.webcamConfig.facingMode, (() => `Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`)); try { this.stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId: this.webcamConfig.deviceId, facingMode: this.webcamConfig.facingMode ? this.webcamConfig.facingMode : "user", width: this.webcamVideoElement.width, height: this.webcamVideoElement.height } }) } catch (e) { throw e.message = `Error thrown while initializing video stream: ${e.message}`, e } if (!this.stream) throw new Error("Could not obtain video from webcam."); try { this.webcamVideoElement.srcObject = this.stream } catch (e) { console.log(e), this.webcamVideoElement.src = window.URL.createObjectURL(this.stream) } return this.webcamVideoElement.play(), this.isClosed = !1, new Promise((e => { this.webcamVideoElement.onloadedmetadata = () => { e() } })) } async next() { if (this.isClosed) return { value: null, done: !0 }; let e; try { e = P.browser.fromPixels(this.webcamVideoElement) } catch (e) { throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`) } if (!this.resize) return { value: e, done: !1 }; try { return { value: this.cropAndResizeFrame(e), done: !1 } } catch (e) { throw new Error(`Error thrown cropping the video: ${e.message}`) } finally { e.dispose() } } needToResize() { return !(!this.webcamConfig.resizeWidth || !this.webcamConfig.resizeHeight || this.webcamVideoElement.width === this.webcamConfig.resizeWidth && this.webcamVideoElement.height === this.webcamConfig.resizeHeight) } cropAndResizeFrame(e) { return (0, P.tidy)((() => { const t = (0, P.expandDims)((0, P.cast)(e, "float32"), 0); let n; n = P.image.cropAndResize(t, this.cropBox, this.cropBoxInd, this.cropSize, "bilinear"); const r = n.shape; return (0, P.reshape)(n, r.slice(1)) })) } async capture() { return (await this.next()).value } stop() { this.stream.getTracks().forEach((e => e.stop())); try { this.webcamVideoElement.srcObject = null } catch (e) { console.log(e), this.webcamVideoElement.src = null } this.isClosed = !0 } toArray() { throw new Error("Can not convert infinite video stream to array.") } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Lf { } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class jf extends uf { split(e) { return new Uf(this, e) } } class Uf extends jf { constructor(e, t) { super(), this.upstream = e, this.impl = new Wf(e, t) } summary() { return this.impl.summary() } async next() { return this.impl.next() } } class Wf extends vf { constructor(e, t) { super(), this.upstream = e, this.separator = t, this.carryover = "" } summary() { return `${this.upstream.summary()} -> Split('${this.separator}')` } async pump() { const e = await this.upstream.next(); if (e.done) return "" !== this.carryover && (this.outputQueue.push(this.carryover), this.carryover = "", !0); const t = e.value.split(this.separator); t[0] = this.carryover + t[0]; for (const e of t.slice(0, -1)) this.outputQueue.push(e); return this.carryover = t[t.length - 1], !0 } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Vf extends uf { decodeUTF8() { return new Gf(this) } } class Gf extends jf { constructor(e) { super(), this.upstream = e, this.impl = new Hf(e) } summary() { return this.impl.summary() } async next() { return this.impl.next() } } class Hf extends vf { constructor(e) { if (super(), this.upstream = e, (0, P.env)().get("IS_BROWSER")) this.decoder = new TextDecoder("utf-8"); else { const { StringDecoder: e } = n(4530); this.decoder = new e("utf8") } } summary() { return `${this.upstream.summary()} -> Utf8` } async pump() { const e = await this.upstream.next(); let t, n; return !e.done && (t = e.value, n = (0, P.env)().get("IS_BROWSER") ? this.decoder.decode(t, { stream: !0 }) : this.decoder.write(Buffer.from(t.buffer)), this.outputQueue.push(n), !0) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class qf extends Vf { constructor(e, t = {}) { super(), this.file = e, this.options = t, P.util.assert(e instanceof Uint8Array || !!(0, P.env)().get("IS_BROWSER") && (e instanceof File || e instanceof Blob), (() => "FileChunkIterator only supports File, Blob and Uint8Array right now.")), this.offset = t.offset || 0, this.chunkSize = t.chunkSize || 1048576 } summary() { return `FileChunks ${this.file}` } async next() { if (this.offset >= (this.file instanceof Uint8Array ? this.file.byteLength : this.file.size)) return { value: null, done: !0 }; const e = new Promise(((e, t) => { const n = this.offset + this.chunkSize; if (this.file instanceof Uint8Array) e(new Uint8Array(this.file.slice(this.offset, n))); else { const r = new FileReader; r.onload = n => { let i = r.result; if (i instanceof ArrayBuffer && (i = new Uint8Array(i)), !(i instanceof Uint8Array)) return t(new TypeError("FileReader returned unknown type.")); e(i) }, r.onabort = e => t(new Error("Aborted")), r.onerror = e => t(new Error(e.type)); const i = this.file.slice(this.offset, n); r.readAsArrayBuffer(i) } this.offset = n })); return { value: await e, done: !1 } } } const Yf = e => ({ method: e.method, headers: e.headers, body: e.body, mode: e.mode, credentials: e.credentials, cache: e.cache, redirect: e.redirect, referrer: e.referrer, integrity: e.integrity }); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + function Xf(e) { return "string" == typeof e && "file://" === e.slice(0, 7) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Kf extends Lf { constructor(e, t = {}) { super(), this.input = e, this.options = t } async iterator() { if (Xf(this.input) && (0, P.env)().get("IS_NODE")) { const e = n(8108); this.input = e.readFileSync(this.input.slice(7)) } return new qf(this.input, this.options) } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + class Zf extends Lf { + constructor(e, t = {}) { super(), this.url = e, this.fileOptions = t } async iterator() { + return Xf(this.url) ? new Kf(this.url, this.fileOptions).iterator() : + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + async function (e, t = {}, n) { let r, i; "string" == typeof e ? r = e : (r = e.url, i = Yf(e)); const a = await (n || P.util.fetch)(r, i); if (a.ok) { const e = new Uint8Array(await a.arrayBuffer()); return new qf(e, t) } throw new Error(a.statusText) }(this.url, this.fileOptions) + } + } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ + function Jf(e, t = {}) { return new zf(new Zf(e), t) } function Qf(e) { const t = of(e); return Af((async () => t)) } function ep(e) { return Af((async () => { const t = await e(); return of((() => t.next())) })) } async function tp(e, t) { return Bf.create(e, t) } async function np(e) { return Pf.create(e) } + /** @license See the LICENSE file. */ + const rp = "4.22.0"; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ip(e, t) { Array.isArray(e) || (e = [e]), e.forEach((e => { null != e && P.util.assert("complex64" !== e.dtype, (() => `${t} does not support complex64 tensors in the CPU backend.`)) })) } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const ap = P.kernel_impls.whereImpl; class op extends P.KernelBackend { nextDataId() { return op.nextDataId++ } constructor() { super(), this.blockSize = 48, this.firstUse = !0, this.data = new P.DataStorage(this, (0, P.engine)()) } write(e, t, n) { this.firstUse && (this.firstUse = !1, (0, P.env)().get("IS_NODE") && P.backend_util.warn("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================")); const r = { id: this.nextDataId() }; return this.data.set(r, { values: e, dtype: n, refCount: 1 }), r } makeTensorInfo(e, t, n) { let r; if ("string" === t && null != n && n.length > 0 && P.util.isString(n[0])) { const i = n.map((e => P.util.encodeString(e))); r = this.write(i, e, t) } else r = this.write(n, e, t); return { dataId: r, shape: e, dtype: t } } refCount(e) { if (this.data.has(e)) { return this.data.get(e).refCount } return 0 } incRef(e) { this.data.get(e).refCount++ } decRef(e) { if (this.data.has(e)) { this.data.get(e).refCount-- } } move(e, t, n, r, i) { this.data.set(e, { values: t, dtype: r, refCount: i }) } numDataIds() { return this.data.numDataIds() } async read(e) { return this.readSync(e) } readSync(e) { const { dtype: t, complexTensorInfos: n } = this.data.get(e); if ("complex64" === t) { const e = this.readSync(n.real.dataId), t = this.readSync(n.imag.dataId); return P.backend_util.mergeRealAndImagArrays(e, t) } return P.util.convertBackendValuesAndArrayBuffer(this.data.get(e).values, t) } bufferSync(e) { const t = this.readSync(e.dataId); if ("string" === e.dtype) try { const n = t.map((e => P.util.decodeString(e))); return (0, P.buffer)(e.shape, e.dtype, n) } catch (e) { throw new Error("Failed to decode encoded string bytes into utf-8") } return (0, P.buffer)(e.shape, e.dtype, t) } makeOutput(e, t, n) { return (0, P.engine)().makeTensorFromTensorInfo(this.makeTensorInfo(t, n, e), this) } disposeData(e, t = !1) { if (this.data.has(e)) { if (this.data.get(e).refCount--, !t && this.data.get(e).refCount > 0) return !1; const { complexTensorInfos: n } = this.data.get(e); null != n && (this.disposeData(n.real.dataId, !0), this.disposeData(n.imag.dataId, !0)), this.data.delete(e) } return !0 } disposeIntermediateTensorInfo(e) { this.disposeData(e.dataId) } async time(e) { const t = P.util.now(); e(); return { kernelMs: P.util.now() - t } } memory() { return { unreliable: !0, reasons: ["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."] } } where(e) { ip([e], "where"); const t = this.readSync(e.dataId); return ap(e.shape, t) } dispose() { } floatPrecision() { return 32 } epsilon() { return super.epsilon() } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function sp(e) { const t = new Float32Array(e.length); for (let n = 0; n < e.length; ++n)t[n] = Math.abs(e[n]); return t } op.nextDataId = 0; const up = { kernelName: P.Abs, backendName: "cpu", kernelFunc: e => { const { x: t } = e.inputs, n = e.backend; ip(t, "abs"); let r = new Float32Array(P.util.sizeFromShape(t.shape)); return r = sp(n.data.get(t.dataId).values), n.makeOutput(r, t.shape, t.dtype) } }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function lp(e) { return (t, n, r, i, a) => { const o = P.backend_util.assertAndGetBroadcastShape(t, n), s = o.length, u = P.util.computeStrides(o), l = P.util.sizeFromShape(o), c = P.util.getTypedArrayFromDType(a, l), h = t.length, d = n.length, f = P.util.computeStrides(t), p = P.util.computeStrides(n), m = P.backend_util.getBroadcastDims(t, o), g = P.backend_util.getBroadcastDims(n, o); if (m.length + g.length === 0) for (let t = 0; t < c.length; ++t)c[t] = e(r[t % r.length], i[t % i.length]); else for (let t = 0; t < c.length; ++t) { const n = P.util.indexToLoc(t, s, u), a = n.slice(-h); m.forEach((e => a[e] = 0)); const o = P.util.locToIndex(a, h, f), l = n.slice(-d); g.forEach((e => l[e] = 0)); const y = P.util.locToIndex(l, d, p); c[t] = e(r[o], i[y]) } return [c, o] } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function cp(e) { const { inputs: t, backend: n } = e, { real: r, imag: i } = t, a = n.data.get(r.dataId).values, o = n.data.get(i.dataId).values, s = n.makeTensorInfo(r.shape, "complex64"); return n.data.get(s.dataId).complexTensorInfos = { real: n.makeTensorInfo(r.shape, "float32", a), imag: n.makeTensorInfo(i.shape, "float32", o) }, s } const hp = { kernelName: P.Complex, backendName: "cpu", kernelFunc: cp }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function dp(e, t, n = "float32") { if ("complex64" === n) { return cp({ inputs: { real: dp(e, t, "float32"), imag: dp(e, t, "float32") }, backend: e }) } const r = P.util.makeZerosTypedArray(P.util.sizeFromShape(t), n); return e.makeTensorInfo(t, n, r) } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function fp(e) { const { inputs: t, backend: n } = e, { x: r } = t; return n.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype } } const pp = { kernelName: P.Identity, backendName: "cpu", kernelFunc: fp }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function mp(e) { const { inputs: t, backend: n } = e, { input: r } = t, i = n.data.get(r.dataId).complexTensorInfos.real, a = n.data.get(i.dataId).values; return n.makeTensorInfo(i.shape, i.dtype, a) } const gp = { kernelName: P.Real, backendName: "cpu", kernelFunc: mp }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function yp(e, t, n, r) { if ("int32" === r) { return [t, "int32", Int32Array.from(e)] } if ("bool" === r) { const r = P.util.toTypedArray([0], n), [i, a] = lp(((e, t) => e !== t ? 1 : 0))(t, [], e, r, "bool"); return [a, "bool", i] } throw new Error(`Error in Cast: failed to cast ${n} to ${r}`) } function bp(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dtype: a } = r; if ("complex64" === a) { if ("complex64" === i.dtype) return fp({ inputs: { x: i }, backend: n }); const e = dp(n, i.shape, i.dtype), t = bp({ inputs: { x: i }, backend: n, attrs: { dtype: "float32" } }), r = cp({ inputs: { real: t, imag: e }, backend: n }); return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), r } if ("complex64" === i.dtype) { const e = mp({ inputs: { input: i }, backend: n }), t = bp({ inputs: { x: e }, backend: n, attrs: { dtype: a } }); return n.disposeIntermediateTensorInfo(e), t } if (!P.util.hasEncodingLoss(i.dtype, a)) { const e = fp({ inputs: { x: i }, backend: n }); return { dataId: e.dataId, shape: e.shape, dtype: a } } const o = n.data.get(i.dataId).values, [s, u, l] = yp(o, i.shape, i.dtype, a); return n.makeTensorInfo(s, u, l) } const vp = { kernelName: P.Cast, backendName: "cpu", kernelFunc: bp }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function xp(e, t, n, r) { return null == n ? ({ inputs: n, backend: i }) => { const { a, b: o } = n, s = i; ip([a, o], e); const u = s.data.get(a.dataId).values, l = s.data.get(o.dataId).values, c = "string" === a.dtype ? P.backend_util.fromUint8ToStringArray(u) : u, h = "string" === a.dtype ? P.backend_util.fromUint8ToStringArray(l) : l, d = r || a.dtype, [f, p] = t(a.shape, o.shape, c, h, d); return s.makeTensorInfo(p, d, f) } : ({ inputs: e, backend: i }) => { const { a, b: o } = e, s = i; if ("complex64" === a.dtype || "complex64" === o.dtype) { const e = bp({ inputs: { x: a }, backend: s, attrs: { dtype: "complex64" } }), t = s.data.get(e.dataId), r = t.complexTensorInfos.real, i = t.complexTensorInfos.imag, u = s.data.get(r.dataId).values, l = s.data.get(i.dataId).values, c = bp({ inputs: { x: o }, backend: s, attrs: { dtype: "complex64" } }), h = s.data.get(c.dataId), d = h.complexTensorInfos.real, f = h.complexTensorInfos.imag, p = s.data.get(d.dataId).values, m = s.data.get(f.dataId).values, [g, y, b] = n(a.shape, o.shape, u, l, p, m), v = s.makeTensorInfo(b, "float32", g), x = s.makeTensorInfo(b, "float32", y), w = cp({ inputs: { real: v, imag: x }, backend: s }); return s.disposeIntermediateTensorInfo(e), s.disposeIntermediateTensorInfo(c), s.disposeIntermediateTensorInfo(v), s.disposeIntermediateTensorInfo(x), w } { const e = s.data.get(a.dataId).values, n = s.data.get(o.dataId).values, i = r || a.dtype, [u, l] = t(a.shape, o.shape, e, n, i); return s.makeTensorInfo(l, i, u) } } } function wp(e) { return (t, n, r, i, a, o) => { const s = P.backend_util.assertAndGetBroadcastShape(t, n), u = P.util.sizeFromShape(s), l = s.length, c = P.util.computeStrides(s), h = P.util.getTypedArrayFromDType("float32", u), d = P.util.getTypedArrayFromDType("float32", u), f = P.backend_util.getBroadcastDims(t, s), p = P.backend_util.getBroadcastDims(n, s), m = P.backend_util.mergeRealAndImagArrays(r, i), g = P.backend_util.mergeRealAndImagArrays(a, o), y = t.length, b = P.util.computeStrides(t), v = n.length, x = P.util.computeStrides(n); if (f.length + p.length === 0) for (let t = 0; t < h.length; t++) { const n = t % m.length, r = t % g.length, i = e(m[2 * n], m[2 * n + 1], g[2 * r], g[2 * r + 1]); h[t] = i.real, d[t] = i.imag } else for (let t = 0; t < h.length; t++) { const n = P.util.indexToLoc(t, l, c), r = n.slice(-y); f.forEach((e => r[e] = 0)); const i = P.util.locToIndex(r, y, b), a = n.slice(-v); p.forEach((e => a[e] = 0)); const o = P.util.locToIndex(a, v, x), s = e(m[2 * i], m[2 * i + 1], g[2 * o], g[2 * o + 1]); h[t] = s.real, d[t] = s.imag } return [h, d, s] } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const kp = lp(((e, t) => e + t)), Sp = wp(((e, t, n, r) => ({ real: e + n, imag: t + r }))), _p = xp(P.Add, kp, Sp), Cp = { kernelName: P.Add, backendName: "cpu", kernelFunc: _p }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Ap(e, t, n, r, i) { const a = P.util.sizeFromShape(r), o = P.util.makeZerosTypedArray(i, n); for (let n = 0; n < e.length; n++) { const r = e[n]; if (r < 0) throw new Error("Input x must be non-negative!"); r >= i || (o[r] += a > 0 ? t[n] : 1) } return o } function Tp(e, t, n, r = !1) { const i = e.shape[0], a = e.shape[1], o = (0, P.buffer)([i, n], t.dtype); for (let s = 0; s < i; s++)for (let i = 0; i < a; i++) { const a = e.get(s, i); if (a < 0) throw new Error("Input x must be non-negative!"); a >= n || (r ? o.set(1, s, a) : t.size > 0 ? o.set(o.get(s, a) + t.get(s, i), s, a) : o.set(o.get(s, a) + 1, s, a)) } return o } + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ep = lp(((e, t) => e & t)), Np = xp(P.BitwiseAnd, Ep), Ip = { kernelName: P.BitwiseAnd, backendName: "cpu", kernelFunc: Np }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Mp(e) { return (t, n, r) => { const i = P.util.getArrayFromDType(n, t.length); for (let n = 0; n < t.length; ++n)i[n] = e(t[n], r); return i } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Fp(e, t, n) { return Dp(e, Mp(t), n) } function Dp(e, t, n) { return ({ inputs: r, attrs: i, backend: a }) => { const { x: o } = r; ip(o, e); const s = a, u = s.data.get(o.dataId).values; let l; if ("string" === o.dtype) { if (!Array.isArray(u)) throw new Error("String tensor's value was not an instance of Array"); l = P.backend_util.fromUint8ToStringArray(u) } else l = u; const c = n || o.dtype, h = t(l, c, i); return s.makeTensorInfo(o.shape, c, h) } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const $p = Mp((e => Math.ceil(e))), Rp = Dp(P.Ceil, $p), Op = { kernelName: P.Ceil, backendName: "cpu", kernelFunc: Rp }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function zp(e, t, n, r) { const i = P.util.getArrayFromDType(n, P.util.sizeFromShape(t)); if (r && "string" !== n) { let t = 0; e.forEach((e => { const n = P.util.sizeFromShape(e.shape); i.set(e.vals, t), t += n })) } else { let r = 0; e.forEach((e => { const a = "string" === n ? P.backend_util.fromUint8ToStringArray(e.vals) : e.vals; let o = 0; for (let n = 0; n < e.shape[0]; ++n) { const s = n * t[1] + r; for (let t = 0; t < e.shape[1]; ++t)i[s + t] = a[o++] } r += e.shape[1] })) } return i } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Pp = lp(((e, t) => e === t ? 1 : 0)), Bp = xp(P.Equal, Pp, null, "bool"), Lp = { kernelName: P.Equal, backendName: "cpu", kernelFunc: Bp }, jp = Mp((e => Math.exp(e))), Up = Dp(P.Exp, jp, "float32"), Wp = { kernelName: P.Exp, backendName: "cpu", kernelFunc: Up }, Vp = Mp((e => Math.expm1(e))), Gp = Dp(P.Expm1, Vp), Hp = { kernelName: P.Expm1, backendName: "cpu", kernelFunc: Gp }, qp = Mp((e => Math.floor(e))), Yp = Dp(P.Floor, qp), Xp = { kernelName: P.Floor, backendName: "cpu", kernelFunc: Yp }, Kp = lp(((e, t) => Math.floor(e / t))), Zp = xp(P.FloorDiv, Kp, null, "int32"), Jp = { kernelName: P.FloorDiv, backendName: "cpu", kernelFunc: Zp }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Qp(e, t, n, r, i, a, o, s, u) { const l = (0, P.buffer)([r, a], n); for (let n = 0; n < r; n++) { const r = []; let c = 0; for (let t = 0; t < i; t++) { const a = e[n * i + t]; c += a * o[t], r.push(a) } if (c < 0 || c >= u / a) throw new Error(`Invalid indices: ${r} does not index into ${s}`); for (let e = 0; e < a; e++)l.values[n * a + e] = t.get(...t.indexToLoc(c * a + e)) } return l } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function em(e, t, n) { const r = (0, P.buffer)(n, e.dtype); for (let n = 0; n < r.size; ++n) { const i = r.indexToLoc(n).slice(), a = i[0], o = i[2], s = t.locToIndex([a, o]); i[2] = t.values[s]; const u = e.locToIndex(i); 0 <= u && u < e.values.length && (r.values[n] = e.values[u]) } return r } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const tm = lp(((e, t) => e > t ? 1 : 0)), nm = xp(P.Greater, tm, null, "bool"), rm = { kernelName: P.Greater, backendName: "cpu", kernelFunc: nm }, im = lp(((e, t) => e >= t ? 1 : 0)), am = xp(P.GreaterEqual, im, null, "bool"), om = { kernelName: P.GreaterEqual, backendName: "cpu", kernelFunc: am }, sm = lp(((e, t) => e < t ? 1 : 0)), um = xp(P.Less, sm, null, "bool"), lm = { kernelName: P.Less, backendName: "cpu", kernelFunc: um }, cm = lp(((e, t) => e <= t ? 1 : 0)), hm = xp(P.LessEqual, cm, null, "bool"), dm = { kernelName: P.LessEqual, backendName: "cpu", kernelFunc: hm }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function fm(e, t, n) { const r = (t - e) / (n - 1), i = P.util.makeZerosTypedArray(n, "float32"); i[0] = e; for (let e = 1; e < i.length; e++)i[e] = i[e - 1] + r; return i } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const pm = Mp((e => Math.log(e))), mm = Dp(P.Log, pm), gm = { kernelName: P.Log, backendName: "cpu", kernelFunc: mm }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ym(e, t, n, r) { const i = P.util.getTypedArrayFromDType(r, P.util.sizeFromShape(n)); for (let n = 0; n < i.length; ++n) { const r = n * t; let a = e[r]; for (let n = 0; n < t; ++n) { const t = e[r + n]; (Number.isNaN(t) || t > a) && (a = t) } i[n] = a } return i } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const bm = lp(((e, t) => Math.max(e, t))), vm = xp(P.Maximum, bm), xm = { kernelName: P.Maximum, backendName: "cpu", kernelFunc: vm }, wm = lp(((e, t) => Math.min(e, t))), km = xp(P.Minimum, wm), Sm = { kernelName: P.Minimum, backendName: "cpu", kernelFunc: km }, _m = lp(((e, t) => e * t)), Cm = wp(((e, t, n, r) => ({ real: e * n - t * r, imag: e * r + t * n }))), Am = xp(P.Multiply, _m, Cm), Tm = { kernelName: P.Multiply, backendName: "cpu", kernelFunc: Am }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Em(e, t, n) { const r = P.util.createScalarValue(-1, n); return _m([], t, r, e, n) } const Nm = { kernelName: P.Neg, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t; ip(r, "neg"); const i = n.data.get(r.dataId).values, [a, o] = Em(i, r.shape, r.dtype); return n.makeTensorInfo(o, r.dtype, a) } }, Im = lp(((e, t) => e !== t ? 1 : 0)), Mm = xp(P.NotEqual, Im, null, "bool"), Fm = { kernelName: P.NotEqual, backendName: "cpu", kernelFunc: Mm }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Dm(e, t, n, r, i) { const a = t.length, o = P.util.sizeFromShape(t), s = P.util.computeStrides(t), u = P.util.computeStrides(i), l = P.util.getTypedArrayFromDType(n, P.util.sizeFromShape(i)); for (let t = 0; t < o; ++t) { const n = P.util.indexToLoc(t, a, s), i = new Array(n.length); for (let e = 0; e < i.length; e++)i[e] = n[r[e]]; l[P.util.locToIndex(i, a, u)] = e[t] } return l } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function $m(e) { const { inputs: t, attrs: n, backend: r } = e, { x: i } = t, { perm: a } = n; ip(i, "transpose"); const o = i.shape.length, s = new Array(o); for (let e = 0; e < s.length; e++)s[e] = i.shape[a[e]]; const u = Dm(r.data.get(i.dataId).values, i.shape, i.dtype, a, s); return { dataId: r.write(u, s, i.dtype), shape: s, dtype: i.dtype } } const Rm = { kernelName: P.Transpose, backendName: "cpu", kernelFunc: $m }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Om(e, t, n, r) { const [i, a] = P.backend_util.computeOutAndReduceShapes(e, r), o = (0, P.upcastType)(t, "int32"), s = P.util.makeZerosTypedArray(P.util.sizeFromShape(i), o), u = P.util.sizeFromShape(a); for (let e = 0; e < s.length; ++e) { const t = e * u; let r = 1; for (let e = 0; e < u; ++e)r *= n[t + e]; s[e] = r } return { outVals: s, outShape: i, outDtype: o } } const zm = { kernelName: P.Prod, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "prod"); const s = i.shape.length, u = P.util.parseAxisParam(a, i.shape), l = P.backend_util.getAxesPermutation(u, s); let c = u, h = i; const d = []; null != l && (h = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), d.push(h), c = P.backend_util.getInnerMostAxes(c.length, s)); const f = n.data.get(h.dataId).values, { outVals: p, outShape: m, outDtype: g } = Om(h.shape, h.dtype, f, c); let y = m; return o && (y = P.backend_util.expandShapeToKeepDim(m, u)), d.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(y, g, p) } }; function Pm(e, t, n, r) { const i = []; let a = 0; const o = t.length - 1 + n.length, s = new Array(o).fill(null).map((() => [0])); !function (e, t) { for (let n = 0; n < e.length; ++n) { const r = e[n], i = n === e.length - 1 ? t : e[n + 1].length; if (0 === r.length) throw new Error("Ragged splits may not be empty"); if (r[0] < 0) throw new Error("Ragged splits must be non-negative"); if (r[r.length - 1] > i) throw new Error("Ragged splits must not point past values"); for (let e = 1; e < r.length; ++e)if (r[e - 1] > r[e]) throw new Error("Ragged splits must be sorted in ascending order") } }(n, r); let u = 1; for (let e = 0; e < t.length - 1; ++e) { u *= t[e]; const n = t[e + 1]; for (let t = 1; t < u + 1; ++t)s[e].push(t * n) } for (let r = 0; r < e.length; ++r) { let o = e[r], u = e[r] + 1; for (let e = 0; e < n.length; ++e) { const r = n[e], i = e + t.length - 1; if (i >= 0) { const e = s[i], t = e[e.length - 1] - r[o]; for (let e = o; e < u; ++e)s[i].push(r[e + 1] + t) } o = r[o], u = r[u] } u !== o && (i.push([o, u]), a += u - o) } return { outSplits: s, valueSlices: i, numValues: a } } function Bm(e, t) { const n = e.slice(0, t); for (; n.length < t;)n.push(1); for (let r = t; r < e.length; r++)n[t - 1] *= e[r]; return n } function Lm(e, t, n, r, i) { const a = t.slice(); a[0] = i; const o = P.util.getArrayFromDType(n, P.util.sizeFromShape(a)), s = e.length; return function (e, t, n, r, i, a) { const o = Bm(t, 2)[1], s = Bm(a, 2)[1]; let u = 0; for (const t of n) for (let n = t[0]; n < t[1]; ++n) { for (let t = 0; t < r; ++t)i[u * s + t] = e[n * o + t]; ++u } }(e, t, r, 0 === s ? 0 : s / t[0], o, a), [o, a] } function jm(e, t, n, r, i, a, o, s) { + if (0 === e.length) throw new Error("paramsNestedSplits must be non empty"); if (0 === t[0].length) throw new Error("Split tensors must not be scalars"); if ( + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { e.forEach(((e, r) => { if (e < 0 || e >= n) { const i = P.util.indexToLoc(r, t.length, P.util.computeStrides(t)).join(","); throw new Error(`indices[${i}] = ${e} is not in [0, ${n})`) } })) }(a, o, t[0][0] - 1), 0 === r.length) throw new Error("params.rank must be nonzero"); const u = r[0], { outSplits: l, valueSlices: c, numValues: h } = Pm(a, o, e, u), d = function (e) { const t = []; for (let n = 0; n < e.length; ++n) { const r = e[n].length, i = P.util.getArrayFromDType("int32", r); t.push(i), e[n].forEach(((e, t) => i[t] = e)) } return t }(l), f = Lm(n, r, i, c, h); return [d, f[0], f[1]] + } + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Um = 2147483647; function Wm(e, t, n, r, i, a, o) { if (t.length > 1) throw new Error("starts must be a scalar or vector"); if (i.length > 1) throw new Error("limits must be a scalar or vector"); if (o.length > 1) throw new Error("deltas must be a scalar or vector"); const s = 0 === t.length, u = 0 === i.length, l = 0 === o.length, c = []; s || c.push(t[0]), u || c.push(i[0]), l || c.push(o[0]); for (let e = 1; e < c.length; ++e)if (c[e] !== c[e - 1]) throw new Error("starts, limits, and deltas must have the same shape"); const h = 0 === c.length ? 1 : c[0], d = P.util.getArrayFromDType("int32", h + 1); d[0] = 0; for (let t = 0; t < h; ++t) { const n = s ? e[0] : e[t], i = u ? r[0] : r[t], o = l ? a[0] : a[t]; if (0 === o) throw new Error("Requires delta != 0"); let c; if (o > 0 && i < n || o < 0 && i > n) c = 0; else if (c = Math.ceil(Math.abs((i - n) / o)), c > Um) throw new Error(`Requires ((limit - start) / delta) <= ${Um}`); d[t + 1] = d[t] + c } const f = d[h], p = P.util.getArrayFromDType(n, f); let m = 0; for (let t = 0; t < h; ++t) { const n = d[t + 1] - d[t]; let r = s ? e[0] : e[t]; const i = l ? a[0] : a[t]; for (let e = 0; e < n; ++e)p[m++] = r, r += i } return [d, p] } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var Vm = P.backend_util.RowPartitionType; class Gm { constructor(e, t, n, r, i, a, o, s, u, l) { this.shape = e, this.shapeShape = t, this.values = n, this.valuesShape = r, this.valuesDType = i, this.defaultValue = a, this.defaultValueShape = o, this.rowPartitionValues = s, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = P.backend_util.getRowPartitionTypesHelper(l), this.raggedRank = P.backend_util.getRaggedRank(this.rowPartitionTypes) } getRowPartitionTypeByDimension(e) { return this.rowPartitionTypes[0] === Vm.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e] } getRowPartitionTensor(e) { return this.rowPartitionTypes[0] === Vm.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e] } getMaxWidth(e) { const t = this.getRowPartitionTensor(e - 1); switch (this.getRowPartitionTypeByDimension(e - 1)) { case Vm.VALUE_ROWIDS: return Gm.getMaxWidthValueRowID(t); case Vm.ROW_SPLITS: return Gm.getMaxWidthRowSplit(t); default: throw new Error(`Cannot handle partition type ${Vm[this.getRowPartitionTypeByDimension(e - 1)]}`) } } static getMaxWidthRowSplit(e) { const t = e.length; if (0 === t || 1 === t) return 0; let n = 0; for (let r = 0; r < t - 1; ++r) { const t = e[r + 1] - e[r]; t > n && (n = t) } return n } static getMaxWidthValueRowID(e) { const t = e.length; if (0 === t) return 0; let n = 0, r = e[0], i = 0; for (let a = 1; a < t; ++a) { const t = e[a]; t !== r && (r = t, i = Math.max(a - n, i), n = a) } return Math.max(t - n, i) } tensorShapeFromTensor(e, t, n = !0) { if (0 === t.length) { if (-1 === e[0]) return []; throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.") } return qm(e, n) } calculateOutputSize(e) { const t = this.valuesShape, n = this.defaultValueShape; P.backend_util.validateDefaultValueShape(n, t); const r = this.tensorShapeFromTensor(this.shape, this.shapeShape), i = P.backend_util.combineRaggedTensorToTensorShapes(this.raggedRank, r, t); i[0] < 0 && (i[0] = e); for (let e = 1; e <= this.raggedRank; ++e)i[e] < 0 && (i[e] = this.getMaxWidth(e)); return i } calculateFirstParentOutputIndex(e, t, n) { const r = Math.min(e, n), i = []; let a = 0; for (let e = 0; e < r; ++e, a += t)i.push(a); for (let t = r; t < e; ++t)i.push(-1); return P.util.assert(i.length === e, (() => "Final length of result must be equal to firstDimension.")), i } calculateOutputIndexRowSplit(e, t, n, r) { const i = e.length, a = []; for (let o = 0; o < i - 1; ++o) { const i = e[o + 1] - e[o]; let s = Math.min(r, i), u = t[o]; -1 === u && (s = 0); for (let e = 0; e < s; ++e)a.push(u), u += n; for (let e = 0; e < i - s; ++e)a.push(-1) } if (i > 0 && a.length !== e[i - 1]) throw new Error("Invalid row split size."); return a } calculateOutputIndexValueRowID(e, t, n, r) { const i = e.length, a = []; if (0 === i) return []; let o = 0, s = e[0]; if (s >= t.length) throw new Error(`Got currentValueRowId=${s}, which is not less than ${t.length}`); let u = t[s]; a.push(u); for (let l = 1; l < i; ++l) { const i = e[l]; if (i === s) u >= 0 && (++o, o < r ? u += n : u = -1); else { if (o = 0, s = i, i >= t.length) throw new Error(`Got nextValueRowId=${i} which is not less than ${t.length}`); u = t[i] } a.push(u) } if (a.length !== e.length) throw new Error("Invalid row ids."); return a } calculateOutputIndex(e, t, n, r) { const i = this.getRowPartitionTensor(e), a = this.getRowPartitionTypeByDimension(e); switch (a) { case Vm.VALUE_ROWIDS: return this.calculateOutputIndexValueRowID(i, t, n, r); case Vm.ROW_SPLITS: if (i.length - 1 > t.length) throw new Error(`Row partition size is greater than output size: ${i.length - 1} > ${t.length}`); return this.calculateOutputIndexRowSplit(i, t, n, r); default: throw new Error(`Unsupported partition type: ${Vm[a]}`) } } getFirstDimensionSize() { const e = this.rowPartitionValues[0]; if (0 === this.rowPartitionTypes.length) throw new Error("No row_partition_types given."); const t = this.rowPartitionTypes[0]; switch (t) { case Vm.FIRST_DIM_SIZE: return e[0]; case Vm.VALUE_ROWIDS: throw new Error("Cannot handle VALUE_ROWIDS in first dimension."); case Vm.ROW_SPLITS: return this.rowPartitionValuesShapes[0][0] - 1; default: throw new Error(`Cannot handle type ${Vm[t]}`) } } compute() { if (this.rowPartitionValues[0].length <= 0) throw new Error("Invalid first partition input. Tensor requires at least one element."); const e = this.getFirstDimensionSize(), t = this.calculateOutputSize(e), n = new Array(this.raggedRank + 1); n[n.length - 1] = 1; for (let e = n.length - 2; e >= 0; --e)n[e] = n[e + 1] * t[e + 1]; const r = qm(t, !1), i = P.util.getArrayFromDType(this.valuesDType, P.util.sizeFromShape(r)); if (n[0] * t[0] > 0) { let a = this.calculateFirstParentOutputIndex(e, n[0], t[0]); for (let e = 1; e <= this.raggedRank; ++e) { a = this.calculateOutputIndex(e - 1, a, n[e], t[e]) } this.setOutput(this.raggedRank, a, i, r) } return [r, i] } setOutput(e, t, n, r) { if (0 === n.length) return; const i = this.values, a = n; let o = r.slice(); o = o.slice(e + 1); const s = P.util.sizeFromShape(o), u = t.length; let l = this.defaultValue; if (l.length !== s && 1 !== l.length) { const e = this.defaultValueShape; (0, P.tidy)((() => { const t = (0, P.reshape)(l, e), n = (0, P.broadcastTo)(t, o); l = n.dataSync() })) } let c = 0, h = 0, d = 0; for (let e = 0; e <= u; ++e) { let r = e < u ? t[e] : -1; if (r !== d) { if (h < d) { const e = i.subarray(c * s); Hm(a.subarray(h * s), e, (d - h) * s) } if (e >= u) { const e = n.length; r = Math.floor(e / s) } if (r > d) if (1 === this.defaultValue.length) a.subarray(d * s, r * s).fill(this.defaultValue[0]), d = r; else for (; r > d;) { Hm(a.slice(d * s), l, s), ++d } r < 0 ? (c = e + 1, h = d) : (c = e, h = d, d = h + 1) } else ++d } } } function Hm(e, t, n) { for (let r = 0; r < n; r++)e[r] = t[r] } function qm(e, t) { const n = []; for (let r of e) { if (r < 0) { if (!t) throw new Error(`Dimension ${r} must be >= 0`); if (r < -1) throw new Error(`Dimension ${r} must be >= -1`); r = -1 } n.push(r) } return n } function Ym(e, t, n, r, i, a, o, s, u, l) { return new Gm(e, t, n, r, i, a, o, s, u, l).compute() } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Xm(e, t, n, r) { if (e === t || e < t && n < 0 || t < e && n > 1) return P.util.makeZerosTypedArray(0, r); const i = Math.abs(Math.ceil((t - e) / n)), a = P.util.makeZerosTypedArray(i, r); t < e && 1 === n && (n = -1), a[0] = e; for (let e = 1; e < a.length; e++)a[e] = a[e - 1] + n; return a } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Km = Mp((e => 1 / Math.sqrt(e))), Zm = Dp(P.Rsqrt, Km), Jm = { kernelName: P.Rsqrt, backendName: "cpu", kernelFunc: Zm }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Qm(e, t, n, r, i, a, o, s, u, l) { const c = [r / i, i], h = e.values, d = t.values; if (0 === r) return (0, P.buffer)(n, t.dtype); const f = u instanceof P.TensorBuffer ? u : (0, P.buffer)(c, t.dtype); "string" == typeof u || "number" == typeof u ? f.values.fill(u) : "boolean" == typeof u && f.values.fill(+u); for (let e = 0; e < a; e++) { const a = []; let u = 0; for (let t = 0; t < o; t++) { const n = h[e * o + t]; a.push(n), u += n * s[t] } if (u < 0 || u >= r / i) throw new Error(`Invalid indices: ${a} does not index into ${n}`); for (let n = 0; n < i; n++)l ? f.values[u * i + n] += d[e * i + n] : f.values[u * i + n] = 0 === t.rank ? d[0] : d[e * i + n] } return f } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const eg = Mp((e => 1 / (1 + Math.exp(-e)))), tg = Fp(P.Sigmoid, (e => 1 / (1 + Math.exp(-e)))), ng = { kernelName: P.Sigmoid, backendName: "cpu", kernelFunc: tg }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function rg(e, t, n, r, i) { const a = P.slice_util.isSliceContinous(r, t, n), o = P.util.sizeFromShape(n), s = P.util.computeStrides(r); if (a) { const n = P.slice_util.computeFlatOffset(t, s); return "string" === i ? e.slice(n, n + o) : e.subarray(n, n + o) } const u = "string" === i ? P.backend_util.fromUint8ToStringArray(e) : e, l = (0, P.buffer)(r, i, u), c = (0, P.buffer)(n, i); for (let e = 0; e < c.size; ++e) { const n = c.indexToLoc(e), r = n.map(((e, n) => e + t[n])); c.set(l.get(...r), ...n) } return "string" === i ? P.backend_util.fromStringArrayToUint8(c.values) : c.values } function ig(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, size: o } = r; ip(i, "slice"); const [s, u] = P.slice_util.parseSliceParams(i, a, o); P.slice_util.assertParamsValid(i, s, u); const l = rg(n.data.get(i.dataId).values, s, u, i.shape, i.dtype); return n.makeTensorInfo(u, i.dtype, l) } const ag = { kernelName: P.Slice, backendName: "cpu", kernelFunc: ig }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function og(e, t, n, r, i, a, o) { const s = t[0], u = a[0], l = new Array(u), c = new Array(s), h = t[1]; if (0 === u) { if (0 !== s) throw new Error(P.backend_util.getSparseFillEmptyRowsIndicesDenseShapeMismatch(s)); return [P.util.getArrayFromDType(n, 0), [0, h], P.util.getArrayFromDType(i, 0), l, c] } let d = !0, f = 0; const p = new Array(u).fill(0); for (let t = 0; t < s; ++t) { const n = e[t * h]; if (n < 0) throw new Error(P.backend_util.getSparseFillEmptyRowsNegativeIndexErrorMessage(t, n)); if (n >= u) throw new Error(P.backend_util.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(t, n, u)); ++p[n], d = d && n >= f, f = n } let m = !0; for (let e = 0; e < u; ++e) { const t = 0 === p[e]; l[e] = t, m = m && !t, p[e] = Math.max(p[e], 1), e > 0 && (p[e] += p[e - 1]) } if (m && d) { const t = e, n = r; for (let e = 0; e < s; ++e)c[e] = e; return [t, [s, h], n, l, c] } { const t = p[u - 1], a = P.util.getArrayFromDType(n, t * h), d = P.util.getArrayFromDType(i, t), f = new Array(u).fill(0); for (let t = 0; t < s; ++t) { const n = e[t * h], i = f[n], o = (0 === n ? 0 : p[n - 1]) + i; f[n]++; for (let n = 0; n < h; ++n)a[o * h + n] = e[t * h + n]; d[o] = r[t], c[t] = o } for (let e = 0; e < u; ++e) { if (0 === f[e]) { const t = 0 === e ? 0 : p[e - 1]; a[t * h + 0] = e; for (let e = 1; e < h; ++e)a[t * h + e] = 0; d[t] = o } } return [a, [t, h], d, l, c] } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function sg(e, t, n, r, i) { const a = P.util.sizeFromShape(r), o = t[0], s = i.length, u = []; let l = 1, c = -1; for (let e = 0; e < s; ++e) { const t = i[e]; if (-1 === t) { if (-1 !== c) throw new Error(P.backend_util.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(c, e)); c = e, u.push(1) } else { if (t < 0) throw new Error(P.backend_util.getSparseReshapeNegativeOutputDimErrorMessage(e, t)); l *= t, u.push(t) } } if (-1 !== c) { if (l <= 0) throw new Error(P.backend_util.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage()); const e = Math.trunc(a / l); if (l * e !== a) throw new Error(P.backend_util.getSparseReshapeInputOutputMultipleErrorMessage(r, u)); u[c] = e } if (P.util.sizeFromShape(u) !== a) throw new Error(P.backend_util.getSparseReshapeInputOutputMismatchErrorMessage(r, u)); const h = r.length, d = []; if (h > 0) { d[h - 1] = 1; for (let e = h - 2; e >= 0; --e)d[e] = d[e + 1] * r[e + 1] } const f = []; if (s > 0) { f[s - 1] = 1; for (let e = s - 2; e >= 0; --e)f[e] = f[e + 1] * u[e + 1] } const p = P.util.getArrayFromDType(n, o * s); for (let t = 0; t < o; ++t) { let n = 0; for (let r = 0; r < h; ++r)n += e[t * h + r] * d[r]; for (let e = 0; e < s; ++e)p[t * s + e] = Math.trunc(n / f[e]), n %= f[e] } return [p, [o, s], u] } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ug(e, t, n, r, i, a = !1, o = 0) { const s = r.length, u = [t[0], e.length / t[0]], l = u[1], c = s > 0 ? i[s - 1] + 1 : 0; if (c < 0) throw new Error(P.backend_util.getSparseSegmentReductionNegativeSegmentIdsErrorMessage()); const h = t.slice(); h[0] = c; const d = h.reduce(((e, t) => e * t), 1), f = P.util.getArrayFromDType(n, d); if (0 === s) return c > 0 && f.fill(o), [f, h]; if (c <= 0) throw new Error(P.backend_util.getSparseSegmentReductionNegativeSegmentIdsErrorMessage()); let p = 0, m = 1, g = 0, y = i[p]; for (; ;) { let t = 0; if (m < s) { if (t = i[m], y === t) { ++m; continue } if (y >= t) throw new Error(P.backend_util.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage()) } if (y < 0 || y >= c) throw new Error(P.backend_util.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(y, c)); y > g && f.fill(o, g * l, y * l); for (let t = p; t < m; ++t) { const n = r[t]; if (n < 0 || n >= u[0]) throw new Error(P.backend_util.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(t, r[t], u[0])); for (let t = 0; t < l; t++)f[y * l + t] += e[n * l + t] } if (a) for (let e = 0; e < l; e++)f[y * l + e] /= m - p; if (p = m, ++m, g = y + 1, y = t, m > s) break } return g < c && f.fill(o, g * l, c * l), [f, h] } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const lg = Mp((e => Math.sqrt(e))), cg = Fp(P.Sqrt, (e => Math.sqrt(e))), hg = { kernelName: P.Sqrt, backendName: "cpu", kernelFunc: cg }, dg = lp(((e, t) => { const n = e - t; return n * n })), fg = xp(P.SquaredDifference, dg), pg = { kernelName: P.SquaredDifference, backendName: "cpu", kernelFunc: fg }, mg = Mp(((e, t) => { const { pattern: n, replaceGlobal: r, rewrite: i } = t; return e.replace(new RegExp(n, r ? "g" : ""), i) })), gg = Dp(P.StaticRegexReplace, mg), yg = { kernelName: P.StaticRegexReplace, backendName: "cpu", kernelFunc: gg }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function bg(e, t, n, r) { const i = (0, P.buffer)(e, t.dtype); for (let e = 0; e < i.size; e++) { const a = i.indexToLoc(e), o = new Array(a.length); for (let e = 0; e < o.length; e++)o[e] = a[e] * n[e] + r[e]; i.set(t.get(...o), ...a) } return i } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class vg { constructor(e, t, n, r, i, a) { this.separator = P.util.encodeString(e), this.nGramWidths = t, this.leftPad = P.util.encodeString(n), this.rightPad = P.util.encodeString(r), this.padWidth = i, this.preserveShort = a } getPadWidth(e) { return Math.min(this.padWidth < 0 ? e - 1 : this.padWidth, e - 1) } getNumNGrams(e, t) { const n = this.getPadWidth(t); return Math.max(0, e + 2 * n - t + 1) } createNGrams(e, t, n, r, i, a) { for (let o = 0; o < i; ++o) { const s = this.getPadWidth(a), u = Math.max(0, s - o), l = Math.max(0, s - (i - (o + 1))), c = a - (u + l), h = t + (u > 0 ? 0 : o - s); let d = 0; d += u * this.leftPad.length; for (let t = 0; t < c; ++t)d += e[h + t].length; d += l * this.rightPad.length; d += (u + l + c - 1) * this.separator.length, n[r + o] = new Uint8Array(d); const f = n[r + o]; let p = 0; const m = e => e.forEach((e => f[p++] = e)); for (let e = 0; e < u; ++e)m(this.leftPad), m(this.separator); for (let t = 0; t < c - 1; ++t)m(e[h + t]), m(this.separator); if (c > 0) { m(e[h + c - 1]); for (let e = 0; e < l; ++e)m(this.separator), m(this.rightPad) } else { for (let e = 0; e < l - 1; ++e)m(this.rightPad), m(this.separator); m(this.rightPad) } } } compute(e, t) { const n = e.length, r = t.length; if (r > 0) { let e = t[0]; if (0 !== e) throw new Error(`First split value must be 0, got ${e}`); for (let i = 1; i < r; ++i) { let r = t[i] >= e; if (r = r && t[i] <= n, !r) throw new Error(`Invalid split value ${t[i]}, must be in [${e}, ${n}]`); e = t[i] } if (e !== n) throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`) } const i = r - 1, a = P.util.getArrayFromDType("int32", r); if (0 === n || 0 === r) { const e = new Array(n); for (let e = 0; e <= i; ++e)a[e] = 0; return [e, a] } a[0] = 0; for (let e = 1; e <= i; ++e) { const n = t[e] - t[e - 1]; let r = 0; this.nGramWidths.forEach((e => { r += this.getNumNGrams(n, e) })), this.preserveShort && n > 0 && 0 === r && (r = 1), a[e] = a[e - 1] + r } const o = new Array(a[i]); for (let n = 0; n < i; ++n) { const r = t[n]; let i = a[n]; if (this.nGramWidths.forEach((a => { const s = t[n + 1] - t[n], u = this.getNumNGrams(s, a); this.createNGrams(e, r, o, i, u, a), i += u })), this.preserveShort && i === a[n]) { const a = t[n + 1] - t[n]; if (0 === a) continue; const s = a + 2 * this.padWidth, u = 1; this.createNGrams(e, r, o, i, u, s) } } return [o, a] } } function xg(e, t, n, r, i, a, o, s) { return new vg(n, r, i, a, o, s).compute(e, t) } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function wg(e, t, n, r) { if (!e.length) return; if (0 === t.length) { for (let t = 0; t < e.length; ++t)r.push(e.subarray(t, t + 1)); return } if (1 === t.length) { const i = t[0]; let a = e.indexOf(i); for (; -1 !== a;) { const t = e.subarray(0, a); n && 0 === t.length || r.push(t), a = (e = e.subarray(a + 1)).indexOf(i) } return void (n && 0 === e.length || r.push(e)) } let i = 0; for (let a = 0; a < e.length + 1; a++)if (a === e.length || -1 !== t.indexOf(e[a])) { const t = e.subarray(i, a); n && 0 === t.length || r.push(t), i = a + 1 } } function kg(e, t, n) { const r = e.length, i = []; let a = 0, o = 0; const s = new Array(r); for (let u = 0; u < r; ++u) { const r = i.length; wg(e[u], t, n, i); const l = i.length - r; s[u] = l, a += l, o = Math.max(o, l) } const u = P.util.getArrayFromDType("int32", 2 * a), l = new Array(a), c = [r, o]; let h = 0; for (let e = 0; e < r; ++e)for (let t = 0; t < s[e]; ++t)u[2 * h] = e, u[2 * h + 1] = t, l[h] = i[h], ++h; return [u, l, c] } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Sg(e, t) { const n = P.util.getArrayFromDType("int32", e.length); for (let r = 0; r < e.length; ++r)n[r] = P.util.fingerPrint64(e[r]).modulo(t).getLowBitsUnsigned(); return n } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const _g = lp(((e, t) => e - t)), Cg = wp(((e, t, n, r) => ({ real: e - n, imag: t - r }))), Ag = xp(P.Sub, _g, Cg), Tg = { kernelName: P.Sub, backendName: "cpu", kernelFunc: Ag }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Eg(e, t) { const n = new Array(e.rank); for (let r = 0; r < n.length; r++)n[r] = e.shape[r] * t[r]; const r = (0, P.buffer)(n, e.dtype); for (let t = 0; t < r.values.length; ++t) { const n = r.indexToLoc(t), i = new Array(e.rank); for (let t = 0; t < i.length; t++)i[t] = n[t] % e.shape[t]; const a = e.locToIndex(i); r.values[t] = e.values[a] } return r } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Ng = (e, t) => { const n = t.value - e.value; return 0 === n ? e.index - t.index : n }; function Ig(e, t, n = 0, r = e.length - 1) { for (; r > n;) { if (r - n > 600) { const i = r - n + 1, a = t - n + 1, o = Math.log(i), s = .5 * Math.exp(2 * o / 3), u = .5 * Math.sqrt(o * s * (i - s) / i) * Math.sign(a - i / 2); Ig(e, t, Math.max(n, Math.floor(t - a * s / i + u)), Math.min(r, Math.floor(t + (i - a) * s / i + u))) } const i = e[t]; let a = n, o = r; for (P.util.swap(e, n, t), Ng(e[r], i) > 0 && P.util.swap(e, n, r); a < o;) { for (P.util.swap(e, a, o), a++, o--; Ng(e[a], i) < 0;)a += 1; for (; Ng(e[o], i) > 0;)o -= 1 } 0 === Ng(e[n], i) ? P.util.swap(e, n, o) : (o += 1, P.util.swap(e, o, r)), o <= t && (n = o + 1), t <= o && (r = o - 1) } } function Mg(e, t, n, r, i) { const a = t[t.length - 1], [o, s] = [e.length / a, a], u = P.util.getTypedArrayFromDType(n, o * r), l = P.util.getTypedArrayFromDType("int32", o * r); for (let t = 0; t < o; t++) { const n = t * s, a = e.subarray(n, n + s); let o = new Array(a.length); a.forEach(((e, t) => o[t] = { value: e, index: t })), r < o.length && (Ig(o, r), o = o.slice(0, r)), i && o.sort(Ng); const c = t * r, h = u.subarray(c, c + r), d = l.subarray(c, c + r); for (let e = 0; e < r; e++)h[e] = o[e].value, d[e] = o[e].index } const c = t.slice(); return c[c.length - 1] = r, [(0, P.buffer)(c, n, u), (0, P.buffer)(c, "int32", l)] } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Fg(e, t, n, r) { const i = P.util.parseAxisParam(t, n)[0], a = [1, n[0], 1]; for (let e = 0; e < i; e++)a[0] *= n[e]; a[1] = n[i]; for (let e = i + 1; e < n.length; e++)a[2] *= n[e]; const o = new Map, s = new Int32Array(n[i]), u = new P.TensorBuffer(a, r, e), l = [], c = 1 === a[0] && 1 === a[2]; for (let t = 0; t < n[i]; t++) { let n; if (c) n = e[t].toString(); else { const e = []; for (let n = 0; n < a[0]; n++)for (let r = 0; r < a[2]; r++)e.push(u.get(n, t, r)); n = e.join(",") } const r = o.get(n); if (null != r) s[t] = r; else { const e = o.size; o.set(n, e), s[t] = e, l.push(t) } } const h = a.slice(); h[1] = o.size; const d = new P.TensorBuffer(h, r); l.forEach(((e, t) => { for (let n = 0; n < a[0]; n++)for (let r = 0; r < a[2]; r++)d.set(u.get(n, e, r), n, t, r) })); const f = n.slice(); return f[i] = h[1], { outputValues: d.values, outputShape: f, indices: s } } + /** @license See the LICENSE file. */ + const Dg = "4.22.0"; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + (0, P.registerBackend)("cpu", (() => new op), 1); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const $g = Fp(P.Elu, (e => e >= 0 ? e : Math.exp(e) - 1)), Rg = { kernelName: P.Elu, backendName: "cpu", kernelFunc: $g }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Og(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { alpha: a } = r; ip([i], "leakyRelu"); const o = P.util.sizeFromShape(i.shape), s = n.data.get(i.dataId).values, u = P.util.getTypedArrayFromDType("float32", o); for (let e = 0; e < s.length; e++)u[e] = s[e] < 0 ? a * s[e] : s[e]; return n.makeTensorInfo(i.shape, "float32", u) } const zg = { kernelName: P.LeakyRelu, backendName: "cpu", kernelFunc: Og }, Pg = lp(((e, t) => e < 0 ? t * e : e)); function Bg(e) { const { inputs: t, backend: n } = e, { x: r, alpha: i } = t; ip([r, i], "prelu"); const a = n.data.get(r.dataId).values, o = n.data.get(i.dataId).values, [s, u] = Pg(r.shape, i.shape, a, o, "float32"); return n.makeTensorInfo(u, "float32", s) } const Lg = { kernelName: P.Prelu, backendName: "cpu", kernelFunc: Bg }, jg = Fp(P.Relu, (e => Math.max(0, e))), Ug = { kernelName: P.Relu, backendName: "cpu", kernelFunc: jg }, Wg = Fp(P.Relu6, (e => Math.min(Math.max(0, e), 6))), Vg = { kernelName: P.Relu6, backendName: "cpu", kernelFunc: Wg }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Gg(e, t, n, r, i) { if ("linear" === n) return fp({ inputs: { x: t }, backend: e }); if ("relu" === n) return jg({ inputs: { x: t }, backend: e }); if ("elu" === n) return $g({ inputs: { x: t }, backend: e }); if ("relu6" === n) return Wg({ inputs: { x: t }, backend: e }); if ("prelu" === n) return Bg({ inputs: { x: t, alpha: r }, backend: e }); if ("leakyrelu" === n) return Og({ inputs: { x: t }, backend: e, attrs: { alpha: i } }); if ("sigmoid" === n) return tg({ inputs: { x: t }, backend: e }); throw new Error(`Activation ${n} has not been implemented for the CPU backend.`) } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Hg(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { shape: a } = r, o = P.util.sizeFromShape(i.shape), s = P.util.inferFromImplicitShape(a, o), u = P.util.sizeFromShape(s); P.util.assert(o === u, (() => `The new shape (${s}) has ${u} elements and the old shape (${i.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`)), n.incRef(i.dataId); const l = n.data.get(i.dataId); if (null != l.complexTensorInfos) { const e = l.complexTensorInfos.real, t = l.complexTensorInfos.imag; e.shape = s, t.shape = s } return { dataId: i.dataId, shape: s, dtype: i.dtype } } const qg = { kernelName: P.Reshape, backendName: "cpu", kernelFunc: Hg }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Yg(e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a } = t, { transposeA: o, transposeB: s } = r; ip([i, a], "matMul"); const u = i.shape.length, l = a.shape.length, c = o ? i.shape[u - 2] : i.shape[u - 1], h = s ? a.shape[l - 1] : a.shape[l - 2], d = o ? i.shape[u - 1] : i.shape[u - 2], f = s ? a.shape[l - 2] : a.shape[l - 1], p = i.shape.slice(0, -2), m = a.shape.slice(0, -2), g = P.util.sizeFromShape(p), y = P.util.sizeFromShape(m), b = P.broadcast_util.assertAndGetBroadcastShape(i.shape.slice(0, -2), a.shape.slice(0, -2)).concat([d, f]); P.util.assert(c === h, (() => `Error in matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${i.shape} and ${a.shape} and transposeA=${o} and transposeB=${s} must match.`)); const v = s ? [y, f, h] : [y, h, f], x = Hg({ inputs: { x: i }, backend: n, attrs: { shape: o ? [g, c, d] : [g, d, c] } }), w = Hg({ inputs: { x: a }, backend: n, attrs: { shape: v } }), k = o ? x.shape[1] : x.shape[2], S = o ? x.shape[2] : x.shape[1], _ = s ? w.shape[1] : w.shape[2], C = Math.max(g, y), A = n.data.get(x.dataId).values, T = n.data.get(w.dataId).values, E = P.util.computeStrides(x.shape), N = P.util.computeStrides(w.shape), [I, M, F] = o ? [E[0], 1, E[1]] : [E[0], E[1], 1], [D, $, R] = s ? [1, N[1], N[0]] : [N[1], 1, N[0]], O = S * _, z = (0, P.buffer)([C, S, _], x.dtype), B = z.values, L = n.blockSize; for (let e = 0; e < C; e++) { const t = e % g, n = e % y; for (let r = 0; r < S; r += L) { const i = Math.min(r + L, S); for (let a = 0; a < _; a += L) { const o = Math.min(a + L, _); for (let s = 0; s < k; s += L) { const u = Math.min(s + L, k); for (let l = r; l < i; l++)for (let r = a; r < o; r++) { let i = 0; for (let e = s; e < u; e++) { i += A[t * I + l * M + e * F] * T[e * D + r * $ + n * R] } B[e * O + (l * _ + r)] += i } } } } } return n.disposeIntermediateTensorInfo(x), n.disposeIntermediateTensorInfo(w), n.makeTensorInfo(b, z.dtype, z.values) } const Xg = { kernelName: P.BatchMatMul, backendName: "cpu", kernelFunc: Yg }; const Kg = { + kernelName: P._FusedMatMul, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a, bias: o, preluActivationWeights: s } = t, { transposeA: u, transposeB: l, activation: c, leakyreluAlpha: h } = r; let d, f, p; const m = []; d = Yg({ inputs: { a: i, b: a }, attrs: { transposeA: u, transposeB: l }, backend: n }), o && (f = _p({ inputs: { a: d, b: o }, backend: n }), m.push(d), d = f), c && (p = Gg(n, d, c, s, h), m.push(d), d = p); for (const e of m) n.disposeIntermediateTensorInfo(e); return d } + }, Zg = Fp(P.Acos, (e => Math.acos(e))), Jg = { kernelName: P.Acos, backendName: "cpu", kernelFunc: Zg }, Qg = Fp(P.Acosh, (e => Math.acosh(e))), ey = { kernelName: P.Acosh, backendName: "cpu", kernelFunc: Qg }; const ty = { + kernelName: P.AddN, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, r = t; ip(t, "addN"); const i = r.map((e => n.data.get(e.dataId).values)), a = (0, P.buffer)(r[0].shape, r[0].dtype), o = a.values; for (let e = 0; e < r.length; e++) { const t = i[e]; for (let e = 0; e < o.length; e++)o[e] += t[e] } return n.makeTensorInfo(a.shape, a.dtype, a.values) } + }; const ny = { + kernelName: P.All, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "all"); const s = P.util.parseAxisParam(a, i.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, i.shape.length); let c = i; null != l && (c = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), u = P.backend_util.getInnerMostAxes(u.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("all", u, c.shape.length); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u), f = P.util.sizeFromShape(d), p = P.util.makeZerosTypedArray(P.util.sizeFromShape(h), c.dtype), m = n.data.get(c.dataId).values; for (let e = 0; e < p.length; ++e) { const t = e * f; let n = m[t]; for (let e = 0; e < f; ++e) { const r = m[t + e]; n = n && r } p[e] = n } null != l && n.disposeIntermediateTensorInfo(c); const g = n.makeTensorInfo(h, c.dtype, p); if (o) { const e = Hg({ inputs: { x: g }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(h, s) } }); return n.disposeIntermediateTensorInfo(g), e } return g } + }; const ry = { + kernelName: P.Any, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "any"); const s = P.util.parseAxisParam(a, i.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, i.shape.length); let c = i; null != l && (c = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), u = P.backend_util.getInnerMostAxes(u.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("any", u, c.shape.length); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u), f = P.util.sizeFromShape(d), p = P.util.makeZerosTypedArray(P.util.sizeFromShape(h), c.dtype), m = n.data.get(c.dataId).values; for (let e = 0; e < p.length; ++e) { const t = e * f; let n = m[t]; for (let e = 0; e < f; ++e) { const r = m[t + e]; n = n || r } p[e] = n } null != l && n.disposeIntermediateTensorInfo(c); const g = n.makeTensorInfo(h, c.dtype, p); if (o) { const e = Hg({ inputs: { x: g }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(h, s) } }); return n.disposeIntermediateTensorInfo(g), e } return g } + }; const iy = { + kernelName: P.ArgMax, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; ip(i, "argMax"); let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = $m({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), o = [o[0]], P.backend_util.assertAxesAreInnerMostDims("argMax", o, u.shape.length); const [c, h] = P.backend_util.computeOutAndReduceShapes(u.shape, o), d = P.util.sizeFromShape(c), f = P.util.makeZerosTypedArray(d, "int32"), p = P.util.sizeFromShape(h), m = n.data.get(u.dataId).values; for (let e = 0; e < f.length; ++e) { const t = e * p; let n = m[t], r = 0; for (let e = 0; e < p; ++e) { const i = m[t + e]; i > n && (n = i, r = e) } f[e] = r } return l.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(c, "int32", f) } + }; const ay = { + kernelName: P.ArgMin, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; ip(i, "argMin"); let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = $m({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), o = [o[0]], P.backend_util.assertAxesAreInnerMostDims("argMin", o, u.shape.length); const [c, h] = P.backend_util.computeOutAndReduceShapes(u.shape, o), d = P.util.sizeFromShape(c), f = P.util.makeZerosTypedArray(d, "int32"), p = P.util.sizeFromShape(h), m = n.data.get(u.dataId).values; for (let e = 0; e < f.length; ++e) { const t = e * p; let n = m[t], r = 0; for (let e = 0; e < p; ++e) { const i = m[t + e]; i < n && (n = i, r = e) } f[e] = r } return l.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(c, "int32", f) } + }, oy = Fp(P.Asin, (e => Math.asin(e))), sy = { kernelName: P.Asin, backendName: "cpu", kernelFunc: oy }, uy = Fp(P.Asinh, (e => Math.asinh(e))), ly = { kernelName: P.Asinh, backendName: "cpu", kernelFunc: uy }, cy = Fp(P.Atan, (e => Math.atan(e))), hy = { kernelName: P.Atan, backendName: "cpu", kernelFunc: cy }, dy = lp(((e, t) => Math.atan2(e, t))), fy = xp(P.Atan2, dy), py = { kernelName: P.Atan2, backendName: "cpu", kernelFunc: fy }, my = Fp(P.Atanh, (e => Math.atanh(e))), gy = { kernelName: P.Atanh, backendName: "cpu", kernelFunc: my }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function yy(e, t, n, r, i, a) { const o = i.strideHeight, s = i.strideWidth, u = i.dilationHeight, l = i.dilationWidth, c = i.effectiveFilterHeight, h = i.effectiveFilterWidth, d = i.padInfo.top, f = i.padInfo.left, p = "max" === a ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, m = (0, P.buffer)(i.outShape, n), g = m.values, y = i.outShape[1] * i.outShape[2] * i.outShape[3], b = i.outShape[2] * i.outShape[3], v = i.outShape[3]; for (let t = 0; t < i.batchSize; ++t) { const n = t * y, m = t * r[0]; for (let t = 0; t < i.inChannels; ++t)for (let y = 0; y < i.outHeight; ++y) { const x = y * o - d, w = Math.max(0, x), k = Math.min(i.inHeight, c + x), S = n + y * b; for (let n = 0; n < i.outWidth; ++n) { const o = n * s - f, c = Math.max(0, o), d = Math.min(i.inWidth, h + o); let y = p, b = 0, x = 0; for (let n = w; n < k; n += u) { const i = m + n * r[1]; for (let n = c; n < d; n += l) { const o = e[i + n * r[2] + t]; "max" === a && o > y ? y = o : "avg" === a && (b += o, x++) } if (isNaN(y)) break } g[S + n * v + t] = "avg" === a ? b / x : y } } } return m } function by(e, t, n, r, i = !1, a = !1) { const o = (0, P.buffer)(r.outShape, "int32"), s = r.strideHeight, u = r.strideWidth, l = r.dilationHeight, c = r.dilationWidth, h = r.effectiveFilterHeight, d = r.effectiveFilterWidth, f = r.padInfo.top, p = r.padInfo.left, m = (0, P.buffer)(t, n, e); for (let e = 0; e < r.batchSize; ++e)for (let t = 0; t < r.inChannels; ++t)for (let n = 0; n < r.outHeight; ++n) { const g = n * s - f; let y = g; for (; y < 0;)y += l; const b = Math.min(r.inHeight, h + g); for (let s = 0; s < r.outWidth; ++s) { const h = s * u - p; let f = h; for (; f < 0;)f += c; const v = Math.min(r.inWidth, d + h); let x = Number.NEGATIVE_INFINITY, w = -1; for (let n = y; n < b; n += l) { const o = n - g; for (let s = f; s < v; s += c) { const u = s - h, l = m.get(e, n, s, t); l > x && (x = l, w = i ? a ? ((e * r.inHeight + n) * r.inWidth + s) * r.inChannels + t : (n * r.inWidth + s) * r.inChannels + t : o * d + u) } } o.set(w, e, n, s, t) } } return o } function vy(e, t, n, r, i, a) { const o = i.strideDepth, s = i.strideHeight, u = i.strideWidth, l = i.dilationDepth, c = i.dilationHeight, h = i.dilationWidth, d = i.effectiveFilterDepth, f = i.effectiveFilterHeight, p = i.effectiveFilterWidth, m = i.padInfo.front, g = i.padInfo.top, y = i.padInfo.left, b = "max" === a ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, v = (0, P.buffer)(i.outShape, n), x = v.values, w = i.outShape[1] * i.outShape[2] * i.outShape[3] * i.outShape[4], k = i.outShape[2] * i.outShape[3] * i.outShape[4], S = i.outShape[3] * i.outShape[4], _ = i.outShape[4]; for (let t = 0; t < i.batchSize; ++t) { const n = t * w, v = t * r[0]; for (let t = 0; t < i.inChannels; ++t)for (let w = 0; w < i.outDepth; ++w) { const C = w * o - m; let A = C; for (; A < 0;)A += l; const T = Math.min(i.inDepth, d + C), E = n + w * k; for (let n = 0; n < i.outHeight; ++n) { const o = n * s - g; let d = o; for (; d < 0;)d += c; const m = Math.min(i.inHeight, f + o), w = E + n * S; for (let n = 0; n < i.outWidth; ++n) { const o = n * u - y; let s = o; for (; s < 0;)s += h; const f = Math.min(i.inWidth, p + o), g = w + n * _; let k = b, S = 0, C = 0; for (let n = A; n < T; n += l) { const i = v + n * r[1]; for (let n = d; n < m; n += c) { const o = i + n * r[2]; for (let n = s; n < f; n += h) { const i = e[o + n * r[3] + t]; if ("max" === a && i > k ? k = i : "avg" === a && (S += i, C++), isNaN(k)) break } if (isNaN(k)) break } if (isNaN(k)) break } x[g + t] = "avg" === a ? S / Math.max(C, 1) : k } } } } return v } const xy = { + kernelName: P.AvgPool, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; ip(i, "avgPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); let c; if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) c = fp({ inputs: { x: i }, backend: n }); else { const e = n.data.get(i.dataId).values, t = P.util.computeStrides(i.shape), r = yy(e, i.shape, i.dtype, t, l, "avg"); c = n.makeTensorInfo(l.outShape, i.dtype, r.values) } return c } + }; const wy = { + kernelName: P.AvgPool3D, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u, dataFormat: l } = r; ip(i, "avgPool3d"); const c = P.backend_util.computePool3DInfo(i.shape, a, o, 1, s, u, l), h = vy(n.data.get(i.dataId).values, i.shape, i.dtype, P.util.computeStrides(i.shape), c, "avg"); return n.makeTensorInfo(h.shape, "float32", h.values) } + }; const ky = { + kernelName: P.AvgPool3DGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, { filterSize: o, strides: s, pad: u, dimRoundingMode: l } = r; ip([i, a], "avgPool3DGrad"); const c = P.backend_util.computePool3DInfo(a.shape, o, s, 1, u, l), h = c.strideDepth, d = c.strideHeight, f = c.strideWidth, p = c.filterDepth, m = c.filterHeight, g = c.filterWidth, y = c.dilationDepth, b = c.dilationHeight, v = c.dilationWidth, x = c.effectiveFilterDepth, w = c.effectiveFilterHeight, k = c.effectiveFilterWidth, S = x - 1 - c.padInfo.front, _ = k - 1 - c.padInfo.left, C = w - 1 - c.padInfo.top, A = (0, P.buffer)(a.shape, "float32"), T = 1 / (p * m * g), E = n.bufferSync(i); for (let e = 0; e < c.batchSize; ++e)for (let t = 0; t < c.inChannels; ++t)for (let n = 0; n < c.inDepth; ++n)for (let r = 0; r < c.inHeight; ++r)for (let i = 0; i < c.inWidth; ++i) { const a = n - S, o = r - C, s = i - _; let u = 0; for (let n = 0; n < x; n += y) { const r = (a + n) / h; if (!(r < 0 || r >= c.outDepth || Math.floor(r) !== r)) for (let n = 0; n < w; n += b) { const i = (o + n) / d; if (!(i < 0 || i >= c.outHeight || Math.floor(i) !== i)) for (let n = 0; n < k; n += v) { const a = (s + n) / f; if (a < 0 || a >= c.outWidth || Math.floor(a) !== a) continue; u += E.get(e, r, i, a, t) } } } A.set(u * T, e, n, r, i, t) } return n.makeTensorInfo(A.shape, A.dtype, A.values) } + }; const Sy = { + kernelName: P.AvgPoolGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a; ip([i, a], "avgPoolGrad"); const { filterSize: s, strides: u, pad: l } = r, c = P.backend_util.computePool2DInfo(o.shape, s, u, 1, l), h = c.strideHeight, d = c.strideWidth, f = c.filterHeight, p = c.filterWidth, m = c.dilationHeight, g = c.dilationWidth, y = c.effectiveFilterHeight, b = c.effectiveFilterWidth, v = b - 1 - c.padInfo.left, x = y - 1 - c.padInfo.top, w = (0, P.buffer)(o.shape, "float32"), k = 1 / (f * p), S = n.data.get(i.dataId).values, _ = (0, P.buffer)(i.shape, "float32", S); for (let e = 0; e < c.batchSize; ++e)for (let t = 0; t < c.inChannels; ++t)for (let n = 0; n < c.inHeight; ++n)for (let r = 0; r < c.inWidth; ++r) { const i = n - x, a = r - v; let o = 0; for (let n = 0; n < y; n += m) { const r = (i + n) / h; if (!(r < 0 || r >= c.outHeight || Math.floor(r) !== r)) for (let n = 0; n < b; n += g) { const i = (a + n) / d; if (i < 0 || i >= c.outWidth || Math.floor(i) !== i) continue; o += _.get(e, r, i, t) } } w.set(o * k, e, n, r, t) } return n.makeTensorInfo(w.shape, w.dtype, w.values) } + }; const _y = { + kernelName: P.FusedBatchNorm, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, scale: a, offset: o, mean: s, variance: u } = t; P.util.assert(s.shape.length === u.shape.length, (() => "Batch normalization gradient requires mean and variance to have equal ranks.")), P.util.assert(null == o || s.shape.length === o.shape.length, (() => "Batch normalization gradient requires mean and offset to have equal ranks.")), P.util.assert(null == a || s.shape.length === a.shape.length, (() => "Batch normalization gradient requires mean and scale to have equal ranks.")), ip([i, s, u, a, o], "batchNorm"); let { varianceEpsilon: l } = r; null == l && (l = .001); const c = n.data.get(i.dataId).values, h = n.data.get(s.dataId).values, d = n.data.get(u.dataId).values, f = a ? n.data.get(a.dataId).values : new Float32Array([1]), p = o ? n.data.get(o.dataId).values : new Float32Array([0]), m = new Float32Array(c.length), g = p.length, y = f.length, b = d.length, v = h.length; let x = 0, w = 0, k = 0, S = 0; for (let e = 0; e < c.length; ++e)m[e] = p[x++] + (c[e] - h[w++]) * f[k++] / Math.sqrt(d[S++] + l), x >= g && (x = 0), w >= v && (w = 0), k >= y && (k = 0), S >= b && (S = 0); return n.makeTensorInfo(i.shape, i.dtype, m) } + }; const Cy = { + kernelName: P.BatchToSpaceND, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, crops: o } = r; ip([i], "batchToSpaceND"); const s = a.reduce(((e, t) => e * t)), u = P.backend_util.getReshaped(i.shape, a, s), l = P.backend_util.getPermuted(u.length, a.length), c = P.backend_util.getReshapedPermuted(i.shape, a, s), h = P.backend_util.getSliceBeginCoords(o, a.length), d = P.backend_util.getSliceSize(c, o, a.length), f = Hg({ inputs: { x: i }, backend: n, attrs: { shape: u } }), p = $m({ inputs: { x: f }, backend: n, attrs: { perm: l } }), m = Hg({ inputs: { x: p }, backend: n, attrs: { shape: c } }), g = ig({ inputs: { x: m }, backend: n, attrs: { begin: h, size: d } }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), g } + }; const Ay = { + kernelName: P.Bincount, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o } = r, s = Ap(n.data.get(i.dataId).values, n.data.get(a.dataId).values, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, s) } + }; const Ty = { + kernelName: P.BroadcastArgs, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { s0: r, s1: i } = t, a = n.data.get(r.dataId).values, o = n.data.get(i.dataId).values, s = P.backend_util.assertAndGetBroadcastShape(Array.from(a), Array.from(o)); return n.makeTensorInfo([s.length], "int32", Int32Array.from(s)) } + }, Ey = Fp(P.ClipByValue, ((e, t) => { const n = t; return e > n.clipValueMax ? n.clipValueMax : e < n.clipValueMin ? n.clipValueMin : e })), Ny = { kernelName: P.ClipByValue, backendName: "cpu", kernelFunc: Ey }, Iy = { kernelName: P.ComplexAbs, backendName: "cpu", kernelFunc: e => { const { x: t } = e.inputs, n = e.backend, r = new Float32Array(P.util.sizeFromShape(t.shape)), i = n.data.get(t.dataId), a = i.complexTensorInfos.real, o = i.complexTensorInfos.imag, s = n.data.get(a.dataId).values, u = n.data.get(o.dataId).values; for (let e = 0; e < s.length; e++) { const t = s[e], n = u[e]; r[e] = Math.hypot(t, n) } return n.makeOutput(r, t.shape, "float32") } }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function My(e) { const { inputs: t, backend: n } = e, { input: r } = t, i = n.data.get(r.dataId).complexTensorInfos.imag, a = n.data.get(i.dataId).values; return n.makeTensorInfo(i.shape, i.dtype, a) } const Fy = { kernelName: P.Imag, backendName: "cpu", kernelFunc: My }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Dy(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r, a = P.util.parseAxisParam(i, t[0].shape)[0], o = t.map((e => e.shape)); P.backend_util.assertParamsConsistent(o, a); let s = P.backend_util.computeOutShape(t.map((e => e.shape)), a); if (0 === P.util.sizeFromShape(s)) return n.makeTensorInfo(s, t[0].dtype, []); const u = t.filter((e => P.util.sizeFromShape(e.shape) > 0)); if (1 === u.length) return fp({ inputs: { x: u[0] }, backend: n }); if ("complex64" === u[0].dtype) { const e = u.map((e => mp({ inputs: { input: e }, backend: n }))), t = u.map((e => My({ inputs: { input: e }, backend: n }))), r = Dy({ inputs: e, backend: n, attrs: { axis: a } }), i = Dy({ inputs: t, backend: n, attrs: { axis: a } }), o = cp({ inputs: { real: r, imag: i }, backend: n }); return e.forEach((e => n.disposeIntermediateTensorInfo(e))), t.forEach((e => n.disposeIntermediateTensorInfo(e))), n.disposeIntermediateTensorInfo(r), n.disposeIntermediateTensorInfo(i), o } const l = u.map((e => { const t = P.util.sizeFromShape(e.shape.slice(a)); return Hg({ inputs: { x: e }, backend: n, attrs: { shape: [-1, t] } }) })), c = l.map((e => ({ vals: n.data.get(e.dataId).values, shape: e.shape }))); s = P.backend_util.computeOutShape(l.map((e => e.shape)), 1); const h = 1 === l[0].shape[0], d = zp(c, s, t[0].dtype, h), f = P.backend_util.computeOutShape(u.map((e => e.shape)), a), p = n.makeTensorInfo(f, t[0].dtype, d); return l.forEach((e => n.disposeIntermediateTensorInfo(e))), p } const $y = { kernelName: P.Concat, backendName: "cpu", kernelFunc: Dy }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Ry(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dataFormat: u, dilations: l, dimRoundingMode: c } = r; ip([i, a], "conv2d"); const h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, l, s, c, !1, h), f = d.filterHeight, p = d.filterWidth, m = d.dilationHeight, g = d.dilationWidth, y = d.padInfo.left, b = d.padInfo.top, v = "channelsLast" === d.dataFormat, x = new P.TensorBuffer(d.outShape, i.dtype), w = P.util.computeStrides(i.shape), k = P.util.computeStrides(a.shape), S = w[0], _ = v ? w[1] : w[2], C = v ? w[2] : 1, A = v ? 1 : w[1], T = x.strides[0], E = v ? x.strides[1] : x.strides[2], N = v ? x.strides[2] : 1, I = v ? 1 : x.strides[1], M = n.data.get(i.dataId).values, F = n.data.get(a.dataId).values, D = x.values; for (let e = 0; e < d.batchSize; ++e) { const t = e * S, n = e * T; for (let e = 0; e < d.outHeight; ++e) { const r = n + e * E, i = e * d.strideHeight - b; for (let e = 0; e < f; ++e) { const n = i + e * m; if (n < 0 || n >= d.inHeight) continue; const a = e * k[0], o = t + n * _; for (let e = 0; e < d.outWidth; ++e) { const t = r + e * N, n = e * d.strideWidth - y; for (let e = 0; e < p; ++e) { const r = n + e * g; if (r < 0 || r >= d.inWidth) continue; const i = o + r * C; let s = a + e * k[1]; for (let e = 0; e < d.inChannels; ++e) { const n = M[i + e * A]; for (let e = 0; e < d.outChannels; ++e)D[t + e * I] += n * F[s + e]; s += d.outChannels } } } } } } return n.makeTensorInfo(x.shape, x.dtype, D) } const Oy = { kernelName: P.Conv2D, backendName: "cpu", kernelFunc: Ry }; const zy = { + kernelName: P.Conv2DBackpropFilter, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, dataFormat: u, dimRoundingMode: l, filterShape: c } = r; ip([i, a], "conv2dBackpropFilter"); const h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, c, o, 1, s, l, !1, h), { strideHeight: f, strideWidth: p, filterHeight: m, filterWidth: g } = d, y = "channelsLast" === d.dataFormat, b = new P.TensorBuffer(d.filterShape, "float32"), v = d.padInfo.left, x = d.padInfo.top, w = n.data.get(i.dataId).values, k = n.data.get(a.dataId).values, S = new P.TensorBuffer(i.shape, i.dtype, w), _ = new P.TensorBuffer(a.shape, a.dtype, k); for (let e = 0; e < m; ++e) { const t = Math.max(0, Math.ceil((x - e) / f)), n = Math.min(d.outHeight, (d.inHeight + x - e) / f); for (let r = 0; r < g; ++r) { const i = Math.max(0, Math.ceil((v - r) / p)), a = Math.min(d.outWidth, (d.inWidth + v - r) / p); for (let o = 0; o < d.inChannels; ++o)for (let s = 0; s < d.outChannels; ++s) { let u = 0; for (let l = 0; l < d.batchSize; ++l)for (let c = t; c < n; ++c) { const t = e + c * f - x; for (let e = i; e < a; ++e) { const n = r + e * p - v; u += y ? S.get(l, t, n, o) * _.get(l, c, e, s) : S.get(l, o, t, n) * _.get(l, s, c, e) } } b.set(u, e, r, o, s) } } } return n.makeTensorInfo(b.shape, b.dtype, b.values) } + }; const Py = { + kernelName: P.Conv2DBackpropInput, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { inputShape: o, strides: s, pad: u, dataFormat: l, dimRoundingMode: c } = r; ip([i, a], "conv2dBackpropInput"); const h = P.util.computeStrides(a.shape), d = P.util.computeStrides(i.shape); let f = P.backend_util.convertConv2DDataFormat(l); const p = P.backend_util.computeConv2DInfo(o, a.shape, s, 1, u, c, !1, f), m = new P.TensorBuffer(p.inShape, "float32"), g = m.values, y = n.data.get(i.dataId).values, b = n.data.get(a.dataId).values, [v, x, w] = h, { batchSize: k, filterHeight: S, filterWidth: _, inChannels: C, inHeight: A, inWidth: T, outChannels: E, outHeight: N, outWidth: I, strideHeight: M, strideWidth: F } = p; f = p.dataFormat; const D = S - 1 - p.padInfo.top, $ = _ - 1 - p.padInfo.left, R = "channelsLast" === f, O = m.strides[0], z = R ? m.strides[1] : m.strides[2], B = R ? m.strides[2] : 1, L = R ? 1 : m.strides[1], j = d[0], U = R ? d[1] : d[2], W = R ? d[2] : 1, V = R ? 1 : d[1]; for (let e = 0; e < k; ++e)for (let t = 0; t < C; ++t)for (let n = 0; n < A; ++n) { const r = n - D, i = Math.max(0, Math.ceil(r / M)), a = Math.min(N, (S + r) / M); for (let o = 0; o < T; ++o) { const s = o - $, u = Math.max(0, Math.ceil(s / F)), l = Math.min(I, (_ + s) / F); let c = 0; for (let n = i; n < a; ++n) { const i = n * M - r; for (let r = u; r < l; ++r) { const a = j * e + U * n + W * r, o = v * (S - 1 - i) + x * (_ - 1 - (r * F - s)) + w * t; for (let e = 0; e < E; ++e) { c += y[a + V * e] * b[o + e] } } } g[O * e + z * n + B * o + L * t] = c } } return n.makeTensorInfo(m.shape, m.dtype, m.values) } + }; const By = { + kernelName: P.Conv3D, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r; ip([i, a], "conv3d"); const l = P.backend_util.computeConv3DInfo(i.shape, a.shape, o, u, s), { filterDepth: c, filterHeight: h, filterWidth: d, dilationDepth: f, dilationHeight: p, dilationWidth: m, padInfo: g } = l, y = g.front, b = g.left, v = g.top, x = new P.TensorBuffer(l.outShape, i.dtype), w = n.data.get(i.dataId).values, k = n.data.get(a.dataId).values, S = x.values, _ = P.util.computeStrides(i.shape), C = P.util.computeStrides(a.shape); for (let e = 0; e < l.batchSize; ++e) { const t = e * _[0], n = e * x.strides[0]; for (let e = 0; e < l.outDepth; ++e) { const r = n + e * x.strides[1], i = e * l.strideDepth - y; for (let e = 0; e < c; ++e) { const n = i + e * f; if (n < 0 || n >= l.inDepth) continue; const a = e * C[0], o = t + n * _[1]; for (let e = 0; e < l.outHeight; ++e) { const t = r + e * x.strides[2], n = e * l.strideHeight - v; for (let e = 0; e < h; ++e) { const r = n + e * p; if (r < 0 || r >= l.inHeight) continue; const i = a + e * C[1], s = o + r * _[2]; for (let e = 0; e < l.outWidth; ++e) { const n = t + e * l.outChannels, r = e * l.strideWidth - b; for (let e = 0; e < d; ++e) { const t = r + e * m; if (t < 0 || t >= l.inWidth) continue; const a = i + e * C[2], o = s + t * l.inChannels; let u = a; for (let e = 0; e < l.inChannels; ++e) { const t = w[o + e]; for (let e = 0; e < l.outChannels; ++e)S[n + e] += t * k[u + e]; u += l.outChannels } } } } } } } } return n.makeTensorInfo(x.shape, x.dtype, x.values) } + }; const Ly = { + kernelName: P.Conv3DBackpropFilterV2, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, filterShape: u } = r; ip([i, a], "conv3dBackpropFilterV2"); const l = P.util.computeStrides(i.shape), c = P.util.computeStrides(a.shape), h = P.backend_util.computeConv3DInfo(i.shape, u, o, 1, s), d = h.strideDepth, f = h.strideHeight, p = h.strideWidth, m = h.filterDepth, g = h.filterHeight, y = h.filterWidth, b = new P.TensorBuffer(h.filterShape, "float32"), v = b.values, [x, w, k, S] = b.strides, _ = n.data.get(a.dataId).values, [C, A, T, E] = c, N = n.data.get(i.dataId).values, [I, M, F, D] = l, $ = h.padInfo.front, R = h.padInfo.left, O = h.padInfo.top; for (let e = 0; e < m; ++e) { const t = Math.max(0, Math.ceil(($ - e) / d)), n = Math.min(h.outDepth, (h.inDepth + $ - e) / d), r = e * x; for (let i = 0; i < g; ++i) { const a = Math.max(0, Math.ceil((O - i) / f)), o = Math.min(h.outHeight, (h.inHeight + O - i) / f), s = i * w + r; for (let r = 0; r < y; ++r) { const u = Math.max(0, Math.ceil((R - r) / p)), l = Math.min(h.outWidth, (h.inWidth + R - r) / p), c = r * k + s; for (let s = 0; s < h.inChannels; ++s) { const m = s * S + c; for (let c = 0; c < h.outChannels; ++c) { let g = 0; for (let m = 0; m < h.batchSize; ++m) { const h = m * I, y = m * C; for (let m = t; m < n; ++m) { const t = (e + m * d - $) * M + h, n = m * A + y; for (let e = a; e < o; ++e) { const a = (i + e * f - O) * F + t, o = e * T + n; for (let e = u; e < l; ++e) { const t = e * E + o; g += N[(r + e * p - R) * D + a + s] * _[t + c] } } } } v[m + c] = g } } } } } return n.makeTensorInfo(b.shape, b.dtype, b.values) } + }; const jy = { + kernelName: P.Conv3DBackpropInputV2, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { pad: o, strides: s, inputShape: u } = r; ip([i], "conv3dBackpropInputV2"); const l = P.util.computeStrides(i.shape), c = P.util.computeStrides(a.shape), h = P.backend_util.computeConv3DInfo(u, a.shape, s, 1, o), d = new P.TensorBuffer(h.inShape, "float32"), f = d.values, [p, m, g, y] = d.strides, b = n.data.get(i.dataId).values, [v, x, w, k] = l, S = n.data.get(a.dataId).values, [_, C, A, T] = c, { batchSize: E, filterDepth: N, filterHeight: I, filterWidth: M, inChannels: F, inDepth: D, inHeight: $, inWidth: R, outChannels: O, outDepth: z, outHeight: B, outWidth: L, strideDepth: j, strideHeight: U, strideWidth: W } = h, V = N - 1 - h.padInfo.front, G = I - 1 - h.padInfo.top, H = M - 1 - h.padInfo.left; for (let e = 0; e < E; ++e)for (let t = 0; t < F; ++t)for (let n = 0; n < D; ++n) { const r = n - V, i = Math.max(0, Math.ceil(r / j)), a = Math.min(z, (N + r) / j); for (let o = 0; o < $; ++o) { const s = o - G, u = Math.max(0, Math.ceil(s / U)), l = Math.min(B, (I + s) / U); for (let c = 0; c < R; ++c) { const h = c - H, d = Math.max(0, Math.ceil(h / W)), E = Math.min(L, (M + h) / W); let F = 0; for (let n = i; n < a; ++n) { const i = n * j - r; for (let r = u; r < l; ++r) { const a = r * U - s; for (let o = d; o < E; ++o) { const s = v * e + x * n + w * r + k * o, u = _ * (N - 1 - i) + C * (I - 1 - a) + A * (M - 1 - (o * W - h)) + T * t; for (let e = 0; e < O; ++e) { F += b[s + e] * S[u + e] } } } } f[p * e + m * n + g * o + y * c + t] = F } } } return n.makeTensorInfo(d.shape, d.dtype, d.values) } + }, Uy = Fp(P.Cos, (e => Math.cos(e))), Wy = { kernelName: P.Cos, backendName: "cpu", kernelFunc: Uy }, Vy = Fp(P.Cosh, (e => Math.cosh(e))), Gy = { kernelName: P.Cosh, backendName: "cpu", kernelFunc: Vy }; const Hy = { + kernelName: P.CropAndResize, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i, boxes: a, boxInd: o } = t, { cropSize: s, method: u, extrapolationValue: l } = r, [c, h, d, f] = i.shape, p = a.shape[0], [m, g] = s, y = (0, P.buffer)([p, m, g, f], "float32"), b = n.data.get(a.dataId).values, v = n.data.get(o.dataId).values, x = n.data.get(i.dataId).values, w = P.util.computeStrides(i.shape), k = P.util.computeStrides(y.shape); for (let e = 0; e < p; e++) { const t = 4 * e, n = b[t], r = b[t + 1], i = b[t + 2], a = b[t + 3], o = v[e]; if (o >= c) continue; const s = m > 1 ? (i - n) * (h - 1) / (m - 1) : 0, p = g > 1 ? (a - r) * (d - 1) / (g - 1) : 0; for (let t = 0; t < m; t++) { const c = m > 1 ? n * (h - 1) + t * s : .5 * (n + i) * (h - 1); if (c < 0 || c > h - 1) for (let n = 0; n < g; n++)for (let r = 0; r < f; r++) { const i = r + n * k[2] + t * k[1] + e * k[0]; y.values[i] = l } else if ("bilinear" === u) { const n = Math.floor(c), i = Math.ceil(c), s = c - n; for (let u = 0; u < g; u++) { const c = g > 1 ? r * (d - 1) + u * p : .5 * (r + a) * (d - 1); if (c < 0 || c > d - 1) { for (let n = 0; n < f; n++) { const r = n + u * k[2] + t * k[1] + e * k[0]; y.values[r] = l } continue } const h = Math.floor(c), m = Math.ceil(c), b = c - h; for (let r = 0; r < f; r++) { let a = r + h * w[2] + n * w[1] + o * w[0]; const l = x[a]; a = r + m * w[2] + n * w[1] + o * w[0]; const c = x[a]; a = r + h * w[2] + i * w[1] + o * w[0]; const d = x[a]; a = r + m * w[2] + i * w[1] + o * w[0]; const f = l + (c - l) * b, p = d + (x[a] - d) * b; a = r + u * k[2] + t * k[1] + e * k[0], y.values[a] = f + (p - f) * s } } } else for (let n = 0; n < g; ++n) { const i = g > 1 ? r * (d - 1) + n * p : .5 * (r + a) * (d - 1); if (i < 0 || i > d - 1) { for (let r = 0; r < f; r++) { const i = r + n * k[2] + t * k[1] + e * k[0]; y.values[i] = l } continue } const s = Math.round(i), u = Math.round(c); for (let r = 0; r < f; r++) { const i = r + s * w[2] + u * w[1] + o * w[0], a = r + n * k[2] + t * k[1] + e * k[0]; y.values[a] = x[i] } } } } return n.makeTensorInfo(y.shape, y.dtype, y.values) } + }; const qy = { + kernelName: P.Cumprod, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; ip(i, "cumprod"); const u = P.backend_util.getAxesPermutation([a], i.shape.length); let l = i; null != u && (l = $m({ inputs: { x: i }, backend: n, attrs: { perm: u } })); const c = P.backend_util.getInnerMostAxes(1, i.shape.length)[0]; if (c !== l.shape.length - 1) throw new Error(`backend.cumprod in CPU expects an inner-most axis=${l.shape.length - 1} but got axis=${c}`); const h = (0, P.upcastType)(l.dtype, "int32"), d = P.util.makeOnesTypedArray(P.util.sizeFromShape(l.shape), h), f = n.data.get(l.dataId).values, p = l.shape[l.shape.length - 1], m = s ? (e, t) => e + p - t - 1 : (e, t) => e + t; for (let e = 0; e < f.length; e += p)for (let t = 0; t < p; t++) { const n = m(e, t); if (0 === t) d[n] = o ? 1 : f[n]; else { const r = m(e, t - 1); d[n] = o ? f[r] * d[r] : f[n] * d[r] } } const g = n.makeTensorInfo(l.shape, h, d); if (null != u) { const e = $m({ inputs: { x: g }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(u) } }); return n.disposeIntermediateTensorInfo(g), n.disposeIntermediateTensorInfo(l), e } return g } + }; const Yy = { + kernelName: P.Cumsum, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; ip(i, "cumsum"); const u = P.backend_util.getAxesPermutation([a], i.shape.length); let l = i; null != u && (l = $m({ inputs: { x: i }, backend: n, attrs: { perm: u } })); const c = P.backend_util.getInnerMostAxes(1, i.shape.length)[0]; if (c !== l.shape.length - 1) throw new Error(`backend.cumsum in CPU expects an inner-most axis=${l.shape.length - 1} but got axis=${c}`); const h = (0, P.upcastType)(l.dtype, "int32"), d = P.util.makeZerosTypedArray(P.util.sizeFromShape(l.shape), h), f = n.data.get(l.dataId).values, p = l.shape[l.shape.length - 1], m = s ? (e, t) => e + p - t - 1 : (e, t) => e + t; for (let e = 0; e < f.length; e += p)for (let t = 0; t < p; t++) { const n = m(e, t); if (0 === t) d[n] = o ? 0 : f[n]; else { const r = m(e, t - 1); d[n] = o ? f[r] + d[r] : f[n] + d[r] } } const g = n.makeTensorInfo(l.shape, h, d); if (null != u) { const e = $m({ inputs: { x: g }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(u) } }); return n.disposeIntermediateTensorInfo(g), n.disposeIntermediateTensorInfo(l), e } return g } + }; const Xy = { + kernelName: P.DenseBincount, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o, binaryOutput: s } = r; if (1 === i.shape.length) { const e = Ap(n.data.get(i.dataId).values, n.data.get(a.dataId).values, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, e) } if (2 === i.shape.length) { const e = Tp(n.bufferSync(i), n.bufferSync(a), o, s); return n.makeTensorInfo(e.shape, a.dtype, e.values) } throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${i.shape.length}.`) } + }; const Ky = { + kernelName: P.DepthToSpace, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockSize: a, dataFormat: o } = r; P.util.assert("NHWC" === o, (() => `Only NHWC dataFormat supported on CPU for depthToSpace. Got ${o}`)); const s = i.shape[0], u = i.shape[1], l = i.shape[2], c = i.shape[3], h = u * a, d = l * a, f = c / (a * a), p = n.data.get(i.dataId).values, m = new Float32Array(s * h * d * f); let g = 0; for (let e = 0; e < s; ++e)for (let t = 0; t < h; ++t) { const n = Math.floor(t / a), r = t % a; for (let t = 0; t < d; ++t) { const i = Math.floor(t / a), o = (r * a + t % a) * f; for (let t = 0; t < f; ++t) { const r = t + o + c * (i + l * (n + u * e)); m[g++] = p[r] } } } return n.makeTensorInfo([s, h, d, f], i.dtype, m) } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Zy(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u, dimRoundingMode: l } = r; ip([i, a], "depthwiseConv2DNative"); const c = P.util.computeStrides(i.shape), h = P.util.computeStrides(a.shape); let d = u; null == d && (d = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, d), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${d}'`)); const f = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, d, s, l, !0), { filterHeight: p, filterWidth: m, dilationHeight: g, dilationWidth: y, padInfo: b } = f, v = b.left, x = b.top, w = f.outChannels / f.inChannels, k = new P.TensorBuffer(f.outShape, i.dtype), S = n.data.get(i.dataId).values, _ = n.data.get(a.dataId).values, C = k.values; for (let e = 0; e < f.batchSize; ++e) { const t = e * c[0], n = e * k.strides[0]; for (let e = 0; e < f.outHeight; ++e) { const r = n + e * k.strides[1], i = e * f.strideHeight - x; for (let e = 0; e < p; ++e) { const n = i + e * g; if (n < 0 || n >= f.inHeight) continue; const a = e * h[0], o = t + n * c[1]; for (let e = 0; e < f.outWidth; ++e) { const t = r + e * k.strides[2], n = e * f.strideWidth - v; for (let e = 0; e < m; ++e) { const r = n + e * y; if (r < 0 || r >= f.inWidth) continue; const i = a + e * h[1], s = o + r * f.inChannels; let u = t, l = i; for (let e = 0; e < f.inChannels; ++e) { const t = S[s + e]; for (let e = 0; e < w; ++e)C[u + e] += t * _[l + e]; u += w, l += w } } } } } } return n.makeTensorInfo(k.shape, k.dtype, k.values) } const Jy = { kernelName: P.DepthwiseConv2dNative, backendName: "cpu", kernelFunc: Zy }; const Qy = { + kernelName: P.DepthwiseConv2dNativeBackpropFilter, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, filterShape: c } = r; ip([i, a], "depthwiseConv2dNativeBackpropFilter"); const h = P.backend_util.computeConv2DInfo(i.shape, c, o, s, u, l, !0), { strideHeight: d, strideWidth: f, filterHeight: p, filterWidth: m } = h, g = new P.TensorBuffer(h.filterShape, "float32"), y = h.padInfo.left, b = h.padInfo.top, v = h.outChannels / h.inChannels, x = n.data.get(i.dataId).values, w = new P.TensorBuffer(i.shape, i.dtype, x), k = n.data.get(a.dataId).values, S = new P.TensorBuffer(a.shape, a.dtype, k); for (let e = 0; e < p; ++e) { const t = Math.max(0, Math.ceil((b - e) / d)), n = Math.min(h.outHeight, (h.inHeight + b - e) / d); for (let r = 0; r < m; ++r) { const i = Math.max(0, Math.ceil((y - r) / f)), a = Math.min(h.outWidth, (h.inWidth + y - r) / f); for (let o = 0; o < h.outChannels; ++o) { const s = Math.trunc(o / v), u = o % v; let l = 0; for (let u = 0; u < h.batchSize; ++u)for (let c = t; c < n; ++c) { const t = e + c * d - b; for (let e = i; e < a; ++e) { const n = r + e * f - y; l += w.get(u, t, n, s) * S.get(u, c, e, o) } } g.set(l, e, r, s, u) } } } return n.makeTensorInfo(g.shape, g.dtype, g.values) } + }; const eb = { + kernelName: P.DepthwiseConv2dNativeBackpropInput, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, inputShape: c } = r; ip([i, a], "depthwiseConv2DNativeBackpropInput"); const h = P.util.computeStrides(i.shape), d = P.util.computeStrides(a.shape), f = P.backend_util.computeConv2DInfo(c, a.shape, o, s, u, l, !0), p = new P.TensorBuffer(f.inShape, "float32"), m = p.values, [g, y, b] = p.strides, v = n.data.get(i.dataId).values, [x, w, k] = h, S = n.data.get(a.dataId).values, [_, C, A] = d, { batchSize: T, filterHeight: E, filterWidth: N, inChannels: I, inHeight: M, inWidth: F, outChannels: D, outHeight: $, outWidth: R, strideHeight: O, strideWidth: z } = f, B = E - 1 - f.padInfo.top, L = N - 1 - f.padInfo.left, j = D / I; for (let e = 0; e < T; ++e)for (let t = 0; t < I; ++t)for (let n = 0; n < M; ++n) { const r = n - B, i = Math.max(0, Math.ceil(r / O)), a = Math.min($, (E + r) / O); for (let o = 0; o < F; ++o) { const s = o - L, u = Math.max(0, Math.ceil(s / z)), l = Math.min(R, (N + s) / z); let c = 0; for (let n = i; n < a; ++n) { const i = n * O - r; for (let r = u; r < l; ++r) { const a = x * e + w * n + k * r, o = _ * (E - 1 - i) + C * (N - 1 - (r * z - s)) + A * t; for (let e = 0; e < j; ++e) { c += v[a + (t * j + e)] * S[o + e] } } } m[g * e + y * n + b * o + t] = c } } return n.makeTensorInfo(p.shape, p.dtype, p.values) } + }; const tb = { + kernelName: P.Diag, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = P.util.sizeFromShape(r.shape), a = n.data.get(r.dataId).values, o = (0, P.buffer)([i, i], r.dtype), s = o.values; for (let e = 0; e < a.length; e++)s[e * i + e] = a[e]; const u = [...r.shape, ...r.shape]; return n.makeTensorInfo(u, o.dtype, o.values) } + }, nb = { kernelName: P.Dilation2D, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, filter: i } = e, { strides: a, pad: o, dilations: s } = n, u = t, l = u.data.get(r.dataId).values, c = r.shape.length, h = u.data.get(i.dataId).values, d = i.shape.length, { batchSize: f, inHeight: p, inWidth: m, inChannels: g, outHeight: y, outWidth: b, padInfo: v, strideHeight: x, strideWidth: w, filterHeight: k, filterWidth: S, dilationHeight: _, dilationWidth: C, outShape: A } = P.backend_util.computeDilation2DInfo(r.shape, i.shape, a, o, "NHWC", s), T = P.util.sizeFromShape(A), E = A.length, N = P.util.getArrayFromDType(r.dtype, T); for (let e = 0; e < f; ++e)for (let t = 0; t < y; ++t) { const n = t * x - v.top; for (let a = 0; a < b; ++a) { const o = a * w - v.left; for (let s = 0; s < g; ++s) { let u = Number.MIN_SAFE_INTEGER; for (let t = 0; t < k; ++t) { const a = n + t * _; if (a >= 0 && a < p) for (let n = 0; n < S; ++n) { const f = o + n * C; if (f >= 0 && f < m) { const o = P.util.locToIndex([e, a, f, s], c, P.util.computeStrides(r.shape)), p = P.util.locToIndex([t, n, s], d, P.util.computeStrides(i.shape)), m = l[o] + h[p]; m > u && (u = m) } } } N[P.util.locToIndex([e, t, a, s], E, P.util.computeStrides(A))] = u } } } return { dataId: u.write(P.util.toTypedArray(N, r.dtype), A, r.dtype), shape: A, dtype: r.dtype } } }, rb = { kernelName: P.Dilation2DBackpropFilter, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, filter: i, dy: a } = e, { strides: o, pad: s, dilations: u } = n, l = t, c = P.util.toNestedArray(r.shape, l.data.get(r.dataId).values), h = P.util.toNestedArray(i.shape, l.data.get(i.dataId).values), { batchSize: d, inHeight: f, inWidth: p, inChannels: m, outHeight: g, outWidth: y, padInfo: b, strideHeight: v, strideWidth: x, filterHeight: w, filterWidth: k, dilationHeight: S, dilationWidth: _, outShape: C } = P.backend_util.computeDilation2DInfo(r.shape, i.shape, o, s, "NHWC", u); P.util.assert(a.rank === C.length, (() => `Error in ${P.Dilation2DBackpropFilter}, dy must have the same rank as output ${C.length}, but got ${a.rank}`)); const A = P.util.toNestedArray(C, l.data.get(a.dataId).values), T = P.util.makeZerosNestedTypedArray(i.shape, i.dtype); for (let e = 0; e < d; ++e)for (let t = 0; t < g; ++t) { const n = t * v - b.top; for (let r = 0; r < y; ++r) { const i = r * x - b.left; for (let a = 0; a < m; ++a) { let o = Number.MIN_SAFE_INTEGER, s = 0, u = 0; for (let t = 0; t < w; ++t) { const r = n + t * S; if (r >= 0 && r < f) for (let n = 0; n < k; ++n) { const l = i + n * _; if (l >= 0 && l < p) { const i = c[e][r][l][a] + h[t][n][a]; i > o && (o = i, s = t, u = n) } } } T[s][u][a] += A[e][t][r][a] } } } return { dataId: l.write(P.util.toTypedArray(T, r.dtype), i.shape, i.dtype), shape: i.shape, dtype: i.dtype } } }, ib = { kernelName: P.Dilation2DBackpropInput, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, filter: i, dy: a } = e, { strides: o, pad: s, dilations: u } = n, l = t, c = P.util.toNestedArray(r.shape, l.data.get(r.dataId).values), h = P.util.toNestedArray(i.shape, l.data.get(i.dataId).values), { batchSize: d, inHeight: f, inWidth: p, inChannels: m, outHeight: g, outWidth: y, padInfo: b, strideHeight: v, strideWidth: x, filterHeight: w, filterWidth: k, dilationHeight: S, dilationWidth: _, outShape: C } = P.backend_util.computeDilation2DInfo(r.shape, i.shape, o, s, "NHWC", u); P.util.assert(a.rank === C.length, (() => `Error in ${P.Dilation2DBackpropInput}, dy must have the same rank as output ${C.length}, but got ${a.rank}`)); const A = P.util.toNestedArray(C, l.data.get(a.dataId).values), T = P.util.makeZerosNestedTypedArray(r.shape, r.dtype); for (let e = 0; e < d; ++e)for (let t = 0; t < g; ++t) { const n = t * v - b.top; for (let r = 0; r < y; ++r) { const i = r * x - b.left; for (let a = 0; a < m; ++a) { let o = Number.MIN_SAFE_INTEGER, s = n < 0 ? 0 : n, u = i < 0 ? 0 : i; for (let t = 0; t < w; ++t) { const r = n + t * S; if (r >= 0 && r < f) for (let n = 0; n < k; ++n) { const l = i + n * _; if (l >= 0 && l < p) { const i = c[e][r][l][a] + h[t][n][a]; i > o && (o = i, s = r, u = l) } } } T[e][s][u][a] += A[e][t][r][a] } } } return { dataId: l.write(P.util.toTypedArray(T, r.dtype), r.shape, r.dtype), shape: r.shape, dtype: r.dtype } } }; const ab = { + kernelName: P.Draw, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i } = t, { canvas: a, options: o } = r, { contextOptions: s, imageOptions: u } = o || {}, l = (null == u ? void 0 : u.alpha) || 1, c = (null == s ? void 0 : s.contextType) || "2d"; if ("2d" !== c) throw new Error(`Context type ${s.contextType} is not supported by the CPU backend.`); const h = a.getContext(c, (null == s ? void 0 : s.contextAttributes) || {}); if (null == h) throw new Error(`Could not get the context with ${c} type.`); const [d, f] = i.shape.slice(0, 2), p = 2 === i.shape.length ? 1 : i.shape[2], m = n.data.get(i.dataId).values, g = "float32" === i.dtype ? 255 : 1, y = new Uint8ClampedArray(f * d * 4); for (let e = 0; e < d * f; ++e) { const t = [0, 0, 0, 255 * l]; for (let n = 0; n < p; n++) { const r = m[e * p + n]; if ("float32" === i.dtype) { if (r < 0 || r > 1) throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${r}.`) } else if ("int32" === i.dtype && (r < 0 || r > 255)) throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${r}.`); 1 === p ? (t[0] = r * g, t[1] = r * g, t[2] = r * g) : t[n] = r * g } const n = 4 * e; y[n + 0] = Math.round(t[0]), y[n + 1] = Math.round(t[1]), y[n + 2] = Math.round(t[2]), y[n + 3] = Math.round(t[3]) } a.width = f, a.height = d; const b = new ImageData(y, f, d); return h.putImageData(b, 0, 0), i } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ob(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; let s; ip(i, "sum"), s = "bool" === i.dtype ? bp({ inputs: { x: i }, backend: n, attrs: { dtype: "int32" } }) : fp({ inputs: { x: i }, backend: n }); const u = s.shape.length, l = P.util.parseAxisParam(a, s.shape), c = P.backend_util.getAxesPermutation(l, u); let h = l, d = s; null != c && (d = $m({ inputs: { x: s }, backend: n, attrs: { perm: c } }), h = P.backend_util.getInnerMostAxes(h.length, u)), P.backend_util.assertAxesAreInnerMostDims("sum", h, d.shape.length); const [f, p] = P.backend_util.computeOutAndReduceShapes(d.shape, h); let m = dp(n, f, P.backend_util.upcastType(d.dtype, "int32")); const g = P.util.sizeFromShape(p), y = n.data.get(m.dataId).values, b = n.data.get(d.dataId).values; for (let e = 0; e < y.length; ++e) { const t = e * g; let n = 0; for (let e = 0; e < g; ++e)n += b[t + e]; y[e] = n } if (o) { const e = m; m = Hg({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(m.shape, l) } }), n.disposeIntermediateTensorInfo(e) } return n.disposeIntermediateTensorInfo(s), null != c && n.disposeIntermediateTensorInfo(d), m } const sb = { kernelName: P.Sum, backendName: "cpu", kernelFunc: ob }; const ub = { + kernelName: P.Einsum, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { equation: i } = r, a = t, { allDims: o, summedDims: s, idDims: u } = P.backend_util.decodeEinsumEquation(i, a.length); P.backend_util.checkEinsumDimSizes(o.length, u, a); const { path: l, steps: c } = P.backend_util.getEinsumComputePath(s, u), h = c.length; let d = null, f = o.length; const p = []; for (let e = 0; e < h; ++e) { for (const t of c[e]) { const { permutationIndices: e, expandDims: r } = P.backend_util.getEinsumPermutation(f, u[t]); let i; P.backend_util.isIdentityPermutation(e) ? i = a[t] : (i = $m({ inputs: { x: a[t] }, backend: n, attrs: { perm: e } }), p.push(i)); const o = i.shape.slice(); for (let e = 0; e < r.length; ++e)o.splice(r[e], 0, 1); P.util.arraysEqual(i.shape, o) || (i = Hg({ inputs: { x: i }, backend: n, attrs: { shape: o } }), p.push(i)), null === d ? d = i : (d = Am({ inputs: { a: i, b: d }, backend: n }), p.push(d)) } e < h - 1 && (l[e] >= 0 && (d = ob({ inputs: { x: d }, backend: n, attrs: { axis: l[e] - (o.length - f), keepDims: !1 } }), p.push(d)), f--) } for (const e of p) e !== d && n.disposeIntermediateTensorInfo(e); return d } + }; const lb = { + kernelName: P.EluGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { dy: r, y: i } = t; ip([r, i], "eluGrad"); const a = new Float32Array(P.util.sizeFromShape(i.shape)), o = n.data.get(i.dataId).values, s = n.data.get(r.dataId).values; for (let e = 0; e < o.length; ++e) { const t = o[e]; a[e] = t >= 0 ? s[e] : s[e] * (t + 1) } return n.makeTensorInfo(i.shape, "float32", a) } + }, cb = P.backend_util.ERF_P, hb = P.backend_util.ERF_A1, db = P.backend_util.ERF_A2, fb = P.backend_util.ERF_A3, pb = P.backend_util.ERF_A4, mb = P.backend_util.ERF_A5, gb = Fp(P.Erf, (e => { const t = Math.sign(e), n = Math.abs(e), r = 1 / (1 + cb * n); return t * (1 - ((((mb * r + pb) * r + fb) * r + db) * r + hb) * r * Math.exp(-n * n)) })), yb = { kernelName: P.Erf, backendName: "cpu", kernelFunc: gb }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function bb(e) { const { inputs: t, backend: n, attrs: r } = e, { input: i } = t, { dim: a } = r, o = i.shape.length, s = i.shape.slice(); let u = a; return a < 0 && (P.util.assert(-(o + 1) <= a, (() => `Axis must be in the interval [${-(o + 1)}, ${o}]`)), u = o + a + 1), s.splice(u, 0, 1), Hg({ inputs: { x: i }, backend: n, attrs: { shape: s } }) } const vb = { kernelName: P.ExpandDims, backendName: "cpu", kernelFunc: bb }, xb = lp(((e, t) => e / t)), wb = xp(P.RealDiv, xb), kb = { kernelName: P.RealDiv, backendName: "cpu", kernelFunc: wb }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Sb(e, t, n) { const r = e.shape, i = r[0], a = r[1], o = n.data.get(e.dataId), s = o.complexTensorInfos.real, u = o.complexTensorInfos.imag, l = [i, a], c = P.util.sizeFromShape(l), h = P.util.getTypedArrayFromDType("float32", c), d = P.util.getTypedArrayFromDType("float32", c); for (let e = 0; e < i; e++) { const r = ig({ inputs: { x: s }, backend: n, attrs: { begin: [e, 0], size: [1, a] } }), i = ig({ inputs: { x: u }, backend: n, attrs: { begin: [e, 0], size: [1, a] } }), o = cp({ inputs: { real: r, imag: i }, backend: n }), { real: l, imag: c } = _b(o, t, n), f = P.backend_util.mergeRealAndImagArrays(l, c); for (let t = 0; t < a; t++) { const n = P.backend_util.getComplexWithIndex(f, t); h[e * a + t] = n.real, d[e * a + t] = n.imag } n.disposeIntermediateTensorInfo(r), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(o) } const f = n.makeTensorInfo(l, "float32", h), p = n.makeTensorInfo(l, "float32", d), m = cp({ inputs: { real: f, imag: p }, backend: n }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), m } function _b(e, t, n) { const r = P.util.sizeFromShape(e.shape), i = n.data.get(e.dataId), a = n.data.get(i.complexTensorInfos.real.dataId).values, o = n.data.get(i.complexTensorInfos.imag.dataId).values; if ((s = r) & s - 1) { const e = function (e, t, n) { const r = new Float32Array(2 * t); for (let i = 0; i < t; i++) { let a = 0, o = 0; for (let r = 0; r < t; r++) { const s = P.backend_util.exponent(i * r, t, n), u = P.backend_util.getComplexWithIndex(e, r); a += u.real * s.real - u.imag * s.imag, o += u.real * s.imag + u.imag * s.real } n && (a /= t, o /= t), P.backend_util.assignToTypedArray(r, a, o, i) } return r }(P.backend_util.mergeRealAndImagArrays(a, o), r, t); return P.backend_util.splitRealAndImagArrays(e) } { const i = Cb(a, o, r, t, n), s = [e.shape[0], e.shape[1]]; if (t) { const e = n.makeTensorInfo(s, "float32", i.real), t = n.makeTensorInfo(s, "float32", i.imag), a = n.makeTensorInfo([], "float32", P.util.createScalarValue(r, "float32")), o = fp({ inputs: { x: a }, backend: n }), u = kb.kernelFunc({ inputs: { a: e, b: a }, backend: n }), l = kb.kernelFunc({ inputs: { a: t, b: o }, backend: n }), c = n.data.get(u.dataId).values, h = n.data.get(l.dataId).values; return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), n.disposeIntermediateTensorInfo(a), n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(u), n.disposeIntermediateTensorInfo(l), { real: c, imag: h } } return i } var s } function Cb(e, t, n, r, i) { if (1 === n) return { real: e, imag: t }; const a = P.backend_util.mergeRealAndImagArrays(e, t), o = n / 2, s = P.backend_util.complexWithEvenIndex(a), u = s.real, l = s.imag, c = [u.length], h = i.makeTensorInfo(c, "float32", u), d = i.makeTensorInfo(c, "float32", l), f = cp({ inputs: { real: h, imag: d }, backend: i }), p = P.backend_util.complexWithOddIndex(a), m = p.real, g = p.imag, y = [m.length], b = i.makeTensorInfo(y, "float32", m), v = i.makeTensorInfo(y, "float32", g), x = cp({ inputs: { real: b, imag: v }, backend: i }), w = Cb(u, l, o, r, i), k = w.real, S = w.imag, _ = [k.length], C = i.makeTensorInfo(_, "float32", k), A = i.makeTensorInfo(_, "float32", S), T = cp({ inputs: { real: C, imag: A }, backend: i }), E = Cb(m, g, o, r, i), N = E.real, I = E.imag, M = [N.length], F = i.makeTensorInfo(M, "float32", N), D = i.makeTensorInfo(M, "float32", I), $ = cp({ inputs: { real: F, imag: D }, backend: i }), R = P.backend_util.exponents(n, r), O = [R.real.length], z = i.makeTensorInfo(O, "float32", R.real), B = i.makeTensorInfo(O, "float32", R.imag), L = cp({ inputs: { real: z, imag: B }, backend: i }), j = Am({ inputs: { a: L, b: $ }, backend: i }), U = _p({ inputs: { a: T, b: j }, backend: i }), W = Ag({ inputs: { a: T, b: j }, backend: i }), V = mp({ inputs: { input: U }, backend: i }), G = mp({ inputs: { input: W }, backend: i }), H = My({ inputs: { input: U }, backend: i }), q = My({ inputs: { input: W }, backend: i }), Y = Dy({ inputs: [V, G], backend: i, attrs: { axis: 0 } }), X = Dy({ inputs: [H, q], backend: i, attrs: { axis: 0 } }), K = i.data.get(Y.dataId).values, Z = i.data.get(X.dataId).values; return i.disposeIntermediateTensorInfo(h), i.disposeIntermediateTensorInfo(d), i.disposeIntermediateTensorInfo(f), i.disposeIntermediateTensorInfo(b), i.disposeIntermediateTensorInfo(v), i.disposeIntermediateTensorInfo(x), i.disposeIntermediateTensorInfo(C), i.disposeIntermediateTensorInfo(A), i.disposeIntermediateTensorInfo(T), i.disposeIntermediateTensorInfo(F), i.disposeIntermediateTensorInfo(D), i.disposeIntermediateTensorInfo($), i.disposeIntermediateTensorInfo(z), i.disposeIntermediateTensorInfo(B), i.disposeIntermediateTensorInfo(L), i.disposeIntermediateTensorInfo(j), i.disposeIntermediateTensorInfo(U), i.disposeIntermediateTensorInfo(W), i.disposeIntermediateTensorInfo(V), i.disposeIntermediateTensorInfo(H), i.disposeIntermediateTensorInfo(G), i.disposeIntermediateTensorInfo(q), i.disposeIntermediateTensorInfo(Y), i.disposeIntermediateTensorInfo(X), { real: K, imag: Z } } const Ab = { + kernelName: P.FFT, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { input: r } = t, i = P.util.sizeFromShape(r.shape), a = r.shape[r.shape.length - 1], o = Hg({ inputs: { x: r }, backend: n, attrs: { shape: [i / a, a] } }), s = Sb(o, !1, n), u = Hg({ inputs: { x: s }, backend: n, attrs: { shape: r.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(s), u } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Tb(e) { const { backend: t, attrs: n } = e, { shape: r, value: i, dtype: a } = n, o = a || P.util.inferDtype(i), s = P.util.getArrayFromDType(o, P.util.sizeFromShape(r)); return function (e, t) { e.fill(t) }(s, i), t.makeTensorInfo(r, o, s) } const Eb = { kernelName: P.Fill, backendName: "cpu", kernelFunc: Tb }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Nb = { kernelName: P.FlipLeftRight, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, i = n, a = P.util.getTypedArrayFromDType(r.dtype, P.util.sizeFromShape(r.shape)), [o, s, u, l] = r.shape, c = i.data.get(r.dataId).values; for (let e = 0; e < o; e++) { const t = e * u * s * l; for (let e = 0; e < s; e++) { const n = e * (u * l); for (let e = 0; e < u; e++) { const r = e * l; for (let i = 0; i < l; i++) { const o = Math.round(u - e - 1), s = t + n + r + i; let h = c[s]; if (o >= 0 && o < u) { h = c[t + n + o * l + i] } a[s] = h } } } } return { dataId: i.write(a, r.shape, r.dtype), shape: r.shape, dtype: r.dtype } } }; const Ib = { + kernelName: P.FusedConv2D, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r; let m = Ry({ inputs: { x: i, filter: a }, backend: n, attrs: { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d } }); if (o) { const e = m; if ("NCHW" === c && 1 === o.shape.length && 1 !== o.shape[0]) { const e = Hg({ inputs: { x: o }, backend: n, attrs: { shape: [o.shape[0], 1, 1] } }); m = _p({ inputs: { a: m, b: e }, backend: n }), n.disposeIntermediateTensorInfo(e) } else m = _p({ inputs: { a: m, b: o }, backend: n }); n.disposeIntermediateTensorInfo(e) } if (f) { const e = m; if ("NCHW" === c && "prelu" === f && 1 === s.shape.length && 1 !== s.shape[0]) { const e = Hg({ inputs: { x: s }, backend: n, attrs: { shape: [s.shape[0], 1, 1] } }); m = Gg(n, m, f, e, p), n.disposeIntermediateTensorInfo(e) } else m = Gg(n, m, f, s, p); n.disposeIntermediateTensorInfo(e) } return m } + }; const Mb = { + kernelName: P.FusedDepthwiseConv2D, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r; let m = Zy({ inputs: { x: i, filter: a }, backend: n, attrs: { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d } }); if (o) { const e = m; m = _p({ inputs: { a: m, b: o }, backend: n }), n.disposeIntermediateTensorInfo(e) } if (f) { const e = m; m = Gg(n, m, f, s, p), n.disposeIntermediateTensorInfo(e) } return m } + }; const Fb = { + kernelName: P.GatherNd, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { params: r, indices: i } = t, a = P.util.sizeFromShape(r.shape), o = i.shape, s = o[o.length - 1], [u, l, c, h] = P.backend_util.prepareAndValidate(r, i); if (0 === l) return n.makeTensorInfo(u, r.dtype, []); const d = Qp(n.data.get(i.dataId).values, n.bufferSync(r), r.dtype, l, s, c, h, r.shape, a); return n.makeTensorInfo(u, r.dtype, d.values) } + }; const Db = { + kernelName: P.GatherV2, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, indices: a } = t, { axis: o, batchDims: s } = r; ip([i, a], "gatherV2"); const u = P.util.parseAxisParam(o, i.shape)[0], l = n.data.get(a.dataId).values, c = i.shape[u]; for (let e = 0; e < l.length; ++e) { const t = l[e]; P.util.assert(t <= c - 1 && t >= 0, (() => `GatherV2: the index value ${t} is not in [0, ${c - 1}]`)) } let h = s; null == s && (h = 0); const d = P.util.sizeFromShape(a.shape), f = P.backend_util.segment_util.collectGatherOpShapeInfo(i, a, u, h), p = Hg({ inputs: { x: i }, backend: n, attrs: { shape: [f.batchSize, f.outerSize, f.dimSize, f.sliceSize] } }), m = Hg({ inputs: { x: a }, backend: n, attrs: { shape: [f.batchSize, d / f.batchSize] } }), g = [f.batchSize, f.outerSize, d / f.batchSize, f.sliceSize], y = n.bufferSync(m), b = em(n.bufferSync(p), y, g); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), n.makeTensorInfo(f.outputShape, b.dtype, b.values) } + }; const $b = { + kernelName: P.IFFT, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { input: r } = t, i = P.util.sizeFromShape(r.shape), a = r.shape[r.shape.length - 1], o = Hg({ inputs: { x: r }, backend: n, attrs: { shape: [i / a, a] } }), s = Sb(o, !0, n), u = Hg({ inputs: { x: s }, backend: n, attrs: { shape: r.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(s), u } + }, Rb = Fp(P.IsFinite, (e => Number.isFinite(e) ? 1 : 0), "bool"), Ob = { kernelName: P.IsFinite, backendName: "cpu", kernelFunc: Rb }, zb = Fp(P.IsInf, (e => Math.abs(e) === 1 / 0 ? 1 : 0), "bool"), Pb = { kernelName: P.IsInf, backendName: "cpu", kernelFunc: zb }, Bb = Fp(P.IsNan, (e => Number.isNaN(e) ? 1 : 0), "bool"), Lb = { kernelName: P.IsNan, backendName: "cpu", kernelFunc: Bb }; const jb = { + kernelName: P.LinSpace, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, num: a } = n, o = fm(r, i, a); return t.makeTensorInfo([o.length], "float32", o) } + }, Ub = Fp(P.Log1p, (e => Math.log1p(e))), Wb = { kernelName: P.Log1p, backendName: "cpu", kernelFunc: Ub }, Vb = lp(((e, t) => e && t)), Gb = xp(P.LogicalAnd, Vb, null, "bool"), Hb = { kernelName: P.LogicalAnd, backendName: "cpu", kernelFunc: Gb }, qb = Fp(P.LogicalNot, (e => e ? 0 : 1), "bool"), Yb = { kernelName: P.LogicalNot, backendName: "cpu", kernelFunc: qb }, Xb = lp(((e, t) => e || t)), Kb = xp(P.LogicalOr, Xb, null, "bool"), Zb = { kernelName: P.LogicalOr, backendName: "cpu", kernelFunc: Kb }; const Jb = { + kernelName: P.LRN, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { depthRadius: a, bias: o, alpha: s, beta: u } = r; ip(i, "LRN"); const l = i.shape[3], c = l - 1, h = n.data.get(i.dataId).values, d = P.util.sizeFromShape(i.shape), f = new Float32Array(d); function p(e) { const t = e % l; let n = e - t + Math.max(0, t - a); const r = e - t + Math.min(t + a, c); let i = 0; for (; n <= r; n++) { const e = h[n]; i += e * e } return i } for (let e = 0; e < d; e++) { const t = p(e), n = h[e] * Math.pow(o + s * t, -u); f[e] = n } return n.makeTensorInfo(i.shape, i.dtype, f) } + }; const Qb = { + kernelName: P.LRNGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, y: a, dy: o } = t, { depthRadius: s, bias: u, alpha: l, beta: c } = r; ip(o, "LRNGrad"); const h = P.util.sizeFromShape(o.shape), d = o.shape[3], f = n.data.get(o.dataId).values, p = n.data.get(i.dataId).values, m = n.data.get(a.dataId).values, g = new Float32Array(h), y = h; for (let e = 0; e < y; e++) { const t = e % d, n = e - t + Math.max(0, t - s), r = e - t + Math.min(d, t + s + 1); let i = 0; for (let e = n; e < r; e++)i += Math.pow(p[e], 2); i = l * i + u; for (let t = n; t < r; t++) { let n = -2 * l * c * p[t] * m[e] / i; e === t && (n += Math.pow(i, -c)), n *= f[e], g[t] += n } } return n.makeTensorInfo(o.shape, i.dtype, g) } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ev(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reductionIndices: a, keepDims: o } = r, s = n; let u = i.shape; const l = u.length, c = P.util.parseAxisParam(a, u); let h = c; const d = P.backend_util.getAxesPermutation(h, l); let f = s.data.get(i.dataId).values; if (null != d) { const e = new Array(l); for (let t = 0; t < e.length; t++)e[t] = u[d[t]]; f = Dm(f, u, i.dtype, d, e), h = P.backend_util.getInnerMostAxes(h.length, l), u = e } ip(i, "max"), P.backend_util.assertAxesAreInnerMostDims("max", h, l); const [p, m] = P.backend_util.computeOutAndReduceShapes(u, h), g = ym(f, P.util.sizeFromShape(m), p, i.dtype), y = s.write(g, p, i.dtype); let b = p; if (o) { b = P.backend_util.expandShapeToKeepDim(p, c) } return { dataId: y, shape: b, dtype: i.dtype } } const tv = { kernelName: P.Max, backendName: "cpu", kernelFunc: ev }; const nv = { + kernelName: P.MaxPool, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; ip(i, "maxPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); let c; if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) c = fp({ inputs: { x: i }, backend: n }); else { const e = n.data.get(i.dataId).values, t = P.util.computeStrides(i.shape), r = yy(e, i.shape, i.dtype, t, l, "max"); c = n.makeTensorInfo(l.outShape, i.dtype, r.values) } return c } + }; const rv = { + kernelName: P.MaxPool3D, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u, dataFormat: l } = r; ip(i, "maxPool3d"); const c = P.backend_util.computePool3DInfo(i.shape, a, o, 1, s, u, l), h = vy(n.data.get(i.dataId).values, i.shape, i.dtype, P.util.computeStrides(i.shape), c, "max"); return n.makeTensorInfo(h.shape, "float32", h.values) } + }; const iv = { + kernelName: P.MaxPool3DGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, { filterSize: o, strides: s, pad: u, dimRoundingMode: l } = r; ip([i, a], "maxPool3DGrad"); const c = P.backend_util.computePool3DInfo(a.shape, o, s, 1, u, l), h = function (e, t) { const n = (0, P.buffer)(t.outShape, "int32"), r = t.strideDepth, i = t.strideHeight, a = t.strideWidth, o = t.dilationDepth, s = t.dilationHeight, u = t.dilationWidth, l = t.effectiveFilterDepth, c = t.effectiveFilterHeight, h = t.effectiveFilterWidth, d = t.padInfo.front, f = t.padInfo.top, p = t.padInfo.left; for (let m = 0; m < t.batchSize; ++m)for (let g = 0; g < t.inChannels; ++g)for (let y = 0; y < t.outDepth; ++y) { const b = y * r - d; let v = b; for (; v < 0;)v += o; const x = Math.min(t.inDepth, l + b); for (let r = 0; r < t.outHeight; ++r) { const l = r * i - f; let d = l; for (; d < 0;)d += s; const w = Math.min(t.inHeight, c + l); for (let i = 0; i < t.outWidth; ++i) { const f = i * a - p; let k = f; for (; k < 0;)k += u; const S = Math.min(t.inWidth, h + f); let _ = Number.NEGATIVE_INFINITY, C = -1; for (let t = v; t < x; t += o) { const n = t - b; for (let r = d; r < w; r += s) { const i = r - l; for (let a = k; a < S; a += u) { const o = a - f, s = e.get(m, t, r, a, g); s >= _ && (_ = s, C = n * c * h + i * c + o) } } } n.set(C, m, y, r, i, g) } } } return n }(n.bufferSync(a), c), d = c.strideDepth, f = c.strideHeight, p = c.strideWidth, m = c.dilationDepth, g = c.dilationHeight, y = c.dilationWidth, b = c.effectiveFilterDepth, v = c.effectiveFilterHeight, x = c.effectiveFilterWidth, w = b - 1 - c.padInfo.front, k = x - 1 - c.padInfo.left, S = v - 1 - c.padInfo.top, _ = (0, P.buffer)(a.shape, "float32"), C = n.bufferSync(i); for (let e = 0; e < c.batchSize; ++e)for (let t = 0; t < c.inChannels; ++t)for (let n = 0; n < c.inDepth; ++n)for (let r = 0; r < c.inHeight; ++r)for (let i = 0; i < c.inWidth; ++i) { const a = n - w, o = r - S, s = i - k; let u = 0; for (let n = 0; n < b; n += m) { const r = (a + n) / d; if (!(r < 0 || r >= c.outDepth || Math.floor(r) !== r)) for (let i = 0; i < v; i += g) { const a = (o + i) / f; if (!(a < 0 || a >= c.outHeight || Math.floor(a) !== a)) for (let o = 0; o < x; o += y) { const l = (s + o) / p; if (l < 0 || l >= c.outWidth || Math.floor(l) !== l) continue; const d = b * v * x - 1 - h.get(e, r, a, l, t) === n * v * x + i * x + o ? 1 : 0; if (0 === d) continue; u += C.get(e, r, a, l, t) * d } } } _.set(u, e, n, r, i, t) } return n.makeTensorInfo(_.shape, _.dtype, _.values) } + }; const av = { + kernelName: P.MaxPoolGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a, output: o } = t, s = a; ip([a, o], "maxPoolGrad"); const { filterSize: u, strides: l, pad: c, dimRoundingMode: h } = r, d = P.backend_util.computePool2DInfo(s.shape, u, l, 1, c, h), f = n.data.get(s.dataId).values, p = (0, P.buffer)(d.outShape, s.dtype, by(f, s.shape, s.dtype, d).values), m = d.strideHeight, g = d.strideWidth, y = d.dilationHeight, b = d.dilationWidth, v = d.effectiveFilterHeight, x = d.effectiveFilterWidth, w = x - 1 - d.padInfo.left, k = v - 1 - d.padInfo.top, S = (0, P.buffer)(s.shape, "float32"), _ = n.data.get(i.dataId).values, C = (0, P.buffer)(i.shape, "float32", _); for (let e = 0; e < d.batchSize; ++e)for (let t = 0; t < d.inChannels; ++t)for (let n = 0; n < d.inHeight; ++n)for (let r = 0; r < d.inWidth; ++r) { const i = n - k, a = r - w; let o = 0; for (let n = 0; n < v; n += y) { const r = (i + n) / m; if (!(r < 0 || r >= d.outHeight || Math.floor(r) !== r)) for (let i = 0; i < x; i += b) { const s = (a + i) / g; if (s < 0 || s >= d.outWidth || Math.floor(s) !== s) continue; const u = v * x - 1 - p.get(e, r, s, t) === n * x + i ? 1 : 0; if (0 === u) continue; o += C.get(e, r, s, t) * u } } S.set(o, e, n, r, t) } return n.makeTensorInfo(S.shape, S.dtype, S.values) } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const ov = { + kernelName: P.MaxPoolWithArgmax, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { + const { x: r } = e, { filterSize: i, strides: a, pad: o, includeBatchInIndex: s } = t, u = n; ip(r, "MaxPoolWithArgmax"); const l = u.data.get(r.dataId).values, c = P.backend_util.computePool2DInfo(r.shape, i, a, [1, 1], o), [h, d] = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i) { const a = yy(e, 0, n, P.util.computeStrides(t), i, "max"), o = by(e, t, n, i, !0, r); return [a.values, o.values] }(l, r.shape, r.dtype, s, c), f = u.write(h, c.outShape, r.dtype), p = u.write(d, c.outShape, r.dtype); return [{ dataId: f, shape: c.outShape, dtype: r.dtype }, { dataId: p, shape: c.outShape, dtype: "int32" }] + } + }; const sv = { + kernelName: P.Mean, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = P.util.parseAxisParam(a, i.shape), u = P.backend_util.computeOutAndReduceShapes(i.shape, s)[1], l = P.util.sizeFromShape(u), c = [], h = n.makeTensorInfo([], "float32", new Float32Array([l])); c.push(h); const d = bp({ inputs: { x: i }, backend: n, attrs: { dtype: "float32" } }); c.push(d); const f = wb({ inputs: { a: d, b: h }, backend: n }); c.push(f); const p = ob({ inputs: { x: f }, backend: n, attrs: { axis: a, keepDims: o } }); return c.forEach((e => n.disposeIntermediateTensorInfo(e))), p } + }; const uv = { + kernelName: P.Min, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "min"); const s = P.util.parseAxisParam(a, i.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, i.shape.length); let c = i; null != l && (c = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), u = P.backend_util.getInnerMostAxes(u.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("min", u, c.shape.length); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u), f = P.util.sizeFromShape(d), p = P.util.makeZerosTypedArray(P.util.sizeFromShape(h), c.dtype), m = n.data.get(c.dataId).values; for (let e = 0; e < p.length; ++e) { const t = e * f; let n = m[t]; for (let e = 0; e < f; ++e) { const r = m[t + e]; (Number.isNaN(r) || r < n) && (n = r) } p[e] = n } null != l && n.disposeIntermediateTensorInfo(c); const g = n.makeTensorInfo(h, c.dtype, p); if (o) { const e = Hg({ inputs: { x: g }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(h, s) } }); return n.disposeIntermediateTensorInfo(g), e } return g } + }; const lv = { + kernelName: P.MirrorPad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, mode: o } = r; ip(i, "mirrorPad"); const s = a.map(((e, t) => e[0] + i.shape[t] + e[1])), u = a.map((e => e[0])), l = a.map(((e, t) => e[0] + i.shape[t])), c = "reflect" === o ? 0 : 1, h = n.data.get(i.dataId).values, d = i.shape.length, f = P.util.computeStrides(i.shape), p = P.util.sizeFromShape(s), m = s.length, g = P.util.computeStrides(s), y = P.util.getTypedArrayFromDType(i.dtype, p); for (let e = 0; e < p; e++) { let t = P.util.indexToLoc(e, m, g); for (let e = 0; e < m; e++)t[e] < u[e] ? t[e] = 2 * u[e] - t[e] - c : t[e] >= l[e] && (t[e] = 2 * (l[e] - 1) - t[e] + c); t = t.map(((e, t) => e - u[t])); const n = P.util.locToIndex(t, d, f); y[e] = h[n] } return { dataId: n.write(y, s, i.dtype), shape: s, dtype: i.dtype } } + }, cv = lp(((e, t) => { const n = e % t; return e < 0 && t < 0 || e >= 0 && t >= 0 ? n : (n + t) % t })), hv = xp(P.Mod, cv), dv = { kernelName: P.Mod, backendName: "cpu", kernelFunc: hv }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function fv(e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { dim: a } = r, o = i.shape.length; let s = a; if (-1 === s && (s = o - 1), s !== o - 1) throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${o} and dim was ${s}`); const u = P.util.parseAxisParam([s], i.shape), l = ev({ inputs: { x: i }, backend: n, attrs: { reductionIndices: u, keepDims: !1 } }), c = P.backend_util.expandShapeToKeepDim(l.shape, u), h = Hg({ inputs: { x: l }, backend: n, attrs: { shape: c } }), d = Ag({ inputs: { a: i, b: h }, backend: n }), f = Up({ inputs: { x: d }, backend: n }), p = ob({ inputs: { x: f }, backend: n, attrs: { axis: u, keepDims: !1 } }), m = Hg({ inputs: { x: p }, backend: n, attrs: { shape: c } }), g = wb({ inputs: { a: f, b: m }, backend: n }); return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), g } const pv = { kernelName: P.Softmax, backendName: "cpu", kernelFunc: fv }; const mv = { + kernelName: P.Multinomial, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { numSamples: a, seed: o, normalized: s } = r; ip(i, "multinomial"); const u = s ? i : fv({ inputs: { logits: i }, backend: n, attrs: { dim: -1 } }), l = u.shape[0], c = u.shape[1], h = n.data.get(u.dataId).values, d = [l, a], f = P.util.makeZerosTypedArray(P.util.sizeFromShape(d), "int32"); for (let e = 0; e < l; ++e) { const t = e * c, n = new Float32Array(c - 1); n[0] = h[t]; for (let e = 1; e < n.length; ++e)n[e] = n[e - 1] + h[t + e]; const r = qd.alea(o.toString()), i = e * a; for (let e = 0; e < a; ++e) { const t = r(); f[i + e] = n.length; for (let r = 0; r < n.length; r++)if (t < n[r]) { f[i + e] = r; break } } } return s || n.disposeIntermediateTensorInfo(u), n.makeTensorInfo(d, "int32", f) } + }, gv = P.kernel_impls.nonMaxSuppressionV3Impl; const yv = { kernelName: P.NonMaxSuppressionV3, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = r; ip(i, "NonMaxSuppression"); const l = n.data.get(i.dataId).values, c = n.data.get(a.dataId).values, { selectedIndices: h } = gv(l, c, o, s, u); return n.makeTensorInfo([h.length], "int32", new Int32Array(h)) } }, bv = P.kernel_impls.nonMaxSuppressionV4Impl; const vv = { kernelName: P.NonMaxSuppressionV4, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, padToMaxOutputSize: l } = r; ip(i, "NonMaxSuppressionPadded"); const c = n.data.get(i.dataId).values, h = n.data.get(a.dataId).values, { selectedIndices: d, validOutputs: f } = bv(c, h, o, s, u, l); return [n.makeTensorInfo([d.length], "int32", new Int32Array(d)), n.makeTensorInfo([], "int32", new Int32Array([f]))] } }, xv = P.kernel_impls.nonMaxSuppressionV5Impl; const wv = { kernelName: P.NonMaxSuppressionV5, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = r; ip(i, "NonMaxSuppressionWithScore"); const c = n.data.get(i.dataId).values, h = n.data.get(a.dataId).values, d = o, f = s, p = u, m = l, { selectedIndices: g, selectedScores: y } = xv(c, h, d, f, p, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([y.length], "float32", new Float32Array(y))] } }; const kv = { + kernelName: P.OneHot, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i } = t, { dtype: a, depth: o, onValue: s, offValue: u } = r; ip(i, "oneHot"); const l = P.util.sizeFromShape(i.shape), c = new Float32Array(l * o); c.fill(u); const h = n.data.get(i.dataId).values; for (let e = 0; e < l; ++e)h[e] >= 0 && h[e] < o && (c[e * o + h[e]] = s); return n.makeTensorInfo([...i.shape, o], a, c) } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Sv(e) { const { inputs: t, backend: n } = e, { x: r } = t; if ("string" === r.dtype) throw new Error("zerosLike is not supported for string tensors"); if ("complex64" === r.dtype) { const e = mp({ inputs: { input: r }, backend: n }), t = Sv({ inputs: { x: e }, backend: n }), i = My({ inputs: { input: r }, backend: n }), a = Sv({ inputs: { x: i }, backend: n }), o = cp({ inputs: { real: t, imag: a }, backend: n }); return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(a), o } return Tb({ backend: n, attrs: { shape: r.shape, value: 0, dtype: r.dtype } }) } const _v = { kernelName: P.ZerosLike, backendName: "cpu", kernelFunc: Sv }; const Cv = { + kernelName: P.OnesLike, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function e(t) { const { inputs: n, backend: r } = t, { x: i } = n; if ("string" === i.dtype) throw new Error("onesLike is not supported for string tensors"); if ("complex64" === i.dtype) { const t = mp({ inputs: { input: i }, backend: r }), n = e({ inputs: { x: t }, backend: r }), a = My({ inputs: { input: i }, backend: r }), o = Sv({ inputs: { x: a }, backend: r }), s = cp({ inputs: { real: n, imag: o }, backend: r }); return r.disposeIntermediateTensorInfo(t), r.disposeIntermediateTensorInfo(n), r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s } return Tb({ backend: r, attrs: { shape: i.shape, value: 1, dtype: i.dtype } }) } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Av(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r; if (1 === t.length) return bb({ inputs: { input: t[0] }, backend: n, attrs: { dim: i } }); const a = t[0].shape, o = t[0].dtype; t.forEach((e => { P.util.assertShapesMatch(a, e.shape, "All tensors passed to stack must have matching shapes"), P.util.assert(o === e.dtype, (() => "All tensors passed to stack must have matching dtypes")) })); const s = [], u = Dy({ inputs: t.map((e => { const t = bb({ inputs: { input: e }, backend: n, attrs: { dim: i } }); return s.push(t), t })), backend: n, attrs: { axis: i } }); return s.forEach((e => n.disposeIntermediateTensorInfo(e))), u } const Tv = { kernelName: P.Pack, backendName: "cpu", kernelFunc: Av }; const Ev = { + kernelName: P.PadV2, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, constantValue: o } = r; ip(i, "pad"); const s = a.map(((e, t) => e[0] + i.shape[t] + e[1])), u = a.map((e => e[0])), l = n.data.get(i.dataId).values, c = P.util.sizeFromShape(i.shape), h = i.shape.length, d = P.util.computeStrides(i.shape), f = P.util.sizeFromShape(s), p = s.length, m = P.util.computeStrides(s), g = P.util.getTypedArrayFromDType(i.dtype, f); 0 !== o && g.fill(o); for (let e = 0; e < c; e++) { const t = P.util.indexToLoc(e, h, d).map(((e, t) => e + u[t])); g[P.util.locToIndex(t, p, m)] = l[e] } return { dataId: n.write(g, s, i.dtype), shape: s, dtype: i.dtype } } + }, Nv = lp(((e, t) => Math.pow(e, t))), Iv = xp(P.Pow, Nv), Mv = { kernelName: P.Pow, backendName: "cpu", kernelFunc: Iv }; const Fv = { + kernelName: P.RaggedGather, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { paramsNestedSplits: i, paramsDenseValues: a, indices: o } = t, { outputRaggedRank: s } = r, u = i.map((e => n.data.get(e.dataId).values)), l = i.map((e => e.shape)), c = n.data.get(a.dataId).values, h = n.data.get(o.dataId).values, [d, f, p] = jm(u, l, c, a.shape, a.dtype, h, o.shape), m = d.map((e => n.makeTensorInfo([e.length], "int32", e))), g = n.makeTensorInfo(p, a.dtype, f); return m.concat([g]) } + }; const Dv = { + kernelName: P.RaggedRange, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { starts: r, limits: i, deltas: a } = t, o = n.data.get(r.dataId).values, s = n.data.get(i.dataId).values, u = n.data.get(a.dataId).values, [l, c] = Wm(o, r.shape, r.dtype, s, i.shape, u, a.shape); return [n.makeTensorInfo([l.length], "int32", l), n.makeTensorInfo([c.length], r.dtype, c)] } + }; const $v = { + kernelName: P.RaggedTensorToTensor, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { shape: i, values: a, defaultValue: o, rowPartitionTensors: s } = t, { rowPartitionTypes: u } = r, l = n.data.get(i.dataId).values, c = n.data.get(a.dataId).values, h = n.data.get(o.dataId).values, d = s.map((e => n.data.get(e.dataId).values)), f = s.map((e => e.shape)), [p, m] = Ym(l, i.shape, c, a.shape, a.dtype, h, o.shape, d, f, u); return n.makeTensorInfo(p, a.dtype, m) } + }; const Rv = { + kernelName: P.Range, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, dtype: a, step: o } = n, s = Xm(r, i, o, a); return t.makeTensorInfo([s.length], a, s) } + }, Ov = Fp(P.Reciprocal, (e => 1 / e)), zv = { kernelName: P.Reciprocal, backendName: "cpu", kernelFunc: Ov }; const Pv = { + kernelName: P.ResizeBilinear, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r; ip(i, "resizeBilinear"); const u = P.util.computeStrides(i.shape), [l, c] = s, [h, d, f, p] = i.shape, m = n.data.get(i.dataId).values, g = new Float32Array(P.util.sizeFromShape([h, l, c, p])), y = [a && l > 1 ? d - 1 : d, a && c > 1 ? f - 1 : f], b = [a && l > 1 ? l - 1 : l, a && c > 1 ? c - 1 : c]; let v = 0; const x = y[0] / b[0], w = y[1] / b[1]; for (let e = 0; e < h; e++)for (let t = 0; t < l; t++) { let n; n = o ? x * (t + .5) - .5 : x * t; const r = Math.max(0, Math.floor(n)), i = n - r, a = Math.min(d - 1, Math.ceil(n)), s = e * u[0] + r * u[1], l = e * u[0] + a * u[1]; for (let e = 0; e < c; e++) { let t; t = o ? w * (e + .5) - .5 : w * e; const n = Math.max(0, Math.floor(t)), r = t - n, a = Math.min(f - 1, Math.ceil(t)), c = s + n * u[2], h = l + n * u[2], d = s + a * u[2], y = l + a * u[2]; for (let e = 0; e < p; e++) { const t = m[c + e], n = m[h + e], a = t + (m[d + e] - t) * r, o = a + (n + (m[y + e] - n) * r - a) * i; g[v++] = o } } } return n.makeTensorInfo([h, l, c, p], "float32", g) } + }; const Bv = { + kernelName: P.ResizeBilinearGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r; ip([a, i], "resizeBilinearGrad"); const s = P.util.computeStrides(i.shape), [u, l, c, h] = i.shape, [, d, f] = a.shape, p = new Float32Array(u * l * c * h), m = [o && d > 1 ? l - 1 : l, o && f > 1 ? c - 1 : c], g = [o && d > 1 ? d - 1 : d, o && f > 1 ? f - 1 : f], y = m[0] / g[0], b = m[1] / g[1], v = n.data.get(a.dataId).values; let x = 0; for (let e = 0; e < u; e++) { const t = e * s[0]; for (let e = 0; e < d; e++) { const n = e * y, r = Math.floor(n), i = Math.min(Math.ceil(n), l - 1), a = t + r * s[1], o = t + i * s[1], u = n - r, d = 1 - u; for (let e = 0; e < f; e++) { const t = e * b, n = Math.floor(t), r = Math.min(Math.ceil(t), c - 1), i = t - n, l = 1 - i, f = a + n * s[2], m = a + r * s[2], g = o + n * s[2], y = o + r * s[2], w = d * l, k = d * i, S = u * l, _ = u * i; for (let e = 0; e < h; e++) { const t = v[x++]; p[f + e] += t * w, p[m + e] += t * k, p[g + e] += t * S, p[y + e] += t * _ } } } } return n.makeTensorInfo([u, c, l, h], "float32", p) } + }; const Lv = { + kernelName: P.ResizeNearestNeighbor, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r; ip(i, "resizeNearestNeighbor"); const u = P.util.computeStrides(i.shape), [l, c] = s, [h, d, f, p] = i.shape, m = n.data.get(i.dataId).values, g = new Float32Array(h * l * c * p), y = [a && l > 1 ? d - 1 : d, a && c > 1 ? f - 1 : f], b = [a && l > 1 ? l - 1 : l, a && c > 1 ? c - 1 : c], v = y[0] / b[0], x = y[1] / b[1]; let w = 0; for (let e = 0; e < h; e++) { const t = e * u[0]; for (let e = 0; e < l; e++) { const n = o ? v * (e + .5) : v * e; let r = Math.min(d - 1, a ? Math.round(n) : Math.floor(n)); o && (r = Math.max(0, r)); const i = t + r * u[1]; for (let e = 0; e < c; e++) { const t = o ? x * (e + .5) : x * e; let n = Math.min(f - 1, a ? Math.round(t) : Math.floor(t)); o && (n = Math.max(0, n)); const r = i + n * u[2]; for (let e = 0; e < p; e++) { const t = m[r + e]; g[w++] = t } } } } return n.makeTensorInfo([h, l, c, p], i.dtype, g) } + }; const jv = { + kernelName: P.ResizeNearestNeighborGrad, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r; ip([a, i], "resizeNearestNeighborGrad"); const s = P.util.computeStrides(i.shape), u = P.util.computeStrides(a.shape), [l, c, h, d] = i.shape, [, f, p] = a.shape, m = new Float32Array(l * c * h * d), g = n.data.get(a.dataId).values, y = [o && f > 1 ? c - 1 : c, o && p > 1 ? h - 1 : h], b = [o && f > 1 ? f - 1 : f, o && p > 1 ? p - 1 : p], v = y[0] / b[0], x = y[1] / b[1], w = 1 / v, k = 1 / x, S = 2 * Math.ceil(w) + 2, _ = 2 * Math.ceil(k) + 2; for (let e = 0; e < l; e++) { const t = e * s[0]; for (let e = 0; e < c; e++) { const n = t + e * s[1], r = Math.floor(e * w), i = Math.floor(r - S / 2); for (let r = 0; r < h; r++) { const a = n + r * s[2], l = Math.floor(r * k), y = Math.floor(l - _ / 2); for (let n = 0; n < d; n++) { let s = 0; for (let a = 0; a < S; a++) { const l = a + i; if (l < 0 || l >= f) continue; const d = t + l * u[1], m = l * v; if (e === Math.min(c - 1, o ? Math.round(m) : Math.floor(m))) for (let e = 0; e < _; e++) { const t = e + y; if (t < 0 || t >= p) continue; const i = d + t * u[2], a = t * x; r === Math.min(h - 1, o ? Math.round(a) : Math.floor(a)) && (s += g[i + n]) } } m[a + n] = s } } } } return n.makeTensorInfo(i.shape, i.dtype, m) } + }; const Uv = { + kernelName: P.Reverse, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dims: a } = r; ip(i, "reverse"); const o = i.shape.length, s = P.util.parseAxisParam(a, i.shape); if (0 === o) return fp({ inputs: { x: i }, backend: n }); const u = new P.TensorBuffer(i.shape, i.dtype), l = n.bufferSync(i); for (let e = 0; e < u.size; e++) { const t = u.indexToLoc(e), n = t.slice(); s.forEach((e => n[e] = i.shape[e] - 1 - n[e])), u.set(l.get(...n), ...t) } return n.makeTensorInfo(u.shape, u.dtype, u.values) } + }, Wv = { kernelName: P.RotateWithOffset, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, { radians: i, fillValue: a, center: o } = t, s = n, u = P.util.getTypedArrayFromDType(r.dtype, P.util.sizeFromShape(r.shape)), [l, c, h, d] = r.shape, [f, p] = P.backend_util.getImageCenter(o, c, h), m = Math.sin(i), g = Math.cos(i), y = s.data.get(r.dataId).values; for (let e = 0; e < l; e++) { const t = e * h * c * d; for (let e = 0; e < c; e++) { const n = e * (h * d); for (let r = 0; r < h; r++) { const i = r * d; for (let o = 0; o < d; o++) { const s = [l, e, r, o], b = s[2], v = s[1]; let x = (b - f) * g - (v - p) * m, w = (b - f) * m + (v - p) * g; x = Math.round(x + f), w = Math.round(w + p); let k = a; if ("number" != typeof a && (k = 3 === o ? 255 : a[o]), x >= 0 && x < h && w >= 0 && w < c) { k = y[t + w * (h * d) + x * d + o] } u[t + n + i + o] = k } } } } return { dataId: s.write(u, r.shape, r.dtype), shape: r.shape, dtype: r.dtype } } }, Vv = Fp(P.Round, (e => { const t = Math.floor(e); return e - t < .5 ? Math.floor(e) : e - t > .5 ? Math.ceil(e) : t % 2 == 0 ? t : t + 1 })), Gv = { kernelName: P.Round, backendName: "cpu", kernelFunc: Vv }; const Hv = { + kernelName: P.ScatterNd, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i, updates: a } = t, { shape: o } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(a, i, o), d = Qm(n.bufferSync(i), n.bufferSync(a), o, h, l, u, s, c, 0, !0); return n.makeTensorInfo(o, d.dtype, d.values) } + }; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function qv(e, t) { let n = 0, r = e.length, i = 0; for (; n < r;)i = Math.floor((n + r) / 2), e[i] < t ? n = i + 1 : r = i; return r } function Yv(e, t) { let n = 0, r = e.length, i = 0; for (; n < r;)i = Math.floor((n + r) / 2), e[i] <= t ? n = i + 1 : r = i; return r } const Xv = { + kernelName: P.SearchSorted, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { sortedSequence: i, values: a } = t, { side: o } = r, s = function (e, t, n, r, i, a) { const o = P.util.getArrayFromDType("int32", n * i); for (let s = 0; s < n; ++s) { const n = e.slice(s * r, (s + 1) * r), u = s * i; for (let e = 0; e < i; ++e)o[u + e] = "left" === a ? qv(n, t[e + u]) : Yv(n, t[e + u]) } return o }(n.data.get(i.dataId).values, n.data.get(a.dataId).values, i.shape[0], i.shape[1], a.shape[1], o); return n.makeTensorInfo(a.shape, "int32", s) } + }; const Kv = { + kernelName: P.Select, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { condition: r, t: i, e: a } = t; ip([r, i, a], "select"); const o = r.shape.length, s = n.data.get(r.dataId).values, u = n.data.get(i.dataId).values, l = n.data.get(a.dataId).values, c = (0, P.upcastType)(i.dtype, a.dtype), h = P.util.makeZerosTypedArray(P.util.sizeFromShape(i.shape), c); let d = 0; const f = 0 === o || o > 1 || 1 === i.shape.length ? 1 : P.util.sizeFromShape(i.shape.slice(1)); for (let e = 0; e < s.length; e++)for (let t = 0; t < f; t++)1 === s[e] ? h[d++] = u[e] : h[d++] = l[e]; return n.makeTensorInfo(i.shape, c, h) } + }, Zv = P.backend_util.SELU_SCALEALPHA, Jv = P.backend_util.SELU_SCALE, Qv = Fp(P.Selu, (e => e >= 0 ? Jv * e : Zv * (Math.exp(e) - 1))), ex = { kernelName: P.Selu, backendName: "cpu", kernelFunc: Qv }, tx = Fp(P.Sign, (e => e < 0 ? -1 : e > 0 ? 1 : 0)), nx = { kernelName: P.Sign, backendName: "cpu", kernelFunc: tx }, rx = Fp(P.Sin, (e => Math.sin(e))), ix = { kernelName: P.Sin, backendName: "cpu", kernelFunc: rx }, ax = Fp(P.Sinh, (e => Math.sinh(e))), ox = { kernelName: P.Sinh, backendName: "cpu", kernelFunc: ax }, sx = Math.log(1.1920928955078125e-7) + 2, ux = Fp(P.Softplus, (e => { const t = e > -sx, n = e < sx, r = Math.exp(e); let i; return i = n ? r : t ? e : Math.log(1 + r), i })), lx = { kernelName: P.Softplus, backendName: "cpu", kernelFunc: ux }; const cx = { + kernelName: P.SpaceToBatchND, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, paddings: o } = r; ip([i], "spaceToBatchND"); const s = P.util.sizeFromShape(a), u = [[0, 0]]; u.push(...o); for (let e = 1 + a.length; e < i.shape.length; ++e)u.push([0, 0]); const l = Ev.kernelFunc({ inputs: { x: i }, backend: n, attrs: { paddings: u, constantValue: 0 } }), c = P.backend_util.getReshaped(l.shape, a, s, !1), h = P.backend_util.getPermuted(c.length, a.length, !1), d = P.backend_util.getReshapedPermuted(l.shape, a, s, !1), f = Hg({ inputs: { x: l }, backend: n, attrs: { shape: c } }), p = $m({ inputs: { x: f }, backend: n, attrs: { perm: h } }), m = Hg({ inputs: { x: p }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), m } + }; const hx = { + kernelName: P.SparseFillEmptyRows, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { indices: r, values: i, denseShape: a, defaultValue: o } = t; if (1 !== a.shape.length) throw new Error(`Dense shape must be a vector, saw:\n ${a.shape}`); if (2 !== r.shape.length) throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Values must be a vector, saw:\n ${i.shape}`); if (0 !== o.shape.length) throw new Error(`Default value must be a scalar, saw:\n ${o.shape}`); const s = n.data.get(r.dataId).values, u = n.data.get(i.dataId).values, l = n.data.get(a.dataId).values, c = n.data.get(o.dataId).values[0], [h, d, f, p, m] = og(s, r.shape, r.dtype, u, i.dtype, l, c); return [n.makeTensorInfo(d, r.dtype, h), n.makeTensorInfo([d[0]], i.dtype, f), n.makeTensorInfo([p.length], "bool", new Uint8Array(p.map((e => Number(e))))), n.makeTensorInfo([m.length], r.dtype, new Int32Array(m))] } + }; const dx = { + kernelName: P.SparseReshape, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { inputIndices: r, inputShape: i, newShape: a } = t; if (2 !== r.shape.length) throw new Error(`Input indices should be a matrix but received shape\n ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Input shape should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Target shape should be a vector but received shape ${a.shape}`); const o = Array.from(n.data.get(i.dataId).values), s = n.data.get(r.dataId).values, u = Array.from(n.data.get(a.dataId).values), [l, c, h] = sg(s, r.shape, r.dtype, o, u); return [n.makeTensorInfo(c, r.dtype, l), n.makeTensorInfo([h.length], a.dtype, new Int32Array(h))] } + }; const fx = { + kernelName: P.SparseSegmentMean, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); if (i.shape[0] !== a.shape[0]) throw new Error("segmentIds and indices should have same size."); const o = n.data.get(r.dataId).values, s = n.data.get(i.dataId).values, u = n.data.get(a.dataId).values, [l, c] = ug(o, r.shape, r.dtype, s, u, !0); return n.makeTensorInfo(c, r.dtype, l) } + }; const px = { + kernelName: P.SparseSegmentSum, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); if (i.shape[0] !== a.shape[0]) throw new Error("segmentIds and indices should have same size."); const o = n.data.get(r.dataId).values, s = n.data.get(i.dataId).values, u = n.data.get(a.dataId).values, [l, c] = ug(o, r.shape, r.dtype, s, u); return n.makeTensorInfo(c, r.dtype, l) } + }; const mx = { + kernelName: P.SparseToDense, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { sparseIndices: i, sparseValues: a, defaultValue: o } = t, { outputShape: s } = r, { sliceRank: u, numUpdates: l, sliceSize: c, strides: h, outputSize: d } = P.backend_util.calculateShapes(a, i, s), f = !1, p = n.bufferSync(i); let m; switch (a.dtype) { case "bool": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, Boolean(n.data.get(o.dataId).values[0]), f); break; case "float32": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, n.data.get(o.dataId).values[0], f); break; case "int32": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, n.data.get(o.dataId).values[0], f); break; case "string": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, P.util.decodeString(n.data.get(o.dataId).values[0]), f); break; default: throw new Error(`Unsupported type ${a.dtype}`) }return n.makeTensorInfo(s, m.dtype, m.values) } + }; const gx = { + kernelName: P.SplitV, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { numOrSizeSplits: a, axis: o } = r, s = P.util.parseAxisParam(o, i.shape)[0], u = P.backend_util.prepareSplitSize(i, a, s), l = new Array(i.shape.length).fill(0), c = i.shape.slice(); return u.map((e => { const t = [...c]; t[s] = e; const r = ig({ inputs: { x: i }, backend: n, attrs: { begin: l, size: t } }); return l[s] += e, r })) } + }, yx = { kernelName: P.Square, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t }) => { const { x: n } = e, r = t; ip(n, "square"); const i = r.data.get(n.dataId).values, a = new Float32Array(i.length); for (let e = 0; e < i.length; ++e) { const t = i[e]; a[e] = t * t } return { dataId: r.write(a, n.shape, n.dtype), shape: n.shape, dtype: n.dtype } } }, bx = Fp(P.Step, ((e, t) => { const n = t; return isNaN(e) ? NaN : e > 0 ? 1 : n.alpha })), vx = { kernelName: P.Step, backendName: "cpu", kernelFunc: bx }; const xx = { + kernelName: P.StridedSlice, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, end: o, strides: s, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: h, shrinkAxisMask: d } = r; ip(i, "stridedSlice"); const { finalShapeSparse: f, finalShape: p, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: b, end: v, strides: x } = P.slice_util.sliceInfo(i.shape, a, o, s, u, l, c, h, d); let w; if (m) w = Hg({ inputs: { x: i }, backend: n, attrs: { shape: p } }); else if (g || y) { P.util.assert(i.shape.length >= 1, (() => `Input must have rank at least 1, got: ${i.shape.length}`)); const e = P.slice_util.computeOutShape(b, v, x), t = ig({ inputs: { x: i }, backend: n, attrs: { begin: b, size: e } }); w = Hg({ inputs: { x: t }, backend: n, attrs: { shape: p } }), n.disposeIntermediateTensorInfo(t) } else { const e = bg(f, n.bufferSync(i), x, b); w = n.makeTensorInfo(p, e.dtype, e.values) } return w } + }; const wx = { + kernelName: P.StringNGrams, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { separator: i, nGramWidths: a, leftPad: o, rightPad: s, padWidth: u, preserveShortSequences: l } = r, { data: c, dataSplits: h } = t, d = n.data.get(c.dataId).values, f = n.data.get(h.dataId).values, [p, m] = xg(d, f, i, a, o, s, u, l); return [n.makeTensorInfo([p.length], "string", p), n.makeTensorInfo(h.shape, "int32", m)] } + }; const kx = { + kernelName: P.StringSplit, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { skipEmpty: i } = r, { input: a, delimiter: o } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (1 !== a.shape.length) throw new Error(`Input must be a vector, got shape: ${a.shape}`); if (0 !== o.shape.length) throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`); const s = n.data.get(a.dataId).values, u = n.data.get(o.dataId).values[0], [l, c, h] = kg(s, u, i), d = c.length; return [n.makeTensorInfo([d, 2], "int32", l), n.makeTensorInfo([d], "string", c), n.makeTensorInfo([2], "int32", new Int32Array(h))] } + }; const Sx = { + kernelName: P.StringToHashBucketFast, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { numBuckets: i } = r, { input: a } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (i <= 0) throw new Error("Number of buckets must be at least 1"); const o = Sg(n.data.get(a.dataId).values, i); return n.makeTensorInfo(a.shape, "int32", o) } + }, _x = Fp(P.Tan, (e => Math.tan(e))), Cx = { kernelName: P.Tan, backendName: "cpu", kernelFunc: _x }, Ax = Fp(P.Tanh, (e => Math.tanh(e))), Tx = { kernelName: P.Tanh, backendName: "cpu", kernelFunc: Ax }; const Ex = { + kernelName: P.TensorScatterUpdate, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { tensor: r, indices: i, updates: a } = t, { sliceRank: o, numUpdates: s, sliceSize: u, strides: l, outputSize: c } = P.backend_util.calculateShapes(a, i, r.shape), h = n.bufferSync(i), d = n.bufferSync(a), f = n.bufferSync(r), p = Qm(h, d, r.shape, c, u, s, o, l, f, !1); return n.makeTensorInfo(r.shape, p.dtype, p.values) } + }; const Nx = { + kernelName: P.Tile, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reps: a } = r; ip(i, "tile"); const o = Eg(n.bufferSync(i), a); return n.makeTensorInfo(o.shape, o.dtype, o.values) } + }; const Ix = { + kernelName: P.TopK, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { k: a, sorted: o } = r; ip(i, "topk"); const s = n.data.get(i.dataId).values, [u, l] = Mg(s, i.shape, i.dtype, a, o); return [n.makeTensorInfo(u.shape, u.dtype, u.values), n.makeTensorInfo(l.shape, l.dtype, l.values)] } + }; const Mx = { + kernelName: P.Transform, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, attrs: n, backend: r } = e, { image: i, transforms: a } = t, { interpolation: o, fillMode: s, fillValue: u, outputShape: l } = n, [c, h, d, f] = i.shape, [p, m] = null != l ? l : [h, d], g = [c, p, m, f], y = P.util.computeStrides(i.shape), b = y[0], v = y[1], x = y[2], w = P.util.computeStrides(g), k = w[0], S = w[1], _ = w[2], C = P.util.getTypedArrayFromDType(i.dtype, P.util.sizeFromShape(g)); C.fill(u); const A = r.data.get(i.dataId).values, T = r.data.get(a.dataId).values; for (let e = 0; e < c; ++e) { const t = 1 === a.shape[0] ? T : T.subarray(8 * e, 8 * e + 8); for (let n = 0; n < p; ++n)for (let r = 0; r < m; ++r)for (let i = 0; i < f; ++i) { let a; const l = t[6] * r + t[7] * n + 1; if (0 === l) continue; const c = (t[0] * r + t[1] * n + t[2]) / l, f = (t[3] * r + t[4] * n + t[5]) / l, p = Fx(c, d, s), m = Fx(f, h, s); switch (o) { case "nearest": a = $x(A, h, d, b, v, x, e, m, p, i, u); break; case "bilinear": a = Rx(A, h, d, b, v, x, e, m, p, i, u); break; default: throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`) }C[e * k + n * S + r * _ + i] = a } return r.makeTensorInfo(g, i.dtype, C) } return { dataId: r.write(C, g, i.dtype), shape: i.shape, dtype: i.dtype } } + }; function Fx(e, t, n) { switch (n) { case "reflect": return function (e, t) { let n = e; if (n < 0) if (t <= 1) n = 0; else { const e = 2 * t; n < e && (n = e * Math.trunc(-n / e) + n), n = n < -t ? n + e : -n - 1 } else if (n > t - 1) if (t <= 1) n = 0; else { const e = 2 * t; n -= e * Math.trunc(n / e), n >= t && (n = e - n - 1) } return P.util.clamp(0, n, t - 1) }(e, t); case "wrap": return function (e, t) { let n = e; if (n < 0) if (t <= 1) n = 0; else { const e = t - 1; n += t * (Math.trunc(-n / e) + 1) } else if (n > t - 1) if (t <= 1) n = 0; else { const e = t - 1; n -= t * Math.trunc(n / e) } return P.util.clamp(0, n, t - 1) }(e, t); case "nearest": return function (e, t) { return P.util.clamp(0, e, t - 1) }(e, t); default: return function (e) { return e }(e) } } function Dx(e, t, n, r, i, a, o, s, u, l, c) { return 0 <= s && s < t && 0 <= u && u < n ? e[o * r + s * i + u * a + l] : c } function $x(e, t, n, r, i, a, o, s, u, l, c) { return Dx(e, t, n, r, i, a, o, Math.round(s), Math.round(u), l, c) } function Rx(e, t, n, r, i, a, o, s, u, l, c) { const h = Math.floor(s), d = Math.floor(u), f = h + 1, p = d + 1; return (f - s) * ((p - u) * Dx(e, t, n, r, i, a, o, h, d, l, c) + (u - d) * Dx(e, t, n, r, i, a, o, h, p, l, c)) + (s - h) * ((p - u) * Dx(e, t, n, r, i, a, o, f, d, l, c) + (u - d) * Dx(e, t, n, r, i, a, o, f, p, l, c)) } const Ox = { + kernelName: P.Unique, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, attrs: n, backend: r } = e, { axis: i } = n, { x: a } = t; ip(a, "unique"); const o = r.data.get(a.dataId).values, { outputValues: s, outputShape: u, indices: l } = Fg(o, i, a.shape, a.dtype); return [r.makeTensorInfo(u, a.dtype, s), r.makeTensorInfo([l.length], "int32", l)] } + }; const zx = { + kernelName: P.Unpack, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { value: i } = t; let { axis: a } = r; a < 0 && (a += i.shape.length); const o = i.shape.length, s = i.shape[a], u = new Array(o - 1); let l = 0; for (let e = 0; e < o; e++)e !== a && (u[l++] = i.shape[e]); const c = new Array(o).fill(0), h = i.shape.slice(); h[a] = 1; const d = new Array(s); for (let e = 0; e < d.length; e++) { c[a] = e; const t = ig({ inputs: { x: i }, backend: n, attrs: { begin: c, size: h } }); d[e] = Hg({ inputs: { x: t }, backend: n, attrs: { shape: u } }), n.disposeIntermediateTensorInfo(t) } return d } + }; const Px = { + kernelName: P.UnsortedSegmentSum, backendName: "cpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, segmentIds: a } = t, { numSegments: o } = r; ip(i, "unsortedSegmentSum"); const s = [], u = [], l = i.shape.length - a.shape.length; let c = a; for (let e = 0; e < l; ++e) { const t = bb({ inputs: { input: c }, backend: n, attrs: { dim: e + 1 } }); c = t, u.push(t) } for (let e = 0; e < o; ++e) { const t = P.util.createScalarValue(e, "int32"), r = n.makeTensorInfo([], "int32", t), a = Bp({ inputs: { a: r, b: c }, backend: n }), o = bp({ inputs: { x: a }, backend: n, attrs: { dtype: "float32" } }), l = Am({ inputs: { a: o, b: i }, backend: n }), h = ob({ inputs: { x: l }, backend: n, attrs: { axis: 0, keepDims: !1 } }); s.push(h), u.push(r), u.push(a), u.push(o), u.push(l), u.push(h) } const h = Av({ inputs: s, backend: n, attrs: { axis: 0 } }); return u.forEach((e => n.disposeIntermediateTensorInfo(e))), h } + }, Bx = [Kg, up, Jg, ey, Cp, ty, ny, ry, iy, ay, sy, ly, hy, py, gy, xy, wy, ky, Sy, Xg, _y, Cy, Ay, Ip, Ty, vp, Op, Ny, hp, Iy, $y, Oy, zy, Py, By, Ly, jy, Wy, Gy, Hy, qy, Yy, Xy, Ky, Jy, Qy, eb, tb, nb, rb, ib, ab, ub, Rg, lb, Lp, yb, Wp, vb, Hp, Ab, Eb, Nb, Xp, Jp, Ib, Mb, Fb, Db, rm, om, pp, $b, Fy, Ob, Pb, Lb, zg, lm, dm, jb, gm, Wb, Hb, Yb, Zb, Jb, Qb, tv, xm, nv, rv, iv, av, ov, sv, uv, Sm, lv, dv, mv, Tm, Nm, yv, vv, wv, Fm, kv, Cv, Tv, Ev, Mv, Lg, zm, Fv, Dv, $v, Rv, gp, kb, zv, Ug, Vg, qg, Pv, Bv, Lv, jv, Uv, Wv, Gv, Jm, Hv, Xv, Kv, ex, ng, nx, ix, ox, ag, pv, lx, cx, hx, dx, fx, px, mx, gx, hg, yx, pg, yg, vx, xx, wx, kx, Sx, Tg, sb, Cx, Tx, Ex, Nx, Ix, Mx, Rm, Ox, zx, Px, _v]; for (const e of Bx) (0, P.registerKernel)(e); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Lx = {}, jx = { alpha: !1, antialias: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !1, depth: !1, stencil: !1, failIfMajorPerformanceCaveat: !0 }; function Ux(e, t) { Lx[e] = t } function Wx(e, t) { if (!(e in Lx) || null != t) { const n = function (e, t) { if (1 !== e && 2 !== e) throw new Error("Cannot get WebGL rendering context, WebGL is disabled."); const n = null == t ? function (e) { if ((0, P.env)().getBool("IS_SAFARI") || "undefined" == typeof OffscreenCanvas || 2 !== e) { if ("undefined" != typeof document) return document.createElement("canvas"); throw new Error("Cannot create a canvas in this context") } return new OffscreenCanvas(300, 150) }(e) : t; n.addEventListener("webglcontextlost", (t => { t.preventDefault(), delete Lx[e] }), !1), (0, P.env)().getBool("SOFTWARE_WEBGL_ENABLED") && (jx.failIfMajorPerformanceCaveat = !1); if (1 === e) return n.getContext("webgl", jx) || n.getContext("experimental-webgl", jx); return n.getContext("webgl2", jx) }(e, t); if (null === n) return console.log("Could not get context for WebGL version", e), null; Lx[e] = n } const n = Lx[e]; return null == n || n.isContextLost() ? (delete Lx[e], Wx(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), Lx[e]) } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var Vx, Gx, Hx, qx, Yx, Xx; function Kx(e, t) { return [t, e] } function Zx(e) { const t = P.util.sizeFromShape(e), n = Math.ceil(t / 4); return P.util.sizeToSquarishShape(n) } function Jx(e, t) { return [Math.max(1, Math.ceil(t / 2)), Math.max(1, Math.ceil(e / 2))] } function Qx(e, t) { const n = e; let r, i, a, o, s, u, l, c, h, d; return 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? (r = n.R32F, i = n.R16F, a = n.RGBA16F, o = n.RGBA32F, s = n.RED, l = 4, c = 1, h = n.HALF_FLOAT, d = n.FLOAT, u = n.RGBA8) : (r = e.RGBA, i = e.RGBA, a = e.RGBA, o = n.RGBA, s = e.RGBA, l = 4, c = 4, h = null != t ? t.HALF_FLOAT_OES : null, d = e.FLOAT, u = e.RGBA), { internalFormatFloat: r, internalFormatHalfFloat: i, internalFormatPackedHalfFloat: a, internalFormatPackedFloat: o, textureFormatFloat: s, downloadTextureFormat: u, downloadUnpackNumChannels: l, defaultNumChannels: c, textureTypeHalfFloat: h, textureTypeFloat: d } } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ew(e, t) { const n = t(); return (0, P.env)().getBool("DEBUG") && function (e) { const t = e.getError(); if (t !== e.NO_ERROR) throw new Error("WebGL Error: " + iw(e, t)) }(e), n } (Gx = Vx || (Vx = {}))[Gx.DENSE = 0] = "DENSE", Gx[Gx.SHARED_BATCH = 1] = "SHARED_BATCH", (qx = Hx || (Hx = {}))[qx.RENDER = 0] = "RENDER", qx[qx.UPLOAD = 1] = "UPLOAD", qx[qx.PIXELS = 2] = "PIXELS", qx[qx.DOWNLOAD = 3] = "DOWNLOAD", (Xx = Yx || (Yx = {}))[Xx.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", Xx[Xx.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", Xx[Xx.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", Xx[Xx.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", Xx[Xx.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16"; const tw = 5.96e-8, nw = 65504; function rw(e) { return !!((0, P.env)().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || 0 === e || tw < Math.abs(e) && Math.abs(e) < nw) } function iw(e, t) { switch (t) { case e.NO_ERROR: return "NO_ERROR"; case e.INVALID_ENUM: return "INVALID_ENUM"; case e.INVALID_VALUE: return "INVALID_VALUE"; case e.INVALID_OPERATION: return "INVALID_OPERATION"; case e.INVALID_FRAMEBUFFER_OPERATION: return "INVALID_FRAMEBUFFER_OPERATION"; case e.OUT_OF_MEMORY: return "OUT_OF_MEMORY"; case e.CONTEXT_LOST_WEBGL: return "CONTEXT_LOST_WEBGL"; default: return `Unknown error code ${t}` } } function aw(e, t) { return Iw(e, (() => e.getExtension(t)), 'Extension "' + t + '" not supported on this browser.') } function ow(e, t) { const n = Iw(e, (() => e.createShader(e.VERTEX_SHADER)), "Unable to create vertex WebGLShader."); if (ew(e, (() => e.shaderSource(n, t))), ew(e, (() => e.compileShader(n))), !1 === e.getShaderParameter(n, e.COMPILE_STATUS)) throw console.log(e.getShaderInfoLog(n)), new Error("Failed to compile vertex shader."); return n } function sw(e, t) { const n = Iw(e, (() => e.createShader(e.FRAGMENT_SHADER)), "Unable to create fragment WebGLShader."); if (ew(e, (() => e.shaderSource(n, t))), ew(e, (() => e.compileShader(n))), (0, P.env)().get("ENGINE_COMPILE_ONLY")) return n; if (!1 === e.getShaderParameter(n, e.COMPILE_STATUS)) throw lw(t, e.getShaderInfoLog(n)), new Error("Failed to compile fragment shader."); return n } const uw = /ERROR: [0-9]+:([0-9]+):/g; function lw(e, t) { const n = uw.exec(t); if (null == n) return console.log(`Couldn't parse line number in error: ${t}`), void console.log(e); const r = +n[1], i = e.split("\n"), a = i.length.toString().length + 2, o = i.map(((e, t) => P.util.rightPad((t + 1).toString(), a) + e)); let s = 0; for (let e = 0; e < o.length; e++)s = Math.max(o[e].length, s); const u = o.slice(0, r - 1), l = o.slice(r - 1, r), c = o.slice(r); console.log(u.join("\n")), console.log(t.split("\n")[0]), console.log(`%c ${P.util.rightPad(l[0], s)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(c.join("\n")) } function cw(e) { return Iw(e, (() => e.createProgram()), "Unable to create WebGLProgram.") } function hw(e, t) { if (ew(e, (() => e.linkProgram(t))), !(0, P.env)().get("ENGINE_COMPILE_ONLY") && !1 === e.getProgramParameter(t, e.LINK_STATUS)) throw console.log(e.getProgramInfoLog(t)), new Error("Failed to link vertex and fragment shaders.") } function dw(e, t) { if (ew(e, (() => e.validateProgram(t))), !1 === e.getProgramParameter(t, e.VALIDATE_STATUS)) throw console.log(e.getProgramInfoLog(t)), new Error("Shader program validation failed.") } function fw(e, t) { const n = Iw(e, (() => e.createBuffer()), "Unable to create WebGLBuffer"); return ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, n))), ew(e, (() => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW))), n } function pw(e, t) { const n = Iw(e, (() => e.createBuffer()), "Unable to create WebGLBuffer"); return ew(e, (() => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n))), ew(e, (() => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW))), n } function mw() { return 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? 1 : 4 } function gw(e) { return Iw(e, (() => e.createTexture()), "Unable to create WebGLTexture.") } function yw(e, t) { const n = (0, P.env)().getNumber("WEBGL_MAX_TEXTURE_SIZE"); if (e <= 0 || t <= 0) { throw new Error("Requested texture size " + `[${e}x${t}]` + " is invalid.") } if (e > n || t > n) { throw new Error("Requested texture size " + `[${e}x${t}]` + " greater than WebGL maximum on this browser / GPU " + `[${n}x${n}]` + ".") } } function bw(e) { return Iw(e, (() => e.createFramebuffer()), "Unable to create WebGLFramebuffer.") } function vw(e, t, n, r, i, a, o) { const s = e.getAttribLocation(t, n); return -1 !== s && (ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, r))), ew(e, (() => e.vertexAttribPointer(s, i, e.FLOAT, !1, a, o))), ew(e, (() => e.enableVertexAttribArray(s))), !0) } function xw(e, t, n) { Mw(e, n), ew(e, (() => e.activeTexture(e.TEXTURE0 + n))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, t))) } function ww(e, t) { Mw(e, t), ew(e, (() => e.activeTexture(e.TEXTURE0 + t))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))) } function kw(e, t, n) { return Iw(e, (() => e.getUniformLocation(t, n)), 'uniform "' + n + '" not present in program.') } function Sw(e, t, n) { return e.getUniformLocation(t, n) } function _w(e, t, n, r) { ew(e, (() => xw(e, t, r))), ew(e, (() => e.uniform1i(n, r))) } function Cw(e) { ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, null))), ew(e, (() => e.viewport(0, 0, e.canvas.width, e.canvas.height))), ew(e, (() => e.scissor(0, 0, e.canvas.width, e.canvas.height))) } function Aw(e, t, n) { ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, n))), ew(e, (() => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0))) } function Tw(e, t) { ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, t))), ew(e, (() => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0))) } function Ew(e) { const t = e.checkFramebufferStatus(e.FRAMEBUFFER); if (t !== e.FRAMEBUFFER_COMPLETE) throw new Error("Error binding framebuffer: " + Nw(e, t)) } function Nw(e, t) { switch (t) { case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS"; case e.FRAMEBUFFER_UNSUPPORTED: return "FRAMEBUFFER_UNSUPPORTED"; default: return `unknown error ${t}` } } function Iw(e, t, n) { const r = ew(e, (() => t())); if (null == r) throw new Error(n); return r } function Mw(e, t) { const n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0; if (r < e.TEXTURE0 || r > n) { throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`) } } function Fw(e, t = 2) { return P.util.sizeFromShape(e.slice(0, e.length - t)) } function Dw(e) { if (0 === e.length) throw Error("Cannot get rows and columns of an empty shape array."); return [e.length > 1 ? e[e.length - 2] : 1, e[e.length - 1]] } function $w(e) { let t = [1, 1, 1]; return 0 === e.length || 1 === e.length && 1 === e[0] || (t = [Fw(e), ...Dw(e)]), t } function Rw(e, t = !1) { let n = (0, P.env)().getNumber("WEBGL_MAX_TEXTURE_SIZE"), r = (0, P.env)().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE"); if (r === 1 / 0 && (0, P.env)().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (r = n / 2), t && (n *= 2, r *= 2, 1 === (e = e.map(((t, n) => n >= e.length - 2 ? P.util.nearestLargerEven(e[n]) : e[n]))).length && (e = [2, e[0]])), 2 !== e.length) { const t = P.util.squeezeShape(e); e = t.newShape } let i = P.util.sizeFromShape(e), a = null; e.length <= 1 && i <= n ? a = [1, i] : 2 === e.length && e[0] <= n && e[1] <= n ? a = e : 3 === e.length && e[0] * e[1] <= n && e[2] <= n ? a = [e[0] * e[1], e[2]] : 3 === e.length && e[0] <= n && e[1] * e[2] <= n ? a = [e[0], e[1] * e[2]] : 4 === e.length && e[0] * e[1] * e[2] <= n && e[3] <= n ? a = [e[0] * e[1] * e[2], e[3]] : 4 === e.length && e[0] <= n && e[1] * e[2] * e[3] <= n && (a = [e[0], e[1] * e[2] * e[3]]); const o = null != a && Math.max(...a) > r && Math.min(...a) <= (t ? 2 : 1) && Math.min(...a) > 0; if (null == a || o) if (t) { const t = Fw(e); let n = 2, r = 2; e.length && ([n, r] = Dw(e)), i = t * (n / 2) * (r / 2), a = P.util.sizeToSquarishShape(i).map((e => 2 * e)) } else a = P.util.sizeToSquarishShape(i); return a } function Ow(e) { return e % 2 == 0 } function zw(e, t) { if (e = e.slice(-2), t = t.slice(-2), P.util.arraysEqual(e, t)) return !0; if (!e.length || !t.length) return !0; if (0 === e[0] || 0 === e[1] || 0 === t[0] || 0 === t[1]) return !0; if (e.length !== t.length) { const n = e[e.length - 1], r = t[t.length - 1]; if (n === r) return !0; if (Ow(n) && Ow(r) && (1 === e[0] || 1 === t[0])) return !0 } return e[1] === t[1] && Ow(e[0]) && Ow(t[0]) } let Pw, Bw; function Lw(e) { if (null == Pw) { const t = Wx(e); Pw = t.getParameter(t.MAX_TEXTURE_SIZE) } return Pw } function jw() { Pw = null } function Uw() { Bw = null } function Ww(e) { if (null == Bw) { const t = Wx(e); Bw = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS) } return Math.min(16, Bw) } function Vw(e) { if (0 === e) return 0; let t; const n = Wx(e); return t = Gw(n, "EXT_disjoint_timer_query_webgl2") && 2 === e ? 2 : Gw(n, "EXT_disjoint_timer_query") ? 1 : 0, t } function Gw(e, t) { return null != e.getExtension(t) } function Hw(e) { try { if (null != Wx(e)) return !0 } catch (e) { return console.log("Error when getting WebGL context: ", e), !1 } return !1 } function qw(e) { if (0 === e) return !1; const t = Wx(e); if (1 === e) { if (!Gw(t, "OES_texture_float")) return !1 } else if (!Gw(t, "EXT_color_buffer_float")) return !1; return Xw(t) } function Yw(e) { if (0 === e) return !1; const t = Wx(e); if (1 !== e) { if (Gw(t, "EXT_color_buffer_float")) return Xw(t); const e = "EXT_color_buffer_half_float"; if (Gw(t, e)) { const n = t.getExtension(e); return function (e, t) { const n = Qx(e, t), r = e.createTexture(); e.bindTexture(e.TEXTURE_2D, r); const i = 1, a = 1; e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, i, a, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null); const o = e.createFramebuffer(); e.bindFramebuffer(e.FRAMEBUFFER, o), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0); const s = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE; return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(o), s }(t, n) } return !1 } if (!Gw(t, "OES_texture_float")) return !1; if (!Gw(t, "WEBGL_color_buffer_float")) return !1; return Xw(t) } function Xw(e) { const t = Qx(e), n = e.createTexture(); e.bindTexture(e.TEXTURE_2D, n); e.texImage2D(e.TEXTURE_2D, 0, t.internalFormatFloat, 1, 1, 0, t.textureFormatFloat, t.textureTypeFloat, null); const r = e.createFramebuffer(); e.bindFramebuffer(e.FRAMEBUFFER, r), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, n, 0); const i = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE; return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(r), i } function Kw(e) { if (2 !== e) return !1; return null != Wx(e).fenceSync } function Zw(e, t) { Array.isArray(e) || (e = [e]), e.forEach((e => { null != e && P.util.assert("complex64" !== e.dtype, (() => `${t} does not support complex64 tensors in the WebGL backend.`)) })) } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Jw = (0, P.env)(); + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Qw() { let e, t, n, r, i, a, o, s, u, l; return 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? (e = "#version 300 es", t = "in", n = "out", r = "in", i = "texture", a = "outputColor", o = "out vec4 outputColor;", s = (0, P.env)().getBool("WEBGL2_ISNAN_CUSTOM") ? "\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n " : "", u = "", l = "\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n ") : (e = "", t = "attribute", n = "varying", r = "varying", i = "texture2D", a = "gl_FragColor", o = "", s = "\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ", u = "\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ", l = "\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "), { version: e, attribute: t, varyingVs: n, varyingFs: r, texture2D: i, output: a, defineOutput: o, defineSpecialNaN: s, defineSpecialInf: u, defineRound: l } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ek(e, t, n = "index") { const r = P.util.computeStrides(t); return r.map(((t, i) => `${`int ${e[i]} = ${n} / ${t}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${t}` : `index -= ${e[i]} * ${t}`};`)).join("") } function tk(e, t, n = "index") { const r = P.util.computeStrides(t); return r.map(((t, i) => `${`int ${e[i]} = ${n} / outShapeStrides[${i}]`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * outShapeStrides[${i}]` : `index -= ${e[i]} * outShapeStrides[${i}]`};`)).join("") } function nk(e, t, n = "index") { const r = function (e, t) { const n = e.length, r = e.map((e => `${t}[${e}]`)), i = new Array(n - 1); i[n - 2] = r[n - 1]; for (let e = n - 3; e >= 0; --e)i[e] = `(${i[e + 1]} * ${r[e + 1]})`; return i }(e.map(((e, t) => t)), t); return r.map(((t, i) => `${`int ${e[i]} = ${n} / ${r[i]}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${r[i]}` : `index -= ${e[i]} * ${r[i]}`};`)).join("") } function rk(e) { const t = P.util.computeStrides(e).map((e => e.toString())); return `\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n` } Jw.registerFlag("HAS_WEBGL", (() => Jw.getNumber("WEBGL_VERSION") > 0)), Jw.registerFlag("WEBGL_VERSION", (() => Hw(2) ? 2 : Hw(1) ? 1 : 0)), Jw.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS", (() => !1)), Jw.registerFlag("WEBGL_BUFFER_SUPPORTED", (() => 2 === Jw.get("WEBGL_VERSION"))), Jw.registerFlag("WEBGL_CPU_FORWARD", (() => !0)), Jw.registerFlag("WEBGL_FORCE_F16_TEXTURES", (() => !1)), Jw.registerFlag("WEBGL_PACK", (() => Jw.getBool("HAS_WEBGL"))), Jw.registerFlag("WEBGL_PACK_NORMALIZATION", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_CLIP", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_DEPTHWISECONV", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_BINARY_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_UNARY_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_REDUCE", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_LAZILY_UNPACK", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_CONV_IM2COL", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_MAX_TEXTURE_SIZE", (() => Lw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER", (() => Ww(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION", (() => { const e = Jw.getNumber("WEBGL_VERSION"); return 0 === e ? 0 : Vw(e) })), Jw.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE", (() => Jw.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 && !P.device_util.isMobile())), Jw.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE", (() => qw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED", (() => !Jw.getBool("WEBGL_FORCE_F16_TEXTURES") && Jw.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))), Jw.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED", (() => Yw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_FENCE_API_ENABLED", (() => Kw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM", (() => Jw.getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? 4 : 0)), Jw.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD", (() => -1), (e => { if ("number" != typeof e) throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${e}.`); if (e < 0 && -1 !== e) throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`) })), Jw.registerFlag("WEBGL_FLUSH_THRESHOLD", (() => P.device_util.isMobile() ? 1 : -1), (e => { if ("number" != typeof e) throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${e}.`); if (e < 0 && -1 !== e) throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`) })), Jw.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD", (() => 128)), Jw.registerFlag("WEBGL_USE_SHAPES_UNIFORMS", (() => !1)), Jw.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD", (() => 1e5)), Jw.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD", (() => 128)), Jw.registerFlag("WEBGL_EXP_CONV", (() => !1)), Jw.registerFlag("SOFTWARE_WEBGL_ENABLED", (() => Jw.getBool("IS_TEST"))), Jw.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE", (() => 1 / 0)), Jw.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE", (() => !1)), Jw.registerFlag("WEBGL2_ISNAN_CUSTOM", (() => !1)), Jw.registerFlag("ENGINE_COMPILE_ONLY", (() => !1)); const ik = "\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n", { getBroadcastDims: ak } = P.backend_util; function ok(e, t, n) { const r = []; if (e.forEach((e => { const t = P.util.sizeFromShape(e.shapeInfo.logicalShape); if (e.shapeInfo.isUniform ? r.push(`uniform float ${e.name}${t > 1 ? `[${t}]` : ""};`) : (r.push(`uniform sampler2D ${e.name};`), r.push(`uniform int offset${e.name};`)), n.enableShapeUniforms) { const { uniformShape: t } = yk(n.packedInputs, e.shapeInfo.logicalShape, e.shapeInfo.texShape); switch (t.length) { case 1: r.push(`uniform int ${e.name}Shape;`); break; case 2: r.push(`uniform ivec2 ${e.name}Shape;`); break; case 3: r.push(`uniform ivec3 ${e.name}Shape;`); break; case 4: r.push(`uniform ivec4 ${e.name}Shape;`) }r.push(`uniform ivec2 ${e.name}TexShape;`) } })), n.enableShapeUniforms) { switch (t.logicalShape.length) { case 1: r.push("uniform int outShape;"); break; case 2: r.push("uniform ivec2 outShape;"), r.push("uniform int outShapeStrides;"); break; case 3: r.push("uniform ivec3 outShape;"), r.push("uniform ivec2 outShapeStrides;"); break; case 4: r.push("uniform ivec4 outShape;"), r.push("uniform ivec3 outShapeStrides;") }r.push("uniform ivec2 outTexShape;") } n.customUniforms && n.customUniforms.forEach((e => { r.push(`uniform ${e.type} ${e.name}${e.arrayIndex ? `[${e.arrayIndex}]` : ""};`) })); const i = r.join("\n"), a = e.map((e => function (e, t, n = !1, r) { let i = ""; i += n ? uk(e, r) : sk(e, r); const a = e.shapeInfo.logicalShape, o = t.logicalShape; a.length <= o.length && (i += n ? function (e, t) { const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, o = t.logicalShape.length, s = ak(e.shapeInfo.logicalShape, t.logicalShape), u = gk(o), l = o - a; let c; const h = ["x", "y", "z", "w", "u", "v"]; c = 0 === a ? "" : o < 2 && s.length >= 1 ? "coords = 0;" : s.map((e => `coords.${h[e + l]} = 0;`)).join("\n"); let d = ""; d = o < 2 && a > 0 ? "coords" : e.shapeInfo.logicalShape.map(((e, t) => `coords.${h[t + l]}`)).join(", "); let f = "return outputValue;"; const p = 1 === P.util.sizeFromShape(e.shapeInfo.logicalShape), m = P.util.sizeFromShape(t.logicalShape), g = 1 === m; if (1 !== a || p || g) { if (p && !g) f = 1 === o ? "\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n " : "\n return vec4(outputValue.x);\n "; else if (s.length) { const e = a - 2, t = a - 1; s.indexOf(e) > -1 && s.indexOf(t) > -1 ? f = "return vec4(outputValue.x);" : s.indexOf(e) > -1 ? f = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : s.indexOf(t) > -1 && (f = "return vec4(outputValue.xx, outputValue.zz);") } } else f = "\n return vec4(outputValue.xy, outputValue.xy);\n "; return `\n vec4 ${i}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${d});\n ${f}\n }\n ` }(e, t) : function (e, t) { const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = t.texShape, o = e.shapeInfo.texShape, s = e.shapeInfo.logicalShape.length, u = t.logicalShape.length; if (!e.shapeInfo.isUniform && s === u && null == e.shapeInfo.flatOffset && P.util.arraysEqual(o, a)) return `\n float ${i}() {\n return sampleTexture(${n}, resultUV);\n }\n `; const l = gk(u), c = ak(e.shapeInfo.logicalShape, t.logicalShape), h = u - s; let d; const f = ["x", "y", "z", "w", "u", "v"]; d = 0 === s ? "" : u < 2 && c.length >= 1 ? "coords = 0;" : c.map((e => `coords.${f[e + h]} = 0;`)).join("\n"); let p = ""; p = u < 2 && s > 0 ? "coords" : e.shapeInfo.logicalShape.map(((e, t) => `coords.${f[t + h]}`)).join(", "); return `\n float ${i}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${p});\n }\n ` }(e, t)); return i }(e, t, n.packedInputs, n.enableShapeUniforms))).join("\n"), o = t.texShape, s = Qw(), u = function (e) { return `\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n ` }(s); let l, c, h = function (e) { const t = `${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${lk}\n ${ck}\n ${hk}\n `; return t }(s); t.isPacked ? (l = function (e, t, n) { switch (e.length) { case 0: return fk(); case 1: return function (e, t, n) { const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)]; if (1 === r[0]) return n ? "\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n " : `\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `; if (1 === r[1]) return n ? "\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n " : `\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `; if (n) return "\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n "; return `\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n ` }(0, t, n); case 2: return function (e, t, n) { const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)]; if (P.util.arraysEqual(e, t)) return n ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n " : `\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `; const i = Math.ceil(e[1] / 2); if (n) return "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n "; return `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec2(r, c);\n }\n ` }(e, t, n); case 3: return function (e, t, n) { if (n) return "\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n "; const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], i = Math.ceil(e[2] / 2), a = i * Math.ceil(e[1] / 2); return `\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${a};\n index -= b * ${a};\n\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec3(b, r, c);\n }\n ` }(e, t, n); default: return function (e, t, n) { if (n) return "\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n "; const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], i = Math.ceil(e[e.length - 1] / 2), a = i * Math.ceil(e[e.length - 2] / 2); let o = a, s = "", u = "b, r, c"; for (let t = 2; t < e.length - 1; t++)o *= e[e.length - t - 1], s = `\n int b${t} = index / ${o};\n index -= b${t} * ${o};\n ` + s, u = `b${t}, ` + u; return `\n ivec${e.length} getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n ${s}\n\n int b = index / ${a};\n index -= b * ${a};\n\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec${e.length}(${u});\n }\n ` }(e, t, n) } }(t.logicalShape, o, n.enableShapeUniforms), c = function (e) { return `\n void setOutput(vec4 val) {\n ${e.output} = val;\n }\n ` }(s)) : (l = function (e, t, n) { switch (e.length) { case 0: return fk(); case 1: return function (e, t, n) { if (1 === t[0]) return n ? "\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n " : `\n int getOutputCoords() {\n return int(resultUV.x * ${t[1]}.0);\n }\n `; if (1 === t[1]) return n ? "\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n " : `\n int getOutputCoords() {\n return int(resultUV.y * ${t[0]}.0);\n }\n `; if (n) return "\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n "; return `\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n return resTexRC.x * ${t[1]} + resTexRC.y;\n }\n ` }(0, t, n); case 2: return function (e, t, n) { if (P.util.arraysEqual(e, t)) return n ? "\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n " : `\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n }\n `; if (1 === e[1]) return n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n " : `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `; if (1 === e[0]) return n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n " : `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `; if (n) return "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n "; return `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n int r = index / ${e[1]};\n int c = index - r * ${e[1]};\n return ivec2(r, c);\n }\n ` }(e, t, n); case 3: return function (e, t, n) { if (n) { return `\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${tk(["r", "c", "d"], e)}\n return ivec3(r, c, d);\n }\n` } const r = ek(["r", "c", "d"], e); return `\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec3(r, c, d);\n }\n ` }(e, t, n); case 4: return function (e, t, n) { if (n) { return `\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${tk(["r", "c", "d", "d2"], e)}\n return ivec4(r, c, d, d2);\n }\n ` } const r = ek(["r", "c", "d", "d2"], e); return `\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec4(r, c, d, d2);\n }\n ` }(e, t, n); case 5: return function (e, t) { const n = ek(["r", "c", "d", "d2", "d3"], e); return `\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n ${t[1]}));\n\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n ` }(e, t); case 6: return function (e, t) { const n = ek(["r", "c", "d", "d2", "d3", "d4"], e); return `\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n ` }(e, t); default: throw new Error(`${e.length}-D output sampling is not yet supported`) } }(t.logicalShape, o, n.enableShapeUniforms), c = function (e) { return `\n void setOutput(float val) {\n ${e.output} = vec4(val, 0, 0, 0);\n }\n ` }(s)), n.packedInputs && (h += dk); return [h, u, c, i, l, a, n.userCode].join("\n") } function sk(e, t = !1) { const n = e.shapeInfo.logicalShape; switch (n.length) { case 0: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1); if (e.shapeInfo.isUniform) return `float ${r}() {return ${n};}`; const [i, a] = e.shapeInfo.texShape; if (1 === i && 1 === a) return `\n float ${r}() {\n return sampleTexture(${n}, halfCR);\n }\n `; const o = pk(n); if (t) return `\n float ${r}() {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${o});\n return sampleTexture(${n}, uv);\n }\n `; const [s, u] = e.shapeInfo.texShape; return `\n float ${r}() {\n vec2 uv = uvFromFlat(${s}, ${u}, ${o});\n return sampleTexture(${n}, uv);\n }\n ` }(e, t); case 1: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1); if (e.shapeInfo.isUniform) return `\n float ${r}(int index) {\n ${mk(e)}\n }\n `; const i = e.shapeInfo.texShape, a = i[0], o = i[1]; if (1 === o && 1 === a) return `\n float ${r}(int index) {\n return sampleTexture(${n}, halfCR);\n }\n `; const s = pk(n); if (1 === o) return t ? `\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${s}) + 0.5) / float(${n}TexShape[0]));\n return sampleTexture(${n}, uv);\n }\n ` : `\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${s}) + 0.5) / ${a}.0);\n return sampleTexture(${n}, uv);\n }\n `; if (1 === a) return t ? `\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${s}) + 0.5) / float(${n}TexShape[1]), 0.5);\n return sampleTexture(${n}, uv);\n }\n ` : `\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${s}) + 0.5) / ${o}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `; if (t) return `\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${s});\n return sampleTexture(${n}, uv);\n }\n `; return `\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${a}, ${o}, index + ${s});\n return sampleTexture(${n}, uv);\n }\n ` }(e, t); case 2: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape; if (null != a && P.util.arraysEqual(n, a)) { if (t) return `\n float ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `; const e = a[0]; return `\n float ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${a[1]}.0, ${e}.0);\n return sampleTexture(${r}, uv);\n }\n ` } const { newShape: o, keptDims: s } = P.util.squeezeShape(n), u = o; if (u.length < n.length) { const n = ["row", "col"]; return `\n ${sk(bk(e, u), t)}\n float ${i}(int row, int col) {\n return ${i}(${vk(n, s)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${i}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));\n ${mk(e)}\n }\n `; const l = a[0], c = a[1], h = pk(r); if (1 === c) return t ? `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);\n return sampleTexture(${r}, uv);\n }\n `; if (1 === l) return t ? `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);\n return sampleTexture(${r}, uv);\n }\n `; if (t) return `\n float ${i}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r}Shape[1] + col + ${h};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `; return `\n float ${i}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${n[1]} + col + ${h};\n vec2 uv = uvFromFlat(${l}, ${c}, index);\n return sampleTexture(${r}, uv);\n }\n` }(e, t); case 3: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = n[1] * n[2], o = n[2], { newShape: s, keptDims: u } = P.util.squeezeShape(n), l = s; if (l.length < n.length) { const n = ["row", "col", "depth"]; return `\n ${sk(bk(e, l), t)}\n float ${i}(int row, int col, int depth) {\n return ${i}(${vk(n, u)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${i}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${a}, ${o}, 1)));\n ${mk(e)}\n }\n `; const c = e.shapeInfo.texShape, h = c[0], d = c[1], f = e.shapeInfo.flatOffset; if (d === a && null == f) return t ? `\n float ${i}(int row, int col, int depth) {\n int stride1 = ${r}Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${o}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `; if (d === o && null == f) return t ? `\n float ${i}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${n[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `; const p = pk(r); if (t) return `\n float ${i}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = ${r}Shape[1] * ${r}Shape[2];\n int stride1 = ${r}Shape[2];\n int index = row * stride0 + col * stride1 + depth + ${p};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `; return `\n float ${i}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${a} + col * ${o} + depth + ${p};\n vec2 uv = uvFromFlat(${h}, ${d}, index);\n return sampleTexture(${r}, uv);\n }\n ` }(e, t); case 4: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = n[3], o = n[2] * a, s = n[1] * o, { newShape: u, keptDims: l } = P.util.squeezeShape(n); if (u.length < n.length) { const n = ["row", "col", "depth", "depth2"]; return `\n ${sk(bk(e, u), t)}\n float ${i}(int row, int col, int depth, int depth2) {\n return ${i}(${vk(n, l)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${i}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${s}, ${o}, ${a}, 1)));\n ${mk(e)}\n }\n `; const c = e.shapeInfo.flatOffset, h = e.shapeInfo.texShape, d = h[0], f = h[1], p = `int stride2 = ${r}Shape[3];`, m = `int stride1 = ${r}Shape[2] * stride2;`, g = `int stride0 = ${r}Shape[1] * stride1;`; if (f === s && null == c) return t ? `\n float ${i}(int row, int col, int depth, int depth2) {\n ${p}\n ${m}\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${o}, ${a}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${r}, uv);\n }\n `; if (f === a && null == c) return t ? `\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${n[1] * n[2]}, ${n[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${r}, uv);\n }\n `; const y = pk(r); if (t) return `\n float ${i}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n ${p}\n ${m}\n ${g}\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${y});\n return sampleTexture(${r}, uv);\n }\n `; return `\n float ${i}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${s} + col * ${o} +\n depth * ${a} + depth2;\n vec2 uv = uvFromFlat(${d}, ${f}, index + ${y});\n return sampleTexture(${r}, uv);\n }\n ` }(e, t); case 5: return function (e) { const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = t[4], a = t[3] * i, o = t[2] * a, s = t[1] * o, { newShape: u, keptDims: l } = P.util.squeezeShape(t); if (u.length < t.length) { const t = ["row", "col", "depth", "depth2", "depth3"]; return `\n ${sk(bk(e, u))}\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n return ${r}(${vk(t, l)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${s}, ${o}, ${a}, ${i})) +\n depth3;\n ${mk(e)}\n }\n `; const c = e.shapeInfo.flatOffset, h = e.shapeInfo.texShape, d = h[0], f = h[1]; if (f === s && null == c) return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${o}, ${a}, ${i}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `; if (f === i && null == c) return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4(${t[1] * t[2] * t[3]},\n ${t[2] * t[3]}, ${t[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `; const p = pk(n); return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${s} + col * ${o} + depth * ${a} +\n depth2 * ${i} + depth3 + ${p};\n vec2 uv = uvFromFlat(${d}, ${f}, index);\n return sampleTexture(${n}, uv);\n }\n ` }(e); case 6: return function (e) { const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: i, keptDims: a } = P.util.squeezeShape(t); if (i.length < t.length) { const t = ["row", "col", "depth", "depth2", "depth3", "depth4"]; return `\n ${sk(bk(e, i))}\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${r}(${vk(t, a)});\n }\n ` } const o = t[5], s = t[4] * o, u = t[3] * s, l = t[2] * u, c = t[1] * l; if (e.shapeInfo.isUniform) return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${c}, ${l}, ${u}, ${s})) +\n dot(\n vec2(depth3, depth4),\n vec2(${o}, 1)));\n ${mk(e)}\n }\n `; const h = e.shapeInfo.flatOffset, d = e.shapeInfo.texShape, f = d[0], p = d[1]; if (p === c && null == h) return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${l}, ${u}, ${s}, ${o})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${f}.0);\n return sampleTexture(${n}, uv);\n }\n `; if (p === o && null == h) return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${t[1] * t[2] * t[3] * t[4]},\n ${t[2] * t[3] * t[4]},\n ${t[3] * t[4]},\n ${t[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${f}.0);\n return sampleTexture(${n}, uv);\n }\n `; const m = pk(n); return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${c} + col * ${l} + depth * ${u} +\n depth2 * ${s} + depth3 * ${o} + depth4 + ${m};\n vec2 uv = uvFromFlat(${f}, ${p}, index);\n return sampleTexture(${n}, uv);\n }\n ` }(e); default: throw new Error(`${n.length}-D input sampling is not yet supported`) } } function uk(e, t) { switch (e.shapeInfo.logicalShape.length) { case 0: return function (e) { const t = e.name, n = "get" + t.charAt(0).toUpperCase() + t.slice(1), r = Qw(); return `\n vec4 ${n}() {\n return ${r.texture2D}(${t}, halfCR);\n }\n ` }(e); case 1: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = e.shapeInfo.texShape, a = Qw(); if (t) return `\n vec4 ${r}(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ${a.texture2D}(${n}, uv);\n }\n `; const o = [Math.ceil(i[0] / 2), Math.ceil(i[1] / 2)]; return `\n vec4 ${r}(int index) {\n vec2 uv = packedUVfrom1D(\n ${o[0]}, ${o[1]}, index);\n return ${a.texture2D}(${n}, uv);\n }\n ` }(e, t); case 2: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, o = a[0], s = a[1], u = Qw(); if (null != a && P.util.arraysEqual(n, a)) return t ? `\n vec4 ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n\n return ${u.texture2D}(${r}, uv);\n }\n ` : `\n vec4 ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}.0, ${o}.0);\n\n return ${u.texture2D}(${r}, uv);\n }\n `; if (t) return `\n vec4 ${i}(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return ${u.texture2D}(${r}, uv);\n }\n `; const l = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)], c = Math.ceil(n[1] / 2); return `\n vec4 ${i}(int row, int col) {\n vec2 uv = packedUVfrom2D(${c}, ${l[0]}, ${l[1]}, row, col);\n return ${u.texture2D}(${r}, uv);\n }\n ` }(e, t); case 3: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, o = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)]; if (1 === n[0]) { const r = [1, 2], a = ["b", "row", "col"]; return `\n ${uk(bk(e, n.slice(1)), t)}\n vec4 ${i}(int b, int row, int col) {\n return ${i}(${vk(a, r)});\n }\n ` } const s = Qw(); if (t) return `\n vec4 ${i}(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ${s.texture2D}(${r}, uv);\n }\n `; const u = o[0], l = o[1], c = Math.ceil(n[2] / 2), h = c * Math.ceil(n[1] / 2); return `\n vec4 ${i}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${u}, ${l}, ${h}, ${c}, b, row, col);\n return ${s.texture2D}(${r}, uv);\n }\n ` }(e, t); default: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = Qw(); if (t) return `\n vec4 ${r}(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ${n}Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${i.texture2D}(${n}, uv);\n }\n `; const a = e.shapeInfo.logicalShape, o = a.length, s = e.shapeInfo.texShape, u = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)], l = u[0], c = u[1], h = Math.ceil(a[o - 1] / 2); let d = h * Math.ceil(a[o - 2] / 2), f = "int b, int row, int col", p = `b * ${d} + (row / 2) * ${h} + (col / 2)`; for (let e = 2; e < o - 1; e++)f = `int b${e}, ` + f, d *= a[o - e - 1], p = `b${e} * ${d} + ` + p; return `\n vec4 ${r}(${f}) {\n int index = ${p};\n int texR = index / ${c};\n int texC = index - texR * ${c};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${l});\n return ${i.texture2D}(${n}, uv);\n }\n ` }(e, t) } } const lk = "\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", ck = "\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", hk = "\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", dk = "\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n"; function fk() { return "\n int getOutputCoords() {\n return 0;\n }\n " } function pk(e) { return `offset${e}` } function mk(e) { const t = e.name, n = P.util.sizeFromShape(e.shapeInfo.logicalShape); return n < 2 ? `return ${t};` : `\n for (int i = 0; i < ${n}; i++) {\n if (i == index) {\n return ${t}[i];\n }\n }\n ` } function gk(e) { if (e <= 1) return "int"; if (2 === e) return "ivec2"; if (3 === e) return "ivec3"; if (4 === e) return "ivec4"; if (5 === e) return "ivec5"; if (6 === e) return "ivec6"; throw Error(`GPU for rank ${e} is not yet supported`) } function yk(e, t, n) { const { newShape: r, keptDims: i } = P.util.squeezeShape(t), a = t.length, o = e && 3 === a && 1 === t[0], s = o ? t.slice(1) : r, u = !e && a > 1 && !P.util.arraysEqual(t, n) && r.length < a || o; return { useSqueezeShape: u, uniformShape: u ? s : t, keptDims: i } } function bk(e, t) { const n = JSON.parse(JSON.stringify(e)); return n.shapeInfo.logicalShape = t, n } function vk(e, t) { return t.map((t => e[t])).join(", ") } function xk(e, t, n) { const r = [], i = []; let a, o, s, u = null, l = null; l = e.getUniformLocation(n, "NAN", !1), 1 === (0, P.env)().getNumber("WEBGL_VERSION") && (u = e.getUniformLocation(n, "INFINITY", !1)); const c = !1; for (const i of t.variableNames) { const a = { name: i, uniform: e.getUniformLocation(n, i, c), offset: e.getUniformLocation(n, `offset${i}`, c) }; t.enableShapeUniforms && (a.shape = e.getUniformLocation(n, `${i}Shape`, c), a.texShape = e.getUniformLocation(n, `${i}TexShape`, c)), r.push(a) } if (t.enableShapeUniforms && (a = e.getUniformLocation(n, "outShape", c), s = e.getUniformLocation(n, "outShapeStrides", c), o = e.getUniformLocation(n, "outTexShape", c)), t.customUniforms) for (const r of t.customUniforms) i.push(e.getUniformLocation(n, r.name, c)); return { variablesLocations: r, customUniformLocations: i, infLoc: u, nanLoc: l, outShapeLocation: a, outShapeStridesLocation: s, outTexShapeLocation: o } } function wk(e, t) { if (e.length !== t.length) throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`); e.forEach(((e, n) => { const r = e.logicalShape, i = t[n], a = i.shape; if (!P.util.arraysEqual(r, a)) throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${a} must match`); if (e.isUniform && i.isUniform) return; const o = e.texShape, s = i.isUniform ? null : i.texData.texShape; if (!P.util.arraysEqual(o, s)) throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${s} must match`) })) } function kk(e) { return (0, P.env)().getBool("WEBGL_USE_SHAPES_UNIFORMS") && e <= 4 } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Sk { constructor(e) { this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.outPackingScheme = Vx.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const t = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms ? tk(["r", "c", "d"], e) : ek(["r", "c", "d"], e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class _k { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outPackingScheme = Vx.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const t = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms ? tk(["r", "c", "d"], e) : ek(["r", "c", "d"], e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Ck { constructor(e) { this.variableNames = ["A"], this.outTexUsage = Hx.DOWNLOAD; const t = Qw(); this.outputShape = e, this.userCode = `\n ${ik}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Ak { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !1, this.outTexUsage = Hx.DOWNLOAD; const t = Qw(); this.outputShape = e, this.userCode = `\n ${ik}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Tk = { R: 0, G: 1, B: 2, A: 3 }; class Ek { constructor(e, t = !1, n = "RGBA") { this.variableNames = ["A"], this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const r = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); let i = "result"; t && (i = "floor(result * 255. + 0.5)"); let a = ""; for (let e = 0; e < n.length; e++) { const t = n[e]; a += `\n if(offset == ${e}) {\n result = values[${Tk[t]}];\n }` } this.userCode = `\n ${this.enableShapeUniforms ? "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n" : rk(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n int flatIndex = getFlatIndex(coords);\n float result = 0.;\n int offset = imod(flatIndex, ${n.length});\n\n flatIndex = idiv(flatIndex, ${n.length}, 1.);\n\n int r = flatIndex / texShape[1];\n if (r < texShape[0]) {\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${r.texture2D}(A, uv);\n ${a}\n }\n ${r.output} = vec4(${i}, 0., 0., 0.);\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Nk { constructor(e, t = !1) { this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const n = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); let r = "", i = "result"; t && (i = "floor(result * 255. + 0.5)"); for (let t = 0; t <= 1; t++)for (let i = 0; i <= 1; i++) { const a = 2 * t + i; r += `\n localCoords = coords;\n if(localCoords[2] + ${i} < ${this.enableShapeUniforms ? "outShape[2]" : `${e[2]}`}) {\n localCoords[2] += ${i};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms ? "outShape[1]" : `${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${a}] = values[0];\n } else if (offset == 1) {\n result[${a}] = values[1];\n } else if (offset == 2) {\n result[${a}] = values[2];\n } else {\n result[${a}] = values[3];\n }\n }\n }\n ` } this.userCode = `\n ${this.enableShapeUniforms ? "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n" : rk(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${i};\n }\n ` } } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Ik(e) { const t = Qw(); return ow(e, `${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`) } function Mk(e) { return fw(e, new Float32Array([-1, 1, 0, 0, 1, -1, -1, 0, 0, 0, 1, 1, 0, 1, 1, 1, -1, 0, 1, 0])) } function Fk(e) { return pw(e, new Uint16Array([0, 1, 2, 2, 1, 3])) } function Dk(e, t, n, r, i, a) { yw(t, n); const o = gw(e), s = e.TEXTURE_2D; return ew(e, (() => e.bindTexture(s, o))), ew(e, (() => e.texParameteri(s, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE))), ew(e, (() => e.texParameteri(s, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE))), ew(e, (() => e.texParameteri(s, e.TEXTURE_MIN_FILTER, e.NEAREST))), ew(e, (() => e.texParameteri(s, e.TEXTURE_MAG_FILTER, e.NEAREST))), 1 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texImage2D(s, 0, r, t, n, 0, i, a, null))) : ew(e, (() => e.texStorage2D(s, 1, r, t, n))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))), { texture: o, texShape: [n, t] } } function $k(e) { return e.internalFormatFloat } function Rk(e, t, n, r) { const [i, a] = Kx(t, n); return Dk(e, i, a, $k(r), r.textureFormatFloat, e.FLOAT) } function Ok(e) { return e.internalFormatHalfFloat } function zk(e, t, n, r) { const [i, a] = Kx(t, n); return Dk(e, i, a, Ok(r), r.textureFormatFloat, r.textureTypeHalfFloat) } function Pk(e) { return e.downloadTextureFormat } function Bk(e, t, n, r) { const [i, a] = Kx(t, n); return Dk(e, i, a, Pk(r), e.RGBA, e.UNSIGNED_BYTE) } function Lk(e) { return e.internalFormatPackedFloat } function jk(e, t, n, r) { const [i, a] = Jx(t, n); return Dk(e, i, a, Lk(r), e.RGBA, e.FLOAT) } function Uk(e) { return e.internalFormatPackedHalfFloat } function Wk(e, t, n, r) { const [i, a] = Jx(t, n); return Dk(e, i, a, Uk(r), e.RGBA, r.textureTypeHalfFloat) } function Vk(e, t, n) { ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, n))); return vw(e, t, "clipSpacePos", n, 3, 20, 0) && vw(e, t, "uv", n, 2, 20, 12) } function Gk(e, t, n, r, i, a) { let o, s, u; ew(e, (() => e.bindTexture(e.TEXTURE_2D, t))), i instanceof Uint8Array ? (o = new Uint8Array(n * r * 4), s = e.UNSIGNED_BYTE, u = e.RGBA) : (o = new Float32Array(n * r * 4), s = e.FLOAT, u = a.internalFormatPackedFloat), o.set(i), 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, n, r, e.RGBA, s, o))) : ew(e, (() => e.texImage2D(e.TEXTURE_2D, 0, u, n, r, 0, e.RGBA, s, o))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))) } function Hk(e, t, n) { ew(e, (() => e.bindTexture(e.TEXTURE_2D, t))), n.data instanceof Uint8Array ? 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, n.width, n.height, e.RGBA, e.UNSIGNED_BYTE, n.data))) : ew(e, (() => e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, n.width, n.height, 0, e.RGBA, e.UNSIGNED_BYTE, n.data))) : 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, e.RGBA, e.UNSIGNED_BYTE, n))) : ew(e, (() => e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, n))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))) } function qk(e, t, n, r) { const i = e.createBuffer(); ew(e, (() => e.bindBuffer(e.PIXEL_PACK_BUFFER, i))); const a = 16 * t * n; return ew(e, (() => e.bufferData(e.PIXEL_PACK_BUFFER, a, e.STREAM_READ))), ew(e, (() => e.readPixels(0, 0, n, t, e.RGBA, e.FLOAT, 0))), ew(e, (() => e.bindBuffer(e.PIXEL_PACK_BUFFER, null))), i } function Yk(e, t, n) { const r = e, i = new Float32Array(n); return r.bindBuffer(r.PIXEL_PACK_BUFFER, t), r.getBufferSubData(r.PIXEL_PACK_BUFFER, 0, i), r.bindBuffer(r.PIXEL_PACK_BUFFER, null), i } function Xk(e, t, n, r) { const [i, a] = Kx(t, n), o = new Uint8Array(t * n * 4); return ew(e, (() => e.readPixels(0, 0, i, a, r.downloadTextureFormat, e.UNSIGNED_BYTE, o))), new Float32Array(o.buffer) } function Kk(e, t, n, r, i, a, o, s) { const u = e, l = new Float32Array(function (e, t) { const [n, r] = Jx(e, t); return n * r * 4 }(a, o)); return u.bindBuffer(u.PIXEL_PACK_BUFFER, t), u.getBufferSubData(u.PIXEL_PACK_BUFFER, 0, l), u.bindBuffer(u.PIXEL_PACK_BUFFER, null), l } function Zk(e, t, n) { const r = new Float32Array(t * n * 4); return ew(e, (() => e.readPixels(0, 0, n, t, e.RGBA, e.FLOAT, r))), r } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Jk { constructor(e) { this.outputTexture = null, this.program = null, this.disposed = !1, this.itemsToPoll = []; const t = (0, P.env)().getNumber("WEBGL_VERSION"); if (null != e ? (this.gl = e, Ux(t, e)) : this.gl = Wx(t), e = this.gl, 2 === (0, P.env)().getNumber("WEBGL_VERSION")) { const t = e; this.createVertexArray = () => ew(t, (() => t.createVertexArray())), this.bindVertexArray = e => ew(t, (() => t.bindVertexArray(e))), this.deleteVertexArray = e => ew(t, (() => t.deleteVertexArray(e))), this.getVertexArray = () => ew(t, (() => t.getParameter(t.VERTEX_ARRAY_BINDING))) } else if (null != e) { const t = e.getExtension("OES_vertex_array_object"); if (null == t) throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object."); this.createVertexArray = () => ew(e, (() => t.createVertexArrayOES())), this.bindVertexArray = n => ew(e, (() => t.bindVertexArrayOES(n))), this.deleteVertexArray = n => ew(e, (() => t.deleteVertexArrayOES(n))), this.getVertexArray = () => ew(e, (() => e.getParameter(t.VERTEX_ARRAY_BINDING_OES))) } let n = "WEBGL_color_buffer_float"; const r = "EXT_color_buffer_half_float"; if (this.parallelCompilationExtension = this.gl.getExtension("KHR_parallel_shader_compile"), 1 === (0, P.env)().getNumber("WEBGL_VERSION")) { const e = "OES_texture_float", t = "OES_texture_half_float"; if (this.textureFloatExtension = aw(this.gl, e), Gw(this.gl, t)) this.textureHalfFloatExtension = aw(this.gl, t); else if ((0, P.env)().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true."); if (this.colorBufferFloatExtension = this.gl.getExtension(n), Gw(this.gl, r)) this.colorBufferHalfFloatExtension = aw(this.gl, r); else if ((0, P.env)().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.") } else if (n = "EXT_color_buffer_float", Gw(this.gl, n)) this.colorBufferFloatExtension = this.gl.getExtension(n); else { if (!Gw(this.gl, r)) throw new Error("GL context does not support color renderable floats"); this.colorBufferHalfFloatExtension = this.gl.getExtension(r) } this.vertexBuffer = Mk(this.gl), this.indexBuffer = Fk(this.gl), this.framebuffer = bw(this.gl), this.textureConfig = Qx(this.gl, this.textureHalfFloatExtension) } get debug() { return (0, P.env)().getBool("DEBUG") } dispose() { if (this.disposed) return; null != this.program && console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."), null != this.outputTexture && console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing."); const e = this.gl; ew(e, (() => e.finish())), ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, null))), ew(e, (() => e.deleteFramebuffer(this.framebuffer))), ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, null))), ew(e, (() => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null))), ew(e, (() => e.deleteBuffer(this.indexBuffer))), this.disposed = !0 } createFloat32MatrixTexture(e, t) { return this.throwIfDisposed(), Rk(this.gl, e, t, this.textureConfig) } createFloat16MatrixTexture(e, t) { return this.throwIfDisposed(), zk(this.gl, e, t, this.textureConfig) } createUnsignedBytesMatrixTexture(e, t) { return this.throwIfDisposed(), Bk(this.gl, e, t, this.textureConfig) } uploadPixelDataToTexture(e, t) { this.throwIfDisposed(), Hk(this.gl, e, t) } uploadDenseMatrixToTexture(e, t, n, r) { this.throwIfDisposed(), Gk(this.gl, e, t, n, r, this.textureConfig) } createFloat16PackedMatrixTexture(e, t) { return this.throwIfDisposed(), Wk(this.gl, e, t, this.textureConfig) } createPackedMatrixTexture(e, t) { return this.throwIfDisposed(), jk(this.gl, e, t, this.textureConfig) } deleteMatrixTexture(e) { this.throwIfDisposed(), this.outputTexture === e && (Tw(this.gl, this.framebuffer), this.outputTexture = null), ew(this.gl, (() => this.gl.deleteTexture(e))) } downloadByteEncodedFloatMatrixFromOutputTexture(e, t, n) { return this.downloadMatrixDriver(e, (() => Xk(this.gl, t, n, this.textureConfig))) } downloadPackedMatrixFromBuffer(e, t, n, r, i, a) { return Kk(this.gl, e, 0, 0, 0, i, a, this.textureConfig) } downloadFloat32MatrixFromBuffer(e, t) { return Yk(this.gl, e, t) } createBufferFromTexture(e, t, n) { this.bindTextureToFrameBuffer(e); const r = qk(this.gl, t, n, this.textureConfig); return this.unbindTextureToFrameBuffer(), r } createAndWaitForFence() { const e = this.createFence(this.gl); return this.pollFence(e) } createFence(e) { let t, n; if ((0, P.env)().getBool("WEBGL_FENCE_API_ENABLED")) { const r = e, i = r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE, 0); e.flush(), n = () => { const e = r.clientWaitSync(i, 0, 0); return e === r.ALREADY_SIGNALED || e === r.CONDITION_SATISFIED }, t = i } else (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 ? (t = this.beginQuery(), this.endQuery(), n = () => this.isQueryAvailable(t, (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))) : n = () => !0; return { query: t, isFencePassed: n } } downloadMatrixFromPackedTexture(e, t, n) { return this.downloadMatrixDriver(e, (() => Zk(this.gl, t, n))) } createProgram(e) { this.throwIfDisposed(); const t = this.gl; null == this.vertexShader && (this.vertexShader = Ik(t)); const n = cw(t); ew(t, (() => t.attachShader(n, this.vertexShader))), ew(t, (() => t.attachShader(n, e))), hw(t, n); const r = Object.assign(n, { vao: this.createVertexArray() }); return this.debug && dw(t, r), r } buildVao(e) { this.setProgram(e), this.bindVertexArray(e.vao); const t = this.gl; ew(t, (() => t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer))), Vk(t, e, this.vertexBuffer) } deleteProgram(e) { this.throwIfDisposed(), e === this.program && (this.program = null), null != e && (ew(this.gl, (() => this.gl.deleteProgram(e))), this.deleteVertexArray(e.vao)) } setProgram(e) { this.throwIfDisposed(), this.program = e, null != this.program && this.debug && dw(this.gl, this.program), ew(this.gl, (() => this.gl.useProgram(e))) } getUniformLocation(e, t, n = !0) { return this.throwIfDisposed(), n ? kw(this.gl, e, t) : Sw(this.gl, e, t) } getAttributeLocation(e, t) { return this.throwIfDisposed(), ew(this.gl, (() => this.gl.getAttribLocation(e, t))) } getUniformLocationNoThrow(e, t) { return this.throwIfDisposed(), this.gl.getUniformLocation(e, t) } setInputMatrixTexture(e, t, n) { this.throwIfDisposed(), this.throwIfNoProgram(), _w(this.gl, e, t, n) } setOutputMatrixTexture(e, t, n) { this.setOutputMatrixTextureDriver(e, n, t) } setOutputPackedMatrixTexture(e, t, n) { this.throwIfDisposed(); const [r, i] = Jx(t, n); this.setOutputMatrixTextureDriver(e, r, i) } setOutputMatrixWriteRegion(e, t, n, r) { this.setOutputMatrixWriteRegionDriver(n, e, r, t) } setOutputPackedMatrixWriteRegion(e, t, n, r) { throw new Error("setOutputPackedMatrixWriteRegion not implemented.") } debugValidate() { null != this.program && dw(this.gl, this.program), Ew(this.gl) } executeProgram() { this.throwIfDisposed(), this.throwIfNoProgram(); const e = this.gl; if (this.debug) { const e = this.getVertexArray(); console.assert(e === this.program.vao, "VAO changed between setProgram and executeProgram!"), this.debugValidate() } ew(e, (() => e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0))) } blockUntilAllProgramsCompleted() { this.throwIfDisposed(), ew(this.gl, (() => this.gl.finish())) } getQueryTimerExtension() { return null == this.disjointQueryTimerExtension && (this.disjointQueryTimerExtension = aw(this.gl, 2 === (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension } getQueryTimerExtensionWebGL2() { return this.getQueryTimerExtension() } getQueryTimerExtensionWebGL1() { return this.getQueryTimerExtension() } beginQuery() { if (2 === (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) { const e = this.gl, t = this.getQueryTimerExtensionWebGL2(), n = e.createQuery(); return e.beginQuery(t.TIME_ELAPSED_EXT, n), n } const e = this.getQueryTimerExtensionWebGL1(), t = e.createQueryEXT(); return e.beginQueryEXT(e.TIME_ELAPSED_EXT, t), t } endQuery() { if (2 === (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) { const e = this.gl, t = this.getQueryTimerExtensionWebGL2(); return void e.endQuery(t.TIME_ELAPSED_EXT) } const e = this.getQueryTimerExtensionWebGL1(); e.endQueryEXT(e.TIME_ELAPSED_EXT) } async waitForQueryAndGetTime(e) { return await P.util.repeatedTry((() => this.disposed || this.isQueryAvailable(e, (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))), this.getQueryTime(e, (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) } getQueryTime(e, t) { if (0 === t) return null; if (2 === t) { const t = this.gl; return t.getQueryParameter(e, t.QUERY_RESULT) / 1e6 } { const t = this.getQueryTimerExtensionWebGL1(); return t.getQueryObjectEXT(e, t.QUERY_RESULT_EXT) / 1e6 } } isQueryAvailable(e, t) { if (0 === t) return !0; if (2 === t) { const t = this.gl, n = this.getQueryTimerExtensionWebGL2(), r = t.getQueryParameter(e, t.QUERY_RESULT_AVAILABLE); return null == this.disjoint && (this.disjoint = this.gl.getParameter(n.GPU_DISJOINT_EXT)), r && !this.disjoint } { const t = this.getQueryTimerExtensionWebGL1(), n = t.getQueryObjectEXT(e, t.QUERY_RESULT_AVAILABLE_EXT); return null == this.disjoint && (this.disjoint = this.gl.getParameter(t.GPU_DISJOINT_EXT)), n && !this.disjoint } } pollFence(e) { return new Promise((t => { this.addItemToPoll((() => e.isFencePassed()), (() => t())) })) } pollItems() { const e = function (e) { let t = 0; for (; t < e.length; ++t) { if (!e[t]()) break } return t - 1 }(this.itemsToPoll.map((e => e.isDoneFn))); for (let t = 0; t <= e; ++t) { const { resolveFn: e } = this.itemsToPoll[t]; e() } this.itemsToPoll = this.itemsToPoll.slice(e + 1) } addItemToPoll(e, t) { if (this.itemsToPoll.push({ isDoneFn: e, resolveFn: t }), this.itemsToPoll.length > 1) return; let n; "setTimeoutCustom" in (0, P.env)().platform && (n = (0, P.env)().platform.setTimeoutCustom.bind((0, P.env)().platform)), P.util.repeatedTry((() => (this.pollItems(), 0 === this.itemsToPoll.length)), (() => 0), null, n) } bindTextureToFrameBuffer(e) { this.throwIfDisposed(), Aw(this.gl, e, this.framebuffer), this.debug && Ew(this.gl) } unbindTextureToFrameBuffer() { null != this.outputTexture ? (Aw(this.gl, this.outputTexture, this.framebuffer), this.debug && Ew(this.gl)) : Tw(this.gl, this.framebuffer) } downloadMatrixDriver(e, t) { this.bindTextureToFrameBuffer(e); const n = t(); return this.unbindTextureToFrameBuffer(), n } setOutputMatrixTextureDriver(e, t, n) { this.throwIfDisposed(); const r = this.gl; Aw(r, e, this.framebuffer), this.debug && Ew(r), this.outputTexture = e, ew(r, (() => r.viewport(0, 0, t, n))), ew(r, (() => r.scissor(0, 0, t, n))) } setOutputMatrixWriteRegionDriver(e, t, n, r) { this.throwIfDisposed(), ew(this.gl, (() => this.gl.scissor(e, t, n, r))) } throwIfDisposed() { if (this.disposed) throw new Error("Attempted to use disposed GPGPUContext.") } throwIfNoProgram() { if (null == this.program) throw new Error("No GPU program is currently set.") } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const { addImpl: Qk, bincountImpl: eS, bincountReduceImpl: tS, bitwiseAndImpl: nS, castImpl: rS, ceilImpl: iS, concatImpl: aS, equalImpl: oS, expImpl: sS, expm1Impl: uS, floorImpl: lS, gatherNdImpl: cS, gatherV2Impl: hS, greaterImpl: dS, greaterEqualImpl: fS, lessImpl: pS, lessEqualImpl: mS, linSpaceImpl: gS, logImpl: yS, maxImpl: bS, maximumImpl: vS, minimumImpl: xS, multiplyImpl: wS, negImpl: kS, notEqualImpl: SS, prodImpl: _S, raggedGatherImpl: CS, raggedRangeImpl: AS, raggedTensorToTensorImpl: TS, rangeImpl: ES, rsqrtImpl: NS, scatterImpl: IS, sigmoidImpl: MS, simpleAbsImpl: FS, sliceImpl: DS, sparseFillEmptyRowsImpl: $S, sparseReshapeImpl: RS, sparseSegmentReductionImpl: OS, sqrtImpl: zS, staticRegexReplaceImpl: PS, stridedSliceImpl: BS, stringNGramsImpl: LS, stringSplitImpl: jS, stringToHashBucketFastImpl: US, subImpl: WS, tileImpl: VS, topKImpl: GS, transposeImpl: HS, uniqueImpl: qS } = N; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function YS(e, t) { return ["x", "y", "z", "w", "u", "v"].slice(0, t).map((t => `${e}.${t}`)) } function XS(e, t) { return 1 === t ? [e] : YS(e, t) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class KS { constructor(e) { if (this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.outputShape = e, this.rank = e.length, this.enableShapeUniforms = kk(this.outputShape.length), 0 === this.rank) this.userCode = "\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n "; else { const e = XS("rc", this.rank), t = gk(this.rank), n = this.getOutOfBoundsCondition(e), r = this.getSetup(e), i = this.getOutput(e); this.userCode = `\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${i}));\n }\n }\n ` } } getSourceCoordsArr(e) { const t = []; for (let n = 0; n <= 1; n++)for (let r = 0; r <= 1; r++) { let i = `${0 === n ? "r" : "rp1"}, ${0 === r ? "c" : "cp1"}`; for (let t = 2; t < this.rank; t++)i = `${e[e.length - 1 - t]},` + i; t.push(i) } return t } getOutOfBoundsCondition(e) { if (1 === this.rank) return `rc > ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]}`; let t = ""; for (let n = this.rank - 2; n < this.rank; n++)t += `${e[n]} >= ${this.enableShapeUniforms ? `outShape[${n}]` : this.outputShape[n]}`, n < this.rank - 1 && (t += "||"); return t } getSetup(e) { if (1 === this.rank) return ""; const t = e.slice(-2), n = this.enableShapeUniforms ? `outShape[${this.rank} - 1]` : this.outputShape[this.rank - 1], r = this.enableShapeUniforms ? `outShape[${this.rank} - 2]` : this.outputShape[this.rank - 2]; return `\n int r = ${t[0]};\n int c = ${t[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${n};\n bool rEdge = rp1 >= ${r};\n ` } getOutput(e) { const t = this.getSourceCoordsArr(e); if (1 === this.rank) { return `getA(rc), (rc + 1 >= ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0` } return `getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ZS { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); let n = ""; for (let e = 0; e < 4; e++) { let t = "thisRC = rc;"; e % 2 == 1 && (t += "thisRC.z += 1;"), e > 1 && (t += "thisRC.y += 1;"), n += `\n ${t}\n ${e > 0 ? "if(thisRC.y < rows && thisRC.z < cols){" : ""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e > 0 ? "}" : ""}\n ` } var r, i; this.userCode = `\n ${r = t, i = this.enableShapeUniforms, `\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${i ? nk(["r", "c", "d"], "inputShape") : ek(["r", "c", "d"], r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms ? "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n" : rk(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms ? "outShape[1]" : e[1]};\n int cols = ${this.enableShapeUniforms ? "outShape[2]" : e[2]};\n\n ${n}\n\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class JS { constructor(e) { this.gpgpu = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0, this.freeTextures = {}, this.usedTextures = {}, this.logEnabled = !1 } acquireTexture(e, t, n) { const r = e_(t, n), i = t_(e, r, n); i in this.freeTextures || (this.freeTextures[i] = []), i in this.usedTextures || (this.usedTextures[i] = []); const a = QS(e, r, this.gpgpu.gl, this.gpgpu.textureConfig, n); if (this.freeTextures[i].length > 0) { this.numFreeTextures--, this.numUsedTextures++, this._numBytesFree -= a, this.log(); const e = this.freeTextures[i].pop(); return this.usedTextures[i].push(e), e } let o; return r === Yx.PACKED_2X2_FLOAT32 ? o = this.gpgpu.createPackedMatrixTexture(e[0], e[1]) : r === Yx.PACKED_2X2_FLOAT16 ? o = this.gpgpu.createFloat16PackedMatrixTexture(e[0], e[1]) : r === Yx.UNPACKED_FLOAT32 ? o = this.gpgpu.createFloat32MatrixTexture(e[0], e[1]) : r === Yx.UNPACKED_FLOAT16 ? o = this.gpgpu.createFloat16MatrixTexture(e[0], e[1]) : r === Yx.PACKED_4X1_UNSIGNED_BYTE && (o = this.gpgpu.createUnsignedBytesMatrixTexture(e[0], e[1])), this.usedTextures[i].push(o), this.numUsedTextures++, this._numBytesAllocated += a, this.log(), o } releaseTexture(e, t, n, r) { if (null == this.freeTextures) return; const i = e_(n, r), a = t_(t, i, r); a in this.freeTextures || (this.freeTextures[a] = []); const o = QS(t, i, this.gpgpu.gl, this.gpgpu.textureConfig, r), s = (0, P.env)().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD"); -1 !== s && this._numBytesAllocated > s ? (this.gpgpu.deleteMatrixTexture(e.texture), this._numBytesAllocated -= o) : (this.freeTextures[a].push(e), this.numFreeTextures++, this._numBytesFree += o), this.numUsedTextures--; const u = this.usedTextures[a], l = u && u.indexOf(e); if (null == l || l < 0) throw new Error("Cannot release a texture that was never provided by this texture manager"); u[l] = u[u.length - 1], u.pop(), this.log() } log() { if (!this.logEnabled) return; const e = this.numFreeTextures + this.numUsedTextures; console.log("Free/Used", `${this.numFreeTextures} / ${this.numUsedTextures}`, `(${e})`); const t = this._numBytesFree / this._numBytesAllocated; console.log(`Bytes allocated: ${this._numBytesAllocated}`), console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100 * t)}%)`) } get numBytesAllocated() { return this._numBytesAllocated } get numBytesFree() { return this._numBytesFree } getNumUsedTextures() { return this.numUsedTextures } getNumFreeTextures() { return this.numFreeTextures } dispose() { if (null != this.freeTextures) { for (const e in this.freeTextures) this.freeTextures[e].forEach((e => { this.gpgpu.deleteMatrixTexture(e.texture) })); for (const e in this.usedTextures) this.usedTextures[e].forEach((e => { this.gpgpu.deleteMatrixTexture(e.texture) })); this.freeTextures = null, this.usedTextures = null, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0 } } } function QS(e, t, n, r, i) { const a = function (e, t) { switch (e) { case Yx.PACKED_2X2_FLOAT32: return Lk(t); case Yx.PACKED_2X2_FLOAT16: return Uk(t); case Yx.UNPACKED_FLOAT32: return $k(t); case Yx.UNPACKED_FLOAT16: return Ok(t); case Yx.PACKED_4X1_UNSIGNED_BYTE: return Pk(t); default: throw new Error(`Unknown physical texture type ${e}`) } }(t, r); let o; if (i) { const [t, n] = Jx(e[0], e[1]); o = t * n } else { const [t, n] = Kx(e[0], e[1]); o = t * n } const s = function (e, t) { const n = e; if (t === n.R32F) return 4; if (t === n.R16F) return 2; if (t === n.RGBA32F) return 16; if (t === e.RGBA) return 16; if (t === n.RGBA16F) return 8; if (t === n.RGBA8) return 4; throw new Error(`Unknown internal format ${t}`) }(n, a); return o * s } function e_(e, t) { if (e === Hx.UPLOAD) return Yx.PACKED_2X2_FLOAT32; if (e === Hx.RENDER || null == e) return function (e) { return (0, P.env)().getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? e ? Yx.PACKED_2X2_FLOAT32 : Yx.UNPACKED_FLOAT32 : e ? Yx.PACKED_2X2_FLOAT16 : Yx.UNPACKED_FLOAT16 }(t); if (e === Hx.DOWNLOAD || e === Hx.PIXELS) return Yx.PACKED_4X1_UNSIGNED_BYTE; throw new Error(`Unknown logical texture type ${e}`) } function t_(e, t, n) { return `${e[0]}_${e[1]}_${t}_${n}` } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class n_ { constructor(e, t) { this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n ` } } const r_ = "if (isnan(x)) return x;", i_ = "return abs(x);"; const a_ = r_ + "\n return (x < 0.0) ? 0.0 : x;\n", o_ = r_ + "\n return (x < 0.0) ? 0.0 : min(6.0, x);\n", s_ = "return x;"; class u_ { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class l_ { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !1, this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); const t = e.length, n = XS("rc", t), r = gk(t), i = function (e, t) { if (1 === e) return "rc"; let n = ""; for (let r = 0; r < e; r++)n += t[r], r < e - 1 && (n += ","); return n }(t, n), a = n.slice(-2), o = t <= 1 ? "rc" : `vec2(${a.join(",")})`; this.userCode = `\n void main() {\n ${r} rc = getOutputCoords();\n vec4 packedInput = getA(${i});\n\n setOutput(getChannel(packedInput, ${o}));\n }\n ` } } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const c_ = P.kernel_impls.whereImpl, h_ = {}; const d_ = (0, P.env)().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"); class f_ extends P.KernelBackend { + nextDataId() { return f_.nextDataId++ } constructor(e) { if (super(), this.pendingRead = new WeakMap, this.pendingDisposal = new WeakSet, this.dataRefCount = new WeakMap, this.numBytesInGPU = 0, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.lastGlFlushTime = 0, this.warnedAboutMemory = !1, this.pendingDeletes = 0, this.disposed = !1, !(0, P.env)().getBool("HAS_WEBGL")) throw new Error("WebGL is not supported on this device"); let t; if (null != e) { if (e instanceof Jk) t = e; else { const n = Wx((0, P.env)().getNumber("WEBGL_VERSION"), e); t = new Jk(n) } this.binaryCache = {}, this.gpgpuCreatedLocally = !1 } else { const e = Wx((0, P.env)().getNumber("WEBGL_VERSION")); t = new Jk(e), this.binaryCache = ((n = (0, P.env)().getNumber("WEBGL_VERSION")) in h_ || (h_[n] = {}), h_[n]), this.gpgpuCreatedLocally = !0 } var n; this.gpgpu = t, this.canvas = this.gpgpu.gl.canvas, this.textureManager = new JS(this.gpgpu), this.numMBBeforeWarning = null == (0, P.env)().global.screen ? 1024 : (0, P.env)().global.screen.height * (0, P.env)().global.screen.width * window.devicePixelRatio * 600 / 1024 / 1024, this.texData = new P.DataStorage(this, (0, P.engine)()) } numDataIds() { return this.texData.numDataIds() - this.pendingDeletes } writeTexture(e, t, n, r, i, a) { const o = this.makeTensorInfo(t, n), s = this.texData.get(o.dataId); s.isPacked = !1, s.texture = { texture: e, texShape: [r, i] }, s.texShape = [r, i]; const u = $w(t), l = new Ek(u, !1, a), c = this.runWebGLProgram(l, [o], n, [[r, i]]); return c.shape = t, s.texture = null, this.disposeIntermediateTensorInfo(o), c.dataId } write(e, t, n) { if (((0, P.env)().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS") || (0, P.env)().getBool("DEBUG")) && this.checkNumericalProblems(e), "complex64" === n && null != e) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag)."); const r = { id: this.nextDataId() }; return this.texData.set(r, { shape: t, dtype: n, values: e, usage: Hx.UPLOAD, refCount: 1 }), r } refCount(e) { if (this.texData.has(e)) { return this.texData.get(e).refCount } return 0 } incRef(e) { this.texData.get(e).refCount++ } decRef(e) { if (this.texData.has(e)) { this.texData.get(e).refCount-- } } move(e, t, n, r, i) { if ((0, P.env)().getBool("DEBUG") && this.checkNumericalProblems(t), "complex64" === r) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag)."); this.texData.set(e, { shape: n, dtype: r, values: t, usage: Hx.UPLOAD, refCount: i }) } disposeIntermediateTensorInfo(e) { this.disposeData(e.dataId) } readSync(e) { const t = this.texData.get(e), { values: n, dtype: r, complexTensorInfos: i, slice: a, shape: o, isPacked: s } = t; if (null != a) { let t; t = s ? new u_(o, s_) : new n_(o, s_); const n = this.runWebGLProgram(t, [{ dataId: e, shape: o, dtype: r }], r), i = this.readSync(n.dataId); return this.disposeIntermediateTensorInfo(n), i } if (null != n) return this.convertAndCacheOnCPU(e); if ("string" === r) return n; const u = null != this.activeTimers; let l, c; if (u && (l = P.util.now()), "complex64" === r) { const e = this.readSync(i.real.dataId), t = this.readSync(i.imag.dataId); c = P.backend_util.mergeRealAndImagArrays(e, t) } else c = this.getValuesFromTexture(e); return u && (this.downloadWaitMs += P.util.now() - l), this.convertAndCacheOnCPU(e, c) } async read(e) { if (this.pendingRead.has(e)) { const t = this.pendingRead.get(e); return new Promise((e => t.push(e))) } const t = this.texData.get(e), { values: n, shape: r, slice: i, dtype: a, complexTensorInfos: o, isPacked: s } = t; if (null != i) { let t; t = s ? new u_(r, s_) : new n_(r, s_); const n = this.runWebGLProgram(t, [{ dataId: e, shape: r, dtype: a }], a), i = this.read(n.dataId); return this.disposeIntermediateTensorInfo(n), i } if (null != n) return this.convertAndCacheOnCPU(e); if ((0, P.env)().getBool("DEBUG") && !(0, P.env)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED") && 2 === (0, P.env)().getNumber("WEBGL_VERSION")) throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported."); let u, l, c = null; if ("complex64" !== a && (0, P.env)().get("WEBGL_BUFFER_SUPPORTED")) { u = this.decode(e); const t = this.texData.get(u.dataId); c = this.gpgpu.createBufferFromTexture(t.texture.texture, ...Zx(r)) } if (this.pendingRead.set(e, []), "complex64" !== a && await this.gpgpu.createAndWaitForFence(), "complex64" === a) { const e = await Promise.all([this.read(o.real.dataId), this.read(o.imag.dataId)]), t = e[0], n = e[1]; l = P.backend_util.mergeRealAndImagArrays(t, n) } else if (null == c) l = this.getValuesFromTexture(e); else { const e = P.util.sizeFromShape(r); l = this.gpgpu.downloadFloat32MatrixFromBuffer(c, e) } if (null != u && this.disposeIntermediateTensorInfo(u), null != c) { const e = this.gpgpu.gl; ew(e, (() => e.deleteBuffer(c))) } const h = this.convertAndCacheOnCPU(e, l), d = this.pendingRead.get(e); return this.pendingRead.delete(e), d.forEach((e => e(h))), this.pendingDisposal.has(e) && (this.pendingDisposal.delete(e), this.disposeData(e) && (0, P.engine)().removeDataId(e, this), this.pendingDeletes--), h } readToGPU(e, t = {}) { const n = this.texData.get(e), { values: r, shape: i, slice: a, dtype: o, isPacked: s, texture: u } = n; if ("complex64" === o) throw new Error("Does not support reading texture for complex64 dtype."); if (null != a) { let n; n = s ? new u_(i, s_) : new n_(i, s_); const r = this.runWebGLProgram(n, [{ dataId: e, shape: i, dtype: o }], o), a = this.readToGPU(r, t); return this.disposeIntermediateTensorInfo(r), a } if (null == u) throw null != r ? new Error("Data is not on GPU but on CPU.") : new Error("There is no data on GPU or CPU."); const l = this.decode(e, t.customTexShape), c = (0, P.engine)().makeTensorFromTensorInfo(l), h = this.texData.get(l.dataId); return Object.assign({ tensorRef: c }, h.texture) } bufferSync(e) { const t = this.readSync(e.dataId); if ("string" === e.dtype) try { const n = t.map((e => P.util.decodeString(e))); return (0, P.buffer)(e.shape, e.dtype, n) } catch (e) { throw new Error("Failed to decode encoded string bytes into utf-8") } return (0, P.buffer)(e.shape, e.dtype, t) } checkNumericalProblems(e) { if (null != e) for (let t = 0; t < e.length; t++) { const n = e[t]; if (!rw(n)) { if ((0, P.env)().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")) throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`); throw Error(`The value ${n} cannot be represented on this device.`) } } } getValuesFromTexture(e) { const { shape: t, dtype: n, isPacked: r } = this.texData.get(e), i = P.util.sizeFromShape(t); if ((0, P.env)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")) { const n = this.decode(e), r = this.texData.get(n.dataId), a = this.gpgpu.downloadMatrixFromPackedTexture(r.texture.texture, ...Zx(t)).subarray(0, i); return this.disposeIntermediateTensorInfo(n), a } const a = (0, P.env)().getBool("WEBGL_PACK") && !0 === r, o = a ? $w(t) : t, s = a ? new Ak(o) : new Ck(o), u = this.runWebGLProgram(s, [{ shape: o, dtype: n, dataId: e }], "float32"), l = this.texData.get(u.dataId), c = this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(l.texture.texture, l.texShape[0], l.texShape[1]).subarray(0, i); return this.disposeIntermediateTensorInfo(u), c } timerAvailable() { return (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 } time(e) { const t = this.activeTimers, n = []; let r = !1; null == this.programTimersStack ? (this.programTimersStack = n, r = !0) : this.activeTimers.push(n), this.activeTimers = n, e(); const i = P.util.flatten(this.activeTimers.map((e => e.query))).filter((e => null != e)), a = P.util.flatten(this.activeTimers.map((e => e.name))).filter((e => null != e)); this.activeTimers = t, r && (this.programTimersStack = null); const o = { uploadWaitMs: this.uploadWaitMs, downloadWaitMs: this.downloadWaitMs, kernelMs: null, wallMs: null }; return (async () => { if ((0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0) { const e = await Promise.all(i); o.kernelMs = P.util.sum(e), o.getExtraProfileInfo = () => e.map(((e, t) => ({ name: a[t], ms: e }))).map((e => `${e.name}: ${e.ms}`)).join(", ") } else o.kernelMs = { error: "WebGL query timers are not supported in this environment." }; return this.uploadWaitMs = 0, this.downloadWaitMs = 0, o })() } memory() { return { unreliable: !1, numBytesInGPU: this.numBytesInGPU, numBytesInGPUAllocated: this.textureManager.numBytesAllocated, numBytesInGPUFree: this.textureManager.numBytesFree } } startTimer() { return (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? this.gpgpu.beginQuery() : { startMs: P.util.now(), endMs: null } } endTimer(e) { return (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? (this.gpgpu.endQuery(), e) : (e.endMs = P.util.now(), e) } async getQueryTime(e) { if ((0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0) return this.gpgpu.waitForQueryAndGetTime(e); const t = e; return t.endMs - t.startMs } disposeData(e, t = !1) { if (this.pendingDisposal.has(e)) return !1; if (!this.texData.has(e)) return !0; if (t ? this.texData.get(e).refCount = 0 : this.texData.get(e).refCount--, !t && this.texData.get(e).refCount > 0) return !1; if (this.pendingRead.has(e)) return this.pendingDisposal.add(e), this.pendingDeletes++, !1; this.releaseGPUData(e); const { complexTensorInfos: n } = this.texData.get(e); return null != n && (this.disposeData(n.real.dataId, t), this.disposeData(n.imag.dataId, t)), this.texData.delete(e), !0 } releaseGPUData(e) { const { texture: t, dtype: n, texShape: r, usage: i, isPacked: a, slice: o } = this.texData.get(e), s = o && o.origDataId || e, u = this.dataRefCount.get(s); u > 1 ? this.dataRefCount.set(s, u - 1) : (this.dataRefCount.delete(s), null != t && (this.numBytesInGPU -= this.computeBytes(r, n), this.textureManager.releaseTexture(t, r, i, a))); const l = this.texData.get(e); l.texture = null, l.texShape = null, l.isPacked = !1, l.slice = null } getTexture(e) { return this.uploadToGPU(e), this.texData.get(e).texture.texture } getDataInfo(e) { return this.texData.get(e) } shouldExecuteOnCPU(e, t = d_) { return (0, P.env)().getBool("WEBGL_CPU_FORWARD") && e.every((e => null == this.texData.get(e.dataId).texture && P.util.sizeFromShape(e.shape) < t)) } getGPGPUContext() { return this.gpgpu } where(e) { P.backend_util.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead"); const t = e.dataSync(); return c_(e.shape, t) } packedUnaryOp(e, t, n) { const r = new u_(e.shape, t), i = this.compileAndRun(r, [e], n); return (0, P.engine)().makeTensorFromTensorInfo(i) } abs(e) { if (this.shouldExecuteOnCPU([e]) && "complex64" !== e.dtype) { const t = FS(this.texData.get(e.dataId).values); return this.makeOutput(e.shape, e.dtype, t) } if ((0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(e, i_, e.dtype); const t = new n_(e.shape, i_), n = this.compileAndRun(t, [e]); return (0, P.engine)().makeTensorFromTensorInfo(n) } makeTensorInfo(e, t, n) { let r; if ("string" === t && null != n && n.length > 0 && P.util.isString(n[0])) { const i = n.map((e => P.util.encodeString(e))); r = this.write(i, e, t) } else r = this.write(n, e, t); return this.texData.get(r).usage = null, { dataId: r, shape: e, dtype: t } } makeOutput(e, t, n) { return (0, P.engine)().makeTensorFromTensorInfo(this.makeTensorInfo(e, t, n), this) } unpackTensor(e) { const t = new l_(e.shape); return this.runWebGLProgram(t, [e], e.dtype) } packTensor(e) { const t = new KS(e.shape); return this.runWebGLProgram(t, [e], e.dtype, null, !0) } packedReshape(e, t) { const n = [Fw(e.shape), ...Dw(e.shape)], r = { dtype: e.dtype, shape: n, dataId: e.dataId }, i = [Fw(t), ...Dw(t)], a = new ZS(i, n), o = [n], s = this.runWebGLProgram(a, [r], e.dtype, o, !0); return { dataId: s.dataId, shape: t, dtype: s.dtype } } decode(e, t) { const n = this.texData.get(e), { isPacked: r, shape: i, dtype: a } = n; if (null != t) { const e = P.util.sizeFromShape(i), n = t[0] * t[1] * 4; P.util.assert(e <= n, (() => "customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")) } const o = $w(i); let s; s = r ? new _k(o) : new Sk(o); const u = [null != t ? t : Zx(o)]; return { dtype: a, shape: i, dataId: this.runWebGLProgram(s, [{ shape: o, dtype: a, dataId: e }], a, u, !0, t).dataId } } runWebGLProgram(e, t, n, r, i = !1, a) { + const o = this.makeTensorInfo(e.outputShape, n), s = this.texData.get(o.dataId); if (e.packedOutput && (s.isPacked = !0), e.outPackingScheme === Vx.DENSE) { const t = null != a ? a : Zx(e.outputShape); s.texShape = t.map((e => 2 * e)) } if (null != e.outTexUsage && (s.usage = e.outTexUsage), 0 === P.util.sizeFromShape(o.shape)) return s.values = P.util.getTypedArrayFromDType(o.dtype, 0), o; const u = [], l = t.map((t => { if ("complex64" === t.dtype) throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts."); let n = this.texData.get(t.dataId); if (null == n.texture) { if (!e.packedInputs && P.util.sizeFromShape(t.shape) <= (0, P.env)().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM")) return { shape: t.shape, texData: null, isUniform: !0, uniformValues: n.values }; e.packedInputs && (n.isPacked = !0, n.shape = t.shape) } if (this.uploadToGPU(t.dataId), !!n.isPacked != !!e.packedInputs) t = n.isPacked ? this.unpackTensor(t) : this.packTensor(t), u.push(t), n = this.texData.get(t.dataId); else if (n.isPacked && !zw(n.shape, t.shape)) { const e = t, r = t.shape; t.shape = n.shape, t = this.packedReshape(t, r), u.push(t), n = this.texData.get(t.dataId), e.shape = r } return { shape: t.shape, texData: n, isUniform: !1 } })); this.uploadToGPU(o.dataId); const c = { shape: o.shape, texData: s, isUniform: !1 }, h = function (e, t, n) { let r = ""; t.concat(n).forEach((t => { const i = null != t.texData && null != t.texData.slice && t.texData.slice.flatOffset > 0; if (e.enableShapeUniforms && !t.isUniform) { const a = t.texData.texShape, { useSqueezeShape: o, uniformShape: s, keptDims: u } = yk(e.packedInputs, t.shape, a); let l = "", c = "", h = ""; if (1 === s.length && e.packedInputs) { const e = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)]; l = `${e[0] > 1}_${e[1] > 1}` } else if (2 !== s.length || e.packedInputs) { if (s.length > 2 && !e.packedInputs) { const e = P.util.computeStrides(s); h = `${e[0] === a[1]}_${e[e.length - 1] === a[1]}` } } else c = `${s[0] > 1}_${s[1] > 1}`; const d = t.shape.length, f = 2 === s.length && P.util.arraysEqual(t.shape, a), p = 1 === P.util.sizeFromShape(t.shape), m = P.backend_util.getBroadcastDims(t.shape, n.shape), g = !e.packedInputs && d === n.shape.length && P.util.arraysEqual(a, n.texData.texShape), y = e.packedInputs || s.length > 2 ? "" : `${a[0] > 1}_${a[1] > 1}`; r += `${d}_${g}_${o ? u : ""}_${s.length}_${p}_${m}_${f}_${l}_${c}_${h}_${y}_${i}` } else { const e = t.isUniform ? "uniform" : t.texData.texShape; r += `${t.shape}_${e}_${i}` } })); const i = e.userCode; let a = e.constructor.name; return a += "_" + r + "_" + i + `${(0, P.env)().getNumber("WEBGL_VERSION")}`, a }(e, l, c), d = this.getAndSaveBinary(h, (() => + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { const i = n.map(((e, n) => { const r = { logicalShape: e.shape, texShape: e.isUniform ? null : e.texData.texShape, isUniform: e.isUniform, isPacked: !e.isUniform && e.texData.isPacked, flatOffset: null }; return null != e.texData && null != e.texData.slice && e.texData.slice.flatOffset > 0 && (r.flatOffset = e.texData.slice.flatOffset), { name: t.variableNames[n], shapeInfo: r } })), a = i.map((e => e.shapeInfo)), o = { logicalShape: r.shape, texShape: r.texData.texShape, isUniform: !1, isPacked: r.texData.isPacked, flatOffset: null }, s = ok(i, o, t), u = sw(e.gl, s), l = e.createProgram(u); return (0, P.env)().get("ENGINE_COMPILE_ONLY") ? { program: t, fragmentShader: u, source: s, webGLProgram: l, inShapeInfos: a, outShapeInfo: o, variablesLocations: null, customUniformLocations: null, infLoc: null, nanLoc: null, outShapeLocation: null, outShapeStridesLocation: null, outTexShapeLocation: null } : (e.buildVao(l), Object.assign({ program: t, fragmentShader: u, source: s, webGLProgram: l, inShapeInfos: a, outShapeInfo: o }, xk(e, t, l))) }(this.gpgpu, e, l, c))), f = null != this.activeTimers; let p; f && (p = this.startTimer()), (0, P.env)().get("ENGINE_COMPILE_ONLY") || function (e, t, n, r, i) { t.program.enableShapeUniforms || (wk(t.inShapeInfos, n), wk([t.outShapeInfo], [r])); const a = r.texData.texture, o = r.texData.texShape; r.texData.isPacked ? e.setOutputPackedMatrixTexture(a.texture, o[0], o[1]) : e.setOutputMatrixTexture(a.texture, o[0], o[1]), e.setProgram(t.webGLProgram), e.bindVertexArray(t.webGLProgram.vao), 1 === (0, P.env)().getNumber("WEBGL_VERSION") && null !== t.infLoc && e.gl.uniform1f(t.infLoc, 1 / 0), null !== t.nanLoc && e.gl.uniform1f(t.nanLoc, NaN); for (let r = 0; r < n.length; ++r) { const i = n[r], { uniform: a, offset: o, shape: s, texShape: u } = t.variablesLocations[r]; if (s) { const { uniformShape: n } = yk(t.program.packedInputs, i.shape, i.texData.texShape); switch (n.length) { case 1: e.gl.uniform1iv(s, new Int32Array(n)); break; case 2: e.gl.uniform2iv(s, new Int32Array(n)); break; case 3: e.gl.uniform3iv(s, new Int32Array(n)); break; case 4: e.gl.uniform4iv(s, new Int32Array(n)) } } if (u && e.gl.uniform2i(u, i.texData.texShape[0], i.texData.texShape[1]), null != a) if (i.isUniform) if (P.util.sizeFromShape(i.shape) < 2) e.gl.uniform1f(a, i.uniformValues[0]); else { let t = i.uniformValues; t instanceof Float32Array || (t = new Float32Array(t)), e.gl.uniform1fv(a, t) } else null != i.texData.slice && null != o && e.gl.uniform1i(o, i.texData.slice.flatOffset), e.setInputMatrixTexture(i.texData.texture.texture, a, r) } const s = t.outShapeLocation; if (s) switch (r.shape.length) { case 1: e.gl.uniform1iv(s, new Int32Array(r.shape)); break; case 2: e.gl.uniform2iv(s, new Int32Array(r.shape)); break; case 3: e.gl.uniform3iv(s, new Int32Array(r.shape)); break; case 4: e.gl.uniform4iv(s, new Int32Array(r.shape)) }if (t.outShapeStridesLocation) { const n = P.util.computeStrides(r.shape); switch (r.shape.length) { case 2: e.gl.uniform1iv(t.outShapeStridesLocation, new Int32Array(n)); break; case 3: e.gl.uniform2iv(t.outShapeStridesLocation, new Int32Array(n)); break; case 4: e.gl.uniform3iv(t.outShapeStridesLocation, new Int32Array(n)) } } if (t.outTexShapeLocation && e.gl.uniform2i(t.outTexShapeLocation, r.texData.texShape[0], r.texData.texShape[1]), t.program.customUniforms && i) for (let n = 0; n < t.program.customUniforms.length; ++n) { const r = t.program.customUniforms[n], a = t.customUniformLocations[n], o = i[n]; if ("float" === r.type) e.gl.uniform1fv(a, o); else if ("vec2" === r.type) e.gl.uniform2fv(a, o); else if ("vec3" === r.type) e.gl.uniform3fv(a, o); else if ("vec4" === r.type) e.gl.uniform4fv(a, o); else if ("int" === r.type) e.gl.uniform1iv(a, o); else if ("ivec2" === r.type) e.gl.uniform2iv(a, o); else if ("ivec3" === r.type) e.gl.uniform3iv(a, o); else { if ("ivec4" !== r.type) throw Error(`uniform type ${r.type} is not supported yet.`); e.gl.uniform4iv(a, o) } } e.executeProgram() }(this.gpgpu, d, l, c, r), u.forEach((e => this.disposeIntermediateTensorInfo(e))), f && (p = this.endTimer(p), this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime(p) })); const m = (0, P.env)().getNumber("WEBGL_FLUSH_THRESHOLD"); if (m > 0) { const e = P.util.now(); e - this.lastGlFlushTime > m && (this.gpgpu.gl.flush(), this.lastGlFlushTime = e) } if (!(0, P.env)().getBool("WEBGL_LAZILY_UNPACK") && s.isPacked && !1 === i) { const e = this.unpackTensor(o); return this.disposeIntermediateTensorInfo(o), e } return o + } compileAndRun(e, t, n, r, i = !1) { n = n || t[0].dtype; return this.runWebGLProgram(e, t, n, r, i) } getAndSaveBinary(e, t) { return e in this.binaryCache || (this.binaryCache[e] = t()), this.binaryCache[e] } getTextureManager() { return this.textureManager } dispose() { if (!this.disposed) { if (!(0, P.env)().getBool("IS_TEST")) { Object.keys(this.binaryCache).forEach((e => { this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram), delete this.binaryCache[e] })) } this.textureManager.dispose(), null != this.canvas && "undefined" != typeof HTMLCanvasElement && this.canvas instanceof HTMLCanvasElement ? this.canvas.remove() : this.canvas = null, this.gpgpuCreatedLocally && (this.gpgpu.program = null, this.gpgpu.dispose()), this.disposed = !0 } } floatPrecision() { return null == this.floatPrecisionValue && (this.floatPrecisionValue = (0, P.tidy)((() => { if (!(0, P.env)().get("WEBGL_RENDER_FLOAT32_ENABLED")) { const e = (0, P.env)().getBool("DEBUG"); (0, P.env)().set("DEBUG", !1); const t = this.abs((0, P.scalar)(1e-8)).dataSync()[0]; if ((0, P.env)().set("DEBUG", e), t > 0) return 32 } return 16 }))), this.floatPrecisionValue } epsilon() { return 32 === this.floatPrecision() ? 1e-7 : 1e-4 } uploadToGPU(e) { const t = this.texData.get(e), { shape: n, dtype: r, values: i, texture: a, usage: o, isPacked: s } = t; if (null != a) return; const u = null != this.activeTimers; let l; u && (l = P.util.now()); let c = t.texShape; if (null == c && (c = Rw(n, s), t.texShape = c), null != i) { const e = $w(n); let a, o = c[1], h = c[0]; const d = i instanceof Uint8Array || i instanceof Uint8ClampedArray; !s && d || ([o, h] = Jx(c[0], c[1])), a = s ? new Nk(e, d) : new Ek(e, d); const f = d ? [h, o] : c, p = this.makeTensorInfo(f, r), m = this.texData.get(p.dataId); m.usage = d ? Hx.PIXELS : Hx.UPLOAD, m.texShape = f, this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(p.dataId), o, h, i); const g = [[h, o]], y = !0, b = this.runWebGLProgram(a, [p], r, g, y), v = this.texData.get(b.dataId); t.texShape = v.texShape, t.isPacked = v.isPacked, t.usage = v.usage, (0, P.env)().get("ENGINE_COMPILE_ONLY") ? this.disposeData(b.dataId) : (t.texture = v.texture, t.values = null, this.texData.delete(b.dataId)), this.disposeIntermediateTensorInfo(p), u && (this.uploadWaitMs += P.util.now() - l) } else { const e = this.acquireTexture(c, o, r, s); t.texture = e } } convertAndCacheOnCPU(e, t) { const n = this.texData.get(e), { dtype: r } = n; return null != t && (n.values = function (e, t) { if ("float32" === t || "complex64" === t) return e; if ("int32" === t || "bool" === t) { const n = "int32" === t ? new Int32Array(e.length) : new Uint8Array(e.length); for (let t = 0; t < n.length; ++t)n[t] = Math.round(e[t]); return n } throw new Error(`Unknown dtype ${t}`) }(t, r)), n.values } acquireTexture(e, t, n, r) { if (this.numBytesInGPU += this.computeBytes(e, n), !this.warnedAboutMemory && this.numBytesInGPU > 1024 * this.numMBBeforeWarning * 1024) { const e = (this.numBytesInGPU / 1024 / 1024).toFixed(2); this.warnedAboutMemory = !0, console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`) } return this.textureManager.acquireTexture(e, t, r) } computeBytes(e, t) { return e[0] * e[1] * P.util.bytesPerElement(t) } checkCompileCompletion() { for (const [, e] of Object.entries(this.binaryCache)) this.checkCompletion_(e) } async checkCompileCompletionAsync() { const e = []; if (this.gpgpu.parallelCompilationExtension) { for (const [, t] of Object.entries(this.binaryCache)) e.push(this.checkCompletionAsync_(t)); return Promise.all(e) } for (const [, t] of Object.entries(this.binaryCache)) { const n = new Promise((e => { try { this.checkCompletion_(t), e(!0) } catch (e) { throw e } })); e.push(n) } return Promise.all(e) } async checkCompletionAsync_(e) { return this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR) ? this.checkCompletion_(e) : (await (0, P.nextFrame)(), this.checkCompletionAsync_(e)) } checkCompletion_(e) { if (!1 === this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.gl.LINK_STATUS)) { if (console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)), !1 === this.gpgpu.gl.getShaderParameter(e.fragmentShader, this.gpgpu.gl.COMPILE_STATUS)) throw lw(e.source, this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)), new Error("Failed to compile fragment shader."); throw new Error("Failed to link vertex and fragment shaders.") } return !0 } getUniformLocations() { for (const e of Object.values(this.binaryCache)) { this.gpgpu.buildVao(e.webGLProgram); const { variablesLocations: t, customUniformLocations: n, infLoc: r, nanLoc: i, outShapeLocation: a, outShapeStridesLocation: o, outTexShapeLocation: s } = xk(this.gpgpu, e.program, e.webGLProgram); e.variablesLocations = t, e.customUniformLocations = n, e.infLoc = r, e.nanLoc = i, e.outShapeLocation = a, e.outShapeStridesLocation = o, e.outTexShapeLocation = s } } createTensorFromGPUData(e, t, n) { e.channels = e.channels || "RGBA"; const { texture: r, height: i, width: a, channels: o } = e, s = (0, P.engine)().backend; if (!s.gpgpu.gl.isTexture(r)) throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'."); const u = s.writeTexture(r, t, n, i, a, o); return (0, P.engine)().makeTensorFromDataId(u, t, n, s) } + } f_.nextDataId = 0; + /** @license See the LICENSE file. */ + const p_ = "4.22.0"; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function m_() { (0, P.env)().set("WEBGL_FORCE_F16_TEXTURES", !0) } + /** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + P.device_util.isBrowser() && (0, P.registerBackend)("webgl", (() => new f_), 2); const g_ = { forceHalfFloat: m_ }, y_ = "\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n"; class b_ { constructor(e, t, n) { this.variableNames = ["A", "B"], this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n), this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const v_ = "\n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n"; class x_ { constructor(e, t, n, r = !1) { this.variableNames = ["A", "B"], this.supportsBroadcasting = !0, this.packedInputs = !0, this.packedOutput = !0, this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n); const i = this.outputShape.length; this.enableShapeUniforms = kk(i); let a = ""; if (r) if (0 === i || 1 === P.util.sizeFromShape(this.outputShape)) a = "\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n "; else { if (a = `\n ${gk(i)} coords = getOutputCoords();\n `, 1 === i) this.enableShapeUniforms ? a += "\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n " : a += `\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `; else { const e = XS("coords", i); this.enableShapeUniforms ? a += `\n bool nextRowOutOfBounds =\n (${e[i - 2]} + 1) >= outShape[${i} - 2];\n bool nextColOutOfBounds =\n (${e[i - 1]} + 1) >= outShape[${i} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n ` : a += `\n bool nextRowOutOfBounds =\n (${e[i - 2]} + 1) >= ${this.outputShape[i - 2]};\n bool nextColOutOfBounds =\n (${e[i - 1]} + 1) >= ${this.outputShape[i - 1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n ` } } this.userCode = `\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${a}\n\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function w_(e) { const { inputs: t, backend: n } = e, { x: r } = t; return n.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype } } const k_ = { kernelName: P.Identity, backendName: "webgl", kernelFunc: w_ }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function S_(e) { const { inputs: t, backend: n } = e, { real: r, imag: i } = t, a = n.makeTensorInfo(r.shape, "complex64"), o = n.texData.get(a.dataId), s = w_({ inputs: { x: r }, backend: n }), u = w_({ inputs: { x: i }, backend: n }); return o.complexTensorInfos = { real: s, imag: u }, a } const __ = { kernelName: P.Complex, backendName: "webgl", kernelFunc: S_ }, C_ = "return (a < 0.) ? b * a : a;", A_ = "\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n"; const T_ = { kernelName: P.LeakyRelu, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { alpha: a } = r, o = n.makeTensorInfo([], "float32", P.util.createScalarValue(a, "float32")), s = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_(A_, i.shape, o.shape) : new b_(C_, i.shape, o.shape), u = n.runWebGLProgram(s, [i, o], "float32"); return n.disposeIntermediateTensorInfo(o), u } }, E_ = "return (a < 0.) ? b * a : a;", N_ = "\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n"; const I_ = { kernelName: P.Prelu, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r, alpha: i } = t, a = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_(N_, r.shape, i.shape) : new b_(E_, r.shape, i.shape); return n.runWebGLProgram(a, [r, i], "float32") } }, M_ = "if (isnan(x)) return x;"; function F_({ opSnippet: e, packedOpSnippet: t, cpuKernelImpl: n, dtype: r }) { return ({ inputs: i, backend: a }) => { const { x: o } = i, s = a, u = r || o.dtype; if (s.shouldExecuteOnCPU([o]) && null != n) { const e = s.texData.get(o.dataId), t = n(e.values, u); return s.makeTensorInfo(o.shape, u, t) } let l; return l = (0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS") && null != t ? new u_(o.shape, t) : new n_(o.shape, e), s.runWebGLProgram(l, [o], u) } } function D_({ opSnippet: e, packedOpSnippet: t, checkOutOfBounds: n = !1, supportsComplex: r = !1, cpuKernelImpl: i, dtype: a }) { return ({ inputs: o, backend: s }) => { const { a: u, b: l } = o, c = s; if (r && "complex64" === u.dtype) { const t = c.texData.get(u.dataId), n = c.texData.get(l.dataId), [r, i] = [[t.complexTensorInfos.real, n.complexTensorInfos.real], [t.complexTensorInfos.imag, n.complexTensorInfos.imag]].map((t => { const [n, r] = t, i = { dataId: n.dataId, dtype: n.dtype, shape: u.shape }, a = { dataId: r.dataId, dtype: r.dtype, shape: l.shape }, o = new b_(e, u.shape, l.shape); return c.runWebGLProgram(o, [i, a], (0, P.upcastType)(n.dtype, r.dtype)) })), a = S_({ inputs: { real: r, imag: i }, backend: c }); return c.disposeIntermediateTensorInfo(r), c.disposeIntermediateTensorInfo(i), a } const h = a || (0, P.upcastType)(u.dtype, l.dtype); if (("string" === u.dtype || "string" === l.dtype || c.shouldExecuteOnCPU([u, l])) && null != i) { const e = c.texData.get(u.dataId).values, t = c.texData.get(l.dataId).values, n = "string" === u.dtype ? P.backend_util.fromUint8ToStringArray(e) : e, r = "string" === u.dtype ? P.backend_util.fromUint8ToStringArray(t) : t, [a, o] = i(u.shape, l.shape, n, r, h), s = c.makeTensorInfo(o, h); return c.texData.get(s.dataId).values = a, s } let d; return d = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") && null != t ? new x_(t, u.shape, l.shape, n) : new b_(e, u.shape, l.shape), c.runWebGLProgram(d, [u, l], h) } } function $_(e, t = !1) { if ("linear" === e) return "return x;"; if ("relu" === e) return t ? "\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" : a_; if ("elu" === e) return t ? "\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n" : "return (x >= 0.0) ? x : (exp(x) - 1.0);"; if ("relu6" === e) return t ? "\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" : o_; if ("prelu" === e) return t ? N_ : E_; if ("leakyrelu" === e) return t ? A_ : C_; if ("sigmoid" === e) return "return 1.0 / (1.0 + exp(-1.0 * x));"; throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`) } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class R_ { constructor(e, t, n, r = !1, i = !1, a = !1, o = null, s = !1, u = !1) { this.variableNames = ["matrixA", "matrixB"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = n, this.enableShapeUniforms = kk(this.outputShape.length); const l = r ? e[1] : e[2], c = Math.ceil(l / 2), h = r ? "i * 2, rc.y" : "rc.y, i * 2", d = i ? "rc.z, i * 2" : "i * 2, rc.z", f = r ? ["a.xxyy", "a.zzww"] : ["a.xxzz", "a.yyww"], p = i ? ["b.xzxz", "b.ywyw"] : ["b.xyxy", "b.zwzw"]; let m = "", g = ""; o && (m = s ? `vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${o}\n }` : u ? `vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${o}\n }` : `vec4 activation(vec4 x) {\n ${o}\n }`, g = "result = activation(result);"); const y = a ? "result += getBiasAtOutCoords();" : ""; a && this.variableNames.push("bias"), s && this.variableNames.push("preluActivationWeights"), u && this.variableNames.push("leakyreluAlpha"); let b = "rc.x", v = "rc.x"; e[0] < t[0] ? b = `imod(rc.x, ${e[0]})` : t[0] < e[0] && (v = `imod(rc.x, ${t[0]})`), this.userCode = `\n ${m}\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = ${c}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n int batchA = ${b};\n int batchB = ${v};\n for (int i = 0; i < ${c}; i++) {\n vec4 a = getMatrixA(batchA, ${h});\n vec4 b = getMatrixB(batchB, ${d});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${f[0]} * ${p[0]});\n result += (${f[1]} * ${p[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${y}\n\n ${g}\n\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const O_ = "return areal * breal - aimag * bimag;", z_ = "return areal * bimag + aimag * breal;"; class P_ { constructor(e, t, n) { this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n), this.userCode = `\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${e}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const B_ = "return a * b;"; function L_(e) { const { inputs: t, backend: n } = e, { a: r, b: i } = t, a = P.backend_util.upcastType(r.dtype, i.dtype); if ("complex64" === r.dtype) { const e = n.texData.get(r.dataId), t = n.texData.get(i.dataId), a = new P_(O_, r.shape, i.shape), o = new P_(z_, r.shape, i.shape), s = [{ dataId: e.complexTensorInfos.real.dataId, dtype: e.complexTensorInfos.real.dtype, shape: r.shape }, { dataId: e.complexTensorInfos.imag.dataId, dtype: e.complexTensorInfos.imag.dtype, shape: r.shape }, { dataId: t.complexTensorInfos.real.dataId, dtype: t.complexTensorInfos.real.dtype, shape: i.shape }, { dataId: t.complexTensorInfos.imag.dataId, dtype: t.complexTensorInfos.imag.dtype, shape: i.shape }], u = n.runWebGLProgram(a, s, "float32"), l = n.runWebGLProgram(o, s, "float32"), c = S_({ inputs: { real: u, imag: l }, backend: n }); return n.disposeIntermediateTensorInfo(u), n.disposeIntermediateTensorInfo(l), c } if (n.shouldExecuteOnCPU([r, i])) { const e = n.texData.get(r.dataId), t = n.texData.get(i.dataId), [o, s] = wS(r.shape, i.shape, e.values, t.values, a), u = n.makeTensorInfo(s, a); return n.texData.get(u.dataId).values = o, u } let o; return o = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_(B_, r.shape, i.shape) : new b_(B_, r.shape, i.shape), n.runWebGLProgram(o, [r, i], a) } const j_ = { kernelName: P.Multiply, backendName: "webgl", kernelFunc: L_ }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function U_(e) { + const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { shape: a } = r, o = n, s = P.util.sizeFromShape(i.shape), u = P.util.inferFromImplicitShape(a, s), l = P.util.sizeFromShape(u); P.util.assert(s === l, (() => `The new shape (${u}) has ${l} elements and the old shape (${i.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)); const c = o.texData.get(i.dataId); return !c.isPacked || zw(i.shape, u) || null !== c.texture && zw(c.shape, u) ? (o.incRef(i.dataId), { dataId: i.dataId, shape: u, dtype: i.dtype }) : + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n) { const r = [Fw(e.shape), ...Dw(e.shape)], i = { dtype: e.dtype, shape: r, dataId: e.dataId }, a = [Fw(t), ...Dw(t)], o = new ZS(a, r), s = [r], u = n.runWebGLProgram(o, [i], e.dtype, s, !0); return { dataId: u.dataId, shape: t, dtype: u.dtype } }(i, u, o) + } const W_ = { kernelName: P.Reshape, backendName: "webgl", kernelFunc: U_ }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class V_ { constructor(e, t) { this.variableNames = ["x"]; const { windowSize: n, batchSize: r, inSize: i, outSize: a } = e; this.outputShape = [r, a]; const o = 4 * Math.floor(n / 4), s = n % 4; let u = "sumValue += dot(values, ones);"; if (null != t) { const e = 1 / t; u = `sumValue += dot(values * ${P.util.isInt(e) ? e.toPrecision(2) : e}, ones);` } let l = ""; i % n > 0 && (l = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return 0.0;\n }\n `), this.userCode = `\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${o};\n if (${1 === s}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2 === s}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3 === s}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n ` } } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class G_ { constructor(e, t) { this.variableNames = ["x"]; const { windowSize: n, batchSize: r, inSize: i, outSize: a } = e; this.outputShape = [r, a]; let o = "0.0", s = ""; "prod" === t ? o = "1.0" : "min" === t ? (o = "1.0 / 1e-20", s = "min") : "max" === t && (o = "-1.0 / 1e-20", s = "max"); let u = `${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`; "sum" === t ? u = "sumValue" : "prod" === t ? u = "prodValue" : "all" === t ? u = "allValue" : "any" === t && (u = "anyValue"); const l = 4 * Math.floor(n / 4), c = n % 4; let h = `\n if (${"sum" === t}) {\n sumValue += dot(values, ones);\n } else if (${"prod" === t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${s}(values, minMaxValue);\n if (${"min" === t} || ${"max" === t}) {\n minMaxValue = ${s}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `, d = "vec4"; "all" === t ? (o = "1.0", h = "\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ", d = "bvec4") : "any" === t && (o = "0.0", h = "\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ", d = "bvec4"); let f = ""; i % n > 0 && (f = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return initializationValue;\n }\n `), this.userCode = `\n const float initializationValue = ${o};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${f}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${o});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${h}\n }\n\n int inIdx = inOffset + ${l};\n if (${1 === c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${h}\n } else if (${2 === c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${h}\n } else if (${3 === c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${h}\n }\n setOutput(${u});\n }\n ` } } function H_(e, t, n, r) { + const i = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = []; for (; 0 === t.length || 1 !== t[t.length - 1].outSize;) { const n = t.length ? t[t.length - 1].outSize : e[1], r = P.backend_util.computeOptimalWindowSize(n); t.push({ inSize: n, windowSize: r, outSize: Math.ceil(n / r) }) } return t }(e.shape); let a = e; for (let o = 0; o < i.length; o++) { const { inSize: s, windowSize: u, outSize: l } = i[o]; let c, h; c = "mean" === n ? 0 === o ? new V_({ windowSize: u, inSize: s, batchSize: e.shape[0], outSize: l }, s) : new V_({ windowSize: u, inSize: s, batchSize: e.shape[0], outSize: l }) : new G_({ windowSize: u, inSize: s, batchSize: e.shape[0], outSize: l }, n), h = a, a = r.runWebGLProgram(c, [a], t), h.dataId !== e.dataId && r.disposeIntermediateTensorInfo(h) } return a + } + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class q_ { constructor(e, t) { this.variableNames = ["A"]; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[t[r]]; this.outputShape = n, this.rank = n.length; const r = gk(this.rank), i = function (e) { const t = e.length; if (t > 6) throw Error(`Transpose for rank ${t} is not yet supported`); const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u", "resRC.v"], r = new Array(t); for (let t = 0; t < e.length; t++)r[e[t]] = n[t]; return r.join() }(t); this.userCode = `\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${i}));\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Y_ { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[t[r]]; if (this.outputShape = n, this.rank = n.length, this.rank > 6) throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`); const r = gk(this.rank), i = YS("rc", this.rank), a = new Array(this.rank); for (let e = 0; e < t.length; e++)a[t[e]] = i[e]; const o = `vec2(${a.slice(-2).join()})`, s = `++${i[this.rank - 1]} < ${n[this.rank - 1]}`, u = `getChannel(getA(${a.join()}), ${o})`; this.userCode = `\n void main() {\n ${r} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${u};\n if(${s}) {\n result[1] = ${u};\n }\n --${i[this.rank - 1]};\n if(++${i[this.rank - 2]} < ${n[this.rank - 2]}) {\n result[2] = ${u};\n if(${s}) {\n result[3] = ${u};\n }\n }\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function X_(e, t, n) { const r = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new Y_(e.shape, t) : new q_(e.shape, t); return n.runWebGLProgram(r, [e], e.dtype) } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function K_(e) { + const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + return function (e, t, n, r) { const i = t, a = e.shape.length, o = P.util.parseAxisParam(i, e.shape); let s = o; const u = P.backend_util.getAxesPermutation(s, a), l = null != u; let c = e; l && (c = X_(e, u, r), s = P.backend_util.getInnerMostAxes(s.length, a)), P.backend_util.assertAxesAreInnerMostDims("sum", s, a); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, s); let f = h; n && (f = P.backend_util.expandShapeToKeepDim(h, o)); const p = P.util.sizeFromShape(d), m = U_({ inputs: { x: c }, attrs: { shape: [P.util.sizeFromShape(e.shape) / p, p] }, backend: r }), g = H_(m, (0, P.sumOutType)(e.dtype), "sum", r), y = U_({ inputs: { x: g }, attrs: { shape: f }, backend: r }); return r.disposeIntermediateTensorInfo(m), r.disposeIntermediateTensorInfo(g), l && r.disposeIntermediateTensorInfo(c), y }(i, a, o, n) + } const Z_ = { kernelName: P.Sum, backendName: "webgl", kernelFunc: K_ }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function J_(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { perm: a } = r, o = n, s = i.shape.length, u = new Array(s); for (let e = 0; e < u.length; e++)u[e] = i.shape[a[e]]; let l; if (o.shouldExecuteOnCPU([i])) { const e = o.texData.get(i.dataId).values, t = HS(e, i.shape, i.dtype, a, u); l = o.makeTensorInfo(u, i.dtype); o.texData.get(l.dataId).values = t } else l = X_(i, a, o); return l } const Q_ = { kernelName: P.Transpose, backendName: "webgl", kernelFunc: J_ }; function eC({ a: e, b: t, transposeA: n, transposeB: r, backend: i, bias: a = null, preluActivationWeights: o = null, leakyreluAlpha: s = 0, activation: u = null }) { const l = e.shape.length, c = t.shape.length, h = n ? e.shape[l - 2] : e.shape[l - 1], d = r ? t.shape[c - 1] : t.shape[c - 2], f = n ? e.shape[l - 1] : e.shape[l - 2], p = r ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), y = P.util.sizeFromShape(m), b = P.util.sizeFromShape(g), v = P.broadcast_util.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([f, p]); P.util.assert(h === d, (() => `Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`)); const x = n ? [y, h, f] : [y, f, h], w = r ? [b, p, d] : [b, d, p], k = U_({ inputs: { x: e }, backend: i, attrs: { shape: x } }), S = U_({ inputs: { x: t }, backend: i, attrs: { shape: w } }), _ = [k, S], C = Math.max(y, b), A = n ? k.shape[1] : k.shape[2], T = null != a, E = null != o, N = "leakyrelu" === u, I = null != u ? $_(u, !0) : null; let M; if ((1 === f || 1 === p) && A > 1e3 && !1 === (T || E || N || null != I)) { let e = k, t = S; n && (e = J_({ inputs: { x: k }, backend: i, attrs: { perm: [0, 2, 1] } }), _.push(e)), r && (t = J_({ inputs: { x: S }, backend: i, attrs: { perm: [0, 2, 1] } }), _.push(t)); const a = 1 === p; let o = e; 1 !== p && (o = U_({ inputs: { x: e }, backend: i, attrs: { shape: [C, A, 1] } }), _.push(o)); const s = 1 === p ? 2 : 1; let u = t; a && (u = U_({ inputs: { x: t }, backend: i, attrs: { shape: [C, 1, A] } }), _.push(u)); const l = L_({ inputs: { a: o, b: u }, backend: i }); M = K_({ inputs: { x: l }, backend: i, attrs: { axis: s, keepDims: !0 } }), _.push(l) } else { const u = (0, P.upcastType)(e.dtype, t.dtype), l = new R_(x, w, [C, f, p], n, r, T, I, E, N), c = [k, S]; if (null != a && c.push(a), E && c.push(o), N) { const e = i.makeTensorInfo([], "float32", P.util.createScalarValue(s, "float32")); c.push(e), _.push(e) } M = i.runWebGLProgram(l, c, u) } const F = U_({ inputs: { x: M }, backend: i, attrs: { shape: v } }); _.push(M); for (const e of _) i.disposeIntermediateTensorInfo(e); return F } const tC = { + kernelName: P._FusedMatMul, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a, bias: o, preluActivationWeights: s } = t, { transposeA: u, transposeB: l, activation: c, leakyreluAlpha: h } = r; return eC({ a: i, b: a, transposeA: u, transposeB: l, backend: n, bias: o, preluActivationWeights: s, leakyreluAlpha: h, activation: c }) } + }, nC = "return abs(x);"; const rC = { kernelName: P.Abs, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t; if (n.shouldExecuteOnCPU([r]) && "complex64" !== r.dtype) { const e = n.texData.get(r.dataId), t = FS(e.values); return n.makeTensorInfo(r.shape, r.dtype, t) } let i; return i = (0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? new u_(r.shape, nC) : new n_(r.shape, nC), n.runWebGLProgram(i, [r], r.dtype) } }, iC = F_({ opSnippet: r_ + "\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n" }), aC = { kernelName: P.Acos, backendName: "webgl", kernelFunc: iC }, oC = F_({ opSnippet: r_ + "\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));" }), sC = { kernelName: P.Acosh, backendName: "webgl", kernelFunc: oC }, uC = "return a + b;", lC = D_({ opSnippet: uC, packedOpSnippet: uC, supportsComplex: !0, cpuKernelImpl: Qk }), cC = { kernelName: P.Add, backendName: "webgl", kernelFunc: lC }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class hC { constructor(e, t) { this.outputShape = [], this.outputShape = e, this.variableNames = t.map(((e, t) => `T${t}`)); const n = []; this.variableNames.forEach((e => { n.push(`float v${e} = get${e}AtOutCoords();`) })); const r = this.variableNames.map((e => `v${e}`)).join(" + "); this.userCode = `\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class dC { constructor(e, t) { this.outputShape = [], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.variableNames = t.map(((e, t) => `T${t}`)); const n = []; this.variableNames.forEach((e => { n.push(`vec4 v${e} = get${e}AtOutCoords();`) })); const r = this.variableNames.map((e => `v${e}`)).join(" + "); this.userCode = `\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n ` } } const fC = { + kernelName: P.AddN, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function e(t) { const { inputs: n, backend: r } = t, i = n; if (1 === i.length) return w_({ inputs: { x: i[0] }, backend: r }); if (i.length > (0, P.env)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")) { const t = Math.floor(i.length / 2), n = e({ inputs: i.slice(0, t), backend: r }), a = e({ inputs: i.slice(t), backend: r }); return e({ inputs: [n, a], backend: r }) } const a = i.map((e => e.dtype)).reduce(((e, t) => (0, P.upcastType)(e, t))), o = i.map((e => e.shape)), s = (0, P.env)().getBool("WEBGL_PACK") ? new dC(i[0].shape, o) : new hC(i[0].shape, o); return r.runWebGLProgram(s, i, a) } + }; const pC = { + kernelName: P.All, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), l = P.backend_util.getInnerMostAxes(l.length, s)), P.backend_util.assertAxesAreInnerMostDims("all", l, s); const [d, f] = P.backend_util.computeOutAndReduceShapes(h.shape, l), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, P.util.sizeFromShape(f)] } }), m = H_(p, p.dtype, "all", n); let g; if (o) { g = U_({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(d, u) } }) } else g = U_({ inputs: { x: m }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), null != c && n.disposeIntermediateTensorInfo(h), g } + }; const mC = { + kernelName: P.Any, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), l = P.backend_util.getInnerMostAxes(l.length, s)), P.backend_util.assertAxesAreInnerMostDims("any", l, s); const [d, f] = P.backend_util.computeOutAndReduceShapes(h.shape, l), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, P.util.sizeFromShape(f)] } }), m = H_(p, p.dtype, "any", n); let g; if (o) { g = U_({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(d, u) } }) } else g = U_({ inputs: { x: m }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), null != c && n.disposeIntermediateTensorInfo(h), g } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class gC { constructor(e, t, n) { this.variableNames = ["A"]; const { windowSize: r, batchSize: i, outSize: a } = e; n || this.variableNames.push("bestIndicesA"), this.outputShape = [i, a]; const o = "max" === t ? ">" : "<", s = n ? "inOffset + i;" : "round(getBestIndicesA(batch, inOffset + i));"; this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${s};\n float candidate = getA(batch, inIdx);\n if (candidate ${o} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class yC { constructor(e, t, n, r) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, P.util.assert(e.length > 2, (() => `Packed arg${n.charAt(0).toUpperCase() + n.slice(1)} supports only inputs with rank above 2.`)); const i = e[e.length - 1], a = Math.ceil(i / t); this.outputShape = e.slice(0, -1), a > 1 && this.outputShape.push(a), r || this.variableNames.push("bestIndicesA"); const o = this.outputShape, s = o.length, u = gk(s), l = XS("coords", s); let c, h; if (1 === a) { h = s + 1; const e = gk(h); c = `\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[s - 1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[s - 2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[s - 1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[s - 2]};` } else h = s, c = `\n ${u} sourceLocR = coords;\n ++${l[s - 1]};\n ${u} sourceLocG = coords;\n ++${l[s - 2]};\n ${u} sourceLocA = coords;\n --${l[s - 1]};\n ${u} sourceLocB = coords;\n --${l[s - 2]};`; const d = ["x", "y", "z", "w", "u", "v"].slice(0, h), f = "." + d[h - 1], p = d.map((e => "int " + e)), m = XS("sourceLocR", h - 1).concat("inIdx.r"), g = XS("sourceLocG", h - 1).concat("inIdx.g"), y = XS("sourceLocB", h - 1).concat("inIdx.b"), b = XS("sourceLocA", h - 1).concat("inIdx.a"), v = "max" === n ? "greaterThan" : "lessThan", x = r ? "" : `\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`, w = `vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`, k = r ? "" : `\n float getBestIndicesAChannel(${p.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`; this.userCode = `\n float getAChannel(${p.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${k}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[s - 1]} < ${o[s - 1] - 1};\n bool hasNextRow = ${l[s - 2]} < ${o[s - 2] - 1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${f}, sourceLocG${f},\n sourceLocB${f}, sourceLocA${f}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${w};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${x}\n vec4 candidate = ${w};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${v}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function bC(e, t, n, r = null) { let i = t.shape[0], a = t.shape[1]; null != r && (i = r.shape[0], a = r.shape[1]); const o = P.backend_util.computeOptimalWindowSize(a), s = { windowSize: o, inSize: a, batchSize: i, outSize: Math.ceil(a / o) }, u = new gC(s, n, null == r), l = [t]; null != r && l.push(r); const c = e.runWebGLProgram(u, l, "int32"); if (1 === c.shape[1]) return c; const h = bC(e, t, n, c); return e.disposeIntermediateTensorInfo(c), h } function vC(e, t, n, r = null) { const i = null != r ? r.shape : t.shape, a = i[i.length - 1], o = P.backend_util.computeOptimalWindowSize(a), s = new yC(i, o, n, null == r), u = null == r ? [t] : [t, r], l = e.runWebGLProgram(s, u, "int32"); if (l.shape.length === t.shape.length) { const r = vC(e, t, n, l); return e.disposeIntermediateTensorInfo(l), r } return l } function xC(e, t, n, r) { const i = [n]; if (P.backend_util.assertAxesAreInnerMostDims("arg" + r.charAt(0).toUpperCase() + r.slice(1), i, t.shape.length), !(0, P.env)().getBool("WEBGL_PACK_REDUCE") || t.shape.length <= 2) { const n = [], a = e.texData.get(t.dataId); let o = t; null !== a && a.isPacked && (o = e.unpackTensor(t), n.push(o)); const [s, u] = P.backend_util.computeOutAndReduceShapes(o.shape, i), l = P.util.sizeFromShape(u), c = U_({ inputs: { x: o }, backend: e, attrs: { shape: [-1, l] } }); n.push(c); const h = bC(e, c, r); n.push(h); const d = U_({ inputs: { x: h }, backend: e, attrs: { shape: s } }); return n.forEach((t => e.disposeIntermediateTensorInfo(t))), d } return vC(e, t, r) } const wC = { + kernelName: P.ArgMax, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = J_({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), P.backend_util.assertAxesAreInnerMostDims("argMax", [o[0]], u.shape.length); const c = xC(n, u, o[0], "max"); return l.forEach((e => n.disposeIntermediateTensorInfo(e))), c } + }; const kC = { + kernelName: P.ArgMin, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = J_({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), P.backend_util.assertAxesAreInnerMostDims("argMin", [o[0]], u.shape.length); const c = xC(n, u, o[0], "min"); return l.forEach((e => n.disposeIntermediateTensorInfo(e))), c } + }, SC = F_({ opSnippet: r_ + "\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n" }), _C = { kernelName: P.Asin, backendName: "webgl", kernelFunc: SC }, CC = F_({ opSnippet: r_ + "return log(x + sqrt(x * x + 1.0));" }), AC = { kernelName: P.Asinh, backendName: "webgl", kernelFunc: CC }, TC = F_({ opSnippet: r_ + "\n return atan(x);\n" }), EC = { kernelName: P.Atan, backendName: "webgl", kernelFunc: TC }, NC = D_({ opSnippet: y_ + "\n return atan(a, b);\n", packedOpSnippet: "\n vec4 result = atan(a, b);\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n " + v_ + "\n return result;\n" }), IC = { kernelName: P.Atan2, backendName: "webgl", kernelFunc: NC }, MC = F_({ opSnippet: r_ + "\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;" }), FC = { kernelName: P.Atanh, backendName: "webgl", kernelFunc: MC }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class DC { constructor(e, t, n, r = !1, i = !1) { if (this.variableNames = ["x"], "avg" === t && n) throw new Error("Cannot compute positions for average pool."); const a = e.filterWidth, o = e.strideHeight, s = e.strideWidth, u = e.dilationHeight, l = e.dilationWidth, c = e.effectiveFilterHeight, h = e.effectiveFilterWidth, d = e.padInfo.top, f = e.padInfo.left; this.outputShape = e.outShape; const p = "avg" === t, m = `((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`, g = `(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`; let y = "0.0"; if (p || (y = "-1.0 / 1e-20"), n) { const t = ">="; return void (this.userCode = `\n const ivec2 strides = ivec2(${o}, ${s});\n const ivec2 pads = ivec2(${d}, ${f});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${h};\n wC += ${l}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r ? i ? m : g : `wR * ${h} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `) } let b = `${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`; "avg" === t && (b = "avgValue / max(count, 1.0)"); const v = 4 * Math.floor(a / 4), x = a % 4, w = `\n if (${p}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `; this.userCode = `\n const ivec2 strides = ivec2(${o}, ${s});\n const ivec2 pads = ivec2(${d}, ${f});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${v}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${w}\n }\n\n int xC = xCCorner + ${v};\n if (${1 === x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${w}\n } else if (${2 === x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${w}\n } else if (${3 === x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${w}\n }\n }\n setOutput(${b});\n }\n ` } } class $C { constructor(e, t, n, r = !1, i = !1) { if (this.variableNames = ["x"], "avg" === t && n) throw new Error("Cannot compute positions for average pool."); const a = e.filterWidth, o = e.strideDepth, s = e.strideHeight, u = e.strideWidth, l = e.dilationDepth, c = e.dilationHeight, h = e.dilationWidth, d = e.effectiveFilterDepth, f = e.effectiveFilterHeight, p = e.effectiveFilterWidth, m = e.padInfo.front, g = e.padInfo.top, y = e.padInfo.left; this.outputShape = e.outShape; const b = "avg" === t; let v = "0.0"; if (b || (v = "-1.0 / 1e-20"), n) { const t = ">="; return void (this.userCode = `\n const ivec3 strides =\n ivec3(${o}, ${s}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${f};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${h}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r ? i ? `(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `wD * ${f} * ${p} +\n wR * ${p} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `) } let x = `${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`; "avg" === t && (x = "avgValue / max(count, 1.0)"); const w = 4 * Math.floor(a / 4), k = a % 4, S = `\n if (${b}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `; this.userCode = `\n const ivec3 strides =\n ivec3(${o}, ${s}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${v};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${v});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${f};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${w}; wC += 4) {\n int xC = xCCorner + wC * ${h};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${h}, ch),\n getValue(batch, xD, xR, xC + 2 * ${h}, ch),\n getValue(batch, xD, xR, xC + 3 * ${h}, ch)\n );\n\n ${S}\n }\n\n int xC = xCCorner + ${w};\n if (${1 === k}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${2 === k}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${h}, ch),\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${3 === k}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${h}, ch),\n getValue(batch, xD, xR, xC + 2 * ${h}, ch),\n initializationValue\n );\n\n ${S}\n }\n }\n }\n setOutput(${x});\n }\n ` } } const RC = { + kernelName: P.AvgPool, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; Zw(i, "avgPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) return w_({ inputs: { x: i }, backend: n }); const c = new DC(l, "avg", !1); return n.runWebGLProgram(c, [i], "float32") } + }; const OC = { + kernelName: P.AvgPool3D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u, dataFormat: l } = r, c = P.backend_util.computePool3DInfo(i.shape, a, o, [1, 1, 1], s, u, l), h = new $C(c, "avg", !1); return n.runWebGLProgram(h, [i], "float32") } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class zC { constructor(e) { this.variableNames = ["dy"], this.outputShape = e.inShape; const t = e.filterHeight, n = e.filterWidth, r = e.strideHeight, i = e.strideWidth, a = e.dilationHeight, o = e.dilationWidth, s = e.effectiveFilterHeight, u = e.effectiveFilterWidth, l = s - 1 - e.padInfo.top, c = u - 1 - e.padInfo.left, h = 1 / (t * n); this.userCode = `\n const ivec2 pads = ivec2(${l}, ${c});\n const float avgMultiplier = float(${h});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${s};\n wR += ${a}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC+= ${o}) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n ` } } class PC { constructor(e) { this.variableNames = ["dy"], this.outputShape = e.inShape; const t = e.filterDepth, n = e.filterHeight, r = e.filterWidth, i = e.strideDepth, a = e.strideHeight, o = e.strideWidth, s = e.dilationDepth, u = e.dilationHeight, l = e.dilationWidth, c = e.effectiveFilterDepth, h = e.effectiveFilterHeight, d = e.effectiveFilterWidth, f = c - 1 - e.padInfo.front, p = h - 1 - e.padInfo.top, m = d - 1 - e.padInfo.left, g = 1 / (t * n * r); this.userCode = `\n const ivec3 pads = ivec3(${f}, ${p}, ${m});\n const float avgMultiplier = float(${g});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${c};\n wD += ${s}) {\n float dyD = float(dyDCorner + wD) / ${i}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${h};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${a}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${d};\n wC += ${l}) {\n float dyC = float(dyCCorner + wC) / ${o}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const BC = { + kernelName: P.AvgPool3DGrad, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a, { filterSize: s, strides: u, pad: l, dimRoundingMode: c } = r, h = P.backend_util.computePool3DInfo(o.shape, s, u, [1, 1, 1], l, c), d = new PC(h); return n.runWebGLProgram(d, [i], o.dtype) } + }; const LC = { + kernelName: P.AvgPoolGrad, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a; Zw([i, a], "avgPoolGrad"); const { filterSize: s, strides: u, pad: l } = r, c = P.backend_util.computePool2DInfo(o.shape, s, u, 1, l), h = new zC(c); return n.runWebGLProgram(h, [i], o.dtype) } + }; const jC = { + kernelName: P.BatchMatMul, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a } = t, { transposeA: o, transposeB: s } = r; return eC({ a: i, b: a, transposeA: o, transposeB: s, backend: n }) } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class UC { constructor(e, t, n, r, i, a) { this.outputShape = [], this.variableNames = ["x", "mean", "variance"], P.backend_util.assertAndGetBroadcastShape(e, t), P.backend_util.assertAndGetBroadcastShape(e, n); let o = "0.0"; null != r && (P.backend_util.assertAndGetBroadcastShape(e, r), this.variableNames.push("offset"), o = "getOffsetAtOutCoords()"); let s = "1.0"; null != i && (P.backend_util.assertAndGetBroadcastShape(e, i), this.variableNames.push("scale"), s = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${o};\n float scale = ${s};\n float inv = scale * inversesqrt(variance + float(${a}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class WC { constructor(e, t, n, r, i, a) { this.packedInputs = !0, this.packedOutput = !0, this.variableNames = ["x", "mean", "variance"], P.backend_util.assertAndGetBroadcastShape(e, t), P.backend_util.assertAndGetBroadcastShape(e, n); let o = "vec4(0.0)"; null != r && (P.backend_util.assertAndGetBroadcastShape(e, r), this.variableNames.push("offset"), o = "getOffsetAtOutCoords()"); let s = "vec4(1.0)"; null != i && (P.backend_util.assertAndGetBroadcastShape(e, i), this.variableNames.push("scale"), s = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `\n void main() {\n vec4 offset = ${o};\n vec4 scale = ${s};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${a}));\n\n setOutput((x - mean) * inv + offset);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const VC = { kernelName: P.FusedBatchNorm, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, mean: i, variance: a, offset: o, scale: s } = e; P.util.assert(i.shape.length === a.shape.length, (() => "Batch normalization gradient requires mean and variance to have equal ranks.")), P.util.assert(null == o || i.shape.length === o.shape.length, (() => "Batch normalization gradient requires mean and offset to have equal ranks.")), P.util.assert(null == s || i.shape.length === s.shape.length, (() => "Batch normalization gradient requires mean and scale to have equal ranks.")); let { varianceEpsilon: u } = n; null == u && (u = .001); const l = [r, i, a]; let c = null; null != o && (c = o.shape, l.push(o)); let h = null; null != s && (h = s.shape, l.push(s)); const d = (0, P.env)().getBool("WEBGL_PACK_NORMALIZATION") ? new WC(r.shape, i.shape, a.shape, c, h, u) : new UC(r.shape, i.shape, a.shape, c, h, u); return t.runWebGLProgram(d, l, l[0].dtype) } }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class GC { constructor(e) { this.variableNames = ["source"], this.outputShape = e, this.rank = e.length; const t = gk(this.rank); this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }]; const n = function (e) { if (1 === e) return "sourceLoc"; if (e <= 6) return HC.slice(0, e).map((e => "sourceLoc." + e)).join(","); throw Error(`Slicing for rank ${e} is not yet supported`) }(this.rank); let r; r = `\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${e.map(((e, t) => `sourceLoc.${HC[t]} = start[${t}] + coords.${HC[t]};`)).join("\n")}\n `, this.userCode = `\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n ` } } const HC = ["x", "y", "z", "w", "u", "v"]; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class qC { constructor(e) { this.variableNames = ["source"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.rank = e.length, this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }]; const t = gk(this.rank), n = XS("coords", this.rank), r = XS("sourceLoc", this.rank), i = 1 === this.rank ? "sourceLoc" : `vec2(${r.slice(-2).join()})`, a = `getChannel(getSource(${r.join()}), ${i})`, o = `\n result.x = ${a};\n if (++${n[this.rank - 1]} < ${e[this.rank - 1]}) {\n ++${r[this.rank - 1]};\n result.y = ${a};\n --${r[this.rank - 1]};\n }\n `, s = 1 === this.rank ? "" : `\n --${n[this.rank - 1]};\n if (++${n[this.rank - 2]} < ${e[this.rank - 2]}) {\n ++${r[this.rank - 2]};\n result.z = ${a};\n if (++${n[this.rank - 1]} < ${e[this.rank - 1]}) {\n ++${r[this.rank - 1]};\n result.w = ${a};\n }\n }\n `, u = this.rank <= 4 ? `sourceLoc = coords +\n ${t}(${e.map(((e, t) => `start[${t}]`)).join()});` : e.map(((e, t) => `${r[t]} = ${n[t]} + start[${t}];`)).join("\n"); this.userCode = `\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${o}\n ${s}\n setOutput(result);\n }\n ` } } function YC(e) { + const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, size: o } = r, [s, u] = P.slice_util.parseSliceParams(i, a, o); if (P.slice_util.assertParamsValid(i, s, u), 0 === P.util.sizeFromShape(u)) return n.makeTensorInfo(u, i.dtype, []); if (n.shouldExecuteOnCPU([i]) || "string" === i.dtype) { const e = n.texData.get(i.dataId), t = DS(e.values, s, u, i.shape, i.dtype); return n.makeTensorInfo(u, i.dtype, t) } const { isPacked: l } = n.texData.get(i.dataId), c = P.slice_util.isSliceContinous(i.shape, s, u); if (l || !c) { const e = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new qC(u) : new GC(u), t = [s]; return n.runWebGLProgram(e, [i], i.dtype, t) } return n.uploadToGPU(i.dataId), + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { const i = r.texData.get(e.dataId), a = r.makeTensorInfo(n, e.dtype), o = r.texData.get(a.dataId); Object.assign(o, i), o.refCount = 1, o.shape = n, o.dtype = e.dtype; let s = P.slice_util.computeFlatOffset(t, P.util.computeStrides(e.shape)); i.slice && (s += i.slice.flatOffset), o.slice = { flatOffset: s, origDataId: i.slice && i.slice.origDataId || e.dataId }; const u = r.dataRefCount.get(o.slice.origDataId) || 1; return r.dataRefCount.set(o.slice.origDataId, u + 1), a }(i, s, u, n) + } const XC = { kernelName: P.Slice, backendName: "webgl", kernelFunc: YC }, KC = { kernelName: P.BatchToSpaceND, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, crops: o } = r; P.util.assert(i.shape.length <= 4, (() => "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet")); const s = a.reduce(((e, t) => e * t)), u = P.backend_util.getReshaped(i.shape, a, s), l = P.backend_util.getPermuted(u.length, a.length), c = P.backend_util.getReshapedPermuted(i.shape, a, s), h = P.backend_util.getSliceBeginCoords(o, a.length), d = P.backend_util.getSliceSize(c, o, a.length), f = [], p = U_({ inputs: { x: i }, backend: n, attrs: { shape: u } }), m = J_({ inputs: { x: p }, backend: n, attrs: { perm: l } }), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: c } }), y = YC({ inputs: { x: g }, backend: n, attrs: { begin: h, size: d } }); return f.push(p), f.push(m), f.push(g), f.forEach((e => n.disposeIntermediateTensorInfo(e))), y } }; const ZC = { + kernelName: P.Bincount, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o } = r, s = n.readSync(i.dataId), u = n.readSync(a.dataId), l = eS(s, u, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, l) } + }; const JC = { kernelName: P.BitwiseAnd, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { a: r, b: i } = t, a = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"), o = (0, P.env)().getNumber("WEBGL_VERSION"); if (n.shouldExecuteOnCPU([r, i]) || 1 === o) { const e = n.texData.get(r.dataId).values, t = n.texData.get(i.dataId).values, [a, o] = nS(r.shape, i.shape, e, t, r.dtype), s = n.makeTensorInfo(o, r.dtype); return n.texData.get(s.dataId).values = a, s } let s; return s = a ? new x_("\n int r = int(a.r) & int(b.r);\n int g = int(a.g) & int(b.g);\n int rb = int(a.b) & int(b.b);\n int ra = int(a.a) & int(b.a);\n return vec4(r, g, rb, ra);\n", r.shape, i.shape, !1) : new b_("\n return float(int(a.r) & int(b.r));\n", r.shape, i.shape), n.runWebGLProgram(s, [r, i], r.dtype) } }; const QC = { + kernelName: P.BroadcastArgs, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { s0: r, s1: i } = t, a = n.readSync(r.dataId), o = n.readSync(i.dataId), s = P.backend_util.assertAndGetBroadcastShape(Array.from(a), Array.from(o)); return n.makeTensorInfo([s.length], "int32", Int32Array.from(s)) } + }, eA = D_({ opSnippet: "return float(a != b);", cpuKernelImpl: SS, dtype: "bool" }), tA = { kernelName: P.NotEqual, backendName: "webgl", kernelFunc: eA }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function nA(e) { const { inputs: t, backend: n } = e, { input: r } = t; return w_({ inputs: { x: n.texData.get(r.dataId).complexTensorInfos.real }, backend: n }) } const rA = { kernelName: P.Real, backendName: "webgl", kernelFunc: nA }; const iA = { + kernelName: P.Cast, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function e(t) { const { inputs: n, backend: r, attrs: i } = t, { x: a } = n, { dtype: o } = i; if ("complex64" === o) { if ("complex64" === a.dtype) return w_({ inputs: { x: a }, backend: r }); const t = P.zeros(a.shape), n = e({ inputs: { x: a }, backend: r, attrs: { dtype: "float32" } }), i = S_({ inputs: { real: n, imag: t }, backend: r }); return t.dispose(), r.disposeIntermediateTensorInfo(n), i } if ("complex64" === a.dtype) { const t = nA({ inputs: { input: a }, backend: r }), n = e({ inputs: { x: t }, backend: r, attrs: { dtype: o } }); return r.disposeIntermediateTensorInfo(t), n } if (!P.util.hasEncodingLoss(a.dtype, o)) { const e = w_({ inputs: { x: a }, backend: r }); return { dataId: e.dataId, shape: e.shape, dtype: o } } if (r.shouldExecuteOnCPU([a])) { const e = r.texData.get(a.dataId).values, [t, n, i] = rS(e, a.shape, a.dtype, o); return r.makeTensorInfo(t, n, i) } if ("int32" === o) return function (e, t) { const n = new n_(e.shape, "return float(int(x));"), r = t.runWebGLProgram(n, [e], "int32"); return { dataId: r.dataId, shape: r.shape, dtype: r.dtype } }(a, r); if ("bool" === o) { const e = r.makeTensorInfo([], "bool", P.util.getTypedArrayFromDType("bool", 1)), t = eA({ inputs: { a, b: e }, backend: r }); return r.disposeIntermediateTensorInfo(e), t } throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${o}`) } + }, aA = "return ceil(x);", oA = F_({ opSnippet: aA, packedOpSnippet: aA, cpuKernelImpl: iS }), sA = { kernelName: P.Ceil, backendName: "webgl", kernelFunc: oA }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class uA { constructor(e) { this.variableNames = ["A"], this.customUniforms = [{ name: "minVal", type: "float" }, { name: "maxVal", type: "float" }], this.outputShape = e, this.userCode = "\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n " } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class lA { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "minVal", type: "float" }, { name: "maxVal", type: "float" }], this.outputShape = e, this.userCode = "\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n " } } const cA = { + kernelName: P.ClipByValue, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { clipValueMin: a, clipValueMax: o } = r; let s; s = (0, P.env)().getBool("WEBGL_PACK_CLIP") ? new lA(i.shape) : new uA(i.shape); const u = [[a], [o]]; return n.runWebGLProgram(s, [i], i.dtype, u) } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class hA { constructor(e) { this.variableNames = ["real", "imag"], this.outputShape = e, this.userCode = "\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n " } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function dA(e, t) { return { dataId: t.dataId, dtype: t.dtype, shape: e.shape } } const fA = { kernelName: P.ComplexAbs, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = n.texData.get(r.dataId), a = new hA(r.shape), o = [dA(r, i.complexTensorInfos.real), dA(r, i.complexTensorInfos.imag)]; return n.runWebGLProgram(a, o, o[0].dtype) } }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class pA { constructor(e) { this.outputShape = [], this.outputShape = P.backend_util.computeOutShape(e, 1), this.variableNames = e.map(((e, t) => `T${t}`)); const t = new Array(e.length - 1); t[0] = e[0][1]; for (let n = 1; n < t.length; n++)t[n] = t[n - 1] + e[n][1]; const n = [`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`]; for (let e = 1; e < t.length; e++) { const r = t[e - 1]; n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${r}));`) } const r = t.length, i = t[t.length - 1]; n.push(`else setOutput(getT${r}(yR, yC-${i}));`), this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class mA { constructor(e, t) { this.packedInputs = !0, this.packedOutput = !0, this.outputShape = [], this.outputShape = P.backend_util.computeOutShape(e, t); const n = this.outputShape, r = n.length, i = gk(r), a = XS("coords", r), o = ["x", "y", "z", "w", "u", "v"].slice(0, r); this.variableNames = e.map(((e, t) => `T${t}`)); const s = new Array(e.length - 1); s[0] = e[0][t]; for (let n = 1; n < s.length; n++)s[n] = s[n - 1] + e[n][t]; const u = o[t], l = o.slice(-2), c = o.join(); let h = `if (${u} < ${s[0]}) {\n return getChannel(\n getT0(${c}), vec2(${l.join()}));\n }`; for (let e = 1; e < s.length; e++) { const t = s[e - 1]; h += `\n if (${u} < ${s[e]} && ${u} >= ${s[e - 1]}) {\n return getChannel(\n getT${e}(${gA(o, u, t)}),\n vec2(${gA(l, u, t)}));\n }` } const d = s.length, f = s[s.length - 1]; h += `\n return getChannel(\n getT${d}(${gA(o, u, f)}),\n vec2(${gA(l, u, f)}));`, this.userCode = `\n float getValue(${o.map((e => "int " + e))}) {\n ${h}\n }\n\n void main() {\n ${i} coords = getOutputCoords();\n vec4 result = vec4(getValue(${a}), 0., 0., 0.);\n\n ${a[r - 1]} = ${a[r - 1]} + 1;\n if (${a[r - 1]} < ${n[r - 1]}) {\n result.g = getValue(${a});\n }\n\n ${a[r - 2]} = ${a[r - 2]} + 1;\n if (${a[r - 2]} < ${n[r - 2]}) {\n result.a = getValue(${a});\n }\n\n ${a[r - 1]} = ${a[r - 1]} - 1;\n if (${a[r - 2]} < ${n[r - 2]} &&\n ${a[r - 1]} < ${n[r - 1]}) {\n result.b = getValue(${a});\n }\n setOutput(result);\n }\n ` } } function gA(e, t, n) { const r = e.indexOf(t); return e.map(((e, t) => t === r ? `${e} - ${n}` : e)).join() } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function yA(e) { const { inputs: t, backend: n } = e, { input: r } = t; return w_({ inputs: { x: n.texData.get(r.dataId).complexTensorInfos.imag }, backend: n }) } const bA = { kernelName: P.Imag, backendName: "webgl", kernelFunc: yA }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function vA(e, t, n) { const r = e[0].dtype; if ("complex64" === r) { const r = e.map((e => nA({ inputs: { input: e }, backend: n }))), i = e.map((e => yA({ inputs: { input: e }, backend: n }))), a = vA(r, t, n), o = vA(i, t, n), s = S_({ inputs: { real: a, imag: o }, backend: n }); return r.forEach((e => n.disposeIntermediateTensorInfo(e))), i.forEach((e => n.disposeIntermediateTensorInfo(e))), n.disposeIntermediateTensorInfo(a), n.disposeIntermediateTensorInfo(o), s } let i = n.shouldExecuteOnCPU(e); if ("string" === r && (i = !0), i) { const i = e.map((e => { const r = P.util.sizeFromShape(e.shape.slice(t)); return U_({ inputs: { x: e }, backend: n, attrs: { shape: [-1, r] } }) })), a = i.map((e => ({ vals: n.readSync(e.dataId), shape: e.shape }))), o = P.backend_util.computeOutShape(i.map((e => e.shape)), 1), s = 1 === i[0].shape[0], u = aS(a, o, r, s), l = P.backend_util.computeOutShape(e.map((e => e.shape)), t), c = n.makeTensorInfo(l, r, u); return i.forEach((e => n.disposeIntermediateTensorInfo(e))), c } const a = e.filter((e => P.util.sizeFromShape(e.shape) > 0)), o = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") && a[0].shape.length > 1; if (1 === a.length) { const t = o ? new n_(e[0].shape, s_) : new u_(e[0].shape, s_); return n.runWebGLProgram(t, e, r) } const s = (0, P.env)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER"); if (a.length > s) { const e = []; for (let r = 0; r < a.length; r += s) { const i = a.slice(r, r + s); e.push(vA(i, t, n)) } const r = vA(e, t, n); for (const t of e) n.disposeIntermediateTensorInfo(t); return r } if (o) { const e = new mA(a.map((e => e.shape)), t); return n.runWebGLProgram(e, a, r) } const { tensors2D: u, outShape: l } = function (e, t, n) { const r = P.backend_util.computeOutShape(e.map((e => e.shape)), t), i = e.map((e => U_({ inputs: { x: e }, attrs: { shape: [-1, P.util.sizeFromShape(e.shape.slice(t))] }, backend: n }))); return { tensors2D: i, outShape: r } }(a, t, n), c = new pA(u.map((e => e.shape))), h = n.runWebGLProgram(c, u, r); u.forEach((e => n.disposeIntermediateTensorInfo(e))); const d = U_({ inputs: { x: h }, attrs: { shape: l }, backend: n }); return n.disposeIntermediateTensorInfo(h), d } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function xA(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r, a = P.util.parseAxisParam(i, t[0].shape)[0], o = t.map((e => e.shape)); P.backend_util.assertParamsConsistent(o, a); const s = P.backend_util.computeOutShape(t.map((e => e.shape)), a); if (0 === P.util.sizeFromShape(s)) return n.makeTensorInfo(s, t[0].dtype, []); const u = t.filter((e => P.util.sizeFromShape(e.shape) > 0)); return 1 === u.length ? w_({ inputs: { x: u[0] }, backend: n }) : vA(u, a, n) } const wA = { kernelName: P.Concat, backendName: "webgl", kernelFunc: xA }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class kA { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; const a = e.padInfo.top, o = e.padInfo.left, s = e.strideHeight, u = e.strideWidth, l = e.dilationHeight, c = e.dilationWidth, h = e.filterHeight, d = e.filterWidth, f = 4 * Math.floor(e.inChannels / 4), p = e.inChannels % 4, m = "channelsLast" === e.dataFormat, g = m ? 1 : 2, y = m ? 2 : 3, b = m ? 3 : 1; let v = "", x = ""; n && (v = r ? `float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `\n float activation(float x) {\n ${n}\n }\n `, x = "result = activation(result);"); const w = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${v}\n\n const ivec2 strides = ivec2(${s}, ${u});\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${h}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${f}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1 === p}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${f}) *\n getW(wR, wC, ${f}, d2);\n } else {\n dotProd +=\n getX(batch, ${f}, xR, xC) *\n getW(wR, wC, ${f}, d2);\n }\n\n } else if (${2 === p}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${f}, d2),\n getW(wR, wC, ${f} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${f}),\n getX(batch, xR, xC, ${f} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${f}, xR, xC),\n getX(batch, ${f} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3 === p}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${f}, d2),\n getW(wR, wC, ${f} + 1, d2),\n getW(wR, wC, ${f} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${f}),\n getX(batch, xR, xC, ${f} + 1),\n getX(batch, xR, xC, ${f} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${f}, xR, xC),\n getX(batch, ${f} + 1, xR, xC),\n getX(batch, ${f} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${w}\n ${x}\n setOutput(result);\n }\n ` } } class SA { constructor(e) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; const t = e.padInfo.front, n = e.padInfo.top, r = e.padInfo.left, i = e.strideDepth, a = e.strideHeight, o = e.strideWidth, s = e.dilationDepth, u = e.dilationHeight, l = e.dilationWidth, c = e.filterDepth, h = e.filterHeight, d = e.filterWidth, f = 4 * Math.floor(e.inChannels / 4), p = e.inChannels % 4; this.userCode = `\n const ivec3 strides = ivec3(${i}, ${a}, ${o});\n const ivec3 pads = ivec3(${t}, ${n}, ${r});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${c}; wF++) {\n int xF = xFCorner + wF * ${s};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${f}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1 === p}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${f}) *\n getW(wF, wR, wC, ${f}, d2);\n } else if (${2 === p}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${f}),\n getX(batch, xF, xR, xC, ${f} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${f}, d2),\n getW(wF, wR, wC, ${f} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3 === p}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${f}),\n getX(batch, xF, xR, xC, ${f} + 1),\n getX(batch, xF, xR, xC, ${f} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${f}, d2),\n getW(wF, wR, wC, ${f} + 1, d2),\n getW(wF, wR, wC, ${f} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class _A { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = kk(this.outputShape.length); const a = e.padInfo.left, o = e.strideWidth, s = e.dilationWidth, u = e.filterHeight, l = e.filterWidth, c = l; let h = "\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;"; for (let e = 0; e < l; e++)h += `\n vec4 xTexelC${2 * e};\n int xTexelC${2 * e}Ready;\n vec4 xTexelC${2 * e + 1};\n int xTexelC${2 * e + 1}Ready;\n vec4 xC${e};`; h += `\n for (int r = 0; r < ${u}; r++) {\n for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {\n `; for (let e = 0; e < l; e++)h += `\n xTexelC${2 * e} = vec4(0.0);\n xTexelC${2 * e}Ready = 0;\n xTexelC${2 * e + 1} = vec4(0.0);\n xTexelC${2 * e + 1}Ready = 0;\n xC${e} = vec4(0.0);`; h += "\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n "; for (let t = 0; t < (c + 1) / 2; t++) { const n = 2 * t; if (h += `\n xC = xCCorner + ${n * s};\n `, 1 === o) { if (n < l && (a % 2 == 1 ? (h += `\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `, h += 1 === s && n > 0 ? `\n xC${n} = vec4(xTexelC${n - 2}.zw, xTexelC${n}.xy);\n ` : `\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `) : h += `\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `, n + 1 < l)) { const e = a % 2 == 0 ? P.util.nearestLargerEven(s) : s; s % 2 == 0 && a % 2 == 1 || s % 2 != 0 && a % 2 != 1 ? (h += `\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.0);\n }\n xTexelC${n + 1}Ready = 1;\n }\n `, h += s > 1 ? `\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n + 1} = vec4(previous.zw, xTexelC${n + 1}.xy);\n } else {\n xC${n + 1} = vec4(0.0, 0.0, xTexelC${n + 1}.xy);\n }\n ` : `\n xC${n + 1} = vec4(xTexelC${n}.zw, xTexelC${n + 1}.xy);\n `) : h += 1 === e ? `\n xC${n + 1} = xTexelC${n};\n ` : `\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.0);\n }\n xTexelC${n + 1}Ready = 1;\n }\n\n xC${n + 1} = xTexelC${n + 1};\n ` } } else n < l && (a % 2 == 1 ? (h += `\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.0);\n }\n xTexelC${n + 1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n + 1}.zw);\n `, n + 1 < l && (h += `\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n + 1} = vec4(xTexelC${n + 1}.xy, final.xy);\n `)) : (h += `\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.);\n }\n xTexelC${n + 1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n + 1}.xy);\n `, n + 1 < l && (h += `\n xC${n + 1} = vec4(xTexelC${n}.zw, xTexelC${n + 1}.zw);\n `))); n < l && (h += `\n wTexel = getW(r, ${n}, d1, d2);\n dotProd += xC${n}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `, n + 1 < l && (h += `\n wTexel = getW(r, ${n + 1}, d1, d2);\n dotProd += xC${n + 1}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n + 1}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `)) } h += "\n }\n ", h += "\n }\n ", h += "\n }\n "; let d = "", f = ""; n && (d = r ? `vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `vec4 activation(vec4 x) {\n ${n}\n }`, f = "result = activation(result);"); const p = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${d}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${h}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${p}\n ${f}\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class CA { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec4" }, { name: "pad", type: "ivec2" }, { name: "stride", type: "ivec2" }, { name: "dilation", type: "ivec2" }, { name: "inChannels", type: "int" }, { name: "itemsPerBlockRow", type: "int" }, { name: "outWidth", type: "int" }], this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); const { dataFormat: n } = t, r = Qw(), i = "channelsLast" === n, a = i ? 1 : 2, o = i ? 2 : 3, s = this.enableShapeUniforms ? "if(blockIndex < outShape[2] && pos < outShape[1]) {" : `if(blockIndex < ${e[2]} && pos < ${e[1]}) {`; let u = ""; for (let e = 0; e <= 1; e++)for (let t = 0; t <= 1; t++)u += `\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${s}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${a}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${o}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${i}) {\n innerDims = vec2(d1, ch);\n result[${2 * e + t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2 * e + t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `; this.userCode = `\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function AA(e, t) { const n = e.length; return n >= 3 ? t ? [...e.slice(0, -3), e[n - 3] * e[n - 2], e[n - 1]] : [...e.slice(0, -3), e[n - 3], e[n - 2] * e[n - 1]] : !t && 1 === n && e[0] > 1 ? [e[0], 1] : null } function TA({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const u = e.shape, l = r.texData.get(e.dataId), c = n.inChannels, h = u[0] * u[1] * u[2], d = n.outChannels, f = "channelsLast" === n.dataFormat, p = !1; let m; const g = []; if (null != a) { const e = AA(a.shape, f); null != e && (a = U_({ inputs: { x: a }, backend: r, attrs: { shape: e } }), g.push(a)) } if (null != i) { const e = AA(i.shape, f); null != e && (i = U_({ inputs: { x: i }, backend: r, attrs: { shape: e } }), g.push(i)) } if (!((1 === h || 1 === d) && c > 1e3) && l.isPacked && f && null != l.texture && u[2] % 2 != 0 && P.util.arraysEqual(l.shape.slice(-3), u.slice(-3))) { const c = u[0] * u[1] * (u[2] + 1), h = { dataId: e.dataId, shape: [1, c, n.inChannels], dtype: e.dtype }, d = l.shape; l.shape = l.shape.slice(), l.shape[l.shape.length - 2]++, P.util.assert(zw(l.shape, h.shape), (() => `packed reshape ${l.shape} to ${h.shape} isn't free`)); const f = U_({ inputs: { x: t }, backend: r, attrs: { shape: [1, n.inChannels, n.outChannels] } }); g.push(f); const y = eC({ a: h, b: f, backend: r, transposeA: false, transposeB: p, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }), b = r.texData.get(y.dataId); P.util.assert(b.isPacked, (() => "batchMatMul result is expected to be packed")), l.shape = d, b.shape = n.outShape, m = w_({ inputs: { x: y }, backend: r }), m.shape = n.outShape, g.push(y) } else { const u = n.outHeight * n.outWidth, l = U_({ inputs: { x: e }, backend: r, attrs: { shape: f ? [n.batchSize, u, n.inChannels] : [n.batchSize, n.inChannels, u] } }), c = U_({ inputs: { x: t }, backend: r, attrs: { shape: [1, n.inChannels, n.outChannels] } }), h = eC({ a: f ? l : c, b: f ? c : l, transposeA: !f, transposeB: p, backend: r, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }); m = U_({ inputs: { x: h }, backend: r, attrs: { shape: n.outShape } }), g.push(l), g.push(c), g.push(h) } for (const e of g) r.disposeIntermediateTensorInfo(e); return m } function EA({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const { filterWidth: u, filterHeight: l, inChannels: c, outWidth: h, outHeight: d, dataFormat: f } = n, p = "channelsLast" === f, m = u * l * c, g = d * h, y = [n.batchSize, m, g], b = []; if (null != a) { const e = AA(a.shape, p); null != e && (a = U_({ inputs: { x: a }, backend: r, attrs: { shape: e } }), b.push(a)) } if (null != i) { const e = AA(i.shape, p); null != e && (i = U_({ inputs: { x: i }, backend: r, attrs: { shape: e } }), b.push(i)) } const v = U_({ inputs: { x: t }, backend: r, attrs: { shape: [1, m, P.util.sizeFromShape(t.shape) / m] } }); b.push(v); const x = new CA(y, n), w = [e.shape, [n.padInfo.top, n.padInfo.left], [n.strideHeight, n.strideWidth], [n.dilationHeight, n.dilationWidth], [n.inChannels], [n.filterWidth * n.inChannels], [n.outWidth]], k = r.runWebGLProgram(x, [e], "float32", w), S = U_({ inputs: { x: k }, backend: r, attrs: { shape: y } }); b.push(k), b.push(S); const _ = null != i, C = null != a, A = "leakyrelu" === s, T = s ? $_(s, !0) : null, E = new R_(p ? S.shape : v.shape, p ? v.shape : S.shape, p ? [n.batchSize, g, n.outChannels] : [n.batchSize, n.outChannels, g], !0, !1, _, T, C, A), N = p ? [S, v] : [v, S]; if (i && N.push(i), C && N.push(a), A) { const e = r.makeTensorInfo([], "float32", P.util.createScalarValue(o, "float32")); N.push(e), b.push(e) } const I = r.runWebGLProgram(E, N, "float32"), M = U_({ inputs: { x: I }, backend: r, attrs: { shape: n.outShape } }); b.push(I); for (const e of b) r.disposeIntermediateTensorInfo(e); return M } const NA = { + kernelName: P.Conv2D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dataFormat: u, dilations: l, dimRoundingMode: c } = r, h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, l, s, c, !1, h); let f; if (1 !== d.filterHeight || 1 !== d.filterWidth || 1 !== d.dilationHeight || 1 !== d.dilationWidth || 1 !== d.strideHeight || 1 !== d.strideWidth || "SAME" !== d.padInfo.type && "VALID" !== d.padInfo.type) if (d.strideWidth <= 2 && "channelsLast" === h && (0, P.env)().getBool("WEBGL_EXP_CONV")) { const e = new _A(d), t = [[d.padInfo.top, d.padInfo.left], [d.strideHeight, d.strideWidth], [d.dilationHeight, d.dilationWidth], [d.inHeight, d.inWidth]]; f = n.runWebGLProgram(e, [i, a], "float32", t) } else if ((0, P.env)().getBool("WEBGL_CONV_IM2COL")) f = EA({ x: i, filter: a, convInfo: d, backend: n }); else { const e = new kA(d); f = n.runWebGLProgram(e, [i, a], "float32") } else f = TA({ x: i, filter: a, convInfo: d, backend: n }); const p = U_({ inputs: { x: f }, backend: n, attrs: { shape: d.outShape } }); return n.disposeIntermediateTensorInfo(f), p } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class IA { constructor(e) { this.variableNames = ["x", "dy"], this.outputShape = e.filterShape; const t = e.strideHeight, n = e.strideWidth, r = e.padInfo.top, i = e.padInfo.left, a = "channelsLast" === e.dataFormat; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${i};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n ${a ? "float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);" : "float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);"}\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class MA { constructor(e) { this.variableNames = ["dy", "W"], this.outputShape = e.inShape; const t = e.filterHeight, n = e.filterWidth, r = e.strideHeight, i = e.strideWidth, a = "channelsLast" === e.dataFormat, o = t - 1 - e.padInfo.top, s = n - 1 - e.padInfo.left, u = a ? 1 : 2, l = a ? 2 : 3, c = a ? 3 : 1; this.userCode = `\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${a}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class FA { constructor(e) { this.variableNames = ["x", "dy"], this.outputShape = e.filterShape; const t = e.strideDepth, n = e.strideHeight, r = e.strideWidth, i = e.padInfo.front, a = e.padInfo.top, o = e.padInfo.left; this.userCode = `\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yF = 0; yF < ${e.outDepth}; yF++) {\n int xF = wF + yF * ${t} - ${i};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${a};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${r} - ${o};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class DA { constructor(e) { this.variableNames = ["dy", "W"], this.outputShape = e.inShape; const t = e.filterDepth, n = e.filterHeight, r = e.filterWidth, i = e.strideDepth, a = e.strideHeight, o = e.strideWidth, s = t - 1 - e.padInfo.front, u = n - 1 - e.padInfo.top, l = r - 1 - e.padInfo.left; this.userCode = `\n const ivec3 pads = ivec3(${s}, ${u}, ${l});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${t}; wF++) {\n float dyF = float(dyFCorner + wF) / ${i}.0;\n\n if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${t} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${a}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${o}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${r} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const $A = { + kernelName: P.Conv2DBackpropFilter, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, dataFormat: u, dimRoundingMode: l, filterShape: c } = r, h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, c, o, 1, s, l, !1, h), f = new IA(d); return n.runWebGLProgram(f, [i, a], "float32") } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class RA { constructor(e) { this.variableNames = ["dy", "W"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "strides", type: "vec2" }], this.outputShape = e.inShape, this.enableShapeUniforms = kk(this.outputShape.length); const t = e.filterHeight, n = e.filterWidth, r = t - 1 - e.padInfo.top, i = n - 1 - e.padInfo.left; this.userCode = `\n const ivec2 pads = ivec2(${r}, ${i});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n\n ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n vec4 result = vec4(0.);\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / strides[0];\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n int wCPerm = ${n} - 1 - wC;\n\n float dyC = float(dyCCorner + wC) / strides[1];\n bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0)\n && (fract(dyC) == 0.0);\n int idyC = int(dyC);\n\n float dyC2 = float(dyCCorner + wC + 1) / strides[1];\n bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0)\n && (fract(dyC2) == 0.0);\n int idyC2 = int(dyC2);\n\n if (idyCVal && idyCVal2) {\n for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?\n dySample : getDy(batch, idyR, idyC2, d2);\n\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n\n dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample2.xy : dySample2.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal) {\n for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal2) {\n for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC2, d2);\n vec2 dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n }\n }\n }\n setOutput(result);\n }\n ` } } const OA = { + kernelName: P.Conv2DBackpropInput, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { inputShape: o, strides: s, pad: u, dataFormat: l, dimRoundingMode: c } = r, h = P.backend_util.convertConv2DDataFormat(l), d = P.backend_util.computeConv2DInfo(o, a.shape, s, 1, u, c, !1, h); if ((0, P.env)().getBool("WEBGL_PACK_CONV2DTRANSPOSE") && "channelsLast" === h) { const e = [[d.strideHeight, d.strideWidth]], t = new RA(d); return n.runWebGLProgram(t, [i, a], "float32", e) } { const e = new MA(d); return n.runWebGLProgram(e, [i, a], "float32") } } + }; const zA = { + kernelName: P.Conv3D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r, l = P.backend_util.computeConv3DInfo(i.shape, a.shape, o, u, s), c = new SA(l); return n.runWebGLProgram(c, [i, a], "float32") } + }; const PA = { + kernelName: P.Conv3DBackpropFilterV2, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, filterShape: u } = r, l = P.backend_util.computeConv3DInfo(i.shape, u, o, 1, s), c = new FA(l); return n.runWebGLProgram(c, [i, a], "float32") } + }; const BA = { + kernelName: P.Conv3DBackpropInputV2, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { pad: o, strides: s, inputShape: u } = r, l = P.backend_util.computeConv3DInfo(u, a.shape, s, 1, o), c = new DA(l); return n.runWebGLProgram(c, [i, a], "float32") } + }, LA = F_({ opSnippet: M_ + "\n return cos(x);\n", packedOpSnippet: `\n vec4 result = cos(x);\n bvec4 isNaN = isnan(x);\n ${v_}\n return result;\n` }), jA = { kernelName: P.Cos, backendName: "webgl", kernelFunc: LA }, UA = F_({ opSnippet: "\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n" }), WA = { kernelName: P.Cosh, backendName: "webgl", kernelFunc: UA }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class VA { constructor(e, t, n, r, i) { this.variableNames = ["Image", "Boxes", "BoxInd"], this.outputShape = []; const [a, o, s, u] = e, [l] = t, [c, h] = n; this.outputShape = [l, c, h, u]; const d = "bilinear" === r ? 1 : 0, [f, p] = [o - 1 + ".0", s - 1 + ".0"], [m, g, y] = c > 1 ? ["" + (o - 1) / (c - 1), "(y2-y1) * height_ratio", `y1*${f} + float(y)*(height_scale)`] : ["0.0", "0.0", `0.5 * (y1+y2) * ${f}`], [b, v, x] = h > 1 ? ["" + (s - 1) / (h - 1), "(x2-x1) * width_ratio", `x1*${p} + float(x)*(width_scale)`] : ["0.0", "0.0", `0.5 * (x1+x2) * ${p}`]; this.userCode = `\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${a}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${v};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${f} ) {\n setOutput(float(${i}));\n return;\n }\n float in_x = ${x};\n if( in_x < 0.0 || in_x > ${p} ) {\n setOutput(float(${i}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const GA = { kernelName: P.CropAndResize, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { image: i, boxes: a, boxInd: o } = t, { cropSize: s, method: u, extrapolationValue: l } = r, c = new VA(i.shape, a.shape, s, u, l); return n.runWebGLProgram(c, [i, a, o], "float32") } }; var HA, qA; (qA = HA || (HA = {})).Prod = "*", qA.Sum = "+"; class YA { constructor(e, t, n, r) { this.op = e, this.outputShape = t, this.variableNames = ["x"], this.customUniforms = [{ name: "index", type: "float" }]; const i = this.outputShape.length, a = this.op === HA.Prod ? "1.0" : "0.0", o = n ? a : `getX(${XA(i, "coords", this.op)})`, s = this.outputShape[this.outputShape.length - 1]; let u = "", l = ""; n ? (u = r ? "end != " + (s - 1) : "end != 0", l = r ? "end + 1" : "end - 1") : (u = r ? `end + pow2 < ${s}` : "end >= pow2", l = r ? "end + pow2" : "end - pow2"), this.userCode = `\n void main() {\n ${gk(i)} coords = getOutputCoords();\n int end = ${KA(i, "coords", this.op)};\n float val = ${o};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${l};\n ${KA(i, "coords", this.op)} = idx;\n val ${this.op}= getX(${XA(i, "coords", this.op)});\n }\n setOutput(val);\n }\n ` } } function XA(e, t, n) { if (1 === e) return `${t}`; if (2 === e) return `${t}.x, ${t}.y`; if (3 === e) return `${t}.x, ${t}.y, ${t}.z`; if (4 === e) return `${t}.x, ${t}.y, ${t}.z, ${t}.w`; throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`) } function KA(e, t, n) { if (1 === e) return `${t}`; if (2 === e) return `${t}.y`; if (3 === e) return `${t}.z`; if (4 === e) return `${t}.w`; throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`) } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ZA(e, t, n, r, i, a) { const o = t.shape.length, s = P.backend_util.getAxesPermutation([r], o); let u = t; null != s && (u = J_({ inputs: { x: t }, backend: n, attrs: { perm: s } })); const l = P.backend_util.getInnerMostAxes(1, o)[0]; if (l !== o - 1) throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length - 1} but got axis=${r}`); const c = u.shape[l]; let h = w_({ inputs: { x: u }, backend: n }); for (let t = 0; t <= Math.ceil(Math.log2(c)) - 1; t++) { const r = new YA(e, u.shape, !1, a), i = [[t]], o = h; h = n.runWebGLProgram(r, [h], h.dtype, i), n.disposeIntermediateTensorInfo(o) } if (i) { const t = new YA(e, u.shape, i, a), r = h; h = n.runWebGLProgram(t, [h], h.dtype), n.disposeIntermediateTensorInfo(r) } if (null != s) { const e = J_({ inputs: { x: h }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(s) } }); return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(u), e } return h } const JA = { + kernelName: P.Cumprod, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; return ZA(HA.Prod, i, n, a, o, s) } + }; const QA = { + kernelName: P.Cumsum, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; return ZA(HA.Sum, i, n, a, o, s) } + }; const eT = { + kernelName: P.DenseBincount, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o, binaryOutput: s } = r; if (1 === i.shape.length) { const e = n.readSync(i.dataId), t = n.readSync(a.dataId), r = eS(e, t, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, r) } if (2 === i.shape.length) { const e = n.bufferSync(i), t = n.bufferSync(a), r = tS(e, t, o, s); return n.makeTensorInfo(r.shape, a.dtype, r.values) } throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${i.shape.length}.`) } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class tT { constructor(e, t, n) { this.variableNames = ["x"], this.outputShape = [], this.outputShape = e, this.blockSize = t, this.dataFormat = n, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${t};\n int offset_h = imod(h, ${t});\n int in_w = w / ${t};\n int offset_w = imod(w, ${t});\n int offset_d = (offset_h * ${t} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n ` } getHeightCoordString() { return "NHWC" === this.dataFormat ? "coords[1]" : "coords[2]" } getWidthCoordString() { return "NHWC" === this.dataFormat ? "coords[2]" : "coords[3]" } getDepthCoordString() { return "NHWC" === this.dataFormat ? "coords[3]" : "coords[1]" } getOutputDepthSize() { return "NHWC" === this.dataFormat ? this.outputShape[3] : this.outputShape[1] } getInputSamplingString() { return "NHWC" === this.dataFormat ? "getX(b, in_h, in_w, in_d)" : "getX(b, in_d, in_h, in_w)" } } const nT = { + kernelName: P.DepthToSpace, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockSize: a, dataFormat: o } = r, s = i.shape[0], u = ("NHWC" === o ? i.shape[1] : i.shape[2]) * a, l = ("NHWC" === o ? i.shape[2] : i.shape[3]) * a, c = ("NHWC" === o ? i.shape[3] : i.shape[1]) / (a * a), h = new tT("NHWC" === o ? [s, u, l, c] : [s, c, u, l], a, o); return n.runWebGLProgram(h, [i], i.dtype) } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rT { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = kk(this.outputShape.length); const a = e.filterHeight, o = e.filterWidth, s = e.outChannels / e.inChannels; let u = "", l = ""; n && (u = r ? `float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `\n float activation(float x) {\n ${n}\n }\n `, l = "result = activation(result);"); const c = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${s};\n int q = d2 - d1 * ${s};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${a}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${o}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${c}\n ${l}\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class iT { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = kk(this.outputShape.length); const a = e.outChannels / e.inChannels, o = e.padInfo.left, s = e.strideWidth, u = e.dilationWidth, l = e.filterHeight, c = e.filterWidth, h = c; let d = "\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;"; for (let e = 0; e < c; e++)d += `\n vec4 xTexelC${2 * e};\n int xTexelC${2 * e}Ready;\n vec4 xTexelC${2 * e + 1};\n int xTexelC${2 * e + 1}Ready;\n vec4 xC${e};`; d += `\n for (int r = 0; r < ${l}; r++) {\n `; for (let e = 0; e < c; e++)d += `\n xTexelC${2 * e} = vec4(0.0);\n xTexelC${2 * e}Ready = 0;\n xTexelC${2 * e + 1} = vec4(0.0);\n xTexelC${2 * e + 1}Ready = 0;\n xC${e} = vec4(0.0);`; d += "\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n "; for (let e = 0; e < (h + 1) / 2; e++) { const t = 2 * e; if (d += `\n xC = xCCorner + ${t * u};\n `, 1 === s) { if (t < c && (o % 2 == 1 ? (d += `\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `, d += 1 === u && t > 0 ? `\n xC${t} = vec4(xTexelC${t - 2}.zw, xTexelC${t}.xy);\n ` : `\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `) : d += `\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `, t + 1 < c)) { const e = o % 2 == 0 ? P.util.nearestLargerEven(u) : u; u % 2 == 0 && o % 2 == 1 || u % 2 != 0 && o % 2 != 1 ? (d += `\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.0);\n }\n xTexelC${t + 1}Ready = 1;\n }\n `, d += u > 1 ? `\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${t + 1} = vec4(previous.zw, xTexelC${t + 1}.xy);\n } else {\n xC${t + 1} = vec4(0.0, 0.0, xTexelC${t + 1}.xy);\n }\n ` : `\n xC${t + 1} = vec4(xTexelC${t}.zw, xTexelC${t + 1}.xy);\n `) : d += 1 === e ? `\n xC${t + 1} = xTexelC${t};\n ` : `\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.0);\n }\n xTexelC${t + 1}Ready = 1;\n }\n\n xC${t + 1} = xTexelC${t + 1};\n ` } } else t < c && (o % 2 == 1 ? (d += `\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.0);\n }\n xTexelC${t + 1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t + 1}.zw);\n `, t + 1 < c && (d += `\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t + 1} = vec4(xTexelC${t + 1}.xy, final.xy);\n `)) : (d += `\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.);\n }\n xTexelC${t + 1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t + 1}.xy);\n `, t + 1 < c && (d += `\n xC${t + 1} = vec4(xTexelC${t}.zw, xTexelC${t + 1}.zw);\n `))); t < c && (d += `\n wTexel = getW(r, ${t}, d1, q);\n dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz);\n `, t + 1 < c && (d += `\n wTexel = getW(r, ${t + 1}, d1, q);\n dotProd += xC${t + 1} * vec4(wTexel.xz, wTexel.xz);\n `)) } d += "\n }\n ", d += "\n }\n "; let f = "", p = ""; n && (f = r ? `vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `vec4 activation(vec4 x) {\n ${n}\n }`, p = "result = activation(result);"); const m = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${f}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${a};\n int q = d2 - d1 * ${a};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${d}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${m}\n ${p}\n setOutput(result);\n }\n ` } } const aT = { + kernelName: P.DepthwiseConv2dNative, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u, dimRoundingMode: l } = r; let c = u; null == c && (c = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, c), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`)); const h = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, c, s, l, !0); let d; d = (0, P.env)().getBool("WEBGL_PACK_DEPTHWISECONV") && h.strideWidth <= 2 && h.outChannels / h.inChannels == 1 ? new iT(h) : new rT(h); const f = [[h.padInfo.top, h.padInfo.left], [h.strideHeight, h.strideWidth], [h.dilationHeight, h.dilationWidth], [h.inHeight, h.inWidth]]; return n.runWebGLProgram(d, [i, a], "float32", f) } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class oT { constructor(e) { this.variableNames = ["x", "dy"], this.outputShape = e.filterShape; const t = e.strideHeight, n = e.strideWidth, r = e.padInfo.top, i = e.padInfo.left, a = e.outChannels / e.inChannels; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${a} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${i};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class sT { constructor(e) { this.variableNames = ["dy", "W"], this.outputShape = e.inShape; const t = e.filterHeight, n = e.filterWidth, r = e.strideHeight, i = e.strideWidth, a = t - 1 - e.padInfo.top, o = n - 1 - e.padInfo.left, s = e.outChannels / e.inChannels; this.userCode = `\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${s}; dm++) {\n int d2 = d1 * ${s} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const uT = { + kernelName: P.DepthwiseConv2dNativeBackpropFilter, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, filterShape: c } = r, h = P.backend_util.computeConv2DInfo(i.shape, c, o, s, u, l, !0), d = new oT(h); return n.runWebGLProgram(d, [i, a], "float32") } + }; const lT = { + kernelName: P.DepthwiseConv2dNativeBackpropInput, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, inputShape: c } = r, h = P.backend_util.computeConv2DInfo(c, a.shape, o, s, u, l, !0), d = new sT(h); return n.runWebGLProgram(d, [i, a], "float32") } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class cT { constructor(e) { this.variableNames = ["X"], this.outputShape = [e, e], this.userCode = "\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n " } } const hT = { + kernelName: P.Diag, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = [...r.shape, ...r.shape], a = P.util.sizeFromShape(r.shape), o = U_({ inputs: { x: r }, backend: n, attrs: { shape: [a] } }), s = new cT(a), u = n.runWebGLProgram(s, [o], o.dtype), l = U_({ inputs: { x: u }, backend: n, attrs: { shape: i } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(u), l } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class dT { constructor(e) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; const { inHeight: t, inWidth: n, padInfo: r, strideHeight: i, strideWidth: a, filterHeight: o, filterWidth: s, dilationHeight: u, dilationWidth: l } = e, { top: c, left: h } = r; this.userCode = `\n const ivec2 strides = ivec2(${i}, ${a});\n const ivec2 pads = ivec2(${c}, ${h});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${o}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${s}; w++) {\n int wIn = wBeg + w * ${l};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n ` } } const fT = { + kernelName: P.Dilation2D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r, l = P.backend_util.computeDilation2DInfo(i.shape, a.shape, o, s, "NHWC", u); let c; const h = new dT(l); c = n.runWebGLProgram(h, [i, a], "float32"); const d = U_({ inputs: { x: c }, backend: n, attrs: { shape: l.outShape } }); return n.disposeIntermediateTensorInfo(c), d } + }; const pT = { + kernelName: P.Einsum, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { equation: i } = r, a = t, { allDims: o, summedDims: s, idDims: u } = P.backend_util.decodeEinsumEquation(i, a.length); P.backend_util.checkEinsumDimSizes(o.length, u, a); const { path: l, steps: c } = P.backend_util.getEinsumComputePath(s, u), h = c.length; let d = null, f = o.length; const p = []; for (let e = 0; e < h; ++e) { for (const t of c[e]) { const { permutationIndices: e, expandDims: r } = P.backend_util.getEinsumPermutation(f, u[t]); let i; P.backend_util.isIdentityPermutation(e) ? i = a[t] : (i = J_({ inputs: { x: a[t] }, backend: n, attrs: { perm: e } }), p.push(i)); const o = i.shape.slice(); for (let e = 0; e < r.length; ++e)o.splice(r[e], 0, 1); P.util.arraysEqual(i.shape, o) || (i = U_({ inputs: { x: i }, backend: n, attrs: { shape: o } }), p.push(i)), null === d ? d = i : (d = L_({ inputs: { a: i, b: d }, backend: n }), p.push(d)) } e < h - 1 && (l[e] >= 0 && (d = K_({ inputs: { x: d }, backend: n, attrs: { axis: l[e] - (o.length - f), keepDims: !1 } }), p.push(d)), f--) } for (const e of p) e !== d && n.disposeIntermediateTensorInfo(e); return d } + }, mT = F_({ opSnippet: "return (x >= 0.0) ? x : (exp(x) - 1.0);", packedOpSnippet: "\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n" }), gT = { kernelName: P.Elu, backendName: "webgl", kernelFunc: mT }, yT = { kernelName: P.EluGrad, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n } = e, { dy: r, y: i } = t, a = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n", r.shape, i.shape) : new b_("return (b >= 0.0) ? a : a * (b + 1.0);", r.shape, i.shape); return n.runWebGLProgram(a, [r, i], r.dtype) } }, bT = D_({ opSnippet: "return float(a == b);", packedOpSnippet: "\n return vec4(equal(a, b));\n", dtype: "bool", cpuKernelImpl: oS }), vT = { kernelName: P.Equal, backendName: "webgl", kernelFunc: bT }, xT = F_({ opSnippet: `\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${P.backend_util.ERF_P};\n float a1 = ${P.backend_util.ERF_A1};\n float a2 = ${P.backend_util.ERF_A2};\n float a3 = ${P.backend_util.ERF_A3};\n float a4 = ${P.backend_util.ERF_A4};\n float a5 = ${P.backend_util.ERF_A5};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n` }), wT = { kernelName: P.Erf, backendName: "webgl", kernelFunc: xT }, kT = F_({ opSnippet: M_ + "\n return exp(x);\n", packedOpSnippet: "\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n", cpuKernelImpl: sS, dtype: "float32" }), ST = { kernelName: P.Exp, backendName: "webgl", kernelFunc: kT }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function _T(e) { const { inputs: t, attrs: n, backend: r } = e, { dim: i } = n, { input: a } = t, o = a.shape.length, s = a.shape.slice(); let u = i; return i < 0 && (P.util.assert(-(o + 1) <= i, (() => `Axis must be in the interval [${-(o + 1)}, ${o}]`)), u = o + i + 1), s.splice(u, 0, 1), U_({ inputs: { x: a }, backend: r, attrs: { shape: s } }) } const CT = { kernelName: P.ExpandDims, backendName: "webgl", kernelFunc: _T }, AT = "return exp(x) - 1.0;", TT = F_({ opSnippet: AT, packedOpSnippet: AT, cpuKernelImpl: uS }), ET = { kernelName: P.Expm1, backendName: "webgl", kernelFunc: TT }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class NT { constructor(e, t, n) { this.variableNames = ["real", "imag"]; const r = t[1]; this.outputShape = t; const i = n ? `2.0 * ${Math.PI}` : `-2.0 * ${Math.PI}`, a = n ? `${r}.0` : "1.0"; let o; if ("real" === e) o = "return real * expR - imag * expI;"; else { if ("imag" !== e) throw new Error(`FFT component must be either "real" or "imag", got ${e}.`); o = "return real * expI + imag * expR;" } this.userCode = `\n const float exponentMultiplier = ${i};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${o}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${r});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${r}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${a};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function IT(e, t, n) { const r = n.texData.get(e.dataId), i = P.util.sizeFromShape(e.shape), a = e.shape[e.shape.length - 1], o = U_({ inputs: { x: e }, backend: n, attrs: { shape: [i / a, a] } }), s = o.shape, u = new NT("real", s, t), l = new NT("imag", s, t), c = [{ dataId: r.complexTensorInfos.real.dataId, dtype: r.complexTensorInfos.real.dtype, shape: s }, { dataId: r.complexTensorInfos.imag.dataId, dtype: r.complexTensorInfos.imag.dtype, shape: s }], h = n.runWebGLProgram(u, c, "float32"), d = n.runWebGLProgram(l, c, "float32"), f = S_({ inputs: { real: h, imag: d }, backend: n }); n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(d); const p = U_({ inputs: { x: f }, backend: n, attrs: { shape: e.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(f), p } const MT = { + kernelName: P.FFT, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { input: r } = t; return IT(r, !1, n) } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class FT { constructor(e, t) { this.outputShape = [], this.customUniforms = [{ name: "value", type: "float" }], this.variableNames = ["x"], this.outputShape = e, this.userCode = "\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n " } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function DT(e) { const { backend: t, attrs: n } = e, { shape: r, value: i } = n; let { dtype: a } = n; if (a = a || P.util.inferDtype(i), "string" === a) { const e = P.util.getArrayFromDType(a, P.util.sizeFromShape(r)); return e.fill(i), t.makeTensorInfo(r, a, e) } { const e = new FT(r, i), n = [[i]]; return t.runWebGLProgram(e, [], a, n) } } const $T = { kernelName: P.Fill, backendName: "webgl", kernelFunc: DT }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class RT { constructor(e) { this.variableNames = ["Image"], this.outputShape = []; const t = e[2]; this.outputShape = e, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const OT = { kernelName: P.FlipLeftRight, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t }) => { const { image: n } = e, r = t, i = new RT(n.shape); return r.runWebGLProgram(i, [n], n.dtype) } }, zT = "return floor(x);", PT = F_({ opSnippet: zT, packedOpSnippet: zT, cpuKernelImpl: lS }), BT = { kernelName: P.Floor, backendName: "webgl", kernelFunc: PT }, LT = D_({ opSnippet: "\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n", packedOpSnippet: "\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n", dtype: "int32" }), jT = { kernelName: P.FloorDiv, backendName: "webgl", kernelFunc: LT }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class UT { constructor(e) { this.variableNames = ["A"]; const t = Qw(), [n, r] = e; this.outputShape = e, this.userCode = `\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n ` } } + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class WT { constructor(e) { this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0; const t = Qw(), [n, r] = e; this.outputShape = e, this.userCode = `\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const VT = { kernelName: P.FromPixels, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e; let { pixels: i } = t; const { numChannels: a } = r, o = "undefined" != typeof HTMLVideoElement && i instanceof HTMLVideoElement, s = "undefined" != typeof HTMLImageElement && i instanceof HTMLImageElement, [u, l] = o ? [i.videoWidth, i.videoHeight] : [i.width, i.height], c = [l, u], h = [l, u, a]; if (s || o) { const e = (0, P.env)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"); null != GT && e === HT || (HT = e, GT = document.createElement("canvas").getContext("2d", { willReadFrequently: HT })), GT.canvas.width = u, GT.canvas.height = l, GT.drawImage(i, 0, 0, u, l), i = GT.canvas } const d = n.makeTensorInfo(c, "int32"); n.texData.get(d.dataId).usage = Hx.PIXELS, n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId), i); const f = (0, P.env)().getBool("WEBGL_PACK") ? new WT(h) : new UT(h), p = n.runWebGLProgram(f, [d], "int32"); return n.disposeData(d.dataId), p } }; let GT, HT = (0, P.env)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"); const qT = { + kernelName: P.FusedConv2D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r, m = P.backend_util.convertConv2DDataFormat(c), g = P.backend_util.computeConv2DInfo(i.shape, a.shape, u, h, l, d, !1, m); let y; const b = [], v = null != o, x = null != s, w = "leakyrelu" === f, k = () => { const e = [i, a], t = (e, t) => { if ("NCHW" === t && 1 === e.shape.length && 1 !== e.shape[0]) { const t = U_({ inputs: { x: e }, backend: n, attrs: { shape: [e.shape[0], 1, 1] } }); return b.push(t), t } return e }; if (v && e.push(t(o, c)), x && e.push(t(s, c)), w) { const t = n.makeTensorInfo([], "float32", P.util.createScalarValue(p, "float32")); e.push(t), b.push(t) } return e }; if (1 !== g.filterHeight || 1 !== g.filterWidth || 1 !== g.dilationHeight || 1 !== g.dilationWidth || 1 !== g.strideHeight || 1 !== g.strideWidth || "SAME" !== g.padInfo.type && "VALID" !== g.padInfo.type) if (g.strideWidth <= 2 && "channelsLast" === m && (0, P.env)().getBool("WEBGL_EXP_CONV")) { const e = f ? $_(f, !0) : null, t = new _A(g, v, e, x, w), r = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], i = k(); y = n.runWebGLProgram(t, i, "float32", r) } else if ((0, P.env)().getBool("WEBGL_CONV_IM2COL")) y = EA({ x: i, filter: a, convInfo: g, backend: n, bias: o, activation: f, preluActivationWeights: s, leakyreluAlpha: p }); else { const e = f ? $_(f, !1) : null, t = new kA(g, v, e, x, w), r = k(); y = n.runWebGLProgram(t, r, "float32") } else y = TA({ x: i, filter: a, convInfo: g, backend: n, bias: o, activation: f, preluActivationWeights: s, leakyreluAlpha: p }); const S = U_({ inputs: { x: y }, backend: n, attrs: { shape: g.outShape } }); return b.push(y), b.forEach((e => n.disposeIntermediateTensorInfo(e))), S } + }; const YT = { + kernelName: P.FusedDepthwiseConv2D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dilations: c, dimRoundingMode: h, activation: d, leakyreluAlpha: f } = r, p = []; let m = c; null == m && (m = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(u, m), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`)); const g = P.backend_util.computeConv2DInfo(i.shape, a.shape, u, m, l, h, !0), y = (0, P.env)().getBool("WEBGL_PACK_DEPTHWISECONV") && g.strideWidth <= 2 && g.outChannels / g.inChannels == 1, b = d ? $_(d, y) : null, v = [i, a], x = null != o, w = null != s, k = "leakyrelu" === d; if (x && v.push(o), w && v.push(s), k) { const e = n.makeTensorInfo([], "float32", P.util.createScalarValue(f, "float32")); v.push(e), p.push(e) } let S; S = y ? new iT(g, x, b, w, k) : new rT(g, x, b, w, k); const _ = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], C = n.runWebGLProgram(S, v, "float32", _); return p.forEach((e => n.disposeIntermediateTensorInfo(e))), C } + }; class XT { constructor(e, t, n, r) { this.sliceDim = e, this.strides = t, this.paramsShape = r, this.variableNames = ["x", "indices"], this.outputShape = n; const i = gk(n.length); let a = "\n int index;"; for (let e = 0; e < this.sliceDim; e++)a += `\n index = round(getIndices(coords[0], ${e}));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${this.paramsShape[e]};\n flattenIndex += index * ${this.strides[e]};`; this.userCode = `\n void main() {\n ${i} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n\n ${a}\n\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n ` } } const KT = { + kernelName: P.GatherNd, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { params: r, indices: i } = t, a = i.shape, o = a[a.length - 1], s = P.util.sizeFromShape(r.shape), [u, l, c, h] = P.backend_util.prepareAndValidate(r, i), d = U_({ inputs: { x: i }, backend: n, attrs: { shape: [l, o] } }), f = U_({ inputs: { x: r }, backend: n, attrs: { shape: [P.util.sizeFromShape(r.shape) / c, c] } }); if (n.shouldExecuteOnCPU([r, i]) || "string" === r.dtype) { const e = n.readSync(i.dataId), t = n.bufferSync(r), a = cS(e, t, r.dtype, l, o, c, h, r.shape, s); return n.makeTensorInfo(u, r.dtype, a.values) } const p = new XT(o, h, [l, c], r.shape), m = n.runWebGLProgram(p, [f, d], f.dtype), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: u } }); return n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(m), g } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ZT { constructor(e, t) { this.variableNames = ["A", "indices"], this.outputShape = t, this.rank = t.length; const n = gk(this.rank), r = function (e) { const t = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], n = []; for (let r = 0; r < e.length; r++)2 === r ? n.push("index") : n.push(`${t[r]}`); return n.join() }(e); this.userCode = `\n void main() {\n ${n} resRC = getOutputCoords();\n int index = int(getIndices(resRC.x, resRC.z));\n float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function JT(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, indices: a } = t, { axis: o, batchDims: s } = r, u = P.util.parseAxisParam(o, i.shape)[0]; if ((0, P.env)().get("DEBUG")) { const e = n.readSync(a.dataId), t = i.shape[u]; for (let n = 0; n < e.length; ++n) { const r = e[n]; P.util.assert(r <= t - 1 && r >= 0, (() => `GatherV2: the index value ${r} is not in [0, ${t - 1}]`)) } } const l = P.backend_util.segment_util.collectGatherOpShapeInfo(i, a, u, s), c = P.util.sizeFromShape(a.shape), h = [], d = U_({ inputs: { x: i }, backend: n, attrs: { shape: [l.batchSize, l.outerSize, l.dimSize, l.sliceSize] } }), f = U_({ inputs: { x: a }, backend: n, attrs: { shape: [l.batchSize, c / l.batchSize] } }); h.push(d), h.push(f); const p = [l.batchSize, l.outerSize, c / l.batchSize, l.sliceSize]; if (n.shouldExecuteOnCPU([i, a]) || "string" === i.dtype) { const e = n.bufferSync(f), t = n.bufferSync(d), r = hS(t, e, p); return h.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(l.outputShape, r.dtype, r.values) } const m = new ZT(d.shape, p), g = n.runWebGLProgram(m, [d, f], d.dtype); h.push(g); const y = U_({ inputs: { x: g }, backend: n, attrs: { shape: l.outputShape } }); return h.forEach((e => n.disposeIntermediateTensorInfo(e))), y } const QT = { kernelName: P.GatherV2, backendName: "webgl", kernelFunc: JT }, eE = D_({ opSnippet: "return float(a > b);", packedOpSnippet: "\n return vec4(greaterThan(a, b));\n", cpuKernelImpl: dS, dtype: "bool" }), tE = { kernelName: P.Greater, backendName: "webgl", kernelFunc: eE }, nE = D_({ opSnippet: "return float(a >= b);", packedOpSnippet: "\n return vec4(greaterThanEqual(a, b));\n", dtype: "bool", cpuKernelImpl: fS }), rE = { kernelName: P.GreaterEqual, backendName: "webgl", kernelFunc: nE }; const iE = { + kernelName: P.IFFT, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { input: r } = t; return IT(r, !0, n) } + }, aE = F_({ opSnippet: "return float(!isnan(x) && !isinf(x));", dtype: "bool" }), oE = { kernelName: P.IsFinite, backendName: "webgl", kernelFunc: aE }, sE = F_({ opSnippet: "return float(isinf(x));", dtype: "bool" }), uE = { kernelName: P.IsInf, backendName: "webgl", kernelFunc: sE }, lE = F_({ opSnippet: "return float(isnan(x));", dtype: "bool" }), cE = { kernelName: P.IsNan, backendName: "webgl", kernelFunc: lE }, hE = D_({ opSnippet: "return float(a < b);", packedOpSnippet: "\n return vec4(lessThan(a, b));\n", cpuKernelImpl: pS, dtype: "bool" }), dE = { kernelName: P.Less, backendName: "webgl", kernelFunc: hE }, fE = D_({ opSnippet: "return float(a <= b);", packedOpSnippet: "\n return vec4(lessThanEqual(a, b));\n", cpuKernelImpl: mS, dtype: "bool" }), pE = { kernelName: P.LessEqual, backendName: "webgl", kernelFunc: fE }; const mE = { + kernelName: P.LinSpace, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, num: a } = n, o = gS(r, i, a); return t.makeTensorInfo([o.length], "float32", o) } + }, gE = F_({ opSnippet: M_ + "\n return x < 0.0 ? 0./0. : log(x);\n", packedOpSnippet: "\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n", cpuKernelImpl: yS }), yE = { kernelName: P.Log, backendName: "webgl", kernelFunc: gE }, bE = F_({ opSnippet: M_ + "\n return log(1.0 + x);\n" }), vE = { kernelName: P.Log1p, backendName: "webgl", kernelFunc: bE }, xE = D_({ opSnippet: "return float(a >= 1.0 && b >= 1.0);", packedOpSnippet: "\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n", dtype: "bool" }), wE = { kernelName: P.LogicalAnd, backendName: "webgl", kernelFunc: xE }, kE = F_({ opSnippet: "return float(!(x >= 1.0));" }), SE = { kernelName: P.LogicalNot, backendName: "webgl", kernelFunc: kE }, _E = D_({ opSnippet: "return float(a >= 1.0 || b >= 1.0);", packedOpSnippet: "\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n", dtype: "bool" }), CE = { kernelName: P.LogicalOr, backendName: "webgl", kernelFunc: _E }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class AE { constructor(e, t, n, r, i) { this.variableNames = ["x"], this.outputShape = []; const a = t, o = e[3] - 1; let s; this.outputShape = e; const u = `float(${n}) + float(${r}) * sum`; s = .5 === i ? `inversesqrt(${u})` : 1 === i ? `1.0/(${u})` : `exp(log(${u}) * float(-${i}));`, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${a}; j <= ${a}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${o}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${s};\n setOutput(val);\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class TE { constructor(e, t, n, r, i) { this.variableNames = ["x"], this.outputShape = [], this.packedInputs = !0, this.packedOutput = !0; const a = t, o = e[3] - 1; let s; this.outputShape = e; const u = `float(${n}) + float(${r}) * sum`; s = .5 === i ? `inversesqrt(${u})` : 1 === i ? `1.0/(${u})` : `exp(log(${u}) * float(-${i}));`, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${a};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${a}; j <= ${a}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${o}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${s};\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const EE = { kernelName: P.LRN, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { depthRadius: a, bias: o, alpha: s, beta: u } = r, l = (0, P.env)().getBool("WEBGL_PACK_NORMALIZATION") ? new TE(i.shape, a, o, s, u) : new AE(i.shape, a, o, s, u); return n.runWebGLProgram(l, [i], i.dtype) } }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class NE { constructor(e, t, n, r, i) { this.variableNames = ["inputImage", "outputImage", "dy"], this.outputShape = [], this.outputShape = e, this.depth = e[3], this.depthRadius = t, this.bias = n, this.alpha = r, this.beta = i, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${t})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${t} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${r}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${r})\n * float(${i})\n * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${i});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const IE = { kernelName: P.LRNGrad, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i, y: a, dy: o } = t, { depthRadius: s, bias: u, alpha: l, beta: c } = r, h = new NE(i.shape, s, u, l, c); return n.runWebGLProgram(h, [i, a, o], i.dtype) } }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ME(e) { + const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reductionIndices: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s), h = null != c, d = n.shouldExecuteOnCPU([i]); let f = i; if (h) { if (d) { const e = n.texData.get(f.dataId).values, t = new Array(s); for (let e = 0; e < t.length; e++)t[e] = i.shape[c[e]]; const r = HS(e, i.shape, i.dtype, c, t); f = n.makeTensorInfo(t, i.dtype); n.texData.get(f.dataId).values = r } else f = X_(i, c, n); l = P.backend_util.getInnerMostAxes(l.length, s) } P.backend_util.assertAxesAreInnerMostDims("max", l, s); const [p, m] = P.backend_util.computeOutAndReduceShapes(f.shape, l); let g, y = p; if (o && (y = P.backend_util.expandShapeToKeepDim(p, u)), d) { const e = n.texData.get(f.dataId).values, t = bS(e, P.util.sizeFromShape(m), y, i.dtype); g = n.makeTensorInfo(y, i.dtype); n.texData.get(g.dataId).values = t } else g = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { const i = P.util.sizeFromShape(t), a = U_({ inputs: { x: e }, attrs: { shape: [P.util.sizeFromShape(e.shape) / i, i] }, backend: r }), o = H_(a, e.dtype, "max", r), s = U_({ inputs: { x: o }, attrs: { shape: n }, backend: r }); return r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s }(f, m, y, n); return h && n.disposeIntermediateTensorInfo(f), g + } const FE = { kernelName: P.Max, backendName: "webgl", kernelFunc: ME }, DE = D_({ opSnippet: y_ + "\n return max(a, b);\n", packedOpSnippet: "\n vec4 result = vec4(max(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n " + v_ + "\n return result;\n", cpuKernelImpl: vS }), $E = { kernelName: P.Maximum, backendName: "webgl", kernelFunc: DE }; const RE = { + kernelName: P.MaxPool, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; Zw(i, "maxPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) return w_({ inputs: { x: i }, backend: n }); const c = new DC(l, "max", !1); return n.runWebGLProgram(c, [i], i.dtype) } + }; const OE = { + kernelName: P.MaxPool3D, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dataFormat: u, dimRoundingMode: l } = r, c = P.backend_util.computePool3DInfo(i.shape, a, o, [1, 1, 1], s, l, u), h = new $C(c, "max", !1); return n.runWebGLProgram(h, [i], i.dtype) } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class zE { constructor(e) { this.variableNames = ["dy", "maxPos"], this.outputShape = e.inShape; const t = e.strideHeight, n = e.strideWidth, r = e.dilationHeight, i = e.effectiveFilterHeight, a = e.effectiveFilterWidth, o = i - 1 - e.padInfo.top, s = a - 1 - e.padInfo.left, u = i * a - 1; this.userCode = `\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${i};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${t}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${a}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${a} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n ` } } class PE { constructor(e) { this.variableNames = ["dy", "maxPos"], this.outputShape = e.inShape; const t = e.strideDepth, n = e.strideHeight, r = e.strideWidth, i = e.dilationDepth, a = e.dilationHeight, o = e.dilationWidth, s = e.effectiveFilterDepth, u = e.effectiveFilterHeight, l = e.effectiveFilterWidth, c = s - 1 - e.padInfo.front, h = u - 1 - e.padInfo.top, d = l - 1 - e.padInfo.left, f = s * u * l - 1; this.userCode = `\n const ivec3 pads = ivec3(${c}, ${h}, ${d});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${s};\n wD += ${i}) {\n float dyD = float(dyDCorner + wD) / ${t}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${u};\n wR += ${a}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${l};\n wC += ${o}) {\n float dyC = float(dyCCorner + wC) / ${r}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${f} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${u} * ${l} +\n wR * ${l} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const BE = { + kernelName: P.MaxPool3DGrad, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a, { filterSize: s, strides: u, pad: l, dimRoundingMode: c } = r, h = P.backend_util.computePool3DInfo(o.shape, s, u, [1, 1, 1], l, c), d = new $C(h, "max", !0), f = n.runWebGLProgram(d, [o], o.dtype), p = new PE(h), m = n.runWebGLProgram(p, [i, f], o.dtype); return n.disposeIntermediateTensorInfo(f), m } + }; const LE = { + kernelName: P.MaxPoolGrad, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a, output: o } = t, s = a; Zw([a, o], "maxPoolGrad"); const { filterSize: u, strides: l, pad: c, dimRoundingMode: h } = r, d = P.backend_util.computePool2DInfo(s.shape, u, l, 1, c, h), f = new DC(d, "max", !0), p = n.runWebGLProgram(f, [s], s.dtype), m = new zE(d), g = n.runWebGLProgram(m, [i, p], s.dtype); return n.disposeIntermediateTensorInfo(p), g } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const jE = { + kernelName: P.MaxPoolWithArgmax, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { + const { x: r } = e, { filterSize: i, strides: a, pad: o, includeBatchInIndex: s } = t, u = n; P.util.assert(4 === r.shape.length, (() => `Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`)); const l = [1, 1]; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(a, l), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${l}'`)); const c = P.backend_util.computePool2DInfo(r.shape, i, a, l, o), [h, d] = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { let i = new DC(n, "max", !1); const a = r.runWebGLProgram(i, [e], "float32"); return i = new DC(n, "max", !0, !0, t), [a, r.runWebGLProgram(i, [e], "float32")] }(r, s, c, u); return [h, d] + } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const UE = { + kernelName: P.Mean, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { + const { x: r } = e, { keepDims: i, axis: a } = t, o = n, s = r.shape.length, u = P.util.parseAxisParam(a, r.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s), h = null != c, d = o.shouldExecuteOnCPU([r]), f = []; let p = r; if (h) { if (d) { const e = o.texData.get(p.dataId).values, t = new Array(s); for (let e = 0; e < t.length; e++)t[e] = r.shape[c[e]]; const n = HS(e, r.shape, r.dtype, c, t); p = o.makeTensorInfo(t, r.dtype); o.texData.get(p.dataId).values = n } else p = X_(r, c, o); f.push(p), l = P.backend_util.getInnerMostAxes(l.length, s) } P.backend_util.assertAxesAreInnerMostDims("sum", l, s); const [m, g] = P.backend_util.computeOutAndReduceShapes(p.shape, l); let y = m; i && (y = P.backend_util.expandShapeToKeepDim(m, u)); const b = + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r) { const i = P.util.sizeFromShape(t), a = U_({ inputs: { x: e }, attrs: { shape: [P.util.sizeFromShape(e.shape) / i, i] }, backend: r }), o = H_(a, "float32", "mean", r), s = U_({ inputs: { x: o }, attrs: { shape: n }, backend: r }); return r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s }(p, g, y, o); for (const e of f) o.disposeIntermediateTensorInfo(e); return b + } + }; const WE = { + kernelName: P.Min, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), l = P.backend_util.getInnerMostAxes(l.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("min", l, s); const [d, f] = P.backend_util.computeOutAndReduceShapes(h.shape, l), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, P.util.sizeFromShape(f)] } }), m = H_(p, p.dtype, "min", n); let g; if (o) { g = U_({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(d, u) } }) } else g = U_({ inputs: { x: m }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), null != c && n.disposeIntermediateTensorInfo(h), g } + }, VE = D_({ opSnippet: y_ + "\n return min(a, b);\n", packedOpSnippet: "\n vec4 result = vec4(min(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n " + v_ + "\n return result;\n", cpuKernelImpl: xS }), GE = { kernelName: P.Minimum, backendName: "webgl", kernelFunc: VE }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class HE { constructor(e, t, n) { this.variableNames = ["x"], this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, r), u = "reflect" === n ? 0 : 1; this.userCode = 1 !== r ? `\n ${i} start = ${i}(${a});\n ${i} end = ${i}(${o});\n\n void main() {\n ${i} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${i} coords = outC - start;\n setOutput(getX(${s}));\n }\n ` : `\n int start = ${a};\n int end = ${o};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class qE { constructor(e, t, n) { this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = XS("rc", r), u = XS("source", r), l = `${s[r - 1]} < ${this.outputShape[r - 1]}`, c = 1 === r ? "source" : `vec2(${u.slice(-2).join()})`, h = "reflect" === n ? 0 : 1; let d = ""; if (1 === r) { const e = `\n ${i} source = rc;\n if (source < start) {\n source = start * 2 - source - ${h};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${h};\n }\n source -= start;\n `; d = `\n ${i} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${s[r - 1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n ` } else { const e = `\n ${i} source = rc;\n ${i} lt = ${i}(lessThan(source, start));\n ${i} gte = ${i}(greaterThanEqual(source, end));\n ${i} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${h}) +\n gte * ((end - 1) * 2 - source + ${h});\n source -= start;\n `; d = `\n ${i} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${s[r - 1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n rc = outputLoc;\n ${s[r - 2]} += 1;\n if(${s[r - 2]} < ${this.outputShape[r - 2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${c});\n ${s[r - 1]} += 1;\n if(${l}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${c});\n }\n }\n ` } this.userCode = `\n const ${i} start = ${i}(${a});\n const ${i} end = ${i}(${o});\n\n void main() {\n ${i} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const YE = { kernelName: P.MirrorPad, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r } = e, { paddings: i, mode: a } = n, o = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new qE(r.shape, i, a) : new HE(r.shape, i, a); return t.runWebGLProgram(o, [r], r.dtype) } }, XE = D_({ opSnippet: "if (b == 0.0) return NAN;\n return mod(a, b);", packedOpSnippet: "\n vec4 result = mod(a, b);\n bvec4 isNaN = equal(b, vec4(0.0));\n " + v_ + "\n return result;\n" }), KE = { kernelName: P.Mod, backendName: "webgl", kernelFunc: XE }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ZE { constructor(e, t, n) { this.variableNames = ["probs"], this.customUniforms = [{ name: "seed", type: "float" }], this.outputShape = [e, n], this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${t - 1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${t - 1}));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const JE = D_({ opSnippet: "\nif (a == b) {\n return 1.0;\n};\nreturn a / b;", packedOpSnippet: "\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n", checkOutOfBounds: !0 }), QE = { kernelName: P.RealDiv, backendName: "webgl", kernelFunc: JE }, eN = "return a - b;", tN = D_({ opSnippet: eN, packedOpSnippet: eN, supportsComplex: !0, cpuKernelImpl: WS }), nN = { kernelName: P.Sub, backendName: "webgl", kernelFunc: tN }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function rN(e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { dim: a } = r, o = P.util.parseAxisParam([a], i.shape), s = ME({ inputs: { x: i }, backend: n, attrs: { reductionIndices: o, keepDims: !1 } }), u = P.backend_util.expandShapeToKeepDim(s.shape, o), l = U_({ inputs: { x: s }, backend: n, attrs: { shape: u } }), c = tN({ inputs: { a: i, b: l }, backend: n }), h = kT({ inputs: { x: c }, backend: n }), d = K_({ inputs: { x: h }, backend: n, attrs: { axis: o, keepDims: !1 } }), f = U_({ inputs: { x: d }, backend: n, attrs: { shape: u } }), p = JE({ inputs: { a: h, b: f }, backend: n }); return n.disposeIntermediateTensorInfo(s), n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(c), n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(f), p } const iN = { kernelName: P.Softmax, backendName: "webgl", kernelFunc: rN }; const aN = { + kernelName: P.Multinomial, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { numSamples: a, seed: o, normalized: s } = r, u = s ? i : rN({ inputs: { logits: i }, backend: n, attrs: { dim: i.shape.length - 1 } }), l = u.shape[0], c = u.shape[1], h = new ZE(l, c, a), d = [[o]], f = n.runWebGLProgram(h, [u], "int32", d); return s || n.disposeIntermediateTensorInfo(u), f } + }, oN = r_ + "\n return -x;\n"; const sN = { kernelName: P.Neg, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t; if (n.shouldExecuteOnCPU([r])) { const e = n.texData.get(r.dataId), [t, i] = kS(e.values, r.shape, r.dtype); return n.makeTensorInfo(i, r.dtype, t) } let i; return i = (0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? new u_(r.shape, "\n vec4 result = -x;\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n") : new n_(r.shape, oN), n.runWebGLProgram(i, [r], r.dtype) } }, uN = P.kernel_impls.nonMaxSuppressionV3Impl; const lN = { kernelName: P.NonMaxSuppressionV3, backendName: "webgl", kernelFunc: function (e) { P.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = r, l = n.readSync(i.dataId), c = n.readSync(a.dataId), { selectedIndices: h } = uN(l, c, o, s, u); return n.makeTensorInfo([h.length], "int32", new Int32Array(h)) } }, cN = P.kernel_impls.nonMaxSuppressionV4Impl; const hN = { kernelName: P.NonMaxSuppressionV4, backendName: "webgl", kernelFunc: function (e) { P.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, padToMaxOutputSize: l } = r, c = n.readSync(i.dataId), h = n.readSync(a.dataId), { selectedIndices: d, validOutputs: f } = cN(c, h, o, s, u, l); return [n.makeTensorInfo([d.length], "int32", new Int32Array(d)), n.makeTensorInfo([], "int32", new Int32Array([f]))] } }, dN = P.kernel_impls.nonMaxSuppressionV5Impl; const fN = { kernelName: P.NonMaxSuppressionV5, backendName: "webgl", kernelFunc: function (e) { P.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = r, c = n.readSync(i.dataId), h = n.readSync(a.dataId), d = o, f = s, p = u, m = l, { selectedIndices: g, selectedScores: y } = dN(c, h, d, f, p, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([y.length], "float32", new Float32Array(y))] } }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class pN { constructor(e, t, n, r) { this.variableNames = ["indices"], this.outputShape = [e, t], this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${r}), float(${n}),\n float(index == coords.y)));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const mN = { kernelName: P.OneHot, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { indices: i } = t, { dtype: a, depth: o, onValue: s, offValue: u } = r, l = P.util.sizeFromShape(i.shape), c = new pN(l, o, s, u), h = U_({ inputs: { x: i }, backend: n, attrs: { shape: [l] } }), d = n.runWebGLProgram(c, [h], a); n.disposeIntermediateTensorInfo(h); const f = U_({ inputs: { x: d }, backend: n, attrs: { shape: [...i.shape, o] } }); return n.disposeIntermediateTensorInfo(d), f } }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function gN(e) { const { inputs: t, backend: n } = e, { x: r } = t; if ("complex64" === r.dtype) { const e = nA({ inputs: { input: r }, backend: n }), t = gN({ inputs: { x: e }, backend: n }), i = yA({ inputs: { input: r }, backend: n }), a = gN({ inputs: { x: i }, backend: n }), o = S_({ inputs: { real: t, imag: a }, backend: n }); return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(a), o } return DT({ attrs: { shape: r.shape, dtype: r.dtype, value: "string" === r.dtype ? "" : 0 }, backend: n }) } const yN = { kernelName: P.ZerosLike, backendName: "webgl", kernelFunc: gN }; const bN = { + kernelName: P.OnesLike, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function e(t) { const { inputs: n, backend: r } = t, { x: i } = n; if ("string" === i.dtype) throw new Error("onesLike is not supported under string dtype"); if ("complex64" === i.dtype) { const t = nA({ inputs: { input: i }, backend: r }), n = e({ inputs: { x: t }, backend: r }), a = yA({ inputs: { input: i }, backend: r }), o = gN({ inputs: { x: a }, backend: r }), s = S_({ inputs: { real: n, imag: o }, backend: r }); return r.disposeIntermediateTensorInfo(t), r.disposeIntermediateTensorInfo(n), r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s } return DT({ attrs: { shape: i.shape, dtype: i.dtype, value: 1 }, backend: r }) } + }; const vN = { + kernelName: P.Pack, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r; if (1 === t.length) return _T({ inputs: { input: t[0] }, backend: n, attrs: { dim: i } }); const a = t[0].shape, o = t[0].dtype; t.forEach((e => { P.util.assertShapesMatch(a, e.shape, "All tensors passed to stack must have matching shapes"), P.util.assert(o === e.dtype, (() => "All tensors passed to stack must have matching dtypes")) })); const s = [], u = xA({ inputs: t.map((e => { const t = _T({ inputs: { input: e }, backend: n, attrs: { dim: i } }); return s.push(t), t })), backend: n, attrs: { axis: i } }); return s.forEach((e => n.disposeIntermediateTensorInfo(e))), u } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class xN { constructor(e, t, n) { this.variableNames = ["x"], this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, r); this.userCode = 1 !== r ? `\n ${i} start = ${i}(${a});\n ${i} end = ${i}(${o});\n\n void main() {\n ${i} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${i} coords = outC - start;\n setOutput(getX(${s}));\n }\n }\n ` : `\n int start = ${a};\n int end = ${o};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class wN { constructor(e, t, n) { this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = XS("rc", r), u = XS("source", r), l = `${s[r - 1]} < ${this.outputShape[r - 1]}`, c = 1 === r ? "source" : `vec2(${u.slice(-2).join()})`, h = [`${i} rc = outputLoc;`, `${s[r - 1]} += 1;\n if(${l}) {\n `, 1 === r ? "" : `}\n rc = outputLoc;\n ${s[r - 2]} += 1;\n if(${s[r - 2]} < ${this.outputShape[r - 2]}) {`, 1 === r ? "" : ` ${s[r - 1]} += 1;\n if(${l}) {`], d = 1 === r ? "rc < start || rc >= end" : "any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))"; let f = ""; for (let e = 0, t = 1 === r ? 2 : 4; e < t; e++)f += `\n ${h[e]}\n if (${d}) {\n result[${e}] = float(value);\n } else {\n ${i} source = rc - start;\n result[${e}] = getChannel(getX(${u.join()}), ${c});\n }\n `; f += 1 === r ? "} " : "}}", this.userCode = `\n const ${i} start = ${i}(${a});\n const ${i} end = ${i}(${o});\n\n void main() {\n ${i} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${f}\n setOutput(result);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const kN = e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, constantValue: o } = r; if (0 === P.util.sizeFromShape(i.shape)) { return DT({ backend: n, attrs: { shape: a.map(((e, t) => e[0] + i.shape[t] + e[1])), value: o, dtype: i.dtype } }) } const s = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new wN(i.shape, a, o) : new xN(i.shape, a, o), u = [[o]]; return n.runWebGLProgram(s, [i], i.dtype, u) }, SN = { kernelName: P.PadV2, backendName: "webgl", kernelFunc: kN }, _N = D_({ opSnippet: "\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n", packedOpSnippet: "\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n bvec4 isNaN1 = lessThan(a, vec4(0.0));\n bvec4 isNaN2 = lessThan(floor(b), b);\n bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);\n " + v_ + "\n return result;\n" }), CN = { kernelName: P.Pow, backendName: "webgl", kernelFunc: _N }; const AN = { + kernelName: P.Prod, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = [], l = P.util.parseAxisParam(a, i.shape); let c = l; const h = P.backend_util.getAxesPermutation(c, s); let d, f = i; if (null != h && (f = J_({ inputs: { x: i }, backend: n, attrs: { perm: h } }), c = P.backend_util.getInnerMostAxes(c.length, s), u.push(f)), P.backend_util.assertAxesAreInnerMostDims("prod", c, s), n.shouldExecuteOnCPU([f])) { const e = n.texData.get(f.dataId).values, { outVals: t, outShape: r, outDtype: i } = _S(f.shape, f.dtype, e, c); d = n.makeTensorInfo(r, i, t) } else { const [e, t] = P.backend_util.computeOutAndReduceShapes(f.shape, c), r = P.util.sizeFromShape(t), a = U_({ inputs: { x: f }, backend: n, attrs: { shape: [-1, r] } }), o = H_(a, (0, P.sumOutType)(i.dtype), "prod", n); d = U_({ inputs: { x: o }, backend: n, attrs: { shape: e } }), u.push(a), u.push(o) } if (o) { u.push(d); const e = P.backend_util.expandShapeToKeepDim(d.shape, l); d = U_({ inputs: { x: d }, backend: n, attrs: { shape: e } }) } return u.forEach((e => n.disposeIntermediateTensorInfo(e))), d } + }; const TN = { + kernelName: P.RaggedGather, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { paramsNestedSplits: i, paramsDenseValues: a, indices: o } = t, { outputRaggedRank: s } = r, u = i.map((e => n.readSync(e.dataId))), l = i.map((e => e.shape)), c = n.readSync(a.dataId), h = n.readSync(o.dataId), [d, f, p] = CS(u, l, c, a.shape, a.dtype, h, o.shape, s), m = d.map((e => n.makeTensorInfo([e.length], "int32", e))), g = n.makeTensorInfo(p, a.dtype, f); return m.concat([g]) } + }; const EN = { + kernelName: P.RaggedRange, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { starts: r, limits: i, deltas: a } = t, o = n.readSync(r.dataId), s = n.readSync(i.dataId), u = n.readSync(a.dataId), [l, c] = AS(o, r.shape, r.dtype, s, i.shape, u, a.shape); return [n.makeTensorInfo([l.length], "int32", l), n.makeTensorInfo([c.length], r.dtype, c)] } + }; const NN = { + kernelName: P.RaggedTensorToTensor, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { shape: i, values: a, defaultValue: o, rowPartitionTensors: s } = t, { rowPartitionTypes: u } = r, l = n.readSync(i.dataId), c = n.readSync(a.dataId), h = n.readSync(o.dataId), d = s.map((e => n.readSync(e.dataId))), f = s.map((e => e.shape)), [p, m] = TS(l, i.shape, c, a.shape, a.dtype, h, o.shape, d, f, u); return n.makeTensorInfo(p, a.dtype, m) } + }, IN = e => { const { backend: t, attrs: n } = e, { start: r, stop: i, step: a, dtype: o } = n, s = ES(r, i, a, o); return t.makeTensorInfo([s.length], o, s) }, MN = { kernelName: P.Range, backendName: "webgl", kernelFunc: IN }, FN = F_({ opSnippet: "return 1.0 / x;" }), DN = { kernelName: P.Reciprocal, backendName: "webgl", kernelFunc: FN }, $N = F_({ opSnippet: r_ + "\n return (x < 0.0) ? 0.0 : x;\n", packedOpSnippet: "\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" }), RN = { kernelName: P.Relu, backendName: "webgl", kernelFunc: $N }, ON = F_({ opSnippet: r_ + "\n return (x < 0.0) ? 0.0 : min(6.0, x);\n", packedOpSnippet: "\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" }), zN = { kernelName: P.Relu6, backendName: "webgl", kernelFunc: ON }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class PN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n]; let h; h = i ? "(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)" : "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0] / c[0]},\n ${l[1] / c[1]});\n const vec2 inputShapeRC = vec2(${o}.0, ${s}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${h};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class BN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n]; let h; h = i ? "(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)" : "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0] / c[0]},\n ${l[1] / c[1]},\n ${l[1] / c[1]});\n const vec3 inputShapeRC = vec3(${o}.0, ${s}.0,\n ${s}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${h};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u - 1};\n bool hasNextRow = coords.z < ${n - 1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n ` } } const LN = { + kernelName: P.ResizeBilinear, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r, [u, l] = s, c = (0, P.env)().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new BN(i.shape, u, l, a, o) : new PN(i.shape, u, l, a, o); return n.runWebGLProgram(c, [i], "float32") } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class jN { constructor(e, t, n) { this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t; const [, r, i] = t, [, a, o] = e, s = [n && a > 1 ? r - 1 : r, n && o > 1 ? i - 1 : i], u = [n && a > 1 ? a - 1 : a, n && o > 1 ? o - 1 : o], l = s[0] / u[0], c = s[1] / u[1], h = 1 / l, d = 1 / c, f = 2 * Math.ceil(h) + 2, p = 2 * Math.ceil(d) + 2; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${h});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${f});\n const int winWidth = int(${p});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${a}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${o}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r - 1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${i - 1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n ` } } const UN = { + kernelName: P.ResizeBilinearGrad, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r, s = new jN(a.shape, i.shape, o); return n.runWebGLProgram(s, [a], a.dtype) } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class WN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n], h = r ? "0.5" : "0.0"; let d; d = i ? "max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))" : "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0] / c[0]},\n ${l[1] / c[1]});\n const vec2 inputShapeRC = vec2(${o}.0, ${s}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class VN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n], h = r ? "0.5" : "0.0"; let d; d = i ? "max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))" : "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0] / c[0]},\n ${l[1] / c[1]},\n ${l[1] / c[1]});\n const vec3 inputShapeRC = vec3(${o}.0, ${s}.0,\n ${s}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u - 1};\n bool hasNextRow = coords.z < ${n - 1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n ` } } const GN = { + kernelName: P.ResizeNearestNeighbor, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r, [u, l] = s, c = (0, P.env)().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new VN(i.shape, u, l, a, o) : new WN(i.shape, u, l, a, o); return n.runWebGLProgram(c, [i], i.dtype) } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class HN { constructor(e, t, n) { this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t; const [, r, i] = t, [, a, o] = e, s = [n && a > 1 ? r - 1 : r, n && o > 1 ? i - 1 : i], u = [n && a > 1 ? a - 1 : a, n && o > 1 ? o - 1 : o], l = s[0] / u[0], c = s[1] / u[1], h = 1 / l, d = 1 / c, f = 2 * Math.ceil(h) + 2, p = 2 * Math.ceil(d) + 2; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${h});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${f});\n const int winWidth = int(${p});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${a}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${o}) {\n continue;\n }\n\n float sourceFracRow =\n float(${s[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${s[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${i}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n ` } } const qN = { + kernelName: P.ResizeNearestNeighborGrad, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r, s = new HN(a.shape, i.shape, o); return n.runWebGLProgram(s, [a], a.dtype) } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class YN { constructor(e, t) { this.variableNames = ["x"]; const n = e.length; if (n > 4) throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`); if (this.outputShape = e, 1 === n) return void (this.userCode = `\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `); const r = e.map(((n, r) => (n => -1 !== t.indexOf(n) && 1 !== e[n] ? `${e[n]} - coords[${n}] - 1` : `coords[${n}]`)(r))).join(","), i = gk(n); this.userCode = `\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class XN { constructor(e, t) { this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0; const n = e.length; if (n > 4) throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`); this.outputShape = e; const r = XS("rc", n), i = `${r[n - 1]} + 1 < ${this.outputShape[n - 1]}`, a = `${r[n - 2]} + 1 < ${this.outputShape[n - 2]}`, o = gk(n); function s(n) { const r = e.map(((r, i) => function (n, r) { return -1 !== t.indexOf(n) && 1 !== e[n] ? `${e[n]} - ${r[n]} - 1` : `${r[n]}` }(i, n))); return `getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))` } this.userCode = 1 === n ? `\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${i}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n ` : `\n void main() {\n ${o} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function (e) { return s(e) }(r.slice())};\n if(${i}){\n result.g = ${function (e) { return e[n - 1] = "(" + e[n - 1] + " + 1)", s(e) }(r.slice())};\n }\n if(${a}) {\n result.b = ${function (e) { return e[n - 2] = "(" + e[n - 2] + " + 1)", s(e) }(r.slice())};\n if(${i}) {\n result.a = ${function (e) { return e[n - 1] = "(" + e[n - 1] + " + 1)", e[n - 2] = "(" + e[n - 2] + " + 1)", s(e) }(r.slice())};\n }\n }\n setOutput(result);\n }\n ` } } const KN = { + kernelName: P.Reverse, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dims: a } = r, o = i.shape.length, s = P.util.parseAxisParam(a, i.shape); if (0 === o) return w_({ inputs: { x: i }, backend: n }); const u = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new XN(i.shape, s) : new YN(i.shape, s); return n.runWebGLProgram(u, [i], i.dtype) } + }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ZN { constructor(e, t) { this.variableNames = ["Image"], this.outputShape = [], this.customUniforms = [{ name: "params", type: "vec4" }]; const n = e[1], r = e[2]; this.outputShape = e; let i = ""; i = "number" == typeof t ? `float outputValue = ${t.toFixed(2)};` : `\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${i}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const JN = { kernelName: P.RotateWithOffset, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, { radians: i, fillValue: a, center: o } = t, s = n, u = new ZN(r.shape, a), [l, c] = P.backend_util.getImageCenter(o, r.shape[1], r.shape[2]), h = [[l, c, Math.sin(i), Math.cos(i)]]; return s.runWebGLProgram(u, [r], r.dtype, h) } }, QN = F_({ opSnippet: "\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n" }), eI = { kernelName: P.Round, backendName: "webgl", kernelFunc: QN }, tI = F_({ opSnippet: "return inversesqrt(x);", cpuKernelImpl: NS }), nI = { kernelName: P.Rsqrt, backendName: "webgl", kernelFunc: tI }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rI { constructor(e, t, n, r, i, a, o = !0, s = !1) { this.variableNames = ["updates", "indices", "defaultValue"], this.outputShape = a; const u = gk(i.length), l = gk(a.length); let c = ""; 1 === n ? c = "i" : 2 === n && (c = "i, j"); const h = `getIndices(${c})`; let d = ""; 1 === r ? d = "i" : 2 === r && (d = "i, coords[1]"); const f = `getUpdates(${d})`; let p = ""; s && (p = "coords[0], coords[1]"); const m = `getDefaultValue(${p})`, g = t > 1 ? "strides[j]" : "strides"; this.userCode = `\n ${u} strides = ${u}(${i});\n\n void main() {\n ${l} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${e}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${t}; j++) {\n int index = round(${h});\n flattenedIndex += index * ${g};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${f};\n found = true;\n }\n }\n setOutput(mix(${m}, sum, float(found)));\n }\n ` } } + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class iI { constructor(e, t, n, r, i, a, o = !0, s = !1) { this.variableNames = ["updates", "indices", "defaultValue"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = a; const u = gk(i.length), l = gk(a.length); let c = ""; 1 === n ? c = "i" : 2 === n && (c = "i, j"); const h = `getIndices(${c})`; let d = ""; 1 === r ? d = "i" : 2 === r && (d = "i, coords[1]"); const f = `getUpdates(${d})`; let p = ""; s && (p = "coords[0], coords[1]"); const m = `getDefaultValue(${p})`, g = t > 1 ? "strides[j]" : "strides", y = t > 1 ? "strides[j + 1]" : "strides"; this.userCode = `\n ${u} strides = ${u}(${i});\n\n void main() {\n ${l} coords = getOutputCoords();\n vec4 sum = vec4(0.);\n vec4 found = vec4(0.);\n for (int i = 0; i < ${e}; i+=2) {\n ivec2 flattenedIndex = ivec2(0);\n for (int j = 0; j < ${t}; j+=2) {\n ivec4 index = round(${h});\n flattenedIndex += index.xz * ${g};\n if (j + 1 < ${t}) {\n flattenedIndex += index.yw * ${y};\n }\n }\n if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||\n flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {\n vec4 updVals = ${f};\n if (flattenedIndex[0] == coords[0]) {\n sum.xy += updVals.xy;\n found.xy = vec2(1.);\n } else if (flattenedIndex[0] == coords[0] + 1) {\n sum.zw += updVals.xy;\n found.zw = vec2(1.);\n }\n if (flattenedIndex[1] == coords[0]) {\n sum.xy += updVals.zw;\n found.xy = vec2(1.);\n } else if (flattenedIndex[1] == coords[0] + 1) {\n sum.zw += updVals.zw;\n found.zw = vec2(1.);\n }\n }\n }\n setOutput(mix(${m}, sum, found));\n }\n ` } } const aI = { + kernelName: P.ScatterNd, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i, updates: a } = t, { shape: o } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(a, i, o), d = [h / l, l]; if (0 === h) return n.makeTensorInfo(o, i.dtype); const f = U_({ inputs: { x: i }, backend: n, attrs: { shape: [u, s] } }), p = U_({ inputs: { x: a }, backend: n, attrs: { shape: [u, l] } }), m = n.makeTensorInfo([], "float32", new Float32Array([0])); let g; g = (0, P.env)().getBool("WEBGL_PACK") ? new iI(u, s, f.shape.length, p.shape.length, c, d) : new rI(u, s, f.shape.length, p.shape.length, c, d); const y = n.runWebGLProgram(g, [p, f, m], p.dtype), b = U_({ inputs: { x: y }, backend: n, attrs: { shape: o } }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(y), n.disposeIntermediateTensorInfo(m), b } + }; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class oI { constructor(e, t, n, r) { this.variableNames = ["sortedSequence", "values"], this.customUniforms = [{ name: "numInputs", type: "int" }], this.outputShape = [e, n]; const i = `for (int i = 0; i < ${Math.ceil(Math.log2(t + 1))}; ++i) { if (left >= right) break;`, a = 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? "while (left < right) {" : i, o = "left" === r ? "<" : "<="; this.userCode = `\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${a}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${o} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n ` } } const sI = { + kernelName: P.SearchSorted, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { sortedSequence: i, values: a } = t, { side: o } = r, s = new oI(i.shape[0], i.shape[1], a.shape[1], o), u = [[i.shape[1]]]; return n.runWebGLProgram(s, [i, a], "int32", u) } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class uI { constructor(e, t, n) { let r, i; if (this.variableNames = ["c", "a", "b"], this.outputShape = t, n > 4) throw Error(`Where for rank ${n} is not yet supported`); if (1 === n) i = "resRC", r = "resRC"; else { const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], a = [], o = []; for (let r = 0; r < t.length; r++)o.push(`${n[r]}`), r < e && a.push(`${n[r]}`); r = a.join(), i = o.join() } const a = gk(n); this.userCode = `\n void main() {\n ${a} resRC = getOutputCoords();\n float cVal = getC(${r});\n if (cVal >= 1.0) {\n setOutput(getA(${i}));\n } else {\n setOutput(getB(${i}));\n }\n }\n ` } } const lI = { + kernelName: P.Select, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { condition: r, t: i, e: a } = t, o = new uI(r.shape.length, i.shape, i.shape.length); return n.runWebGLProgram(o, [r, i, a], (0, P.upcastType)(i.dtype, a.dtype)) } + }, cI = F_({ opSnippet: `\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${P.backend_util.SELU_SCALEALPHA};\n float scale = ${P.backend_util.SELU_SCALE};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n` }), hI = { kernelName: P.Selu, backendName: "webgl", kernelFunc: cI }, dI = F_({ opSnippet: M_ + "\n return 1.0 / (1.0 + exp(-1.0 * x));\n", packedOpSnippet: "\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n", cpuKernelImpl: MS }), fI = { kernelName: P.Sigmoid, backendName: "webgl", kernelFunc: dI }, pI = F_({ opSnippet: "\n if (isnan(x)) { return 0.0; }\n return sign(x);\n" }), mI = { kernelName: P.Sign, backendName: "webgl", kernelFunc: pI }, gI = F_({ opSnippet: M_ + "\n return sin(x);\n", packedOpSnippet: `\n vec4 result = sin(x);\n bvec4 isNaN = isnan(x);\n ${v_}\n return result;\n` }), yI = { kernelName: P.Sin, backendName: "webgl", kernelFunc: gI }, bI = F_({ opSnippet: "\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n" }), vI = { kernelName: P.Sinh, backendName: "webgl", kernelFunc: bI }, xI = F_({ opSnippet: "\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n" }), wI = { kernelName: P.Softplus, backendName: "webgl", kernelFunc: xI }, kI = { kernelName: P.SpaceToBatchND, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, paddings: o } = r; P.util.assert(i.shape.length <= 4, (() => "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet")); const s = a.reduce(((e, t) => e * t)), u = [[0, 0]]; u.push(...o); for (let e = 1 + a.length; e < i.shape.length; ++e)u.push([0, 0]); const l = [], c = kN({ inputs: { x: i }, backend: n, attrs: { paddings: u, constantValue: 0 } }), h = P.backend_util.getReshaped(c.shape, a, s, !1), d = P.backend_util.getPermuted(h.length, a.length, !1), f = P.backend_util.getReshapedPermuted(c.shape, a, s, !1), p = U_({ inputs: { x: c }, backend: n, attrs: { shape: h } }), m = J_({ inputs: { x: p }, backend: n, attrs: { perm: d } }), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: f } }); return l.push(c), l.push(p), l.push(m), l.forEach((e => n.disposeIntermediateTensorInfo(e))), g } }; const SI = { + kernelName: P.SparseFillEmptyRows, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { indices: r, values: i, denseShape: a, defaultValue: o } = t; if (1 !== a.shape.length) throw new Error(`Dense shape must be a vector, saw:\n ${a.shape}`); if (2 !== r.shape.length) throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Values must be a vector, saw:\n ${i.shape}`); if (0 !== o.shape.length) throw new Error(`Default value must be a scalar, saw:\n ${o.shape}`); const s = n.readSync(r.dataId), u = n.readSync(i.dataId), l = n.readSync(a.dataId), c = n.readSync(o.dataId)[0], [h, d, f, p, m] = $S(s, r.shape, r.dtype, u, i.dtype, l, c); return [n.makeTensorInfo(d, r.dtype, h), n.makeTensorInfo([d[0]], i.dtype, f), n.makeTensorInfo([p.length], "bool", new Uint8Array(p.map((e => Number(e))))), n.makeTensorInfo([m.length], r.dtype, new Int32Array(m))] } + }; const _I = { + kernelName: P.SparseReshape, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { inputIndices: r, inputShape: i, newShape: a } = t; if (2 !== r.shape.length) throw new Error(`Input indices should be a matrix but received shape ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Input shape should be a vector but received shape ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Target shape should be a vector but received shape ${a.shape}`); const o = Array.from(n.readSync(i.dataId)), s = n.readSync(r.dataId), u = Array.from(n.readSync(a.dataId)), [l, c, h] = RS(s, r.shape, r.dtype, o, u); return [n.makeTensorInfo(c, r.dtype, l), n.makeTensorInfo([h.length], a.dtype, new Int32Array(h))] } + }; const CI = { + kernelName: P.SparseSegmentMean, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); const o = n.readSync(r.dataId), s = n.readSync(i.dataId), u = n.readSync(a.dataId), [l, c] = OS(o, r.shape, r.dtype, s, u, !0); return n.makeTensorInfo(c, r.dtype, l) } + }; const AI = { + kernelName: P.SparseSegmentSum, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); const o = n.readSync(r.dataId), s = n.readSync(i.dataId), u = n.readSync(a.dataId), [l, c] = OS(o, r.shape, r.dtype, s, u); return n.makeTensorInfo(c, r.dtype, l) } + }; const TI = { + kernelName: P.SparseToDense, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { sparseIndices: i, sparseValues: a, defaultValue: o } = t, { outputShape: s } = r, { sliceRank: u, numUpdates: l, sliceSize: c, strides: h, outputSize: d } = P.backend_util.calculateShapes(a, i, s), f = !1; if ("string" === a.dtype) { const e = n.bufferSync(i), t = n.bufferSync(a), r = P.util.decodeString(n.readSync(o.dataId)[0]), p = IS(e, t, s, d, c, l, u, h, r, f); return n.makeTensorInfo(s, p.dtype, p.values) } const p = new rI(l, u, i.shape.length, a.shape.length, h, [d, 1], f), m = n.runWebGLProgram(p, [a, i, o], a.dtype), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: s } }); return n.disposeIntermediateTensorInfo(m), g } + }; const EI = { + kernelName: P.SplitV, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { numOrSizeSplits: a, axis: o } = r, s = P.util.parseAxisParam(o, i.shape)[0], u = P.backend_util.prepareSplitSize(i, a, s), l = i.shape.length, c = new Array(l).fill(0), h = i.shape.slice(); return u.map((e => { const t = [...h]; t[s] = e; const r = YC({ inputs: { x: i }, backend: n, attrs: { begin: c, size: t } }); return c[s] += e, r })) } + }, NI = "return sqrt(x);", II = F_({ opSnippet: NI, packedOpSnippet: NI, cpuKernelImpl: zS }), MI = { kernelName: P.Sqrt, backendName: "webgl", kernelFunc: II }, FI = F_({ opSnippet: "return x * x;" }), DI = { kernelName: P.Square, backendName: "webgl", kernelFunc: FI }, $I = "return (a - b) * (a - b);", RI = D_({ opSnippet: $I, packedOpSnippet: $I }), OI = { kernelName: P.SquaredDifference, backendName: "webgl", kernelFunc: RI }; const zI = { + kernelName: P.StaticRegexReplace, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; if ("string" !== i.dtype) throw new Error("Input must be of datatype string"); const a = n.readSync(i.dataId), o = P.backend_util.fromUint8ToStringArray(a), s = PS(o, "string", r); return n.makeTensorInfo(i.shape, "string", s) } + }; const PI = { + kernelName: P.Step, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ({ inputs: e, attrs: t, backend: n }) { const { x: r } = e, i = r_ + `\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `, a = new n_(r.shape, i); return n.runWebGLProgram(a, [r], r.dtype) } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class BI { constructor(e, t, n) { this.variableNames = ["x"], this.outputShape = n; const r = n.length, i = gk(n.length), a = gk(n.length); let o = ""; if (1 === r) o = "coords * strides + begin"; else { let e = 0; o = n.map(((t, r) => (e++, 1 === n.length ? `coords * strides[${r}] + begin[${r}]` : `coords[${e - 1}] * strides[${r}] + begin[${r}]`))).join(",") } this.userCode = `\n ${i} begin = ${i}(${e});\n ${i} strides = ${i}(${t});\n\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${o}));\n }\n ` } } const LI = { + kernelName: P.StridedSlice, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, end: o, strides: s, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: h, shrinkAxisMask: d } = r, { finalShapeSparse: f, finalShape: p, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: b, end: v, strides: x } = P.slice_util.sliceInfo(i.shape, a, o, s, u, l, c, h, d); let w; if (m) w = U_({ inputs: { x: i }, backend: n, attrs: { shape: p } }); else if (g || y) { P.util.assert(i.shape.length >= 1, (() => `Input must have rank at least 1, got: ${i.shape.length}`)); const e = P.slice_util.computeOutShape(b, v, x), t = YC({ inputs: { x: i }, backend: n, attrs: { begin: b, size: e } }); w = U_({ inputs: { x: t }, backend: n, attrs: { shape: p } }), n.disposeIntermediateTensorInfo(t) } else { if (n.shouldExecuteOnCPU([i])) { const e = n.readSync(i.dataId), t = (0, P.buffer)(i.shape, i.dtype, e), r = BS(f, t, x, b); w = n.makeTensorInfo(p, i.dtype, r.values) } else { const e = new BI(b, x, f); w = n.runWebGLProgram(e, [i], i.dtype) } } const k = U_({ inputs: { x: w }, backend: n, attrs: { shape: p } }); return n.disposeIntermediateTensorInfo(w), k } + }; const jI = { + kernelName: P.StringNGrams, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { separator: i, nGramWidths: a, leftPad: o, rightPad: s, padWidth: u, preserveShortSequences: l } = r, { data: c, dataSplits: h } = t, d = n.readSync(c.dataId), f = n.readSync(h.dataId), [p, m] = LS(d, f, i, a, o, s, u, l); return [n.makeTensorInfo([p.length], "string", p), n.makeTensorInfo(h.shape, "int32", m)] } + }; const UI = { + kernelName: P.StringSplit, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { skipEmpty: i } = r, { input: a, delimiter: o } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (1 !== a.shape.length) throw new Error(`Input must be a vector, got shape: ${a.shape}`); if (0 !== o.shape.length) throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`); const s = n.readSync(a.dataId), u = n.readSync(o.dataId)[0], [l, c, h] = jS(s, u, i), d = c.length; return [n.makeTensorInfo([d, 2], "int32", l), n.makeTensorInfo([d], "string", c), n.makeTensorInfo([2], "int32", new Int32Array(h))] } + }; const WI = { + kernelName: P.StringToHashBucketFast, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { numBuckets: i } = r, { input: a } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (i <= 0) throw new Error("Number of buckets must be at least 1"); const o = n.readSync(a.dataId), s = US(o, i); return n.makeTensorInfo(a.shape, "int32", s) } + }, VI = F_({ opSnippet: "return tan(x);" }), GI = { kernelName: P.Tan, backendName: "webgl", kernelFunc: VI }, HI = F_({ opSnippet: "\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n" }), qI = { kernelName: P.Tanh, backendName: "webgl", kernelFunc: HI }; const YI = { + kernelName: P.TensorScatterUpdate, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { tensor: i, indices: a, updates: o } = t, { } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(o, a, i.shape), d = [h / l, l]; if (0 === h) return n.makeTensorInfo(i.shape, a.dtype); const f = U_({ inputs: { x: a }, backend: n, attrs: { shape: [u, s] } }), p = U_({ inputs: { x: o }, backend: n, attrs: { shape: [u, l] } }), m = U_({ inputs: { x: i }, backend: n, attrs: { shape: d } }), g = new rI(u, s, f.shape.length, p.shape.length, c, d, !1, !0), y = n.runWebGLProgram(g, [p, f, m], m.dtype), b = U_({ inputs: { x: y }, backend: n, attrs: { shape: i.shape } }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(y), b } + }; + /** + * @license + * Copyright 2017 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class XI { constructor(e, t) { this.variableNames = ["A"]; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[r] * t[r]; this.outputShape = n, this.rank = n.length; const r = gk(this.rank), i = function (e) { const t = e.length; if (t > 5) throw Error(`Tile for rank ${t} is not yet supported`); if (1 === t) return `imod(resRC, ${e[0]})`; const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u"], r = []; for (let t = 0; t < e.length; t++)r.push(`imod(${n[t]}, ${e[t]})`); return r.join() }(e); this.userCode = `\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${i}));\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function KI(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reps: a } = r; if ("string" === i.dtype || i.shape.length > 5) { const e = n.readSync(i.dataId), t = "string" === i.dtype ? e.map((e => P.util.decodeString(e))) : e, r = (0, P.buffer)(i.shape, i.dtype, t), o = VS(r, a); return n.makeTensorInfo(o.shape, o.dtype, o.values) } const o = new XI(i.shape, a); return n.runWebGLProgram(o, [i], i.dtype) } const ZI = { kernelName: P.Tile, backendName: "webgl", kernelFunc: KI }; class JI { constructor(e) { this.variableNames = ["x", "indices"], this.customUniforms = [{ name: "n", type: "int" }, { name: "firstPass", type: "int" }, { name: "negativeInf", type: "float" }, { name: "dir", type: "int" }, { name: "inc", type: "int" }], this.outputShape = e, this.userCode = "\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n " } } class QI { constructor(e) { this.variableNames = ["x", "indices"], this.customUniforms = [{ name: "n", type: "int" }, { name: "firstPass", type: "int" }, { name: "k", type: "int" }], this.outputShape = e, this.userCode = "\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n " } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function eM(e, t) { null !== t && e.disposeIntermediateTensorInfo(t) } function tM(e) { let t = 1; for (; t < e;)t *= 2; return t } const nM = { kernelName: P.TopK, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { k: a, sorted: o } = r, s = (0, P.env)().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"), u = (0, P.env)().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"), l = i.shape, c = l[l.length - 1]; if (n.shouldExecuteOnCPU([i]) || c < s || a > u) { const e = n.readSync(i.dataId), [t, r] = GS(e, l, i.dtype, a, o); return [n.makeTensorInfo(t.shape, t.dtype, t.values), n.makeTensorInfo(r.shape, r.dtype, r.values)] } if (0 === a) return l[l.length - 1] = 0, [n.makeTensorInfo(l, i.dtype, []), n.makeTensorInfo(l, "int32", [])]; if (1 === c) return [i, DT({ attrs: { shape: l, dtype: "int32", value: 0 }, backend: n })]; const h = n.texData.get(i.dataId), d = null !== h && h.isPacked, f = d ? n.unpackTensor(i) : i, p = P.util.sizeFromShape(l) / c, m = U_({ inputs: { x: f }, attrs: { shape: [p, c] }, backend: n }); d && eM(n, f); const g = tM(a), y = tM(c); let b = null; const v = () => null === b ? [m, m] : [m, b], x = (e, t, r) => { const i = v(), a = new JI(r), o = [[c], [null === b ? 1 : 0], [Number.NEGATIVE_INFINITY], [e], [t]], s = b; b = n.runWebGLProgram(a, i, "int32", o), eM(n, s) }; for (let e = 1; e < g; e *= 2) { const t = 2 * e; for (let n = e; n >= 1; n /= 2)x(t, n, [p, y]) } for (let e = y; e > g; e /= 2) { const t = v(), r = new QI([p, e / 2]), i = [[c], [null === b ? 1 : 0], [g]], a = b; b = n.runWebGLProgram(r, t, "int32", i), eM(n, a); const o = g / 2, s = 2 * o; for (let e = o; e >= 1; e /= 2)x(s, e, b.shape) } let w = b; b = YC({ inputs: { x: b }, backend: n, attrs: { begin: 0, size: [p, a] } }), eM(n, w); let k = JT({ inputs: { x: m, indices: b }, backend: n, attrs: { axis: 1, batchDims: 1 } }); eM(n, m); const S = l.slice(0, -1); S.push(a), w = b, b = U_({ inputs: { x: b }, attrs: { shape: S }, backend: n }), eM(n, w); const _ = k; return k = U_({ inputs: { x: k }, attrs: { shape: S }, backend: n }), eM(n, _), [k, b] } }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rM { constructor(e, t, n, r, i, a) { this.variableNames = ["Image", "Transforms"], this.outputShape = a; const o = "nearest" === n ? 1 : 2; let s; switch (r) { case "constant": default: s = 1; break; case "reflect": s = 2; break; case "wrap": s = 3; break; case "nearest": s = 4 }this.userCode = `\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${s} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${s} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${s} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${i});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${i});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${o} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n ` } } const iM = { + kernelName: P.Transform, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i, transforms: a } = t, { interpolation: o, fillMode: s, fillValue: u, outputShape: l } = r, [c, h, d, f] = i.shape, [p, m] = null != l ? l : [h, d], g = new rM(h, d, o, s, u, [c, p, m, f]); return n.runWebGLProgram(g, [i, a], "float32") } + }; const aM = { + kernelName: P.Unique, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, attrs: n, backend: r } = e, { axis: i } = n, { x: a } = t; Zw(a, "unique"), console.warn("WARNING: ", "UI might be locked temporarily as data is being downloaded"); const o = r.readSync(a.dataId), { outputValues: s, outputShape: u, indices: l } = qS(o, i, a.shape, a.dtype); return [r.makeTensorInfo(u, a.dtype, s), r.makeTensorInfo([l.length], "int32", l)] } + }; const oM = { + kernelName: P.Unpack, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { value: i } = t; let { axis: a } = r; a < 0 && (a += i.shape.length); const o = i, s = o.shape.length, u = i.shape[a], l = new Array(s - 1); let c = 0; for (let e = 0; e < s; e++)e !== a && (l[c++] = o.shape[e]); const h = [], d = new Array(s).fill(0), f = o.shape.slice(); f[a] = 1; const p = new Array(u); for (let e = 0; e < p.length; e++) { d[a] = e; const t = YC({ inputs: { x: o }, backend: n, attrs: { begin: d, size: f } }), r = U_({ inputs: { x: t }, backend: n, attrs: { shape: l } }); p[e] = r, h.push(t) } return h.forEach((e => n.disposeIntermediateTensorInfo(e))), p } + }; + /** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class sM { constructor(e, t) { this.variableNames = ["x", "segmentIds"]; const n = e.windowSize, r = e.batchSize, i = e.inSize, a = e.numSegments, o = a * Math.ceil(i / n); this.outputShape = [r, o]; const s = 4 * Math.floor(n / 4), u = n % 4, l = "\n sumValue += dot(values, segFilter);\n "; let c = ""; i % n > 0 && (c = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return initializationValue;\n }\n `); let h = ""; i % n > 0 && (h = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return -1.0;\n }\n `), this.userCode = `\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${h}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${a})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${a})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${l}\n }\n\n int inIdx = inOffset + ${s};\n if (${1 === u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${2 === u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${3 === u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${l}\n }\n setOutput(sumValue);\n }\n ` } } const uM = { + kernelName: P.UnsortedSegmentSum, backendName: "webgl", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, segmentIds: a } = t, { numSegments: o } = r, s = i.shape.length, u = []; let l = 0; const c = P.backend_util.getAxesPermutation([l], s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), u.push(h), l = P.backend_util.getInnerMostAxes(1, s)[0]); const d = P.backend_util.segment_util.computeOutShape(h.shape, l, o), f = P.util.sizeFromShape([h.shape[l]]), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, f] } }); u.push(p); const m = (0, P.sumOutType)(i.dtype), g = (e, t, r, i, a) => { const o = e.shape[0], s = e.shape[1], l = P.backend_util.segment_util.segOpComputeOptimalWindowSize(s, a), c = new sM({ windowSize: l, inSize: s, batchSize: o, numSegments: a }, t), h = n.compileAndRun(c, [e, r], i); if (u.push(h), h.shape[1] === a) return h; const d = IN({ backend: n, attrs: { start: 0, stop: a, step: 1, dtype: "float32" } }), f = KI({ inputs: { x: d }, backend: n, attrs: { reps: [s / l] } }); u.push(d), u.push(f); return g(h, t, f, i, a) }, y = U_({ inputs: { x: g(p, "unsortedSegmentSum", a, m, o) }, backend: n, attrs: { shape: d } }); let b = y; if (null != c) { u.push(y); const e = P.backend_util.getUndoAxesPermutation(c); b = J_({ inputs: { x: b }, backend: n, attrs: { perm: e } }) } return u.forEach((e => n.disposeIntermediateTensorInfo(e))), b } + }, lM = [tC, rC, aC, sC, cC, fC, pC, mC, wC, kC, _C, AC, EC, IC, FC, RC, OC, BC, LC, jC, VC, KC, ZC, JC, QC, iA, sA, cA, __, fA, wA, NA, $A, OA, zA, PA, BA, jA, WA, GA, JA, QA, eT, nT, aT, uT, lT, hT, fT, pT, gT, yT, vT, wT, ST, CT, ET, MT, $T, OT, BT, jT, VT, qT, YT, KT, QT, tE, rE, k_, iE, bA, oE, uE, cE, T_, dE, pE, mE, yE, vE, wE, SE, CE, EE, IE, FE, $E, RE, OE, BE, LE, jE, UE, WE, GE, YE, KE, aN, j_, sN, lN, hN, fN, tA, mN, bN, vN, SN, CN, I_, AN, TN, EN, NN, MN, rA, QE, DN, RN, zN, W_, LN, UN, GN, qN, KN, JN, eI, nI, aI, sI, lI, hI, fI, mI, yI, vI, XC, iN, wI, kI, SI, _I, CI, AI, TI, EI, MI, DI, OI, zI, PI, LI, jI, UI, WI, nN, Z_, GI, qI, YI, ZI, nM, iM, Q_, aM, oM, uM, yN]; for (const e of lM) (0, P.registerKernel)(e); + /** @license See the LICENSE file. */ + const cM = { "tfjs-core": P.version_core, "tfjs-backend-cpu": Dg, "tfjs-backend-webgl": p_, "tfjs-data": rp, "tfjs-layers": Fo, "tfjs-converter": Vd, tfjs: "4.22.0" }; function hM(e, t) { return t ? new Promise(((n, r) => { e.then((e => { t(e), n(e) })).catch((e => { t(void 0, e), r(e) })) })) : e } const dM = e => "undefined" != typeof HTMLVideoElement && e instanceof HTMLVideoElement, fM = e => "undefined" != typeof HTMLAudioElement && e instanceof HTMLAudioElement, pM = e => "undefined" != typeof HTMLCanvasElement && (e instanceof HTMLCanvasElement || e instanceof OffscreenCanvas), mM = e => "undefined" != typeof HTMLImageElement && e instanceof HTMLImageElement, gM = e => "undefined" == typeof ImageData ? "object" == typeof e && (e.data instanceof Uint8ClampedArray || e.data instanceof Uint8Array) && "number" == typeof e.width && "number" == typeof e.height : e instanceof ImageData, yM = e => !!e && (pM(e) || mM(e) || dM(e)), bM = e => { if (yM(e)) return e; if ("object" == typeof e) { if (yM(e.canvas)) return e.canvas; if (yM(e.elt)) return e.elt } return null }; class vM { constructor(...e) { e.forEach((e => this.addArg(e))) } addArg(e) { var t; if (null != e) switch (typeof e) { case "string": this.set({ string: e }); break; case "number": this.set({ number: e }); break; case "function": this.set({ callback: e }); break; case "object": { ((t = e) instanceof P.Tensor && 3 === t.rank || gM(e)) && this.set({ image: e }); const n = bM(e); n && (this.set({ image: n }), dM(n) && this.set({ audio: n, video: n })), fM(e) ? this.set({ audio: e }) : Array.isArray(e) ? this.set({ array: e }) : this.set({ options: e }); break } default: throw new Error("invalid argument") } } set(e, t = !0) { Object.keys(e).forEach((n => { t && this.has(n) && console.warn(`Received multiple ${n} arguments, but only a single ${n} is supported.\n The last ${n} will be used.`), this[n] = e[n] })) } has(e) { return void 0 !== this[e] } require(e, t) { if (this.has(e)) return this; throw new Error(t || `An argument for ${e} must be provided.`) } } function xM(...e) { return new vM(...e) } function wM(e) { return Boolean(e && "function" == typeof e && e.prototype && e.prototype.registerMethod) } const kM = new class { constructor() { this.didSetupPreload = !1, this.p5Constructor = void 0, this.p5Extensions = void 0, this.ml5Library = void 0, this.methodsToPreload = [], this.findAndSetP5() } findAndSetP5() { let e; "undefined" != typeof window ? e = window : "undefined" != typeof globalThis && (e = globalThis), e && (wM(e.p5) && (this.p5Constructor = e.p5, this.registerPreloads()), function (e) { return Boolean(e && "function" == typeof e.loadImage) }(e) && (this.p5Extensions = e)) } setP5(e) { wM(e) ? (this.p5Constructor = e, this.p5Extensions = e.prototype, this.registerPreloads()) : console.warn("Invalid p5 object provided to ml5.setP5().") } setupP5Integration(e, t, n) { this.methodsToPreload = t, this.ml5Library = e, this.checkP5() ? this.registerPreloads() : this.registerAsyncConstructors(e, n) } registerAsyncConstructors(e, t) { this.methodsToPreload.forEach((n => { var r; t.includes(n) || (e[n] = (r = e[n], (...e) => { const t = r(...e); return t.ready ? t.ready.then((() => t)) : Promise.resolve(t) })) })) } registerPreloads() { if (this.didSetupPreload) return; const e = this.p5Constructor, t = this.ml5Library, n = this.methodsToPreload; if (!e || !t) return; const r = { ...t }, i = this; e.prototype.ml5Init = function () { const e = this._incrementPreload.bind(this), a = this._decrementPreload.bind(this); n.forEach((n => { t[n] = function (...t) { e(); const i = r[n](...t); return i.ready.then((() => { a() })), i } })), i.didSetupPreload = !0 }, e.prototype.ml5Remove = function () { n.forEach((e => { t[e] = r[e] })), i.didSetupPreload = !1 }, e.prototype.registerMethod("init", e.prototype.ml5Init), e.prototype.registerMethod("remove", e.prototype.ml5Remove) } get p5Instance() { return this.p5Extensions || this.findAndSetP5(), this.p5Extensions } checkP5() { return !!this.p5Instance } getBlob(e) { return new Promise(((t, n) => { e.toBlob((e => { e ? t(e) : n(new Error("Canvas could not be converted to Blob.")) })) })) } loadAsync(e) { return new Promise(((t, n) => { this.p5Instance.loadImage(e, (e => { t(e) }), (() => { n(new Error(`Could not load image from url ${e}`)) })) })) } async rawToBlob(e, t, n) { const r = Array.from(e), i = document.createElement("canvas"), a = i.getContext("2d"); i.width = t, i.height = n; const o = a.createImageData(t, n), { data: s } = o; for (let e = 0; e < t * n * 4; e += 1)s[e] = r[e]; return a.putImageData(o, 0, 0), this.getBlob(i) } async ImageDataToBlob(e, t, n) { const r = document.createElement("canvas"), i = r.getContext("2d"); return r.width = t, r.height = n, i.putImageData(e, 0, 0), this.getBlob(r) } async blobToP5Image(e) { return this.checkP5() && "undefined" != typeof URL ? this.loadAsync(URL.createObjectURL(e)) : null } }, SM = e => { const t = gM(e) ? e : bM(e); if (pM(t)) return t; if (!t) throw new Error("Invalid image. Image must be one of: HTMLCanvasElement, HTMLImageElement, HTMLVideoElement, ImageData, p5.Image, p5.Graphics, or p5.Video."); const n = t.videoWidth || t.width, r = t.videoHeight || t.height, i = document.createElement("canvas"); i.width = n, i.height = r; const a = i.getContext("2d"); return gM(e) ? a.putImageData(e, 0, 0) : a.drawImage(t, 0, 0, n, r), i }; function _M(e, t = null) { return P.tidy((() => { let n = P.browser.fromPixels(e); t && (n = P.image.resizeBilinear(n, t)); const r = (e => { const t = Math.min(e.shape[0], e.shape[1]), n = e.shape[0] / 2 - t / 2, r = e.shape[1] / 2 - t / 2; return e.slice([n, r, 0], [t, t, 3]) })(n); return r.expandDims(0).toFloat().div(P.scalar(127)).sub(P.scalar(1)) })) } function CM(e) { return yM(e) || gM(e) } async function AM(e, t) { e && (dM(e) || fM(e)) ? (t && await P.nextFrame(), 0 === e.readyState && await new Promise(((t, n) => { e.addEventListener("error", (() => n(e.error))), e.addEventListener("loadeddata", t) }))) : e && mM(e) && (e.complete || await new Promise(((t, n) => { e.addEventListener("error", n), e.addEventListener("load", t) }))) } function TM(e, t, n) { return P.tidy((() => { const r = P.browser.fromPixels(e); return P.image.resizeBilinear(r, [n, t]).clipByValue(0, 255) })) } const EM = async (e, t, n) => { const r = document.createElement("a"); r.style.display = "none", document.body.appendChild(r); const i = new Blob([e], { type: n }); r.href = URL.createObjectURL(i), r.download = t, r.click() }, NM = (e = 0, t = 1) => Math.random() * (t - e) + e, IM = (e = 0, t = 1) => { let n, r, i, a, o, s; if (s) n = r, s = !1; else { do { i = NM(0, 2) - 1, a = NM(0, 2) - 1, o = i * i + a * a } while (o >= 1); o = Math.sqrt(-2 * Math.log(o) / o), n = i * o, r = a * o, s = !0 } return n * t + e }; const MM = class { constructor() { this.isTrained = !1, this.isCompiled = !1, this.isLayered = !1, this.model = null, this.init = this.init.bind(this), this.createModel = this.createModel.bind(this), this.addLayer = this.addLayer.bind(this), this.compile = this.compile.bind(this), this.setOptimizerFunction = this.setOptimizerFunction.bind(this), this.train = this.train.bind(this), this.predict = this.predict.bind(this), this.classify = this.classify.bind(this), this.save = this.save.bind(this), this.load = this.load.bind(this), this.init() } init() { this.createModel() } createModel(e = "sequential") { return e.toLowerCase(), this.model = is(), this.model } addLayer(e) { this.model.add(e), this.model.layers.length >= 2 && (this.isLayered = !0) } compile(e) { this.model.compile(e), this.isCompiled = !0 } setOptimizerFunction(e, t) { return t.call(this, e) } async train(e) { const t = e, n = t.inputs, r = t.outputs, { batchSize: i, epochs: a, shuffle: o, validationSplit: s, whileTraining: u } = t; await this.model.fit(n, r, { batchSize: i, epochs: a, shuffle: o, validationSplit: s, callbacks: u }), n.dispose(), r.dispose(), this.isTrained = !0 } predictSync(e) { const t = P.tidy((() => this.model.predict(e))), n = t.arraySync(); return t.dispose(), e.dispose(), n } async predict(e) { const t = P.tidy((() => this.model.predict(e))), n = await t.array(); return t.dispose(), e.dispose(), n } async classify(e) { return this.predict(e) } classifySync(e) { return this.predictSync(e) } async save(e = "model") { await this.model.save(P.io.withSaveHandler((async t => { this.weightsManifest = { modelTopology: t.modelTopology, weightsManifest: [{ paths: [`./${e}.weights.bin`], weights: t.weightSpecs }] }, await EM(t.weightData, `${e}.weights.bin`, "application/octet-stream"), await EM(JSON.stringify(this.weightsManifest), `${e}.json`, "text/plain") }))) } async load(e) { if (e instanceof FileList) { const t = Array.from(e), n = t.find((e => e.name.includes(".json") && !e.name.includes("_meta"))), r = t.find((e => e.name.includes(".bin"))); this.model = await ts(P.io.browserFiles([n, r])) } else this.model = e instanceof Object ? await ts(P.io.http(e.model, { weightUrlConverter: t => e.weights || t })) : await ts(e); this.isCompiled = !0, this.isLayered = !0, this.isTrained = !0 } dispose() { this.model.dispose() } mutate(e = .1, t) { P.tidy((() => { const n = this.model.getWeights(), r = []; for (let i = 0; i < n.length; i += 1) { const a = n[i], { shape: o } = n[i], s = a.dataSync().slice(); for (let n = 0; n < s.length; n += 1)Math.random() < e && (s[n] = t ? t(s[n]) : Math.min(Math.max(s[n] + IM(), -1), 1)); const u = P.tensor(s, o); r[i] = u } this.model.setWeights(r) })) } crossover(e) { return P.tidy((() => { const t = this.model.getWeights(), n = e.model.getWeights(), r = []; for (let e = 0; e < t.length; e += 1) { const i = t[e], a = n[e], { shape: o } = t[e], s = i.dataSync().slice(), u = a.dataSync().slice(); for (let e = 0; e < s.length; e += 1)Math.random() < .5 && (s[e] = u[e]); const l = P.tensor(s, o); r[e] = l } this.model.setWeights(r) })) } }; function FM(e, t) { return function () { return e.apply(t, arguments) } } const { toString: DM } = Object.prototype, { getPrototypeOf: $M } = Object, RM = (OM = Object.create(null), e => { const t = DM.call(e); return OM[t] || (OM[t] = t.slice(8, -1).toLowerCase()) }); var OM; const zM = e => (e = e.toLowerCase(), t => RM(t) === e), PM = e => t => typeof t === e, { isArray: BM } = Array, LM = PM("undefined"); const jM = zM("ArrayBuffer"); const UM = PM("string"), WM = PM("function"), VM = PM("number"), GM = e => null !== e && "object" == typeof e, HM = e => { if ("object" !== RM(e)) return !1; const t = $M(e); return !(null !== t && t !== Object.prototype && null !== Object.getPrototypeOf(t) || Symbol.toStringTag in e || Symbol.iterator in e) }, qM = zM("Date"), YM = zM("File"), XM = zM("Blob"), KM = zM("FileList"), ZM = zM("URLSearchParams"), [JM, QM, eF, tF] = ["ReadableStream", "Request", "Response", "Headers"].map(zM); function nF(e, t, { allOwnKeys: n = !1 } = {}) { if (null == e) return; let r, i; if ("object" != typeof e && (e = [e]), BM(e)) for (r = 0, i = e.length; r < i; r++)t.call(null, e[r], r, e); else { const i = n ? Object.getOwnPropertyNames(e) : Object.keys(e), a = i.length; let o; for (r = 0; r < a; r++)o = i[r], t.call(null, e[o], o, e) } } function rF(e, t) { t = t.toLowerCase(); const n = Object.keys(e); let r, i = n.length; for (; i-- > 0;)if (r = n[i], t === r.toLowerCase()) return r; return null } const iF = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof window ? window : global, aF = e => !LM(e) && e !== iF; const oF = (sF = "undefined" != typeof Uint8Array && $M(Uint8Array), e => sF && e instanceof sF); var sF; const uF = zM("HTMLFormElement"), lF = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), cF = zM("RegExp"), hF = (e, t) => { const n = Object.getOwnPropertyDescriptors(e), r = {}; nF(n, ((n, i) => { let a; !1 !== (a = t(n, i, e)) && (r[i] = a || n) })), Object.defineProperties(e, r) }, dF = "abcdefghijklmnopqrstuvwxyz", fF = "0123456789", pF = { DIGIT: fF, ALPHA: dF, ALPHA_DIGIT: dF + dF.toUpperCase() + fF }; const mF = zM("AsyncFunction"), gF = (yF = "function" == typeof setImmediate, bF = WM(iF.postMessage), yF ? setImmediate : bF ? (vF = `axios@${Math.random()}`, xF = [], iF.addEventListener("message", (({ source: e, data: t }) => { e === iF && t === vF && xF.length && xF.shift()() }), !1), e => { xF.push(e), iF.postMessage(vF, "*") }) : e => setTimeout(e)); var yF, bF, vF, xF; const wF = "undefined" != typeof queueMicrotask ? queueMicrotask.bind(iF) : "undefined" != typeof process && process.nextTick || gF, kF = { isArray: BM, isArrayBuffer: jM, isBuffer: function (e) { return null !== e && !LM(e) && null !== e.constructor && !LM(e.constructor) && WM(e.constructor.isBuffer) && e.constructor.isBuffer(e) }, isFormData: e => { let t; return e && ("function" == typeof FormData && e instanceof FormData || WM(e.append) && ("formdata" === (t = RM(e)) || "object" === t && WM(e.toString) && "[object FormData]" === e.toString())) }, isArrayBufferView: function (e) { let t; return t = "undefined" != typeof ArrayBuffer && ArrayBuffer.isView ? ArrayBuffer.isView(e) : e && e.buffer && jM(e.buffer), t }, isString: UM, isNumber: VM, isBoolean: e => !0 === e || !1 === e, isObject: GM, isPlainObject: HM, isReadableStream: JM, isRequest: QM, isResponse: eF, isHeaders: tF, isUndefined: LM, isDate: qM, isFile: YM, isBlob: XM, isRegExp: cF, isFunction: WM, isStream: e => GM(e) && WM(e.pipe), isURLSearchParams: ZM, isTypedArray: oF, isFileList: KM, forEach: nF, merge: function e() { const { caseless: t } = aF(this) && this || {}, n = {}, r = (r, i) => { const a = t && rF(n, i) || i; HM(n[a]) && HM(r) ? n[a] = e(n[a], r) : HM(r) ? n[a] = e({}, r) : BM(r) ? n[a] = r.slice() : n[a] = r }; for (let e = 0, t = arguments.length; e < t; e++)arguments[e] && nF(arguments[e], r); return n }, extend: (e, t, n, { allOwnKeys: r } = {}) => (nF(t, ((t, r) => { n && WM(t) ? e[r] = FM(t, n) : e[r] = t }), { allOwnKeys: r }), e), trim: e => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), stripBOM: e => (65279 === e.charCodeAt(0) && (e = e.slice(1)), e), inherits: (e, t, n, r) => { e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", { value: t.prototype }), n && Object.assign(e.prototype, n) }, toFlatObject: (e, t, n, r) => { let i, a, o; const s = {}; if (t = t || {}, null == e) return t; do { for (i = Object.getOwnPropertyNames(e), a = i.length; a-- > 0;)o = i[a], r && !r(o, e, t) || s[o] || (t[o] = e[o], s[o] = !0); e = !1 !== n && $M(e) } while (e && (!n || n(e, t)) && e !== Object.prototype); return t }, kindOf: RM, kindOfTest: zM, endsWith: (e, t, n) => { e = String(e), (void 0 === n || n > e.length) && (n = e.length), n -= t.length; const r = e.indexOf(t, n); return -1 !== r && r === n }, toArray: e => { if (!e) return null; if (BM(e)) return e; let t = e.length; if (!VM(t)) return null; const n = new Array(t); for (; t-- > 0;)n[t] = e[t]; return n }, forEachEntry: (e, t) => { const n = (e && e[Symbol.iterator]).call(e); let r; for (; (r = n.next()) && !r.done;) { const n = r.value; t.call(e, n[0], n[1]) } }, matchAll: (e, t) => { let n; const r = []; for (; null !== (n = e.exec(t));)r.push(n); return r }, isHTMLForm: uF, hasOwnProperty: lF, hasOwnProp: lF, reduceDescriptors: hF, freezeMethods: e => { hF(e, ((t, n) => { if (WM(e) && -1 !== ["arguments", "caller", "callee"].indexOf(n)) return !1; const r = e[n]; WM(r) && (t.enumerable = !1, "writable" in t ? t.writable = !1 : t.set || (t.set = () => { throw Error("Can not rewrite read-only method '" + n + "'") })) })) }, toObjectSet: (e, t) => { const n = {}, r = e => { e.forEach((e => { n[e] = !0 })) }; return BM(e) ? r(e) : r(String(e).split(t)), n }, toCamelCase: e => e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, (function (e, t, n) { return t.toUpperCase() + n })), noop: () => { }, toFiniteNumber: (e, t) => null != e && Number.isFinite(e = +e) ? e : t, findKey: rF, global: iF, isContextDefined: aF, ALPHABET: pF, generateString: (e = 16, t = pF.ALPHA_DIGIT) => { let n = ""; const { length: r } = t; for (; e--;)n += t[Math.random() * r | 0]; return n }, isSpecCompliantForm: function (e) { return !!(e && WM(e.append) && "FormData" === e[Symbol.toStringTag] && e[Symbol.iterator]) }, toJSONObject: e => { const t = new Array(10), n = (e, r) => { if (GM(e)) { if (t.indexOf(e) >= 0) return; if (!("toJSON" in e)) { t[r] = e; const i = BM(e) ? [] : {}; return nF(e, ((e, t) => { const a = n(e, r + 1); !LM(a) && (i[t] = a) })), t[r] = void 0, i } } return e }; return n(e, 0) }, isAsyncFn: mF, isThenable: e => e && (GM(e) || WM(e)) && WM(e.then) && WM(e.catch), setImmediate: gF, asap: wF }; function SF(e, t, n, r, i) { Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = (new Error).stack, this.message = e, this.name = "AxiosError", t && (this.code = t), n && (this.config = n), r && (this.request = r), i && (this.response = i, this.status = i.status ? i.status : null) } kF.inherits(SF, Error, { toJSON: function () { return { message: this.message, name: this.name, description: this.description, number: this.number, fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, config: kF.toJSONObject(this.config), code: this.code, status: this.status } } }); const _F = SF.prototype, CF = {};["ERR_BAD_OPTION_VALUE", "ERR_BAD_OPTION", "ECONNABORTED", "ETIMEDOUT", "ERR_NETWORK", "ERR_FR_TOO_MANY_REDIRECTS", "ERR_DEPRECATED", "ERR_BAD_RESPONSE", "ERR_BAD_REQUEST", "ERR_CANCELED", "ERR_NOT_SUPPORT", "ERR_INVALID_URL"].forEach((e => { CF[e] = { value: e } })), Object.defineProperties(SF, CF), Object.defineProperty(_F, "isAxiosError", { value: !0 }), SF.from = (e, t, n, r, i, a) => { const o = Object.create(_F); return kF.toFlatObject(e, o, (function (e) { return e !== Error.prototype }), (e => "isAxiosError" !== e)), SF.call(o, e.message, t, n, r, i), o.cause = e, o.name = e.name, a && Object.assign(o, a), o }; const AF = SF; function TF(e) { return kF.isPlainObject(e) || kF.isArray(e) } function EF(e) { return kF.endsWith(e, "[]") ? e.slice(0, -2) : e } function NF(e, t, n) { return e ? e.concat(t).map((function (e, t) { return e = EF(e), !n && t ? "[" + e + "]" : e })).join(n ? "." : "") : t } const IF = kF.toFlatObject(kF, {}, null, (function (e) { return /^is[A-Z]/.test(e) })); const MF = function (e, t, n) { if (!kF.isObject(e)) throw new TypeError("target must be an object"); t = t || new FormData; const r = (n = kF.toFlatObject(n, { metaTokens: !0, dots: !1, indexes: !1 }, !1, (function (e, t) { return !kF.isUndefined(t[e]) }))).metaTokens, i = n.visitor || l, a = n.dots, o = n.indexes, s = (n.Blob || "undefined" != typeof Blob && Blob) && kF.isSpecCompliantForm(t); if (!kF.isFunction(i)) throw new TypeError("visitor must be a function"); function u(e) { if (null === e) return ""; if (kF.isDate(e)) return e.toISOString(); if (!s && kF.isBlob(e)) throw new AF("Blob is not supported. Use a Buffer instead."); return kF.isArrayBuffer(e) || kF.isTypedArray(e) ? s && "function" == typeof Blob ? new Blob([e]) : Buffer.from(e) : e } function l(e, n, i) { let s = e; if (e && !i && "object" == typeof e) if (kF.endsWith(n, "{}")) n = r ? n : n.slice(0, -2), e = JSON.stringify(e); else if (kF.isArray(e) && function (e) { return kF.isArray(e) && !e.some(TF) }(e) || (kF.isFileList(e) || kF.endsWith(n, "[]")) && (s = kF.toArray(e))) return n = EF(n), s.forEach((function (e, r) { !kF.isUndefined(e) && null !== e && t.append(!0 === o ? NF([n], r, a) : null === o ? n : n + "[]", u(e)) })), !1; return !!TF(e) || (t.append(NF(i, n, a), u(e)), !1) } const c = [], h = Object.assign(IF, { defaultVisitor: l, convertValue: u, isVisitable: TF }); if (!kF.isObject(e)) throw new TypeError("data must be an object"); return function e(n, r) { if (!kF.isUndefined(n)) { if (-1 !== c.indexOf(n)) throw Error("Circular reference detected in " + r.join(".")); c.push(n), kF.forEach(n, (function (n, a) { !0 === (!(kF.isUndefined(n) || null === n) && i.call(t, n, kF.isString(a) ? a.trim() : a, r, h)) && e(n, r ? r.concat(a) : [a]) })), c.pop() } }(e), t }; function FF(e) { const t = { "!": "%21", "'": "%27", "(": "%28", ")": "%29", "~": "%7E", "%20": "+", "%00": "\0" }; return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, (function (e) { return t[e] })) } function DF(e, t) { this._pairs = [], e && MF(e, this, t) } const $F = DF.prototype; $F.append = function (e, t) { this._pairs.push([e, t]) }, $F.toString = function (e) { const t = e ? function (t) { return e.call(this, t, FF) } : FF; return this._pairs.map((function (e) { return t(e[0]) + "=" + t(e[1]) }), "").join("&") }; const RF = DF; function OF(e) { return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]") } function zF(e, t, n) { if (!t) return e; const r = n && n.encode || OF; kF.isFunction(n) && (n = { serialize: n }); const i = n && n.serialize; let a; if (a = i ? i(t, n) : kF.isURLSearchParams(t) ? t.toString() : new RF(t, n).toString(r), a) { const t = e.indexOf("#"); -1 !== t && (e = e.slice(0, t)), e += (-1 === e.indexOf("?") ? "?" : "&") + a } return e } const PF = class { constructor() { this.handlers = [] } use(e, t, n) { return this.handlers.push({ fulfilled: e, rejected: t, synchronous: !!n && n.synchronous, runWhen: n ? n.runWhen : null }), this.handlers.length - 1 } eject(e) { this.handlers[e] && (this.handlers[e] = null) } clear() { this.handlers && (this.handlers = []) } forEach(e) { kF.forEach(this.handlers, (function (t) { null !== t && e(t) })) } }, BF = { silentJSONParsing: !0, forcedJSONParsing: !0, clarifyTimeoutError: !1 }, LF = { isBrowser: !0, classes: { URLSearchParams: "undefined" != typeof URLSearchParams ? URLSearchParams : RF, FormData: "undefined" != typeof FormData ? FormData : null, Blob: "undefined" != typeof Blob ? Blob : null }, protocols: ["http", "https", "file", "blob", "url", "data"] }, jF = "undefined" != typeof window && "undefined" != typeof document, UF = "object" == typeof navigator && navigator || void 0, WF = jF && (!UF || ["ReactNative", "NativeScript", "NS"].indexOf(UF.product) < 0), VF = "undefined" != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope && "function" == typeof self.importScripts, GF = jF && window.location.href || "http://localhost", HF = { ...D, ...LF }; const qF = function (e) { function t(e, n, r, i) { let a = e[i++]; if ("__proto__" === a) return !0; const o = Number.isFinite(+a), s = i >= e.length; if (a = !a && kF.isArray(r) ? r.length : a, s) return kF.hasOwnProp(r, a) ? r[a] = [r[a], n] : r[a] = n, !o; r[a] && kF.isObject(r[a]) || (r[a] = []); return t(e, n, r[a], i) && kF.isArray(r[a]) && (r[a] = function (e) { const t = {}, n = Object.keys(e); let r; const i = n.length; let a; for (r = 0; r < i; r++)a = n[r], t[a] = e[a]; return t }(r[a])), !o } if (kF.isFormData(e) && kF.isFunction(e.entries)) { const n = {}; return kF.forEachEntry(e, ((e, r) => { t(function (e) { return kF.matchAll(/\w+|\[(\w*)]/g, e).map((e => "[]" === e[0] ? "" : e[1] || e[0])) }(e), r, n, 0) })), n } return null }; const YF = { transitional: BF, adapter: ["xhr", "http", "fetch"], transformRequest: [function (e, t) { const n = t.getContentType() || "", r = n.indexOf("application/json") > -1, i = kF.isObject(e); i && kF.isHTMLForm(e) && (e = new FormData(e)); if (kF.isFormData(e)) return r ? JSON.stringify(qF(e)) : e; if (kF.isArrayBuffer(e) || kF.isBuffer(e) || kF.isStream(e) || kF.isFile(e) || kF.isBlob(e) || kF.isReadableStream(e)) return e; if (kF.isArrayBufferView(e)) return e.buffer; if (kF.isURLSearchParams(e)) return t.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString(); let a; if (i) { if (n.indexOf("application/x-www-form-urlencoded") > -1) return function (e, t) { return MF(e, new HF.classes.URLSearchParams, Object.assign({ visitor: function (e, t, n, r) { return HF.isNode && kF.isBuffer(e) ? (this.append(t, e.toString("base64")), !1) : r.defaultVisitor.apply(this, arguments) } }, t)) }(e, this.formSerializer).toString(); if ((a = kF.isFileList(e)) || n.indexOf("multipart/form-data") > -1) { const t = this.env && this.env.FormData; return MF(a ? { "files[]": e } : e, t && new t, this.formSerializer) } } return i || r ? (t.setContentType("application/json", !1), function (e, t, n) { if (kF.isString(e)) try { return (t || JSON.parse)(e), kF.trim(e) } catch (e) { if ("SyntaxError" !== e.name) throw e } return (n || JSON.stringify)(e) }(e)) : e }], transformResponse: [function (e) { const t = this.transitional || YF.transitional, n = t && t.forcedJSONParsing, r = "json" === this.responseType; if (kF.isResponse(e) || kF.isReadableStream(e)) return e; if (e && kF.isString(e) && (n && !this.responseType || r)) { const n = !(t && t.silentJSONParsing) && r; try { return JSON.parse(e) } catch (e) { if (n) { if ("SyntaxError" === e.name) throw AF.from(e, AF.ERR_BAD_RESPONSE, this, null, this.response); throw e } } } return e }], timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", maxContentLength: -1, maxBodyLength: -1, env: { FormData: HF.classes.FormData, Blob: HF.classes.Blob }, validateStatus: function (e) { return e >= 200 && e < 300 }, headers: { common: { Accept: "application/json, text/plain, */*", "Content-Type": void 0 } } }; kF.forEach(["delete", "get", "head", "post", "put", "patch"], (e => { YF.headers[e] = {} })); const XF = YF, KF = kF.toObjectSet(["age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent"]), ZF = Symbol("internals"); function JF(e) { return e && String(e).trim().toLowerCase() } function QF(e) { return !1 === e || null == e ? e : kF.isArray(e) ? e.map(QF) : String(e) } function eD(e, t, n, r, i) { return kF.isFunction(r) ? r.call(this, t, n) : (i && (t = n), kF.isString(t) ? kF.isString(r) ? -1 !== t.indexOf(r) : kF.isRegExp(r) ? r.test(t) : void 0 : void 0) } class tD { constructor(e) { e && this.set(e) } set(e, t, n) { const r = this; function i(e, t, n) { const i = JF(t); if (!i) throw new Error("header name must be a non-empty string"); const a = kF.findKey(r, i); (!a || void 0 === r[a] || !0 === n || void 0 === n && !1 !== r[a]) && (r[a || t] = QF(e)) } const a = (e, t) => kF.forEach(e, ((e, n) => i(e, n, t))); if (kF.isPlainObject(e) || e instanceof this.constructor) a(e, t); else if (kF.isString(e) && (e = e.trim()) && !/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())) a((e => { const t = {}; let n, r, i; return e && e.split("\n").forEach((function (e) { i = e.indexOf(":"), n = e.substring(0, i).trim().toLowerCase(), r = e.substring(i + 1).trim(), !n || t[n] && KF[n] || ("set-cookie" === n ? t[n] ? t[n].push(r) : t[n] = [r] : t[n] = t[n] ? t[n] + ", " + r : r) })), t })(e), t); else if (kF.isHeaders(e)) for (const [t, r] of e.entries()) i(r, t, n); else null != e && i(t, e, n); return this } get(e, t) { if (e = JF(e)) { const n = kF.findKey(this, e); if (n) { const e = this[n]; if (!t) return e; if (!0 === t) return function (e) { const t = Object.create(null), n = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; let r; for (; r = n.exec(e);)t[r[1]] = r[2]; return t }(e); if (kF.isFunction(t)) return t.call(this, e, n); if (kF.isRegExp(t)) return t.exec(e); throw new TypeError("parser must be boolean|regexp|function") } } } has(e, t) { if (e = JF(e)) { const n = kF.findKey(this, e); return !(!n || void 0 === this[n] || t && !eD(0, this[n], n, t)) } return !1 } delete(e, t) { const n = this; let r = !1; function i(e) { if (e = JF(e)) { const i = kF.findKey(n, e); !i || t && !eD(0, n[i], i, t) || (delete n[i], r = !0) } } return kF.isArray(e) ? e.forEach(i) : i(e), r } clear(e) { const t = Object.keys(this); let n = t.length, r = !1; for (; n--;) { const i = t[n]; e && !eD(0, this[i], i, e, !0) || (delete this[i], r = !0) } return r } normalize(e) { const t = this, n = {}; return kF.forEach(this, ((r, i) => { const a = kF.findKey(n, i); if (a) return t[a] = QF(r), void delete t[i]; const o = e ? function (e) { return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, ((e, t, n) => t.toUpperCase() + n)) }(i) : String(i).trim(); o !== i && delete t[i], t[o] = QF(r), n[o] = !0 })), this } concat(...e) { return this.constructor.concat(this, ...e) } toJSON(e) { const t = Object.create(null); return kF.forEach(this, ((n, r) => { null != n && !1 !== n && (t[r] = e && kF.isArray(n) ? n.join(", ") : n) })), t } [Symbol.iterator]() { return Object.entries(this.toJSON())[Symbol.iterator]() } toString() { return Object.entries(this.toJSON()).map((([e, t]) => e + ": " + t)).join("\n") } get [Symbol.toStringTag]() { return "AxiosHeaders" } static from(e) { return e instanceof this ? e : new this(e) } static concat(e, ...t) { const n = new this(e); return t.forEach((e => n.set(e))), n } static accessor(e) { const t = (this[ZF] = this[ZF] = { accessors: {} }).accessors, n = this.prototype; function r(e) { const r = JF(e); t[r] || (!function (e, t) { const n = kF.toCamelCase(" " + t);["get", "set", "has"].forEach((r => { Object.defineProperty(e, r + n, { value: function (e, n, i) { return this[r].call(this, t, e, n, i) }, configurable: !0 }) })) }(n, e), t[r] = !0) } return kF.isArray(e) ? e.forEach(r) : r(e), this } } tD.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]), kF.reduceDescriptors(tD.prototype, (({ value: e }, t) => { let n = t[0].toUpperCase() + t.slice(1); return { get: () => e, set(e) { this[n] = e } } })), kF.freezeMethods(tD); const nD = tD; function rD(e, t) { const n = this || XF, r = t || n, i = nD.from(r.headers); let a = r.data; return kF.forEach(e, (function (e) { a = e.call(n, a, i.normalize(), t ? t.status : void 0) })), i.normalize(), a } function iD(e) { return !(!e || !e.__CANCEL__) } function aD(e, t, n) { AF.call(this, null == e ? "canceled" : e, AF.ERR_CANCELED, t, n), this.name = "CanceledError" } kF.inherits(aD, AF, { __CANCEL__: !0 }); const oD = aD; function sD(e, t, n) { const r = n.config.validateStatus; n.status && r && !r(n.status) ? t(new AF("Request failed with status code " + n.status, [AF.ERR_BAD_REQUEST, AF.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4], n.config, n.request, n)) : e(n) } const uD = function (e, t) { e = e || 10; const n = new Array(e), r = new Array(e); let i, a = 0, o = 0; return t = void 0 !== t ? t : 1e3, function (s) { const u = Date.now(), l = r[o]; i || (i = u), n[a] = s, r[a] = u; let c = o, h = 0; for (; c !== a;)h += n[c++], c %= e; if (a = (a + 1) % e, a === o && (o = (o + 1) % e), u - i < t) return; const d = l && u - l; return d ? Math.round(1e3 * h / d) : void 0 } }; const lD = function (e, t) { let n, r, i = 0, a = 1e3 / t; const o = (t, a = Date.now()) => { i = a, n = null, r && (clearTimeout(r), r = null), e.apply(null, t) }; return [(...e) => { const t = Date.now(), s = t - i; s >= a ? o(e, t) : (n = e, r || (r = setTimeout((() => { r = null, o(n) }), a - s))) }, () => n && o(n)] }, cD = (e, t, n = 3) => { let r = 0; const i = uD(50, 250); return lD((n => { const a = n.loaded, o = n.lengthComputable ? n.total : void 0, s = a - r, u = i(s); r = a; e({ loaded: a, total: o, progress: o ? a / o : void 0, bytes: s, rate: u || void 0, estimated: u && o && a <= o ? (o - a) / u : void 0, event: n, lengthComputable: null != o, [t ? "download" : "upload"]: !0 }) }), n) }, hD = (e, t) => { const n = null != e; return [r => t[0]({ lengthComputable: n, total: e, loaded: r }), t[1]] }, dD = e => (...t) => kF.asap((() => e(...t))), fD = HF.hasStandardBrowserEnv ? (pD = new URL(HF.origin), mD = HF.navigator && /(msie|trident)/i.test(HF.navigator.userAgent), e => (e = new URL(e, HF.origin), pD.protocol === e.protocol && pD.host === e.host && (mD || pD.port === e.port))) : () => !0; var pD, mD; const gD = HF.hasStandardBrowserEnv ? { write(e, t, n, r, i, a) { const o = [e + "=" + encodeURIComponent(t)]; kF.isNumber(n) && o.push("expires=" + new Date(n).toGMTString()), kF.isString(r) && o.push("path=" + r), kF.isString(i) && o.push("domain=" + i), !0 === a && o.push("secure"), document.cookie = o.join("; ") }, read(e) { const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)")); return t ? decodeURIComponent(t[3]) : null }, remove(e) { this.write(e, "", Date.now() - 864e5) } } : { write() { }, read: () => null, remove() { } }; function yD(e, t) { return e && !/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? function (e, t) { return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e }(e, t) : t } const bD = e => e instanceof nD ? { ...e } : e; function vD(e, t) { t = t || {}; const n = {}; function r(e, t, n, r) { return kF.isPlainObject(e) && kF.isPlainObject(t) ? kF.merge.call({ caseless: r }, e, t) : kF.isPlainObject(t) ? kF.merge({}, t) : kF.isArray(t) ? t.slice() : t } function i(e, t, n, i) { return kF.isUndefined(t) ? kF.isUndefined(e) ? void 0 : r(void 0, e, 0, i) : r(e, t, 0, i) } function a(e, t) { if (!kF.isUndefined(t)) return r(void 0, t) } function o(e, t) { return kF.isUndefined(t) ? kF.isUndefined(e) ? void 0 : r(void 0, e) : r(void 0, t) } function s(n, i, a) { return a in t ? r(n, i) : a in e ? r(void 0, n) : void 0 } const u = { url: a, method: a, data: a, baseURL: o, transformRequest: o, transformResponse: o, paramsSerializer: o, timeout: o, timeoutMessage: o, withCredentials: o, withXSRFToken: o, adapter: o, responseType: o, xsrfCookieName: o, xsrfHeaderName: o, onUploadProgress: o, onDownloadProgress: o, decompress: o, maxContentLength: o, maxBodyLength: o, beforeRedirect: o, transport: o, httpAgent: o, httpsAgent: o, cancelToken: o, socketPath: o, responseEncoding: o, validateStatus: s, headers: (e, t, n) => i(bD(e), bD(t), 0, !0) }; return kF.forEach(Object.keys(Object.assign({}, e, t)), (function (r) { const a = u[r] || i, o = a(e[r], t[r], r); kF.isUndefined(o) && a !== s || (n[r] = o) })), n } const xD = e => { const t = vD({}, e); let n, { data: r, withXSRFToken: i, xsrfHeaderName: a, xsrfCookieName: o, headers: s, auth: u } = t; if (t.headers = s = nD.from(s), t.url = zF(yD(t.baseURL, t.url), e.params, e.paramsSerializer), u && s.set("Authorization", "Basic " + btoa((u.username || "") + ":" + (u.password ? unescape(encodeURIComponent(u.password)) : ""))), kF.isFormData(r)) if (HF.hasStandardBrowserEnv || HF.hasStandardBrowserWebWorkerEnv) s.setContentType(void 0); else if (!1 !== (n = s.getContentType())) { const [e, ...t] = n ? n.split(";").map((e => e.trim())).filter(Boolean) : []; s.setContentType([e || "multipart/form-data", ...t].join("; ")) } if (HF.hasStandardBrowserEnv && (i && kF.isFunction(i) && (i = i(t)), i || !1 !== i && fD(t.url))) { const e = a && o && gD.read(o); e && s.set(a, e) } return t }, wD = "undefined" != typeof XMLHttpRequest && function (e) { return new Promise((function (t, n) { const r = xD(e); let i = r.data; const a = nD.from(r.headers).normalize(); let o, s, u, l, c, { responseType: h, onUploadProgress: d, onDownloadProgress: f } = r; function p() { l && l(), c && c(), r.cancelToken && r.cancelToken.unsubscribe(o), r.signal && r.signal.removeEventListener("abort", o) } let m = new XMLHttpRequest; function g() { if (!m) return; const r = nD.from("getAllResponseHeaders" in m && m.getAllResponseHeaders()); sD((function (e) { t(e), p() }), (function (e) { n(e), p() }), { data: h && "text" !== h && "json" !== h ? m.response : m.responseText, status: m.status, statusText: m.statusText, headers: r, config: e, request: m }), m = null } m.open(r.method.toUpperCase(), r.url, !0), m.timeout = r.timeout, "onloadend" in m ? m.onloadend = g : m.onreadystatechange = function () { m && 4 === m.readyState && (0 !== m.status || m.responseURL && 0 === m.responseURL.indexOf("file:")) && setTimeout(g) }, m.onabort = function () { m && (n(new AF("Request aborted", AF.ECONNABORTED, e, m)), m = null) }, m.onerror = function () { n(new AF("Network Error", AF.ERR_NETWORK, e, m)), m = null }, m.ontimeout = function () { let t = r.timeout ? "timeout of " + r.timeout + "ms exceeded" : "timeout exceeded"; const i = r.transitional || BF; r.timeoutErrorMessage && (t = r.timeoutErrorMessage), n(new AF(t, i.clarifyTimeoutError ? AF.ETIMEDOUT : AF.ECONNABORTED, e, m)), m = null }, void 0 === i && a.setContentType(null), "setRequestHeader" in m && kF.forEach(a.toJSON(), (function (e, t) { m.setRequestHeader(t, e) })), kF.isUndefined(r.withCredentials) || (m.withCredentials = !!r.withCredentials), h && "json" !== h && (m.responseType = r.responseType), f && ([u, c] = cD(f, !0), m.addEventListener("progress", u)), d && m.upload && ([s, l] = cD(d), m.upload.addEventListener("progress", s), m.upload.addEventListener("loadend", l)), (r.cancelToken || r.signal) && (o = t => { m && (n(!t || t.type ? new oD(null, e, m) : t), m.abort(), m = null) }, r.cancelToken && r.cancelToken.subscribe(o), r.signal && (r.signal.aborted ? o() : r.signal.addEventListener("abort", o))); const y = function (e) { const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e); return t && t[1] || "" }(r.url); y && -1 === HF.protocols.indexOf(y) ? n(new AF("Unsupported protocol " + y + ":", AF.ERR_BAD_REQUEST, e)) : m.send(i || null) })) }, kD = (e, t) => { const { length: n } = e = e ? e.filter(Boolean) : []; if (t || n) { let n, r = new AbortController; const i = function (e) { if (!n) { n = !0, o(); const t = e instanceof Error ? e : this.reason; r.abort(t instanceof AF ? t : new oD(t instanceof Error ? t.message : t)) } }; let a = t && setTimeout((() => { a = null, i(new AF(`timeout ${t} of ms exceeded`, AF.ETIMEDOUT)) }), t); const o = () => { e && (a && clearTimeout(a), a = null, e.forEach((e => { e.unsubscribe ? e.unsubscribe(i) : e.removeEventListener("abort", i) })), e = null) }; e.forEach((e => e.addEventListener("abort", i))); const { signal: s } = r; return s.unsubscribe = () => kF.asap(o), s } }, SD = function* (e, t) { let n = e.byteLength; if (!t || n < t) return void (yield e); let r, i = 0; for (; i < n;)r = i + t, yield e.slice(i, r), i = r }, _D = async function* (e) { if (e[Symbol.asyncIterator]) return void (yield* e); const t = e.getReader(); try { for (; ;) { const { done: e, value: n } = await t.read(); if (e) break; yield n } } finally { await t.cancel() } }, CD = (e, t, n, r) => { const i = async function* (e, t) { for await (const n of _D(e)) yield* SD(n, t) }(e, t); let a, o = 0, s = e => { a || (a = !0, r && r(e)) }; return new ReadableStream({ async pull(e) { try { const { done: t, value: r } = await i.next(); if (t) return s(), void e.close(); let a = r.byteLength; if (n) { let e = o += a; n(e) } e.enqueue(new Uint8Array(r)) } catch (e) { throw s(e), e } }, cancel: e => (s(e), i.return()) }, { highWaterMark: 2 }) }, AD = "function" == typeof fetch && "function" == typeof Request && "function" == typeof Response, TD = AD && "function" == typeof ReadableStream, ED = AD && ("function" == typeof TextEncoder ? (ND = new TextEncoder, e => ND.encode(e)) : async e => new Uint8Array(await new Response(e).arrayBuffer())); var ND; const ID = (e, ...t) => { try { return !!e(...t) } catch (e) { return !1 } }, MD = TD && ID((() => { let e = !1; const t = new Request(HF.origin, { body: new ReadableStream, method: "POST", get duplex() { return e = !0, "half" } }).headers.has("Content-Type"); return e && !t })), FD = TD && ID((() => kF.isReadableStream(new Response("").body))), DD = { stream: FD && (e => e.body) }; var $D; AD && ($D = new Response, ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((e => { !DD[e] && (DD[e] = kF.isFunction($D[e]) ? t => t[e]() : (t, n) => { throw new AF(`Response type '${e}' is not supported`, AF.ERR_NOT_SUPPORT, n) }) }))); const RD = async (e, t) => { const n = kF.toFiniteNumber(e.getContentLength()); return null == n ? (async e => { if (null == e) return 0; if (kF.isBlob(e)) return e.size; if (kF.isSpecCompliantForm(e)) { const t = new Request(HF.origin, { method: "POST", body: e }); return (await t.arrayBuffer()).byteLength } return kF.isArrayBufferView(e) || kF.isArrayBuffer(e) ? e.byteLength : (kF.isURLSearchParams(e) && (e += ""), kF.isString(e) ? (await ED(e)).byteLength : void 0) })(t) : n }, OD = { http: null, xhr: wD, fetch: AD && (async e => { let { url: t, method: n, data: r, signal: i, cancelToken: a, timeout: o, onDownloadProgress: s, onUploadProgress: u, responseType: l, headers: c, withCredentials: h = "same-origin", fetchOptions: d } = xD(e); l = l ? (l + "").toLowerCase() : "text"; let f, p = kD([i, a && a.toAbortSignal()], o); const m = p && p.unsubscribe && (() => { p.unsubscribe() }); let g; try { if (u && MD && "get" !== n && "head" !== n && 0 !== (g = await RD(c, r))) { let e, n = new Request(t, { method: "POST", body: r, duplex: "half" }); if (kF.isFormData(r) && (e = n.headers.get("content-type")) && c.setContentType(e), n.body) { const [e, t] = hD(g, cD(dD(u))); r = CD(n.body, 65536, e, t) } } kF.isString(h) || (h = h ? "include" : "omit"); const i = "credentials" in Request.prototype; f = new Request(t, { ...d, signal: p, method: n.toUpperCase(), headers: c.normalize().toJSON(), body: r, duplex: "half", credentials: i ? h : void 0 }); let a = await fetch(f); const o = FD && ("stream" === l || "response" === l); if (FD && (s || o && m)) { const e = {};["status", "statusText", "headers"].forEach((t => { e[t] = a[t] })); const t = kF.toFiniteNumber(a.headers.get("content-length")), [n, r] = s && hD(t, cD(dD(s), !0)) || []; a = new Response(CD(a.body, 65536, n, (() => { r && r(), m && m() })), e) } l = l || "text"; let y = await DD[kF.findKey(DD, l) || "text"](a, e); return !o && m && m(), await new Promise(((t, n) => { sD(t, n, { data: y, headers: nD.from(a.headers), status: a.status, statusText: a.statusText, config: e, request: f }) })) } catch (t) { if (m && m(), t && "TypeError" === t.name && /fetch/i.test(t.message)) throw Object.assign(new AF("Network Error", AF.ERR_NETWORK, e, f), { cause: t.cause || t }); throw AF.from(t, t && t.code, e, f) } }) }; kF.forEach(OD, ((e, t) => { if (e) { try { Object.defineProperty(e, "name", { value: t }) } catch (e) { } Object.defineProperty(e, "adapterName", { value: t }) } })); const zD = e => `- ${e}`, PD = e => kF.isFunction(e) || null === e || !1 === e, BD = e => { e = kF.isArray(e) ? e : [e]; const { length: t } = e; let n, r; const i = {}; for (let a = 0; a < t; a++) { let t; if (n = e[a], r = n, !PD(n) && (r = OD[(t = String(n)).toLowerCase()], void 0 === r)) throw new AF(`Unknown adapter '${t}'`); if (r) break; i[t || "#" + a] = r } if (!r) { const e = Object.entries(i).map((([e, t]) => `adapter ${e} ` + (!1 === t ? "is not supported by the environment" : "is not available in the build"))); let n = t ? e.length > 1 ? "since :\n" + e.map(zD).join("\n") : " " + zD(e[0]) : "as no adapter specified"; throw new AF("There is no suitable adapter to dispatch the request " + n, "ERR_NOT_SUPPORT") } return r }; function LD(e) { if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted) throw new oD(null, e) } function jD(e) { LD(e), e.headers = nD.from(e.headers), e.data = rD.call(e, e.transformRequest), -1 !== ["post", "put", "patch"].indexOf(e.method) && e.headers.setContentType("application/x-www-form-urlencoded", !1); return BD(e.adapter || XF.adapter)(e).then((function (t) { return LD(e), t.data = rD.call(e, e.transformResponse, t), t.headers = nD.from(t.headers), t }), (function (t) { return iD(t) || (LD(e), t && t.response && (t.response.data = rD.call(e, e.transformResponse, t.response), t.response.headers = nD.from(t.response.headers))), Promise.reject(t) })) } const UD = "1.7.8", WD = {};["object", "boolean", "number", "function", "string", "symbol"].forEach(((e, t) => { WD[e] = function (n) { return typeof n === e || "a" + (t < 1 ? "n " : " ") + e } })); const VD = {}; WD.transitional = function (e, t, n) { function r(e, t) { return "[Axios v1.7.8] Transitional option '" + e + "'" + t + (n ? ". " + n : "") } return (n, i, a) => { if (!1 === e) throw new AF(r(i, " has been removed" + (t ? " in " + t : "")), AF.ERR_DEPRECATED); return t && !VD[i] && (VD[i] = !0, console.warn(r(i, " has been deprecated since v" + t + " and will be removed in the near future"))), !e || e(n, i, a) } }, WD.spelling = function (e) { return (t, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0) }; const GD = { assertOptions: function (e, t, n) { if ("object" != typeof e) throw new AF("options must be an object", AF.ERR_BAD_OPTION_VALUE); const r = Object.keys(e); let i = r.length; for (; i-- > 0;) { const a = r[i], o = t[a]; if (o) { const t = e[a], n = void 0 === t || o(t, a, e); if (!0 !== n) throw new AF("option " + a + " must be " + n, AF.ERR_BAD_OPTION_VALUE) } else if (!0 !== n) throw new AF("Unknown option " + a, AF.ERR_BAD_OPTION) } }, validators: WD }, HD = GD.validators; class qD { constructor(e) { this.defaults = e, this.interceptors = { request: new PF, response: new PF } } async request(e, t) { try { return await this._request(e, t) } catch (e) { if (e instanceof Error) { let t = {}; Error.captureStackTrace ? Error.captureStackTrace(t) : t = new Error; const n = t.stack ? t.stack.replace(/^.+\n/, "") : ""; try { e.stack ? n && !String(e.stack).endsWith(n.replace(/^.+\n.+\n/, "")) && (e.stack += "\n" + n) : e.stack = n } catch (e) { } } throw e } } _request(e, t) { "string" == typeof e ? (t = t || {}).url = e : t = e || {}, t = vD(this.defaults, t); const { transitional: n, paramsSerializer: r, headers: i } = t; void 0 !== n && GD.assertOptions(n, { silentJSONParsing: HD.transitional(HD.boolean), forcedJSONParsing: HD.transitional(HD.boolean), clarifyTimeoutError: HD.transitional(HD.boolean) }, !1), null != r && (kF.isFunction(r) ? t.paramsSerializer = { serialize: r } : GD.assertOptions(r, { encode: HD.function, serialize: HD.function }, !0)), GD.assertOptions(t, { baseUrl: HD.spelling("baseURL"), withXsrfToken: HD.spelling("withXSRFToken") }, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase(); let a = i && kF.merge(i.common, i[t.method]); i && kF.forEach(["delete", "get", "head", "post", "put", "patch", "common"], (e => { delete i[e] })), t.headers = nD.concat(a, i); const o = []; let s = !0; this.interceptors.request.forEach((function (e) { "function" == typeof e.runWhen && !1 === e.runWhen(t) || (s = s && e.synchronous, o.unshift(e.fulfilled, e.rejected)) })); const u = []; let l; this.interceptors.response.forEach((function (e) { u.push(e.fulfilled, e.rejected) })); let c, h = 0; if (!s) { const e = [jD.bind(this), void 0]; for (e.unshift.apply(e, o), e.push.apply(e, u), c = e.length, l = Promise.resolve(t); h < c;)l = l.then(e[h++], e[h++]); return l } c = o.length; let d = t; for (h = 0; h < c;) { const e = o[h++], t = o[h++]; try { d = e(d) } catch (e) { t.call(this, e); break } } try { l = jD.call(this, d) } catch (e) { return Promise.reject(e) } for (h = 0, c = u.length; h < c;)l = l.then(u[h++], u[h++]); return l } getUri(e) { return zF(yD((e = vD(this.defaults, e)).baseURL, e.url), e.params, e.paramsSerializer) } } kF.forEach(["delete", "get", "head", "options"], (function (e) { qD.prototype[e] = function (t, n) { return this.request(vD(n || {}, { method: e, url: t, data: (n || {}).data })) } })), kF.forEach(["post", "put", "patch"], (function (e) { function t(t) { return function (n, r, i) { return this.request(vD(i || {}, { method: e, headers: t ? { "Content-Type": "multipart/form-data" } : {}, url: n, data: r })) } } qD.prototype[e] = t(), qD.prototype[e + "Form"] = t(!0) })); const YD = qD; class XD { constructor(e) { if ("function" != typeof e) throw new TypeError("executor must be a function."); let t; this.promise = new Promise((function (e) { t = e })); const n = this; this.promise.then((e => { if (!n._listeners) return; let t = n._listeners.length; for (; t-- > 0;)n._listeners[t](e); n._listeners = null })), this.promise.then = e => { let t; const r = new Promise((e => { n.subscribe(e), t = e })).then(e); return r.cancel = function () { n.unsubscribe(t) }, r }, e((function (e, r, i) { n.reason || (n.reason = new oD(e, r, i), t(n.reason)) })) } throwIfRequested() { if (this.reason) throw this.reason } subscribe(e) { this.reason ? e(this.reason) : this._listeners ? this._listeners.push(e) : this._listeners = [e] } unsubscribe(e) { if (!this._listeners) return; const t = this._listeners.indexOf(e); -1 !== t && this._listeners.splice(t, 1) } toAbortSignal() { const e = new AbortController, t = t => { e.abort(t) }; return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal } static source() { let e; return { token: new XD((function (t) { e = t })), cancel: e } } } const KD = XD; const ZD = { Continue: 100, SwitchingProtocols: 101, Processing: 102, EarlyHints: 103, Ok: 200, Created: 201, Accepted: 202, NonAuthoritativeInformation: 203, NoContent: 204, ResetContent: 205, PartialContent: 206, MultiStatus: 207, AlreadyReported: 208, ImUsed: 226, MultipleChoices: 300, MovedPermanently: 301, Found: 302, SeeOther: 303, NotModified: 304, UseProxy: 305, Unused: 306, TemporaryRedirect: 307, PermanentRedirect: 308, BadRequest: 400, Unauthorized: 401, PaymentRequired: 402, Forbidden: 403, NotFound: 404, MethodNotAllowed: 405, NotAcceptable: 406, ProxyAuthenticationRequired: 407, RequestTimeout: 408, Conflict: 409, Gone: 410, LengthRequired: 411, PreconditionFailed: 412, PayloadTooLarge: 413, UriTooLong: 414, UnsupportedMediaType: 415, RangeNotSatisfiable: 416, ExpectationFailed: 417, ImATeapot: 418, MisdirectedRequest: 421, UnprocessableEntity: 422, Locked: 423, FailedDependency: 424, TooEarly: 425, UpgradeRequired: 426, PreconditionRequired: 428, TooManyRequests: 429, RequestHeaderFieldsTooLarge: 431, UnavailableForLegalReasons: 451, InternalServerError: 500, NotImplemented: 501, BadGateway: 502, ServiceUnavailable: 503, GatewayTimeout: 504, HttpVersionNotSupported: 505, VariantAlsoNegotiates: 506, InsufficientStorage: 507, LoopDetected: 508, NotExtended: 510, NetworkAuthenticationRequired: 511 }; Object.entries(ZD).forEach((([e, t]) => { ZD[t] = e })); const JD = ZD; const QD = function e(t) { const n = new YD(t), r = FM(YD.prototype.request, n); return kF.extend(r, YD.prototype, n, { allOwnKeys: !0 }), kF.extend(r, n, null, { allOwnKeys: !0 }), r.create = function (n) { return e(vD(t, n)) }, r }(XF); QD.Axios = YD, QD.CanceledError = oD, QD.CancelToken = KD, QD.isCancel = iD, QD.VERSION = UD, QD.toFormData = MF, QD.AxiosError = AF, QD.Cancel = QD.CanceledError, QD.all = function (e) { return Promise.all(e) }, QD.spread = function (e) { return function (t) { return e.apply(null, t) } }, QD.isAxiosError = function (e) { return kF.isObject(e) && !0 === e.isAxiosError }, QD.mergeConfig = vD, QD.AxiosHeaders = nD, QD.formToJSON = e => qF(kF.isHTMLForm(e) ? new FormData(e) : e), QD.getAdapter = BD, QD.HttpStatusCode = JD, QD.default = QD; const e$ = QD; function t$(e) { return new RegExp("^(?:[a-z]+:)?//", "i").test(e) } class n$ { constructor(e, t = "model", n = !0) { const r = n ? function (e) { if (!t$(e) && "undefined" != typeof window) { if (e.startsWith("/")) return window.location.origin + e; let t = window.location.href; return t.endsWith("/") || (t += "/"), t + e } return e }(e) : e, i = {}; if (r.endsWith(".json")) { const e = r.lastIndexOf("/") + 1; this.directory = r.slice(0, e); const n = r.slice(e, -5); n !== t && ["model", "manifest", "metadata"].includes(n) ? console.warn(`Expected a ${t}.json file URL, but received a ${n}.json file instead.`) : i[t] = r } else this.directory = r.endsWith("/") ? r : `${r}/`; this.modelUrl = i.model || this.getPath("model.json"), this.metadataUrl = i.metadata || this.getPath("metadata.json"), this.manifestUrl = i.manifest || this.getPath("manifest.json") } getPath(e) { return t$(e) ? e : this.directory + e } async loadManifestJson() { try { return (await e$.get(this.manifestUrl)).data } catch (e) { throw new Error(`Error loading manifest.json file from URL ${this.manifestUrl}: ${String(e)}`) } } async loadMetadataJson() { try { return (await e$.get(this.metadataUrl)).data } catch (e) { throw new Error(`Error loading metadata.json file from URL ${this.metadataUrl}: ${String(e)}`) } } async loadLayersModel(e) { const t = e ? this.getPath(e) : this.modelUrl; try { return await ts(t) } catch (e) { throw new Error(`Error loading model from URL ${t}: ${String(e)}`) } } } function r$(e, t, n) { return new n$(e, t, n) } class i$ { constructor(e) { this.options = e || {} } normalizeValue(e, t, n) { return t === n ? 0 : (e - t) / (n - t) } unnormalizeValue(e, t, n) { return t === n ? t : e * (n - t) + t } getMin(e) { return e.reduce(((e, t) => Math.min(e, t))) } getMax(e) { return e.reduce(((e, t) => Math.max(e, t))) } isJsonOrString(e) { try { JSON.parse(e) } catch (e) { return !1 } return !0 } zipArrays(e, t) { if (e.length !== t.length) return console.error("arrays do not have the same length"), []; return [...new Array(e.length).fill(null)].map(((n, r) => ({ ...e[r], ...t[r] }))) } createLabelsFromArrayValues(e, t) { let n; return Array.isArray(e) && (n = e.map(((e, n) => `${t}_${n}`))), n } formatDataAsObject(e, t) { let n = {}; if (Array.isArray(e)) return e.forEach(((e, r) => { const i = t[r]; n[i] = e })), n; if ("object" == typeof e) return n = e, n; throw new Error("input provided is not supported or does not match your output label specifications") } getDataType(e) { let t = typeof e; return "object" === t && Array.isArray(e) && (t = "array"), t } } const a$ = new i$; const o$ = class { constructor() { this.meta = { inputUnits: null, outputUnits: null, inputs: {}, outputs: {}, isNormalized: !1 }, this.isMetadataReady = !1, this.isWarmedUp = !1, this.data = { raw: [] } } createMetadata(e = null) { this.getDTypesFromData(), this.getDataStats(), this.getDataOneHot(), this.getDataUnits(e), this.isMetadataReady = !0 } getDataStats() { this.meta.inputs = this.getInputMetaStats(this.meta.inputs, "xs"), this.meta.outputs = this.getInputMetaStats(this.meta.outputs, "ys") } getInputMetaStats(e, t) { const n = Object.assign({}, e); return Object.keys(n).forEach((e => { if ("string" === n[e].dtype) n[e].min = 0, n[e].max = 1; else if ("number" === n[e].dtype) { const r = this.data.raw.map((n => n[t][e])); n[e].min = a$.getMin(r), n[e].max = a$.getMax(r) } else if ("array" === n[e].dtype) { const r = this.data.raw.map((n => n[t][e])).flat(); n[e].min = a$.getMin(r), n[e].max = a$.getMax(r) } })), n } getDataUnits(e = null) { this.meta.inputUnits = e || [this.getInputMetaUnits(this.meta.inputs)].flat(), this.meta.outputUnits = this.getInputMetaUnits(this.meta.outputs) } getInputMetaUnits(e) { let t = 0; return Object.entries(e).forEach((e => { const { dtype: n } = e[1]; if ("number" === n) t += 1; else if ("string" === n) { const { uniqueValues: n } = e[1], r = n.length; t += r } else "array" === n && (t = []) })), t } getDTypesFromData() { const e = { ...this.meta, inputs: {}, outputs: {} }, t = this.data.raw[0], n = Object.keys(t.xs), r = Object.keys(t.ys); n.forEach((n => { e.inputs[n] = { dtype: a$.getDataType(t.xs[n]) } })), r.forEach((n => { e.outputs[n] = { dtype: a$.getDataType(t.ys[n]) } })), this.meta = e } addData(e, t) { this.data.raw.push({ xs: e, ys: t }) } convertRawToTensors(e) { const t = Object.assign({}, this.meta), n = e.length; return P.tidy((() => { const r = [], i = []; e.forEach((e => { const n = Object.keys(t.inputs).map((t => e.xs[t])).flat(); r.push(n); const a = Object.keys(t.outputs).map((t => e.ys[t])).flat(); i.push(a) })); return { inputs: P.tensor(r.flat(), [n, ...t.inputUnits]), outputs: P.tensor(i.flat(), [n, t.outputUnits]) } })) } normalizeDataRaw() { const e = this.normalizeInputData(this.meta.inputs, "xs"), t = this.normalizeInputData(this.meta.outputs, "ys"); return a$.zipArrays(e, t) } normalizeInputData(e, t) { const n = this.data.raw, r = n.length, i = Object.assign({}, e), a = {}; Object.keys(i).forEach((e => { const r = { min: i[e].min, max: i[e].max }, o = n.map((n => n[t][e])); "string" === i[e].dtype ? (r.legend = i[e].legend, a[e] = this.normalizeArray(o, r)) : "number" === i[e].dtype ? a[e] = this.normalizeArray(o, r) : "array" === i[e].dtype && (a[e] = o.map((e => this.normalizeArray(e, r)))) })); return [...new Array(r).fill(null)].map(((e, n) => { const r = { [t]: {} }; return Object.keys(i).forEach((e => { r[t][e] = a[e][n] })), r })) } normalizeArray(e, t) { const { min: n, max: r } = t; if (t.legend) { return e.map((e => t.legend[e] ? t.legend[e] : e)) } if (n === r && console.warn("🟪 ml5.js NeuralNetwork warns: Normalization failed, all data entries for an input parameter are identical (min === max). The data for this input parameter will be set to 0, effectively removing it from the model. Please check your input data."), e.every((e => "number" == typeof e))) { return e.map((e => a$.normalizeValue(e, n, r))) } throw new Error("error in inputArray of normalizeArray() function") } unnormalizeArray(e, t) { const { min: n, max: r } = t; if (t.legend) { const n = e.map((e => { let n; return Object.entries(t.legend).forEach((t => { const r = t[0], i = t[1]; e.map(((e, t) => e === i[t])).every((e => !0 === e)) && (n = r) })), n })); return n } if (e.every((e => "number" == typeof e))) { return e.map((e => a$.unnormalizeValue(e, n, r))) } throw new Error("error in inputArray of normalizeArray() function") } applyOneHotEncodingsToDataRaw() { const e = Object.assign({}, this.meta); return this.data.raw.map((t => { const n = { ...t.xs }, r = { ...t.ys }; return Object.keys(e.inputs).forEach((r => { e.inputs[r].legend && (n[r] = e.inputs[r].legend[t.xs[r]]) })), Object.keys(e.outputs).forEach((n => { e.outputs[n].legend && (r[n] = e.outputs[n].legend[t.ys[n]]) })), { xs: n, ys: r } })) } getDataOneHot() { this.meta.inputs = this.getInputMetaOneHot(this.meta.inputs, "xs"), this.meta.outputs = this.getInputMetaOneHot(this.meta.outputs, "ys") } getInputMetaOneHot(e, t) { const n = Object.assign({}, e); return Object.entries(n).forEach((e => { const r = e[0], { dtype: i } = e[1]; if ("string" === i) { const e = [...new Set(this.data.raw.map((e => e[t][r])))], i = this.createOneHotEncodings(e); n[r] = { ...n[r], ...i } } })), n } createOneHotEncodings(e) { return P.tidy((() => { const t = { uniqueValues: e, legend: {} }, n = e; if (n.length < 2) throw new Error(`🟪 ml5.js classification error: Classification requires at least 2 different classes, but only found ${n.length} class: "${n[0] || "undefined"}". Please add training data with multiple different output values.`); const r = n.map(((e, t) => t)), i = P.oneHot(P.tensor1d(r, "int32"), n.length).arraySync(); return n.forEach(((e, n) => { t.legend[e] = i[n] })), t })) } async loadDataFromUrl(e, t, n) { try { if (e.endsWith(".csv")) await this.loadCSV(e, t, n); else if (e.endsWith(".json")) await this.loadJSON(e, t, n); else { if (!e.includes("blob")) throw new Error("Not a valid data format. Must be csv or json"); await this.loadBlob(e, t, n) } } catch (e) { throw console.error(e), new Error(e) } } async loadJSON(e, t, n) { try { let r; if (e instanceof Object) r = Object.assign({}, e); else { const { data: t } = await e$.get(e); r = t } this.formatRawData(r, t, n) } catch (e) { throw console.error("error loading json"), new Error(e) } } async loadCSV(e, t, n) { try { const r = Jf(e), i = { entries: await r.toArray() }; this.formatRawData(i, t, n) } catch (e) { throw console.error("error loading csv", e), new Error(e) } } async loadBlob(e, t, n) { try { const { data: r } = await e$.get(e), i = r; if (a$.isJsonOrString(i)) { const e = JSON.parse(i); await this.loadJSON(e, t, n) } else { const e = this.csvToJSON(i); await this.loadJSON(e, t, n) } } catch (e) { throw console.log("mmm might be passing in a string or something!", e), new Error(e) } } async loadData(e) { try { let t; if ("string" != typeof e) { const n = e[0]; if ((new FileReader).readAsText(n), n.name.includes(".json")) { const e = await n.text(); t = JSON.parse(e) } else console.log('data must be a json object containing an array called "data" or "entries') } else { let n = await e$.get(e, { responseType: "text" }); a$.isJsonOrString(n.data) ? t = JSON.parse(n.data) : console.error("🟪 ml5.js error: `NeuralNetwork.loadData` only accepts JSON data.") } this.data.raw = this.findEntries(t), !this.data.raw.length > 0 && console.error("🟪 ml5.js error: `NeuralNetwork.loadData` only accepts JSON objects with a 'data' property.") } catch (e) { throw new Error(e) } } async saveData(e) { const t = new Date; let n = `${`${String(t.getFullYear())}-${String(t.getMonth() + 1)}-${String(t.getDate())}`}_${`${String(t.getHours())}-${String(t.getMinutes())}-${String(t.getSeconds())}`}`; e && (n = e); const r = { data: this.data.raw }; await EM(JSON.stringify(r), `${n}.json`, "text/plain") } async saveMeta(e = "model") { await EM(JSON.stringify(this.meta), `${e}_meta.json`, "text/plain") } async loadMeta(e) { if (e instanceof FileList) { const t = Array.from(e).find((e => e.name.includes("_meta.json"))); if (!t) return void console.warn("no model_meta.json file found in FileList"); const n = await t.text(); this.meta = JSON.parse(n) } else if (e instanceof Object) { const t = await e$.get(e.metadata); this.meta = t.data } else { const t = r$(e).getPath("model_meta.json"), n = await e$.get(t); this.meta = n.data } this.isMetadataReady = !0, this.isWarmedUp = !0 } formatRawData(e, t, n) { const r = this.findEntries(e); !r.length > 0 && console.log("your data must be contained in an array in \n\n a property called 'entries' or 'data' of your json object"); const i = r.map(((e, r) => { const i = { xs: {}, ys: {} }; return t.forEach((t => { void 0 !== e[t] ? i.xs[t] = e[t] : console.error(`the input label ${t} does not exist at row ${r}`) })), n.forEach((t => { void 0 !== e[t] ? i.ys[t] = e[t] : console.error(`the output label ${t} does not exist at row ${r}`) })), i })); this.data.raw = i } csvToJSON(e) { const t = e.split("\n"), n = [], r = t[0].split(","); for (let e = 1; e < t.length; e += 1) { const i = {}, a = t[e].split(","); r.forEach(((e, t) => { i[e] = a[t] })), n.push(i) } return { entries: n } } findEntries(e) { const t = Object.assign({}, e); if (t.entries && t.entries instanceof Array) return t.entries; if (t.data && t.data instanceof Array) return t.data; return Object.keys(t).forEach((e => { if ("object" == typeof t[e]) return this.findEntries(t[e]) })), t } getData() { return this.data.raw } }; var s$ = n(9778); const u$ = class { constructor() { this.config = { height: 300 } } modelSummary(e, t) { const n = { ...e }; s$.show.modelSummary(n, t) } scatterplot(e, t, n) { const r = n.map((n => ({ x: n.xs[e], y: n.ys[t] }))), i = { xLabel: "X", yLabel: "Y", height: this.config.height }; s$.render.scatterplot({ name: "debug mode" }, r, i) } scatterplotAll(e, t, n) { let r = []; e.forEach((e => { t.forEach((t => { const i = n.map((n => ({ x: n.xs[e], y: n.ys[t] }))); r = [...r, ...i] })) })); const i = { xLabel: "X", yLabel: "Y", height: this.config.height }; s$.render.scatterplot({ name: "debug mode" }, r, i) } barchart(e, t, n) { const r = n.map((n => ({ value: n.xs[e], index: n.ys[t] }))), i = { xLabel: "label", yLabel: "value", height: this.config.height }; console.log(i); s$.render.barchart({ name: "Bar chart" }, r) } trainingVis() { return s$.show.fitCallbacks({ name: "Training Performance" }, ["loss", "accuracy"], { height: this.config.height, callbacks: ["onEpochEnd"] }) } }, l$ = { inputs: [], outputs: [], dataUrl: null, modelUrl: null, layers: [], task: null, debug: !1, learningRate: .2, hiddenUnits: 16, neuroEvolution: !1 }; class c$ { constructor(e, t) { "imageClassification" === e.task && (l$.learningRate = .02), this.options = { ...l$, ...e } || l$, this.neuralNetwork = new MM, this.neuralNetworkData = new o$, this.neuralNetworkVis = new u$, this.data = { training: [] }, this.init = this.init.bind(this), this.addData = this.addData.bind(this), this.loadDataFromUrl = this.loadDataFromUrl.bind(this), this.createMetaData = this.createMetaData.bind(this), this.prepareForTraining = this.prepareForTraining.bind(this), this.normalizeData = this.normalizeData.bind(this), this.normalizeInput = this.normalizeInput.bind(this), this.searchAndFormat = this.searchAndFormat.bind(this), this.formatInputItem = this.formatInputItem.bind(this), this.convertTrainingDataToTensors = this.convertTrainingDataToTensors.bind(this), this.formatInputsForPrediction = this.formatInputsForPrediction.bind(this), this.formatInputsForPredictionAll = this.formatInputsForPredictionAll.bind(this), this.isOneHotEncodedOrNormalized = this.isOneHotEncodedOrNormalized.bind(this), this.train = this.train.bind(this), this.trainInternal = this.trainInternal.bind(this), this.addLayer = this.addLayer.bind(this), this.createNetworkLayers = this.createNetworkLayers.bind(this), this.addDefaultLayers = this.addDefaultLayers.bind(this), this.compile = this.compile.bind(this), this.predict = this.predict.bind(this), this.predictMultiple = this.predictMultiple.bind(this), this.classify = this.classify.bind(this), this.classifyMultiple = this.classifyMultiple.bind(this), this.predictInternal = this.predictInternal.bind(this), this.classifyInternal = this.classifyInternal.bind(this), this.saveData = this.saveData.bind(this), this.loadData = this.loadData.bind(this), this.save = this.save.bind(this), this.load = this.load.bind(this), this.dispose = this.dispose.bind(this), this.mutate = this.mutate.bind(this), this.crossover = this.crossover.bind(this), this.ready = hM(this.init(), t) } async init() { return !0 === this.options.neuroEvolution && this.createLayersNoTraining(), this.options.dataUrl ? await this.loadDataFromUrl() : this.options.modelUrl && await this.load(this.options.modelUrl), this } createLayersNoTraining() { const { inputs: e, outputs: t, task: n } = this.options; if ("classification" === n) for (let n = 0; n < t.length; n += 1) { const r = new Array(e).fill(0); this.addData(r, [t[n]]) } else { const n = new Array(e).fill(0), r = new Array(t).fill(0); this.addData(n, r) } this.neuralNetworkData.createMetadata(), this.addDefaultLayers() } copy() { const e = new c$(this.options); return P.tidy((() => { const t = this.neuralNetwork.model.getWeights(), n = []; for (let e = 0; e < t.length; e += 1)n[e] = t[e].clone(); return e.neuralNetwork.model.setWeights(n), e })) } addData(e, t, n = null) { const { inputs: r, outputs: i } = this.options; let a, o; if (null !== n ? (a = n.inputLabels, o = n.outputLabels) : r.length > 0 && i.length > 0 ? (r.every((e => "string" == typeof e)) && (a = r), i.every((e => "string" == typeof e)) && (o = i)) : "object" == typeof e && "object" == typeof t ? (a = Object.keys(e), o = Object.keys(t)) : (a = a$.createLabelsFromArrayValues(e, "input"), o = a$.createLabelsFromArrayValues(t, "output")), !(a instanceof Array)) throw new Error("inputLabels must be an array"); if (!(o instanceof Array)) throw new Error("outputLabels must be an array"); const s = this.searchAndFormat(e), u = a$.formatDataAsObject(s, a), l = a$.formatDataAsObject(t, o); this.neuralNetworkData.addData(u, l) } async loadDataFromUrl() { const { dataUrl: e, inputs: t, outputs: n } = this.options; await this.neuralNetworkData.loadDataFromUrl(e, t, n), this.createMetaData(), this.prepareForTraining() } createMetaData() { const { inputs: e } = this.options; let t; Array.isArray(e) && e.length > 0 && (t = e.every((e => "number" == typeof e)) && e.length > 0 ? e : null), this.neuralNetworkData.createMetadata(t) } prepareForTraining() { this.data.training = this.neuralNetworkData.applyOneHotEncodingsToDataRaw(), this.neuralNetworkData.isWarmedUp = !0 } normalizeData() { this.neuralNetworkData.isMetadataReady || this.createMetaData(), this.neuralNetworkData.isWarmedUp || this.prepareForTraining(); const e = this.neuralNetworkData.normalizeDataRaw(); this.data.training = e, this.neuralNetworkData.meta.isNormalized = !0 } normalizeInput(e, t, n) { const r = t, { min: i, max: a } = n[r]; return a$.normalizeValue(e, i, a) } searchAndFormat(e) { let t; if (Array.isArray(e)) t = e.map((e => this.formatInputItem(e))); else if ("object" == typeof e) { const n = Object.assign({}, e); Object.keys(e).forEach((t => { const r = e[t]; n[t] = this.formatInputItem(r) })), t = n } return t } formatInputItem(e) { let t, n; return CM(e) ? t = e : "object" == typeof e && CM(e.elt) ? t = e.elt : "object" == typeof e && CM(e.canvas) && (t = e.canvas), n = t ? function (e) { const t = SM(e), n = t.getContext("2d").getImageData(0, 0, t.width, t.height); return Array.from(n.data) }(t) : e, n } convertTrainingDataToTensors() { return this.neuralNetworkData.convertRawToTensors(this.data.training) } formatInputsForPrediction(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r = []; return e instanceof Array ? r = n.map(((n, r) => this.isOneHotEncodedOrNormalized(e[r], n, t.inputs))) : e instanceof Object && (r = n.map((n => this.isOneHotEncodedOrNormalized(e[n], n, t.inputs)))), r = r.flat(), r } formatInputsForPredictionAll(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r; return e instanceof Array && e.every((e => Array.isArray(e))) ? (r = e.map((e => this.formatInputsForPrediction(e))), P.tensor(r, [e.length, n.length])) : (r = this.formatInputsForPrediction(e), P.tensor([r])) } isOneHotEncodedOrNormalized(e, t, n) { const r = e, i = t; let a; return "number" != typeof e ? a = n[i].legend[r] : (a = e, this.neuralNetworkData.meta.isNormalized && (a = this.normalizeInput(e, i, n))), a } async train(e, t, n) { let r, i, a; return "object" == typeof e && "function" == typeof t && "function" == typeof n ? (r = e, i = t, a = n) : "object" == typeof e && "function" == typeof t ? (r = e, i = null, a = t) : "function" == typeof e && "function" == typeof t ? (r = {}, i = e, a = t) : (r = {}, i = null, a = e), hM(this.trainInternal(r, i), a) } async trainInternal(e, t) { const n = { epochs: 10, batchSize: 32, validationSplit: .1, whileTraining: null, ...e }; if (!0 === this.options.debug || "true" === this.options.debug ? n.whileTraining = [this.neuralNetworkVis.trainingVis(), { onEpochEnd: t }] : n.whileTraining = [{ onEpochEnd: t }], this.neuralNetworkData.isMetadataReady || this.createMetaData(), this.neuralNetworkData.isWarmedUp || this.prepareForTraining(), !n.inputs && !n.outputs) { const { inputs: e, outputs: t } = this.convertTrainingDataToTensors(); n.inputs = e, n.outputs = t } this.neuralNetwork.isLayered || (this.options.layers = this.createNetworkLayers(this.options.layers)), this.neuralNetwork.isLayered || (this.options.layers = this.addDefaultLayers()), this.neuralNetwork.isCompiled || this.compile(), await this.neuralNetwork.train(n) } addLayer(e) { this.neuralNetwork.addLayer(e) } createNetworkLayers(e) { const t = [...e], { inputUnits: n, outputUnits: r } = this.neuralNetworkData.meta, a = t.length; if (!(t.length >= 2)) return !1; t[0].inputShape = t[0].inputShape ? t[0].inputShape : n; const o = t[a - 1]; return o.units = o.units ? o.units : r, t.forEach((e => { this.addLayer(i[e.type](e)) })), t } addDefaultLayers() { let e; switch (this.options.task.toLowerCase()) { case "classification": return e = [{ type: "dense", units: this.options.hiddenUnits, activation: "relu" }, { type: "dense", activation: "softmax" }], this.createNetworkLayers(e); case "regression": return e = [{ type: "dense", units: this.options.hiddenUnits, activation: "relu" }, { type: "dense", activation: "sigmoid" }], this.createNetworkLayers(e); case "imageclassification": return e = [{ type: "conv2d", filters: 8, kernelSize: 5, strides: 1, activation: "relu", kernelInitializer: "varianceScaling" }, { type: "maxPooling2d", poolSize: [2, 2], strides: [2, 2] }, { type: "conv2d", filters: 16, kernelSize: 5, strides: 1, activation: "relu", kernelInitializer: "varianceScaling" }, { type: "maxPooling2d", poolSize: [2, 2], strides: [2, 2] }, { type: "flatten" }, { type: "dense", kernelInitializer: "varianceScaling", activation: "softmax" }], this.createNetworkLayers(e); default: return console.log("no imputUnits or outputUnits defined"), e = [{ type: "dense", units: this.options.hiddenUnits, activation: "relu" }, { type: "dense", activation: "sigmoid" }], this.createNetworkLayers(e) } } compile() { const e = this.options.learningRate; let t = {}; "classification" === this.options.task || "imageClassification" === this.options.task ? t = { loss: "categoricalCrossentropy", optimizer: P.train.sgd, metrics: ["accuracy"] } : "regression" === this.options.task && (t = { loss: "meanSquaredError", optimizer: P.train.adam, metrics: ["accuracy"] }), t.optimizer = t.optimizer ? this.neuralNetwork.setOptimizerFunction(e, t.optimizer) : this.neuralNetwork.setOptimizerFunction(e, P.train.sgd), this.neuralNetwork.compile(t), this.options.debug && this.neuralNetworkVis.modelSummary({ name: "Model Summary" }, this.neuralNetwork.model) } predictSync(e) { return this.predictSyncInternal(e) } predict(e, t) { return hM(this.predictInternal(e), t) } predictMultiple(e, t) { return hM(this.predictInternal(e), t) } classifySync(e) { return this.classifySyncInternal(e) } classify(e, t) { return hM(this.classifyInternal(e), t) } classifyMultiple(e, t) { return hM(this.classifyInternal(e), t) } predictSyncInternal(e) { const { meta: t } = this.neuralNetworkData, n = this.formatInputsForPredictionAll(e), r = this.neuralNetwork.predictSync(n); if (n.dispose(), null !== t) { const e = Object.keys(t.outputs), n = r.map((n => e.map(((r, i) => { let a, o; if (t.isNormalized) { const { min: e, max: s } = t.outputs[r]; a = a$.unnormalizeValue(n[i], e, s), o = n[i] } else a = n[i]; const s = { [e[i]]: a, label: r, value: a }; return o && (s.unNormalizedValue = o), s })))); return n.length < 2 ? n[0] : n } return r } async predictInternal(e) { const { meta: t } = this.neuralNetworkData, n = this.formatInputsForPredictionAll(e), r = await this.neuralNetwork.predict(n); if (n.dispose(), null !== t) { const e = Object.keys(t.outputs), n = r.map((n => e.map(((r, i) => { let a, o; if (t.isNormalized) { const { min: e, max: s } = t.outputs[r]; a = a$.unnormalizeValue(n[i], e, s), o = n[i] } else a = n[i]; const s = { [e[i]]: a, label: r, value: a }; return o && (s.unNormalizedValue = o), s })))); return n.length < 2 ? n[0] : n } return r } classifySyncInternal(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r; if ("imageClassification" === this.options.task) { if (r = this.searchAndFormat(e), r = Array.isArray(r) ? r.flat() : r[n[0]], t.isNormalized) { const { min: e, max: i } = t.inputs[n[0]]; r = this.neuralNetworkData.normalizeArray(Array.from(r), { min: e, max: i }) } else r = Array.from(r); r = P.tensor([r], [1, ...t.inputUnits]) } else r = this.formatInputsForPredictionAll(e); const i = this.neuralNetwork.classifySync(r); if (r.dispose(), null !== t) { const e = Object.keys(t.outputs)[0], n = Object.entries(t.outputs[e].legend), r = i.map((e => n.map(((t, n) => ({ [t[0]]: e[n], label: t[0], confidence: e[n] }))).sort(((e, t) => t.confidence - e.confidence)))); return r.length < 2 ? r[0] : r } return i } async classifyInternal(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r; if ("imageClassification" === this.options.task) { if (r = this.searchAndFormat(e), r = Array.isArray(r) ? r.flat() : r[n[0]], t.isNormalized) { const { min: e, max: i } = t.inputs[n[0]]; r = this.neuralNetworkData.normalizeArray(Array.from(r), { min: e, max: i }) } else r = Array.from(r); r = P.tensor([r], [1, ...t.inputUnits]) } else r = this.formatInputsForPredictionAll(e); const i = await this.neuralNetwork.classify(r); if (r.dispose(), null !== t) { const e = Object.keys(t.outputs)[0], n = Object.entries(t.outputs[e].legend); n.sort(((e, t) => t[1].reduce(((e, t) => 2 * e + t), 0) - e[1].reduce(((e, t) => 2 * e + t), 0))); const r = i.map((e => n.map(((t, n) => ({ [t[0]]: e[n], label: t[0], confidence: e[n] }))).sort(((e, t) => t.confidence - e.confidence)))); return r.length < 2 ? r[0] : r } return i } saveData(e, t) { const n = xM(e, t); return hM(this.neuralNetworkData.saveData(n.name), n.callback) } async loadData(e, t) { return hM(this.neuralNetworkData.loadData(e), t) } async save(e, t) { const n = xM(e, t), r = n.string || "model"; return hM(Promise.all([this.neuralNetwork.save(r), this.neuralNetworkData.saveMeta(r)]), n.callback) } async load(e, t) { return hM(Promise.all([this.neuralNetwork.load(e), this.neuralNetworkData.loadMeta(e)]), t) } dispose() { this.neuralNetwork.dispose() } mutate(e, t) { this.neuralNetwork.mutate(e, t) } crossover(e) { const t = this.copy(); return t.neuralNetwork.crossover(e.neuralNetwork), t } } const h$ = (e, t, n) => { let r, i; e instanceof Object ? (r = e, i = t) : (r = { inputs: e, outputs: t }, i = n); return new c$(r, i) }; var d$ = n(8554), f$ = function () { return f$ = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }, f$.apply(this, arguments) }; function p$(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function m$(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(s) { return function (u) { return function (s) { if (n) throw new TypeError("Generator is already executing."); for (; a && (a = 0, s[0] && (o = 0)), o;)try { if (n = 1, r && (i = 2 & s[0] ? r.return : s[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, s[1])).done) return i; switch (r = 0, i && (s = [2 & s[0], i.value]), s[0]) { case 0: case 1: i = s; break; case 4: return o.label++, { value: s[1], done: !1 }; case 5: o.label++, r = s[1], s = [0]; continue; case 7: s = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== s[0] && 2 !== s[0])) { o = 0; continue } if (3 === s[0] && (!i || s[1] > i[0] && s[1] < i[3])) { o.label = s[1]; break } if (6 === s[0] && o.label < i[1]) { o.label = i[1], i = s; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(s); break } i[2] && o.ops.pop(), o.trys.pop(); continue }s = t.call(e, o) } catch (e) { s = [6, e], r = 0 } finally { n = i = 0 } if (5 & s[0]) throw s[1]; return { value: s[0] ? s[1] : void 0, done: !0 } }([s, u]) } } } "function" == typeof SuppressedError && SuppressedError; var g$ = ["wrist", "thumb_cmc", "thumb_mcp", "thumb_ip", "thumb_tip", "index_finger_mcp", "index_finger_pip", "index_finger_dip", "index_finger_tip", "middle_finger_mcp", "middle_finger_pip", "middle_finger_dip", "middle_finger_tip", "ring_finger_mcp", "ring_finger_pip", "ring_finger_dip", "ring_finger_tip", "pinky_finger_mcp", "pinky_finger_pip", "pinky_finger_dip", "pinky_finger_tip"], y$ = { runtime: "mediapipe", maxHands: 2, modelType: "full" }, b$ = function () { function e(e) { var t, n = this; this.width = 0, this.height = 0, this.selfieMode = !1, this.handsSolution = new d$.Hands({ locateFile: function (t, n) { return e.solutionPath ? e.solutionPath.replace(/\/+$/, "") + "/" + t : n + "/" + t } }), t = "lite" === e.modelType ? 0 : 1, this.handsSolution.setOptions({ modelComplexity: t, selfieMode: this.selfieMode, maxNumHands: e.maxHands }), this.handsSolution.onResults((function (e) { if (n.height = e.image.height, n.width = e.image.width, n.hands = [], null !== e.multiHandLandmarks) for (var t = e.multiHandedness, r = e.multiHandLandmarks, i = e.multiHandWorldLandmarks, a = 0; a < t.length; a++)n.hands.push(f$(f$({}, n.translateOutput(r[a], i[a])), { score: t[a].score, handedness: t[a].label })) })) } return e.prototype.translateOutput = function (e, t) { var n = this; return { keypoints: e.map((function (e, t) { return { x: e.x * n.width, y: e.y * n.height, score: e.visibility, name: g$[t] } })), keypoints3D: t.map((function (e, t) { return { x: e.x, y: e.y, z: e.z, score: e.visibility, name: g$[t] } })) } }, e.prototype.estimateHands = function (e, t) { return p$(this, void 0, void 0, (function () { var n, r; return m$(this, (function (i) { switch (i.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.handsSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (r = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return n = new (r.apply(ImageData, [void 0, i.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: n = e, i.label = 3; case 3: return e = n, [4, this.handsSolution.send({ image: e })]; case 4: return i.sent(), [2, this.hands] } })) })) }, e.prototype.dispose = function () { this.handsSolution.close() }, e.prototype.reset = function () { this.handsSolution.reset(), this.width = 0, this.height = 0, this.hands = null, this.selfieMode = !1 }, e.prototype.initialize = function () { return this.handsSolution.initialize() }, e }(); function v$(e) { return p$(this, void 0, void 0, (function () { var t, n; return m$(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return f$({}, y$); var t = f$({}, e); return t.runtime = "mediapipe", null == t.maxHands && (t.maxHands = y$.maxHands), null == t.modelType && (t.modelType = y$.modelType), t }(e), [4, (n = new b$(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } function x$(e) { return e.width * e.height } function w$(e) { var t = e.xCenter - e.width / 2, n = t + e.width, r = e.yCenter - e.height / 2; return { xMin: t, xMax: n, yMin: r, yMax: r + e.height, width: e.width, height: e.height } } function k$(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function S$(e) { return e - 2 * Math.PI * Math.floor((e + Math.PI) / (2 * Math.PI)) } function _$(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function C$(e, t) { P.util.assert(0 !== e.width, (function () { return t + " width cannot be 0." })), P.util.assert(0 !== e.height, (function () { return t + " height cannot be 0." })) } function A$(e, t, n) { var r = t.outputTensorSize, i = t.keepAspectRatio, a = t.borderMode, o = t.outputTensorFloatRange, s = k$(e), u = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(s, n), l = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; C$(t, "targetSize"), C$(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(u, r, i), c = function (e, t, n, r) { var i = e.width, a = e.height, o = r ? -1 : 1, s = Math.cos(e.rotation), u = Math.sin(e.rotation), l = e.xCenter, c = e.yCenter, h = 1 / t, d = 1 / n, f = new Array(16); return f[0] = i * s * o * h, f[1] = -a * u * h, f[2] = 0, f[3] = (-.5 * i * s * o + .5 * a * u + l) * h, f[4] = i * u * o * d, f[5] = a * s * d, f[6] = 0, f[7] = (-.5 * a * s - .5 * i * u * o + c) * d, f[8] = 0, f[9] = 0, f[10] = i * h, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, function (e) { if (16 !== e.length) throw new Error("Array length must be 16 but got " + e.length); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] }(f) }(u, s.width, s.height, !1), h = (0, P.tidy)((function () { var t = _$(e), n = (0, P.tensor2d)(function (e, t, n) { return C$(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] }(c, s, r), [1, 8]), i = "zero" === a ? "constant" : "nearest", u = P.image.transform((0, P.expandDims)((0, P.cast)(t, "float32")), n, "bilinear", i, 0, [r.height, r.width]); return null != o ? function (e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return (0, P.tidy)((function () { return (0, P.add)((0, P.mul)(e, n.scale), n.offset) })) }(u, o) : u })); return { imageTensor: h, padding: l, transformationMatrix: c } } function T$(e, t, n, r) { return 1 === r ? .5 * (e + t) : e + (t - e) * n / (r - 1) } function E$(e) { return { xCenter: e.xMin + e.width / 2, yCenter: e.yMin + e.height / 2, width: e.width, height: e.height } } function N$(e) { var t = e.relativeKeypoints; if (t.length <= 1) throw new Error("2 or more keypoints required to calculate a rect."); var n = Number.MAX_VALUE, r = Number.MAX_VALUE, i = Number.MIN_VALUE, a = Number.MIN_VALUE; return t.forEach((function (e) { n = Math.min(n, e.x), i = Math.max(i, e.x), r = Math.min(r, e.y), a = Math.max(a, e.y) })), { xCenter: (n + i) / 2, yCenter: (r + a) / 2, width: i - n, height: a - r } } function I$(e, t, n, r) { return p$(this, void 0, void 0, (function () { var r, i, a, o, s; return m$(this, (function (u) { switch (u.label) { case 0: return e.sort((function (e, t) { return Math.max.apply(Math, t.score) - Math.max.apply(Math, e.score) })), r = (0, P.tensor2d)(e.map((function (e) { return [e.locationData.relativeBoundingBox.yMin, e.locationData.relativeBoundingBox.xMin, e.locationData.relativeBoundingBox.yMax, e.locationData.relativeBoundingBox.xMax] }))), i = (0, P.tensor1d)(e.map((function (e) { return e.score[0] }))), [4, P.image.nonMaxSuppressionAsync(r, i, t, n)]; case 1: return [4, (a = u.sent()).array()]; case 2: return o = u.sent(), s = e.filter((function (e, t) { return o.indexOf(t) > -1 })), (0, P.dispose)([r, i, a]), [2, s] } })) })) } function M$(e, t) { return e.map((function (e) { var n = f$(f$({}, e), { x: e.x * t.width, y: e.y * t.height }); return null != e.z && (n.z = e.z * t.width), n })) } function F$(e, t, n) { return p$(this, void 0, void 0, (function () { var r, i, a, o, s; return m$(this, (function (u) { switch (u.label) { case 0: return r = e[0], i = e[1], a = function (e, t, n) { return (0, P.tidy)((function () { var r, i, a, o; n.reverseOutputOrder ? (i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))) : (r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))), i = (0, P.add)((0, P.mul)((0, P.div)(i, n.xScale), t.w), t.x), r = (0, P.add)((0, P.mul)((0, P.div)(r, n.yScale), t.h), t.y), n.applyExponentialOnBoxSize ? (a = (0, P.mul)((0, P.exp)((0, P.div)(a, n.hScale)), t.h), o = (0, P.mul)((0, P.exp)((0, P.div)(o, n.wScale)), t.w)) : (a = (0, P.mul)((0, P.div)(a, n.hScale), t.h), o = (0, P.mul)((0, P.div)(o, n.wScale), t.h)); var s = (0, P.sub)(r, (0, P.div)(a, 2)), u = (0, P.sub)(i, (0, P.div)(o, 2)), l = (0, P.add)(r, (0, P.div)(a, 2)), c = (0, P.add)(i, (0, P.div)(o, 2)), h = (0, P.concat)([(0, P.reshape)(s, [n.numBoxes, 1]), (0, P.reshape)(u, [n.numBoxes, 1]), (0, P.reshape)(l, [n.numBoxes, 1]), (0, P.reshape)(c, [n.numBoxes, 1])], 1); if (n.numKeypoints) for (var d = 0; d < n.numKeypoints; ++d) { var f = n.keypointCoordOffset + d * n.numValuesPerKeypoint, p = void 0, m = void 0; n.reverseOutputOrder ? (p = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), m = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))) : (m = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), p = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))); var g = (0, P.add)((0, P.mul)((0, P.div)(p, n.xScale), t.w), t.x), y = (0, P.add)((0, P.mul)((0, P.div)(m, n.yScale), t.h), t.y); h = (0, P.concat)([h, (0, P.reshape)(g, [n.numBoxes, 1]), (0, P.reshape)(y, [n.numBoxes, 1])], 1) } return h })) }(i, t, n), o = (0, P.tidy)((function () { var e = r; return n.sigmoidScore ? (null != n.scoreClippingThresh && (e = (0, P.clipByValue)(r, -n.scoreClippingThresh, n.scoreClippingThresh)), e = (0, P.sigmoid)(e)) : e })), [4, D$(a, o, n)]; case 1: return s = u.sent(), (0, P.dispose)([a, o]), [2, s] } })) })) } function D$(e, t, n) { return p$(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p; return m$(this, (function (m) { switch (m.label) { case 0: return r = [], [4, e.data()]; case 1: return i = m.sent(), [4, t.data()]; case 2: for (a = m.sent(), o = 0; o < n.numBoxes; ++o)if (!(null != n.minScoreThresh && a[o] < n.minScoreThresh || (s = o * n.numCoords, u = $$(i[s + 0], i[s + 1], i[s + 2], i[s + 3], a[o], n.flipVertically, o), (l = u.locationData.relativeBoundingBox).width < 0 || l.height < 0))) { if (n.numKeypoints > 0) for ((c = u.locationData).relativeKeypoints = [], h = n.numKeypoints * n.numValuesPerKeypoint, d = 0; d < h; d += n.numValuesPerKeypoint)f = s + n.keypointCoordOffset + d, p = { x: i[f + 0], y: n.flipVertically ? 1 - i[f + 1] : i[f + 1] }, c.relativeKeypoints.push(p); r.push(u) } return [2, r] } })) })) } function $$(e, t, n, r, i, a, o) { return { score: [i], ind: o, locationData: { relativeBoundingBox: { xMin: t, yMin: a ? 1 - n : e, xMax: r, yMax: a ? 1 - e : n, width: r - t, height: n - e } } } } function R$(e, t) { return "none" === e ? t : function (e) { return 1 / (1 + Math.exp(-e)) }(t) } function O$(e, t, n, r) { return p$(this, void 0, void 0, (function () { var i, a, o, s, u, l, c, h; return m$(this, (function (d) { switch (d.label) { case 0: return n = n || t.flipHorizontally || !1, r = r || t.flipVertically || !1, i = e.size, a = i / t.numLandmarks, [4, e.data()]; case 1: for (o = d.sent(), s = [], u = 0; u < t.numLandmarks; ++u)l = u * a, (h = { x: 0, y: 0 }).x = n ? t.inputImageWidth - o[l] : o[l], a > 1 && (h.y = r ? t.inputImageHeight - o[l + 1] : o[l + 1]), a > 2 && (h.z = o[l + 2]), a > 3 && (h.score = R$(t.visibilityActivation, o[l + 3])), s.push(h); for (c = 0; c < s.length; ++c)(h = s[c]).x = h.x / t.inputImageWidth, h.y = h.y / t.inputImageHeight, h.z = h.z / t.inputImageWidth / (t.normalizeZ || 1); return [2, s] } })) })) } function z$(e, t, n) { var r = e.width, i = e.height, a = e.rotation; if (null == n.rotation && null == n.rotationDegree || (a = function (e, t) { return null != t.rotation ? e += t.rotation : null != t.rotationDegree && (e += Math.PI * t.rotationDegree / 180), S$(e) }(a, n)), 0 === a) e.xCenter = e.xCenter + r * n.shiftX, e.yCenter = e.yCenter + i * n.shiftY; else { var o = (t.width * r * n.shiftX * Math.cos(a) - t.height * i * n.shiftY * Math.sin(a)) / t.width, s = (t.width * r * n.shiftX * Math.sin(a) + t.height * i * n.shiftY * Math.cos(a)) / t.height; e.xCenter = e.xCenter + o, e.yCenter = e.yCenter + s } if (n.squareLong) { var u = Math.max(r * t.width, i * t.height); r = u / t.width, i = u / t.height } else if (n.squareShort) { var l = Math.min(r * t.width, i * t.height); r = l / t.width, i = l / t.height } return e.width = r * n.scaleX, e.height = i * n.scaleY, e } var P$, B$ = { reduceBoxesInLowestLayer: !1, interpolatedScaleAspectRatio: 1, featureMapHeight: [], featureMapWidth: [], numLayers: 4, minScale: .1484375, maxScale: .75, inputSizeHeight: 192, inputSizeWidth: 192, anchorOffsetX: .5, anchorOffsetY: .5, strides: [8, 16, 16, 16], aspectRatios: [1], fixedAnchorSize: !0 }, L$ = { runtime: "tfjs", modelType: "full", maxHands: 2, detectorModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/full/1", landmarkModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/full/1" }, j$ = { flipHorizontal: !1, staticImageMode: !1 }, U$ = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 2016, numCoords: 18, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 7, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 192, yScale: 192, hScale: 192, wScale: 192, minScoreThresh: .5 }, W$ = { shiftX: 0, shiftY: -.5, scaleX: 2.6, scaleY: 2.6, squareLong: !0 }, V$ = { shiftX: 0, shiftY: -.1, scaleX: 2, scaleY: 2, squareLong: !0 }, G$ = { outputTensorSize: { width: 192, height: 192 }, keepAspectRatio: !0, outputTensorFloatRange: [0, 1], borderMode: "zero" }, H$ = { outputTensorSize: { width: 224, height: 224 }, keepAspectRatio: !0, outputTensorFloatRange: [0, 1], borderMode: "zero" }, q$ = { numLandmarks: 21, inputImageWidth: 224, inputImageHeight: 224, normalizeZ: .4, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, Y$ = { numLandmarks: 21, inputImageWidth: 1, inputImageHeight: 1, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, X$ = function () { function e(e, t, n) { this.detectorModel = e, this.landmarkModel = t, this.maxHands = n, this.prevHandRectsFromLandmarks = null, this.anchors = function (e) { null == e.reduceBoxesInLowestLayer && (e.reduceBoxesInLowestLayer = !1), null == e.interpolatedScaleAspectRatio && (e.interpolatedScaleAspectRatio = 1), null == e.fixedAnchorSize && (e.fixedAnchorSize = !1); for (var t = [], n = 0; n < e.numLayers;) { for (var r = [], i = [], a = [], o = [], s = n; s < e.strides.length && e.strides[s] === e.strides[n];) { var u = T$(e.minScale, e.maxScale, s, e.strides.length); if (0 === s && e.reduceBoxesInLowestLayer) a.push(1), a.push(2), a.push(.5), o.push(.1), o.push(u), o.push(u); else { for (var l = 0; l < e.aspectRatios.length; ++l)a.push(e.aspectRatios[l]), o.push(u); if (e.interpolatedScaleAspectRatio > 0) { var c = s === e.strides.length - 1 ? 1 : T$(e.minScale, e.maxScale, s + 1, e.strides.length); o.push(Math.sqrt(u * c)), a.push(e.interpolatedScaleAspectRatio) } } s++ } for (var h = 0; h < a.length; ++h) { var d = Math.sqrt(a[h]); r.push(o[h] / d), i.push(o[h] * d) } var f = 0, p = 0; if (e.featureMapHeight.length > 0) f = e.featureMapHeight[n], p = e.featureMapWidth[n]; else { var m = e.strides[n]; f = Math.ceil(e.inputSizeHeight / m), p = Math.ceil(e.inputSizeWidth / m) } for (var g = 0; g < f; ++g)for (var y = 0; y < p; ++y)for (var b = 0; b < r.length; ++b) { var v = { xCenter: (y + e.anchorOffsetX) / p, yCenter: (g + e.anchorOffsetY) / f, width: 0, height: 0 }; e.fixedAnchorSize ? (v.width = 1, v.height = 1) : (v.width = i[b], v.height = r[b]), t.push(v) } n = s } return t }(B$); var r = (0, P.tensor1d)(this.anchors.map((function (e) { return e.width }))), i = (0, P.tensor1d)(this.anchors.map((function (e) { return e.height }))), a = (0, P.tensor1d)(this.anchors.map((function (e) { return e.xCenter }))), o = (0, P.tensor1d)(this.anchors.map((function (e) { return e.yCenter }))); this.anchorTensor = { x: a, y: o, w: r, h: i } } return e.prototype.estimateHands = function (e, t) { return p$(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m, g, y, b, v, x = this; return m$(this, (function (w) { switch (w.label) { case 0: return n = function (e) { if (null == e) return f$({}, j$); var t = f$({}, e); return null == t.flipHorizontal && (t.flipHorizontal = j$.flipHorizontal), null == t.staticImageMode && (t.staticImageMode = j$.staticImageMode), t }(t), null == e ? (this.reset(), [2, []]) : (r = k$(e), i = (0, P.tidy)((function () { var t = (0, P.cast)(_$(e), "float32"); return n.flipHorizontal && (t = (0, P.squeeze)(P.image.flipLeftRight((0, P.expandDims)(t, 0)), [0])), t })), a = this.prevHandRectsFromLandmarks, n.staticImageMode || null == a || a.length < this.maxHands ? [4, this.detectPalm(i)] : [3, 2]); case 1: return 0 === (s = w.sent()).length ? (this.reset(), i.dispose(), [2, []]) : (u = s.map((function (e) { return x.palmDetectionToRoi(e, r) })), o = u, [3, 3]); case 2: o = a, w.label = 3; case 3: return k = [], [o].forEach((function (e) { return e.forEach((function (e) { (k = k.filter((function (t) { return function (e, t) { var n = w$(e), r = w$(t); if (!function (e, t) { return !(e.xMax < t.xMin || t.xMax < e.xMin || e.yMax < t.yMin || t.yMax < e.yMin) }(n, r)) return 0; var i = x$(function (e, t) { var n = Math.max(e.xMin, t.xMin), r = Math.min(e.xMax, t.xMax), i = Math.max(e.yMin, t.yMin), a = Math.min(e.yMax, t.yMax); return { xMin: n, xMax: r, yMin: i, yMax: a, width: Math.max(r - n, 0), height: Math.max(a - i, 0) } }(n, r)), a = x$(n) + x$(r) - i; return a > 0 ? i / a : 0 }(e, t) <= .5 }))).push(e) })) })), o = k, [4, Promise.all(o.map((function (e) { return x.handLandmarks(e, i) })))]; case 4: for (l = w.sent(), c = [], this.prevHandRectsFromLandmarks = [], h = 0, d = l; h < d.length; h++)null != (f = d[h]) && (p = f.landmarks, m = f.worldLandmarks, g = f.handScore, y = f.handedness, this.prevHandRectsFromLandmarks.push(this.handLandmarksToRoi(p, r)), null != (b = M$(p, r)) && b.forEach((function (e, t) { delete e.z, e.name = g$[t] })), null != (v = m) && v.forEach((function (e, t) { e.name = g$[t] })), c.push({ keypoints: b, keypoints3D: v, handedness: y, score: g })); return i.dispose(), [2, c] }var k })) })) }, e.prototype.dispose = function () { this.detectorModel.dispose(), this.landmarkModel.dispose(), (0, P.dispose)([this.anchorTensor.x, this.anchorTensor.y, this.anchorTensor.w, this.anchorTensor.h]) }, e.prototype.reset = function () { this.prevHandRectsFromLandmarks = null }, e.prototype.detectPalm = function (e) { return p$(this, void 0, void 0, (function () { var t, n, r, i, a, o, s, u, l, c; return m$(this, (function (h) { switch (h.label) { case 0: return t = A$(e, G$), n = t.imageTensor, r = t.padding, i = this.detectorModel.predict(n), a = function (e) { return (0, P.tidy)((function () { var t = function (e) { return (0, P.tidy)((function () { return [(0, P.slice)(e, [0, 0, 0], [1, -1, 1]), (0, P.slice)(e, [0, 0, 1], [1, -1, -1])] })) }(e), n = t[0], r = t[1]; return { boxes: (0, P.squeeze)(r), logits: (0, P.squeeze)(n) } })) }(i), o = a.boxes, [4, F$([s = a.logits, o], this.anchorTensor, U$)]; case 1: return 0 === (u = h.sent()).length ? ((0, P.dispose)([n, i, s, o]), [2, u]) : [4, I$(u, this.maxHands, .3)]; case 2: return l = h.sent(), c = function (e, t) { void 0 === e && (e = []); for (var n = t.left, r = t.top, i = t.left + t.right, a = t.top + t.bottom, o = 0; o < e.length; o++) { var s = e[o], u = s.locationData.relativeBoundingBox, l = (u.xMin - n) / (1 - i), c = (u.yMin - r) / (1 - a), h = u.width / (1 - i), d = u.height / (1 - a); u.xMin = l, u.yMin = c, u.width = h, u.height = d, u.xMax = l + h, u.yMax = c + d; var f = s.locationData.relativeKeypoints; f && f.forEach((function (e) { var t = (e.x - n) / (1 - i), o = (e.y - r) / (1 - a); e.x = t, e.y = o })) } return e }(l, r), (0, P.dispose)([n, i, s, o]), [2, c] } })) })) }, e.prototype.palmDetectionToRoi = function (e, t) { return z$(function (e, t, n, r, i) { var a = "rect" === n ? function (e, t, n) { var r, i = e.locationData; if ("boundingbox" === t) r = E$(i.boundingBox); else { r = N$(i); var a = n.width, o = n.height; r.xCenter = Math.round(r.xCenter * a), r.yCenter = Math.round(r.yCenter * o), r.width = Math.round(r.width * a), r.height = Math.round(r.height * o) } return r }(e, t, r) : function (e, t) { var n = e.locationData; return "boundingbox" === t ? E$(n.relativeBoundingBox) : N$(n) }(e, t); return i && (a.rotation = function (e, t, n) { var r, i = e.locationData, a = n.rotationVectorStartKeypointIndex, o = n.rotationVectorEndKeypointIndex; r = n.rotationVectorTargetAngle ? n.rotationVectorTargetAngle : Math.PI * n.rotationVectorTargetAngleDegree / 180; var s = i.relativeKeypoints[a].x * t.width, u = i.relativeKeypoints[a].y * t.height, l = i.relativeKeypoints[o].x * t.width, c = i.relativeKeypoints[o].y * t.height; return S$(r - Math.atan2(-(c - u), l - s)) }(e, r, i)), a }(e, "boundingbox", "normRect", t, { rotationVectorStartKeypointIndex: 0, rotationVectorEndKeypointIndex: 2, rotationVectorTargetAngleDegree: 90 }), t, W$) }, e.prototype.handLandmarks = function (e, t) { return p$(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m, g, y; return m$(this, (function (b) { switch (b.label) { case 0: return n = A$(t, H$, e), r = n.imageTensor, i = n.padding, a = this.landmarkModel.execute(r, ["Identity_2:0", "Identity_1:0", "Identity:0", "Identity_3:0"]), o = a[0], s = a[1], u = a[2], l = a[3], [4, s.data()]; case 1: return (c = b.sent()[0]) < .5 ? ((0, P.dispose)(a), (0, P.dispose)(r), [2, null]) : [4, u.data()]; case 2: return h = b.sent()[0], d = h >= .5 ? "Left" : "Right", [4, O$(o, q$)]; case 3: return f = b.sent(), [4, O$(l, Y$)]; case 4: return p = b.sent(), m = function (e, t) { var n = t.left, r = t.top, i = t.left + t.right, a = t.top + t.bottom; return e.map((function (e) { return f$(f$({}, e), { x: (e.x - n) / (1 - i), y: (e.y - r) / (1 - a), z: e.z / (1 - i) }) })) }(f, i), g = function (e, t, n) { void 0 === n && (n = { ignoreRotation: !1 }); for (var r = [], i = 0, a = e; i < a.length; i++) { var o = a[i], s = o.x - .5, u = o.y - .5, l = n.ignoreRotation ? 0 : t.rotation, c = Math.cos(l) * s - Math.sin(l) * u, h = Math.sin(l) * s + Math.cos(l) * u; c = c * t.width + t.xCenter, h = h * t.height + t.yCenter; var d = o.z * t.width, f = f$({}, o); f.x = c, f.y = h, f.z = d, r.push(f) } return r }(m, e), y = function (e, t) { for (var n = [], r = 0, i = e; r < i.length; r++) { var a = i[r], o = a.x, s = a.y, u = t.rotation, l = Math.cos(u) * o - Math.sin(u) * s, c = Math.sin(u) * o + Math.cos(u) * s, h = f$({}, a); h.x = l, h.y = c, n.push(h) } return n }(p, e), (0, P.dispose)(a), (0, P.dispose)(r), [2, { landmarks: g, worldLandmarks: y, handScore: c, handedness: d }] } })) })) }, e.prototype.handLandmarksToRoi = function (e, t) { return z$(function (e, t) { for (var n = function (e, t) { var n = e[0].x * t.width, r = e[0].y * t.height, i = (e[4].x + e[8].x) / 2, a = (e[4].y + e[8].y) / 2; return i = (i + e[6].x) / 2 * t.width, a = (a + e[6].y) / 2 * t.height, S$(Math.PI / 2 - Math.atan2(-(a - r), i - n)) }(e, t), r = S$(-n), i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, u = 0, l = e; u < l.length; u++) { var c = (g = l[u]).x, h = g.y; i = Math.min(i, c), a = Math.max(a, c), o = Math.min(o, h), s = Math.max(s, h) } var d = (a + i) / 2, f = (s + o) / 2; i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY; for (var p = 0, m = e; p < m.length; p++) { var g, y = ((g = m[p]).x - d) * t.width, b = (g.y - f) * t.height, v = y * Math.cos(r) - b * Math.sin(r), x = y * Math.sin(r) + b * Math.cos(r); i = Math.min(i, v), a = Math.max(a, v), o = Math.min(o, x), s = Math.max(s, x) } var w = (a + i) / 2, k = (s + o) / 2, S = w * Math.cos(n) - k * Math.sin(n) + t.width * d, _ = w * Math.sin(n) + k * Math.cos(n) + t.height * f, C = (a - i) / t.width, A = (s - o) / t.height; return { xCenter: S / t.width, yCenter: _ / t.height, width: C, height: A, rotation: n } }([].concat(e.slice(0, 4), e.slice(5, 7), e.slice(9, 11), e.slice(13, 15), e.slice(17, 19)), t), t, V$) }, e }(); function K$(e) { return p$(this, void 0, void 0, (function () { var t, n, r, i, a, o; return m$(this, (function (s) { switch (s.label) { case 0: return t = function (e) { if (null == e) return f$({}, L$); var t = f$({}, e); if (t.runtime = "tfjs", null == t.maxHands && (t.maxHands = L$.maxHands), null == t.modelType && (t.modelType = L$.modelType), "lite" !== t.modelType && "full" !== t.modelType) throw new Error("Model type must be one of lite or full, but got " + t.modelType); return null == t.detectorModelUrl && ("lite" === t.modelType ? t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/lite/1" : t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/full/1"), null == t.landmarkModelUrl && ("lite" === t.modelType ? t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/lite/1" : t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/full/1"), t }(e), n = t.detectorModelUrl.indexOf("https://tfhub.dev") > -1, r = t.landmarkModelUrl.indexOf("https://tfhub.dev") > -1, [4, Promise.all([Ud(t.detectorModelUrl, { fromTFHub: n }), Ud(t.landmarkModelUrl, { fromTFHub: r })])]; case 1: return i = s.sent(), a = i[0], o = i[1], [2, new X$(a, o, t.maxHands)] } })) })) } (P$ || (P$ = {})).MediaPipeHands = "MediaPipeHands"; var Z$ = n(3185); const J$ = (e, t, n, r, i) => `🟪ml5.js warns: The '${t}' option for ${e} has to be set to a ${r}, but it is being set to a ${n} instead.\n\nml5.js is using default value of '${i}'.`, Q$ = (e, t, n, r, i) => `🟪ml5.js warns: The '${t}' option for ${e} has to be set to ${iR(r)}, but it is being set to '${n}' instead.\n\nml5.js is using default value of '${i}'.`, eR = (e, t, n, r, i, a) => `🟪ml5.js warns: The '${t}' option for ${e} has to be set to a number between ${r} and ${i}, but it is being set to '${n}' instead.\n\nml5.js is using default value of '${a}'.`, tR = (e, t, n, r) => `🟪ml5.js warns: The '${t}' option for ${e} has to be set to an integer, but it is being set to the float value '${n}' instead.\n\nml5.js is using the default value of '${r}'.`, nR = (e, t, n, r, i) => `🟪ml5.js warns: The '${t}' option for ${e} has to be a multiple of ${r}, but it is being set to '${n}' instead.\n\nml5.js is using the default value of '${i}'.`, rR = (e, t, n, r) => `🟪ml5.js warns: The modelName parameter for ${e} has to be set to ${iR(n)}, but it is being set to '${t}' instead.\n\nml5.js is using default model '${r}'.`; function iR(e) { if (1 === e.length) return `'${e[0]}'`; if (2 === e.length) return `'${e[0]}' or '${e[1]}'`; { const t = e.pop(); return `'${e.join("', '")}', or '${t}'` } } function aR(e, t) { return "function" == typeof t ? t(e) : t } function oR(e, t, n) { if (n && "string" == typeof e) { return t.find((t => t.toLowerCase() === e.toLowerCase())) } return t.includes(e) ? e : void 0 } function sR(e, t, n) { return e < t || e > n ? void 0 : e } function uR(e, t, n, r) { if (void 0 === e) return n; const i = oR(e, t, !0); return void 0 === i ? (console.warn(rR(r, e, t, n)), n) : i } const lR = function (e, t, n) { const r = {}; for (const i in t) { const a = t[i], o = aR(r, a.type), s = aR(r, a.default); if (aR(r, a.ignore)) continue; const u = t[i].alias; let l, c = !1; if (void 0 !== e[i]) l = e[i]; else { if (void 0 === u || void 0 === e[u]) { r[i] = s; continue } l = e[u], c = !0 } if (typeof l !== o && "enum" !== o) console.warn(J$(n, c ? u : i, typeof l, o, s)), r[i] = s; else if ("enum" === o) { const e = aR(r, a.enums), t = oR(l, e, aR(r, a.caseInsensitive) ?? !0); void 0 === t ? (console.warn(Q$(n, c ? u : i, l, e, s)), r[i] = s) : r[i] = t } else if ("number" === o) { const e = aR(r, a.min) ?? -1 / 0, t = aR(r, a.max) ?? 1 / 0, o = aR(r, a.integer) ?? !1, h = aR(r, a.multipleOf), d = sR(l, e, t); o && !Number.isInteger(l) ? (console.warn(tR(n, c ? u : i, l, s)), r[i] = s) : void 0 !== h && l % h != 0 ? (console.warn(nR(n, c ? u : i, l, h, s)), r[i] = s) : void 0 === d ? (console.warn(eR(n, c ? u : i, l, e, t, s)), r[i] = s) : r[i] = d } else { if ("boolean" !== o && "string" !== o && "object" !== o) throw new Error(`Unknown type "${o}" for ${i} in moldObject.`); r[i] = l } } return r }; function cR(e, t, n) { return Object.assign(e, { [n]: e[t] }), delete e[t], e } + /** + * @license + * Copyright (c) 2020-2024 ml5 + * This software is released under the ml5.js License. + * https://github.com/ml5js/ml5-next-gen/blob/main/LICENSE.md + */ + const hR = { maxHands: { type: "number", min: 1, max: 2147483647, integer: !0, default: 2 }, runtime: { type: "enum", enums: ["mediapipe", "tfjs"], default: "tfjs" }, modelType: { type: "enum", enums: ["lite", "full"], default: "full" }, solutionPath: { type: "string", default: "https://cdn.jsdelivr.net/npm/@mediapipe/hands", ignore: e => "mediapipe" !== e.runtime }, detectorModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime }, landmarkModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime } }, dR = { flipHorizontal: { type: "boolean", alias: "flipped", default: !1 } }; class fR { constructor(e, t, n) { this.modelName = this.modelName = uR(e, ["MediaPipeHands"], "MediaPipeHands", "handPose"), this.model = null, this.userOptions = t, this.runtimeConfig = {}, this.detectMedia = null, this.detectCallback = null, this.detecting = !1, this.signalStop = !1, this.prevCall = "", this.ready = hM(this.loadModel(), n) } async loadModel() { const e = P$.MediaPipeHands, t = lR(this.userOptions, hR, "handPose"); return this.runtimeConfig = lR(this.userOptions, dR, "handPose"), await P.ready(), this.model = await function (e, t) { return p$(this, void 0, void 0, (function () { var n, r; return m$(this, (function (i) { if (e === P$.MediaPipeHands) { if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, K$(n)]; if ("mediapipe" === n.runtime) return [2, v$(n)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got " + r) } throw new Error(e + " is not a supported model name.") })) })) }(e, t), this } async detect(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detect()."); const { image: n, callback: r } = t; await AM(n, !1); let i = await this.model.estimateHands(n, this.runtimeConfig); return this.renameScoreToConfidence(i), this.addKeypoints(i), "function" == typeof r && r(i), i } detectStart(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detectStart()."), t.require("callback", "A callback function argument is required for detectStart()."), this.detectMedia = t.image, this.detectCallback = t.callback, this.signalStop = !1, this.detecting || (this.detecting = !0, this.detectLoop()), "start" === this.prevCall && console.warn("detectStart() was called more than once without calling detectStop(). Only the latest detectStart() call will take effect."), this.prevCall = "start" } detectStop() { this.detecting && (this.signalStop = !0), this.prevCall = "stop" } async detectLoop() { for (await AM(this.detectMedia, !1); !this.signalStop;) { let e = await this.model.estimateHands(this.detectMedia, this.runtimeConfig); this.renameScoreToConfidence(e), this.addKeypoints(e), this.detectCallback(e), await P.nextFrame() } this.detecting = !1, this.signalStop = !1 } renameScoreToConfidence(e) { e.forEach((e => { cR(e, "score", "confidence") })) } addKeypoints(e) { e = e.map((e => { for (let t = 0; t < e.keypoints.length; t++) { let n = e.keypoints[t], r = e.keypoints3D[t]; e[n.name] = { x: n.x, y: n.y, x3D: r.x, y3D: r.y, z3D: r.z } } return e })) } getConnections() { return Z$.c6 } } const pR = (...e) => { const { string: t, options: n = {}, callback: r } = xM(...e); return new fR(t, n, r) }; class mR { constructor(e, t) { this.modelName = uR(e, ["MovieReviews"], "MovieReviews", "sentiment"), this.ready = hM(this.loadModel(), t) } async loadModel(e) { await P.ready(); const t = r$("moviereviews" === this.modelName.toLowerCase() ? "https://storage.googleapis.com/tfjs-models/tfjs/sentiment_cnn_v1/" : this.modelName, "model"), [n, r] = await Promise.all([t.loadLayersModel(), t.loadMetadataJson()]); return this.model = n, this.indexFrom = r.index_from, this.maxLen = r.max_len, this.wordIndex = r.word_index, this.vocabularySize = r.vocabulary_size, this } async predict(...e) { const t = xM(...e), { string: n, callback: r } = t; t.require("string", "A string argument is required for sentiment.predict function."); const i = function (e, t, n = "pre", r = "pre", i = 0) { return e.map((e => { if (e.length > t && ("pre" === r ? e.splice(0, e.length - t) : e.splice(t, e.length - t)), e.length < t) { const r = []; for (let n = 0; n < t - e.length; n += 1)r.push(i); e = "pre" === n ? r.concat(e) : e.concat(r) } return e })) }([n.trim().toLowerCase().replace(/[.,?!]/g, "").split(" ").map((e => { let t = this.wordIndex[e] + this.indexFrom; return t > this.vocabularySize && (t = 2), t }))], this.maxLen), a = P.tensor2d(i, [1, this.maxLen]), o = this.model.predict(a), s = (await o.data())[0]; return o.dispose(), a.dispose(), r && r({ confidence: s }), { confidence: s } } } const gR = (...e) => { const { string: t, callback: n } = xM(...e); return new mR(t, n) }; var yR = n(2726), bR = function () { return bR = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }, bR.apply(this, arguments) }; function vR(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function xR(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(a) { return function (s) { return function (a) { if (n) throw new TypeError("Generator is already executing."); for (; o;)try { if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i; switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) { case 0: case 1: i = a; break; case 4: return o.label++, { value: a[1], done: !1 }; case 5: o.label++, r = a[1], a = [0]; continue; case 7: a = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== a[0] && 2 !== a[0])) { o = 0; continue } if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) { o.label = a[1]; break } if (6 === a[0] && o.label < i[1]) { o.label = i[1], i = a; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(a); break } i[2] && o.ops.pop(), o.trys.pop(); continue }a = t.call(e, o) } catch (e) { a = [6, e], r = 0 } finally { n = i = 0 } if (5 & a[0]) throw a[1]; return { value: a[0] ? a[1] : void 0, done: !0 } }([a, s]) } } } function wR(e) { var t = e.map((function (e) { return e[0] })); return t.push(e[e.length - 1][1]), t } var kR = { lips: wR([[61, 146], [146, 91], [91, 181], [181, 84], [84, 17], [17, 314], [314, 405], [405, 321], [321, 375], [375, 291], [61, 185], [185, 40], [40, 39], [39, 37], [37, 0], [0, 267], [267, 269], [269, 270], [270, 409], [409, 291], [78, 95], [95, 88], [88, 178], [178, 87], [87, 14], [14, 317], [317, 402], [402, 318], [318, 324], [324, 308], [78, 191], [191, 80], [80, 81], [81, 82], [82, 13], [13, 312], [312, 311], [311, 310], [310, 415], [415, 308]]), leftEye: wR([[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]]), leftEyebrow: wR([[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]]), leftIris: wR([[474, 475], [475, 476], [476, 477], [477, 474]]), rightEye: wR([[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]]), rightEyebrow: wR([[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]]), rightIris: wR([[469, 470], [470, 471], [471, 472], [472, 469]]), faceOval: wR([[10, 338], [338, 297], [297, 332], [332, 284], [284, 251], [251, 389], [389, 356], [356, 454], [454, 323], [323, 361], [361, 288], [288, 397], [397, 365], [365, 379], [379, 378], [378, 400], [400, 377], [377, 152], [152, 148], [148, 176], [176, 149], [149, 150], [150, 136], [136, 172], [172, 58], [58, 132], [132, 93], [93, 234], [234, 127], [127, 162], [162, 21], [21, 54], [54, 103], [103, 67], [67, 109], [109, 10]]) }, SR = [[127, 34], [34, 139], [139, 127], [11, 0], [0, 37], [37, 11], [232, 231], [231, 120], [120, 232], [72, 37], [37, 39], [39, 72], [128, 121], [121, 47], [47, 128], [232, 121], [121, 128], [128, 232], [104, 69], [69, 67], [67, 104], [175, 171], [171, 148], [148, 175], [118, 50], [50, 101], [101, 118], [73, 39], [39, 40], [40, 73], [9, 151], [151, 108], [108, 9], [48, 115], [115, 131], [131, 48], [194, 204], [204, 211], [211, 194], [74, 40], [40, 185], [185, 74], [80, 42], [42, 183], [183, 80], [40, 92], [92, 186], [186, 40], [230, 229], [229, 118], [118, 230], [202, 212], [212, 214], [214, 202], [83, 18], [18, 17], [17, 83], [76, 61], [61, 146], [146, 76], [160, 29], [29, 30], [30, 160], [56, 157], [157, 173], [173, 56], [106, 204], [204, 194], [194, 106], [135, 214], [214, 192], [192, 135], [203, 165], [165, 98], [98, 203], [21, 71], [71, 68], [68, 21], [51, 45], [45, 4], [4, 51], [144, 24], [24, 23], [23, 144], [77, 146], [146, 91], [91, 77], [205, 50], [50, 187], [187, 205], [201, 200], [200, 18], [18, 201], [91, 106], [106, 182], [182, 91], [90, 91], [91, 181], [181, 90], [85, 84], [84, 17], [17, 85], [206, 203], [203, 36], [36, 206], [148, 171], [171, 140], [140, 148], [92, 40], [40, 39], [39, 92], [193, 189], [189, 244], [244, 193], [159, 158], [158, 28], [28, 159], [247, 246], [246, 161], [161, 247], [236, 3], [3, 196], [196, 236], [54, 68], [68, 104], [104, 54], [193, 168], [168, 8], [8, 193], [117, 228], [228, 31], [31, 117], [189, 193], [193, 55], [55, 189], [98, 97], [97, 99], [99, 98], [126, 47], [47, 100], [100, 126], [166, 79], [79, 218], [218, 166], [155, 154], [154, 26], [26, 155], [209, 49], [49, 131], [131, 209], [135, 136], [136, 150], [150, 135], [47, 126], [126, 217], [217, 47], [223, 52], [52, 53], [53, 223], [45, 51], [51, 134], [134, 45], [211, 170], [170, 140], [140, 211], [67, 69], [69, 108], [108, 67], [43, 106], [106, 91], [91, 43], [230, 119], [119, 120], [120, 230], [226, 130], [130, 247], [247, 226], [63, 53], [53, 52], [52, 63], [238, 20], [20, 242], [242, 238], [46, 70], [70, 156], [156, 46], [78, 62], [62, 96], [96, 78], [46, 53], [53, 63], [63, 46], [143, 34], [34, 227], [227, 143], [123, 117], [117, 111], [111, 123], [44, 125], [125, 19], [19, 44], [236, 134], [134, 51], [51, 236], [216, 206], [206, 205], [205, 216], [154, 153], [153, 22], [22, 154], [39, 37], [37, 167], [167, 39], [200, 201], [201, 208], [208, 200], [36, 142], [142, 100], [100, 36], [57, 212], [212, 202], [202, 57], [20, 60], [60, 99], [99, 20], [28, 158], [158, 157], [157, 28], [35, 226], [226, 113], [113, 35], [160, 159], [159, 27], [27, 160], [204, 202], [202, 210], [210, 204], [113, 225], [225, 46], [46, 113], [43, 202], [202, 204], [204, 43], [62, 76], [76, 77], [77, 62], [137, 123], [123, 116], [116, 137], [41, 38], [38, 72], [72, 41], [203, 129], [129, 142], [142, 203], [64, 98], [98, 240], [240, 64], [49, 102], [102, 64], [64, 49], [41, 73], [73, 74], [74, 41], [212, 216], [216, 207], [207, 212], [42, 74], [74, 184], [184, 42], [169, 170], [170, 211], [211, 169], [170, 149], [149, 176], [176, 170], [105, 66], [66, 69], [69, 105], [122, 6], [6, 168], [168, 122], [123, 147], [147, 187], [187, 123], [96, 77], [77, 90], [90, 96], [65, 55], [55, 107], [107, 65], [89, 90], [90, 180], [180, 89], [101, 100], [100, 120], [120, 101], [63, 105], [105, 104], [104, 63], [93, 137], [137, 227], [227, 93], [15, 86], [86, 85], [85, 15], [129, 102], [102, 49], [49, 129], [14, 87], [87, 86], [86, 14], [55, 8], [8, 9], [9, 55], [100, 47], [47, 121], [121, 100], [145, 23], [23, 22], [22, 145], [88, 89], [89, 179], [179, 88], [6, 122], [122, 196], [196, 6], [88, 95], [95, 96], [96, 88], [138, 172], [172, 136], [136, 138], [215, 58], [58, 172], [172, 215], [115, 48], [48, 219], [219, 115], [42, 80], [80, 81], [81, 42], [195, 3], [3, 51], [51, 195], [43, 146], [146, 61], [61, 43], [171, 175], [175, 199], [199, 171], [81, 82], [82, 38], [38, 81], [53, 46], [46, 225], [225, 53], [144, 163], [163, 110], [110, 144], [52, 65], [65, 66], [66, 52], [229, 228], [228, 117], [117, 229], [34, 127], [127, 234], [234, 34], [107, 108], [108, 69], [69, 107], [109, 108], [108, 151], [151, 109], [48, 64], [64, 235], [235, 48], [62, 78], [78, 191], [191, 62], [129, 209], [209, 126], [126, 129], [111, 35], [35, 143], [143, 111], [117, 123], [123, 50], [50, 117], [222, 65], [65, 52], [52, 222], [19, 125], [125, 141], [141, 19], [221, 55], [55, 65], [65, 221], [3, 195], [195, 197], [197, 3], [25, 7], [7, 33], [33, 25], [220, 237], [237, 44], [44, 220], [70, 71], [71, 139], [139, 70], [122, 193], [193, 245], [245, 122], [247, 130], [130, 33], [33, 247], [71, 21], [21, 162], [162, 71], [170, 169], [169, 150], [150, 170], [188, 174], [174, 196], [196, 188], [216, 186], [186, 92], [92, 216], [2, 97], [97, 167], [167, 2], [141, 125], [125, 241], [241, 141], [164, 167], [167, 37], [37, 164], [72, 38], [38, 12], [12, 72], [38, 82], [82, 13], [13, 38], [63, 68], [68, 71], [71, 63], [226, 35], [35, 111], [111, 226], [101, 50], [50, 205], [205, 101], [206, 92], [92, 165], [165, 206], [209, 198], [198, 217], [217, 209], [165, 167], [167, 97], [97, 165], [220, 115], [115, 218], [218, 220], [133, 112], [112, 243], [243, 133], [239, 238], [238, 241], [241, 239], [214, 135], [135, 169], [169, 214], [190, 173], [173, 133], [133, 190], [171, 208], [208, 32], [32, 171], [125, 44], [44, 237], [237, 125], [86, 87], [87, 178], [178, 86], [85, 86], [86, 179], [179, 85], [84, 85], [85, 180], [180, 84], [83, 84], [84, 181], [181, 83], [201, 83], [83, 182], [182, 201], [137, 93], [93, 132], [132, 137], [76, 62], [62, 183], [183, 76], [61, 76], [76, 184], [184, 61], [57, 61], [61, 185], [185, 57], [212, 57], [57, 186], [186, 212], [214, 207], [207, 187], [187, 214], [34, 143], [143, 156], [156, 34], [79, 239], [239, 237], [237, 79], [123, 137], [137, 177], [177, 123], [44, 1], [1, 4], [4, 44], [201, 194], [194, 32], [32, 201], [64, 102], [102, 129], [129, 64], [213, 215], [215, 138], [138, 213], [59, 166], [166, 219], [219, 59], [242, 99], [99, 97], [97, 242], [2, 94], [94, 141], [141, 2], [75, 59], [59, 235], [235, 75], [24, 110], [110, 228], [228, 24], [25, 130], [130, 226], [226, 25], [23, 24], [24, 229], [229, 23], [22, 23], [23, 230], [230, 22], [26, 22], [22, 231], [231, 26], [112, 26], [26, 232], [232, 112], [189, 190], [190, 243], [243, 189], [221, 56], [56, 190], [190, 221], [28, 56], [56, 221], [221, 28], [27, 28], [28, 222], [222, 27], [29, 27], [27, 223], [223, 29], [30, 29], [29, 224], [224, 30], [247, 30], [30, 225], [225, 247], [238, 79], [79, 20], [20, 238], [166, 59], [59, 75], [75, 166], [60, 75], [75, 240], [240, 60], [147, 177], [177, 215], [215, 147], [20, 79], [79, 166], [166, 20], [187, 147], [147, 213], [213, 187], [112, 233], [233, 244], [244, 112], [233, 128], [128, 245], [245, 233], [128, 114], [114, 188], [188, 128], [114, 217], [217, 174], [174, 114], [131, 115], [115, 220], [220, 131], [217, 198], [198, 236], [236, 217], [198, 131], [131, 134], [134, 198], [177, 132], [132, 58], [58, 177], [143, 35], [35, 124], [124, 143], [110, 163], [163, 7], [7, 110], [228, 110], [110, 25], [25, 228], [356, 389], [389, 368], [368, 356], [11, 302], [302, 267], [267, 11], [452, 350], [350, 349], [349, 452], [302, 303], [303, 269], [269, 302], [357, 343], [343, 277], [277, 357], [452, 453], [453, 357], [357, 452], [333, 332], [332, 297], [297, 333], [175, 152], [152, 377], [377, 175], [347, 348], [348, 330], [330, 347], [303, 304], [304, 270], [270, 303], [9, 336], [336, 337], [337, 9], [278, 279], [279, 360], [360, 278], [418, 262], [262, 431], [431, 418], [304, 408], [408, 409], [409, 304], [310, 415], [415, 407], [407, 310], [270, 409], [409, 410], [410, 270], [450, 348], [348, 347], [347, 450], [422, 430], [430, 434], [434, 422], [313, 314], [314, 17], [17, 313], [306, 307], [307, 375], [375, 306], [387, 388], [388, 260], [260, 387], [286, 414], [414, 398], [398, 286], [335, 406], [406, 418], [418, 335], [364, 367], [367, 416], [416, 364], [423, 358], [358, 327], [327, 423], [251, 284], [284, 298], [298, 251], [281, 5], [5, 4], [4, 281], [373, 374], [374, 253], [253, 373], [307, 320], [320, 321], [321, 307], [425, 427], [427, 411], [411, 425], [421, 313], [313, 18], [18, 421], [321, 405], [405, 406], [406, 321], [320, 404], [404, 405], [405, 320], [315, 16], [16, 17], [17, 315], [426, 425], [425, 266], [266, 426], [377, 400], [400, 369], [369, 377], [322, 391], [391, 269], [269, 322], [417, 465], [465, 464], [464, 417], [386, 257], [257, 258], [258, 386], [466, 260], [260, 388], [388, 466], [456, 399], [399, 419], [419, 456], [284, 332], [332, 333], [333, 284], [417, 285], [285, 8], [8, 417], [346, 340], [340, 261], [261, 346], [413, 441], [441, 285], [285, 413], [327, 460], [460, 328], [328, 327], [355, 371], [371, 329], [329, 355], [392, 439], [439, 438], [438, 392], [382, 341], [341, 256], [256, 382], [429, 420], [420, 360], [360, 429], [364, 394], [394, 379], [379, 364], [277, 343], [343, 437], [437, 277], [443, 444], [444, 283], [283, 443], [275, 440], [440, 363], [363, 275], [431, 262], [262, 369], [369, 431], [297, 338], [338, 337], [337, 297], [273, 375], [375, 321], [321, 273], [450, 451], [451, 349], [349, 450], [446, 342], [342, 467], [467, 446], [293, 334], [334, 282], [282, 293], [458, 461], [461, 462], [462, 458], [276, 353], [353, 383], [383, 276], [308, 324], [324, 325], [325, 308], [276, 300], [300, 293], [293, 276], [372, 345], [345, 447], [447, 372], [352, 345], [345, 340], [340, 352], [274, 1], [1, 19], [19, 274], [456, 248], [248, 281], [281, 456], [436, 427], [427, 425], [425, 436], [381, 256], [256, 252], [252, 381], [269, 391], [391, 393], [393, 269], [200, 199], [199, 428], [428, 200], [266, 330], [330, 329], [329, 266], [287, 273], [273, 422], [422, 287], [250, 462], [462, 328], [328, 250], [258, 286], [286, 384], [384, 258], [265, 353], [353, 342], [342, 265], [387, 259], [259, 257], [257, 387], [424, 431], [431, 430], [430, 424], [342, 353], [353, 276], [276, 342], [273, 335], [335, 424], [424, 273], [292, 325], [325, 307], [307, 292], [366, 447], [447, 345], [345, 366], [271, 303], [303, 302], [302, 271], [423, 266], [266, 371], [371, 423], [294, 455], [455, 460], [460, 294], [279, 278], [278, 294], [294, 279], [271, 272], [272, 304], [304, 271], [432, 434], [434, 427], [427, 432], [272, 407], [407, 408], [408, 272], [394, 430], [430, 431], [431, 394], [395, 369], [369, 400], [400, 395], [334, 333], [333, 299], [299, 334], [351, 417], [417, 168], [168, 351], [352, 280], [280, 411], [411, 352], [325, 319], [319, 320], [320, 325], [295, 296], [296, 336], [336, 295], [319, 403], [403, 404], [404, 319], [330, 348], [348, 349], [349, 330], [293, 298], [298, 333], [333, 293], [323, 454], [454, 447], [447, 323], [15, 16], [16, 315], [315, 15], [358, 429], [429, 279], [279, 358], [14, 15], [15, 316], [316, 14], [285, 336], [336, 9], [9, 285], [329, 349], [349, 350], [350, 329], [374, 380], [380, 252], [252, 374], [318, 402], [402, 403], [403, 318], [6, 197], [197, 419], [419, 6], [318, 319], [319, 325], [325, 318], [367, 364], [364, 365], [365, 367], [435, 367], [367, 397], [397, 435], [344, 438], [438, 439], [439, 344], [272, 271], [271, 311], [311, 272], [195, 5], [5, 281], [281, 195], [273, 287], [287, 291], [291, 273], [396, 428], [428, 199], [199, 396], [311, 271], [271, 268], [268, 311], [283, 444], [444, 445], [445, 283], [373, 254], [254, 339], [339, 373], [282, 334], [334, 296], [296, 282], [449, 347], [347, 346], [346, 449], [264, 447], [447, 454], [454, 264], [336, 296], [296, 299], [299, 336], [338, 10], [10, 151], [151, 338], [278, 439], [439, 455], [455, 278], [292, 407], [407, 415], [415, 292], [358, 371], [371, 355], [355, 358], [340, 345], [345, 372], [372, 340], [346, 347], [347, 280], [280, 346], [442, 443], [443, 282], [282, 442], [19, 94], [94, 370], [370, 19], [441, 442], [442, 295], [295, 441], [248, 419], [419, 197], [197, 248], [263, 255], [255, 359], [359, 263], [440, 275], [275, 274], [274, 440], [300, 383], [383, 368], [368, 300], [351, 412], [412, 465], [465, 351], [263, 467], [467, 466], [466, 263], [301, 368], [368, 389], [389, 301], [395, 378], [378, 379], [379, 395], [412, 351], [351, 419], [419, 412], [436, 426], [426, 322], [322, 436], [2, 164], [164, 393], [393, 2], [370, 462], [462, 461], [461, 370], [164, 0], [0, 267], [267, 164], [302, 11], [11, 12], [12, 302], [268, 12], [12, 13], [13, 268], [293, 300], [300, 301], [301, 293], [446, 261], [261, 340], [340, 446], [330, 266], [266, 425], [425, 330], [426, 423], [423, 391], [391, 426], [429, 355], [355, 437], [437, 429], [391, 327], [327, 326], [326, 391], [440, 457], [457, 438], [438, 440], [341, 382], [382, 362], [362, 341], [459, 457], [457, 461], [461, 459], [434, 430], [430, 394], [394, 434], [414, 463], [463, 362], [362, 414], [396, 369], [369, 262], [262, 396], [354, 461], [461, 457], [457, 354], [316, 403], [403, 402], [402, 316], [315, 404], [404, 403], [403, 315], [314, 405], [405, 404], [404, 314], [313, 406], [406, 405], [405, 313], [421, 418], [418, 406], [406, 421], [366, 401], [401, 361], [361, 366], [306, 408], [408, 407], [407, 306], [291, 409], [409, 408], [408, 291], [287, 410], [410, 409], [409, 287], [432, 436], [436, 410], [410, 432], [434, 416], [416, 411], [411, 434], [264, 368], [368, 383], [383, 264], [309, 438], [438, 457], [457, 309], [352, 376], [376, 401], [401, 352], [274, 275], [275, 4], [4, 274], [421, 428], [428, 262], [262, 421], [294, 327], [327, 358], [358, 294], [433, 416], [416, 367], [367, 433], [289, 455], [455, 439], [439, 289], [462, 370], [370, 326], [326, 462], [2, 326], [326, 370], [370, 2], [305, 460], [460, 455], [455, 305], [254, 449], [449, 448], [448, 254], [255, 261], [261, 446], [446, 255], [253, 450], [450, 449], [449, 253], [252, 451], [451, 450], [450, 252], [256, 452], [452, 451], [451, 256], [341, 453], [453, 452], [452, 341], [413, 464], [464, 463], [463, 413], [441, 413], [413, 414], [414, 441], [258, 442], [442, 441], [441, 258], [257, 443], [443, 442], [442, 257], [259, 444], [444, 443], [443, 259], [260, 445], [445, 444], [444, 260], [467, 342], [342, 445], [445, 467], [459, 458], [458, 250], [250, 459], [289, 392], [392, 290], [290, 289], [290, 328], [328, 460], [460, 290], [376, 433], [433, 435], [435, 376], [250, 290], [290, 392], [392, 250], [411, 416], [416, 433], [433, 411], [341, 463], [463, 464], [464, 341], [453, 464], [464, 465], [465, 453], [357, 465], [465, 412], [412, 357], [343, 412], [412, 399], [399, 343], [360, 363], [363, 440], [440, 360], [437, 399], [399, 456], [456, 437], [420, 456], [456, 363], [363, 420], [401, 435], [435, 288], [288, 401], [372, 383], [383, 353], [353, 372], [339, 255], [255, 249], [249, 339], [448, 261], [261, 255], [255, 448], [133, 243], [243, 190], [190, 133], [133, 155], [155, 112], [112, 133], [33, 246], [246, 247], [247, 33], [33, 130], [130, 25], [25, 33], [398, 384], [384, 286], [286, 398], [362, 398], [398, 414], [414, 362], [362, 463], [463, 341], [341, 362], [263, 359], [359, 467], [467, 263], [263, 249], [249, 255], [255, 263], [466, 467], [467, 260], [260, 466], [75, 60], [60, 166], [166, 75], [238, 239], [239, 79], [79, 238], [162, 127], [127, 139], [139, 162], [72, 11], [11, 37], [37, 72], [121, 232], [232, 120], [120, 121], [73, 72], [72, 39], [39, 73], [114, 128], [128, 47], [47, 114], [233, 232], [232, 128], [128, 233], [103, 104], [104, 67], [67, 103], [152, 175], [175, 148], [148, 152], [119, 118], [118, 101], [101, 119], [74, 73], [73, 40], [40, 74], [107, 9], [9, 108], [108, 107], [49, 48], [48, 131], [131, 49], [32, 194], [194, 211], [211, 32], [184, 74], [74, 185], [185, 184], [191, 80], [80, 183], [183, 191], [185, 40], [40, 186], [186, 185], [119, 230], [230, 118], [118, 119], [210, 202], [202, 214], [214, 210], [84, 83], [83, 17], [17, 84], [77, 76], [76, 146], [146, 77], [161, 160], [160, 30], [30, 161], [190, 56], [56, 173], [173, 190], [182, 106], [106, 194], [194, 182], [138, 135], [135, 192], [192, 138], [129, 203], [203, 98], [98, 129], [54, 21], [21, 68], [68, 54], [5, 51], [51, 4], [4, 5], [145, 144], [144, 23], [23, 145], [90, 77], [77, 91], [91, 90], [207, 205], [205, 187], [187, 207], [83, 201], [201, 18], [18, 83], [181, 91], [91, 182], [182, 181], [180, 90], [90, 181], [181, 180], [16, 85], [85, 17], [17, 16], [205, 206], [206, 36], [36, 205], [176, 148], [148, 140], [140, 176], [165, 92], [92, 39], [39, 165], [245, 193], [193, 244], [244, 245], [27, 159], [159, 28], [28, 27], [30, 247], [247, 161], [161, 30], [174, 236], [236, 196], [196, 174], [103, 54], [54, 104], [104, 103], [55, 193], [193, 8], [8, 55], [111, 117], [117, 31], [31, 111], [221, 189], [189, 55], [55, 221], [240, 98], [98, 99], [99, 240], [142, 126], [126, 100], [100, 142], [219, 166], [166, 218], [218, 219], [112, 155], [155, 26], [26, 112], [198, 209], [209, 131], [131, 198], [169, 135], [135, 150], [150, 169], [114, 47], [47, 217], [217, 114], [224, 223], [223, 53], [53, 224], [220, 45], [45, 134], [134, 220], [32, 211], [211, 140], [140, 32], [109, 67], [67, 108], [108, 109], [146, 43], [43, 91], [91, 146], [231, 230], [230, 120], [120, 231], [113, 226], [226, 247], [247, 113], [105, 63], [63, 52], [52, 105], [241, 238], [238, 242], [242, 241], [124, 46], [46, 156], [156, 124], [95, 78], [78, 96], [96, 95], [70, 46], [46, 63], [63, 70], [116, 143], [143, 227], [227, 116], [116, 123], [123, 111], [111, 116], [1, 44], [44, 19], [19, 1], [3, 236], [236, 51], [51, 3], [207, 216], [216, 205], [205, 207], [26, 154], [154, 22], [22, 26], [165, 39], [39, 167], [167, 165], [199, 200], [200, 208], [208, 199], [101, 36], [36, 100], [100, 101], [43, 57], [57, 202], [202, 43], [242, 20], [20, 99], [99, 242], [56, 28], [28, 157], [157, 56], [124, 35], [35, 113], [113, 124], [29, 160], [160, 27], [27, 29], [211, 204], [204, 210], [210, 211], [124, 113], [113, 46], [46, 124], [106, 43], [43, 204], [204, 106], [96, 62], [62, 77], [77, 96], [227, 137], [137, 116], [116, 227], [73, 41], [41, 72], [72, 73], [36, 203], [203, 142], [142, 36], [235, 64], [64, 240], [240, 235], [48, 49], [49, 64], [64, 48], [42, 41], [41, 74], [74, 42], [214, 212], [212, 207], [207, 214], [183, 42], [42, 184], [184, 183], [210, 169], [169, 211], [211, 210], [140, 170], [170, 176], [176, 140], [104, 105], [105, 69], [69, 104], [193, 122], [122, 168], [168, 193], [50, 123], [123, 187], [187, 50], [89, 96], [96, 90], [90, 89], [66, 65], [65, 107], [107, 66], [179, 89], [89, 180], [180, 179], [119, 101], [101, 120], [120, 119], [68, 63], [63, 104], [104, 68], [234, 93], [93, 227], [227, 234], [16, 15], [15, 85], [85, 16], [209, 129], [129, 49], [49, 209], [15, 14], [14, 86], [86, 15], [107, 55], [55, 9], [9, 107], [120, 100], [100, 121], [121, 120], [153, 145], [145, 22], [22, 153], [178, 88], [88, 179], [179, 178], [197, 6], [6, 196], [196, 197], [89, 88], [88, 96], [96, 89], [135, 138], [138, 136], [136, 135], [138, 215], [215, 172], [172, 138], [218, 115], [115, 219], [219, 218], [41, 42], [42, 81], [81, 41], [5, 195], [195, 51], [51, 5], [57, 43], [43, 61], [61, 57], [208, 171], [171, 199], [199, 208], [41, 81], [81, 38], [38, 41], [224, 53], [53, 225], [225, 224], [24, 144], [144, 110], [110, 24], [105, 52], [52, 66], [66, 105], [118, 229], [229, 117], [117, 118], [227, 34], [34, 234], [234, 227], [66, 107], [107, 69], [69, 66], [10, 109], [109, 151], [151, 10], [219, 48], [48, 235], [235, 219], [183, 62], [62, 191], [191, 183], [142, 129], [129, 126], [126, 142], [116, 111], [111, 143], [143, 116], [118, 117], [117, 50], [50, 118], [223, 222], [222, 52], [52, 223], [94, 19], [19, 141], [141, 94], [222, 221], [221, 65], [65, 222], [196, 3], [3, 197], [197, 196], [45, 220], [220, 44], [44, 45], [156, 70], [70, 139], [139, 156], [188, 122], [122, 245], [245, 188], [139, 71], [71, 162], [162, 139], [149, 170], [170, 150], [150, 149], [122, 188], [188, 196], [196, 122], [206, 216], [216, 92], [92, 206], [164, 2], [2, 167], [167, 164], [242, 141], [141, 241], [241, 242], [0, 164], [164, 37], [37, 0], [11, 72], [72, 12], [12, 11], [12, 38], [38, 13], [13, 12], [70, 63], [63, 71], [71, 70], [31, 226], [226, 111], [111, 31], [36, 101], [101, 205], [205, 36], [203, 206], [206, 165], [165, 203], [126, 209], [209, 217], [217, 126], [98, 165], [165, 97], [97, 98], [237, 220], [220, 218], [218, 237], [237, 239], [239, 241], [241, 237], [210, 214], [214, 169], [169, 210], [140, 171], [171, 32], [32, 140], [241, 125], [125, 237], [237, 241], [179, 86], [86, 178], [178, 179], [180, 85], [85, 179], [179, 180], [181, 84], [84, 180], [180, 181], [182, 83], [83, 181], [181, 182], [194, 201], [201, 182], [182, 194], [177, 137], [137, 132], [132, 177], [184, 76], [76, 183], [183, 184], [185, 61], [61, 184], [184, 185], [186, 57], [57, 185], [185, 186], [216, 212], [212, 186], [186, 216], [192, 214], [214, 187], [187, 192], [139, 34], [34, 156], [156, 139], [218, 79], [79, 237], [237, 218], [147, 123], [123, 177], [177, 147], [45, 44], [44, 4], [4, 45], [208, 201], [201, 32], [32, 208], [98, 64], [64, 129], [129, 98], [192, 213], [213, 138], [138, 192], [235, 59], [59, 219], [219, 235], [141, 242], [242, 97], [97, 141], [97, 2], [2, 141], [141, 97], [240, 75], [75, 235], [235, 240], [229, 24], [24, 228], [228, 229], [31, 25], [25, 226], [226, 31], [230, 23], [23, 229], [229, 230], [231, 22], [22, 230], [230, 231], [232, 26], [26, 231], [231, 232], [233, 112], [112, 232], [232, 233], [244, 189], [189, 243], [243, 244], [189, 221], [221, 190], [190, 189], [222, 28], [28, 221], [221, 222], [223, 27], [27, 222], [222, 223], [224, 29], [29, 223], [223, 224], [225, 30], [30, 224], [224, 225], [113, 247], [247, 225], [225, 113], [99, 60], [60, 240], [240, 99], [213, 147], [147, 215], [215, 213], [60, 20], [20, 166], [166, 60], [192, 187], [187, 213], [213, 192], [243, 112], [112, 244], [244, 243], [244, 233], [233, 245], [245, 244], [245, 128], [128, 188], [188, 245], [188, 114], [114, 174], [174, 188], [134, 131], [131, 220], [220, 134], [174, 217], [217, 236], [236, 174], [236, 198], [198, 134], [134, 236], [215, 177], [177, 58], [58, 215], [156, 143], [143, 124], [124, 156], [25, 110], [110, 7], [7, 25], [31, 228], [228, 25], [25, 31], [264, 356], [356, 368], [368, 264], [0, 11], [11, 267], [267, 0], [451, 452], [452, 349], [349, 451], [267, 302], [302, 269], [269, 267], [350, 357], [357, 277], [277, 350], [350, 452], [452, 357], [357, 350], [299, 333], [333, 297], [297, 299], [396, 175], [175, 377], [377, 396], [280, 347], [347, 330], [330, 280], [269, 303], [303, 270], [270, 269], [151, 9], [9, 337], [337, 151], [344, 278], [278, 360], [360, 344], [424, 418], [418, 431], [431, 424], [270, 304], [304, 409], [409, 270], [272, 310], [310, 407], [407, 272], [322, 270], [270, 410], [410, 322], [449, 450], [450, 347], [347, 449], [432, 422], [422, 434], [434, 432], [18, 313], [313, 17], [17, 18], [291, 306], [306, 375], [375, 291], [259, 387], [387, 260], [260, 259], [424, 335], [335, 418], [418, 424], [434, 364], [364, 416], [416, 434], [391, 423], [423, 327], [327, 391], [301, 251], [251, 298], [298, 301], [275, 281], [281, 4], [4, 275], [254, 373], [373, 253], [253, 254], [375, 307], [307, 321], [321, 375], [280, 425], [425, 411], [411, 280], [200, 421], [421, 18], [18, 200], [335, 321], [321, 406], [406, 335], [321, 320], [320, 405], [405, 321], [314, 315], [315, 17], [17, 314], [423, 426], [426, 266], [266, 423], [396, 377], [377, 369], [369, 396], [270, 322], [322, 269], [269, 270], [413, 417], [417, 464], [464, 413], [385, 386], [386, 258], [258, 385], [248, 456], [456, 419], [419, 248], [298, 284], [284, 333], [333, 298], [168, 417], [417, 8], [8, 168], [448, 346], [346, 261], [261, 448], [417, 413], [413, 285], [285, 417], [326, 327], [327, 328], [328, 326], [277, 355], [355, 329], [329, 277], [309, 392], [392, 438], [438, 309], [381, 382], [382, 256], [256, 381], [279, 429], [429, 360], [360, 279], [365, 364], [364, 379], [379, 365], [355, 277], [277, 437], [437, 355], [282, 443], [443, 283], [283, 282], [281, 275], [275, 363], [363, 281], [395, 431], [431, 369], [369, 395], [299, 297], [297, 337], [337, 299], [335, 273], [273, 321], [321, 335], [348, 450], [450, 349], [349, 348], [359, 446], [446, 467], [467, 359], [283, 293], [293, 282], [282, 283], [250, 458], [458, 462], [462, 250], [300, 276], [276, 383], [383, 300], [292, 308], [308, 325], [325, 292], [283, 276], [276, 293], [293, 283], [264, 372], [372, 447], [447, 264], [346, 352], [352, 340], [340, 346], [354, 274], [274, 19], [19, 354], [363, 456], [456, 281], [281, 363], [426, 436], [436, 425], [425, 426], [380, 381], [381, 252], [252, 380], [267, 269], [269, 393], [393, 267], [421, 200], [200, 428], [428, 421], [371, 266], [266, 329], [329, 371], [432, 287], [287, 422], [422, 432], [290, 250], [250, 328], [328, 290], [385, 258], [258, 384], [384, 385], [446, 265], [265, 342], [342, 446], [386, 387], [387, 257], [257, 386], [422, 424], [424, 430], [430, 422], [445, 342], [342, 276], [276, 445], [422, 273], [273, 424], [424, 422], [306, 292], [292, 307], [307, 306], [352, 366], [366, 345], [345, 352], [268, 271], [271, 302], [302, 268], [358, 423], [423, 371], [371, 358], [327, 294], [294, 460], [460, 327], [331, 279], [279, 294], [294, 331], [303, 271], [271, 304], [304, 303], [436, 432], [432, 427], [427, 436], [304, 272], [272, 408], [408, 304], [395, 394], [394, 431], [431, 395], [378, 395], [395, 400], [400, 378], [296, 334], [334, 299], [299, 296], [6, 351], [351, 168], [168, 6], [376, 352], [352, 411], [411, 376], [307, 325], [325, 320], [320, 307], [285, 295], [295, 336], [336, 285], [320, 319], [319, 404], [404, 320], [329, 330], [330, 349], [349, 329], [334, 293], [293, 333], [333, 334], [366, 323], [323, 447], [447, 366], [316, 15], [15, 315], [315, 316], [331, 358], [358, 279], [279, 331], [317, 14], [14, 316], [316, 317], [8, 285], [285, 9], [9, 8], [277, 329], [329, 350], [350, 277], [253, 374], [374, 252], [252, 253], [319, 318], [318, 403], [403, 319], [351, 6], [6, 419], [419, 351], [324, 318], [318, 325], [325, 324], [397, 367], [367, 365], [365, 397], [288, 435], [435, 397], [397, 288], [278, 344], [344, 439], [439, 278], [310, 272], [272, 311], [311, 310], [248, 195], [195, 281], [281, 248], [375, 273], [273, 291], [291, 375], [175, 396], [396, 199], [199, 175], [312, 311], [311, 268], [268, 312], [276, 283], [283, 445], [445, 276], [390, 373], [373, 339], [339, 390], [295, 282], [282, 296], [296, 295], [448, 449], [449, 346], [346, 448], [356, 264], [264, 454], [454, 356], [337, 336], [336, 299], [299, 337], [337, 338], [338, 151], [151, 337], [294, 278], [278, 455], [455, 294], [308, 292], [292, 415], [415, 308], [429, 358], [358, 355], [355, 429], [265, 340], [340, 372], [372, 265], [352, 346], [346, 280], [280, 352], [295, 442], [442, 282], [282, 295], [354, 19], [19, 370], [370, 354], [285, 441], [441, 295], [295, 285], [195, 248], [248, 197], [197, 195], [457, 440], [440, 274], [274, 457], [301, 300], [300, 368], [368, 301], [417, 351], [351, 465], [465, 417], [251, 301], [301, 389], [389, 251], [394, 395], [395, 379], [379, 394], [399, 412], [412, 419], [419, 399], [410, 436], [436, 322], [322, 410], [326, 2], [2, 393], [393, 326], [354, 370], [370, 461], [461, 354], [393, 164], [164, 267], [267, 393], [268, 302], [302, 12], [12, 268], [312, 268], [268, 13], [13, 312], [298, 293], [293, 301], [301, 298], [265, 446], [446, 340], [340, 265], [280, 330], [330, 425], [425, 280], [322, 426], [426, 391], [391, 322], [420, 429], [429, 437], [437, 420], [393, 391], [391, 326], [326, 393], [344, 440], [440, 438], [438, 344], [458, 459], [459, 461], [461, 458], [364, 434], [434, 394], [394, 364], [428, 396], [396, 262], [262, 428], [274, 354], [354, 457], [457, 274], [317, 316], [316, 402], [402, 317], [316, 315], [315, 403], [403, 316], [315, 314], [314, 404], [404, 315], [314, 313], [313, 405], [405, 314], [313, 421], [421, 406], [406, 313], [323, 366], [366, 361], [361, 323], [292, 306], [306, 407], [407, 292], [306, 291], [291, 408], [408, 306], [291, 287], [287, 409], [409, 291], [287, 432], [432, 410], [410, 287], [427, 434], [434, 411], [411, 427], [372, 264], [264, 383], [383, 372], [459, 309], [309, 457], [457, 459], [366, 352], [352, 401], [401, 366], [1, 274], [274, 4], [4, 1], [418, 421], [421, 262], [262, 418], [331, 294], [294, 358], [358, 331], [435, 433], [433, 367], [367, 435], [392, 289], [289, 439], [439, 392], [328, 462], [462, 326], [326, 328], [94, 2], [2, 370], [370, 94], [289, 305], [305, 455], [455, 289], [339, 254], [254, 448], [448, 339], [359, 255], [255, 446], [446, 359], [254, 253], [253, 449], [449, 254], [253, 252], [252, 450], [450, 253], [252, 256], [256, 451], [451, 252], [256, 341], [341, 452], [452, 256], [414, 413], [413, 463], [463, 414], [286, 441], [441, 414], [414, 286], [286, 258], [258, 441], [441, 286], [258, 257], [257, 442], [442, 258], [257, 259], [259, 443], [443, 257], [259, 260], [260, 444], [444, 259], [260, 467], [467, 445], [445, 260], [309, 459], [459, 250], [250, 309], [305, 289], [289, 290], [290, 305], [305, 290], [290, 460], [460, 305], [401, 376], [376, 435], [435, 401], [309, 250], [250, 392], [392, 309], [376, 411], [411, 433], [433, 376], [453, 341], [341, 464], [464, 453], [357, 453], [453, 465], [465, 357], [343, 357], [357, 412], [412, 343], [437, 343], [343, 399], [399, 437], [344, 360], [360, 440], [440, 344], [420, 437], [437, 456], [456, 420], [360, 420], [420, 363], [363, 360], [361, 401], [401, 288], [288, 361], [265, 372], [372, 353], [353, 265], [390, 339], [339, 249], [249, 390], [339, 448], [448, 255], [255, 339]], _R = Object.entries(kR).map((function (e) { var t = e[0]; return e[1].map((function (e) { return [e, t] })) })).flat(), CR = new Map(_R); function AR(e) { for (var t = { locationData: { relativeKeypoints: [] } }, n = Number.MAX_SAFE_INTEGER, r = Number.MIN_SAFE_INTEGER, i = Number.MAX_SAFE_INTEGER, a = Number.MIN_SAFE_INTEGER, o = 0; o < e.length; ++o) { var s = e[o]; n = Math.min(n, s.x), r = Math.max(r, s.x), i = Math.min(i, s.y), a = Math.max(a, s.y), t.locationData.relativeKeypoints.push({ x: s.x, y: s.y }) } return t.locationData.relativeBoundingBox = { xMin: n, yMin: i, xMax: r, yMax: a, width: r - n, height: a - i }, t } var TR = { runtime: "mediapipe", maxFaces: 1, refineLandmarks: !1 }, ER = function () { function e(e) { var t = this; this.width = 0, this.height = 0, this.selfieMode = !1, this.faceMeshSolution = new yR.FaceMesh({ locateFile: function (t, n) { return e.solutionPath ? e.solutionPath.replace(/\/+$/, "") + "/" + t : n + "/" + t } }), this.faceMeshSolution.setOptions({ refineLandmarks: e.refineLandmarks, selfieMode: this.selfieMode, maxNumFaces: e.maxFaces }), this.faceMeshSolution.onResults((function (e) { if (t.height = e.image.height, t.width = e.image.width, t.faces = [], null !== e.multiFaceLandmarks) for (var n = e.multiFaceLandmarks, r = 0; r < n.length; r++) { var i = t.translateOutput(n[r]); t.faces.push({ keypoints: i, box: AR(i).locationData.relativeBoundingBox }) } })) } return e.prototype.translateOutput = function (e) { var t = this; return e.map((function (e, n) { var r = { x: e.x * t.width, y: e.y * t.height, z: e.z * t.width }, i = CR.get(n); return null != i && (r.name = i), r })) }, e.prototype.estimateFaces = function (e, t) { return vR(this, void 0, void 0, (function () { var n, r; return xR(this, (function (i) { switch (i.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.faceMeshSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (r = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return n = new (r.apply(ImageData, [void 0, i.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: n = e, i.label = 3; case 3: return e = n, [4, this.faceMeshSolution.send({ image: e })]; case 4: return i.sent(), [2, this.faces] } })) })) }, e.prototype.dispose = function () { this.faceMeshSolution.close() }, e.prototype.reset = function () { this.faceMeshSolution.reset(), this.width = 0, this.height = 0, this.faces = null, this.selfieMode = !1 }, e.prototype.initialize = function () { return this.faceMeshSolution.initialize() }, e }(); function NR(e) { return vR(this, void 0, void 0, (function () { var t, n; return xR(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return bR({}, TR); var t = bR({}, e); return t.runtime = "mediapipe", null == t.maxFaces && (t.maxFaces = TR.maxFaces), null == t.refineLandmarks && (t.refineLandmarks = TR.refineLandmarks), t }(e), [4, (n = new ER(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } var IR = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : void 0 !== n.g ? n.g : "undefined" != typeof self ? self : {}, MR = {}; (function () { var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var n = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }, r = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof IR && IR]; for (var t = 0; t < e.length; ++t) { var n = e[t]; if (n && n.Math == Math) return n } throw Error("Cannot find global object") }(this); function i(e, t) { if (t) e: { var i = r; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in i)) break e; i = i[o] } (t = t(a = i[e = e[e.length - 1]])) != a && null != t && n(i, e, { configurable: !0, writable: !0, value: t }) } } function a(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function o(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function s(e) { if (!(e instanceof Array)) { e = o(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } i("Symbol", (function (e) { function t(e, t) { this.g = e, n(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.g }; var r = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(n) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(r + (n || "") + "_" + i++, n) } })), i("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var i = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), o = 0; o < i.length; o++) { var s = r[i[o]]; "function" == typeof s && "function" != typeof s.prototype[e] && n(s.prototype, e, { configurable: !0, writable: !0, value: function () { return a(t(this)) } }) } return e })); var u, l = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) u = Object.setPrototypeOf; else { var c; e: { var h = {}; try { h.__proto__ = { a: !0 }, c = h.a; break e } catch (e) { } c = !1 } u = c ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var d = u; function f(e, t) { if (e.prototype = l(t.prototype), e.prototype.constructor = e, d) d(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.na = t.prototype } function p() { this.l = !1, this.i = null, this.h = void 0, this.g = 1, this.u = this.o = 0, this.j = null } function m(e) { if (e.l) throw new TypeError("Generator is already running"); e.l = !0 } function g(e, t) { e.j = { da: t, ea: !0 }, e.g = e.o || e.u } function y(e, t, n) { return e.g = n, { value: t } } function b(e) { this.g = new p, this.h = e } function v(e, t, n, r) { try { var i = t.call(e.g.i, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.g.l = !1, i; var a = i.value } catch (t) { return e.g.i = null, g(e.g, t), x(e) } return e.g.i = null, r.call(e.g, a), x(e) } function x(e) { for (; e.g.g;)try { var t = e.h(e.g); if (t) return e.g.l = !1, { value: t.value, done: !1 } } catch (t) { e.g.h = void 0, g(e.g, t) } if (e.g.l = !1, e.g.j) { if (t = e.g.j, e.g.j = null, t.ea) throw t.da; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function w(e) { this.next = function (t) { return m(e.g), e.g.i ? t = v(e, e.g.i.next, t, e.g.s) : (e.g.s(t), t = x(e)), t }, this.throw = function (t) { return m(e.g), e.g.i ? t = v(e, e.g.i.throw, t, e.g.s) : (g(e.g, t), t = x(e)), t }, this.return = function (t) { return function (e, t) { m(e.g); var n = e.g.i; return n ? v(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.g.return) : (e.g.return(t), x(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function k(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new w(new b(e))) } p.prototype.s = function (e) { this.h = e }, p.prototype.return = function (e) { this.j = { return: e }, this.g = this.u }, i("Promise", (function (e) { function t(e) { this.h = 0, this.i = void 0, this.g = [], this.s = !1; var t = this.j(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.g = null } function i(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.h = function (e) { if (null == this.g) { this.g = []; var t = this; this.i((function () { t.l() })) } this.g.push(e) }; var a = r.setTimeout; n.prototype.i = function (e) { a(e, 0) }, n.prototype.l = function () { for (; this.g && this.g.length;) { var e = this.g; this.g = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.j(e) } } } this.g = null }, n.prototype.j = function (e) { this.i((function () { throw e })) }, t.prototype.j = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.D), reject: e(this.l) } }, t.prototype.D = function (e) { if (e === this) this.l(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.H(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.A(e) : this.o(e) } }, t.prototype.A = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.l(e) } "function" == typeof t ? this.I(t, e) : this.o(e) }, t.prototype.l = function (e) { this.u(2, e) }, t.prototype.o = function (e) { this.u(1, e) }, t.prototype.u = function (e, t) { if (0 != this.h) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.h); this.h = e, this.i = t, 2 === this.h && this.G(), this.B() }, t.prototype.G = function () { var e = this; a((function () { if (e.C()) { var t = r.console; void 0 !== t && t.error(e.i) } }), 1) }, t.prototype.C = function () { if (this.s) return !1; var e = r.CustomEvent, t = r.Event, n = r.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = r.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.i, n(e)) }, t.prototype.B = function () { if (null != this.g) { for (var e = 0; e < this.g.length; ++e)s.h(this.g[e]); this.g = null } }; var s = new n; return t.prototype.H = function (e) { var t = this.j(); e.M(t.resolve, t.reject) }, t.prototype.I = function (e, t) { var n = this.j(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.M(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.M = function (e, t) { function n() { switch (r.h) { case 1: e(r.i); break; case 2: t(r.i); break; default: throw Error("Unexpected state: " + r.h) } } var r = this; null == this.g ? s.h(n) : this.g.push(n), this.s = !0 }, t.resolve = i, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var r = o(e), a = r.next(); !a.done; a = r.next())i(a.value).M(t, n) })) }, t.all = function (e) { var n = o(e), r = n.next(); return r.done ? i([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, i(r.value).M(a(o.length - 1), t), r = n.next() } while (!r.done) })) }, t })); var S = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; i("Object.assign", (function (e) { return e || S })), i("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), i("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), i("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })), i("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })); var _ = this || self; function C(e, t) { e = e.split("."); var n, r = _; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function A() { throw Error("Invalid UTF8") } function T(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var E, N, I = "undefined" != typeof TextDecoder, M = "undefined" != typeof TextEncoder, F = {}, D = null; function $(e) { var t; void 0 === t && (t = 0), O(), t = F[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } function R(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = D[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } O(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function O() { if (!D) { D = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); F[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === D[a] && (D[a] = i) } } } } var z, P = "function" == typeof Uint8Array; function B(e) { return P && null != e && e instanceof Uint8Array } function L(e) { if (this.L = e, null !== e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } var j = "function" == typeof Uint8Array.prototype.slice, U = 0; function W(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function V() { return Error("Failed to read varint, encoding is invalid.") } function G(e, t) { t = void 0 !== (t = void 0 === t ? {} : t).v && t.v, this.h = null, this.g = this.i = this.j = 0, this.v = t, e && H(this, e) } function H(e, t) { e.h = function (e, t) { if (e.constructor === Uint8Array) return e; if (e.constructor === ArrayBuffer) return new Uint8Array(e); if (e.constructor === Array) return new Uint8Array(e); if (e.constructor === String) return R(e); if (e.constructor === L) return !t && (t = e.L) && t.constructor === Uint8Array ? t : (t = null == (t = e.L) || B(t) ? t : "string" == typeof t ? R(t) : null, (e = e.L = t) ? new Uint8Array(e) : z || (z = new Uint8Array(0))); if (e instanceof Uint8Array) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength); throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers") }(t, e.v), e.j = 0, e.i = e.h.length, e.g = e.j } function q(e) { if (e.g > e.i) throw Error("Tried to read past the end of the data " + e.g + " > " + e.i) } function Y(e) { var t = e.h, n = t[e.g], r = 127 & n; if (128 > n) return e.g += 1, q(e), r; if (r |= (127 & (n = t[e.g + 1])) << 7, 128 > n) return e.g += 2, q(e), r; if (r |= (127 & (n = t[e.g + 2])) << 14, 128 > n) return e.g += 3, q(e), r; if (r |= (127 & (n = t[e.g + 3])) << 21, 128 > n) return e.g += 4, q(e), r; if (n = t[e.g + 4], e.g += 5, r |= (15 & n) << 28, 128 > n) return q(e), r; if (128 <= t[e.g++] && 128 <= t[e.g++] && 128 <= t[e.g++] && 128 <= t[e.g++] && 128 <= t[e.g++]) throw V(); return q(e), r } G.prototype.reset = function () { this.g = this.j }; var X = []; function K() { this.g = [] } function Z(e, t) { for (; 127 < t;)e.g.push(127 & t | 128), t >>>= 7; e.g.push(t) } function J(e) { var t = {}, n = void 0 !== t.W && t.W; this.l = { v: void 0 !== t.v && t.v }, this.W = n, t = this.l, X.length ? (n = X.pop(), t && (n.v = t.v), e && H(n, e), e = n) : e = new G(e, t), this.g = e, this.j = this.g.g, this.h = this.i = -1 } function Q(e) { var t = e.g; if (t.g == t.i) return !1; e.j = e.g.g; var n = Y(e.g) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw W(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.i = t, e.h = n, !0 } function ee(e) { switch (e.h) { case 0: if (0 != e.h) ee(e); else e: { for (var t = (e = e.g).g, n = t + 10; t < n;)if (!(128 & e.h[t++])) { e.g = t, q(e); break e } throw V() } break; case 1: (e = e.g).g += 8, q(e); break; case 2: 2 != e.h ? ee(e) : (t = Y(e.g) >>> 0, (e = e.g).g += t, q(e)); break; case 5: (e = e.g).g += 4, q(e); break; case 3: for (t = e.i; ;) { if (!Q(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.h) { if (e.i != t) throw Error("Unmatched end-group tag"); break } ee(e) } break; default: throw W(e.h, e.j) } } K.prototype.length = function () { return this.g.length }, K.prototype.end = function () { var e = this.g; return this.g = [], e }, J.prototype.reset = function () { this.g.reset(), this.j = this.g.g, this.h = this.i = -1 }; var te = []; function ne() { this.i = [], this.h = 0, this.g = new K } function re(e, t) { 0 !== t.length && (e.i.push(t), e.h += t.length) } var ie = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol(void 0) : void 0; function ae(e, t) { Object.isFrozen(e) || (ie ? e[ie] |= t : void 0 !== e.N ? e.N |= t : Object.defineProperties(e, { N: { value: t, configurable: !0, writable: !0, enumerable: !1 } })) } function oe(e) { var t; return null == (t = ie ? e[ie] : e.N) ? 0 : t } function se(e) { return ae(e, 1), e } function ue(e) { return !!Array.isArray(e) && !!(2 & oe(e)) } function le(e) { if (!Array.isArray(e)) throw Error("cannot mark non-array as immutable"); ae(e, 2) } function ce(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var he = Object.freeze(se([])); function de(e) { if (ue(e.m)) throw Error("Cannot mutate an immutable Message") } var fe, pe = "undefined" != typeof Symbol && void 0 !== Symbol.hasInstance; function me(e) { return { value: e, configurable: !1, writable: !1, enumerable: !1 } } function ge(e, t, n) { return -1 === t ? null : t >= e.i ? e.g ? e.g[t] : void 0 : void 0 !== n && n && e.g && null != (n = e.g[t]) ? n : e.m[t + e.h] } function ye(e, t, n, r) { r = void 0 !== r && r, de(e), t < e.i && !r ? e.m[t + e.h] = n : (e.g || (e.g = e.m[e.i + e.h] = {}))[t] = n } function be(e, t, n, r) { n = void 0 === n || n; var i = ge(e, t, r = void 0 !== r && r); return null == i && (i = he), ue(e.m) ? n && (le(i), Object.freeze(i)) : (i === he || ue(i)) && ye(e, t, i = se(i.slice()), r), i } function ve(e, t, n) { return null == (e = null == (e = ge(e, t)) ? e : +e) ? void 0 === n ? 0 : n : e } function xe(e, t, n, r) { e.j || (e.j = {}); var i = ue(e.m), a = e.j[n]; if (!a) { r = be(e, n, !0, void 0 !== r && r), a = [], i = i || ue(r); for (var o = 0; o < r.length; o++)a[o] = new t(r[o]), i && le(a[o].m); i && (le(a), Object.freeze(a)), e.j[n] = a } return a } function we(e, t, n, r, i) { var a = void 0 !== a && a; return de(e), a = xe(e, n, t, a), n = r || new n, e = be(e, t), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.m)) : (a.push(n), e.push(n.m)), n } function ke(e, t) { return null == (e = ge(e, t)) ? 0 : e } function Se(e, t) { return null == (e = ge(e, t)) ? "" : e } function _e(e) { return Ae(e, void 0 === Te ? Ee : Te) } function Ce(e, t) { if (null != e) { if (Array.isArray(e)) e = Ae(e, t); else if (ce(e)) { var n, r = {}; for (n in e) r[n] = Ce(e[n], t); e = r } else e = t(e); return e } } function Ae(e, t) { for (var n = e.slice(), r = 0; r < n.length; r++)n[r] = Ce(n[r], t); return Array.isArray(e) && 1 & oe(e) && se(n), n } function Te(e) { return e && "object" == typeof e && e.toJSON ? e.toJSON() : (e = function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e && !Array.isArray(e)) { if (B(e)) return $(e); if (e instanceof L) { var t = e.L; return t = null == t || "string" == typeof t ? t : P && t instanceof Uint8Array ? $(t) : null, (e.L = t) || "" } } }return e }(e), Array.isArray(e) ? _e(e) : e) } function Ee(e) { return B(e) ? new Uint8Array(e) : e } function Ne(e, t, n) { e || (e = fe), fe = null; var r = this.constructor.h; if (e || (e = r ? [r] : []), this.h = (r ? 0 : -1) - (this.constructor.g || 0), this.j = void 0, this.m = e, e = (r = this.m.length) - 1, r && ce(r = this.m[e]) ? (this.i = e - this.h, this.g = r) : void 0 !== t && -1 < t ? (this.i = Math.max(t, e + 1 - this.h), this.g = void 0) : this.i = Number.MAX_VALUE, n) for (t = 0; t < n.length; t++)if ((e = n[t]) < this.i) e += this.h, (r = this.m[e]) ? Array.isArray(r) && se(r) : this.m[e] = he; else { var i = (r = this.g || (this.g = this.m[this.i + this.h] = {}))[e]; i ? Array.isArray(i) && se(i) : r[e] = he } } function Ie() { Ne.apply(this, arguments) } if (Ne.prototype.toJSON = function () { return _e(this.m) }, Ne.prototype.toString = function () { return this.m.toString() }, f(Ie, Ne), pe) { var Me = {}; Object.defineProperties(Ie, (Me[Symbol.hasInstance] = me((function () { throw Error("Cannot perform instanceof checks for MutableMessage") })), Me)) } function Fe(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.ha; o || (i.F = a.la || a.fa.P, a.aa ? (i.U = Be(a.aa), o = function (e) { return function (t, n, r) { return e.F(t, n, r, e.U) } }(i)) : a.ca ? (i.T = Le(a.X.g, a.ca), o = function (e) { return function (t, n, r) { return e.F(t, n, r, e.T) } }(i)) : o = i.F, a.ha = o), o(t, e, a.X), i = { F: i.F, U: i.U, T: i.T } } } !function (e, t) { if (t = t.ba) { re(e, e.g.end()); for (var n = 0; n < t.length; n++)re(e, t[n]) } }(t, e) } var De = Symbol(); function $e(e, t, n) { return e[De] || (e[De] = function (e, r) { return t(e, r, n) }) } function Re(e) { var t = e[De]; if (!t) { var n = Je(e); t = function (e, t) { return Qe(e, t, n) }, e[De] = t } return t } function Oe(e) { var t = function (e) { var t = e.aa; return t ? Re(t) : (t = e.ka) ? $e(e.X.g, t, e.ca) : void 0 }(e), n = e.X, r = e.fa.O; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function ze(e, t, n, r, i, a) { var o = 0; for ((e = e()).length && "number" != typeof e[0] && (n(t, e[0]), o++); o < e.length;) { n = e[o++]; for (var s = o + 1; s < e.length && "number" != typeof e[s];)s++; var u = e[o++]; switch (s -= o) { case 0: r(t, n, u); break; case 1: r(t, n, u, e[o++]); break; case 2: i(t, n, u, e[o++], e[o++]); break; case 3: s = e[o++]; var l = e[o++], c = e[o++]; Array.isArray(c) ? i(t, n, u, s, l, c) : a(t, n, u, s, l, c); break; case 4: a(t, n, u, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + s) } } return t } var Pe = Symbol(); function Be(e) { var t = e[Pe]; if (!t) { var n = He(e); t = function (e, t) { return tt(e, t, n) }, e[Pe] = t } return t } function Le(e, t) { var n = e[Pe]; return n || (n = function (e, n) { return Fe(e, n, t) }, e[Pe] = n), n } var je = Symbol(); function Ue(e, t) { e.push(t) } function We(e, t, n) { e.push(t, n.P) } function Ve(e, t, n, r, i) { var a = Be(i), o = n.P; e.push(t, (function (e, t, n) { return o(e, t, n, r, a) })) } function Ge(e, t, n, r, i, a) { var o = Le(r, a), s = n.P; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function He(e) { return e[je] || ze(e, e[je] = [], Ue, We, Ve, Ge) } var qe = Symbol(); function Ye(e, t) { e[0] = t } function Xe(e, t, n, r) { var i = n.O; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function Ke(e, t, n, r, i, a) { var o = n.O, s = Re(i); e[t] = function (e, t, n) { return o(e, t, n, r, s, a) } } function Ze(e, t, n, r, i, a, o) { var s = n.O, u = $e(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Je(e) { return e[qe] || ze(e, e[qe] = {}, Ye, Xe, Ke, Ze) } function Qe(e, t, n) { for (; Q(t) && 4 != t.h;) { var r = t.i, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = Oe(a)) } if (!(i && i(t, e, r) || (i = t, r = e, a = i.j, ee(i), i.W))) { var o = i.g.h; i = a === (i = i.g.g) ? z || (z = new Uint8Array(0)) : j ? o.slice(a, i) : new Uint8Array(o.subarray(a, i)), (a = r.ba) ? a.push(i) : r.ba = [i] } } return e } function et(e, t, n) { if (te.length) { var r = te.pop(); e && (H(r.g, e), r.i = -1, r.h = -1), e = r } else e = new J(e); try { return Qe(new t, e, Je(n)) } finally { (t = e.g).h = null, t.j = 0, t.i = 0, t.g = 0, t.v = !1, e.i = -1, e.h = -1, 100 > te.length && te.push(e) } } function tt(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); Fe(e, t, i ? n[0] : void 0) } function nt(e, t) { var n = new ne; tt(e, n, He(t)), re(n, n.g.end()), e = new Uint8Array(n.h); for (var r = (t = n.i).length, i = 0, a = 0; a < r; a++) { var o = t[a]; e.set(o, i), i += o.length } return n.i = [e], e } function rt(e, t) { return { O: e, P: t } } var it = rt((function (e, t, n) { if (5 !== e.h) return !1; var r = (e = e.g).h[e.g], i = e.h[e.g + 1], a = e.h[e.g + 2], o = e.h[e.g + 3]; return e.g += 4, q(e), e = 2 * ((i = (r | i << 8 | a << 16 | o << 24) >>> 0) >> 31) + 1, r = i >>> 23 & 255, i &= 8388607, ye(t, n, 255 == r ? i ? NaN : 1 / 0 * e : 0 == r ? e * Math.pow(2, -149) * i : e * Math.pow(2, r - 150) * (i + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = ge(t, n))) { Z(e.g, 8 * n + 5), e = e.g; var r = t; 0 === (r = (n = 0 > r ? 1 : 0) ? -r : r) ? U = 0 < 1 / r ? 0 : 2147483648 : isNaN(r) ? U = 2147483647 : 34028234663852886e22 < r ? U = (n << 31 | 2139095040) >>> 0 : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), U = (n << 31 | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, U = (n << 31 | t + 127 << 23 | 8388607 & r) >>> 0), n = U, e.g.push(n >>> 0 & 255), e.g.push(n >>> 8 & 255), e.g.push(n >>> 16 & 255), e.g.push(n >>> 24 & 255) } })), at = rt((function (e, t, n) { if (0 !== e.h) return !1; for (var r = e.g, i = 128, a = 0, o = e = 0; 4 > o && 128 <= i; o++)i = r.h[r.g++], q(r), a |= (127 & i) << 7 * o; if (128 <= i && (i = r.h[r.g++], q(r), a |= (127 & i) << 28, e |= (127 & i) >> 4), 128 <= i) for (o = 0; 5 > o && 128 <= i; o++)i = r.h[r.g++], q(r), e |= (127 & i) << 7 * o + 3; if (!(128 > i)) throw V(); return r = a >>> 0, (e = 2147483648 & (i = e >>> 0)) && (i = ~i >>> 0, 0 == (r = 1 + ~r >>> 0) && (i = i + 1 >>> 0)), r = 4294967296 * i + (r >>> 0), ye(t, n, e ? -r : r), !0 }), (function (e, t, n) { if (null != (t = ge(t, n)) && null != t) { Z(e.g, 8 * n), e = e.g; var r = t; for (n = 0 > r, t = (r = Math.abs(r)) >>> 0, r = Math.floor((r - t) / 4294967296), r >>>= 0, n && (r = ~r >>> 0, 4294967295 < (t = 1 + (~t >>> 0)) && (t = 0, 4294967295 < ++r && (r = 0))), n = U = t, t = r; 0 < t || 127 < n;)e.g.push(127 & n | 128), n = (n >>> 7 | t << 25) >>> 0, t >>>= 7; e.g.push(n) } })), ot = rt((function (e, t, n) { return 0 === e.h && (ye(t, n, Y(e.g)), !0) }), (function (e, t, n) { if (null != (t = ge(t, n)) && null != t) if (Z(e.g, 8 * n), e = e.g, 0 <= (n = t)) Z(e, n); else { for (t = 0; 9 > t; t++)e.g.push(127 & n | 128), n >>= 7; e.g.push(1) } })), st = rt((function (e, t, n) { if (2 !== e.h) return !1; var r, i = Y(e.g) >>> 0, a = (e = e.g).g; if (e.g += i, q(e), e = e.h, I) (r = E) || (r = E = new TextDecoder("utf-8", { fatal: !0 })), r = r.decode(e.subarray(a, a + i)); else { i = a + i; for (var o, s, u, l = [], c = null; a < i;)128 > (o = e[a++]) ? l.push(o) : 224 > o ? a >= i ? A() : (s = e[a++], 194 > o || 128 != (192 & s) ? (a--, A()) : l.push((31 & o) << 6 | 63 & s)) : 240 > o ? a >= i - 1 ? A() : 128 != (192 & (s = e[a++])) || 224 === o && 160 > s || 237 === o && 160 <= s || 128 != (192 & (r = e[a++])) ? (a--, A()) : l.push((15 & o) << 12 | (63 & s) << 6 | 63 & r) : 244 >= o ? a >= i - 2 ? A() : 128 != (192 & (s = e[a++])) || s - 144 + (o << 28) >> 30 || 128 != (192 & (r = e[a++])) || 128 != (192 & (u = e[a++])) ? (a--, A()) : (o = (7 & o) << 18 | (63 & s) << 12 | (63 & r) << 6 | 63 & u, o -= 65536, l.push(55296 + (o >> 10 & 1023), 56320 + (1023 & o))) : A(), 8192 <= l.length && (c = T(c, l), l.length = 0); r = T(c, l) } return ye(t, n, r), !0 }), (function (e, t, n) { if (null != (t = ge(t, n))) { var r = !1; if (r = void 0 !== r && r, M) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (N || (N = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = a.subarray(0, i) } Z(e.g, 8 * n + 2), Z(e.g, t.length), re(e, e.g.end()), re(e, t) } })), ut = rt((function (e, t, n, r, i) { if (2 !== e.h) return !1; t = we(t, n, r), n = e.g.i, r = Y(e.g) >>> 0; var a = e.g.g + r, o = a - n; if (0 >= o && (e.g.i = a, i(t, e), o = a - e.g.g), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.g.g = a, e.g.i = n, !0 }), (function (e, t, n, r, i) { if (null != (t = xe(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; Z(a.g, 8 * n + 2); var o = a.g.end(); re(a, o), o.push(a.h), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.h + o.g.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.h++; a.push(s), o.h++ } })); function lt() { Ie.apply(this, arguments) } if (f(lt, Ie), pe) { var ct = {}; Object.defineProperties(lt, (ct[Symbol.hasInstance] = me(Object[Symbol.hasInstance]), ct)) } function ht(e) { lt.call(this, e) } function dt() { return [1, ot, 2, it, 3, st, 4, st] } function ft(e) { lt.call(this, e, -1, mt) } function pt() { return [1, ut, ht, dt] } f(ht, lt), f(ft, lt), ft.prototype.addClassification = function (e, t) { return we(this, 1, ht, e, t), this }; var mt = [1]; function gt(e) { lt.call(this, e) } function yt() { return [1, it, 2, it, 3, it, 4, it, 5, it] } function bt(e) { lt.call(this, e, -1, xt) } function vt() { return [1, ut, gt, yt] } f(gt, lt), f(bt, lt); var xt = [1]; function wt(e) { lt.call(this, e) } function kt() { return [1, it, 2, it, 3, it, 4, it, 5, it, 6, at] } f(wt, lt); var St = [[61, 146], [146, 91], [91, 181], [181, 84], [84, 17], [17, 314], [314, 405], [405, 321], [321, 375], [375, 291], [61, 185], [185, 40], [40, 39], [39, 37], [37, 0], [0, 267], [267, 269], [269, 270], [270, 409], [409, 291], [78, 95], [95, 88], [88, 178], [178, 87], [87, 14], [14, 317], [317, 402], [402, 318], [318, 324], [324, 308], [78, 191], [191, 80], [80, 81], [81, 82], [82, 13], [13, 312], [312, 311], [311, 310], [310, 415], [415, 308]], _t = [[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]], Ct = [[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]], At = [[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]], Tt = [[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]], Et = [[10, 338], [338, 297], [297, 332], [332, 284], [284, 251], [251, 389], [389, 356], [356, 454], [454, 323], [323, 361], [361, 288], [288, 397], [397, 365], [365, 379], [379, 378], [378, 400], [400, 377], [377, 152], [152, 148], [148, 176], [176, 149], [149, 150], [150, 136], [136, 172], [172, 58], [58, 132], [132, 93], [93, 234], [234, 127], [127, 162], [162, 21], [21, 54], [54, 103], [103, 67], [67, 109], [109, 10]], Nt = [].concat(s(St), s(_t), s(Ct), s(At), s(Tt), s(Et)); function It(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function Mt(e) { return xe(e, ht, 1).map((function (e) { return { index: ke(e, 1), ga: ve(e, 2), label: null != ge(e, 3) ? Se(e, 3) : void 0, displayName: null != ge(e, 4) ? Se(e, 4) : void 0 } })) } function Ft(e) { return { x: ve(e, 1), y: ve(e, 2), z: ve(e, 3), visibility: null != ge(e, 4) ? ve(e, 4) : void 0 } } function Dt(e, t) { this.h = e, this.g = t, this.l = 0 } function $t(e, t, n) { return function (e, t) { var n = e.g; if (void 0 === e.o) { var r = It(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = It(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.o = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.j = { K: n.getAttribLocation(r, "aVertex"), J: n.getAttribLocation(r, "aTex"), ma: i }, e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.j.K), n.vertexAttribPointer(e.j.K, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.s = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.enableVertexAttribArray(e.j.J), n.vertexAttribPointer(e.j.J, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.j, n.useProgram(e.o), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.h.bindTexture2d(t.glName), n.enableVertexAttribArray(r.K), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.K, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.J), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.vertexAttribPointer(r.J, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.K), n.disableVertexAttribArray(r.J), n.bindBuffer(n.ARRAY_BUFFER, null), e.h.bindTexture2d(0) }(e, t), "function" == typeof e.g.canvas.transferToImageBitmap ? Promise.resolve(e.g.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.g.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.g.canvas) : (void 0 === e.i && (e.i = document.createElement("canvas")), new Promise((function (t) { e.i.height = e.g.canvas.height, e.i.width = e.g.canvas.width, e.i.getContext("2d", {}).drawImage(e.g.canvas, 0, 0, e.g.canvas.width, e.g.canvas.height), t(e.i) }))) } function Rt(e) { this.g = e } var Ot = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function zt(e, t) { return t + e } function Pt(e, t) { window[e] = t } function Bt(e) { if (this.g = e, this.listeners = {}, this.j = {}, this.H = {}, this.o = {}, this.u = {}, this.I = this.s = this.Z = !0, this.D = Promise.resolve(), this.Y = "", this.C = {}, this.locateFile = e && e.locateFile || zt, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.$ = t, e.options) for (var n = (t = o(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.j[n] = "function" == typeof r ? r() : r) } } function Lt(e, t) { var n, r; return k((function (i) { return t in e.H ? i.return(e.H[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.H[t] = r, i.return(r)) })) } function jt(e, t, n) { var r, i, a, s, u, l, c, h, d, f, p, m, g, b; return k((function (v) { switch (v.g) { case 1: if (!n) return v.return(t); for (r = {}, i = 0, a = o(Object.keys(n)), s = a.next(); !s.done; s = a.next())u = s.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.I = !1), c = o(Object.keys(n)), s = c.next(); case 2: if (s.done) { v.g = 4; break } if (h = s.value, "string" == typeof (d = n[h])) return g = r, b = h, y(v, function (e, t, n) { var r; return k((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.h.Uint8BlobList ? i.return(n) : n instanceof e.h.Texture2dDataOut ? ((r = e.u[t]) || (r = new Dt(e.h, e.G), e.u[t] = r), i.return($t(r, n, e.I))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), S = f.getClassificationsList(), _ = [], C = 0; C < x.size(); ++C) { var A = et(x.get(C), wt, kt); A = { boundingBox: { xCenter: ve(A, 1), yCenter: ve(A, 2), height: ve(A, 3), width: ve(A, 4), rotation: ve(A, 5, 0), rectId: ke(A, 6) }, landmarks: xe(et(w.get(C), bt, vt), gt, 1).map(Ft), V: Mt(et(S.get(C), ft, pt)) }, _.push(A) } x = _ } else x = []; r[h] = x, v.g = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, v.g = 7; break } if (void 0 === f) { v.g = 3; break } if ("float_list" === d.type) { r[h] = f, v.g = 7; break } if ("proto" === d.type) { r[h] = f, v.g = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.u[h]) || (p = new Dt(e.h, e.G), e.u[h] = p), y(v, $t(p, f, e.I), 13); case 13: m = v.h, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), v.g = 3; break; case 14: g[b] = v.h; case 3: s = c.next(), v.g = 2; break; case 4: return v.return(r) } })) } function Ut(e, t) { for (var n = t.name || "$", r = [].concat(s(t.wants)), i = new e.h.StringList, a = o(t.wants), u = a.next(); !u.done; u = a.next())i.push_back(u.value); a = e.h.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.D = jt(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.D = n) }))) } }), e.i.attachMultiListener(i, a), i.delete() } function Wt(e) { var t = this; e = e || {}; var n = { url: "face_detection_short.binarypb" }, r = { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }; this.g = new Bt({ locateFile: e.locateFile, files: [{ data: !0, url: "face_detection_short.binarypb" }, { data: !0, url: "face_detection_short_range.tflite" }, { simd: !0, url: "face_detection_solution_simd_wasm_bin.js" }, { simd: !1, url: "face_detection_solution_wasm_bin.js" }], graph: n, listeners: [{ wants: ["detections", "image_transformed"], outs: { image: "image_transformed", detections: { type: "detection_list", stream: "detections" } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, model: { type: 0, onChange: function (e) { var i, a, s, u, l; return k((function (c) { switch (c.g) { case 1: i = o("short" === e ? ["face_detection_short_range.tflite"] : ["face_detection_full_range_sparse.tflite"]), a = i.next(); case 2: if (a.done) { c.g = 4; break } return s = a.value, u = "third_party/mediapipe/modules/face_detection/" + s, y(c, Lt(t.g, s), 5); case 5: l = c.h, t.g.overrideFile(u, l), a = i.next(), c.g = 2; break; case 4: return n.url = "short" === e ? "face_detection_short.binarypb" : "face_detection_full.binarypb", r.graphOptionXref.calculatorName = "short" === e ? "facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator" : "facedetectionfullrangegpu__facedetectionfullrangecommon__TensorsToDetectionsCalculator", c.return(!0) } })) } }, minDetectionConfidence: r } }) } (e = Bt.prototype).close = function () { return this.i && this.i.delete(), Promise.resolve() }, e.reset = function () { var e = this; return k((function (t) { e.i && (e.i.reset(), e.o = {}, e.u = {}), t.g = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.g.options) { for (var r = [], i = [], a = {}, s = o(Object.keys(e)), u = s.next(); !u.done; a = { R: a.R, S: a.S }, u = s.next()) { var l = u.value; l in this.j && this.j[l] === e[l] || (this.j[l] = e[l], void 0 !== (u = t[l]) && (u.onChange && (a.R = u.onChange, a.S = e[l], r.push(function (e) { return function () { return k((function (t) { if (1 == t.g) return y(t, e.R(e.S), 2); !0 === t.h && (n.s = !0), t.g = 0 })) } }(a))), u.graphOptionXref && (l = { valueNumber: 1 === u.type ? e[l] : 0, valueBoolean: 0 === u.type && e[l], valueString: 2 === u.type ? e[l] : "" }, u = Object.assign(Object.assign(Object.assign({}, { calculatorName: "", calculatorIndex: 0 }), u.graphOptionXref), l), i.push(u)))) } 0 === r.length && 0 === i.length || (this.s = !0, this.B = (void 0 === this.B ? [] : this.B).concat(i), this.A = (void 0 === this.A ? [] : this.A).concat(r)) } }, e.initialize = function () { var e = this; return k((function (t) { return 1 == t.g ? y(t, function (e) { var t, n, r, i, a, o, u, l, c, h, d; return k((function (f) { switch (f.g) { case 1: return e.Z ? (t = void 0 === e.g.files ? [] : "function" == typeof e.g.files ? e.g.files(e.j) : e.g.files, y(f, k((function (e) { switch (e.g) { case 1: return e.o = 2, y(e, WebAssembly.instantiate(Ot), 4); case 4: e.g = 3, e.o = 0; break; case 2: return e.o = 0, e.j = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.h, "object" == typeof window) return Pt("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), Pt("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), u = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = Lt(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(u.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.$)) : Promise.resolve() }))).then((function () { var t, n, r; return k((function (i) { if (1 == i.g) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, y(i, t(n), 2); r.h = i.h, i.g = 0 })) })), h = k((function (t) { return e.g.graph && e.g.graph.url ? t = y(t, Lt(e, e.g.graph.url), 0) : (t.g = 0, t = void 0), t })), y(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.$) })), importScripts.apply(null, s(r)), i = e, y(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.h = f.h, e.l = new OffscreenCanvas(1, 1), e.h.canvas = e.l, a = e.h.GL.createContext(e.l, { antialias: !1, alpha: !1, ja: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.h.GL.makeContextCurrent(a), f.g = 4; break; case 7: if (e.l = document.createElement("canvas"), !(d = e.l.getContext("webgl2", {})) && !(d = e.l.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.G = d, e.h.canvas = e.l, e.h.createContext(e.l, !0, !0, {}); case 4: e.i = new e.h.SolutionWasm, e.Z = !1, f.g = 0 } })) }(e), 2) : 3 != t.g ? y(t, function (e) { var t, n, r, i, a, s, u, l; return k((function (c) { if (1 == c.g) return e.g.graph && e.g.graph.url && e.Y === e.g.graph.url ? c.return() : (e.s = !0, e.g.graph && e.g.graph.url ? (e.Y = e.g.graph.url, y(c, Lt(e, e.g.graph.url), 3)) : void (c.g = 2)); for (2 != c.g && (t = c.h, e.i.loadGraph(t)), n = o(Object.keys(e.C)), r = n.next(); !r.done; r = n.next())i = r.value, e.i.overrideFile(i, e.C[i]); if (e.C = {}, e.g.listeners) for (a = o(e.g.listeners), s = a.next(); !s.done; s = a.next())u = s.value, Ut(e, u); l = e.j, e.j = {}, e.setOptions(l), c.g = 0 })) }(e), 3) : y(t, function (e) { var t, n, r, i, a, s; return k((function (u) { switch (u.g) { case 1: if (!e.s) return u.return(); if (!e.A) { u.g = 2; break } t = o(e.A), n = t.next(); case 3: if (n.done) { u.g = 5; break } return y(u, (0, n.value)(), 4); case 4: n = t.next(), u.g = 3; break; case 5: e.A = void 0; case 2: if (e.B) { for (r = new e.h.GraphOptionChangeRequestList, i = o(e.B), a = i.next(); !a.done; a = i.next())s = a.value, r.push_back(s); e.i.changeOptions(r), r.delete(), e.B = void 0 } e.s = !1, u.g = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.i ? this.i.overrideFile(e, t) : this.C[e] = t }, e.clearOverriddenFiles = function () { this.C = {}, this.i && this.i.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, s, u, l, c, h, d = this; return k((function (f) { switch (f.g) { case 1: return d.g.inputs ? (n = 1e3 * (null == t ? performance.now() : t), y(f, d.D, 2)) : f.return(); case 2: return y(f, d.initialize(), 3); case 3: for (r = new d.h.PacketDataList, i = o(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (s = a.value, u = d.g.inputs[s]) { e: { var p = e[s]; switch (u.type) { case "video": var m = d.o[u.stream]; if (m || (m = new Dt(d.h, d.G), d.o[u.stream] = m), 0 === m.l && (m.l = m.h.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, b = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, b = p.naturalHeight) : (g = p.width, b = p.height); b = { glName: m.l, width: g, height: b }, (g = m.g).canvas.width = b.width, g.canvas.height = b.height, g.activeTexture(g.TEXTURE0), m.h.bindTexture2d(m.l), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.h.bindTexture2d(0), m = b; break e; case "detections": for ((m = d.o[u.stream]) || (m = new Rt(d.h), d.o[u.stream] = m), m.data || (m.data = new m.g.DetectionListData), m.data.reset(p.length), b = 0; b < p.length; ++b) { g = p[b]; var v = m.data, x = v.setBoundingBox, w = b, k = g.boundingBox, S = new wt; if (ye(S, 1, k.xCenter), ye(S, 2, k.yCenter), ye(S, 3, k.height), ye(S, 4, k.width), ye(S, 5, k.rotation), ye(S, 6, k.rectId), k = nt(S, kt), x.call(v, w, k), g.landmarks) for (v = 0; v < g.landmarks.length; ++v) { var _ = !!(S = g.landmarks[v]).visibility; w = (x = m.data).addNormalizedLandmark, k = b, S = Object.assign(Object.assign({}, S), { visibility: _ ? S.visibility : 0 }), ye(_ = new gt, 1, S.x), ye(_, 2, S.y), ye(_, 3, S.z), S.visibility && ye(_, 4, S.visibility), S = nt(_, yt), w.call(x, k, S) } if (g.V) for (v = 0; v < g.V.length; ++v)w = (x = m.data).addClassification, k = b, S = g.V[v], ye(_ = new ht, 2, S.ga), S.index && ye(_, 1, S.index), S.label && ye(_, 3, S.label), S.displayName && ye(_, 4, S.displayName), S = nt(_, dt), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign(Object.assign({}, l), { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.i.send(r), y(f, d.D, 4); case 4: r.delete(), f.g = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, C("Solution", Bt), C("OptionType", { BOOL: 0, NUMBER: 1, ia: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = Wt.prototype).close = function () { return this.g.close(), Promise.resolve() }, e.onResults = function (e) { this.g.onResults(e) }, e.initialize = function () { var e = this; return k((function (t) { return y(t, e.g.initialize(), 0) })) }, e.reset = function () { this.g.reset() }, e.send = function (e) { var t = this; return k((function (n) { return y(n, t.g.send(e), 0) })) }, e.setOptions = function (e) { this.g.setOptions(e) }, C("FaceDetection", Wt), C("FACEDETECTION_LIPS", St), C("FACEDETECTION_LEFT_EYE", _t), C("FACEDETECTION_LEFT_EYEBROW", Ct), C("FACEDETECTION_RIGHT_EYE", At), C("FACEDETECTION_RIGHT_EYEBROW", Tt), C("FACEDETECTION_FACE_OVAL", Et), C("FACEDETECTION_CONTOURS", Nt), C("FACEDETECTION_TESSELATION", [[127, 34], [34, 139], [139, 127], [11, 0], [0, 37], [37, 11], [232, 231], [231, 120], [120, 232], [72, 37], [37, 39], [39, 72], [128, 121], [121, 47], [47, 128], [232, 121], [121, 128], [128, 232], [104, 69], [69, 67], [67, 104], [175, 171], [171, 148], [148, 175], [118, 50], [50, 101], [101, 118], [73, 39], [39, 40], [40, 73], [9, 151], [151, 108], [108, 9], [48, 115], [115, 131], [131, 48], [194, 204], [204, 211], [211, 194], [74, 40], [40, 185], [185, 74], [80, 42], [42, 183], [183, 80], [40, 92], [92, 186], [186, 40], [230, 229], [229, 118], [118, 230], [202, 212], [212, 214], [214, 202], [83, 18], [18, 17], [17, 83], [76, 61], [61, 146], [146, 76], [160, 29], [29, 30], [30, 160], [56, 157], [157, 173], [173, 56], [106, 204], [204, 194], [194, 106], [135, 214], [214, 192], [192, 135], [203, 165], [165, 98], [98, 203], [21, 71], [71, 68], [68, 21], [51, 45], [45, 4], [4, 51], [144, 24], [24, 23], [23, 144], [77, 146], [146, 91], [91, 77], [205, 50], [50, 187], [187, 205], [201, 200], [200, 18], [18, 201], [91, 106], [106, 182], [182, 91], [90, 91], [91, 181], [181, 90], [85, 84], [84, 17], [17, 85], [206, 203], [203, 36], [36, 206], [148, 171], [171, 140], [140, 148], [92, 40], [40, 39], [39, 92], [193, 189], [189, 244], [244, 193], [159, 158], [158, 28], [28, 159], [247, 246], [246, 161], [161, 247], [236, 3], [3, 196], [196, 236], [54, 68], [68, 104], [104, 54], [193, 168], [168, 8], [8, 193], [117, 228], [228, 31], [31, 117], [189, 193], [193, 55], [55, 189], [98, 97], [97, 99], [99, 98], [126, 47], [47, 100], [100, 126], [166, 79], [79, 218], [218, 166], [155, 154], [154, 26], [26, 155], [209, 49], [49, 131], [131, 209], [135, 136], [136, 150], [150, 135], [47, 126], [126, 217], [217, 47], [223, 52], [52, 53], [53, 223], [45, 51], [51, 134], [134, 45], [211, 170], [170, 140], [140, 211], [67, 69], [69, 108], [108, 67], [43, 106], [106, 91], [91, 43], [230, 119], [119, 120], [120, 230], [226, 130], [130, 247], [247, 226], [63, 53], [53, 52], [52, 63], [238, 20], [20, 242], [242, 238], [46, 70], [70, 156], [156, 46], [78, 62], [62, 96], [96, 78], [46, 53], [53, 63], [63, 46], [143, 34], [34, 227], [227, 143], [123, 117], [117, 111], [111, 123], [44, 125], [125, 19], [19, 44], [236, 134], [134, 51], [51, 236], [216, 206], [206, 205], [205, 216], [154, 153], [153, 22], [22, 154], [39, 37], [37, 167], [167, 39], [200, 201], [201, 208], [208, 200], [36, 142], [142, 100], [100, 36], [57, 212], [212, 202], [202, 57], [20, 60], [60, 99], [99, 20], [28, 158], [158, 157], [157, 28], [35, 226], [226, 113], [113, 35], [160, 159], [159, 27], [27, 160], [204, 202], [202, 210], [210, 204], [113, 225], [225, 46], [46, 113], [43, 202], [202, 204], [204, 43], [62, 76], [76, 77], [77, 62], [137, 123], [123, 116], [116, 137], [41, 38], [38, 72], [72, 41], [203, 129], [129, 142], [142, 203], [64, 98], [98, 240], [240, 64], [49, 102], [102, 64], [64, 49], [41, 73], [73, 74], [74, 41], [212, 216], [216, 207], [207, 212], [42, 74], [74, 184], [184, 42], [169, 170], [170, 211], [211, 169], [170, 149], [149, 176], [176, 170], [105, 66], [66, 69], [69, 105], [122, 6], [6, 168], [168, 122], [123, 147], [147, 187], [187, 123], [96, 77], [77, 90], [90, 96], [65, 55], [55, 107], [107, 65], [89, 90], [90, 180], [180, 89], [101, 100], [100, 120], [120, 101], [63, 105], [105, 104], [104, 63], [93, 137], [137, 227], [227, 93], [15, 86], [86, 85], [85, 15], [129, 102], [102, 49], [49, 129], [14, 87], [87, 86], [86, 14], [55, 8], [8, 9], [9, 55], [100, 47], [47, 121], [121, 100], [145, 23], [23, 22], [22, 145], [88, 89], [89, 179], [179, 88], [6, 122], [122, 196], [196, 6], [88, 95], [95, 96], [96, 88], [138, 172], [172, 136], [136, 138], [215, 58], [58, 172], [172, 215], [115, 48], [48, 219], [219, 115], [42, 80], [80, 81], [81, 42], [195, 3], [3, 51], [51, 195], [43, 146], [146, 61], [61, 43], [171, 175], [175, 199], [199, 171], [81, 82], [82, 38], [38, 81], [53, 46], [46, 225], [225, 53], [144, 163], [163, 110], [110, 144], [52, 65], [65, 66], [66, 52], [229, 228], [228, 117], [117, 229], [34, 127], [127, 234], [234, 34], [107, 108], [108, 69], [69, 107], [109, 108], [108, 151], [151, 109], [48, 64], [64, 235], [235, 48], [62, 78], [78, 191], [191, 62], [129, 209], [209, 126], [126, 129], [111, 35], [35, 143], [143, 111], [117, 123], [123, 50], [50, 117], [222, 65], [65, 52], [52, 222], [19, 125], [125, 141], [141, 19], [221, 55], [55, 65], [65, 221], [3, 195], [195, 197], [197, 3], [25, 7], [7, 33], [33, 25], [220, 237], [237, 44], [44, 220], [70, 71], [71, 139], [139, 70], [122, 193], [193, 245], [245, 122], [247, 130], [130, 33], [33, 247], [71, 21], [21, 162], [162, 71], [170, 169], [169, 150], [150, 170], [188, 174], [174, 196], [196, 188], [216, 186], [186, 92], [92, 216], [2, 97], [97, 167], [167, 2], [141, 125], [125, 241], [241, 141], [164, 167], [167, 37], [37, 164], [72, 38], [38, 12], [12, 72], [38, 82], [82, 13], [13, 38], [63, 68], [68, 71], [71, 63], [226, 35], [35, 111], [111, 226], [101, 50], [50, 205], [205, 101], [206, 92], [92, 165], [165, 206], [209, 198], [198, 217], [217, 209], [165, 167], [167, 97], [97, 165], [220, 115], [115, 218], [218, 220], [133, 112], [112, 243], [243, 133], [239, 238], [238, 241], [241, 239], [214, 135], [135, 169], [169, 214], [190, 173], [173, 133], [133, 190], [171, 208], [208, 32], [32, 171], [125, 44], [44, 237], [237, 125], [86, 87], [87, 178], [178, 86], [85, 86], [86, 179], [179, 85], [84, 85], [85, 180], [180, 84], [83, 84], [84, 181], [181, 83], [201, 83], [83, 182], [182, 201], [137, 93], [93, 132], [132, 137], [76, 62], [62, 183], [183, 76], [61, 76], [76, 184], [184, 61], [57, 61], [61, 185], [185, 57], [212, 57], [57, 186], [186, 212], [214, 207], [207, 187], [187, 214], [34, 143], [143, 156], [156, 34], [79, 239], [239, 237], [237, 79], [123, 137], [137, 177], [177, 123], [44, 1], [1, 4], [4, 44], [201, 194], [194, 32], [32, 201], [64, 102], [102, 129], [129, 64], [213, 215], [215, 138], [138, 213], [59, 166], [166, 219], [219, 59], [242, 99], [99, 97], [97, 242], [2, 94], [94, 141], [141, 2], [75, 59], [59, 235], [235, 75], [24, 110], [110, 228], [228, 24], [25, 130], [130, 226], [226, 25], [23, 24], [24, 229], [229, 23], [22, 23], [23, 230], [230, 22], [26, 22], [22, 231], [231, 26], [112, 26], [26, 232], [232, 112], [189, 190], [190, 243], [243, 189], [221, 56], [56, 190], [190, 221], [28, 56], [56, 221], [221, 28], [27, 28], [28, 222], [222, 27], [29, 27], [27, 223], [223, 29], [30, 29], [29, 224], [224, 30], [247, 30], [30, 225], [225, 247], [238, 79], [79, 20], [20, 238], [166, 59], [59, 75], [75, 166], [60, 75], [75, 240], [240, 60], [147, 177], [177, 215], [215, 147], [20, 79], [79, 166], [166, 20], [187, 147], [147, 213], [213, 187], [112, 233], [233, 244], [244, 112], [233, 128], [128, 245], [245, 233], [128, 114], [114, 188], [188, 128], [114, 217], [217, 174], [174, 114], [131, 115], [115, 220], [220, 131], [217, 198], [198, 236], [236, 217], [198, 131], [131, 134], [134, 198], [177, 132], [132, 58], [58, 177], [143, 35], [35, 124], [124, 143], [110, 163], [163, 7], [7, 110], [228, 110], [110, 25], [25, 228], [356, 389], [389, 368], [368, 356], [11, 302], [302, 267], [267, 11], [452, 350], [350, 349], [349, 452], [302, 303], [303, 269], [269, 302], [357, 343], [343, 277], [277, 357], [452, 453], [453, 357], [357, 452], [333, 332], [332, 297], [297, 333], [175, 152], [152, 377], [377, 175], [347, 348], [348, 330], [330, 347], [303, 304], [304, 270], [270, 303], [9, 336], [336, 337], [337, 9], [278, 279], [279, 360], [360, 278], [418, 262], [262, 431], [431, 418], [304, 408], [408, 409], [409, 304], [310, 415], [415, 407], [407, 310], [270, 409], [409, 410], [410, 270], [450, 348], [348, 347], [347, 450], [422, 430], [430, 434], [434, 422], [313, 314], [314, 17], [17, 313], [306, 307], [307, 375], [375, 306], [387, 388], [388, 260], [260, 387], [286, 414], [414, 398], [398, 286], [335, 406], [406, 418], [418, 335], [364, 367], [367, 416], [416, 364], [423, 358], [358, 327], [327, 423], [251, 284], [284, 298], [298, 251], [281, 5], [5, 4], [4, 281], [373, 374], [374, 253], [253, 373], [307, 320], [320, 321], [321, 307], [425, 427], [427, 411], [411, 425], [421, 313], [313, 18], [18, 421], [321, 405], [405, 406], [406, 321], [320, 404], [404, 405], [405, 320], [315, 16], [16, 17], [17, 315], [426, 425], [425, 266], [266, 426], [377, 400], [400, 369], [369, 377], [322, 391], [391, 269], [269, 322], [417, 465], [465, 464], [464, 417], [386, 257], [257, 258], [258, 386], [466, 260], [260, 388], [388, 466], [456, 399], [399, 419], [419, 456], [284, 332], [332, 333], [333, 284], [417, 285], [285, 8], [8, 417], [346, 340], [340, 261], [261, 346], [413, 441], [441, 285], [285, 413], [327, 460], [460, 328], [328, 327], [355, 371], [371, 329], [329, 355], [392, 439], [439, 438], [438, 392], [382, 341], [341, 256], [256, 382], [429, 420], [420, 360], [360, 429], [364, 394], [394, 379], [379, 364], [277, 343], [343, 437], [437, 277], [443, 444], [444, 283], [283, 443], [275, 440], [440, 363], [363, 275], [431, 262], [262, 369], [369, 431], [297, 338], [338, 337], [337, 297], [273, 375], [375, 321], [321, 273], [450, 451], [451, 349], [349, 450], [446, 342], [342, 467], [467, 446], [293, 334], [334, 282], [282, 293], [458, 461], [461, 462], [462, 458], [276, 353], [353, 383], [383, 276], [308, 324], [324, 325], [325, 308], [276, 300], [300, 293], [293, 276], [372, 345], [345, 447], [447, 372], [352, 345], [345, 340], [340, 352], [274, 1], [1, 19], [19, 274], [456, 248], [248, 281], [281, 456], [436, 427], [427, 425], [425, 436], [381, 256], [256, 252], [252, 381], [269, 391], [391, 393], [393, 269], [200, 199], [199, 428], [428, 200], [266, 330], [330, 329], [329, 266], [287, 273], [273, 422], [422, 287], [250, 462], [462, 328], [328, 250], [258, 286], [286, 384], [384, 258], [265, 353], [353, 342], [342, 265], [387, 259], [259, 257], [257, 387], [424, 431], [431, 430], [430, 424], [342, 353], [353, 276], [276, 342], [273, 335], [335, 424], [424, 273], [292, 325], [325, 307], [307, 292], [366, 447], [447, 345], [345, 366], [271, 303], [303, 302], [302, 271], [423, 266], [266, 371], [371, 423], [294, 455], [455, 460], [460, 294], [279, 278], [278, 294], [294, 279], [271, 272], [272, 304], [304, 271], [432, 434], [434, 427], [427, 432], [272, 407], [407, 408], [408, 272], [394, 430], [430, 431], [431, 394], [395, 369], [369, 400], [400, 395], [334, 333], [333, 299], [299, 334], [351, 417], [417, 168], [168, 351], [352, 280], [280, 411], [411, 352], [325, 319], [319, 320], [320, 325], [295, 296], [296, 336], [336, 295], [319, 403], [403, 404], [404, 319], [330, 348], [348, 349], [349, 330], [293, 298], [298, 333], [333, 293], [323, 454], [454, 447], [447, 323], [15, 16], [16, 315], [315, 15], [358, 429], [429, 279], [279, 358], [14, 15], [15, 316], [316, 14], [285, 336], [336, 9], [9, 285], [329, 349], [349, 350], [350, 329], [374, 380], [380, 252], [252, 374], [318, 402], [402, 403], [403, 318], [6, 197], [197, 419], [419, 6], [318, 319], [319, 325], [325, 318], [367, 364], [364, 365], [365, 367], [435, 367], [367, 397], [397, 435], [344, 438], [438, 439], [439, 344], [272, 271], [271, 311], [311, 272], [195, 5], [5, 281], [281, 195], [273, 287], [287, 291], [291, 273], [396, 428], [428, 199], [199, 396], [311, 271], [271, 268], [268, 311], [283, 444], [444, 445], [445, 283], [373, 254], [254, 339], [339, 373], [282, 334], [334, 296], [296, 282], [449, 347], [347, 346], [346, 449], [264, 447], [447, 454], [454, 264], [336, 296], [296, 299], [299, 336], [338, 10], [10, 151], [151, 338], [278, 439], [439, 455], [455, 278], [292, 407], [407, 415], [415, 292], [358, 371], [371, 355], [355, 358], [340, 345], [345, 372], [372, 340], [346, 347], [347, 280], [280, 346], [442, 443], [443, 282], [282, 442], [19, 94], [94, 370], [370, 19], [441, 442], [442, 295], [295, 441], [248, 419], [419, 197], [197, 248], [263, 255], [255, 359], [359, 263], [440, 275], [275, 274], [274, 440], [300, 383], [383, 368], [368, 300], [351, 412], [412, 465], [465, 351], [263, 467], [467, 466], [466, 263], [301, 368], [368, 389], [389, 301], [395, 378], [378, 379], [379, 395], [412, 351], [351, 419], [419, 412], [436, 426], [426, 322], [322, 436], [2, 164], [164, 393], [393, 2], [370, 462], [462, 461], [461, 370], [164, 0], [0, 267], [267, 164], [302, 11], [11, 12], [12, 302], [268, 12], [12, 13], [13, 268], [293, 300], [300, 301], [301, 293], [446, 261], [261, 340], [340, 446], [330, 266], [266, 425], [425, 330], [426, 423], [423, 391], [391, 426], [429, 355], [355, 437], [437, 429], [391, 327], [327, 326], [326, 391], [440, 457], [457, 438], [438, 440], [341, 382], [382, 362], [362, 341], [459, 457], [457, 461], [461, 459], [434, 430], [430, 394], [394, 434], [414, 463], [463, 362], [362, 414], [396, 369], [369, 262], [262, 396], [354, 461], [461, 457], [457, 354], [316, 403], [403, 402], [402, 316], [315, 404], [404, 403], [403, 315], [314, 405], [405, 404], [404, 314], [313, 406], [406, 405], [405, 313], [421, 418], [418, 406], [406, 421], [366, 401], [401, 361], [361, 366], [306, 408], [408, 407], [407, 306], [291, 409], [409, 408], [408, 291], [287, 410], [410, 409], [409, 287], [432, 436], [436, 410], [410, 432], [434, 416], [416, 411], [411, 434], [264, 368], [368, 383], [383, 264], [309, 438], [438, 457], [457, 309], [352, 376], [376, 401], [401, 352], [274, 275], [275, 4], [4, 274], [421, 428], [428, 262], [262, 421], [294, 327], [327, 358], [358, 294], [433, 416], [416, 367], [367, 433], [289, 455], [455, 439], [439, 289], [462, 370], [370, 326], [326, 462], [2, 326], [326, 370], [370, 2], [305, 460], [460, 455], [455, 305], [254, 449], [449, 448], [448, 254], [255, 261], [261, 446], [446, 255], [253, 450], [450, 449], [449, 253], [252, 451], [451, 450], [450, 252], [256, 452], [452, 451], [451, 256], [341, 453], [453, 452], [452, 341], [413, 464], [464, 463], [463, 413], [441, 413], [413, 414], [414, 441], [258, 442], [442, 441], [441, 258], [257, 443], [443, 442], [442, 257], [259, 444], [444, 443], [443, 259], [260, 445], [445, 444], [444, 260], [467, 342], [342, 445], [445, 467], [459, 458], [458, 250], [250, 459], [289, 392], [392, 290], [290, 289], [290, 328], [328, 460], [460, 290], [376, 433], [433, 435], [435, 376], [250, 290], [290, 392], [392, 250], [411, 416], [416, 433], [433, 411], [341, 463], [463, 464], [464, 341], [453, 464], [464, 465], [465, 453], [357, 465], [465, 412], [412, 357], [343, 412], [412, 399], [399, 343], [360, 363], [363, 440], [440, 360], [437, 399], [399, 456], [456, 437], [420, 456], [456, 363], [363, 420], [401, 435], [435, 288], [288, 401], [372, 383], [383, 353], [353, 372], [339, 255], [255, 249], [249, 339], [448, 261], [261, 255], [255, 448], [133, 243], [243, 190], [190, 133], [133, 155], [155, 112], [112, 133], [33, 246], [246, 247], [247, 33], [33, 130], [130, 25], [25, 33], [398, 384], [384, 286], [286, 398], [362, 398], [398, 414], [414, 362], [362, 463], [463, 341], [341, 362], [263, 359], [359, 467], [467, 263], [263, 249], [249, 255], [255, 263], [466, 467], [467, 260], [260, 466], [75, 60], [60, 166], [166, 75], [238, 239], [239, 79], [79, 238], [162, 127], [127, 139], [139, 162], [72, 11], [11, 37], [37, 72], [121, 232], [232, 120], [120, 121], [73, 72], [72, 39], [39, 73], [114, 128], [128, 47], [47, 114], [233, 232], [232, 128], [128, 233], [103, 104], [104, 67], [67, 103], [152, 175], [175, 148], [148, 152], [119, 118], [118, 101], [101, 119], [74, 73], [73, 40], [40, 74], [107, 9], [9, 108], [108, 107], [49, 48], [48, 131], [131, 49], [32, 194], [194, 211], [211, 32], [184, 74], [74, 185], [185, 184], [191, 80], [80, 183], [183, 191], [185, 40], [40, 186], [186, 185], [119, 230], [230, 118], [118, 119], [210, 202], [202, 214], [214, 210], [84, 83], [83, 17], [17, 84], [77, 76], [76, 146], [146, 77], [161, 160], [160, 30], [30, 161], [190, 56], [56, 173], [173, 190], [182, 106], [106, 194], [194, 182], [138, 135], [135, 192], [192, 138], [129, 203], [203, 98], [98, 129], [54, 21], [21, 68], [68, 54], [5, 51], [51, 4], [4, 5], [145, 144], [144, 23], [23, 145], [90, 77], [77, 91], [91, 90], [207, 205], [205, 187], [187, 207], [83, 201], [201, 18], [18, 83], [181, 91], [91, 182], [182, 181], [180, 90], [90, 181], [181, 180], [16, 85], [85, 17], [17, 16], [205, 206], [206, 36], [36, 205], [176, 148], [148, 140], [140, 176], [165, 92], [92, 39], [39, 165], [245, 193], [193, 244], [244, 245], [27, 159], [159, 28], [28, 27], [30, 247], [247, 161], [161, 30], [174, 236], [236, 196], [196, 174], [103, 54], [54, 104], [104, 103], [55, 193], [193, 8], [8, 55], [111, 117], [117, 31], [31, 111], [221, 189], [189, 55], [55, 221], [240, 98], [98, 99], [99, 240], [142, 126], [126, 100], [100, 142], [219, 166], [166, 218], [218, 219], [112, 155], [155, 26], [26, 112], [198, 209], [209, 131], [131, 198], [169, 135], [135, 150], [150, 169], [114, 47], [47, 217], [217, 114], [224, 223], [223, 53], [53, 224], [220, 45], [45, 134], [134, 220], [32, 211], [211, 140], [140, 32], [109, 67], [67, 108], [108, 109], [146, 43], [43, 91], [91, 146], [231, 230], [230, 120], [120, 231], [113, 226], [226, 247], [247, 113], [105, 63], [63, 52], [52, 105], [241, 238], [238, 242], [242, 241], [124, 46], [46, 156], [156, 124], [95, 78], [78, 96], [96, 95], [70, 46], [46, 63], [63, 70], [116, 143], [143, 227], [227, 116], [116, 123], [123, 111], [111, 116], [1, 44], [44, 19], [19, 1], [3, 236], [236, 51], [51, 3], [207, 216], [216, 205], [205, 207], [26, 154], [154, 22], [22, 26], [165, 39], [39, 167], [167, 165], [199, 200], [200, 208], [208, 199], [101, 36], [36, 100], [100, 101], [43, 57], [57, 202], [202, 43], [242, 20], [20, 99], [99, 242], [56, 28], [28, 157], [157, 56], [124, 35], [35, 113], [113, 124], [29, 160], [160, 27], [27, 29], [211, 204], [204, 210], [210, 211], [124, 113], [113, 46], [46, 124], [106, 43], [43, 204], [204, 106], [96, 62], [62, 77], [77, 96], [227, 137], [137, 116], [116, 227], [73, 41], [41, 72], [72, 73], [36, 203], [203, 142], [142, 36], [235, 64], [64, 240], [240, 235], [48, 49], [49, 64], [64, 48], [42, 41], [41, 74], [74, 42], [214, 212], [212, 207], [207, 214], [183, 42], [42, 184], [184, 183], [210, 169], [169, 211], [211, 210], [140, 170], [170, 176], [176, 140], [104, 105], [105, 69], [69, 104], [193, 122], [122, 168], [168, 193], [50, 123], [123, 187], [187, 50], [89, 96], [96, 90], [90, 89], [66, 65], [65, 107], [107, 66], [179, 89], [89, 180], [180, 179], [119, 101], [101, 120], [120, 119], [68, 63], [63, 104], [104, 68], [234, 93], [93, 227], [227, 234], [16, 15], [15, 85], [85, 16], [209, 129], [129, 49], [49, 209], [15, 14], [14, 86], [86, 15], [107, 55], [55, 9], [9, 107], [120, 100], [100, 121], [121, 120], [153, 145], [145, 22], [22, 153], [178, 88], [88, 179], [179, 178], [197, 6], [6, 196], [196, 197], [89, 88], [88, 96], [96, 89], [135, 138], [138, 136], [136, 135], [138, 215], [215, 172], [172, 138], [218, 115], [115, 219], [219, 218], [41, 42], [42, 81], [81, 41], [5, 195], [195, 51], [51, 5], [57, 43], [43, 61], [61, 57], [208, 171], [171, 199], [199, 208], [41, 81], [81, 38], [38, 41], [224, 53], [53, 225], [225, 224], [24, 144], [144, 110], [110, 24], [105, 52], [52, 66], [66, 105], [118, 229], [229, 117], [117, 118], [227, 34], [34, 234], [234, 227], [66, 107], [107, 69], [69, 66], [10, 109], [109, 151], [151, 10], [219, 48], [48, 235], [235, 219], [183, 62], [62, 191], [191, 183], [142, 129], [129, 126], [126, 142], [116, 111], [111, 143], [143, 116], [118, 117], [117, 50], [50, 118], [223, 222], [222, 52], [52, 223], [94, 19], [19, 141], [141, 94], [222, 221], [221, 65], [65, 222], [196, 3], [3, 197], [197, 196], [45, 220], [220, 44], [44, 45], [156, 70], [70, 139], [139, 156], [188, 122], [122, 245], [245, 188], [139, 71], [71, 162], [162, 139], [149, 170], [170, 150], [150, 149], [122, 188], [188, 196], [196, 122], [206, 216], [216, 92], [92, 206], [164, 2], [2, 167], [167, 164], [242, 141], [141, 241], [241, 242], [0, 164], [164, 37], [37, 0], [11, 72], [72, 12], [12, 11], [12, 38], [38, 13], [13, 12], [70, 63], [63, 71], [71, 70], [31, 226], [226, 111], [111, 31], [36, 101], [101, 205], [205, 36], [203, 206], [206, 165], [165, 203], [126, 209], [209, 217], [217, 126], [98, 165], [165, 97], [97, 98], [237, 220], [220, 218], [218, 237], [237, 239], [239, 241], [241, 237], [210, 214], [214, 169], [169, 210], [140, 171], [171, 32], [32, 140], [241, 125], [125, 237], [237, 241], [179, 86], [86, 178], [178, 179], [180, 85], [85, 179], [179, 180], [181, 84], [84, 180], [180, 181], [182, 83], [83, 181], [181, 182], [194, 201], [201, 182], [182, 194], [177, 137], [137, 132], [132, 177], [184, 76], [76, 183], [183, 184], [185, 61], [61, 184], [184, 185], [186, 57], [57, 185], [185, 186], [216, 212], [212, 186], [186, 216], [192, 214], [214, 187], [187, 192], [139, 34], [34, 156], [156, 139], [218, 79], [79, 237], [237, 218], [147, 123], [123, 177], [177, 147], [45, 44], [44, 4], [4, 45], [208, 201], [201, 32], [32, 208], [98, 64], [64, 129], [129, 98], [192, 213], [213, 138], [138, 192], [235, 59], [59, 219], [219, 235], [141, 242], [242, 97], [97, 141], [97, 2], [2, 141], [141, 97], [240, 75], [75, 235], [235, 240], [229, 24], [24, 228], [228, 229], [31, 25], [25, 226], [226, 31], [230, 23], [23, 229], [229, 230], [231, 22], [22, 230], [230, 231], [232, 26], [26, 231], [231, 232], [233, 112], [112, 232], [232, 233], [244, 189], [189, 243], [243, 244], [189, 221], [221, 190], [190, 189], [222, 28], [28, 221], [221, 222], [223, 27], [27, 222], [222, 223], [224, 29], [29, 223], [223, 224], [225, 30], [30, 224], [224, 225], [113, 247], [247, 225], [225, 113], [99, 60], [60, 240], [240, 99], [213, 147], [147, 215], [215, 213], [60, 20], [20, 166], [166, 60], [192, 187], [187, 213], [213, 192], [243, 112], [112, 244], [244, 243], [244, 233], [233, 245], [245, 244], [245, 128], [128, 188], [188, 245], [188, 114], [114, 174], [174, 188], [134, 131], [131, 220], [220, 134], [174, 217], [217, 236], [236, 174], [236, 198], [198, 134], [134, 236], [215, 177], [177, 58], [58, 215], [156, 143], [143, 124], [124, 156], [25, 110], [110, 7], [7, 25], [31, 228], [228, 25], [25, 31], [264, 356], [356, 368], [368, 264], [0, 11], [11, 267], [267, 0], [451, 452], [452, 349], [349, 451], [267, 302], [302, 269], [269, 267], [350, 357], [357, 277], [277, 350], [350, 452], [452, 357], [357, 350], [299, 333], [333, 297], [297, 299], [396, 175], [175, 377], [377, 396], [280, 347], [347, 330], [330, 280], [269, 303], [303, 270], [270, 269], [151, 9], [9, 337], [337, 151], [344, 278], [278, 360], [360, 344], [424, 418], [418, 431], [431, 424], [270, 304], [304, 409], [409, 270], [272, 310], [310, 407], [407, 272], [322, 270], [270, 410], [410, 322], [449, 450], [450, 347], [347, 449], [432, 422], [422, 434], [434, 432], [18, 313], [313, 17], [17, 18], [291, 306], [306, 375], [375, 291], [259, 387], [387, 260], [260, 259], [424, 335], [335, 418], [418, 424], [434, 364], [364, 416], [416, 434], [391, 423], [423, 327], [327, 391], [301, 251], [251, 298], [298, 301], [275, 281], [281, 4], [4, 275], [254, 373], [373, 253], [253, 254], [375, 307], [307, 321], [321, 375], [280, 425], [425, 411], [411, 280], [200, 421], [421, 18], [18, 200], [335, 321], [321, 406], [406, 335], [321, 320], [320, 405], [405, 321], [314, 315], [315, 17], [17, 314], [423, 426], [426, 266], [266, 423], [396, 377], [377, 369], [369, 396], [270, 322], [322, 269], [269, 270], [413, 417], [417, 464], [464, 413], [385, 386], [386, 258], [258, 385], [248, 456], [456, 419], [419, 248], [298, 284], [284, 333], [333, 298], [168, 417], [417, 8], [8, 168], [448, 346], [346, 261], [261, 448], [417, 413], [413, 285], [285, 417], [326, 327], [327, 328], [328, 326], [277, 355], [355, 329], [329, 277], [309, 392], [392, 438], [438, 309], [381, 382], [382, 256], [256, 381], [279, 429], [429, 360], [360, 279], [365, 364], [364, 379], [379, 365], [355, 277], [277, 437], [437, 355], [282, 443], [443, 283], [283, 282], [281, 275], [275, 363], [363, 281], [395, 431], [431, 369], [369, 395], [299, 297], [297, 337], [337, 299], [335, 273], [273, 321], [321, 335], [348, 450], [450, 349], [349, 348], [359, 446], [446, 467], [467, 359], [283, 293], [293, 282], [282, 283], [250, 458], [458, 462], [462, 250], [300, 276], [276, 383], [383, 300], [292, 308], [308, 325], [325, 292], [283, 276], [276, 293], [293, 283], [264, 372], [372, 447], [447, 264], [346, 352], [352, 340], [340, 346], [354, 274], [274, 19], [19, 354], [363, 456], [456, 281], [281, 363], [426, 436], [436, 425], [425, 426], [380, 381], [381, 252], [252, 380], [267, 269], [269, 393], [393, 267], [421, 200], [200, 428], [428, 421], [371, 266], [266, 329], [329, 371], [432, 287], [287, 422], [422, 432], [290, 250], [250, 328], [328, 290], [385, 258], [258, 384], [384, 385], [446, 265], [265, 342], [342, 446], [386, 387], [387, 257], [257, 386], [422, 424], [424, 430], [430, 422], [445, 342], [342, 276], [276, 445], [422, 273], [273, 424], [424, 422], [306, 292], [292, 307], [307, 306], [352, 366], [366, 345], [345, 352], [268, 271], [271, 302], [302, 268], [358, 423], [423, 371], [371, 358], [327, 294], [294, 460], [460, 327], [331, 279], [279, 294], [294, 331], [303, 271], [271, 304], [304, 303], [436, 432], [432, 427], [427, 436], [304, 272], [272, 408], [408, 304], [395, 394], [394, 431], [431, 395], [378, 395], [395, 400], [400, 378], [296, 334], [334, 299], [299, 296], [6, 351], [351, 168], [168, 6], [376, 352], [352, 411], [411, 376], [307, 325], [325, 320], [320, 307], [285, 295], [295, 336], [336, 285], [320, 319], [319, 404], [404, 320], [329, 330], [330, 349], [349, 329], [334, 293], [293, 333], [333, 334], [366, 323], [323, 447], [447, 366], [316, 15], [15, 315], [315, 316], [331, 358], [358, 279], [279, 331], [317, 14], [14, 316], [316, 317], [8, 285], [285, 9], [9, 8], [277, 329], [329, 350], [350, 277], [253, 374], [374, 252], [252, 253], [319, 318], [318, 403], [403, 319], [351, 6], [6, 419], [419, 351], [324, 318], [318, 325], [325, 324], [397, 367], [367, 365], [365, 397], [288, 435], [435, 397], [397, 288], [278, 344], [344, 439], [439, 278], [310, 272], [272, 311], [311, 310], [248, 195], [195, 281], [281, 248], [375, 273], [273, 291], [291, 375], [175, 396], [396, 199], [199, 175], [312, 311], [311, 268], [268, 312], [276, 283], [283, 445], [445, 276], [390, 373], [373, 339], [339, 390], [295, 282], [282, 296], [296, 295], [448, 449], [449, 346], [346, 448], [356, 264], [264, 454], [454, 356], [337, 336], [336, 299], [299, 337], [337, 338], [338, 151], [151, 337], [294, 278], [278, 455], [455, 294], [308, 292], [292, 415], [415, 308], [429, 358], [358, 355], [355, 429], [265, 340], [340, 372], [372, 265], [352, 346], [346, 280], [280, 352], [295, 442], [442, 282], [282, 295], [354, 19], [19, 370], [370, 354], [285, 441], [441, 295], [295, 285], [195, 248], [248, 197], [197, 195], [457, 440], [440, 274], [274, 457], [301, 300], [300, 368], [368, 301], [417, 351], [351, 465], [465, 417], [251, 301], [301, 389], [389, 251], [394, 395], [395, 379], [379, 394], [399, 412], [412, 419], [419, 399], [410, 436], [436, 322], [322, 410], [326, 2], [2, 393], [393, 326], [354, 370], [370, 461], [461, 354], [393, 164], [164, 267], [267, 393], [268, 302], [302, 12], [12, 268], [312, 268], [268, 13], [13, 312], [298, 293], [293, 301], [301, 298], [265, 446], [446, 340], [340, 265], [280, 330], [330, 425], [425, 280], [322, 426], [426, 391], [391, 322], [420, 429], [429, 437], [437, 420], [393, 391], [391, 326], [326, 393], [344, 440], [440, 438], [438, 344], [458, 459], [459, 461], [461, 458], [364, 434], [434, 394], [394, 364], [428, 396], [396, 262], [262, 428], [274, 354], [354, 457], [457, 274], [317, 316], [316, 402], [402, 317], [316, 315], [315, 403], [403, 316], [315, 314], [314, 404], [404, 315], [314, 313], [313, 405], [405, 314], [313, 421], [421, 406], [406, 313], [323, 366], [366, 361], [361, 323], [292, 306], [306, 407], [407, 292], [306, 291], [291, 408], [408, 306], [291, 287], [287, 409], [409, 291], [287, 432], [432, 410], [410, 287], [427, 434], [434, 411], [411, 427], [372, 264], [264, 383], [383, 372], [459, 309], [309, 457], [457, 459], [366, 352], [352, 401], [401, 366], [1, 274], [274, 4], [4, 1], [418, 421], [421, 262], [262, 418], [331, 294], [294, 358], [358, 331], [435, 433], [433, 367], [367, 435], [392, 289], [289, 439], [439, 392], [328, 462], [462, 326], [326, 328], [94, 2], [2, 370], [370, 94], [289, 305], [305, 455], [455, 289], [339, 254], [254, 448], [448, 339], [359, 255], [255, 446], [446, 359], [254, 253], [253, 449], [449, 254], [253, 252], [252, 450], [450, 253], [252, 256], [256, 451], [451, 252], [256, 341], [341, 452], [452, 256], [414, 413], [413, 463], [463, 414], [286, 441], [441, 414], [414, 286], [286, 258], [258, 441], [441, 286], [258, 257], [257, 442], [442, 258], [257, 259], [259, 443], [443, 257], [259, 260], [260, 444], [444, 259], [260, 467], [467, 445], [445, 260], [309, 459], [459, 250], [250, 309], [305, 289], [289, 290], [290, 305], [305, 290], [290, 460], [460, 305], [401, 376], [376, 435], [435, 401], [309, 250], [250, 392], [392, 309], [376, 411], [411, 433], [433, 376], [453, 341], [341, 464], [464, 453], [357, 453], [453, 465], [465, 357], [343, 357], [357, 412], [412, 343], [437, 343], [343, 399], [399, 437], [344, 360], [360, 440], [440, 344], [420, 437], [437, 456], [456, 420], [360, 420], [420, 363], [363, 360], [361, 401], [401, 288], [288, 361], [265, 372], [372, 353], [353, 265], [390, 339], [339, 249], [249, 390], [339, 448], [448, 255], [255, 339]]) }).call(IR); var FR = function () { return FR = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }, FR.apply(this, arguments) }; function DR(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function $R(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(a) { return function (s) { return function (a) { if (n) throw new TypeError("Generator is already executing."); for (; o;)try { if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i; switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) { case 0: case 1: i = a; break; case 4: return o.label++, { value: a[1], done: !1 }; case 5: o.label++, r = a[1], a = [0]; continue; case 7: a = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== a[0] && 2 !== a[0])) { o = 0; continue } if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) { o.label = a[1]; break } if (6 === a[0] && o.label < i[1]) { o.label = i[1], i = a; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(a); break } i[2] && o.ops.pop(), o.trys.pop(); continue }a = t.call(e, o) } catch (e) { a = [6, e], r = 0 } finally { n = i = 0 } if (5 & a[0]) throw a[1]; return { value: a[0] ? a[1] : void 0, done: !0 } }([a, s]) } } } var RR = ["rightEye", "leftEye", "noseTip", "mouthCenter", "rightEarTragion", "leftEarTragion"], OR = { modelType: "short", runtime: "mediapipe", maxFaces: 1 }, zR = function () { function e(e) { var t = this; this.width = 0, this.height = 0, this.selfieMode = !1, this.faceDetectorSolution = new MR.FaceDetection({ locateFile: function (t, n) { return e.solutionPath ? e.solutionPath.replace(/\/+$/, "") + "/" + t : n + "/" + t } }), this.faceDetectorSolution.setOptions({ selfieMode: this.selfieMode, model: e.modelType }), this.faceDetectorSolution.onResults((function (e) { if (t.height = e.image.height, t.width = e.image.width, t.faces = [], null !== e.detections) for (var n = 0, r = e.detections; n < r.length; n++) { var i = r[n]; t.faces.push(t.normalizedToAbsolute(i.landmarks, { xMin: o = (a = i.boundingBox).xCenter - a.width / 2, xMax: o + a.width, yMin: s = a.yCenter - a.height / 2, yMax: s + a.height, width: a.width, height: a.height })) } var a, o, s })) } return e.prototype.normalizedToAbsolute = function (e, t) { var n = this; return { keypoints: e.map((function (e, t) { return { x: e.x * n.width, y: e.y * n.height, name: RR[t] } })), box: { xMin: t.xMin * this.width, yMin: t.yMin * this.height, xMax: t.xMax * this.width, yMax: t.yMax * this.height, width: t.width * this.width, height: t.height * this.height } } }, e.prototype.estimateFaces = function (e, t) { return DR(this, void 0, void 0, (function () { var n, r; return $R(this, (function (i) { switch (i.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.faceDetectorSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (r = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return n = new (r.apply(ImageData, [void 0, i.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: n = e, i.label = 3; case 3: return e = n, [4, this.faceDetectorSolution.send({ image: e })]; case 4: return i.sent(), [2, this.faces] } })) })) }, e.prototype.dispose = function () { this.faceDetectorSolution.close() }, e.prototype.reset = function () { this.faceDetectorSolution.reset(), this.width = 0, this.height = 0, this.faces = null, this.selfieMode = !1 }, e.prototype.initialize = function () { return this.faceDetectorSolution.initialize() }, e }(); function PR(e) { return DR(this, void 0, void 0, (function () { var t, n; return $R(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return FR({}, OR); var t = FR({}, e); return t.runtime = "mediapipe", null == t.modelType && (t.modelType = OR.modelType), null == t.maxFaces && (t.maxFaces = OR.maxFaces), t }(e), [4, (n = new zR(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } function BR(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function LR(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function jR(e, t) { P.util.assert(0 !== e.width, (function () { return t + " width cannot be 0." })), P.util.assert(0 !== e.height, (function () { return t + " height cannot be 0." })) } function UR(e) { null == e.reduceBoxesInLowestLayer && (e.reduceBoxesInLowestLayer = !1), null == e.interpolatedScaleAspectRatio && (e.interpolatedScaleAspectRatio = 1), null == e.fixedAnchorSize && (e.fixedAnchorSize = !1); for (var t = [], n = 0; n < e.numLayers;) { for (var r = [], i = [], a = [], o = [], s = n; s < e.strides.length && e.strides[s] === e.strides[n];) { var u = WR(e.minScale, e.maxScale, s, e.strides.length); if (0 === s && e.reduceBoxesInLowestLayer) a.push(1), a.push(2), a.push(.5), o.push(.1), o.push(u), o.push(u); else { for (var l = 0; l < e.aspectRatios.length; ++l)a.push(e.aspectRatios[l]), o.push(u); if (e.interpolatedScaleAspectRatio > 0) { var c = s === e.strides.length - 1 ? 1 : WR(e.minScale, e.maxScale, s + 1, e.strides.length); o.push(Math.sqrt(u * c)), a.push(e.interpolatedScaleAspectRatio) } } s++ } for (var h = 0; h < a.length; ++h) { var d = Math.sqrt(a[h]); r.push(o[h] / d), i.push(o[h] * d) } var f = 0, p = 0; if (e.featureMapHeight.length > 0) f = e.featureMapHeight[n], p = e.featureMapWidth[n]; else { var m = e.strides[n]; f = Math.ceil(e.inputSizeHeight / m), p = Math.ceil(e.inputSizeWidth / m) } for (var g = 0; g < f; ++g)for (var y = 0; y < p; ++y)for (var b = 0; b < r.length; ++b) { var v = { xCenter: (y + e.anchorOffsetX) / p, yCenter: (g + e.anchorOffsetY) / f, width: 0, height: 0 }; e.fixedAnchorSize ? (v.width = 1, v.height = 1) : (v.width = i[b], v.height = r[b]), t.push(v) } n = s } return t } function WR(e, t, n, r) { return 1 === r ? .5 * (e + t) : e + (t - e) * n / (r - 1) } function VR(e, t) { var n = t[0], r = t[1]; return [n * e[0] + r * e[1] + e[3], n * e[4] + r * e[5] + e[7]] } function GR(e, t, n, r) { return DR(this, void 0, void 0, (function () { var r, i, a, o, s; return $R(this, (function (u) { switch (u.label) { case 0: return e.sort((function (e, t) { return Math.max.apply(Math, t.score) - Math.max.apply(Math, e.score) })), r = (0, P.tensor2d)(e.map((function (e) { return [e.locationData.relativeBoundingBox.yMin, e.locationData.relativeBoundingBox.xMin, e.locationData.relativeBoundingBox.yMax, e.locationData.relativeBoundingBox.xMax] }))), i = (0, P.tensor1d)(e.map((function (e) { return e.score[0] }))), [4, P.image.nonMaxSuppressionAsync(r, i, t, n)]; case 1: return [4, (a = u.sent()).array()]; case 2: return o = u.sent(), s = e.filter((function (e, t) { return o.indexOf(t) > -1 })), (0, P.dispose)([r, i, a]), [2, s] } })) })) } function HR(e, t, n) { return DR(this, void 0, void 0, (function () { var r, i, a, o, s; return $R(this, (function (u) { switch (u.label) { case 0: return r = e[0], i = e[1], a = function (e, t, n) { return (0, P.tidy)((function () { var r, i, a, o; n.reverseOutputOrder ? (i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))) : (r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))), i = (0, P.add)((0, P.mul)((0, P.div)(i, n.xScale), t.w), t.x), r = (0, P.add)((0, P.mul)((0, P.div)(r, n.yScale), t.h), t.y), n.applyExponentialOnBoxSize ? (a = (0, P.mul)((0, P.exp)((0, P.div)(a, n.hScale)), t.h), o = (0, P.mul)((0, P.exp)((0, P.div)(o, n.wScale)), t.w)) : (a = (0, P.mul)((0, P.div)(a, n.hScale), t.h), o = (0, P.mul)((0, P.div)(o, n.wScale), t.h)); var s = (0, P.sub)(r, (0, P.div)(a, 2)), u = (0, P.sub)(i, (0, P.div)(o, 2)), l = (0, P.add)(r, (0, P.div)(a, 2)), c = (0, P.add)(i, (0, P.div)(o, 2)), h = (0, P.concat)([(0, P.reshape)(s, [n.numBoxes, 1]), (0, P.reshape)(u, [n.numBoxes, 1]), (0, P.reshape)(l, [n.numBoxes, 1]), (0, P.reshape)(c, [n.numBoxes, 1])], 1); if (n.numKeypoints) for (var d = 0; d < n.numKeypoints; ++d) { var f = n.keypointCoordOffset + d * n.numValuesPerKeypoint, p = void 0, m = void 0; n.reverseOutputOrder ? (p = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), m = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))) : (m = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), p = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))); var g = (0, P.add)((0, P.mul)((0, P.div)(p, n.xScale), t.w), t.x), y = (0, P.add)((0, P.mul)((0, P.div)(m, n.yScale), t.h), t.y); h = (0, P.concat)([h, (0, P.reshape)(g, [n.numBoxes, 1]), (0, P.reshape)(y, [n.numBoxes, 1])], 1) } return h })) }(i, t, n), o = (0, P.tidy)((function () { var e = r; return n.sigmoidScore ? (null != n.scoreClippingThresh && (e = (0, P.clipByValue)(r, -n.scoreClippingThresh, n.scoreClippingThresh)), e = (0, P.sigmoid)(e)) : e })), [4, qR(a, o, n)]; case 1: return s = u.sent(), (0, P.dispose)([a, o]), [2, s] } })) })) } function qR(e, t, n) { return DR(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p; return $R(this, (function (m) { switch (m.label) { case 0: return r = [], [4, e.data()]; case 1: return i = m.sent(), [4, t.data()]; case 2: for (a = m.sent(), o = 0; o < n.numBoxes; ++o)if (!(null != n.minScoreThresh && a[o] < n.minScoreThresh || (s = o * n.numCoords, u = YR(i[s + 0], i[s + 1], i[s + 2], i[s + 3], a[o], n.flipVertically, o), (l = u.locationData.relativeBoundingBox).width < 0 || l.height < 0))) { if (n.numKeypoints > 0) for ((c = u.locationData).relativeKeypoints = [], h = n.numKeypoints * n.numValuesPerKeypoint, d = 0; d < h; d += n.numValuesPerKeypoint)f = s + n.keypointCoordOffset + d, p = { x: i[f + 0], y: n.flipVertically ? 1 - i[f + 1] : i[f + 1] }, c.relativeKeypoints.push(p); r.push(u) } return [2, r] } })) })) } function YR(e, t, n, r, i, a, o) { return { score: [i], ind: o, locationData: { relativeBoundingBox: { xMin: t, yMin: a ? 1 - n : e, xMax: r, yMax: a ? 1 - e : n, width: r - t, height: n - e } } } } var XR, KR = { reduceBoxesInLowestLayer: !1, interpolatedScaleAspectRatio: 1, featureMapHeight: [], featureMapWidth: [], numLayers: 4, minScale: .1484375, maxScale: .75, inputSizeHeight: 128, inputSizeWidth: 128, anchorOffsetX: .5, anchorOffsetY: .5, strides: [8, 16, 16, 16], aspectRatios: [1], fixedAnchorSize: !0 }, ZR = { reduceBoxesInLowestLayer: !1, interpolatedScaleAspectRatio: 0, featureMapHeight: [], featureMapWidth: [], numLayers: 1, minScale: .1484375, maxScale: .75, inputSizeHeight: 192, inputSizeWidth: 192, anchorOffsetX: .5, anchorOffsetY: .5, strides: [4], aspectRatios: [1], fixedAnchorSize: !0 }, JR = { runtime: "tfjs", modelType: "short", maxFaces: 1, detectorModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1" }, QR = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 896, numCoords: 16, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 6, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 128, yScale: 128, hScale: 128, wScale: 128, minScoreThresh: .5 }, eO = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 2304, numCoords: 16, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 6, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 192, yScale: 192, hScale: 192, wScale: 192, minScoreThresh: .6 }, tO = { outputTensorSize: { width: 128, height: 128 }, keepAspectRatio: !0, outputTensorFloatRange: [-1, 1], borderMode: "zero" }, nO = { outputTensorSize: { width: 192, height: 192 }, keepAspectRatio: !0, outputTensorFloatRange: [-1, 1], borderMode: "zero" }, rO = function () { function e(e, t, n) { this.detectorModel = t, this.maxFaces = n, "full" === e ? (this.imageToTensorConfig = nO, this.tensorsToDetectionConfig = eO, this.anchors = UR(ZR)) : (this.imageToTensorConfig = tO, this.tensorsToDetectionConfig = QR, this.anchors = UR(KR)); var r = (0, P.tensor1d)(this.anchors.map((function (e) { return e.width }))), i = (0, P.tensor1d)(this.anchors.map((function (e) { return e.height }))), a = (0, P.tensor1d)(this.anchors.map((function (e) { return e.xCenter }))), o = (0, P.tensor1d)(this.anchors.map((function (e) { return e.yCenter }))); this.anchorTensor = { x: a, y: o, w: r, h: i } } return e.prototype.dispose = function () { this.detectorModel.dispose(), (0, P.dispose)([this.anchorTensor.x, this.anchorTensor.y, this.anchorTensor.w, this.anchorTensor.h]) }, e.prototype.reset = function () { }, e.prototype.detectFaces = function (e, t) { return void 0 === t && (t = !1), DR(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d; return $R(this, (function (f) { switch (f.label) { case 0: return null == e ? (this.reset(), [2, []]) : (n = (0, P.tidy)((function () { var n = (0, P.cast)(LR(e), "float32"); return t && (n = (0, P.squeeze)(P.image.flipLeftRight((0, P.expandDims)(n, 0)), [0])), n })), r = function (e, t, n) { var r = t.outputTensorSize, i = t.keepAspectRatio, a = t.borderMode, o = t.outputTensorFloatRange, s = BR(e), u = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(s, n), l = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; jR(t, "targetSize"), jR(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(u, r, i), c = function (e, t, n) { var r = e.width, i = e.height, a = Math.cos(e.rotation), o = Math.sin(e.rotation), s = e.xCenter, u = e.yCenter, l = 1 / t, c = 1 / n, h = new Array(16); return h[0] = r * a * 1 * l, h[1] = -i * o * l, h[2] = 0, h[3] = (-.5 * r * a * 1 + .5 * i * o + s) * l, h[4] = r * o * 1 * c, h[5] = i * a * c, h[6] = 0, h[7] = (-.5 * i * a - .5 * r * o * 1 + u) * c, h[8] = 0, h[9] = 0, h[10] = r * l, h[11] = 0, h[12] = 0, h[13] = 0, h[14] = 0, h[15] = 1, function (e) { if (16 !== e.length) throw new Error("Array length must be 16 but got " + e.length); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] }(h) }(u, s.width, s.height), h = (0, P.tidy)((function () { var t = LR(e), n = (0, P.tensor2d)(function (e, t, n) { return jR(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] }(c, s, r), [1, 8]), i = "zero" === a ? "constant" : "nearest", u = P.image.transform((0, P.expandDims)((0, P.cast)(t, "float32")), n, "bilinear", i, 0, [r.height, r.width]); return null != o ? function (e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return (0, P.tidy)((function () { return (0, P.add)((0, P.mul)(e, n.scale), n.offset) })) }(u, o) : u })); return { imageTensor: h, padding: l, transformationMatrix: c } }(n, this.imageToTensorConfig), i = r.imageTensor, a = r.transformationMatrix, o = this.detectorModel.execute(i, "Identity:0"), s = function (e) { return (0, P.tidy)((function () { var t = function (e) { return (0, P.tidy)((function () { return [(0, P.slice)(e, [0, 0, 0], [1, -1, 1]), (0, P.slice)(e, [0, 0, 1], [1, -1, -1])] })) }(e), n = t[0], r = t[1]; return { boxes: (0, P.squeeze)(r), logits: (0, P.squeeze)(n) } })) }(o), u = s.boxes, [4, HR([l = s.logits, u], this.anchorTensor, this.tensorsToDetectionConfig)]); case 1: return 0 === (c = f.sent()).length ? ((0, P.dispose)([n, i, o, l, u]), [2, c]) : [4, GR(c, this.maxFaces, .3)]; case 2: return h = f.sent(), d = function (e, t) { void 0 === e && (e = []); var n, r = (n = t, [].concat.apply([], n)); return e.forEach((function (e) { var t = e.locationData; t.relativeKeypoints.forEach((function (e) { var t = VR(r, [e.x, e.y]), n = t[0], i = t[1]; e.x = n, e.y = i })); var n = t.relativeBoundingBox, i = Number.MAX_VALUE, a = Number.MAX_VALUE, o = Number.MIN_VALUE, s = Number.MIN_VALUE;[[n.xMin, n.yMin], [n.xMin + n.width, n.yMin], [n.xMin + n.width, n.yMin + n.height], [n.xMin, n.yMin + n.height]].forEach((function (e) { var t = VR(r, e), n = t[0], u = t[1]; i = Math.min(i, n), o = Math.max(o, n), a = Math.min(a, u), s = Math.max(s, u) })), t.relativeBoundingBox = { xMin: i, xMax: o, yMin: a, yMax: s, width: o - i, height: s - a } })), e }(h, a), (0, P.dispose)([n, i, o, l, u]), [2, d] } })) })) }, e.prototype.estimateFaces = function (e, t) { return DR(this, void 0, void 0, (function () { var n, r; return $R(this, (function (i) { return n = BR(e), r = !!t && t.flipHorizontal, [2, this.detectFaces(e, r).then((function (e) { return e.map((function (e) { for (var t = e.locationData.relativeKeypoints.map((function (e, t) { return FR(FR({}, e), { x: e.x * n.width, y: e.y * n.height, name: RR[t] }) })), r = e.locationData.relativeBoundingBox, i = 0, a = ["width", "xMax", "xMin"]; i < a.length; i++)r[a[i]] *= n.width; for (var o = 0, s = ["height", "yMax", "yMin"]; o < s.length; o++)r[s[o]] *= n.height; return { keypoints: t, box: r } })) }))] })) })) }, e }(); function iO(e) { return DR(this, void 0, void 0, (function () { var t, n, r; return $R(this, (function (i) { switch (i.label) { case 0: return t = function (e) { if (null == e) return FR({}, JR); var t = FR({}, e); return null == t.modelType && (t.modelType = JR.modelType), null == t.maxFaces && (t.maxFaces = JR.maxFaces), null == t.detectorModelUrl && ("full" === t.modelType ? t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/face_detection/full/1" : t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"), t }(e), n = "string" == typeof t.detectorModelUrl && t.detectorModelUrl.indexOf("https://tfhub.dev") > -1, [4, Ud(t.detectorModelUrl, { fromTFHub: n })]; case 1: return r = i.sent(), [2, new rO(t.modelType, r, t.maxFaces)] } })) })) } function aO(e, t) { return DR(this, void 0, void 0, (function () { var n, r; return $R(this, (function (i) { if (e === XR.MediaPipeFaceDetector) { if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, iO(n)]; if ("mediapipe" === n.runtime) return [2, PR(n)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got " + r) } throw new Error(e + " is not a supported model name.") })) })) } function oO(e) { return e.width * e.height } function sO(e) { var t = e.xCenter - e.width / 2, n = t + e.width, r = e.yCenter - e.height / 2; return { xMin: t, xMax: n, yMin: r, yMax: r + e.height, width: e.width, height: e.height } } function uO(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function lO(e) { return e - 2 * Math.PI * Math.floor((e + Math.PI) / (2 * Math.PI)) } function cO(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function hO(e, t) { P.util.assert(0 !== e.width, (function () { return t + " width cannot be 0." })), P.util.assert(0 !== e.height, (function () { return t + " height cannot be 0." })) } function dO(e, t, n) { var r = t.outputTensorSize, i = t.keepAspectRatio, a = t.borderMode, o = t.outputTensorFloatRange, s = uO(e), u = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(s, n), l = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; hO(t, "targetSize"), hO(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(u, r, i), c = function (e, t, n, r) { var i = e.width, a = e.height, o = r ? -1 : 1, s = Math.cos(e.rotation), u = Math.sin(e.rotation), l = e.xCenter, c = e.yCenter, h = 1 / t, d = 1 / n, f = new Array(16); return f[0] = i * s * o * h, f[1] = -a * u * h, f[2] = 0, f[3] = (-.5 * i * s * o + .5 * a * u + l) * h, f[4] = i * u * o * d, f[5] = a * s * d, f[6] = 0, f[7] = (-.5 * a * s - .5 * i * u * o + c) * d, f[8] = 0, f[9] = 0, f[10] = i * h, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, function (e) { if (16 !== e.length) throw new Error("Array length must be 16 but got " + e.length); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] }(f) }(u, s.width, s.height, !1), h = P.tidy((function () { var t = cO(e), n = P.tensor2d(function (e, t, n) { return hO(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] }(c, s, r), [1, 8]), i = "zero" === a ? "constant" : "nearest", u = P.image.transform(P.expandDims(P.cast(t, "float32")), n, "bilinear", i, 0, [r.height, r.width]); return null != o ? function (e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return P.tidy((function () { return P.add(P.mul(e, n.scale), n.offset) })) }(u, o) : u })); return { imageTensor: h, padding: l, transformationMatrix: c } } function fO(e) { return { xCenter: e.xMin + e.width / 2, yCenter: e.yMin + e.height / 2, width: e.width, height: e.height } } function pO(e) { var t = e.relativeKeypoints; if (t.length <= 1) throw new Error("2 or more keypoints required to calculate a rect."); var n = Number.MAX_VALUE, r = Number.MAX_VALUE, i = Number.MIN_VALUE, a = Number.MIN_VALUE; return t.forEach((function (e) { n = Math.min(n, e.x), i = Math.max(i, e.x), r = Math.min(r, e.y), a = Math.max(a, e.y) })), { xCenter: (n + i) / 2, yCenter: (r + a) / 2, width: i - n, height: a - r } } function mO(e, t, n, r, i) { var a = "rect" === n ? function (e, t, n) { var r, i = e.locationData; if ("boundingbox" === t) r = fO(i.boundingBox); else { r = pO(i); var a = n.width, o = n.height; r.xCenter = Math.round(r.xCenter * a), r.yCenter = Math.round(r.yCenter * o), r.width = Math.round(r.width * a), r.height = Math.round(r.height * o) } return r }(e, t, r) : function (e, t) { var n = e.locationData; return "boundingbox" === t ? fO(n.relativeBoundingBox) : pO(n) }(e, t); return i && (a.rotation = function (e, t, n) { var r, i = e.locationData, a = n.rotationVectorStartKeypointIndex, o = n.rotationVectorEndKeypointIndex; r = n.rotationVectorTargetAngle ? n.rotationVectorTargetAngle : Math.PI * n.rotationVectorTargetAngleDegree / 180; var s = i.relativeKeypoints[a].x * t.width, u = i.relativeKeypoints[a].y * t.height, l = i.relativeKeypoints[o].x * t.width, c = i.relativeKeypoints[o].y * t.height; return lO(r - Math.atan2(-(c - u), l - s)) }(e, r, i)), a } function gO(e, t, n) { for (var r = 0; r < t.length; ++r) { var i = t[r], a = n[e[r]]; a.x = i.x, a.y = i.y } } function yO(e, t, n, r) { if ("string" == typeof t) { if ("copy" === t) for (var i = 0; i < n.length; ++i)r[e[i]].z = n[i].z } else { var a = function (e, t) { for (var n = 0, r = 0; r < t.length; ++r)n += e[t[r]].z; return n / t.length }(r, t); for (i = 0; i < e.length; ++i)r[e[i]].z = a } } function bO(e, t) { for (var n = function (e) { var t = [].concat.apply([], e.map((function (e) { return e.indexesMapping }))); if (0 === t.length) throw new Error("There should be at least one landmark in indexes mapping"); var n = t[0], r = t[0], i = new Set(t); i.forEach((function (e) { n = Math.min(n, e), r = Math.max(r, e) })); var a = i.size; if (0 !== n) throw new Error("Indexes are expected to start with 0 instead of " + n); if (r + 1 !== a) throw new Error("Indexes should have no gaps but " + (r - a + 1) + " indexes are missing"); return a }(t), r = new Array(n).fill(null).map(Object), i = 0; i < e.length; ++i) { var a = e[i], o = t[i]; if (a.length !== o.indexesMapping.length) throw new Error("There are " + a.length + " refinement landmarks while mapping has " + o.indexesMapping.length); gO(o.indexesMapping, a, r), yO(o.indexesMapping, o.zRefinement, a, r) } return r } function vO(e, t) { return e.map((function (e) { var n = bR(bR({}, e), { x: e.x * t.width, y: e.y * t.height }); return null != e.z && (n.z = e.z * t.width), n })) } function xO(e, t) { return "none" === e ? t : function (e) { return 1 / (1 + Math.exp(-e)) }(t) } function wO(e, t, n, r) { return vR(this, void 0, void 0, (function () { var i, a, o, s, u, l, c, h; return xR(this, (function (d) { switch (d.label) { case 0: return n = n || t.flipHorizontally || !1, r = r || t.flipVertically || !1, i = e.size, a = i / t.numLandmarks, [4, e.data()]; case 1: for (o = d.sent(), s = [], u = 0; u < t.numLandmarks; ++u)l = u * a, (h = { x: 0, y: 0 }).x = n ? t.inputImageWidth - o[l] : o[l], a > 1 && (h.y = r ? t.inputImageHeight - o[l + 1] : o[l + 1]), a > 2 && (h.z = o[l + 2]), a > 3 && (h.score = xO(t.visibilityActivation, o[l + 3])), s.push(h); for (c = 0; c < s.length; ++c)(h = s[c]).x = h.x / t.inputImageWidth, h.y = h.y / t.inputImageHeight, h.z = h.z / t.inputImageWidth / (t.normalizeZ || 1); return [2, s] } })) })) } function kO(e, t, n) { var r = e.width, i = e.height, a = e.rotation; if (null == n.rotation && null == n.rotationDegree || (a = function (e, t) { return null != t.rotation ? e += t.rotation : null != t.rotationDegree && (e += Math.PI * t.rotationDegree / 180), lO(e) }(a, n)), 0 === a) e.xCenter = e.xCenter + r * n.shiftX, e.yCenter = e.yCenter + i * n.shiftY; else { var o = (t.width * r * n.shiftX * Math.cos(a) - t.height * i * n.shiftY * Math.sin(a)) / t.width, s = (t.width * r * n.shiftX * Math.sin(a) + t.height * i * n.shiftY * Math.cos(a)) / t.height; e.xCenter = e.xCenter + o, e.yCenter = e.yCenter + s } if (n.squareLong) { var u = Math.max(r * t.width, i * t.height); r = u / t.width, i = u / t.height } else if (n.squareShort) { var l = Math.min(r * t.width, i * t.height); r = l / t.width, i = l / t.height } return e.width = r * n.scaleX, e.height = i * n.scaleY, e } (XR || (XR = {})).MediaPipeFaceDetector = "MediaPipeFaceDetector"; var SO, _O = { runtime: "tfjs", maxFaces: 1, refineLandmarks: !1, landmarkModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1" }, CO = { flipHorizontal: !1, staticImageMode: !1 }, AO = { shiftX: 0, shiftY: 0, scaleX: 1.5, scaleY: 1.5, squareLong: !0 }, TO = { outputTensorSize: { width: 192, height: 192 }, outputTensorFloatRange: [0, 1], borderMode: "replicate" }, EO = { numLandmarks: 468, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, NO = { numLandmarks: 80, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, IO = { numLandmarks: 71, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, MO = { numLandmarks: 5, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, FO = { indexesMapping: Array.from(Array(468).keys()), zRefinement: "copy" }, DO = { indexesMapping: [61, 146, 91, 181, 84, 17, 314, 405, 321, 375, 291, 185, 40, 39, 37, 0, 267, 269, 270, 409, 78, 95, 88, 178, 87, 14, 317, 402, 318, 324, 308, 191, 80, 81, 82, 13, 312, 311, 310, 415, 76, 77, 90, 180, 85, 16, 315, 404, 320, 307, 306, 184, 74, 73, 72, 11, 302, 303, 304, 408, 62, 96, 89, 179, 86, 15, 316, 403, 319, 325, 292, 183, 42, 41, 38, 12, 268, 271, 272, 407], zRefinement: "none" }, $O = { indexesMapping: [33, 7, 163, 144, 145, 153, 154, 155, 133, 246, 161, 160, 159, 158, 157, 173, 130, 25, 110, 24, 23, 22, 26, 112, 243, 247, 30, 29, 27, 28, 56, 190, 226, 31, 228, 229, 230, 231, 232, 233, 244, 113, 225, 224, 223, 222, 221, 189, 35, 124, 46, 53, 52, 65, 143, 111, 117, 118, 119, 120, 121, 128, 245, 156, 70, 63, 105, 66, 107, 55, 193], zRefinement: "none" }, RO = { indexesMapping: [263, 249, 390, 373, 374, 380, 381, 382, 362, 466, 388, 387, 386, 385, 384, 398, 359, 255, 339, 254, 253, 252, 256, 341, 463, 467, 260, 259, 257, 258, 286, 414, 446, 261, 448, 449, 450, 451, 452, 453, 464, 342, 445, 444, 443, 442, 441, 413, 265, 353, 276, 283, 282, 295, 372, 340, 346, 347, 348, 349, 350, 357, 465, 383, 300, 293, 334, 296, 336, 285, 417], zRefinement: "none" }, OO = { indexesMapping: [468, 469, 470, 471, 472], zRefinement: [33, 7, 163, 144, 145, 153, 154, 155, 133, 246, 161, 160, 159, 158, 157, 173] }, zO = { indexesMapping: [473, 474, 475, 476, 477], zRefinement: [263, 249, 390, 373, 374, 380, 381, 382, 362, 466, 388, 387, 386, 385, 384, 398] }, PO = function () { function e(e, t, n, r) { this.detector = e, this.landmarkModel = t, this.maxFaces = n, this.withAttention = r, this.prevFaceRectsFromLandmarks = null } return e.prototype.estimateFaces = function (e, t) { return vR(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m = this; return xR(this, (function (g) { switch (g.label) { case 0: return n = function (e) { if (null == e) return bR({}, CO); var t = bR({}, e); return null == t.flipHorizontal && (t.flipHorizontal = CO.flipHorizontal), null == t.staticImageMode && (t.staticImageMode = CO.staticImageMode), t }(t), null == e ? (this.reset(), [2, []]) : (r = uO(e), i = P.tidy((function () { var t = P.cast(cO(e), "float32"); return n.flipHorizontal && (t = P.squeeze(P.image.flipLeftRight(P.expandDims(t, 0)), [0])), t })), a = this.prevFaceRectsFromLandmarks, n.staticImageMode || null == a || a.length < this.maxFaces ? [4, this.detector.detectFaces(i, !1)] : [3, 2]); case 1: return 0 === (s = g.sent()).length ? (this.reset(), i.dispose(), [2, []]) : (o = s.map((function (e) { return m.faceDetectionFrontDetectionToRoi(e, r) })), [3, 3]); case 2: o = [], g.label = 3; case 3: return y = [], [o, a || []].forEach((function (e) { return e.forEach((function (e) { (y = y.filter((function (t) { return function (e, t) { var n = sO(e), r = sO(t); if (!function (e, t) { return !(e.xMax < t.xMin || t.xMax < e.xMin || e.yMax < t.yMin || t.yMax < e.yMin) }(n, r)) return 0; var i = oO(function (e, t) { var n = Math.max(e.xMin, t.xMin), r = Math.min(e.xMax, t.xMax), i = Math.max(e.yMin, t.yMin), a = Math.min(e.yMax, t.yMax); return { xMin: n, xMax: r, yMin: i, yMax: a, width: Math.max(r - n, 0), height: Math.max(a - i, 0) } }(n, r)), a = oO(n) + oO(r) - i; return a > 0 ? i / a : 0 }(e, t) <= .5 }))).push(e) })) })), u = y, [4, Promise.all(u.map((function (e) { return m.faceLandmark(e, i) })))]; case 4: for (l = g.sent(), c = [], this.prevFaceRectsFromLandmarks = [], h = 0; h < l.length; ++h)null != (d = l[h]) && (this.prevFaceRectsFromLandmarks.push(this.faceLandmarksToRoi(d, r)), null != (f = vO(d, r)) && f.forEach((function (e, t) { var n = CR.get(t); null != n && (e.name = n) })), p = AR(f), c.push({ keypoints: f, box: p.locationData.relativeBoundingBox })); return i.dispose(), [2, c] }var y })) })) }, e.prototype.dispose = function () { this.detector.dispose(), this.landmarkModel.dispose() }, e.prototype.reset = function () { this.detector.reset(), this.prevFaceRectsFromLandmarks = null }, e.prototype.faceDetectionFrontDetectionToRoi = function (e, t) { return kO(mO(e, "boundingbox", "normRect", t, { rotationVectorStartKeypointIndex: 0, rotationVectorEndKeypointIndex: 1, rotationVectorTargetAngleDegree: 0 }), t, AO) }, e.prototype.faceLandmark = function (e, t) { return vR(this, void 0, void 0, (function () { var n, r, i, a, o, s, u; return xR(this, (function (l) { switch (l.label) { case 0: return n = dO(t, TO, e).imageTensor, r = ["output_faceflag"].concat(this.withAttention ? ["output_mesh_identity", "output_lips", "Identity_6:0", "Identity_1:0", "Identity_2:0", "Identity_5:0"] : ["output_mesh"]), i = this.landmarkModel.execute(n, r), a = i[0], o = i.slice(1), [4, a.data()]; case 1: return l.sent()[0] < .5 ? (P.dispose(i), P.dispose(n), [2, null]) : this.withAttention ? [4, this.tensorsToFaceLandmarksWithAttention(o)] : [3, 3]; case 2: return s = l.sent(), [3, 5]; case 3: return [4, this.tensorsToFaceLandmarks(o)]; case 4: s = l.sent(), l.label = 5; case 5: return u = function (e, t, n) { void 0 === n && (n = { ignoreRotation: !1 }); for (var r = [], i = 0, a = e; i < a.length; i++) { var o = a[i], s = o.x - .5, u = o.y - .5, l = n.ignoreRotation ? 0 : t.rotation, c = Math.cos(l) * s - Math.sin(l) * u, h = Math.sin(l) * s + Math.cos(l) * u; c = c * t.width + t.xCenter, h = h * t.height + t.yCenter; var d = o.z * t.width, f = bR({}, o); f.x = c, f.y = h, f.z = d, r.push(f) } return r }(s, e), P.dispose(i), P.dispose(n), [2, u] } })) })) }, e.prototype.tensorsToFaceLandmarks = function (e) { return vR(this, void 0, void 0, (function () { return xR(this, (function (t) { return [2, wO(e[0], EO)] })) })) }, e.prototype.tensorsToFaceLandmarksWithAttention = function (e) { return vR(this, void 0, void 0, (function () { var t, n, r, i, a, o; return xR(this, (function (s) { switch (s.label) { case 0: return [4, wO(e[0], EO)]; case 1: return t = s.sent(), [4, wO(e[1], NO)]; case 2: return n = s.sent(), [4, wO(e[3], IO)]; case 3: return r = s.sent(), [4, wO(e[5], IO)]; case 4: return i = s.sent(), [4, wO(e[4], MO)]; case 5: return a = s.sent(), [4, wO(e[2], MO)]; case 6: return o = s.sent(), [2, bO([t, n, r, i, a, o], [FO, DO, $O, RO, OO, zO])] } })) })) }, e.prototype.faceLandmarksToRoi = function (e, t) { return kO(mO(AR(e), "boundingbox", "normRect", t, { rotationVectorStartKeypointIndex: 33, rotationVectorEndKeypointIndex: 263, rotationVectorTargetAngleDegree: 0 }), t, AO) }, e }(); function BO(e) { return vR(this, void 0, void 0, (function () { var t, n, r, i; return xR(this, (function (a) { switch (a.label) { case 0: return t = function (e) { if (null == e) return bR({}, _O); var t = bR({}, e); return t.runtime = "tfjs", null == t.maxFaces && (t.maxFaces = _O.maxFaces), null == t.refineLandmarks && (t.refineLandmarks = _O.refineLandmarks), null == t.landmarkModelUrl && (t.landmarkModelUrl = t.refineLandmarks ? "https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1" : "https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1"), t }(e), n = "string" == typeof t.landmarkModelUrl && t.landmarkModelUrl.indexOf("https://tfhub.dev") > -1, [4, Ud(t.landmarkModelUrl, { fromTFHub: n })]; case 1: return r = a.sent(), [4, aO(XR.MediaPipeFaceDetector, { modelType: "short", maxFaces: t.maxFaces, detectorModelUrl: t.detectorModelUrl, runtime: t.runtime })]; case 2: return i = a.sent(), [2, new PO(i, r, t.maxFaces, t.refineLandmarks)] } })) })) } !function (e) { e.MediaPipeFaceMesh = "MediaPipeFaceMesh" }(SO || (SO = {})); var LO = Object.freeze({ __proto__: null, getKeypointIndexByContour: function (e) { if (e === SO.MediaPipeFaceMesh) return kR; throw new Error("Model " + e + " is not supported.") }, getAdjacentPairs: function (e) { if (e === SO.MediaPipeFaceMesh) return SR; throw new Error("Model " + e + " is not supported.") } }); + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const jO = [[.499976992607117, .652534008026123], [.500025987625122, .547487020492554], [.499974012374878, .602371990680695], [.482113003730774, .471979022026062], [.500150978565216, .527155995368958], [.499909996986389, .498252987861633], [.499523013830185, .40106201171875], [.289712011814117, .380764007568359], [.499954998493195, .312398016452789], [.499987006187439, .269918978214264], [.500023007392883, .107050001621246], [.500023007392883, .666234016418457], [.5000159740448, .679224014282227], [.500023007392883, .692348003387451], [.499976992607117, .695277988910675], [.499976992607117, .70593398809433], [.499976992607117, .719385027885437], [.499976992607117, .737019002437592], [.499967992305756, .781370997428894], [.499816000461578, .562981009483337], [.473773002624512, .573909997940063], [.104906998574734, .254140973091125], [.365929991006851, .409575998783112], [.338757991790771, .41302502155304], [.311120003461838, .409460008144379], [.274657994508743, .389131009578705], [.393361985683441, .403706014156342], [.345234006643295, .344011008739471], [.370094001293182, .346076011657715], [.319321990013123, .347265005111694], [.297903001308441, .353591024875641], [.24779200553894, .410809993743896], [.396889001131058, .842755019664764], [.280097991228104, .375599980354309], [.106310002505779, .399955987930298], [.2099249958992, .391353011131287], [.355807989835739, .534406006336212], [.471751004457474, .65040397644043], [.474155008792877, .680191993713379], [.439785003662109, .657229006290436], [.414617002010345, .66654098033905], [.450374007225037, .680860996246338], [.428770989179611, .682690978050232], [.374971002340317, .727805018424988], [.486716985702515, .547628998756409], [.485300987958908, .527395009994507], [.257764995098114, .314490020275116], [.401223003864288, .455172002315521], [.429818987846375, .548614978790283], [.421351999044418, .533740997314453], [.276895999908447, .532056987285614], [.483370006084442, .499586999416351], [.33721199631691, .282882988452911], [.296391993761063, .293242990970612], [.169294998049736, .193813979625702], [.447580009698868, .302609980106354], [.392390012741089, .353887975215912], [.354490011930466, .696784019470215], [.067304998636246, .730105042457581], [.442739009857178, .572826027870178], [.457098007202148, .584792017936707], [.381974011659622, .694710969924927], [.392388999462128, .694203019142151], [.277076005935669, .271932005882263], [.422551989555359, .563233017921448], [.385919004678726, .281364023685455], [.383103013038635, .255840003490448], [.331431001424789, .119714021682739], [.229923993349075, .232002973556519], [.364500999450684, .189113974571228], [.229622006416321, .299540996551514], [.173287004232407, .278747975826263], [.472878992557526, .666198015213013], [.446828007698059, .668527007102966], [.422762006521225, .673889994621277], [.445307999849319, .580065965652466], [.388103008270264, .693961024284363], [.403039008378983, .706539988517761], [.403629004955292, .693953037261963], [.460041999816895, .557139039039612], [.431158006191254, .692366003990173], [.452181994915009, .692366003990173], [.475387006998062, .692366003990173], [.465828001499176, .779190003871918], [.472328990697861, .736225962638855], [.473087012767792, .717857003211975], [.473122000694275, .704625964164734], [.473033010959625, .695277988910675], [.427942007780075, .695277988910675], [.426479011774063, .703539967536926], [.423162013292313, .711845993995667], [.4183090031147, .720062971115112], [.390094995498657, .639572978019714], [.013953999616206, .560034036636353], [.499913990497589, .58014702796936], [.413199990987778, .69539999961853], [.409626007080078, .701822996139526], [.468080013990402, .601534962654114], [.422728985548019, .585985004901886], [.463079988956451, .593783974647522], [.37211999297142, .47341400384903], [.334562003612518, .496073007583618], [.411671012639999, .546965003013611], [.242175996303558, .14767599105835], [.290776997804642, .201445996761322], [.327338010072708, .256527006626129], [.399509996175766, .748921036720276], [.441727995872498, .261676013469696], [.429764986038208, .187834024429321], [.412198007106781, .108901023864746], [.288955003023148, .398952007293701], [.218936994671822, .435410976409912], [.41278201341629, .398970007896423], [.257135003805161, .355440020561218], [.427684992551804, .437960982322693], [.448339998722076, .536936044692993], [.178560003638268, .45755398273468], [.247308000922203, .457193970680237], [.286267012357712, .467674970626831], [.332827985286713, .460712015628815], [.368755996227264, .447206974029541], [.398963987827301, .432654976844788], [.476410001516342, .405806005001068], [.189241006970406, .523923993110657], [.228962004184723, .348950982093811], [.490725994110107, .562400996685028], [.404670000076294, .485132992267609], [.019469000399113, .401564002037048], [.426243007183075, .420431017875671], [.396993011236191, .548797011375427], [.266469985246658, .376977026462555], [.439121007919312, .51895797252655], [.032313998788595, .644356966018677], [.419054001569748, .387154996395111], [.462783008813858, .505746960639954], [.238978996872902, .779744982719421], [.198220998048782, .831938028335571], [.107550002634525, .540755033493042], [.183610007166862, .740257024765015], [.134409993886948, .333683013916016], [.385764002799988, .883153975009918], [.490967005491257, .579378008842468], [.382384985685349, .508572995662689], [.174399003386497, .397670984268188], [.318785011768341, .39623498916626], [.343364000320435, .400596976280212], [.396100014448166, .710216999053955], [.187885001301765, .588537991046906], [.430987000465393, .944064974784851], [.318993002176285, .898285031318665], [.266247987747192, .869701027870178], [.500023007392883, .190576016902924], [.499976992607117, .954452991485596], [.366169989109039, .398822009563446], [.393207013607025, .39553701877594], [.410373002290726, .391080021858215], [.194993004202843, .342101991176605], [.388664990663528, .362284004688263], [.365961998701096, .355970978736877], [.343364000320435, .355356991291046], [.318785011768341, .35834002494812], [.301414996385574, .363156020641327], [.058132998645306, .319076001644135], [.301414996385574, .387449026107788], [.499987989664078, .618434011936188], [.415838003158569, .624195992946625], [.445681989192963, .566076993942261], [.465844005346298, .620640993118286], [.49992299079895, .351523995399475], [.288718998432159, .819945991039276], [.335278987884521, .852819979190826], [.440512001514435, .902418971061707], [.128294005990028, .791940987110138], [.408771991729736, .373893976211548], [.455606997013092, .451801002025604], [.499877005815506, .908990025520325], [.375436991453171, .924192011356354], [.11421000212431, .615022003650665], [.448662012815475, .695277988910675], [.4480200111866, .704632043838501], [.447111994028091, .715808033943176], [.444831997156143, .730794012546539], [.430011987686157, .766808986663818], [.406787008047104, .685672998428345], [.400738000869751, .681069016456604], [.392399996519089, .677703022956848], [.367855995893478, .663918972015381], [.247923001646996, .601333022117615], [.452769994735718, .420849978923798], [.43639200925827, .359887003898621], [.416164010763168, .368713974952698], [.413385987281799, .692366003990173], [.228018000721931, .683571994304657], [.468268007040024, .352671027183533], [.411361992359161, .804327011108398], [.499989002943039, .469825029373169], [.479153990745544, .442654013633728], [.499974012374878, .439637005329132], [.432112008333206, .493588984012604], [.499886006116867, .866917014122009], [.49991300702095, .821729004383087], [.456548988819122, .819200992584229], [.344549000263214, .745438992977142], [.37890899181366, .574010014533997], [.374292999505997, .780184984207153], [.319687992334366, .570737957954407], [.357154995203018, .604269981384277], [.295284003019333, .621580958366394], [.447750002145767, .862477004528046], [.410986006259918, .508723020553589], [.31395098567009, .775308012962341], [.354128003120422, .812552988529205], [.324548006057739, .703992962837219], [.189096003770828, .646299958229065], [.279776990413666, .71465802192688], [.1338230073452, .682700991630554], [.336768001317978, .644733011722565], [.429883986711502, .466521978378296], [.455527991056442, .548622965812683], [.437114000320435, .558896005153656], [.467287987470627, .529924988746643], [.414712011814117, .335219979286194], [.37704598903656, .322777986526489], [.344107985496521, .320150971412659], [.312875986099243, .32233202457428], [.283526003360748, .333190023899078], [.241245999932289, .382785975933075], [.102986000478268, .468762993812561], [.267612010240555, .424560010433197], [.297879010438919, .433175981044769], [.333433985710144, .433878004550934], [.366427004337311, .426115989685059], [.396012008190155, .416696012020111], [.420121014118195, .41022801399231], [.007561000064015, .480777025222778], [.432949006557465, .569517970085144], [.458638995885849, .479089021682739], [.473466008901596, .545744001865387], [.476087987422943, .563830018043518], [.468472003936768, .555056989192963], [.433990985155106, .582361996173859], [.483518004417419, .562983989715576], [.482482999563217, .57784903049469], [.42645001411438, .389798998832703], [.438998997211456, .39649498462677], [.450067013502121, .400434017181396], [.289712011814117, .368252992630005], [.276670008897781, .363372981548309], [.517862021923065, .471948027610779], [.710287988185883, .380764007568359], [.526226997375488, .573909997940063], [.895093023777008, .254140973091125], [.634069979190826, .409575998783112], [.661242008209229, .41302502155304], [.688880026340485, .409460008144379], [.725341975688934, .389131009578705], [.606630027294159, .40370500087738], [.654766023159027, .344011008739471], [.629905998706818, .346076011657715], [.680678009986877, .347265005111694], [.702096998691559, .353591024875641], [.75221198797226, .410804986953735], [.602918028831482, .842862963676453], [.719901978969574, .375599980354309], [.893692970275879, .399959981441498], [.790081977844238, .391354024410248], [.643998026847839, .534487962722778], [.528249025344849, .65040397644043], [.525849997997284, .680191040039062], [.560214996337891, .657229006290436], [.585384011268616, .66654098033905], [.549625992774963, .680860996246338], [.57122802734375, .682691991329193], [.624852001667023, .72809898853302], [.513050019741058, .547281980514526], [.51509702205658, .527251958847046], [.742246985435486, .314507007598877], [.598631024360657, .454979002475739], [.570338010787964, .548575043678284], [.578631997108459, .533622980117798], [.723087012767792, .532054007053375], [.516445994377136, .499638974666595], [.662801027297974, .282917976379395], [.70362401008606, .293271005153656], [.830704987049103, .193813979625702], [.552385985851288, .302568018436432], [.607609987258911, .353887975215912], [.645429015159607, .696707010269165], [.932694971561432, .730105042457581], [.557260990142822, .572826027870178], [.542901992797852, .584792017936707], [.6180260181427, .694710969924927], [.607590973377228, .694203019142151], [.722943007946014, .271963000297546], [.577413976192474, .563166975975037], [.614082992076874, .281386971473694], [.616907000541687, .255886018276215], [.668509006500244, .119913995265961], [.770092010498047, .232020974159241], [.635536015033722, .189248979091644], [.77039098739624, .299556016921997], [.826722025871277, .278755009174347], [.527121007442474, .666198015213013], [.553171992301941, .668527007102966], [.577238023281097, .673889994621277], [.554691970348358, .580065965652466], [.611896991729736, .693961024284363], [.59696102142334, .706539988517761], [.596370995044708, .693953037261963], [.539958000183105, .557139039039612], [.568841993808746, .692366003990173], [.547818005084991, .692366003990173], [.52461302280426, .692366003990173], [.534089982509613, .779141008853912], [.527670979499817, .736225962638855], [.526912987232208, .717857003211975], [.526877999305725, .704625964164734], [.526966989040375, .695277988910675], [.572058022022247, .695277988910675], [.573521018028259, .703539967536926], [.57683801651001, .711845993995667], [.581691026687622, .720062971115112], [.609944999217987, .639909982681274], [.986046016216278, .560034036636353], [.5867999792099, .69539999961853], [.590372025966644, .701822996139526], [.531915009021759, .601536989212036], [.577268004417419, .585934996604919], [.536915004253387, .593786001205444], [.627542972564697, .473352015018463], [.665585994720459, .495950996875763], [.588353991508484, .546862006187439], [.757824003696442, .14767599105835], [.709249973297119, .201507985591888], [.672684013843536, .256581008434296], [.600408971309662, .74900496006012], [.55826598405838, .261672019958496], [.570303976535797, .187870979309082], [.588165998458862, .109044015407562], [.711045026779175, .398952007293701], [.781069993972778, .435405015945435], [.587247014045715, .398931980133057], [.742869973182678, .355445981025696], [.572156012058258, .437651991844177], [.55186802148819, .536570012569427], [.821442008018494, .457556009292603], [.752701997756958, .457181990146637], [.71375697851181, .467626988887787], [.66711300611496, .460672974586487], [.631101012229919, .447153985500336], [.6008620262146, .432473003864288], [.523481011390686, .405627012252808], [.810747981071472, .523926019668579], [.771045982837677, .348959028720856], [.509127020835876, .562718033790588], [.595292985439301, .485023975372314], [.980530977249146, .401564002037048], [.573499977588654, .420000016689301], [.602994978427887, .548687994480133], [.733529984951019, .376977026462555], [.560611009597778, .519016981124878], [.967685997486115, .644356966018677], [.580985009670258, .387160003185272], [.537728011608124, .505385041236877], [.760966002941132, .779752969741821], [.801778972148895, .831938028335571], [.892440974712372, .54076099395752], [.816350996494293, .740260004997253], [.865594983100891, .333687007427216], [.614073991775513, .883246004581451], [.508952975273132, .579437971115112], [.617941975593567, .508316040039062], [.825608015060425, .397674977779388], [.681214988231659, .39623498916626], [.656635999679565, .400596976280212], [.603900015354156, .710216999053955], [.81208598613739, .588539004325867], [.56801301240921, .944564998149872], [.681007981300354, .898285031318665], [.733752012252808, .869701027870178], [.633830010890961, .398822009563446], [.606792986392975, .39553701877594], [.589659988880157, .391062021255493], [.805015981197357, .342108011245728], [.611334979534149, .362284004688263], [.634037971496582, .355970978736877], [.656635999679565, .355356991291046], [.681214988231659, .35834002494812], [.698584973812103, .363156020641327], [.941866993904114, .319076001644135], [.698584973812103, .387449026107788], [.584177017211914, .624107003211975], [.554318010807037, .566076993942261], [.534153997898102, .62064003944397], [.711217999458313, .819975018501282], [.664629995822906, .852871000766754], [.559099972248077, .902631998062134], [.871706008911133, .791940987110138], [.591234028339386, .373893976211548], [.544341027736664, .451583981513977], [.624562978744507, .924192011356354], [.88577002286911, .615028977394104], [.551338016986847, .695277988910675], [.551980018615723, .704632043838501], [.552887976169586, .715808033943176], [.555167973041534, .730794012546539], [.569944024085999, .767035007476807], [.593203008174896, .685675978660583], [.599261999130249, .681069016456604], [.607599973678589, .677703022956848], [.631937980651855, .663500010967255], [.752032995223999, .601315021514893], [.547226011753082, .420395016670227], [.563543975353241, .359827995300293], [.583841025829315, .368713974952698], [.586614012718201, .692366003990173], [.771915018558502, .683578014373779], [.531597018241882, .352482974529266], [.588370978832245, .804440975189209], [.52079701423645, .442565023899078], [.567984998226166, .493479013442993], [.543282985687256, .819254994392395], [.655317008495331, .745514988899231], [.621008992195129, .574018001556396], [.625559985637665, .78031200170517], [.680198013782501, .570719003677368], [.64276397228241, .604337990283966], [.704662978649139, .621529996395111], [.552012026309967, .862591981887817], [.589071989059448, .508637011051178], [.685944974422455, .775357007980347], [.645735025405884, .812640011310577], [.675342977046967, .703978002071381], [.810858011245728, .646304965019226], [.72012197971344, .714666962623596], [.866151988506317, .682704985141754], [.663187026977539, .644596993923187], [.570082008838654, .466325998306274], [.544561982154846, .548375964164734], [.562758982181549, .558784961700439], [.531987011432648, .530140042304993], [.585271000862122, .335177004337311], [.622952997684479, .32277899980545], [.655896008014679, .320163011550903], [.687132000923157, .322345972061157], [.716481983661652, .333200991153717], [.758756995201111, .382786989212036], [.897013008594513, .468769013881683], [.732392013072968, .424547016620636], [.70211398601532, .433162987232208], [.66652500629425, .433866024017334], [.633504986763, .426087975502014], [.603875994682312, .416586995124817], [.579657971858978, .409945011138916], [.992439985275269, .480777025222778], [.567192018032074, .569419980049133], [.54136598110199, .478899002075195], [.526564002037048, .546118021011353], [.523913025856018, .563830018043518], [.531529009342194, .555056989192963], [.566035985946655, .582329034805298], [.51631098985672, .563053965568542], [.5174720287323, .577877044677734], [.573594987392426, .389806985855103], [.560697972774506, .395331978797913], [.549755990505219, .399751007556915], [.710287988185883, .368252992630005], [.723330020904541, .363372981548309]], UO = { runtime: { type: "enum", enums: ["mediapipe", "tfjs"], default: "tfjs" }, maxFaces: { type: "number", min: 1, default: 1 }, refineLandmarks: { type: "boolean", default: !1 }, solutionPath: { type: "string", default: "https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh", ignore: e => "mediapipe" !== e.runtime }, detectorModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime }, landmarkModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime } }, WO = { flipHorizontal: { type: "boolean", alias: "flipped", default: !1 } }; class VO { constructor(e, t, n) { this.modelName = uR(e, ["FaceMesh"], "FaceMesh", "faceMesh"), this.model = null, this.userOptions = t, this.runtimeConfig = {}, this.detectMedia = null, this.detectCallback = null, this.detecting = !1, this.signalStop = !1, this.prevCall = "", this.ready = hM(this.loadModel(), n) } async loadModel() { const e = SO.MediaPipeFaceMesh, t = lR(this.userOptions, UO, "faceMesh"); return this.runtimeConfig = lR(this.userOptions, WO, "faceMesh"), await P.ready(), this.model = await function (e, t) { return vR(this, void 0, void 0, (function () { var n, r; return xR(this, (function (i) { if (e === SO.MediaPipeFaceMesh) { if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, BO(n)]; if ("mediapipe" === n.runtime) return [2, NR(n)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got " + r) } throw new Error(e + " is not a supported model name.") })) })) }(e, t), this } async detect(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detect()."); const { image: n, callback: r } = t; await AM(n, !1); let i = await this.model.estimateFaces(n, this.runtimeConfig); return i = this.addKeypoints(i), "function" == typeof r && r(i), i } detectStart(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detectStart()."), t.require("callback", "A callback function argument is required for detectStart()."), this.detectMedia = t.image, this.detectCallback = t.callback, this.signalStop = !1, this.detecting || (this.detecting = !0, this.detectLoop()), "start" === this.prevCall && console.warn("detectStart() was called more than once without calling detectStop(). The lastest detectStart() call will be used and the previous calls will be ignored."), this.prevCall = "start" } detectStop() { this.detecting && (this.signalStop = !0), this.prevCall = "stop" } async detectLoop() { for (await AM(this.detectMedia, !1); !this.signalStop;) { let e = await this.model.estimateFaces(this.detectMedia, this.runtimeConfig); e = this.addKeypoints(e), this.detectCallback(e), await P.nextFrame() } this.detecting = !1, this.signalStop = !1 } addKeypoints(e) { const t = LO.getKeypointIndexByContour(SO.MediaPipeFaceMesh); 291 !== t.lips[20] && t.lips.splice(20, 0, 291); for (let n of e) { n.keypoints[291].name = "lips"; for (let e in t) { for (let r of t[e]) { if (r >= n.keypoints.length) continue; void 0 === n[e] && (n[e] = { keypoints: [] }); let t = n.keypoints[r]; n[e].keypoints.push({ x: t.x, y: t.y, z: t.z }), n[e].xMin = void 0 === n[e].xMin || t.x < n[e].xMin ? t.x : n[e].xMin, n[e].xMax = void 0 === n[e].xMax || t.x > n[e].xMax ? t.x : n[e].xMax, n[e].yMin = void 0 === n[e].yMin || t.y < n[e].yMin ? t.y : n[e].yMin, n[e].yMax = void 0 === n[e].yMax || t.y > n[e].yMax ? t.y : n[e].yMax } n[e] && (n[e].x = n[e].xMin, n[e].y = n[e].yMin, n[e].width = n[e].xMax - n[e].xMin, n[e].height = n[e].yMax - n[e].yMin, n[e].centerX = n[e].x + n[e].width / 2, n[e].centerY = n[e].y + n[e].height / 2, delete n[e].xMin, delete n[e].xMax, delete n[e].yMin, delete n[e].yMax) } } return e } getTriangles() { const e = LO.getAdjacentPairs(SO.MediaPipeFaceMesh), t = []; for (let n = 0; n < e.length; n += 3) { const r = [e[n][0], e[n + 1][0], e[n + 2][0]]; t.push(r) } return t } getConnections() { return LO.getAdjacentPairs(SO.MediaPipeFaceMesh) } getUVCoords() { return jO } } const GO = (...e) => { const { string: t, options: n = {}, callback: r } = xM(...e); return new VO(t, n, r) }; var HO = n(3242); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const qO = (0, P.env)(); qO.registerFlag("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE", (() => 15)), qO.registerFlag("WEBGPU_CPU_FORWARD", (() => !0)), qO.registerFlag("WEBGPU_MATMUL_PROGRAM_TYPE", (() => -1)), qO.registerFlag("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE", (() => !0)), qO.registerFlag("WEBGPU_USE_LOW_POWER_GPU", (() => !1)), qO.registerFlag("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD", (() => 1e3)), qO.registerFlag("WEBGPU_USE_PROFILE_TOOL", (() => !1)), qO.registerFlag("WEBGPU_IMPORT_EXTERNAL_TEXTURE", (() => !0)), qO.registerFlag("WEBGPU_USE_NAIVE_CONV2D_DEBUG", (() => !1)), qO.registerFlag("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL", (() => -1)), qO.registerFlag("WEBGPU_CONV_SEPARATE_IM2COL_SHADER", (() => !1)), qO.registerFlag("WEBGPU_PRINT_SHADER", (() => "")), qO.registerFlag("WEBGPU_ENGINE_COMPILE_ONLY", (() => !1)); + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class YO { constructor(e) { e && (this.vendor = e.vendor, this.architecture = e.architecture, this.intelGPUGeneration = this.getIntelGPUGeneration()) } getIntelGPUGeneration() { if (this.isIntel()) { if (this.architecture.startsWith("gen")) return Number(this.architecture.match(/\d+/)); if (this.architecture.startsWith("xe")) return 12 } return 0 } isIntel() { return "intel" === this.vendor } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class XO { constructor(e) { this.device = e, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.freeBuffers = new Map, this.usedBuffers = new Map, this.numBytesUsed = 0, this.numBytesAllocated = 0 } acquireBuffer(e, t, n = !1, r = !0) { let i; const a = KO(e, t); return r ? (this.freeBuffers.has(a) || this.freeBuffers.set(a, []), this.freeBuffers.get(a).length > 0 ? (i = this.freeBuffers.get(a).pop(), this.numFreeBuffers--) : (i = this.device.createBuffer({ size: e, usage: t, mappedAtCreation: n }), this.numBytesAllocated += e)) : (i = this.device.createBuffer({ size: e, usage: t, mappedAtCreation: n }), this.numBytesAllocated += e), this.usedBuffers.has(a) || this.usedBuffers.set(a, []), this.usedBuffers.get(a).push(i), this.numUsedBuffers++, this.numBytesUsed += e, i } releaseBuffer(e, t = !0) { if (0 === this.freeBuffers.size) return; const n = e.size, r = KO(n, e.usage), i = this.usedBuffers.get(r), a = i.indexOf(e); if (a < 0) throw new Error("Cannot find the buffer in buffer manager"); i[a] = i[i.length - 1], i.pop(), this.numUsedBuffers--, this.numBytesUsed -= n, t ? (this.freeBuffers.get(r).push(e), this.numFreeBuffers++) : (e.destroy(), this.numBytesAllocated -= n) } getNumUsedBuffers() { return this.numUsedBuffers } getNumFreeBuffers() { return this.numFreeBuffers } dispose() { this.freeBuffers.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.usedBuffers.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.freeBuffers = new Map, this.usedBuffers = new Map, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0 } } function KO(e, t) { return `${e}_${t}` } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ZO { constructor(e) { this.device = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this.freeTextures = new Map, this.usedTextures = new Map, this.numBytesUsed = 0, this.numBytesAllocated = 0 } acquireTexture(e, t, n, r) { const i = e * t * QO(n), a = JO(e, t, n, r); if (this.freeTextures.has(a) || this.freeTextures.set(a, []), this.usedTextures.has(a) || this.usedTextures.set(a, []), this.numBytesUsed += i, this.numUsedTextures++, this.freeTextures.get(a).length > 0) { this.numFreeTextures--; const e = this.freeTextures.get(a).shift(); return this.usedTextures.get(a).push(e), e } this.numBytesAllocated += i; const o = this.device.createTexture({ size: [e, t], format: n, usage: r }); return this.usedTextures.get(a).push(o), o } releaseTexture(e) { if (0 === this.freeTextures.size) return; const t = e.width, n = e.height, r = e.format, i = JO(t, n, r, e.usage); this.freeTextures.has(i) || this.freeTextures.set(i, []), this.freeTextures.get(i).push(e), this.numFreeTextures++, this.numUsedTextures--; const a = this.usedTextures.get(i), o = a.indexOf(e); if (o < 0) throw new Error("Cannot release a texture that was never provided by this texture manager"); a.splice(o, 1); const s = t * n * QO(r); this.numBytesUsed -= s } getNumUsedTextures() { return this.numUsedTextures } getNumFreeTextures() { return this.numFreeTextures } dispose() { this.freeTextures.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.usedTextures.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.freeTextures = new Map, this.usedTextures = new Map, this.numUsedTextures = 0, this.numFreeTextures = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0 } } function JO(e, t, n, r) { return `${e}_${t}_${n}_${r}` } function QO(e) { if ("rgba8unorm" === e) return 16; throw new Error(`${e} is not supported!`) } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ez(e, t) { if (Math.max(...e) > 5) throw new Error("Cannot symbolically compute strides for rank > 6 tensor."); const n = e.length, r = e.map((e => `${t}.${"xyzwuv"[e]}`)), i = new Array(n - 1); i[n - 2] = r[n - 1]; for (let e = n - 3; e >= 0; --e)i[e] = `(${i[e + 1]} * ${r[e + 1]})`; return i } const tz = (e, t, n) => "int32" === n ? `atomicAdd(${e}, bitcast(${t}));` : `\n {\n var oldValue = 0;\n loop {\n let newValueF32 = bitcast(oldValue) + (${t});\n let newValue = bitcast(newValueF32);\n let res = atomicCompareExchangeWeak(${e}, oldValue, newValue);\n if res.exchanged {\n break;\n }\n oldValue = res.old_value;\n }\n }`; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var nz, rz; (rz = nz || (nz = {}))[rz.FROM_PIXELS = 0] = "FROM_PIXELS", rz[rz.DRAW = 1] = "DRAW"; const iz = (e, t, n, r, i) => { const a = function (e, t, n) { const r = [], i = n.workgroupSize[0] * n.workgroupSize[1] * n.workgroupSize[2]; if (n.outputComponent = n.outputComponent ? n.outputComponent : 1, r.push(`\n\n var localId: vec3;\n var localIndex: u32;\n var globalId: vec3;\n var numWorkgroups: vec3;\n var workgroupId: vec3;\n\n // Only used when the y/z dimension of workgroup size is 1.\n fn getGlobalIndex() -> i32 {\n ${pz(n) ? " return i32(globalId.x);" : ` return i32((workgroupId.z * numWorkgroups.x * numWorkgroups.y +\n workgroupId.y * numWorkgroups.x + workgroupId.x) * ${i}u +\n localIndex);\n `}\n }\n `), null != n.pixelsOpType) { const i = n.pixelsOpType === nz.FROM_PIXELS ? `@group(0) @binding(0) var result: array<${mz(t.dtype, n.outputComponent)}>;` : `@group(0) @binding(1) var inBuf : array<${mz(e[0].dtype, n.outputComponent)}>;`, a = 3 === t.shape.length ? "vec2" : "i32"; r.push(`\n struct Uniform {\n outShapeStrides : ${a},\n size : i32,\n numChannels : i32,\n alpha : f32,\n };\n\n ${i}\n @group(0) @binding(2) var uniforms: Uniform;\n `); const o = gz(n); return [cz, r.join("\n"), dz(t.shape), n.getUserCode(), lz(o, n)].join("\n") } let a, o, s = "struct Uniforms { NAN : f32, INFINITY : f32, "; n.variableNames.forEach(((t, n) => { const r = oz(e[n].shape.length); s += `${t.charAt(0).toLowerCase() + t.slice(1)}Shape : ${r}, `, a = e[n].shape.length - 1, o = oz(a), s += `${t.charAt(0).toLowerCase() + t.slice(1)}ShapeStrides: ${o}, ` })); const u = oz(t.shape.length); s += `outShape : ${u}, `, a = t.shape.length - 1, o = oz(a), s += `\n outShapeStrides: ${o}, `, n.size && (s += "size : i32, "); n.uniforms && (s += n.uniforms); s += "};", s = function (e) { const t = /(\w+)\s*:\s*vec(5|6)/g; e = e.replace(t, (e => "@align(16) " + e)); const n = /vec(5|6)\s*,\s*(\w+)/g; return e = e.replace(n, ((e, t, n) => `vec${t}, @align(16) ${n}`)) }(s), r.push(s), n.atomic ? r.push("\n @group(0) @binding(0) var result: array>;\n ") : r.push(`\n @group(0) @binding(0) var result: array<${mz(t.dtype, n.outputComponent)}>;\n `); n.variableNames.forEach(((t, i) => { r.push(`\n @group(0) @binding(${1 + i}) var ${t}: array<${n.variableComponents ? mz(e[i].dtype, n.variableComponents[i]) : mz(e[i].dtype, n.outputComponent)}>;\n `) })), "" !== s && r.push(`\n @group(0) @binding(${1 + n.variableNames.length}) var uniforms: Uniforms;\n `); const l = function (e, t) { const { x: n, y: r = [], z: i = [] } = t, a = e.length, o = n.length + r.length + i.length; if (o !== a) return ""; if (n.length === a) { return `fn getOutputCoords() -> ${oz(a)}{\n let globalIndex = getGlobalIndex();\n return getCoordsFromIndex(globalIndex);\n }\n ` } let s = ""; const u = [n, r, i]; for (let e = 0; e < u.length; e++) { const t = u[e]; if (0 !== t.length) if (1 === t.length) s += `let d${t[0]} = i32(globalId[${e}]);`; else { const n = ez(t, "uniforms.outShape"); s += `var index${e} = i32(globalId[${e}]);`; for (let r = 0; r < n.length; r++)s += `let d${t[r]} = index${e} / ${n[r]};`, r === n.length - 1 ? s += `let d${t[r + 1]} = index${e} - d${t[r]} * ${n[r]};` : s += `index${e} = index${e} - d${t[r]} * ${n[r]};` } } const l = []; for (let e = 0; e < o; e++)l.push(`d${e}`); const c = oz(o); let h = `fn getOutputCoords() -> ${c} {\n ${s}\n`; 0 === l.length ? h += `return ${c}(0); }` : h += `return ${c}(${l.join(",")}); }`; return h }(t.shape, n.dispatchLayout), c = [cz, r.join("\n") + hz, dz(t.shape), l, fz(t.shape.length)]; n.atomic || c.push(function (e, t, n) { const r = e.length, i = mz(t, n); let a = `fn setOutputAtIndex(flatIndex : i32, value : ${az(n)}) {\n result[flatIndex] = ${i}(value);\n }\n\n fn setOutputAtIndexI32(flatIndex : i32, value : ${az(n, "i32")}) {\n result[flatIndex] = ${i}(value);\n }\n `; if (r >= 2) { const e = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, r), t = oz(r); a += `\n fn setOutputAtCoords(${e.map((e => `${e} : i32`)).join(", ")}, value : ${az(n)}) {\n let flatIndex = getOutputIndexFromCoords(${t}(${e.join(", ")}));\n setOutputAtIndex(flatIndex${1 === n ? "" : ` / ${n}`}, value);\n }\n fn setOutputAtCoordsI32(${e.map((e => `${e} : i32`)).join(", ")}, value : ${az(n, "i32")}) {\n let flatIndex = getOutputIndexFromCoords(${t}(${e.join(", ")}));\n setOutputAtIndexI32(flatIndex${1 === n ? "" : ` / ${n}`}, value);\n }\n ` } return a }(t.shape, t.dtype, n.outputComponent)); n.variableNames.forEach(((t, n) => { c.push(`${dz(e[n].shape, t)}`) })); const h = e.map(((e, r) => function (e, t, n, r) { let i = function (e, t) { const n = e.name, r = e.shape.length, i = oz(r), a = "get" + n.charAt(0).toUpperCase() + n.slice(1), o = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, r), s = o.map((e => `${e} : i32`)).join(", "); if (r < 1) return `\n fn ${a}() -> ${az(t)} {\n return ${az(t)}(${n}[0]);\n }\n `; const u = `uniforms.${n.charAt(0).toLowerCase() + n.slice(1)}Shape`; let l = `${r}D`; 0 === r && (l = "1D"); return `\n fn ${a}(${s}) -> ${az(t)} {\n return ${az(t)}(${n}[getIndexFromCoords${l}(${i}(${o.join(",")}),\n ${u})${1 === t ? "" : ` / ${t}`}]);\n }\n ` }(e, n); const a = e.shape; a.length <= t.length && (i += function (e, t, n, r) { const i = e.name, a = i.charAt(0).toUpperCase() + i.slice(1), o = "get" + a + "ByOutput", s = e.shape.length, u = t.length, l = oz(u); if (P.util.arraysEqual(e.shape, t) && r) return `\n fn ${o}Index(globalIndex : i32) -> ${az(n)} {\n return ${az(n)}(${i}[globalIndex]);\n }\n\n fn ${o}Coords(coords : ${l}) -> ${az(n)} {\n return ${az(n)}(${i}[${u > 1 ? "getOutputIndexFromCoords(coords)" : "coords"}${1 === n ? "" : ` / ${n}`}]);\n }\n `; const c = P.backend_util.getBroadcastDims(e.shape, t), h = u - s; let d = ""; if (0 === s) return `\n fn ${o}Index(globalIndex : i32) -> ${az(n)}{\n return get${a}();\n }\n\n fn ${o}Coords(coords : ${l}) -> ${az(n)}{\n return get${a}();\n }\n `; d = u < 2 && c.length >= 1 ? "coords = 0;" : c.map((e => `coords.${sz(e + h)} = 0;`)).join("\n"); let f = ""; if (u < 2 && s > 0) f = "coords"; else if (u > 1) { const t = oz(s), n = e.shape.map(((e, t) => `coords.${sz(t + h)}`)).join(", "); f = `${t}(${n})` } else f = "coords"; const p = `uniforms.${i.charAt(0).toLowerCase() + i.slice(1)}Shape`, m = `${s}D`; return `\n fn ${o}Index(globalIndex : i32) -> ${az(n)} {\n var coords = getCoordsFromIndex(globalIndex);\n ${d}\n return ${az(n)}(${i}[getIndexFromCoords${m}(${f}, ${p})${1 === n ? "" : ` / ${n}`}]);\n }\n\n fn ${o}Coords(coordsIn : ${l}) -> ${az(n)} {\n var coords = coordsIn;\n ${d}\n return ${az(n)}(${i}[getIndexFromCoords${m}(${f}, ${p})${1 === n ? "" : ` / ${n}`}]);\n }\n` }(e, t, n, r)); return i }(e, t.shape, n.variableComponents ? n.variableComponents[r] : n.outputComponent, n.dispatchLayout.x.length === t.shape.length))).join("\n"); c.push(h), c.push(n.getUserCode()); const d = gz(n); c.push(lz(d, n)); const f = c.join("\n"); return f }(n, { dtype: r.dtype, shape: r.shape }, t), o = e.createShaderModule({ code: a, label: t.constructor.name }); let s = (0, P.env)().get("WEBGPU_PRINT_SHADER"); if ("" !== s) { s = s.toLowerCase(); const e = s.split(","); ("all" === s || e.some((e => t.shaderKey.toLowerCase().includes(e)))) && (console.group(t.shaderKey), console.debug(a), console.groupEnd()) } return i ? e.createComputePipelineAsync({ compute: { module: o, entryPoint: "_start" }, label: t.constructor.name, layout: "auto" }) : e.createComputePipeline({ compute: { module: o, entryPoint: "_start" }, label: t.constructor.name, layout: "auto" }) }, az = (e, t = "f32") => { switch (e) { case 1: return `${t}`; case 2: return `vec2<${t}>`; case 3: return `vec3<${t}>`; case 4: return `vec4<${t}>`; default: throw new Error(`${e}-component ${t} is not supported.`) } }; function oz(e) { if (e <= 1) return "i32"; if (2 === e) return "vec2"; if (3 === e) return "vec3"; if (4 === e) return "vec4"; if (5 === e) return "vec5"; if (6 === e) return "vec6"; throw Error(`GPU for rank ${e} is not yet supported`) } function sz(e) { if (0 === e) return "x"; if (1 === e) return "y"; if (2 === e) return "z"; if (3 === e) return "w"; if (4 === e) return "u"; if (5 === e) return "v"; throw Error(`Index ${e} is not yet supported`) } function uz(...e) { let t; switch (e.length) { case 0: t = "\n fn main()\n "; break; case 1: t = `\n fn main(${e[0]} : i32)\n `; break; default: throw Error("Unreachable") }return t } function lz(e, t) { let n; return n = `\n ${function (e) { return `\n @compute @workgroup_size(${e.workgroupSize[0]}, ${e.workgroupSize[1]}, ${e.workgroupSize[2]})\n` }(t)}\n fn _start(@builtin(local_invocation_id) LocalId : vec3,\n @builtin(global_invocation_id) GlobalId : vec3,\n @builtin(local_invocation_index) LocalIndex: u32,\n @builtin(workgroup_id) WorkgroupId : vec3,\n @builtin(num_workgroups) NumWorkgroups : vec3) {\n localId = LocalId;\n localIndex = LocalIndex;\n globalId = GlobalId;\n numWorkgroups = NumWorkgroups;\n workgroupId = WorkgroupId;\n ${e ? "main(getGlobalIndex());" : "main();"};\n }\n `, n } const cz = "\n struct vec5 {x: i32, y: i32, z: i32, w: i32, u: i32};\n struct vec6 {x: i32, y: i32, z: i32, w: i32, u: i32, v: i32};\n\n // Checks whether coordinates lie within the bounds of the shape.\n fn coordsInBounds2D(coord : vec2, shape : vec2) -> bool {\n return all(coord >= vec2(0)) && all(coord < shape);\n }\n fn coordsInBounds3D(coord : vec3, shape : vec3) -> bool {\n return all(coord >= vec3(0)) && all(coord < shape);\n }\n fn coordsInBounds4D(coord : vec4, shape : vec4) -> bool {\n return all(coord >= vec4(0)) && all(coord < shape);\n }\n\n fn getIndexFromCoords1D(coord : i32, shape : i32) -> i32 {\n return coord;\n }\n fn getIndexFromCoords2D(coords : vec2, shape : vec2) -> i32 {\n return dot(coords, vec2(shape.y, 1));\n }\n fn getIndexFromCoords3D(coords : vec3, shape : vec3) -> i32 {\n return dot(coords, vec3(shape.y * shape.z, shape.z, 1));\n }\n fn getIndexFromCoords4D(coords : vec4, shape : vec4) -> i32 {\n return dot(coords, vec4(\n shape.y * shape.z * shape.w, shape.z * shape.w, shape.w, 1));\n }\n fn getIndexFromCoords5D(coords : vec5, shape : vec5) -> i32 {\n let shapeStrides: vec5 = vec5(shape.y * shape.z * shape.w * shape.u, shape.z * shape.w * shape.u, shape.w * shape.u, shape.u, 1);\n return coords.x*shapeStrides.x + coords.y*shapeStrides.y + coords.z*shapeStrides.z + coords.w*shapeStrides.w + coords.u*shapeStrides.u;\n }\n fn getIndexFromCoords6D(coords : vec6, shape : vec6) -> i32 {\n let shapeStrides: vec6 = vec6(shape.y * shape.z * shape.w * shape.u * shape.v, shape.z * shape.w * shape.u * shape.v, shape.w * shape.u * shape.v, shape.u * shape.v, shape.v, 1);\n return coords.x*shapeStrides.x + coords.y*shapeStrides.y + coords.z*shapeStrides.z + coords.w*shapeStrides.w + coords.u*shapeStrides.u + coords.v*shapeStrides.v;\n }\n\n // NaN defination in IEEE 754-1985 is :\n // - sign = either 0 or 1.\n // - biased exponent = all 1 bits.\n // - fraction = anything except all 0 bits (since all 0 bits represents infinity).\n // https://en.wikipedia.org/wiki/IEEE_754-1985#Representation_of_non-numbers\n fn isnan(val: f32) -> bool {\n let floatToUint: u32 = bitcast(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n fn isnanVec4(val : vec4) -> vec4 {\n let floatToUint: vec4 = bitcast>(val);\n return (floatToUint & vec4(0x7fffffffu)) > vec4(0x7f800000u);\n }\n", hz = "\n fn isinf(val: f32) -> bool {\n return abs(val) == uniforms.INFINITY;\n }\n"; function dz(e, t = "") { const n = e.length, r = "" !== t ? `get${t.charAt(0).toUpperCase() + t.slice(1)}CoordsFromIndex` : "getCoordsFromIndex", i = "" !== t ? `${t.charAt(0).toLowerCase() + t.slice(1)}ShapeStrides` : "outShapeStrides"; if (n <= 1) return `fn ${r}(index : i32) -> i32 { return index; }`; const a = P.util.computeStrides(e), o = oz(n), s = []; for (let e = 0; e < n; e++)s.push(`d${e}`); if (1 === a.length) return ` fn ${r}(index : i32) -> vec2 {\n let d0 = index / uniforms.${i}; let d1 = index - d0 * uniforms.${i};\n return vec2(d0, d1);\n }`; let u; return u = "var index2 = index;" + a.map(((e, t) => `${`let ${s[t]} = index2 / uniforms.${i}.${sz(t)}`}; ${t === a.length - 1 ? `let ${s[t + 1]} = index2 - ${s[t]} * uniforms.${i}.${sz(t)}` : `index2 = index2 - ${s[t]} * uniforms.${i}.${sz(t)}`};`)).join(""), `\n fn ${r}(index : i32) -> ${o} {\n ${u}\n return ${o}(${s.join(",")});\n }\n ` } function fz(e) { let t = ""; switch (e) { case 0: case 1: t += "\n fn getOutputIndexFromCoords(coords : i32) -> i32 {\n return coords;\n }\n "; break; case 2: t += "\n fn getOutputIndexFromCoords(coords : vec2) -> i32 {\n return dot(coords, vec2(uniforms.outShapeStrides, 1));\n }\n "; break; case 3: t += "\n fn getOutputIndexFromCoords(coords : vec3) -> i32 {\n return dot(coords, vec3(uniforms.outShapeStrides.x, uniforms.outShapeStrides.y, 1));\n }\n "; break; case 4: t += "\n fn getOutputIndexFromCoords(coords : vec4) -> i32 {\n return dot(coords, vec4(\n uniforms.outShapeStrides.x, uniforms.outShapeStrides.y, uniforms.outShapeStrides.z, 1));\n }\n "; break; case 5: t += "\n fn getOutputIndexFromCoords(coords : vec5) -> i32 {\n return coords.x * uniforms.outShapeStrides.x +\n coords.y * uniforms.outShapeStrides.y +\n coords.z * uniforms.outShapeStrides.z +\n coords.w * uniforms.outShapeStrides.w +\n coords.u;\n }\n "; break; case 6: t += "\n fn getOutputIndexFromCoords(coords : vec6) -> i32 {\n return coords.x * uniforms.outShapeStrides.x +\n coords.y * uniforms.outShapeStrides.y +\n coords.z * uniforms.outShapeStrides.z +\n coords.w * uniforms.outShapeStrides.w +\n coords.u * uniforms.outShapeStrides.u +\n coords.v;\n }\n "; break; default: P.util.assert(!1, (() => `Unsupported ${e}D shape`)) }return t } function pz(e) { return 1 === e.dispatch[1] && 1 === e.dispatch[2] } function mz(e, t = 1) { if ("float32" === e) return az(t, "f32"); if ("int32" === e || "bool" === e) return az(t, "i32"); throw new Error(`type ${e} is not supported.`) } function gz(e) { return (!e.dispatchLayout.hasOwnProperty("y") || 0 === e.dispatchLayout.y.length) && (!e.dispatchLayout.hasOwnProperty("z") || 0 === e.dispatchLayout.z.length) } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const yz = e => { let t = 1; for (let n = 0; n < e.length; n++)t *= e[n]; return t }; function bz(e, t, n = [1, 1, 1], r = [1, 1, 1]) { const [i, a, o] = [Math.ceil(yz(e.x.map((e => t[e]))) / (n[0] * r[0])), e.y ? Math.ceil(yz(e.y.map((e => t[e]))) / (n[1] * r[1])) : 1, e.z ? Math.ceil(yz(e.z.map((e => t[e]))) / (n[2] * r[2])) : 1]; return [i, a, o] } function vz(e, t, n = !1) { if (n) return [8, 8, 1]; const r = yz(e.x.map((e => t[e]))), i = yz(e.y.map((e => t[e]))); return r <= 4 ? [4, 16, 1] : i <= 4 ? [16, 4, 1] : [16, 16, 1] } function xz(e, t, n = !1) { if (n) return [4, 4, 1]; const r = yz(e.x.map((e => t[e]))), i = yz(e.y.map((e => t[e]))); return r <= 4 ? [1, 2, 1] : i <= 4 ? [2, 1, 1] : [2, 2, 1] } function wz(e) { return { x: e.map(((e, t) => t)) } } function kz(e) { if ("float32" === e || "int32" === e || "bool" === e || "string" === e) return 4; if ("complex64" === e) return 8; throw new Error(`Unknown dtype ${e}`) } function Sz() { return !("undefined" == typeof globalThis || !globalThis.navigator || !globalThis.navigator.gpu) } function _z(e, t) { Array.isArray(e) || (e = [e]), e.forEach((e => { null != e && P.util.assert("complex64" !== e.dtype, (() => `${t} does not support complex64 tensors in the WebGPU backend.`)) })) } var Cz, Az; (Az = Cz || (Cz = {}))[Az.MatMulReduceProgram = 0] = "MatMulReduceProgram", Az[Az.MatMulSplitKProgram = 1] = "MatMulSplitKProgram", Az[Az.MatMulSmallOutputSizeProgram = 2] = "MatMulSmallOutputSizeProgram", Az[Az.MatMulPackedProgram = 3] = "MatMulPackedProgram", Az[Az.MatMulMax = 4] = "MatMulMax"; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Tz = (0, P.env)().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD"); class Ez extends P.KernelBackend { nextDataId() { return Ez.nextDataId++ } constructor(e, t) { if (super(), this.commandQueueOwnedIds = new WeakSet, this.dispatchCountInPass = 0, this.disposed = !1, this.downloadWaitMs = 0, this.tensorDataPendingDisposal = [], this.queryResolveBuffer = null, this.querySet = null, this.querySetCount = 2, this.stagingPendingDisposal = [], this.uniformPendingDisposal = [], this.uploadWaitMs = 0, this.hasReadSyncWarned = !1, this.hasTimestampQueryWarned = !1, !Sz()) throw new Error("WebGPU is not supported on this device"); this.pipelineCache = {}, this.device = e, this.queue = e.queue, this.commandEncoder = null, this.computePassEncoder = null, this.adapterInfo = new YO(t), this.supportTimestampQuery = this.device.features.has("timestamp-query"), this.thresholdToIncreaseWorkgroups = this.adapterInfo.intelGPUGeneration >= 12 ? 16 : 8, this.bufferManager = new XO(this.device), this.textureManager = new ZO(this.device), this.tensorMap = new P.DataStorage(this, (0, P.engine)()), (0, P.env)().getBool("WEBGPU_USE_PROFILE_TOOL") && (this.dummyCanvas = document.createElement("canvas"), this.dummyCanvas.width = 1, this.dummyCanvas.height = 1, this.dummyContext = this.dummyCanvas.getContext("webgpu"), this.dummyContext.configure({ device: e, format: "bgra8unorm" }), document.body.appendChild(this.dummyCanvas)) } floatPrecision() { return 32 } disposeData(e, t = !1) { if (!this.tensorMap.has(e)) return !0; const n = this.tensorMap.get(e); return t ? n.refCount = 0 : n.refCount--, !(n.refCount > 0) && (null != n.complexTensorInfos && (this.disposeData(n.complexTensorInfos.real.dataId), this.disposeData(n.complexTensorInfos.imag.dataId)), this.commandQueueOwnedIds.has(e) ? (this.tensorDataPendingDisposal.push(e), !0) : (this.releaseResource(e), this.tensorMap.delete(e), !0)) } memory() { return { numBytesInGPU: this.bufferManager.numBytesUsed, numBytesAllocatedInGPU: this.bufferManager.numBytesAllocated, unreliable: !1 } } releaseResource(e) { const t = this.tensorMap.get(e); t && t.resource && (t.external || (t.resource instanceof GPUBuffer ? this.bufferManager.releaseBuffer(t.resource) : t.resource instanceof GPUTexture && this.textureManager.releaseTexture(t.resource)), t.resource = null) } refCount(e) { if (this.tensorMap.has(e)) { return this.tensorMap.get(e).refCount } return 0 } incRef(e) { this.tensorMap.get(e).refCount++ } decRef(e) { if (this.tensorMap.has(e)) { this.tensorMap.get(e).refCount-- } } write(e, t, n) { if ("complex64" === n && null != e) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag)."); const r = { id: this.nextDataId() }; return this.tensorMap.set(r, { dtype: n, shape: t, values: e, refCount: 1 }), r } move(e, t, n, r, i) { if ("complex64" === r) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag)."); this.tensorMap.set(e, { dtype: r, shape: n, values: t, refCount: i }) } submitQueue() { this.queue.submit([this.commandEncoder.finish()]), this.commandEncoder = null, this.dispatchCountInPass = 0, this.commandQueueOwnedIds = new WeakSet, this.tensorDataPendingDisposal.forEach((e => { this.releaseResource(e), this.tensorMap.delete(e) })), this.uniformPendingDisposal.forEach((e => this.bufferManager.releaseBuffer(e))), this.stagingPendingDisposal.forEach((e => this.bufferManager.releaseBuffer(e, !1))), this.tensorDataPendingDisposal = [], this.uniformPendingDisposal = [], this.stagingPendingDisposal = [] } ensureCommandEncoderReady() { this.commandEncoder || (this.commandEncoder = this.device.createCommandEncoder()) } endComputePassEncoder() { this.computePassEncoder && (this.computePassEncoder.end(), this.computePassEncoder = null) } async checkCompileCompletionAsync() { let e; try { e = await Promise.all(Object.values(this.pipelineCache)) } catch (e) { throw new Error(e.message) } Object.keys(this.pipelineCache).map(((t, n) => { this.pipelineCache[t] = e[n] })) } async getBufferData(e) { if ((0, P.env)().getBool("WEBGPU_ENGINE_COMPILE_ONLY")) return console.warn("The data may be invalid since WEBGPU_ENGINE_COMPILE_ONLY is true, this can only be called when WEBGPU_ENGINE_COMPILE_ONLY is false"), null; const t = e.size, n = this.bufferManager.acquireBuffer(t, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ); this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(e, 0, n, 0, t), this.submitQueue(), await n.mapAsync(GPUMapMode.READ); const r = n.getMappedRange().slice(0); return n.unmap(), null != n && this.bufferManager.releaseBuffer(n), (0, P.env)().getBool("WEBGPU_USE_PROFILE_TOOL") && (P.util.assert(void 0 !== this.dummyContext, (() => "Fail to get context for profiling tool")), this.dummyContext.getCurrentTexture()), r } convertAndCacheOnCPU(e, t) { const n = this.tensorMap.get(e); return n.values = t, n.values } readSync(e) { const t = this.tensorMap.get(e), { values: n, complexTensorInfos: r } = t; if (null != n || "string" === t.dtype) return n; if ("complex64" === t.dtype) { const t = this.readSync(r.real.dataId), n = this.readSync(r.imag.dataId), i = P.util.convertBackendValuesAndArrayBuffer(P.backend_util.mergeRealAndImagArrays(t, n).buffer, "float32"); return this.convertAndCacheOnCPU(e, i), i } this.hasReadSyncWarned || (this.hasReadSyncWarned = !0, console.warn("The performance of synchronously reading data from GPU to CPU is poor on the webgpu backend, please use asynchronous APIs instead.")); const i = ["opaque", "premultiplied"], a = t.resource, o = a.size; P.util.assert(o % 4 == 0, (() => "Because there is 4 bytes for one pixel, buffer size must be multiple of 4.")); const s = o / 4, u = new ArrayBuffer(o), l = 256, c = 256, h = i.map((e => new OffscreenCanvas(l, c))), d = new OffscreenCanvas(l, c); this.endComputePassEncoder(), h.map(((e, t) => { const n = e.getContext("webgpu"); return n.configure({ device: this.device, format: "bgra8unorm", usage: GPUTextureUsage.COPY_DST, alphaMode: i[t] }), n.getCurrentTexture() })).map(((e, t) => { const n = (n, r, o) => { this.ensureCommandEncoderReady(), this.commandEncoder.copyBufferToTexture({ buffer: a, bytesPerRow: 1024, offset: o }, { texture: e }, { width: n, height: r }), this.submitQueue(); const s = d.getContext("2d", { willReadFrequently: !0 }); s.clearRect(0, 0, n, r), s.drawImage(h[t], 0, 0); const l = s.getImageData(0, 0, n, r).data, c = i[t], f = new Uint8ClampedArray(u, o, n * r * 4); for (let e = 0; e < f.length; e += 4)if ("premultiplied" === c) f[e + 3] = l[e + 3]; else { const t = l[e]; f[e] = l[e + 2], f[e + 1] = l[e + 1], f[e + 2] = t } }, r = Math.floor(s / 65536); let o = l, f = c, p = 0; for (let e = 0; e < r; e++)n(o, f, p), p += 262144; const m = s % 65536; f = Math.floor(m / l), f > 0 && (n(o, f, p), p += 1024 * f), o = m % l, o > 0 && n(o, 1, p) })); const f = P.util.convertBackendValuesAndArrayBuffer(u, t.dtype); return this.convertAndCacheOnCPU(e, f), f } async read(e) { if (!this.tensorMap.has(e)) throw new Error(`Tensor ${e} was not registered!`); const t = this.tensorMap.get(e), { values: n } = t; if (null != n) return n; let r; if ("complex64" === t.dtype) { const e = await Promise.all([this.read(t.complexTensorInfos.real.dataId), this.read(t.complexTensorInfos.imag.dataId)]), n = e[0], i = e[1]; r = P.backend_util.mergeRealAndImagArrays(n, i) } else { const e = await this.getBufferData(t.resource); r = P.util.convertBackendValuesAndArrayBuffer(e, t.dtype) } return this.convertAndCacheOnCPU(e, r), r } copyBuffer(e) { const t = e.size, n = e.usage, r = this.bufferManager.acquireBuffer(t, n); return this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(e, 0, r, 0, t), this.submitQueue(), r } createTensorFromGPUData(e, t, n) { let r = e.buffer; if ("complex64" === n) throw new Error("Cannot write to a complex64 dtype. "); const i = { id: this.nextDataId() }; this.tensorMap.set(i, { dtype: n, shape: t, values: null, refCount: 1, external: e.zeroCopy }); const a = this.tensorMap.get(i), o = kz(a.dtype) * P.util.sizeFromShape(a.shape); if (e.buffer.size < o) throw new Error(`GPUBuffer size(${e.buffer.size}) is smaller than tensor size(${o})!`); if ((e.buffer.usage & (GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC)) != (GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC)) throw new Error("GPUBuffer.usage should include GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC!"); return !0 !== e.zeroCopy && (r = this.copyBuffer(r)), a.resource = r, (0, P.engine)().makeTensorFromDataId(i, t, n, this) } readToGPU(e) { const t = this.tensorMap.get(e), { values: n, dtype: r, shape: i, resource: a } = t; if ("complex64" === r) throw new Error("Does not support reading buffer for complex64 dtype."); if (null == a) throw null != n ? new Error("Data is not on GPU but on CPU.") : new Error("There is no data on GPU or CPU."); const o = a, s = o.size, u = o.usage, l = this.bufferManager.acquireBuffer(s, u); this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(a, 0, l, 0, s), this.submitQueue(); const c = this.makeTensorInfo(i, r), h = (0, P.engine)().makeTensorFromTensorInfo(c); return this.tensorMap.get(c.dataId).resource = l, { tensorRef: h, buffer: l } } bufferSync(e) { const t = this.readSync(e.dataId); if ("string" === e.dtype) try { const n = t.map((e => P.util.decodeString(e))); return (0, P.buffer)(e.shape, e.dtype, n) } catch (e) { throw new Error("Failed to decode encoded string bytes into utf-8") } return (0, P.buffer)(e.shape, e.dtype, t) } async time(e) { this.supportTimestampQuery || this.hasTimestampQueryWarned || (console.warn("This device doesn't support timestamp-query extension. Start Chrome browser with flag --enable-dawn-features=allow_unsafe_apis to try it again. Otherwise, zero will be shown for the kernel time when profiling mode is enabled."), this.hasTimestampQueryWarned = !0); const t = this.activeTimers, n = []; let r = !1; null == this.programTimersStack ? (this.programTimersStack = n, r = !0) : this.activeTimers.push(n), this.activeTimers = n, e(); const i = P.util.flatten(this.activeTimers.map((e => e.query))).filter((e => null != e)), a = P.util.flatten(this.activeTimers.map((e => e.name))).filter((e => null != e)); this.activeTimers = t, r && (this.programTimersStack = null); const o = { uploadWaitMs: this.uploadWaitMs, downloadWaitMs: this.downloadWaitMs, kernelMs: null, wallMs: null }, s = await Promise.all(i); return o.kernelMs = P.util.sum(s), o.getExtraProfileInfo = () => s.map(((e, t) => ({ name: a[t], ms: e }))).map((e => `${e.name}: ${e.ms}`)).join(", "), this.uploadWaitMs = 0, this.downloadWaitMs = 0, o } makeTensorInfo(e, t, n) { "string" === t && null != n && n.length > 0 && P.util.isString(n[0]) && (n = n.map((e => P.util.encodeString(e)))); return { dataId: this.write(n, e, t), shape: e, dtype: t } } tensorToBinding(e) { if (!e) return null; const t = this.tensorMap.get(e.dataId).resource; return t instanceof GPUBuffer ? { buffer: t } : t instanceof GPUTexture ? t.createView() : t } uploadToGPU(e) { const t = this.tensorMap.get(e); if (null != t.resource) return; const n = kz(t.dtype) * P.util.sizeFromShape(t.shape); let r; const i = GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST; if (t.values) { if (r = this.bufferManager.acquireBuffer(n, i, !0), "unmapped" === r.mapState) { const e = this.bufferManager.acquireBuffer(n, GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC, !0, !1), i = e.getMappedRange(); "int32" === t.dtype || "bool" === t.dtype ? new Int32Array(i).set(t.values) : new Float32Array(i).set(t.values), e.unmap(), this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(e, 0, r, 0, n), this.stagingPendingDisposal.push(e) } else { const e = r.getMappedRange(); "int32" === t.dtype || "bool" === t.dtype ? new Int32Array(e).set(t.values) : new Float32Array(e).set(t.values), r.unmap() } t.values = null } else r = this.bufferManager.acquireBuffer(n, i); t.resource = r } makeUniforms(e) { let t = 0, n = 0; const r = []; let i = 1; e.forEach((e => { let a; switch (0 === e.data.length && (e.data = [1]), e.data.length) { case 1: a = 4; break; case 2: a = 8; break; case 3: case 4: case 5: case 6: a = 16; break; default: P.util.assert(!1, (() => `Unsupported ${e.data.length}D shape`)) }5 !== n && 6 !== n || (a = 16), a > i && (i = a), t = Math.ceil(t / a) * a, n = e.data.length, r.push(t), t += 4 * e.data.length })), t = Math.ceil(t / i) * i; const a = new ArrayBuffer(t); e.forEach(((e, t) => { const n = r[t]; "int32" === e.type ? new Int32Array(a, n, e.data.length).set(e.data) : "uint32" === e.type ? new Uint32Array(a, n, e.data.length).set(e.data) : new Float32Array(a, n, e.data.length).set(e.data) })); const o = this.bufferManager.acquireBuffer(t, GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM); return this.queue.writeBuffer(o, 0, a, 0, t), this.uniformPendingDisposal.push(o), { offset: 0, size: t, buffer: o } } runWebGPUProgram(e, t, n, r, i) { if (i || (i = this.makeTensorInfo(e.outputShape, n)), 0 === P.util.sizeFromShape(i.shape)) return this.tensorMap.get(i.dataId).values = P.util.getTypedArrayFromDType(i.dtype, 0), i; this.uploadToGPU(i.dataId), e.dispatch = ((e, t) => { const n = e.limits.maxComputeWorkgroupsPerDimension, r = t.dispatchLayout, i = t.dispatch; if (i.every((e => e <= n))) return i; P.util.assert(i[0] > n && void 0 === r.y && void 0 === r.z, (() => "Dispatch size exceeds WebGPU limits in Y or Z dimension.")); let a = Math.ceil(Math.sqrt(i[0])); return a > n ? (a = Math.ceil(Math.cbrt(i[0])), P.util.assert(a <= n, (() => "Total dispatch size exceeds WebGPU maximum.")), [a, a, a]) : [a, a, 1] })(this.device, e); const a = t.map(((t, n) => { if ("complex64" === t.dtype) throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts."); return this.uploadToGPU(t.dataId), { dtype: this.tensorMap.get(t.dataId).dtype, shape: t.shape, name: e.variableNames[n] } })); e.shaderKey = function (e, t, n) { let r = e.shaderKey; if (null != e.pixelsOpType) return r; const i = [], a = []; t.forEach((e => { i.push(e.shape), a.push(e.dtype) })), i.push(n.shape), a.push(n.dtype); const o = t.map((e => P.backend_util.getBroadcastDims(e.shape, n.shape))), s = t.map((e => P.util.arraysEqual(e.shape, n.shape))).join("_"), u = o.map((e => e.join("_"))).join(";"), l = pz(e) ? "flatDispatch" : ""; return r += "_" + (e.workgroupSize ? e.workgroupSize.join(",") : "") + i.map((e => e.length)).join(",") + a.join(",") + e.variableNames.join(",") + u + s + l, r }(e, a, i); const o = (0, P.env)().getBool("WEBGPU_ENGINE_COMPILE_ONLY"); return e.shaderKey in this.pipelineCache || (this.pipelineCache[e.shaderKey] = iz(this.device, e, a, i, o)), e.pipeline = this.pipelineCache[e.shaderKey], o || this.recordAndSubmit(e, i, t, r), i } recordAndSubmit(e, t, n, r) { if (e.pipeline instanceof Promise) throw new Error("Please call checkCompileCompletionAsync to ensure parallel compilation is done!"); let i = [], a = []; const o = "int32"; if (null == e.pixelsOpType) { i.push({ type: "float32", data: [NaN] }, { type: "float32", data: [1 / 0] }), a = n.concat(t).map((e => e.shape)); const e = "int32"; a.map((t => { i.push({ type: e, data: t }); const n = P.util.computeStrides(t); i.push({ type: e, data: n }) })) } else { const e = P.util.computeStrides(t.shape); i.push({ type: o, data: e }) } if (e.size) { const t = P.util.sizeFromShape(e.outputShape); i.push({ type: o, data: [e.outputComponent ? t / e.outputComponent : t] }) } r && (i = [...i, ...r]); const s = [this.tensorToBinding(t), ...n.map((e => this.tensorToBinding(e))), this.makeUniforms(i)]; n.forEach((e => { this.commandQueueOwnedIds.add(e.dataId) })), this.commandQueueOwnedIds.add(t.dataId); const u = this.device.createBindGroup({ layout: e.pipeline.getBindGroupLayout(0), entries: s.map(((e, t) => ({ binding: t, resource: e }))) }), l = null != this.activeTimers; this.ensureCommandEncoderReady(); const c = {}; l && this.supportTimestampQuery ? (this.endComputePassEncoder(), null == this.querySet && (this.querySet = this.device.createQuerySet({ type: "timestamp", count: this.querySetCount })), c.timestampWrites = { querySet: this.querySet, beginningOfPassWriteIndex: 0, endOfPassWriteIndex: 1 }, this.computePassEncoder = this.commandEncoder.beginComputePass(c)) : this.computePassEncoder || (this.computePassEncoder = this.commandEncoder.beginComputePass(c)), this.computePassEncoder.setPipeline(e.pipeline), this.computePassEncoder.setBindGroup(0, u), this.computePassEncoder.dispatchWorkgroups(e.dispatch[0], e.dispatch[1], e.dispatch[2]), this.dispatchCountInPass++, (l || (0, P.env)().get("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE") <= this.dispatchCountInPass || e.pixelsOpType === nz.DRAW) && (this.endComputePassEncoder(), l ? this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime() }) : this.submitQueue()) } async getQueryTime() { if (!this.supportTimestampQuery) return 0; null == this.queryResolveBuffer && (this.queryResolveBuffer = this.bufferManager.acquireBuffer(8 * this.querySetCount, GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST | GPUBufferUsage.QUERY_RESOLVE)), this.commandEncoder.resolveQuerySet(this.querySet, 0, this.querySetCount, this.queryResolveBuffer, 0); const e = this.bufferManager.acquireBuffer(8 * this.querySetCount, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST); this.commandEncoder.copyBufferToBuffer(this.queryResolveBuffer, 0, e, 0, 8 * this.querySetCount), this.submitQueue(), await e.mapAsync(GPUMapMode.READ); const t = new BigUint64Array(e.getMappedRange()), n = Number(t[1] - t[0]) / 1e6; return e.unmap(), this.bufferManager.releaseBuffer(e), n } shouldExecuteOnCPU(e, t = Tz) { return (0, P.env)().getBool("WEBGPU_CPU_FORWARD") && e.every((e => null == this.tensorMap.get(e.dataId).resource && P.util.sizeFromShape(e.shape) < t)) } numDataIds() { return this.tensorMap.numDataIds() - this.tensorDataPendingDisposal.length } dispose() { this.disposed || (null != this.querySet && this.querySet.destroy(), this.bufferManager.dispose(), this.textureManager.dispose(), this.disposed = !0) } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var Nz, Iz; Ez.nextDataId = 0, + /** + * @license + * Copyright 2022 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + Sz() && (0, P.registerBackend)("webgpu", (async () => { const e = { powerPreference: (0, P.env)().get("WEBGPU_USE_LOW_POWER_GPU") ? "low-power" : "high-performance" }, t = await navigator.gpu.requestAdapter(e), n = {}, r = []; t.features.has("timestamp-query") && r.push("timestamp-query"), t.features.has("bgra8unorm-storage") && r.push(["bgra8unorm-storage"]), n.requiredFeatures = r; const i = t.limits; n.requiredLimits = { maxComputeWorkgroupStorageSize: i.maxComputeWorkgroupStorageSize, maxComputeWorkgroupsPerDimension: i.maxComputeWorkgroupsPerDimension, maxStorageBufferBindingSize: i.maxStorageBufferBindingSize, maxBufferSize: i.maxBufferSize, maxComputeWorkgroupSizeX: i.maxComputeWorkgroupSizeX, maxComputeInvocationsPerWorkgroup: i.maxComputeInvocationsPerWorkgroup }; const a = await t.requestDevice(n), o = "info" in t ? t.info : "requestAdapterInfo" in t ? await t.requestAdapterInfo() : void 0; return new Ez(a, o) }), 3), (Iz = Nz || (Nz = {}))[Iz.ADD = 0] = "ADD", Iz[Iz.ATAN2 = 1] = "ATAN2", Iz[Iz.COMPLEX_MULTIPLY_IMAG = 2] = "COMPLEX_MULTIPLY_IMAG", Iz[Iz.COMPLEX_MULTIPLY_REAL = 3] = "COMPLEX_MULTIPLY_REAL", Iz[Iz.DIV = 4] = "DIV", Iz[Iz.ELU_DER = 5] = "ELU_DER", Iz[Iz.EQUAL = 6] = "EQUAL", Iz[Iz.FLOOR_DIV = 7] = "FLOOR_DIV", Iz[Iz.GREATER = 8] = "GREATER", Iz[Iz.GREATER_EQUAL = 9] = "GREATER_EQUAL", Iz[Iz.LESS = 10] = "LESS", Iz[Iz.LESS_EQUAL = 11] = "LESS_EQUAL", Iz[Iz.LOGICAL_AND = 12] = "LOGICAL_AND", Iz[Iz.LOGICAL_OR = 13] = "LOGICAL_OR", Iz[Iz.MAX = 14] = "MAX", Iz[Iz.MIN = 15] = "MIN", Iz[Iz.MOD = 16] = "MOD", Iz[Iz.MUL = 17] = "MUL", Iz[Iz.NOT_EQUAL = 18] = "NOT_EQUAL", Iz[Iz.POW = 19] = "POW", Iz[Iz.PRELU = 20] = "PRELU", Iz[Iz.SQUARED_DIFFERENCE = 21] = "SQUARED_DIFFERENCE", Iz[Iz.SUB = 22] = "SUB"; function Mz(e, t) { let n; do { switch (e) { case Nz.ATAN2: n = "let resultTemp = atan2(a, b);"; break; case Nz.MAX: n = "let resultTemp = max(a, b);"; break; case Nz.MIN: n = "let resultTemp = min(a, b);"; break; case Nz.MOD: n = t ? "\n let isNaN = !vec4(b);\n var resultTemp = vec4(a % b);\n if (!((a[0] < 0. && b[0] < 0.) || (a[0] >= 0. && b[0] > 0.))) {\n resultTemp[0] = (resultTemp[0] + b[0]) % b[0];\n }\n if (!((a[1] < 0. && b[1] < 0.) || (a[1] >= 0. && b[1] > 0.))) {\n resultTemp[1] = (resultTemp[1] + b[1]) % b[1];\n }\n if (!((a[2] < 0. && b[2] < 0.) || (a[2] >= 0. && b[2] > 0.))) {\n resultTemp[2] = (resultTemp[2] + b[2]) % b[2];\n }\n if (!((a[3] < 0. && b[3] < 0.) || (a[3] >= 0. && b[3] > 0.))) {\n resultTemp[3] = (resultTemp[3] + b[3]) % b[3];\n }\n" : "\n let isNaN = b == 0.;\n var resultTemp = a % b;\n resultTemp = select((resultTemp + b) % b, resultTemp,\n (a < 0. && b < 0.) || (a >= 0. && b > 0.));\n"; break; case Nz.NOT_EQUAL: n = t ? "\n var resultTemp = vec4(a != b);\n let valueForNaN = 1.0;\n" : "\n var resultTemp = f32(a != b);\n let valueForNaN = 1.0;\n"; break; case Nz.POW: n = t ? "\n let isModRound1Bool = vec4(round(abs(b) % vec4(2.0))) == vec4(1);\n let isModRound1 = vec4(isModRound1Bool);\n let multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n var resultTemp = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n let isExpZero = b == vec4(0.0);\n if (isExpZero.r) {\n resultTemp.r = 1.0;\n }\n if (isExpZero.g) {\n resultTemp.g = 1.0;\n }\n if (isExpZero.b) {\n resultTemp.b = 1.0;\n }\n if (isExpZero.a) {\n resultTemp.a = 1.0;\n }\n let isNaN = (a < vec4(0.0)) & (floor(b) < b);\n" : "\n let isNaN = a < 0.0 && floor(b) < b;\n if (b == 0.0) {\n return 1.0;\n }\n var resultTemp = select(sign(a) * pow(abs(a), b), pow(abs(a), b),\n round(abs(b) % 2.0) != 1.0);\n"; break; default: continue }let r, i, a; return t ? (r = "isnanVec4", i = "vec4", a = "vec4") : (r = "isnan", i = "f32", a = "bool"), `\n let aIsNaN = ${r}(a);\n let aPostLegalization = select(a, ${i}(42), aIsNaN);\n let bIsNaN = ${r}(b);\n let bPostLegalization = select(b, ${i}(42), bIsNaN);\n let isNaN = false;\n let valueForNaN = uniforms.NAN;\n {\n let a = aPostLegalization;\n let b = bPostLegalization;\n ${n}\n return select(\n resultTemp, ${i}(valueForNaN),\n ${a}(isNaN) | aIsNaN | bIsNaN);\n }\n ` } while (0); switch (e) { case Nz.ADD: n = "let resultTemp = a + b;"; break; case Nz.COMPLEX_MULTIPLY_IMAG: n = "let resultTemp = areal * bimag + aimag * breal;"; break; case Nz.COMPLEX_MULTIPLY_REAL: n = "let resultTemp = areal * breal - aimag * bimag;"; break; case Nz.DIV: n = "let resultTemp = a / b;"; break; case Nz.ELU_DER: n = "let resultTemp = select(a * (b + 1.0), a, b >= b - b);"; break; case Nz.EQUAL: n = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a == b);\n"; break; case Nz.FLOOR_DIV: n = "\n let remainder =\n select(a % b, round(a % b), (round(a) == a) & (round(b) == b));\n let quotient = (a - remainder) / b;\n let resultTemp =\n round(select(quotient, quotient - 1, sign(remainder) == -sign(b)));\n"; break; case Nz.GREATER: n = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a > b);\n"; break; case Nz.GREATER_EQUAL: n = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a >= b);\n"; break; case Nz.LESS: n = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a < b);\n"; break; case Nz.LESS_EQUAL: n = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a <= b);\n"; break; case Nz.LOGICAL_AND: return t ? "return (vec4(a >= vec4(1.0)) *\n vec4(b >= vec4(1.0)));" : "return f32(a >= 1.0 && b >= 1.0);"; case Nz.LOGICAL_OR: return t ? "return min(vec4(a >= vec4(1.0)) +\n vec4(b >= vec4(1.0)), vec4(1.0));" : "return f32(a >= 1.0 || b >= 1.0);"; case Nz.MUL: n = "let resultTemp = a * b;"; break; case Nz.PRELU: return t ? "\n let aLessThanZero = vec4(a < vec4(0.0));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n" : "if (a < 0.0) { return b * a; } return a;"; case Nz.SQUARED_DIFFERENCE: n = "let resultTemp = (a - b) * (a - b);"; break; case Nz.SUB: n = "let resultTemp = a - b;" }return `\n ${n}\n return resultTemp;\n ` } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var Fz, Dz; (Dz = Fz || (Fz = {}))[Dz.ABS = 0] = "ABS", Dz[Dz.ACOS = 1] = "ACOS", Dz[Dz.ACOSH = 2] = "ACOSH", Dz[Dz.ASIN = 3] = "ASIN", Dz[Dz.ASINH = 4] = "ASINH", Dz[Dz.ATAN = 5] = "ATAN", Dz[Dz.ATANH = 6] = "ATANH", Dz[Dz.CEIL = 7] = "CEIL", Dz[Dz.COS = 8] = "COS", Dz[Dz.COSH = 9] = "COSH", Dz[Dz.ELU = 10] = "ELU", Dz[Dz.ERF = 11] = "ERF", Dz[Dz.EXP = 12] = "EXP", Dz[Dz.EXPM1 = 13] = "EXPM1", Dz[Dz.FLOOR = 14] = "FLOOR", Dz[Dz.IS_FINITE = 15] = "IS_FINITE", Dz[Dz.IS_INF = 16] = "IS_INF", Dz[Dz.IS_NAN = 17] = "IS_NAN", Dz[Dz.LINEAR = 18] = "LINEAR", Dz[Dz.LOG = 19] = "LOG", Dz[Dz.LOG1P = 20] = "LOG1P", Dz[Dz.LOGICAL_NOT = 21] = "LOGICAL_NOT", Dz[Dz.NEG = 22] = "NEG", Dz[Dz.RELU = 23] = "RELU", Dz[Dz.RELU6 = 24] = "RELU6", Dz[Dz.LEAKYRELU = 25] = "LEAKYRELU", Dz[Dz.RECIPROCAL = 26] = "RECIPROCAL", Dz[Dz.ROUND = 27] = "ROUND", Dz[Dz.RSQRT = 28] = "RSQRT", Dz[Dz.SELU = 29] = "SELU", Dz[Dz.SIGMOID = 30] = "SIGMOID", Dz[Dz.SIGN = 31] = "SIGN", Dz[Dz.SIN = 32] = "SIN", Dz[Dz.SINH = 33] = "SINH", Dz[Dz.SOFTPLUS = 34] = "SOFTPLUS", Dz[Dz.SQRT = 35] = "SQRT", Dz[Dz.SQUARE = 36] = "SQUARE", Dz[Dz.STEP = 37] = "STEP", Dz[Dz.TAN = 38] = "TAN", Dz[Dz.TANH = 39] = "TANH", Dz[Dz.TO_INT = 40] = "TO_INT"; const $z = `\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n let p = ${P.backend_util.ERF_P};\n let a1 = ${P.backend_util.ERF_A1};\n let a2 = ${P.backend_util.ERF_A2};\n let a3 = ${P.backend_util.ERF_A3};\n let a4 = ${P.backend_util.ERF_A4};\n let a5 = ${P.backend_util.ERF_A5};\n\n let sign = sign(a);\n let absA = abs(a);\n let t = 1.0 / (1.0 + p * absA);\n return sign * (1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-absA * absA));\n`, Rz = `\n if (a >= 0.0) {\n return ${P.backend_util.SELU_SCALE} * a;\n } else {\n return ${P.backend_util.SELU_SCALEALPHA} * (exp(a) - 1.0);\n }\n`; function Oz(e, t) { switch (e) { case Fz.ABS: return "return abs(a);"; case Fz.ACOS: return "\n if (abs(a) > 1.) {\n return uniforms.NAN;\n }\n return acos(a);\n"; case Fz.ACOSH: return "\n if (a < 1.) {\n return uniforms.NAN;\n }\n return acosh(a);\n"; case Fz.ASIN: return "\n if (abs(a) > 1.) {\n return uniforms.NAN;\n }\n return asin(a);\n"; case Fz.ASINH: return "return asinh(a);"; case Fz.ATAN: return "\n if (isnan(a)) {\n return uniforms.NAN;\n }\n return atan(a);\n"; case Fz.ATANH: return "\n if (abs(a) > 1.) {\n return uniforms.NAN;\n }\n if (a == 1.) {\n return uniforms.INFINITY;\n }\n if (a == -1.) {\n return -uniforms.INFINITY;\n }\n return atanh(a);\n"; case Fz.COS: return "return cos(a);"; case Fz.COSH: return "\n let e2x = exp(-a);\n return (e2x + 1.0 / e2x) / 2.0;\n"; case Fz.CEIL: return "return ceil(a);"; case Fz.ELU: return t ? "\n var resFloat = exp(a) - vec4(1.0);\n if (a.r >= 0.0) {\n resFloat.r = a.r;\n }\n if (a.g >= 0.0) {\n resFloat.g = a.g;\n }\n if (a.b >= 0.0) {\n resFloat.b = a.b;\n }\n if (a.a >= 0.0) {\n resFloat.a = a.a;\n }\n return resFloat;\n" : "if (a >= 0.0) { return a; } return (exp(a) - 1.0);"; case Fz.ERF: return $z; case Fz.EXP: return "return exp(a);"; case Fz.EXPM1: return "return exp(a) - 1.0;"; case Fz.FLOOR: return "return floor(a);"; case Fz.IS_FINITE: return "return f32(!isnan(a) && !isinf(a));"; case Fz.IS_INF: return "return f32(isinf(a));"; case Fz.IS_NAN: return "return f32(isnan(a));"; case Fz.LINEAR: return "return a;"; case Fz.LOG: return "if (a < 0.0) { return uniforms.NAN; }\n return log(a);"; case Fz.LOG1P: return "\n if (isnan(a)) { return a; }\n return log(1.0 + a);\n"; case Fz.LOGICAL_NOT: return "return f32(!(a >= 1.0));"; case Fz.NEG: return "return -a;"; case Fz.LEAKYRELU: return t ? "\n let aLessThanZero = vec4(a < vec4(0.0));\n return (aLessThanZero * (uniforms.alpha * a)) + ((vec4(1.0) - aLessThanZero) * a);\n" : "if (a < 0.0) { return uniforms.alpha * a; } return a;"; case Fz.RECIPROCAL: return "return 1.0 / a;"; case Fz.RELU: return t ? "\n return select(a, vec4(0.0), a < vec4(0.0));\n" : "return select(a, 0.0, a < 0.0);"; case Fz.RELU6: return t ? "return clamp(a, vec4(0.0, 0.0, 0.0, 0.0), vec4(6.0, 6.0, 6.0, 6.0));" : "return clamp(a, 0.0, 6.0);"; case Fz.ROUND: return "return round(a);"; case Fz.RSQRT: return "return inverseSqrt(a);"; case Fz.SELU: return Rz; case Fz.SIGMOID: return "return 1.0 / (1.0 + exp(-1.0 * a));"; case Fz.SIGN: return "return sign(a);"; case Fz.SIN: return "return sin(a);"; case Fz.SINH: return "\n let e2x = exp(a);\n return (e2x - 1.0 / e2x) / 2.0;\n"; case Fz.SOFTPLUS: return "\n let epsilon = 1.1920928955078125e-7;\n let threshold = log(epsilon) + 2.0;\n\n let too_large = a > -threshold;\n let too_small = a < threshold;\n let exp_a = exp(a);\n\n if (too_large) {\n return a;\n } else if (too_small) {\n return exp_a;\n } else {\n return log(exp_a + 1.0);\n }\n"; case Fz.SQRT: return "return sqrt(a);"; case Fz.SQUARE: return "return a * a;"; case Fz.STEP: return "\n if (isnan(a)) {\n return a;\n }\n\n return select(uniforms.stepAlpha, 1.0, a > 0.0);\n"; case Fz.TAN: return "return tan(a);"; case Fz.TANH: return "\n let e2x = exp(-2.0 * abs(a));\n return sign(a) * (1.0 - e2x) / (1.0 + e2x);\n"; case Fz.TO_INT: return "return f32(i32((a)));"; default: throw new Error(`BinaryType ${e} is not implemented!`) } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function zz(e, t = !1, n = !1, r = 3) { if (null === e) return ""; let i = ""; if ("linear" === e) i = Oz(Fz.LINEAR); else if ("relu" === e) i = Oz(Fz.RELU, n); else if ("elu" === e) i = Oz(Fz.ELU, n); else if ("relu6" === e) i = Oz(Fz.RELU6, n); else if ("prelu" === e) i = Mz(Nz.PRELU, n); else if ("sigmoid" === e) i = Oz(Fz.SIGMOID, n); else { if ("leakyrelu" !== e) throw new Error(`Activation ${e} has not been implemented for the WebGPU backend.`); i = Oz(Fz.LEAKYRELU, n) } const a = az(n ? 4 : 1); let o = ""; return o = t ? `\n fn activation(a : ${a}, coords : vec${r}) -> ${a} {\n let b = getPreluActivationWeightsByOutputCoords(coords);\n ${i}\n }` : `\n fn activation(a : ${a}, coords : vec${r}) -> ${a} {\n ${i}\n }`, o } function Pz(e, t) { return `\n ${e ? "value = value + getBiasByOutputCoords(coords);" : ""}\n ${t ? "value = activation(value, coords);" : ""}\n ` } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Bz(e, t, n = !1, r = !1, i = !1, a = 1) { P.util.assert(e && 1 === a || !e, (() => `transposeA ${e} is not compatible with component size ${a}`)); const o = `\n ${e ? "value = getA(batch, col, row);" : "value = getA(batch, row, col);"}\n\n `, s = t ? "value = getB(batch, col, row);" : "value = getB(batch, row, col);"; return `\n fn mm_readA(batch: i32, row: i32, col: i32) -> ${az(a)} {\n var value = ${az(a)}(0.0);\n ${n && i ? o : `\n ${e ? "if(row < uniforms.dimAOuter && col < uniforms.dimInner)" : "if(row < uniforms.aShape[1] && col < uniforms.aShape[2])"}\n {\n ${o}\n }\n `}\n return value;\n }\n\n fn mm_readB(batch: i32, row: i32, col: i32) -> ${az(a)} {\n var value = ${az(a)}(0.0);\n ${s}\n return value;\n }\n ` } function Lz(e, t, n, r, i = !1, a = !1, o = !1, s = 1) { return `\n ${Bz(n, r, i, a, o, s)}\n fn mm_write(batch: i32, row: i32, col: i32, valueIn: ${az(s)}) {\n ${i && a ? "" : "if (row < uniforms.dimAOuter && col < uniforms.dimBOuter)"}\n {\n var value = valueIn;\n let coords = vec3(batch, row, col);\n ${Pz(e, t)}\n setOutputAtCoords(coords[0], coords[1], coords[2], value);\n }\n }\n ` } function jz(e, t, n = !1, r = 32, i = !1, a = 32, o = !1) { const s = t[1] * e[1], u = t[0] * e[0], l = n ? s : r, c = n ? r : s, h = l / t[0], d = r / t[1], f = e[1], p = e[0]; return P.util.assert((n && 4 === h && 4 === e[1] || !n && (3 === h || 4 === h)) && l % t[0] == 0 && r % t[1] == 0 && 4 === e[0], (() => `If transposeA ${n} is true, innerElementSize ${h} and workPerThread[1] ${e[1]} must be 4.\n Otherwise, innerElementSize ${h} must be 3 or 4.\n tileAWidth ${l} must be divisible by workgroupSize[0]${t[0]}. tileInner ${r} must be divisible by workgroupSize[1] ${t[1]}. colPerThread ${e[0]} must be 4.`)), `\n var mm_Asub : array, ${l / h}>, ${c}>;\n var mm_Bsub : array, ${u / e[0]}>, ${r}>;\n\n ${uz()} {\n let localRow = i32(localId.y);\n let tileRow = localRow * ${f};\n let tileCol = i32(localId.x);\n\n let globalRow = i32(globalId.y) * ${f};\n let globalCol = i32(globalId.x) * ${p};\n let batch = ${i ? "0" : "i32(globalId.z)"};\n let batchA = ${i || !o ? "batch" : "batch % uniforms.aShape[0]"};\n let batchB = ${i || !o ? "batch" : "batch % uniforms.bShape[0]"};\n let globalRowStart = i32(workgroupId.y) * ${s};\n\n let numTiles = ${i ? `${Math.ceil(a / r)}` : `(uniforms.dimInner - 1) / ${r} + 1`};\n var kStart = ${i ? `i32(globalId.z) * ${a}` : "0"};\n\n var acc: array, ${f}>;\n\n // Loop over shared dimension.\n let tileRowB = localRow * ${d};\n for (var t = 0; t < numTiles; t++) {\n // Load one tile of A into local memory.\n for (var innerRow = 0; innerRow < ${f}; innerRow++) {\n let inputRow = tileRow + innerRow;\n let inputCol = tileCol;\n ${((e, t) => e ? `\n mm_Asub[inputRow][inputCol] = mm_readA(batchA,\n kStart + inputRow,\n globalRowStart + inputCol * ${t});\n ` : `\n mm_Asub[inputRow][inputCol] = mm_readA(batchA,\n globalRow + innerRow,\n kStart + inputCol * ${t});\n `)(n, h)}\n }\n\n // Load one tile of B into local memory.\n for (var innerRow = 0; innerRow < ${d}; innerRow++) {\n let inputRow = tileRowB + innerRow;\n let inputCol = tileCol;\n mm_Bsub[inputRow][inputCol] = mm_readB(batchB, kStart + inputRow, globalCol);\n }\n kStart = kStart + ${r};\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n ${((e, t, n, r) => { if (e) return `\n for (var k = 0; k < ${r}; k++) {\n let BCached0 = mm_Bsub[k][tileCol];\n let ACached0 = mm_Asub[k][localRow];\n for (var i = 0; i < ${n}; i++) {\n acc[i] = fma(BCached0, vec4(ACached0[i]), acc[i]);\n }\n }`; { let e = "", i = ""; for (let n = 0; n < t; n++)e += `let BCached${n} = mm_Bsub[k * ${t} + ${n}][tileCol];`, i += `acc[i] = fma(BCached${n}, vec4(ACached[${n}]), acc[i]);`; return `\n for (var k = 0; k < ${r / t}; k++) {\n ${e}\n for (var i = 0; i < ${n}; i++) {\n let ACached = mm_Asub[tileRow + i][k];\n ${i}\n }\n }` } })(n, h, f, r)}\n workgroupBarrier();\n }\n\n for (var innerRow = 0; innerRow < ${f}; innerRow++) {\n mm_write(batch, globalRow + innerRow, globalCol, acc[innerRow]);\n }\n }` } const Uz = e => e ? "\n mm_Asub[inputRow][inputCol] = mm_readA(batchA,\n kStart + inputRow,\n globalRowStart + inputCol);\n " : "\n mm_Asub[inputRow][inputCol] = mm_readA(batchA,\n globalRowStart + inputRow,\n kStart + inputCol);\n "; function Wz(e, t, n = !1, r = 32, i = !1, a = 32, o = !1, s = !1) { const u = e[1] * t[1], l = e[0] * t[0], c = n ? u : r, h = n ? r : u; P.util.assert(h % t[1] == 0 && c % t[0] == 0 && r % t[1] == 0, (() => `tileAHight ${h} must be divisible by workgroupSize[1]${t[1]}, tileAWidth ${c} must be divisible by workgroupSize[0]${t[0]}, tileInner ${r} must be divisible by workgroupSize[1]${t[1]}`)); const d = h / t[1], f = c / t[0], p = r / t[1], m = e[1], g = e[0], y = o ? `\n let localRow = i32(localId.y);\n let localCol = i32(localId.x);\n let globalRowStart = i32(workgroupId.y) * ${u};\n let globalColStart = i32(workgroupId.x) * ${l};\n\n // Loop over shared dimension.\n for (var t = 0; t < numTiles; t++) {\n // Load one tile of A into local memory.\n for (var inputRow = localRow; inputRow < ${h}; inputRow = inputRow + ${t[1]}) {\n for (var inputCol = localCol; inputCol < ${c}; inputCol = inputCol + ${t[0]}) {\n ${Uz(n)}\n }\n }\n // Load one tile of B into local memory.\n for (var inputRow = localRow; inputRow < ${r}; inputRow = inputRow + ${t[1]}) {\n for (var inputCol = localCol; inputCol < ${l}; inputCol = inputCol + ${t[0]}) {\n mm_Bsub[inputRow][inputCol] = mm_readB(batchB,\n kStart + inputRow,\n globalColStart + inputCol);\n }\n }\n kStart = kStart + ${r};\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n var BCached : array;\n for (var k = 0; k < ${r}; k++) {\n for (var inner = 0; inner < ${g}; inner++) {\n BCached[inner] = mm_Bsub[k][localCol + inner * ${t[0]}];\n }\n for (var innerRow = 0; innerRow < ${m}; innerRow++) {\n let ACached = ${n ? `mm_Asub[k][localRow + innerRow * ${t[1]}];` : `mm_Asub[localRow + innerRow * ${t[1]}][k];`}\n for (var innerCol = 0; innerCol < ${g}; innerCol++) {\n acc[innerRow][innerCol] =\n fma(ACached, BCached[innerCol], acc[innerRow][innerCol]);\n }\n }\n }\n workgroupBarrier();\n }\n for (var innerRow = 0; innerRow < ${m}; innerRow++) {\n let gRow = globalRowStart + localRow + innerRow * ${t[1]};\n for (var innerCol = 0; innerCol < ${g}; innerCol++) {\n let gCol = globalColStart + localCol + innerCol * ${t[0]};\n mm_write(batch, gRow, gCol, acc[innerRow][innerCol]);\n }\n }\n ` : `\n let tileRow = i32(localId.y) * ${m};\n let tileCol = i32(localId.x) * ${g};\n\n let globalRow = i32(globalId.y) * ${m};\n let globalCol = i32(globalId.x) * ${g};\n let globalRowStart = i32(workgroupId.y) * ${u};\n\n let tileRowA = i32(localId.y) * ${d};\n let tileColA = i32(localId.x) * ${f};\n let tileRowB = i32(localId.y) * ${p};\n // Loop over shared dimension.\n for (var t = 0; t < numTiles; t++) {\n // Load one tile of A into local memory.\n for (var innerRow = 0; innerRow < ${d}; innerRow++) {\n for (var innerCol = 0; innerCol < ${f}; innerCol++) {\n let inputRow = tileRowA + innerRow;\n let inputCol = tileColA + innerCol;\n ${Uz(n)}\n }\n }\n\n // Load one tile of B into local memory.\n for (var innerRow = 0; innerRow < ${p}; innerRow++) {\n for (var innerCol = 0; innerCol < ${g}; innerCol++) {\n let inputRow = tileRowB + innerRow;\n let inputCol = tileCol + innerCol;\n mm_Bsub[inputRow][inputCol] = mm_readB(batchB,\n kStart + inputRow,\n globalCol + innerCol);\n }\n }\n kStart = kStart + ${r};\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n var BCached : array;\n for (var k = 0; k < ${r}; k++) {\n for (var inner = 0; inner < ${g}; inner++) {\n BCached[inner] = mm_Bsub[k][tileCol + inner];\n }\n\n for (var innerRow = 0; innerRow < ${m}; innerRow++) {\n ${(e => e ? "let ACached = mm_Asub[k][tileRow + innerRow];" : "let ACached = mm_Asub[tileRow + innerRow][k];")(n)}\n for (var innerCol = 0; innerCol < ${g}; innerCol++) {\n acc[innerRow][innerCol] =\n fma(ACached, BCached[innerCol], acc[innerRow][innerCol]);\n }\n }\n }\n\n workgroupBarrier();\n }\n\n for (var innerRow = 0; innerRow < ${m}; innerRow++) {\n for (var innerCol = 0; innerCol < ${g}; innerCol++) {\n mm_write(batch, globalRow + innerRow, globalCol + innerCol,\n acc[innerRow][innerCol]);\n }\n }\n `; return `\n var mm_Asub : array, ${h}>;\n var mm_Bsub : array, ${r}>;\n\n ${uz()} {\n let batch = ${i ? "0" : "i32(globalId.z)"};\n let batchA = ${i || !s ? "batch" : "batch % uniforms.aShape[0]"};\n let batchB = ${i || !s ? "batch" : "batch % uniforms.bShape[0]"};\n let numTiles = ${i ? `${Math.ceil(a / r)}` : `(uniforms.dimInner - 1) / ${r} + 1`};\n var kStart = ${i ? `i32(globalId.z) * ${a}` : "0"};\n\n var acc : array, ${m}>;\n\n // Without this initialization strange values show up in acc.\n for (var innerRow = 0; innerRow < ${m}; innerRow++) {\n for (var innerCol = 0; innerCol < ${g}; innerCol++) {\n acc[innerRow][innerCol] = 0.0;\n }\n }\n ${y}\n }\n ` } class Vz { constructor(e, t, n = !1, r = !1, i = null, a = null, o = null, s = !1) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = t, this.dispatchLayout = { x: [2], y: [1], z: [0] }; const u = n ? e[1] : e[2]; if (this.isVec4 = (u % 4 == 0 && !n || t[1] % 4 == 0 && n) && t[2] % 4 == 0 && !r, this.outputComponent = this.isVec4 ? 4 : 1, this.isVectorA = 1 === t[1] && !n, !this.isVec4 && this.isVectorA) this.elementsPerThread = [1, 1, 1], this.workgroupSize = [32, 1, 1]; else { const e = function (e, t, n, r = !1) { const i = [8, 8, 1], a = [4, 4, 1]; return r || (e <= 8 && (a[1] = 1), t <= 16 && n <= 16 && (i[0] = 4)), { workgroupSize: i, elementsPerThread: a } }(t[1], u, t[2], n); this.workgroupSize = e.workgroupSize, this.elementsPerThread = e.elementsPerThread } this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, this.elementsPerThread); const l = null != i, c = null != o; l && this.variableNames.push("bias"), c && this.variableNames.push("preluActivationWeights"), this.sequentialAccessByThreads = s, this.transposeA = n, this.transposeB = r, this.addBias = l, this.activation = a, this.hasPreluActivationWeights = c, [this.fitAOuter, this.fitBOuter, this.fitInner] = this.getShapeFit(t[1], t[2], u), this.shaderKey = `matMulPacked_${this.elementsPerThread}_${n}_${r}_${this.activation}_${this.fitAOuter}_${this.fitBOuter}_${this.fitInner}_${this.isVec4}_${this.isVectorA}_${this.sequentialAccessByThreads}` } getShapeFit(e, t, n) { const r = this.workgroupSize[1] * this.elementsPerThread[1], i = this.workgroupSize[0] * this.elementsPerThread[0]; !this.isVec4 && this.isVectorA ? this.tileInner = 4 * this.workgroupSize[0] : this.tileInner = i; return [e % r == 0, t % i == 0, n % this.tileInner == 0] } getUserCode() { return `\n ${zz(this.activation, this.hasPreluActivationWeights, this.isVec4)}\n ${Lz(this.addBias, this.activation, !1, this.transposeB, this.fitAOuter, this.fitBOuter, this.fitInner, this.isVec4 ? 4 : 1)}\n ${this.isVec4 ? jz(this.elementsPerThread, this.workgroupSize, this.transposeA, this.tileInner, !1, null, !0) : this.isVectorA ? function (e, t = !1) { P.util.assert(1 === e[1] && 1 === e[2], (() => `A linear work group size is required. But got ${e}.`)); const n = 4 * e[0]; return `\n var mm_Asub : array, ${e[0]}>;\n\n ${uz()} {\n let tileCol = i32(localId.x);\n let globalCol = i32(globalId.x);\n let globalRow = i32(globalId.y);\n\n let numTiles = (uniforms.dimInner - 1) / ${n} + 1;\n let batch = i32(globalId.z);\n let batchA = batch % uniforms.aShape[0];\n let batchB = batch % uniforms.bShape[0];\n // Without this initialization strange values show up in acc.\n var acc = 0.0;\n\n // Loop over shared dimension.\n for (var t = 0; t < numTiles; t++) {\n // Load one tile of A into local memory.\n let colA = t * ${n} + tileCol * 4;\n mm_Asub[tileCol] = vec4(${r = t, r ? "\n mm_readA(batchA, colA, globalRow),\n mm_readA(batchA, colA + 1, globalRow),\n mm_readA(batchA, colA + 2, globalRow),\n mm_readA(batchA, colA + 3, globalRow)\n " : "\n mm_readA(batchA, globalRow, colA),\n mm_readA(batchA, globalRow, colA + 1),\n mm_readA(batchA, globalRow, colA + 2),\n mm_readA(batchA, globalRow, colA + 3)\n "});\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n for (var k = 0; k < ${n / 4}; k++) {\n let rowB = t * ${n} + k * 4;\n let BCached = vec4(mm_readB(batchB, rowB, globalCol),\n mm_readB(batchB, rowB + 1, globalCol),\n mm_readB(batchB, rowB + 2, globalCol),\n mm_readB(batchB, rowB + 3, globalCol));\n\n let ACached = mm_Asub[k];\n acc = acc + dot(ACached, BCached);\n }\n\n workgroupBarrier();\n }\n\n mm_write(batch, globalRow, globalCol, acc);\n }\n `; var r }(this.workgroupSize, this.transposeA) : Wz(this.elementsPerThread, this.workgroupSize, this.transposeA, this.tileInner, !1, null, this.sequentialAccessByThreads, !0)}\n ` } } class Gz { + constructor(e, t = !1, n = !1, r = null, i = null, a = null) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workgroupSize = [256, 1, 1], this.outputShape = e, this.dispatchLayout = { x: [], y: [1, 2], z: [0] }, this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize); const o = null != r, s = null != a; o && this.variableNames.push("bias"), s && this.variableNames.push("preluActivationWeights"), this.transposeA = t, this.transposeB = n, this.addBias = o, this.activation = i, this.hasPreluActivationWeights = s, this.shaderKey = `matMulReduce_${this.activation}_${t}_${n}` } getUserCode() { + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var e; return `\n ${zz(this.activation, this.hasPreluActivationWeights)}\n ${Lz(this.addBias, this.activation, this.transposeA, this.transposeB)}\n ${e = this.workgroupSize[0], `\n var sumValues : array;\n ${uz()} {\n let coords = getOutputCoords();\n let batch = coords[0];\n let batchA = batch % uniforms.aShape[0];\n let batchB = batch % uniforms.bShape[0];\n let row = coords[1];\n let col = coords[2];\n var sum = 0.0;\n let Length = uniforms.dimInner;\n for (var k = i32(localId.x); k < Length; k = k + ${e}) {\n let dataA = mm_readA(batchA, row, k);\n let dataB = mm_readB(batchB, k, col);\n sum = sum + dataA * dataB;\n }\n sumValues[localId.x] = sum;\n workgroupBarrier();\n\n for(var currentSize = ${e / 2}u; currentSize > 1u;\n currentSize = currentSize / 2u) {\n if (localId.x < currentSize)\n {\n sumValues[localId.x] = sumValues[localId.x] + sumValues[localId.x + currentSize];\n }\n workgroupBarrier();\n }\n\n if (localId.x == 0u) {\n sum = sumValues[0] + sumValues[1];\n mm_write(batch, row, col, sum);\n }\n }\n `}\n ` + } + } class Hz { + constructor(e, t, n, r = !1, i = !1, a = null, o = null, s = null) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workgroupSize = [16, 8, 1], this.outputShape = n, this.dispatchLayout = { x: [2], y: [1], z: [0] }, this.dispatch = [Math.ceil(n[2] / this.workgroupSize[0]), Math.ceil(n[1] / this.workgroupSize[1]), n[0]]; const u = null != a; u && this.variableNames.push("bias"); const l = null != s; l && this.variableNames.push("preluActivationWeights"), this.transposeA = r, this.transposeB = i, this.addBias = u, this.activation = o, this.hasPreluActivationWeights = l, this.shaderKey = `matMulSmallOutputSize_${this.activation}_${r}_${i}` } getUserCode() { + return `\n ${zz(this.activation, this.hasPreluActivationWeights)}\n ${Lz(this.addBias, this.activation, this.transposeA, this.transposeB)}\n ${ + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const t = e[1], n = e[0], r = t > n ? t : n; return `\n var mm_Asub : array, ${t}>;\n var mm_Bsub : array, ${r}>;\n\n // If the output size is small for matrix multiplication, avoid to use vec4\n // and handle some elements per thread to optimally utilize the ALU.\n // Read data from global memory to registers firstly, then store them into\n // shared memory, so it is instruction-Level parallelism for arithmetic\n // operations and others handle IO operations between barrier api, makes ALU\n // and load/store units work simultaneously, could improves the performance.\n ${uz()} {\n let tileRow = i32(localId.y);\n let tileCol = i32(localId.x);\n let globalRow = i32(globalId.y);\n let globalCol = i32(globalId.x);\n let batch = i32(globalId.z);\n let batchA = batch % uniforms.aShape[0];\n let batchB = batch % uniforms.bShape[0];\n\n // uniforms.dimInner should be greater than 0.\n let numTiles = (uniforms.dimInner - 1) / ${r} + 1;\n var acc = 0.0;\n\n var globalColA = tileCol;\n var globalRowB = 0;\n var regA = mm_readA(batchA, globalRow, globalColA);\n var regB0 = mm_readB(batchB, globalRowB + 2 * tileRow, globalCol);\n var regB1 = mm_readB(batchB, globalRowB + 2 * tileRow + 1, globalCol);\n globalColA = globalColA + ${r};\n globalRowB = globalRowB + ${r};\n\n for (var t = 0; t < numTiles; t = t + 1) {\n mm_Asub[tileRow][tileCol] = regA;\n mm_Bsub[2 * tileRow][tileCol] = regB0;\n mm_Bsub[2 * tileRow + 1][tileCol] = regB1;\n\n workgroupBarrier();\n\n regA = mm_readA(batchA, globalRow, globalColA);\n regB0 = mm_readB(batchB, globalRowB + 2 * tileRow, globalCol);\n regB1 = mm_readB(batchB, globalRowB + 2 * tileRow + 1, globalCol);\n globalColA = globalColA + ${r};\n globalRowB = globalRowB + ${r};\n\n for (var k = 0; k < ${r}; k = k + 1) {\n acc = acc + mm_Asub[tileRow][k] * mm_Bsub[k][tileCol];\n }\n workgroupBarrier();\n }\n\n mm_write(batch, globalRow, globalCol, acc);\n }\n ` }(this.workgroupSize)}\n ` + } + } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class qz { constructor(e, t, n = !1, r = !1) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workgroupSize = [8, 8, 1], this.atomic = !0, this.splitedDimInner = 128, P.util.assert(1 === e[0], (() => "MatMulSplitKProgram only supports batch = 1.")), this.outputShape = e, this.dispatchLayout = { x: [2], y: [1], z: [0, 3] }; const i = (n && this.outputShape[1] % 4 == 0 || !n && t % 4 == 0) && this.outputShape[2] % 4 == 0; this.elementsPerThread = [4, 4, this.splitedDimInner], this.outputComponent = i ? 4 : 1, i || (this.outputShape[1] < 16 && (this.elementsPerThread[1] = 1), this.outputShape[2] < 16 && (this.elementsPerThread[0] = 1)), this.dispatch = bz(this.dispatchLayout, [this.outputShape[0], this.outputShape[1], this.outputShape[2], t], this.workgroupSize, this.elementsPerThread), this.transposeA = n, this.transposeB = r, this.shaderKey = `matMulSplitK_${n}_${r}_${this.elementsPerThread}_${this.outputComponent}` } getUserCode() { const e = this.outputComponent; return `\n ${Bz(!1, this.transposeB, !1, !1, !1, e)}\n fn mm_write(batch: i32, row : i32, col : i32, value : ${az(e)}) {\n if (row < uniforms.dimAOuter && col < uniforms.dimBOuter) {\n let coords = vec3(batch, row, col);\n let flatIndex = getOutputIndexFromCoords(coords);\n // The problem is that we should initialize output to zero before using.\n // Otherwise, the original value will be added to the result.\n for (var i = 0; i < ${e}; i = i + 1) {\n ${tz("&result[flatIndex + i]", "" + (e > 1 ? "value[i]" : "value"), "float32")}\n }\n }\n }\n ${4 === e ? jz(this.elementsPerThread, this.workgroupSize, this.transposeA, 32, !0, this.splitedDimInner) : Wz(this.elementsPerThread, this.workgroupSize, this.transposeA, 32, !0, this.splitedDimInner)}\n ` } } class Yz { constructor(e, t = null, n = null, r = null) { this.uniforms = "", this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.addBias = null != t, this.hasPreluActivationWeights = null != r, this.activation = n, this.addBias && this.variableNames.push("bias"), this.hasPreluActivationWeights && this.variableNames.push("preluActivationWeights"), this.shaderKey = `biasActivation_${n}` } getUserCode() { return `\n ${zz(this.activation, this.hasPreluActivationWeights)}\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n var value = getXByOutputIndex(index);\n ${Pz(this.addBias, this.activation)}\n setOutputAtIndex(index, value);\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Xz { constructor(e) { this.variableNames = [], this.outputShape = [], this.uniforms = "value : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "fill" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n setOutputAtIndex(index, uniforms.value);\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Kz(e) { const { backend: t, attrs: n } = e, { shape: r, value: i } = n; let { dtype: a } = n; if (a = a || P.util.inferDtype(i), "string" === a) { const e = P.util.getArrayFromDType(a, P.util.sizeFromShape(r)); return e.fill(i), t.makeTensorInfo(r, a, e) } { const e = new Xz(r), n = [{ type: "float32", data: [i] }]; return t.runWebGPUProgram(e, [], a, n) } } const Zz = { kernelName: P.Fill, backendName: "webgpu", kernelFunc: Kz }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Jz(e) { const { inputs: t, attrs: n } = e, { x: r } = t, { shape: i } = n, a = P.util.sizeFromShape(r.shape), o = P.util.inferFromImplicitShape(i, a), s = P.util.sizeFromShape(o); return P.util.assert(a === s, (() => `The new shape (${o}) has ${s} elements and the old shape (${r.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`)), e.backend.incRef(r.dataId), { dataId: r.dataId, shape: o, dtype: r.dtype } } const Qz = { kernelName: P.Reshape, backendName: "webgpu", kernelFunc: Jz }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function eP({ a: e, b: t, transposeA: n, transposeB: r, backend: i, bias: a = null, preluActivationWeights: o = null, leakyreluAlpha: s = 0, activation: u = null }) { const l = e.shape.length, c = t.shape.length, h = n ? e.shape[l - 2] : e.shape[l - 1], d = r ? t.shape[c - 1] : t.shape[c - 2], f = n ? e.shape[l - 1] : e.shape[l - 2], p = r ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), y = P.util.sizeFromShape(m), b = P.util.sizeFromShape(g), v = P.broadcast_util.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([f, p]); P.util.assert(h === d, (() => `Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`)); const x = n ? [y, h, f] : [y, f, h], w = r ? [b, p, d] : [b, d, p], k = Jz({ inputs: { x: e }, backend: i, attrs: { shape: x } }), S = Jz({ inputs: { x: t }, backend: i, attrs: { shape: w } }), _ = [k, S], C = Math.max(y, b), A = [k, S], T = [{ type: "int32", data: [f] }, { type: "int32", data: [p] }, { type: "int32", data: [h] }]; let E, N; const I = [C, f, p]; let M = (0, P.env)().get("WEBGPU_MATMUL_PROGRAM_TYPE"); if (M < 0) { const e = (0, P.env)().getNumber("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL"), t = e > 0 ? e : i.thresholdToIncreaseWorkgroups, n = C * Math.ceil(f / 32) * Math.ceil(p / 32); M = n <= t || f <= 8 && n <= 2 * t ? C * f * p <= 128 ? Cz.MatMulReduceProgram : 1 === C && d >= 2e3 ? Cz.MatMulSplitKProgram : Cz.MatMulSmallOutputSizeProgram : Cz.MatMulPackedProgram } switch (M) { case Cz.MatMulReduceProgram: E = new Gz(I, n, r, a, u, o); break; case Cz.MatMulSplitKProgram: if (N = Kz({ backend: i, attrs: { shape: I, value: 0, dtype: e.dtype } }), E = new qz(I, d, n, r), a || u) { N = i.runWebGPUProgram(E, A, e.dtype, T, N); const t = new Yz(N.shape, a, u, o); let n = null; const r = [N]; a && r.push(a), o && r.push(o), "leakyrelu" === u && (n = [{ type: "float32", data: [s] }], t.uniforms += " alpha : f32,"); const l = i.runWebGPUProgram(t, r, N.dtype, n); _.push(N); const c = Jz({ inputs: { x: l }, backend: i, attrs: { shape: v } }); _.push(l); for (const e of _) i.disposeData(e.dataId); return c } break; case Cz.MatMulSmallOutputSizeProgram: E = new Hz(x, w, I, n, r, a, u, o); break; case Cz.MatMulPackedProgram: const t = i.adapterInfo.isIntel(); E = new Vz(x, I, n, r, a, u, o, t); break; default: throw new Error(`Unsupported MatMulProgramType ${M}.`) }a && A.push(a), o && A.push(o), "leakyrelu" === u && (T.push({ type: "float32", data: [s] }), E.uniforms += " alpha : f32,"), N = i.runWebGPUProgram(E, A, e.dtype, T, N); const F = Jz({ inputs: { x: N }, backend: i, attrs: { shape: v } }); _.push(N); for (const e of _) i.disposeData(e.dataId); return F } const tP = { + kernelName: P._FusedMatMul, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a, bias: o, preluActivationWeights: s } = t, { transposeA: u, transposeB: l, activation: c, leakyreluAlpha: h } = r; return eP({ a: i, b: a, transposeA: u, transposeB: l, backend: n, bias: o, preluActivationWeights: s, leakyreluAlpha: h, activation: c }) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class nP { constructor(e, t, n) { this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.workgroupSize = [128, 1, 1], this.size = !0, this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n), this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = `binaryOpComplex_${e}`, this.op = e } getUserCode() { return `\n fn binaryOpComplex(\n areal : f32, aimag : f32, breal : f32, bimag : f32) -> f32 {\n ${Mz(this.op, !1)}\n }\n\n ${uz("index")} {\n if(index < uniforms.size) {\n let areal = getARealByOutputIndex(index);\n let aimag = getAImagByOutputIndex(index);\n let breal = getBRealByOutputIndex(index);\n let bimag = getBImagByOutputIndex(index);\n setOutputAtIndex(index, binaryOpComplex(areal, aimag, breal, bimag));\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rP { constructor(e, t, n) { if (this.size = !0, this.variableNames = ["A", "B"], this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n), this.dispatchLayout = wz(this.outputShape), this.op = e, this.useSharedMemoryWithA = t.length <= 1 && n.length > 1 && t[0] < 128, this.useSharedMemoryWithB = n.length <= 1 && t.length > 1 && n[0] < 128, this.useSharedMemoryWithA || this.useSharedMemoryWithB) this.outputComponent = 1, this.variableComponents = [1, 1], this.lastDimensionSize = this.useSharedMemoryWithB ? n[0] : t[0], this.shaderKey = `binary_${e}_${this.lastDimensionSize}`, this.type = "shared", this.workgroupSize = [256, 1, 1]; else { const r = t.length > 0 && t[t.length - 1] % 4 == 0, i = n.length > 0 && n[n.length - 1] % 4 == 0; r && i ? (this.outputComponent = 4, this.variableComponents = [4, 4]) : r && (P.util.isScalarShape(n) || 1 === n[n.length - 1]) || i && (P.util.isScalarShape(t) || 1 === t[t.length - 1]) ? (this.outputComponent = 4, this.variableComponents = r ? [4, 1] : [1, 4]) : (this.outputComponent = 1, this.variableComponents = [1, 1]), this.type = "nonshared", this.shaderKey = `binary_${e}_${this.variableComponents}`, this.workgroupSize = [128, 1, 1] } this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.outputComponent, 1, 1]) } getUserCode() { let e; const t = 4 === this.outputComponent ? "vec4" : "f32", n = `\n fn binaryOperation(a : ${t}, b : ${t}) -> ${t} {\n ${Mz(this.op, 4 === this.outputComponent)}\n };\n `; if ("shared" === this.type) { const t = this.lastDimensionSize > 1 ? `coords[${this.outputShape.length - 1}]` : "0", r = this.useSharedMemoryWithB ? `let a = getAByOutputIndex(index);\n let b = sharedBuf[${t}];` : `let a = sharedBuf[${t}];\n let b = getBByOutputIndex(index);`; e = `\n ${n}\n var sharedBuf : array;\n ${uz("index")} {\n // Fill in the shared memory buffer.\n let localIndex = i32(localId.x);\n if(localIndex < ${this.lastDimensionSize}) {\n sharedBuf[localIndex] = f32(${this.useSharedMemoryWithB ? "B" : "A"}[localIndex]);\n }\n workgroupBarrier();\n\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n ${r}\n setOutputAtIndex(index, binaryOperation(a, b));\n }\n }\n ` } else e = `\n ${n}\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index * ${this.outputComponent});\n let a = ${t}(getAByOutputCoords(coords));\n let b = ${t}(getBByOutputCoords(coords));\n setOutputAtIndex(index, binaryOperation(a, b));\n }\n }\n `; return e } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function iP(e) { const { inputs: t } = e, { x: n } = t; return e.backend.incRef(n.dataId), { dataId: n.dataId, shape: n.shape, dtype: n.dtype } } const aP = { kernelName: P.Identity, backendName: "webgpu", kernelFunc: iP }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function oP(e) { const { inputs: t, backend: n } = e, { real: r, imag: i } = t, a = n.makeTensorInfo(r.shape, "complex64"), o = n.tensorMap.get(a.dataId), s = iP({ inputs: { x: r }, backend: n }), u = iP({ inputs: { x: i }, backend: n }); return o.complexTensorInfos = { real: s, imag: u }, a } const sP = { kernelName: P.Complex, backendName: "webgpu", kernelFunc: oP }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class uP { constructor(e, t, n = "") { this.variableNames = ["A"], this.size = !0; this.workgroupSize = [128, 1, 1], this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.op = t, "" !== n && (this.uniforms = n), this.shaderKey = `unary_${t}` } getUserCode() { return `\n fn unaryOperation(a : f32) -> f32 {\n ${Oz(this.op, !1)}\n }\n ${uz("index")} {\n if (index < uniforms.size) {\n let a = getAByOutputIndex(index);\n setOutputAtIndex(index, unaryOperation(a));\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function lP({ opType: e, cpuKernelImpl: t, dtype: n }) { return ({ inputs: r, backend: i }) => { const { x: a } = r, o = i, s = n || a.dtype; if (o.shouldExecuteOnCPU([a]) && null != t) { const e = o.tensorMap.get(a.dataId), n = t(e.values, s); return o.makeTensorInfo(a.shape, s, n) } const u = new uP(a.shape, e); return o.runWebGPUProgram(u, [a], s) } } function cP({ opType: e, cpuKernelImpl: t, supportsComplex: n = !1, dtype: r }) { return ({ inputs: i, backend: a }) => { const { a: o, b: s } = i, u = a; if (n && "complex64" === o.dtype) { const t = u.tensorMap.get(o.dataId), n = u.tensorMap.get(s.dataId); let r, i; if (e !== Nz.MUL) [r, i] = [[t.complexTensorInfos.real, n.complexTensorInfos.real], [t.complexTensorInfos.imag, n.complexTensorInfos.imag]].map((t => { const [n, r] = t, i = { dataId: n.dataId, dtype: n.dtype, shape: o.shape }, a = { dataId: r.dataId, dtype: r.dtype, shape: s.shape }, l = new rP(e, o.shape, s.shape); return u.runWebGPUProgram(l, [i, a], (0, P.upcastType)(n.dtype, r.dtype)) })); else { const e = new nP(Nz.COMPLEX_MULTIPLY_REAL, o.shape, s.shape), a = new nP(Nz.COMPLEX_MULTIPLY_IMAG, o.shape, s.shape), l = [{ dataId: t.complexTensorInfos.real.dataId, dtype: t.complexTensorInfos.real.dtype, shape: o.shape }, { dataId: t.complexTensorInfos.imag.dataId, dtype: t.complexTensorInfos.imag.dtype, shape: o.shape }, { dataId: n.complexTensorInfos.real.dataId, dtype: n.complexTensorInfos.real.dtype, shape: s.shape }, { dataId: n.complexTensorInfos.imag.dataId, dtype: n.complexTensorInfos.imag.dtype, shape: s.shape }]; r = u.runWebGPUProgram(e, l, "float32"), i = u.runWebGPUProgram(a, l, "float32") } const a = oP({ inputs: { real: r, imag: i }, backend: u }); return u.disposeData(r.dataId), u.disposeData(i.dataId), a } const l = r || (0, P.upcastType)(o.dtype, s.dtype); if (("string" === o.dtype || "string" === s.dtype || u.shouldExecuteOnCPU([o, s])) && null != t) { const e = u.tensorMap.get(o.dataId).values, n = u.tensorMap.get(s.dataId).values, r = "string" === o.dtype ? P.backend_util.fromUint8ToStringArray(e) : e, i = "string" === o.dtype ? P.backend_util.fromUint8ToStringArray(n) : n, [a, c] = t(o.shape, s.shape, r, i, l); return u.makeTensorInfo(c, l, a) } const c = new rP(e, o.shape, s.shape); return u.runWebGPUProgram(c, [o, s], l) } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const { addImpl: hP, castImpl: dP, ceilImpl: fP, concatImpl: pP, equalImpl: mP, expImpl: gP, expm1Impl: yP, floorImpl: bP, floorDivImpl: vP, gatherNdImpl: xP, gatherV2Impl: wP, greaterEqualImpl: kP, greaterImpl: SP, lessEqualImpl: _P, lessImpl: CP, logImpl: AP, maxImpl: TP, maximumImpl: EP, minimumImpl: NP, multiplyImpl: IP, negImpl: MP, notEqualImpl: FP, prodImpl: DP, rangeImpl: $P, rsqrtImpl: RP, scatterImpl: OP, simpleAbsImpl: zP, sliceImpl: PP, stridedSliceImpl: BP, stringNGramsImpl: LP, subImpl: jP, tileImpl: UP, topKImpl: WP, transposeImpl: VP, uniqueImpl: GP } = N, HP = lP({ opType: Fz.ABS, cpuKernelImpl: zP }), qP = { kernelName: P.Abs, backendName: "webgpu", kernelFunc: HP }, YP = lP({ opType: Fz.ACOS }), XP = { kernelName: P.Acos, backendName: "webgpu", kernelFunc: YP }, KP = lP({ opType: Fz.ACOSH }), ZP = { kernelName: P.Acosh, backendName: "webgpu", kernelFunc: KP }, JP = cP({ opType: Nz.ADD, cpuKernelImpl: hP, supportsComplex: !0 }), QP = { kernelName: P.Add, backendName: "webgpu", kernelFunc: JP }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class eB { constructor(e) { this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e[0], this.variableNames = e.map(((e, t) => `T${t}`)), this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.shaderKey = "addN" } getUserCode() { const e = []; this.variableNames.forEach((t => { e.push(`let v${t} = get${t}ByOutputCoords(coords);`) })); const t = this.variableNames.map((e => `v${e}`)).join(" + "); return `\n ${uz("index")} {\n for (var i = 0; i < ${this.workPerThread}; i = i + 1) {\n let flatIndex = index * ${this.workPerThread} + i;\n if (flatIndex < uniforms.size) {\n let coords = getCoordsFromIndex(flatIndex);\n ${e.join("\n ")}\n setOutputAtIndex(flatIndex, ${t});\n }\n }\n }\n ` } } const tB = { + kernelName: P.AddN, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, r = t; if (1 === r.length) return iP({ inputs: { x: r[0] }, backend: n }); const i = r.map((e => e.dtype)).reduce(((e, t) => (0, P.upcastType)(e, t))), a = r.map((e => e.shape)), o = new eB(a); return n.runWebGPUProgram(o, r, i) } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class nB { constructor(e, t) { this.variableNames = ["A"], this.workgroupSize = [16, 16, 1]; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[t[r]]; this.outputShape = n, this.dispatchLayout = { x: [0], y: [1] }, this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [1, 1, 1]), this.shaderKey = "transposeShared" } getUserCode() { P.util.assert(this.workgroupSize[0] === this.workgroupSize[1], (() => `Must be a square tile, current tile shape is ${this.workgroupSize[0]} x ${this.workgroupSize[1]}`)); const e = this.workgroupSize[0]; return `\n var tile : array, ${this.workgroupSize[0]}>;\n ${uz()} {\n var x = i32(workgroupId.x) * ${e} + i32(localId.x);\n var y = i32(workgroupId.y) * ${e} + i32(localId.y);\n let width = uniforms.outShape[0];\n let height = uniforms.outShape[1];\n if (x < width && y < height) {\n tile[localId.y][localId.x] = f32(A[y * width + x]);\n }\n workgroupBarrier();\n\n x = i32(workgroupId.y) * ${e} + i32(localId.x);\n y = i32(workgroupId.x) * ${e} + i32(localId.y);\n if (x < height && y < width) {\n setOutputAtIndex((y * height + x), tile[localId.x]\n [localId.y]);\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rB { constructor(e, t) { this.variableNames = ["A"], this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[t[r]]; this.outputShape = n, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.newDim = t, this.shaderKey = `transpose_${t}` } getUserCode() { const e = oz(this.outputShape.length), t = iB(this.newDim); return `\n ${uz("index")} {\n for(var i = 0; i < ${this.workPerThread}; i = i + 1) {\n let flatIndex = index * ${this.workPerThread} + i;\n if(flatIndex < uniforms.size) {\n let coords = getCoordsFromIndex(flatIndex);\n setOutputAtIndex(flatIndex, A[getIndexFromCoords${this.outputShape.length}D(\n ${e}(${t}), uniforms.aShape)]);\n }\n }\n }\n ` } } function iB(e) { const t = e.length; if (t > 6) throw Error(`Transpose for rank ${t} is not yet supported`); const n = new Array(t); for (let t = 0; t < e.length; t++)n[e[t]] = `coords.${sz(t)}`; return n.join() } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function aB(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { perm: a } = r, o = n, s = i.shape.length, u = new Array(s); for (let e = 0; e < u.length; e++)u[e] = i.shape[a[e]]; if (n.shouldExecuteOnCPU([i])) { const e = o.tensorMap.get(i.dataId).values, t = VP(e, i.shape, i.dtype, a, u); return n.makeTensorInfo(u, i.dtype, t) } if (2 === i.shape.length && P.util.arraysEqual(a, [1, 0])) { const e = new nB(i.shape, a); return o.runWebGPUProgram(e, [i], i.dtype) } const l = new rB(i.shape, a); return o.runWebGPUProgram(l, [i], i.dtype) } const oB = { kernelName: P.Transpose, backendName: "webgpu", kernelFunc: aB }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class sB { constructor(e, t, n) { this.variableNames = ["x"], this.uniforms = "reduceSize : i32,", this.size = !0, this.inputShape = [e.batchSize, e.inSize]; const [r] = P.backend_util.computeOutAndReduceShapes(this.inputShape, [1]); this.outputShape = 0 === r.length ? [1] : r, e.inSize >= 32768 && n >= 512 ? this.workgroupSize = [512, 1, 1] : e.inSize >= 4096 ? this.workgroupSize = [256, 1, 1] : this.workgroupSize = [64, 1, 1], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, [1, 1, 1]), this.reduceType = t, this.shaderKey = `reduce_${t}` } getUserCode() { let e = "", t = "0.0"; const n = this.workgroupSize[0]; "min" === this.reduceType || "max" === this.reduceType ? (e = `\n if (isnan(candidate)) {\n bestValue = uniforms.NAN;\n } else if (!isnan(bestValue) && candidate ${"min" === this.reduceType ? "<" : ">"} bestValue)\n { bestValue = candidate; }`, t = "f32(x[offset])") : "sum" === this.reduceType || "mean" === this.reduceType ? e = " bestValue = bestValue + candidate; " : "prod" === this.reduceType ? (e = " bestValue = bestValue * candidate; ", t = "1.0") : "all" === this.reduceType ? (e = " bestValue = f32(bestValue >= 1.0 && candidate >= 1.0); ", t = "1.0") : "any" === this.reduceType && (e = " bestValue = f32(bestValue >= 1.0 || candidate >= 1.0); ", t = "0.0"); const r = "mean" === this.reduceType ? "setOutputAtIndex(outputIndex, bestValue / f32(uniforms.reduceSize));" : "setOutputAtIndex(outputIndex, bestValue);"; return `\n fn DIV_CEIL(a : u32, b : u32) -> u32 {\n return ((a - 1u) / b + 1u);\n }\n\n ${`\n var xBestValues : array;\n `}\n fn getOffset(outputIndex : i32) -> i32 {\n let outputCoords = getCoordsFromIndex(outputIndex);\n let offset = ${1 === this.outputShape.length ? "outputCoords" : "outputCoords[0]"} * uniforms.reduceSize;\n return offset;\n }\n ${uz("index")} {\n let outputIndex = index / ${n};\n let offset = getOffset(outputIndex);\n var bestValue = ${t};\n let Length = uniforms.reduceSize;\n let WorkPerThread = DIV_CEIL(u32(Length), ${n}u);\n for (var k = i32(localId.x); k < Length && outputIndex < uniforms.size;\n k = k + ${n}) {\n let candidate = f32(x[offset + k]);\n ${e}\n }\n xBestValues[localId.x] = bestValue;\n workgroupBarrier();\n\n var reduceSize = min(u32(Length), ${n}u);\n for (var currentSize = reduceSize / 2u; reduceSize > 1u;\n currentSize = reduceSize / 2u) {\n let interval = DIV_CEIL(reduceSize, 2u);\n if (localId.x < currentSize) {\n let candidate = xBestValues[localId.x + interval];\n ${e}\n xBestValues[localId.x] = bestValue;\n }\n reduceSize = interval;\n workgroupBarrier();\n }\n\n if (localId.x == 0u && outputIndex < uniforms.size) {\n ${r}\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const uB = { mean: "float32", all: "bool", any: "bool" }; function lB(e, t, n, r, i) { const a = e.shape.length, o = [], s = P.util.parseAxisParam(t, e.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, a); let c = e; null != l && (c = aB({ inputs: { x: e }, attrs: { perm: l }, backend: i }), u = P.backend_util.getInnerMostAxes(u.length, a), o.push(c)), P.backend_util.assertAxesAreInnerMostDims(r, u, a); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u); let f, p = h; if (n && (p = P.backend_util.expandShapeToKeepDim(h, s)), "max" !== r && "prod" !== r || !i.shouldExecuteOnCPU([c])) { const t = P.util.sizeFromShape(d), n = { windowSize: t, inSize: t, batchSize: P.util.sizeFromShape(c.shape) / t, outSize: 1 }, a = uB[r] || (0, P.sumOutType)(e.dtype), s = [{ type: "int32", data: [t] }], u = new sB(n, r, i.device.limits.maxComputeWorkgroupSizeX), l = i.runWebGPUProgram(u, [c], a, s); o.push(l), f = Jz({ inputs: { x: l }, attrs: { shape: p }, backend: i }) } else { const t = i.tensorMap.get(c.dataId).values; switch (r) { case "max": const n = TP(t, P.util.sizeFromShape(d), p, e.dtype); f = i.makeTensorInfo(p, e.dtype, n); break; case "prod": const { outVals: a, outShape: o, outDtype: s } = DP(c.shape, c.dtype, t, u); f = i.makeTensorInfo(o, s, a); break; default: throw new Error(`${r} CPU implementation is not yet supported.`) } } return o.forEach((e => i.disposeData(e.dataId))), f } const cB = { + kernelName: P.All, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { keepDims: a, axis: o } = r; return lB(i, o, a, "all", n) } + }; const hB = { + kernelName: P.Any, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { keepDims: a, axis: o } = r; return lB(i, o, a, "any", n) } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class dB { constructor(e, t, n) { this.workgroupSize = [64, 1, 1], this.variableNames = ["x"], this.uniforms = "infinityValue : f32,", this.size = !0; const r = [t]; this.op = "min" === n ? "<" : ">"; const [i, a] = P.backend_util.computeOutAndReduceShapes(e, r); this.outputShape = 0 === i.length ? [1] : i, this.dispatchLayout = wz(this.outputShape), P.util.sizeFromShape(a) < 32 ? (this.type = "plain", this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize)) : (this.type = "shared", this.dispatch = bz(this.dispatchLayout, this.outputShape, [1, 1, 1])), this.inputShape = e, this.shaderKey = `argMinMax_${this.op}_${this.type}` } getUserCode() { const e = this.workgroupSize[0], t = () => 1 === this.inputShape.length ? "uniforms.xShape" : `uniforms.xShape.${sz(this.inputShape.length - 1)}`, n = () => { let e = ""; if (1 === this.outputShape.length) 1 !== this.inputShape.length && (e += "outputCoords,"); else for (let t = 0; t < this.outputShape.length; t++)e += `outputCoords.${sz(t)},`; return e }; if ("shared" === this.type) { return `\n fn DIV_CEIL(a : u32, b : u32) -> u32 {\n return ((a - 1u) / b + 1u);\n }\n\n ${`\n var xBestIndices : array;\n var xBestValues : array;\n `}\n\n ${uz("index")} {\n let outputIndex = index / ${e};\n let reduceLength = ${t()};\n\n var bestIndex = i32(localId.x);\n var bestValue = uniforms.infinityValue;\n let outputCoords = getCoordsFromIndex(outputIndex);\n for (var k = i32(localId.x); k < reduceLength && outputIndex < uniforms.size;\n k = k + ${e}) {\n let candidate = getX(${n()} k);\n if (!isnan(candidate) && candidate ${this.op} bestValue) {\n bestValue = candidate;\n bestIndex = k;\n }\n }\n xBestValues[localId.x] = bestValue;\n xBestIndices[localId.x] = bestIndex;\n workgroupBarrier();\n\n var reduceSize = min(u32(reduceLength), ${e}u);\n for (var currentSize = reduceSize / 2u; reduceSize > 1u;\n currentSize = reduceSize / 2u) {\n let interval = DIV_CEIL(reduceSize, 2u);\n if (localId.x < currentSize) {\n let candidate = xBestValues[localId.x + interval];\n if (candidate ${this.op} bestValue) {\n bestValue = candidate;\n xBestValues[localId.x] = bestValue;\n xBestIndices[localId.x] = xBestIndices[localId.x + interval];\n }\n }\n reduceSize = interval;\n workgroupBarrier();\n }\n\n if (localId.x == 0u && outputIndex < uniforms.size) {\n setOutputAtIndexI32(outputIndex, xBestIndices[localId.x]);\n }\n }\n ` } return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let outputCoords = getCoordsFromIndex(index);\n var bestIndex = 0;\n var bestValue = getX(${n()} 0);\n let reduceLength = ${t()};\n for (var i = 1; i < reduceLength; i++) {\n let candidate = getX(${n()} i);\n if (candidate ${this.op} bestValue) {\n bestValue = candidate;\n bestIndex = i;\n }\n }\n setOutputAtIndexI32(index, bestIndex);\n }\n }\n ` } } const fB = { + kernelName: P.ArgMax, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = aB({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), P.backend_util.assertAxesAreInnerMostDims("argMax", [o[0]], u.shape.length); const c = new dB(u.shape, o[0], "max"), h = [{ type: "float32", data: [Number.NEGATIVE_INFINITY] }], d = n.runWebGPUProgram(c, [u], "int32", h); return l.forEach((e => n.disposeData(e.dataId))), d } + }; const pB = { + kernelName: P.ArgMin, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = aB({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), P.backend_util.assertAxesAreInnerMostDims("argMin", [o[0]], u.shape.length); const c = new dB(u.shape, o[0], "min"), h = [{ type: "float32", data: [Number.POSITIVE_INFINITY] }], d = n.runWebGPUProgram(c, [u], "int32", h); return l.forEach((e => n.disposeData(e.dataId))), d } + }, mB = lP({ opType: Fz.ASIN }), gB = { kernelName: P.Asin, backendName: "webgpu", kernelFunc: mB }, yB = lP({ opType: Fz.ASINH }), bB = { kernelName: P.Asinh, backendName: "webgpu", kernelFunc: yB }, vB = lP({ opType: Fz.ATAN }), xB = { kernelName: P.Atan, backendName: "webgpu", kernelFunc: vB }, wB = cP({ opType: Nz.ATAN2 }), kB = { kernelName: P.Atan2, backendName: "webgpu", kernelFunc: wB }, SB = lP({ opType: Fz.ATANH }), _B = { kernelName: P.Atanh, backendName: "webgpu", kernelFunc: SB }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class CB { constructor(e) { this.variableNames = ["x"], this.uniforms = "strides : vec2,", this.workgroupSize = [256, 1, 1], this.size = !0, this.outputShape = e.outShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "poolWithFilterSizeEqualsOne" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords[0];\n let d = coords[3];\n\n let xRCCorner = coords.yz * uniforms.strides;\n let xRCorner = xRCCorner.x;\n let xCCorner = xRCCorner.y;\n\n let value = getX(batch, xRCorner, xCCorner, d);\n setOutputAtIndex(index, value);\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class AB { constructor(e, t, n = !1, r = !1, i = !1) { if (this.variableNames = ["x"], this.uniforms = "strides : vec2, pads : vec2, dilations : vec2, convDims : vec2, filterDims : vec2,", this.workgroupSize = [128, 1, 1], this.size = !0, "avg" === t && n) throw new Error("Cannot compute positions for average pool."); this.outputShape = e.outShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.poolType = t, this.computePositions = n, this.flattenPositions = r, this.includeBatchIndex = i, this.shaderKey = `pool2D_${t}_${n}_${r}_${i}` } getUserCode() { let e; if ("avg" === this.poolType) e = "resultValue = resultValue + value; count = count + 1.0;"; else if (this.computePositions) { e = `let currMaxValue = mix(value, maxValue, maxValueFound);\n if (value >= currMaxValue) {\n maxValue = value;\n maxValueFound = 1.0;\n maxPosition = ${this.flattenPositions ? this.includeBatchIndex ? "((batch * uniforms.xShape[1] + xR) * uniforms.xShape[2] + xC) * uniforms.xShape[3] + d" : "(xR * uniforms.xShape[2] + xC) * uniforms.xShape[3] + d" : "wR * uniforms.filterDims.y + wC"};\n }` } else e = "resultValue = max(value, resultValue);"; let t = "resultValue"; "avg" === this.poolType && (t = "resultValue / max(count, 1.0)"); return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords[0];\n let d = coords[3];\n let xRCCorner = vec2(coords.yz) * uniforms.strides - uniforms.pads;\n let xRCorner = xRCCorner.x;\n let xCCorner = xRCCorner.y;\n\n ${this.computePositions ? "var maxValue = 0.0;\n var maxValueFound = 0.0;\n var maxPosition = 0;" : `var resultValue = ${"avg" === this.poolType ? "0.0" : "-1.0 / pow(10.0, -20.0)"};`}\n\n var count = 0.0;\n for (var wR = 0; wR < uniforms.filterDims.x; wR = wR + uniforms.dilations.x) {\n let xR = xRCorner + wR;\n\n if (xR < 0 || xR >= uniforms.convDims.x) {\n continue;\n }\n\n for (var wC = 0; wC < uniforms.filterDims.y; wC = wC + uniforms.dilations.y) {\n let xC = xCCorner + wC;\n if (xC < 0 || xC >= uniforms.convDims.y) {\n continue;\n }\n\n let value = getX(batch, xR, xC, d);\n ${e}\n }\n }\n\n ${this.computePositions ? "setOutputAtIndexI32(index, maxPosition);" : `setOutputAtIndex(index, ${t});`}\n }\n }\n ` } } class TB { constructor(e, t, n = !1, r = !1, i = !1) { if (this.variableNames = ["x"], this.uniforms = "strides : vec3, pads : vec3, convDims : vec3, filterDims : vec3,", this.workgroupSize = [128, 1, 1], this.size = !0, "avg" === t && n) throw new Error("Cannot compute positions for average pool."); this.outputShape = e.outShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.poolType = t, this.computePositions = n, this.flattenPositions = r, this.includeBatchIndex = i, this.shaderKey = `pool3D_${t}_${n}_${r}_${i}` } getUserCode() { let e; if ("avg" === this.poolType) e = "resultValue += value; count += 1.0;"; else if (this.computePositions) { e = `let currMaxValue = mix(value, maxValue, maxValueFound);\n if (value >= currMaxValue) {\n maxValue = value;\n maxValueFound = 1.0;\n maxPosition = ${this.flattenPositions ? this.includeBatchIndex ? "(((batch * uniforms.xShape.y + xD) * uniforms.xShape.z + xR) * uniforms.xShape.w + xC) * uniforms.xShape.u + ch" : "((xD * uniforms.xShape.z + xR) * uniforms.xShape.w + xC) * uniforms.xShape.u + ch" : "wD * uniforms.filterDims.y * uniforms.filterDims.y + wR * uniforms.filterDims.z + wC"};\n }` } else e = "resultValue = max(value, resultValue);"; let t = "resultValue"; "avg" === this.poolType && (t = "resultValue / max(count, 1.0)"); return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords.x;\n let ch = coords.u;\n\n let xCorner = vec3(coords.y, coords.z, coords.w) * uniforms.strides - uniforms.pads;\n let xDCorner = xCorner.x;\n let xRCorner = xCorner.y;\n let xCCorner = xCorner.z;\n\n ${this.computePositions ? "var maxValue = 0.0;\n var maxValueFound = 0.0;\n var maxPosition = 0;" : `var resultValue = ${"avg" === this.poolType ? "0.0" : "-1.0 / pow(10.0, -20.0)"};`}\n\n var count = 0.0;\n for (var wD = 0; wD < uniforms.filterDims.x; wD++) {\n let xD = xDCorner + wD;\n if (xD < 0 || xD >= uniforms.convDims.x) {\n continue;\n }\n\n for (var wR = 0; wR < uniforms.filterDims.y; wR++) {\n let xR = xRCorner + wR;\n if (xR < 0 || xR >= uniforms.convDims.y) {\n continue;\n }\n\n for (var wC = 0; wC < uniforms.filterDims.z; wC++) {\n let xC = xCCorner + wC;\n if (xC < 0 || xC >= uniforms.convDims.z) {\n continue;\n }\n\n let value = getX(batch, xD, xR, xC, ch);\n ${e}\n }\n }\n }\n\n ${this.computePositions ? "setOutputAtIndexI32(index, maxPosition);" : `setOutputAtIndex(index, ${t});`}\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function EB(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reductionIndices: a, keepDims: o } = r; return lB(i, a, o, "max", n) } const NB = { kernelName: P.Max, backendName: "webgpu", kernelFunc: EB }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function IB(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { keepDims: a, axis: o } = r; return lB(i, o, a, "mean", n) } const MB = { kernelName: P.Mean, backendName: "webgpu", kernelFunc: IB }; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function FB(e, t, n, r) { if (1 === t.filterWidth && 1 === t.filterHeight && P.util.arraysEqual(t.inShape, t.outShape)) return iP({ inputs: { x: e }, backend: r }); if (t.filterWidth === t.inWidth && t.filterHeight === t.inHeight && 1 === t.batchSize && "VALID" === t.padInfo.type) { const i = e.shape.length, a = Jz({ inputs: { x: e }, backend: r, attrs: { shape: [e.shape[i - 3] * e.shape[i - 2], e.shape[i - 1]] } }); let o; "avg" === n ? o = IB({ inputs: { x: a }, backend: r, attrs: { axis: 0, keepDims: !1 } }) : (P.util.assert("max" === n, (() => `Invalid pool type ${n}`)), o = EB({ inputs: { x: a }, backend: r, attrs: { reductionIndices: 0, keepDims: !1 } })); const s = Jz({ inputs: { x: o }, backend: r, attrs: { shape: t.outShape } }); return r.disposeData(a.dataId), r.disposeData(o.dataId), s } let i; const a = [{ type: "int32", data: [t.strideHeight, t.strideWidth] }]; return 1 === t.filterHeight && 1 === t.filterWidth ? i = new CB(t) : ("avg" === n ? i = new AB(t, "avg") : (P.util.assert("max" === n, (() => `Invalid pool type ${n}`)), i = new AB(t, "max")), a.push({ type: "int32", data: [t.padInfo.top, t.padInfo.left] }, { type: "int32", data: [t.dilationHeight, t.dilationWidth] }, { type: "int32", data: [t.inHeight, t.inWidth] }, { type: "int32", data: [t.effectiveFilterHeight, t.effectiveFilterWidth] })), r.runWebGPUProgram(i, [e], e.dtype, a) } const DB = { + kernelName: P.AvgPool, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; return FB(i, P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u), "avg", n) } + }; const $B = { + kernelName: P.AvgPool3D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dataFormat: u, dimRoundingMode: l } = r, c = P.backend_util.computePool3DInfo(i.shape, a, o, [1, 1, 1], s, l, u), h = new TB(c, "avg"), d = [{ type: "int32", data: [c.strideDepth, c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.padInfo.front, c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.inDepth, c.inHeight, c.inWidth] }, { type: "int32", data: [c.effectiveFilterDepth, c.effectiveFilterHeight, c.effectiveFilterWidth] }]; return n.runWebGPUProgram(h, [i], i.dtype, d) } + }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class RB { constructor(e) { this.variableNames = ["dy"], this.uniforms = "strides : vec2, pads : vec2, dilations : vec2, filterDims : vec2,\n outHeight : i32, outWidth : i32, avgMultiplier : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "avgPool2DBackprop" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords[0];\n let d = coords[3];\n\n let dyRCCorner = vec2(coords.yz) - uniforms.pads;\n let dyRCorner = dyRCCorner.x;\n let dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = 0.0;\n for (var wR = 0; wR < uniforms.filterDims[0]; wR = wR + uniforms.dilations[0]) {\n let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[0]);\n\n if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) {\n continue;\n }\n let idyR = i32(dyR);\n\n for (var wC = 0; wC < uniforms.filterDims[1]; wC = wC + uniforms.dilations[1]) {\n let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[1]);\n\n if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) {\n continue;\n }\n let idyC = i32(dyC);\n\n let dyValue = getDy(batch, idyR, idyC, d);\n\n dotProd = dotProd + dyValue * uniforms.avgMultiplier;\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } class OB { constructor(e) { this.variableNames = ["dy"], this.uniforms = "strides : vec3, pads : vec3, filterDims : vec3,\n outDepth : i32, outHeight : i32, outWidth : i32, avgMultiplier : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "avgPool3DBackprop" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords.x;\n let ch = coords.u;\n\n let dyCorner = vec3(coords.y, coords.z, coords.w) - uniforms.pads;\n let dyDCorner = dyCorner.x;\n let dyRCorner = dyCorner.y;\n let dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = 0.0;\n for (var wD = 0; wD < uniforms.filterDims[0]; wD++) {\n let dyD = f32(dyDCorner + wD) / f32(uniforms.strides[0]);\n\n if (dyD < 0.0 || dyD >= f32(uniforms.outDepth) || fract(dyD) > 0.0) {\n continue;\n }\n let idyD = i32(dyD);\n\n for (var wR = 0; wR < uniforms.filterDims[1]; wR++) {\n let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[1]);\n\n if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) {\n continue;\n }\n let idyR = i32(dyR);\n\n for (var wC = 0; wC < uniforms.filterDims[2]; wC++) {\n let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[2]);\n\n if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) {\n continue;\n }\n let idyC = i32(dyC);\n\n let dyValue = getDy(batch, idyD, idyR, idyC, ch);\n dotProd += dyValue * uniforms.avgMultiplier;\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } const zB = { + kernelName: P.AvgPool3DGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a, { filterSize: s, strides: u, pad: l, dimRoundingMode: c } = r, h = P.backend_util.computePool3DInfo(o.shape, s, u, 1, l, c), d = new OB(h), f = 1 / (h.filterDepth * h.filterHeight * h.filterWidth), p = [{ type: "int32", data: [h.strideDepth, h.strideHeight, h.strideWidth] }, { type: "int32", data: [h.effectiveFilterDepth - 1 - h.padInfo.front, h.effectiveFilterHeight - 1 - h.padInfo.top, h.effectiveFilterWidth - 1 - h.padInfo.left] }, { type: "int32", data: [h.effectiveFilterDepth, h.effectiveFilterHeight, h.effectiveFilterWidth] }, { type: "int32", data: [h.outDepth] }, { type: "int32", data: [h.outHeight] }, { type: "int32", data: [h.outWidth] }, { type: "float32", data: [f] }]; return n.runWebGPUProgram(d, [i], o.dtype, p) } + }; const PB = { + kernelName: P.AvgPoolGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a; _z([i, a], "avgPoolGrad"); const { filterSize: s, strides: u, pad: l } = r, c = P.backend_util.computePool2DInfo(o.shape, s, u, 1, l), h = new RB(c), d = 1 / (c.filterHeight * c.filterWidth), f = [{ type: "int32", data: [c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.effectiveFilterHeight - 1 - c.padInfo.top, c.effectiveFilterWidth - 1 - c.padInfo.left] }, { type: "int32", data: [c.dilationHeight, c.dilationWidth] }, { type: "int32", data: [c.effectiveFilterHeight, c.effectiveFilterWidth] }, { type: "int32", data: [c.outHeight] }, { type: "int32", data: [c.outWidth] }, { type: "float32", data: [d] }]; return n.runWebGPUProgram(h, [i], o.dtype, f) } + }; const BB = { + kernelName: P.BatchMatMul, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a } = t, { transposeA: o, transposeB: s } = r; return eP({ a: i, b: a, transposeA: o, transposeB: s, backend: n }) } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class LB { constructor(e, t) { this.variableNames = ["source"], this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = t, this.rank = t.length, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.start = e, this.uniforms = `start : ${oz(e.length)}, `, this.shaderKey = "slice" } getUserCode() { const e = oz(this.rank), t = function (e) { if (1 === e) return "sourceLoc"; if (e <= 6) return jB.slice(0, e).map((e => `sourceLoc.${e}`)).join(","); throw Error(`Slicing for rank ${e} is not yet supported`) }(this.rank); let n; n = 1 === this.start.length ? this.outputShape.map(((e, t) => "sourceLoc = uniforms.start + coords;")) : this.outputShape.map(((e, t) => `sourceLoc.${jB[t]} = uniforms.start.${sz(t)} + coords.${jB[t]};`)); return `\n ${uz("index")} {\n if (index < uniforms.size) {\n var sourceLoc : ${e};\n let coords = getCoordsFromIndex(index);\n ${n.join("\n")}\n setOutputAtIndex(index, getSource(${t}));\n }\n }\n ` } } const jB = ["x", "y", "z", "w", "u", "v"]; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function UB(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, size: o } = r, [s, u] = P.slice_util.parseSliceParams(i, a, o); if (P.slice_util.assertParamsValid(i, s, u), n.shouldExecuteOnCPU([i]) || "string" === i.dtype) { const e = n.tensorMap.get(i.dataId), t = PP(e.values, s, u, i.shape, i.dtype); return n.makeTensorInfo(u, i.dtype, t) } if (0 === P.util.sizeFromShape(u)) return n.makeTensorInfo(u, i.dtype, []); const l = new LB(s, u), c = [{ type: "int32", data: s }]; return n.runWebGPUProgram(l, [i], i.dtype, c) } const WB = { kernelName: P.Slice, backendName: "webgpu", kernelFunc: UB }, VB = { kernelName: P.BatchToSpaceND, backendName: "webgpu", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, crops: o } = r; P.util.assert(i.shape.length <= 4, (() => "batchToSpaceND for rank > 4 with a WebGPU backend not implemented yet")); const s = a.reduce(((e, t) => e * t)), u = P.backend_util.getReshaped(i.shape, a, s), l = P.backend_util.getPermuted(u.length, a.length), c = P.backend_util.getReshapedPermuted(i.shape, a, s), h = P.backend_util.getSliceBeginCoords(o, a.length), d = P.backend_util.getSliceSize(c, o, a.length), f = [], p = Jz({ inputs: { x: i }, backend: n, attrs: { shape: u } }), m = aB({ inputs: { x: p }, backend: n, attrs: { perm: l } }), g = Jz({ inputs: { x: m }, backend: n, attrs: { shape: c } }), y = UB({ inputs: { x: g }, backend: n, attrs: { begin: h, size: d } }); return f.push(p), f.push(m), f.push(g), f.forEach((e => n.disposeData(e.dataId))), y } }, GB = `\n fn bincount_write(index: i32, value: f32) {\n ${tz("&result[index]", "value", "float32")}\n }\n`; class HB { constructor(e, t, n = !1) { this.outputShape = [], this.variableNames = ["x"], this.uniforms = "binCountSize : i32,", this.workgroupSize = [64, 1, 1], this.atomic = !0, this.hasWeights = !0, this.binaryOutput = !1, this.outputShape = e, this.rank = e.length, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.binaryOutput = n, n && (this.atomic = !1), this.hasWeights = t, this.hasWeights && this.variableNames.push("w"), this.shaderKey = `bincount_${this.hasWeights}_${this.binaryOutput}_${this.rank}` } getUserCode() { return `\n ${this.binaryOutput ? "\n fn bincount_write(index: i32, value: f32) {\n atomicStore(&result[index], bitcast(value));\n }\n" : GB}\n ${uz("index")} {\n ${1 === this.rank ? `if (index < uniforms.xShape) {\n let indexVal = i32(getX(index));\n if (indexVal < uniforms.binCountSize) {\n let value = ${this.binaryOutput ? 1 : this.hasWeights ? "getW(index)" : "1."};\n bincount_write(indexVal, value);\n }\n }` : `let coord = getCoordsFromIndex(index);\n if (coordsInBounds2D(coord, uniforms.xShape)) {\n let indexVal = i32(getX(coord[0], coord[1]));\n if (indexVal < uniforms.binCountSize) {\n let value = ${this.binaryOutput ? 1 : this.hasWeights ? "getW(coord[0], coord[1])" : "1."};\n bincount_write(coord.x * uniforms.binCountSize + indexVal, value);\n }\n }`}\n }\n ` } } const qB = { + kernelName: P.Bincount, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o } = r, s = P.util.sizeFromShape(i.shape), u = P.util.sizeFromShape(a.shape) > 0, l = [o], c = a.dtype, h = Kz({ backend: n, attrs: { shape: l, value: 0, dtype: c } }), d = new HB([s], u), f = [{ type: "int32", data: [o] }], p = u ? [i, a] : [i]; return n.runWebGPUProgram(d, p, c, f, h) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class YB { constructor(e) { this.outputShape = [], this.variableNames = ["s0", "s1"], this.uniforms = "s0Size : i32, s1Size : i32, ", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "broadcastArgs" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n var s0 = 1.0;\n var s1 = 1.0;\n let indexS0 = index - uniforms.size + uniforms.s0Size;\n let indexS1 = index - uniforms.size + uniforms.s1Size;\n if (indexS0 >= 0) {\n s0 = getS0(indexS0);\n }\n if (indexS1 >= 0) {\n s1 = getS1(indexS1);\n }\n\n if (s0 == 1.0) {\n setOutputAtIndex(index, s1);\n } else if (s1 == 1.0) {\n setOutputAtIndex(index, s0);\n } else if (s0 != s1) {\n setOutputAtIndex(index, uniforms.NAN);\n } else {\n setOutputAtIndex(index, s0);\n }\n }\n }\n ` } } const XB = { + kernelName: P.BroadcastArgs, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { s0: r, s1: i } = t; if (n.shouldExecuteOnCPU([r, i])) { const e = n.tensorMap.get(r.dataId), t = n.tensorMap.get(i.dataId), a = e.values, o = t.values, s = P.backend_util.assertAndGetBroadcastShape(Array.from(a), Array.from(o)); return n.makeTensorInfo([s.length], "int32", Int32Array.from(s)) } const a = P.util.sizeFromShape(r.shape), o = P.util.sizeFromShape(i.shape), s = Math.max(a, o), u = new YB(s), l = [{ type: "int32", data: [a] }, { type: "int32", data: [o] }]; return n.runWebGPUProgram(u, [r, i], "int32", l) } + }, KB = cP({ opType: Nz.NOT_EQUAL, dtype: "bool", cpuKernelImpl: FP }), ZB = { kernelName: P.NotEqual, backendName: "webgpu", kernelFunc: KB }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function JB(e) { const { inputs: t, backend: n } = e, { input: r } = t; return iP({ inputs: { x: n.tensorMap.get(r.dataId).complexTensorInfos.real }, backend: n }) } const QB = { kernelName: P.Real, backendName: "webgpu", kernelFunc: JB }; const eL = { + kernelName: P.Cast, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function e(t) { + const { inputs: n, backend: r, attrs: i } = t, { x: a } = n, { dtype: o } = i; if ("complex64" === o) { if ("complex64" === a.dtype) return iP({ inputs: { x: a }, backend: r }); const t = P.zeros(a.shape), n = e({ inputs: { x: a }, backend: r, attrs: { dtype: "float32" } }), i = oP({ inputs: { real: n, imag: t }, backend: r }); return t.dispose(), r.disposeData(n.dataId), i } if ("complex64" === a.dtype) { const t = JB({ inputs: { input: a }, backend: r }), n = e({ inputs: { x: t }, backend: r, attrs: { dtype: o } }); return r.disposeData(t.dataId), n } if (!P.util.hasEncodingLoss(a.dtype, o)) { const e = iP({ inputs: { x: a }, backend: r }); return { dataId: e.dataId, shape: e.shape, dtype: o } } if (r.shouldExecuteOnCPU([a])) { const e = r.tensorMap.get(a.dataId).values, [t, n, i] = dP(e, a.shape, a.dtype, o); return r.makeTensorInfo(t, n, i) } if ("int32" === o) + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + return function (e, t) { const n = new uP(e.shape, Fz.TO_INT), r = t.runWebGPUProgram(n, [e], "int32"); return { dataId: r.dataId, shape: r.shape, dtype: r.dtype } }(a, r); if ("bool" === o) { const e = r.makeTensorInfo([], "bool", P.util.getTypedArrayFromDType("bool", 1)), t = KB({ inputs: { a, b: e }, backend: r }); return r.disposeData(e.dataId), t } throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${o}`) + } + }, tL = lP({ opType: Fz.CEIL, cpuKernelImpl: fP }), nL = { kernelName: P.Ceil, backendName: "webgpu", kernelFunc: tL }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class rL { constructor(e) { this.variableNames = ["A"], this.uniforms = "minVal : f32, maxVal : f32,", this.workPerThread = 4, this.workgroupSize = [64, 1, 1], this.outputComponent = 4, this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.shaderKey = "clipVec4" } getUserCode() { return `\n ${uz("index")} {\n if(index < uniforms.size) {\n let value = getAByOutputIndex(index);\n var clampedValue = clamp(\n value, vec4(uniforms.minVal), vec4(uniforms.maxVal));\n clampedValue = select(clampedValue, value, isnanVec4(value));\n setOutputAtIndex(index, clampedValue);\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class iL { constructor(e) { this.variableNames = ["A"], this.uniforms = "minVal : f32, maxVal : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "clip" } getUserCode() { return `\n ${uz("index")} {\n if(index < uniforms.size) {\n let value = getAByOutputIndex(index);\n if (isnan(value)) {\n setOutputAtIndex(index, value);\n return;\n }\n setOutputAtIndex(index, clamp(value, uniforms.minVal, uniforms.maxVal));\n }\n }\n ` } } const aL = { + kernelName: P.ClipByValue, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { clipValueMin: a, clipValueMax: o } = r; let s; const u = [{ type: "float32", data: [a] }, { type: "float32", data: [o] }]; return s = P.util.sizeFromShape(i.shape) % 4 == 0 ? new rL(i.shape) : new iL(i.shape), n.runWebGPUProgram(s, [i], i.dtype, u) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class oL { constructor(e) { this.outputShape = [], this.variableNames = ["real", "imag"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "complexAbs" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let re = abs(getRealByOutputIndex(index));\n let im = abs(getImagByOutputIndex(index));\n let mx = max(re, im);\n\n // The length function in wgsl may be not underflow-safe on some GPUs.\n // So the safe solution is to ensure underflow-safety in all cases.\n setOutputAtIndex(index, select(mx * length(vec2(1, min(re, im)/mx)), 0.0, mx == 0.0));\n }\n }\n ` } } + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function sL(e, t) { return { dataId: t.dataId, dtype: t.dtype, shape: e.shape } } const uL = { kernelName: P.ComplexAbs, backendName: "webgpu", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = n.tensorMap.get(r.dataId), a = new oL(r.shape), o = [sL(r, i.complexTensorInfos.real), sL(r, i.complexTensorInfos.imag)]; return n.runWebGPUProgram(a, o, o[0].dtype) } }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class lL { constructor(e) { this.uniforms = "", this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = P.backend_util.computeOutShape(e, 1), this.variableNames = e.map(((e, t) => `T${t}`)), this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.offsetLength = e.length - 1; for (let e = 0; e < this.offsetLength; e++)this.uniforms += `offset${e} : i32,`; this.shaderKey = "concat" } getUserCode() { const e = []; if (this.offsetLength > 0) { e.push("if (yC < uniforms.offset0){ setOutputAtCoords(coords.x, coords.y, getT0(yR, yC)); }"); for (let t = 1; t < this.offsetLength; t++)e.push(`else if (yC < uniforms.offset${[t]}){ setOutputAtCoords(coords.x, coords.y, getT${t}(yR, yC - uniforms.offset${t - 1})); }`); const t = this.offsetLength, n = this.offsetLength - 1; e.push(`else { setOutputAtCoords(coords.x, coords.y, getT${t}(yR, yC - uniforms.offset${n})); }`) } else e.push("setOutputAtCoords(coords.x, coords.y, getT0(yR, yC));"); return `\n ${uz("index")} {\n for(var i = 0; i < ${this.workPerThread}; i = i + 1) {\n let flatIndex = index * ${this.workPerThread} + i;\n if(flatIndex < uniforms.size) {\n let coords = getCoordsFromIndex(flatIndex);\n let yR = coords.x;\n let yC = coords.y;\n\n ${e.join("\n ")}\n }\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function cL(e) { const { inputs: t, backend: n } = e, { input: r } = t; return iP({ inputs: { x: n.tensorMap.get(r.dataId).complexTensorInfos.imag }, backend: n }) } const hL = { kernelName: P.Imag, backendName: "webgpu", kernelFunc: cL }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function dL(e, t, n) { const r = e[0].dtype; if ("complex64" === r) { const r = e.map((e => JB({ inputs: { input: e }, backend: n }))), i = e.map((e => cL({ inputs: { input: e }, backend: n }))), a = dL(r, t, n), o = dL(i, t, n), s = oP({ inputs: { real: a, imag: o }, backend: n }); return r.forEach((e => n.disposeData(e.dataId))), i.forEach((e => n.disposeData(e.dataId))), n.disposeData(a.dataId), n.disposeData(o.dataId), s } let i = n.shouldExecuteOnCPU(e); if ("string" === r && (i = !0), i) { const i = e.map((e => { const r = P.util.sizeFromShape(e.shape.slice(t)); return Jz({ inputs: { x: e }, backend: n, attrs: { shape: [-1, r] } }) })), a = i.map((e => ({ vals: n.readSync(e.dataId), shape: e.shape }))), o = P.backend_util.computeOutShape(i.map((e => e.shape)), 1), s = 1 === i[0].shape[0], u = pP(a, o, r, s), l = P.backend_util.computeOutShape(e.map((e => e.shape)), t), c = n.makeTensorInfo(l, r, u); return i.forEach((e => n.disposeData(e.dataId))), c } const a = n.device.limits.maxStorageBuffersPerShaderStage - 1; if (e.length > a) { const r = []; for (let i = 0; i < e.length; i += a) { const o = e.slice(i, i + a); r.push(dL(o, t, n)) } const i = dL(r, t, n); for (const e of r) n.disposeData(e.dataId); return i } const { tensors2D: o, outShape: s } = function (e, t, n) { const r = P.backend_util.computeOutShape(e.map((e => e.shape)), t), i = e.map((e => Jz({ inputs: { x: e }, backend: n, attrs: { shape: [P.util.sizeFromShape(e.shape.slice(0, t)), P.util.sizeFromShape(e.shape.slice(t))] } }))); return { tensors2D: i, outShape: r } }(e, t, n), u = o.map((e => e.shape)), l = new lL(u), c = [], h = new Array(u.length - 1); if (h.length > 0) { h[0] = u[0][1], c.push({ type: "int32", data: [h[0]] }); for (let e = 1; e < h.length; e++)h[e] = h[e - 1] + u[e][1], c.push({ type: "int32", data: [h[e]] }) } const d = n.runWebGPUProgram(l, o, o[0].dtype, c); o.forEach((e => n.disposeData(e.dataId))); const f = Jz({ inputs: { x: d }, backend: n, attrs: { shape: s } }); return n.disposeData(d.dataId), f } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function fL(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r, a = P.util.parseAxisParam(i, t[0].shape)[0], o = t.map((e => e.shape)); P.backend_util.assertParamsConsistent(o, a); const s = P.backend_util.computeOutShape(t.map((e => e.shape)), a); if (0 === P.util.sizeFromShape(s)) return n.makeTensorInfo(s, t[0].dtype, []); const u = t.filter((e => P.util.sizeFromShape(e.shape) > 0)); return 1 === u.length ? iP({ inputs: { x: u[0] }, backend: n }) : dL(u, a, n) } const pL = { kernelName: P.Concat, backendName: "webgpu", kernelFunc: fL }; class mL { + constructor(e, t, n, r, i = !1, a = null, o = !1, s = !1) { this.variableNames = ["x", "W"], this.uniforms = "filterDims : vec2, pads : vec2, strides : vec2, dilations : vec2, dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = e.outShape, this.isChannelsLast = "channelsLast" === e.dataFormat, this.isVec4 = ((e.inChannels % 4 == 0 || e.inChannels % 3 == 0) && this.isChannelsLast || e.outWidth % 4 == 0 && !this.isChannelsLast) && e.outChannels % 4 == 0, this.dispatchLayout = this.isChannelsLast ? { x: [3], y: [1, 2], z: [0] } : { x: [2, 3], y: [1], z: [0] }, this.workgroupSize = vz(this.dispatchLayout, this.outputShape, this.isVec4), this.elementsPerThread = xz(this.dispatchLayout, this.outputShape, this.isVec4), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, this.elementsPerThread), this.isVec4 ? (this.outputComponent = 4, this.isChannelsLast && e.inChannels % 4 != 0 ? (this.innerElementSize = 3, this.variableComponents = [1, 4]) : (this.innerElementSize = 4, this.variableComponents = [4, 4]), i && (this.variableNames.push("bias"), this.variableComponents.push(4)), o && (this.variableNames.push("preluActivationWeights"), this.variableComponents.push(4))) : (this.innerElementSize = this.elementsPerThread[0], i && this.variableNames.push("bias"), o && this.variableNames.push("preluActivationWeights")), this.sequentialAccessByThreads = s, this.addBias = i, this.activation = a, this.hasPreluActivationWeights = o, this.tileAOuter = this.workgroupSize[1] * this.elementsPerThread[1], this.tileBOuter = this.workgroupSize[0] * this.elementsPerThread[0], this.tileInner = Math.max(this.workgroupSize[0] * this.innerElementSize, this.workgroupSize[1]), this.fitAOuter = t % this.tileAOuter == 0, this.fitBOuter = n % this.tileBOuter == 0, this.fitInner = r % this.tileInner == 0, this.shaderKey = `conv2DMM_${this.elementsPerThread}_${this.activation}}_${this.fitAOuter}_${this.fitBOuter}_${this.fitInner}_${this.isVec4}_${this.innerElementSize}_${this.isChannelsLast}_${this.sequentialAccessByThreads}` } getUserCode() { + const e = this.isVec4 ? jz(this.elementsPerThread, this.workgroupSize, !this.isChannelsLast, this.tileInner) : Wz(this.elementsPerThread, this.workgroupSize, !this.isChannelsLast, this.tileInner, !1, null, this.sequentialAccessByThreads), t = this.isVec4 ? [this.innerElementSize, 4, 4] : [1, 1, 1]; return `\n ${ + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e, t, n, r, i = !1, a = null, o = !1, s = 4, u = 4, l = 4) { const c = e ? "\n let coord = vec4(batch, xRow, xCol, xCh);\n " : "\n let coord = vec4(batch, xCh, xRow, xCol);\n ", h = e ? "\n let coords = vec4(\n batch,\n row / outWidth,\n row % outWidth,\n col);\n " : "\n let coords = vec4(\n batch,\n row,\n col / outWidth,\n col % outWidth);\n ", d = e ? "uniforms.xShape[1]" : "uniforms.xShape[2]", f = e ? "uniforms.xShape[2]" : "uniforms.xShape[3]", p = e ? "row" : "col", m = e ? "col" : "row", g = `\n let inChannels = uniforms.wShape[2];\n let outWidth = ${e ? "uniforms.outShape[2]" : "uniforms.outShape[3]"};\n let outRow = ${p} / outWidth;\n let outCol = ${p} % outWidth;\n\n let WRow = ${m} / (uniforms.filterDims[1] * inChannels);\n let WCol = ${m} / inChannels % uniforms.filterDims[1];\n let xRow = outRow * uniforms.strides[0] + uniforms.dilations[0] * WRow - uniforms.pads[0];\n let xCol = outCol * uniforms.strides[1] + uniforms.dilations[1] * WCol - uniforms.pads[1];\n let xCh = ${m} % inChannels;\n var resData = ${az(s)}(0.0);\n // The bounds checking is always needed since we use it to pad zero for\n // the 'same' padding type.\n if (xRow >= 0 && xRow < ${d} && xCol >= 0 && xCol < ${f}) {\n ${c}\n let xIndex = getIndexFromCoords4D(coord, uniforms.xShape);\n ${(e => { switch (e) { case 1: return "resData = f32(x[xIndex]);"; case 3: return "resData = vec3(x[xIndex], x[xIndex + 1], x[xIndex + 2]);"; case 4: return "resData = vec4(x[xIndex / 4]);"; default: throw new Error(`innerElementSize ${e} is not supported.`) } })(s)}\n }\n return resData;`, y = e ? t && r ? `\n ${g}` : `\n if (row < uniforms.dimAOuter && col < uniforms.dimInner) {\n ${g}\n }\n return ${az(s)}(0.0);` : r && n ? `\n ${g}` : `\n if (row < uniforms.dimInner && col < uniforms.dimBOuter) {\n ${g}\n }\n return ${az(s)}(0.0);`, b = `${(e => { switch (e) { case 1: return "return f32(W[row * uniforms.wShape[3] + col]);"; case 4: return "return vec4(W[(row * uniforms.wShape[3] + col) / 4]);"; default: throw new Error(`innerElementSize ${e} is not supported.`) } })(u)}`, v = az(l), x = az(e ? s : u), w = az(e ? u : s); return `\n ${zz(a, o, 4 === l, 4)}\n fn mm_readA(batch: i32, row : i32, col : i32) -> ${x} {\n ${e ? y : b}\n }\n\n fn mm_readB(batch: i32, row : i32, col : i32) -> ${w} {\n ${e ? b : y}\n }\n\n fn mm_write(batch: i32, row : i32, col : i32, valueIn : ${v}) {\n if (row < uniforms.dimAOuter && col < uniforms.dimBOuter)\n {\n var value = valueIn;\n let outWidth = ${e ? "uniforms.outShape[2]" : "uniforms.outShape[3]"};\n ${h}\n ${Pz(i, a)}\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);\n }\n }` }(this.isChannelsLast, this.fitAOuter, this.fitBOuter, this.fitInner, this.addBias, this.activation, this.hasPreluActivationWeights, t[0], t[1], t[2])}\n ${e}\n ` + } + } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class gL { constructor(e, t = !1, n = null, r = !1) { this.variableNames = ["x", "W"], this.uniforms = "filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2,", this.workgroupSize = [4, 4, 8], this.outputShape = e.outShape, this.isChannelsLast = "channelsLast" === e.dataFormat, this.dispatchLayout = this.isChannelsLast ? { x: [2], y: [1], z: [0, 3] } : { x: [3], y: [2], z: [0, 1] }, this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.addBias = t, this.activation = n, this.hasPreluActivationWeights = r, t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), this.shaderKey = `conv2dnaive_${this.activation}_${this.isChannelsLast}` } getUserCode() { return `\n ${zz(this.activation, this.hasPreluActivationWeights, !1, 4)}\n fn readInp(batch : i32, row : i32, col : i32, chan : i32) -> f32{\n let coords = vec4(batch, row, col, chan);\n if (coordsInBounds4D(coords, uniforms.xShape)) {\n return getX(batch, row, col, chan);\n } else {\n return 0.0;\n }\n }\n fn readFilt(row : i32, col : i32, xChannel : i32, outChannel : i32) -> f32{\n let coords = vec4(row, col, xChannel, outChannel);\n if(coordsInBounds4D(coords, uniforms.wShape)) {\n return getW(row, col, xChannel, outChannel);\n } else {\n return 0.0;\n }\n }\n fn writeResult(batch : i32, row : i32, col : i32, chan : i32, valueIn : f32) {\n let coords = ${this.isChannelsLast ? "vec4(batch, row, col, chan);" : "vec4(batch, chan, row, col);"}\n if (coordsInBounds4D(coords, uniforms.outShape)) {\n var value = valueIn;\n ${Pz(this.addBias, this.activation)}\n setOutputAtCoords(coords.x, coords.y, coords.z, coords.w, value);\n }\n }\n ${uz("index")} {\n let coords = getOutputCoords();\n let batch = coords[0];\n let outChannel = ${this.isChannelsLast ? "coords[3];" : "coords[1];"}\n let outRow = ${this.isChannelsLast ? "coords[1];" : "coords[2];"}\n let outCol = ${this.isChannelsLast ? "coords[2];" : "coords[3];"}\n var acc : f32 = 0.0;\n for (var row = 0; row < uniforms.filterDims[0]; row = row + 1) {\n for (var col = 0; col < uniforms.filterDims[1]; col = col + 1) {\n let xRow = outRow * uniforms.strides[0] + uniforms.dilations[0] * row - uniforms.pads[0];\n let xCol = outCol * uniforms.strides[1] + uniforms.dilations[1] * col - uniforms.pads[1];\n for (var xChannel = 0; xChannel < ${this.isChannelsLast ? "uniforms.xShape[3];" : "uniforms.xShape[1];"} xChannel = xChannel + 1) {\n ${this.isChannelsLast ? "let v = readInp(batch, xRow, xCol, xChannel);" : "let v = readInp(batch, xChannel, xRow, xCol);"}\n let f = readFilt(row, col, xChannel, outChannel);\n acc = acc + v * f;\n }\n }\n }\n writeResult(batch, outRow, outCol, outChannel, acc);\n }\n ` } } + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class yL { constructor(e, t) { this.variableNames = ["x"], this.uniforms = "pads : vec2, strides : vec2, dilations : vec2, outWidth : i32, itemsPerBlockRow : i32,\n inChannels : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.isChannelsLast = t, this.shaderKey = `im2col_${this.isChannelsLast}` } getUserCode() { const e = this.isChannelsLast ? 1 : 2, t = this.isChannelsLast ? 2 : 3, n = this.isChannelsLast ? "coords[1]" : "coords[2]", r = this.isChannelsLast ? "coords[2]" : "coords[1]", i = this.isChannelsLast ? "getX(batch, xRow, xCol, ch)" : "getX(batch, ch, xRow, xCol)"; return `\n ${uz("index")} {\n let coords = getCoordsFromIndex(index);\n if(index < uniforms.size) {\n let batch = coords[0];\n let row = ${n};\n let col = ${r};\n let offsetY = (row / uniforms.outWidth) * uniforms.strides[0] - uniforms.pads[0];\n let xRow = offsetY + uniforms.dilations[0] * (col / uniforms.itemsPerBlockRow);\n var value = 0.0;\n if(xRow < uniforms.xShape[${e}] && xRow >= 0) {\n let offsetX = (row % uniforms.outWidth) * uniforms.strides[1] -\n uniforms.pads[1];\n let xCol = offsetX + uniforms.dilations[1] * ((col %\n uniforms.itemsPerBlockRow) / uniforms.inChannels);\n let ch = col % uniforms.inChannels;\n if(xCol < uniforms.xShape[${t}] && xCol >= 0) {\n value = ${i};\n }\n }\n setOutputAtIndex(index, value);\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function bL(e, t) { const n = e.length; return n >= 3 ? t ? [...e.slice(0, -3), e[n - 3] * e[n - 2], e[n - 1]] : [...e.slice(0, -3), e[n - 3], e[n - 2] * e[n - 1]] : !t && 1 === n && e[0] > 1 ? [e[0], 1] : null } function vL({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const u = null != i, l = null != a, c = "channelsLast" === n.dataFormat, h = c && n.filterHeight === n.inHeight && n.filterWidth === n.inWidth && "VALID" === n.padInfo.type, d = (0, P.env)().getBool("WEBGPU_USE_NAIVE_CONV2D_DEBUG"); if (!d && (h || 1 === n.filterHeight && 1 === n.filterWidth && 1 === n.dilationHeight && 1 === n.dilationWidth && 1 === n.strideHeight && 1 === n.strideWidth && ("SAME" === n.padInfo.type || "VALID" === n.padInfo.type))) return function ({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const u = "channelsLast" === n.dataFormat, l = !u, c = []; let h, d; if (u && n.filterHeight === n.inHeight && n.filterWidth === n.inWidth && "VALID" === n.padInfo.type) { const i = n.inHeight * n.inWidth * n.inChannels; h = Jz({ inputs: { x: e }, backend: r, attrs: { shape: [1, n.batchSize, i] } }), d = Jz({ inputs: { x: t }, backend: r, attrs: { shape: [1, i, n.outChannels] } }) } else h = Jz({ inputs: { x: e }, backend: r, attrs: { shape: u ? [n.batchSize, n.inHeight * n.inWidth, n.inChannels] : [n.batchSize, n.inChannels, n.inHeight * n.inWidth] } }), d = Jz({ inputs: { x: t }, backend: r, attrs: { shape: [1, n.inChannels, n.outChannels] } }); if (c.push(h), c.push(d), null != a) { const e = bL(a.shape, u); null != e && (a = Jz({ inputs: { x: a }, backend: r, attrs: { shape: e } }), c.push(a)) } if (null != i) { const e = bL(i.shape, u); null != e && (i = Jz({ inputs: { x: i }, backend: r, attrs: { shape: e } }), c.push(i)) } const f = eP({ a: u ? h : d, b: u ? d : h, transposeA: l, transposeB: !1, backend: r, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }), p = Jz({ inputs: { x: f }, backend: r, attrs: { shape: n.outShape } }); c.push(f); for (const e of c) r.disposeData(e.dataId); return p }({ x: e, filter: t, convInfo: n, backend: r, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }); const f = (0, P.env)().getNumber("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL"), p = f > -1 ? f : r.thresholdToIncreaseWorkgroups, m = n.batchSize * Math.ceil(n.outHeight * n.outWidth / 32) * Math.ceil(n.outChannels / 32); if ((0, P.env)().getBool("WEBGPU_CONV_SEPARATE_IM2COL_SHADER") || m <= p) return function ({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const { filterWidth: u, filterHeight: l, inChannels: c, strideWidth: h, strideHeight: d, padInfo: f, outWidth: p, outHeight: m, dilationWidth: g, dilationHeight: y, dataFormat: b } = n, v = "channelsLast" === b, x = u * l * c, w = m * p, k = v ? [n.batchSize, w, x] : [n.batchSize, x, w], S = new yL(k, v), _ = [{ type: "int32", data: [f.top, f.left] }, { type: "int32", data: [d, h] }, { type: "int32", data: [y, g] }, { type: "int32", data: [p] }, { type: "int32", data: [c * u] }, { type: "int32", data: [c] }], C = r.runWebGPUProgram(S, [e], e.dtype, _), A = []; A.push(C); const T = Jz({ inputs: { x: t }, backend: r, attrs: { shape: [1, x, -1] } }); if (A.push(T), null != a) { const e = bL(a.shape, v); null != e && (a = Jz({ inputs: { x: a }, backend: r, attrs: { shape: e } }), A.push(a)) } if (null != i) { const e = bL(i.shape, v); null != e && (i = Jz({ inputs: { x: i }, backend: r, attrs: { shape: e } }), A.push(i)) } const E = eP({ a: v ? C : T, b: v ? T : C, transposeA: !v, transposeB: !1, backend: r, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }), N = Jz({ inputs: { x: E }, backend: r, attrs: { shape: n.outShape } }); A.push(E); for (const e of A) r.disposeData(e.dataId); return N }({ x: e, filter: t, convInfo: n, backend: r, bias: i, preluActivationWeights: a, leakyreluAlpha: o, activation: s }); let g; const y = [n.padInfo.top, n.padInfo.left], b = [{ type: "int32", data: [n.filterHeight, n.filterWidth] }, { type: "int32", data: [...y] }, { type: "int32", data: [n.strideHeight, n.strideWidth] }, { type: "int32", data: [n.dilationHeight, n.dilationWidth] }]; if (d) g = new gL(n, u, s, l); else { const e = c ? n.outHeight * n.outWidth : n.outChannels, t = c ? n.outChannels : n.outHeight * n.outWidth, i = n.filterHeight * n.filterWidth * n.inChannels; b.push({ type: "int32", data: [e] }, { type: "int32", data: [t] }, { type: "int32", data: [i] }); const a = r.adapterInfo.isIntel(); g = new mL(n, e, t, i, u, s, l, a) } const v = [], x = [e, t]; u && (c || 1 !== i.shape.length || (i = Jz({ inputs: { x: i }, backend: r, attrs: { shape: [i.shape[0], 1, 1] } }), v.push(i)), x.push(i)), l && (c || 1 !== a.shape.length || (a = Jz({ inputs: { x: a }, backend: r, attrs: { shape: [a.shape[0], 1, 1] } }), v.push(a)), x.push(a)), "leakyrelu" === s && (b.push({ type: "float32", data: [o] }), g.uniforms += " alpha : f32,"); const w = r.runWebGPUProgram(g, x, e.dtype, b); for (const e of v) r.disposeData(e.dataId); return w } const xL = { + kernelName: P.Conv2D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, attrs: n, backend: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dataFormat: u, dilations: l, dimRoundingMode: c } = n, h = P.backend_util.convertConv2DDataFormat(u); return vL({ x: i, filter: a, convInfo: P.backend_util.computeConv2DInfo(i.shape, a.shape, o, l, s, c, !1, h), backend: r }) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class wL { constructor(e) { this.variableNames = ["dy", "W"], this.uniforms = "filterDims : vec2, pads : vec2, strides : vec2, outBackprop : vec4,", this.workgroupSize = [64, 1, 1], this.size = !1, this.isVec4 = !1, this.workPerThread = 1, this.outputShape = e.inShape, this.isChannelsLast = "channelsLast" === e.dataFormat, this.isVec4 = this.isChannelsLast && e.outChannels % 4 == 0 && e.inChannels % 4 == 0, this.isVec4 ? (this.workPerThread = 2, this.outputComponent = 4, this.workgroupSize = [4, 4, 4], this.dispatchLayout = { x: [3], y: [2], z: [0, 1] }, this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [4, this.workPerThread, 1])) : (this.size = !0, this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize)), this.shaderKey = `conv2DDerInput_${this.isChannelsLast}_${this.isVec4}_${this.workPerThread}` } getUserCode() { const e = this.isChannelsLast ? 1 : 2, t = this.isChannelsLast ? 2 : 3, n = this.isChannelsLast ? 3 : 1, r = `\n ${uz()} {\n let batch = i32(globalId.z) / uniforms.outShape[1];\n let r = i32(globalId.z) % uniforms.outShape[1];\n let c = i32(globalId.y) * ${this.workPerThread};\n let d1 = i32(globalId.x) * 4;\n\n let dyCorner = vec2(r, c) - uniforms.pads;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n var dotProd: array, ${this.workPerThread}>;\n for (var i = 0; i < ${this.workPerThread}; i++) {\n dotProd[i] = vec4(0.0);\n }\n for (var wR = 0; wR < uniforms.filterDims.x; wR = wR + 1) {\n let dyR = f32(dyCorner.x + wR) / f32(uniforms.strides.x);\n let wRPerm = uniforms.filterDims.x - 1 - wR;\n if (dyR < 0.0 || dyR >= f32(uniforms.outBackprop[1]) ||\n fract(dyR) > 0.0) {\n continue;\n }\n let idyR = i32(dyR);\n\n for (var wC = 0; wC < uniforms.filterDims.y; wC = wC + 1) {\n let dyC = f32(dyCorner.y + wC) / f32(uniforms.strides.y);\n let dyC2 = f32(dyCorner.y + 1 + wC) / f32(uniforms.strides.y);\n let wCPerm = uniforms.filterDims.y - 1 - wC;\n var bDyCVal = true;\n var bDyCVal2 = true;\n if (dyC < 0.0 || dyC >= f32(uniforms.outBackprop[2]) ||\n fract(dyC) > 0.0) {\n bDyCVal = false;\n }\n if (dyC2 < 0.0 || dyC2 >= f32(uniforms.outBackprop[2]) ||\n fract(dyC2) > 0.0) {\n bDyCVal2 = false;\n }\n\n let idyC = i32(dyC);\n let idyC2 = i32(dyC2);\n if (bDyCVal && bDyCVal2) {\n let d2Length = uniforms.outBackprop[3];\n for (var d2 = 0; d2 < d2Length; d2 = d2 + 4) {\n let wValue0 = getW(wRPerm, wCPerm, d1, d2);\n let wValue1 = getW(wRPerm, wCPerm, d1 + 1, d2);\n let wValue2 = getW(wRPerm, wCPerm, d1 + 2, d2);\n let wValue3 = getW(wRPerm, wCPerm, d1 + 3, d2);\n var xValue = getDy(batch, idyR, idyC, d2);\n let tmpval = vec4(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n dotProd[0] = dotProd[0] + tmpval;\n xValue = getDy(batch, idyR, idyC2, d2);\n dotProd[1] = dotProd[1] + vec4(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n }\n } else if (bDyCVal) {\n let d2Length = uniforms.outBackprop[3];\n for (var d2 = 0; d2 < d2Length; d2 = d2 + 4) {\n let wValue0 = getW(wRPerm, wCPerm, d1, d2);\n let wValue1 = getW(wRPerm, wCPerm, d1 + 1, d2);\n let wValue2 = getW(wRPerm, wCPerm, d1 + 2, d2);\n let wValue3 = getW(wRPerm, wCPerm, d1 + 3, d2);\n var xValue = getDy(batch, idyR, idyC, d2);\n let tmpval = vec4(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n dotProd[0] = dotProd[0] + tmpval;\n }\n } else if (bDyCVal2) {\n let d2Length = uniforms.outBackprop[3];\n for (var d2 = 0; d2 < d2Length; d2 = d2 + 4) {\n let wValue0 = getW(wRPerm, wCPerm, d1, d2);\n let wValue1 = getW(wRPerm, wCPerm, d1 + 1, d2);\n let wValue2 = getW(wRPerm, wCPerm, d1 + 2, d2);\n let wValue3 = getW(wRPerm, wCPerm, d1 + 3, d2);\n var xValue = getDy(batch, idyR, idyC2, d2);\n let tmpval = vec4(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n dotProd[1] = dotProd[1] + tmpval;\n }\n }\n }\n }\n\n for (var i = 0; i < ${this.workPerThread}; i = i + 1) {\n let coords = vec4(batch, r, c + i, d1);\n if (coordsInBounds4D(coords, uniforms.outShape)) {\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], dotProd[i]);\n }\n }\n }\n `; return this.isVec4 ? `\n ${r}\n ` : `\n ${uz("index")} {\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords[0];\n let d1 = coords[${n}];\n\n let dyCorner = vec2(coords[${e}], coords[${t}]) - uniforms.pads;\n let dyRCorner = dyCorner.x;\n let dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = 0.0;\n for (var wR = 0; wR < uniforms.filterDims.x; wR = wR + 1) {\n let dyR = (f32(dyRCorner) + f32(wR)) / f32(uniforms.strides.x);\n let wRPerm = uniforms.filterDims.x - 1 - wR;\n if (dyR < 0.0 || dyR >= f32(uniforms.outBackprop[1]) || fract(dyR) > 0.0 ||\n wRPerm < 0) {\n continue;\n }\n let idyR = i32(dyR);\n\n for (var wC = 0; wC < uniforms.filterDims.y; wC = wC + 1) {\n let dyC = (f32(dyCCorner) + f32(wC)) / f32(uniforms.strides.y);\n let wCPerm = uniforms.filterDims.y - 1 - wC;\n if (dyC < 0.0 || dyC >= f32(uniforms.outBackprop[2]) ||\n fract(dyC) > 0.0 || wCPerm < 0) {\n continue;\n }\n let idyC = i32(dyC);\n\n for (var d2 = 0; d2 < uniforms.outBackprop[3]; d2 = d2 + 1) {\n let xValue = ${this.isChannelsLast ? "getDy(batch, idyR, idyC, d2)" : "getDy(batch, d2, idyR, idyC)"};\n let wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd = dotProd + xValue * wValue;\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } class kL { constructor(e) { this.variableNames = ["x", "dy"], this.uniforms = "pads : vec2, strides : vec2, batchSize : i32, outHeight : i32, outWidth : i32, inHeight : i32, inWidth : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.filterShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.isChannelsLast = "channelsLast" === e.dataFormat, this.shaderKey = `conv2DDerFilter_${this.isChannelsLast}` } getUserCode() { return `\n ${uz("index")} {\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let wR = coords[0];\n let wC = coords[1];\n let d1 = coords[2];\n let d2 = coords[3];\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = 0.0;\n for (var b = 0; b < uniforms.batchSize; b = b + 1) {\n for (var yR = 0; yR < uniforms.outHeight; yR = yR + 1) {\n let xR = wR + yR * uniforms.strides[0] - uniforms.pads[0];\n if (xR < 0 || xR >= uniforms.inHeight) {\n continue;\n }\n\n for (var yC = 0; yC < uniforms.outWidth; yC = yC + 1) {\n let xC = wC + yC * uniforms.strides[1] - uniforms.pads[1];\n\n if (xC < 0 || xC >= uniforms.inWidth) {\n continue;\n }\n\n if (${this.isChannelsLast}) {\n let dyValue = getDy(b, yR, yC, d2);\n let xValue = getX(b, xR, xC, d1);\n dotProd = dotProd + xValue * dyValue;\n } else {\n let dyValue = getDy(b, d2, yR, yC);\n let xValue = getX(b, d1, xR, xC);\n dotProd = dotProd + xValue * dyValue;\n }\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } class SL { constructor(e) { this.variableNames = ["x", "dy"], this.uniforms = "pads : vec3, strides : vec3, batchSize : i32, outDepth : i32,\n outHeight : i32, outWidth : i32, inDepth : i32, inHeight : i32, inWidth : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.filterShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "conv3DDerFilter" } getUserCode() { return `\n ${uz("index")} {\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let wF = coords.x;\n let wR = coords.y;\n let wC = coords.z;\n let d1 = coords.w;\n let d2 = coords.u;\n\n var dotProd = 0.0;\n for (var b = 0; b < uniforms.batchSize; b++) {\n for (var yF = 0; yF < uniforms.outDepth; yF++) {\n let xF = wF + yF * uniforms.strides[0] - uniforms.pads[0];\n if (xF < 0 || xF >= uniforms.inDepth) {\n continue;\n }\n\n for (var yR = 0; yR < uniforms.outHeight; yR++) {\n let xR = wR + yR * uniforms.strides[1] - uniforms.pads[1];\n if (xR < 0 || xR >= uniforms.inHeight) {\n continue;\n }\n\n for (var yC = 0; yC < uniforms.outWidth; yC++) {\n let xC = wC + yC * uniforms.strides[2] - uniforms.pads[2];\n if (xC < 0 || xC >= uniforms.inWidth) {\n continue;\n }\n\n let dyValue = getDy(b, yF, yR, yC, d2);\n let xValue = getX(b, xF, xR, xC, d1);\n dotProd += xValue * dyValue;\n }\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } class _L { constructor(e) { this.variableNames = ["dy", "W"], this.uniforms = "filterDims : vec3, pads : vec3, strides : vec3,\n outDepth : i32, outHeight : i32, outWidth : i32, outChannels : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "conv3DDerInput" } getUserCode() { return `\n ${uz("index")} {\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords.x;\n let d1 = coords.u;\n\n let dyCorner = vec3(coords.y, coords.z, coords.w) - uniforms.pads;\n let dyFCorner = dyCorner.x;\n let dyRCorner = dyCorner.y;\n let dyCCorner = dyCorner.z;\n\n var dotProd = 0.0;\n for (var wF = 0; wF < uniforms.filterDims[0]; wF++) {\n let dyF = f32(dyFCorner + wF) / f32(uniforms.strides[0]);\n if (dyF < 0.0 || dyF >= f32(uniforms.outDepth) || fract(dyF) > 0.0) {\n continue;\n }\n let idyF = i32(dyF);\n\n let wFPerm = uniforms.filterDims[0] - 1 - wF;\n\n for (var wR = 0; wR < uniforms.filterDims[1]; wR++) {\n let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[1]);\n\n if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) {\n continue;\n }\n let idyR = i32(dyR);\n\n let wRPerm = uniforms.filterDims[1] - 1 - wR;\n\n for (var wC = 0; wC < uniforms.filterDims[2]; wC++) {\n let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[2]);\n\n if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) {\n continue;\n }\n let idyC = i32(dyC);\n\n let wCPerm = uniforms.filterDims[2] - 1 - wC;\n\n for (var d2 = 0; d2 < uniforms.outChannels; d2++) {\n let xValue = getDy(batch, idyF, idyR, idyC, d2);\n let wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } const CL = { + kernelName: P.Conv2DBackpropFilter, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, dataFormat: u, dimRoundingMode: l, filterShape: c } = r, h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, c, o, 1, s, l, !1, h), f = new kL(d), p = [{ type: "int32", data: [d.padInfo.top, d.padInfo.left] }, { type: "int32", data: [d.strideHeight, d.strideWidth] }, { type: "int32", data: [d.batchSize] }, { type: "int32", data: [d.outHeight] }, { type: "int32", data: [d.outWidth] }, { type: "int32", data: [d.inHeight] }, { type: "int32", data: [d.inWidth] }]; return n.runWebGPUProgram(f, [i, a], i.dtype, p) } + }; class AL { + constructor(e) { this.variableNames = ["x", "W"], this.uniforms = "filterDims : vec2, pads : vec2, strides : vec2, outBackprop : vec4, dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = e.inShape, P.util.assert("channelsLast" === e.dataFormat, (() => "TODO: NCHW is unimplemented")), this.isVec4 = e.inChannels % 4 == 0 && e.outChannels % 4 == 0, this.dispatchLayout = { x: [3], y: [1, 2], z: [0] }, this.workgroupSize = vz(this.dispatchLayout, this.outputShape, this.isVec4), this.elementsPerThread = xz(this.dispatchLayout, this.outputShape, this.isVec4), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, this.elementsPerThread), this.isVec4 && (this.outputComponent = 4, this.variableComponents = [4, 1]), this.shaderKey = `conv2DDerInputMM_${this.isVec4}_${this.elementsPerThread}` } getUserCode() { + const e = this.isVec4 ? jz(this.elementsPerThread, this.workgroupSize) : Wz(this.elementsPerThread, this.workgroupSize); return `\n ${ + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e = 4) { const t = `if (row < uniforms.dimAOuter && col < uniforms.dimInner) {\n \n let outRow = row / uniforms.outShape[2];\n let outCol = row % uniforms.outShape[2];\n\n let WRow = col / (uniforms.filterDims[1] * uniforms.outBackprop[3]);\n let WCol = col / uniforms.outBackprop[3] % uniforms.filterDims[1];\n let xR = f32(outRow - uniforms.pads[0] + WRow) / f32(uniforms.strides[0]);\n let xC = f32(outCol - uniforms.pads[1] + WCol) / f32(uniforms.strides[1]);\n if (xR < 0.0 || xR >= f32(uniforms.outBackprop[1]) || fract(xR) > 0.0) {\n return ${az(e)}(0.0);\n }\n if (xC < 0.0 || xC >= f32(uniforms.outBackprop[2]) || fract(xC) > 0.0) {\n return ${az(e)}(0.0);\n }\n let coord = vec4(\n batch,\n i32(xR),\n i32(xC),\n col % uniforms.outBackprop[3]);\n return x[getIndexFromCoords4D(coord, uniforms.xShape)/${e}];\n }\n return ${az(e)}(0.0);`; return `\n fn mm_readA(batch: i32, row : i32, col : i32) -> ${az(e)} {\n ${t}\n }\n\n fn mm_readB(batch: i32, row : i32, col : i32) -> ${az(e)} {\n let coordX = uniforms.filterDims.x - 1 -\n row / (uniforms.filterDims[1] * uniforms.outBackprop[3]);\n let coordY = uniforms.filterDims.y - 1 -\n (row / uniforms.outBackprop[3]) % uniforms.filterDims[1];\n if (row < uniforms.dimInner && col < uniforms.dimBOuter &&\n coordX >= 0 && coordY >= 0) {\n let rowInner = row % uniforms.outBackprop[3];\n let coord = vec4(coordX, coordY, col, rowInner);\n ${(e => { switch (e) { case 1: return "return W[getIndexFromCoords4D(coord, uniforms.wShape)];"; case 4: return "\n let coord1 = vec4(coordX, coordY, col + 1, rowInner);\n let coord2 = vec4(coordX, coordY, col + 2, rowInner);\n let coord3 = vec4(coordX, coordY, col + 3, rowInner);\n let v0 = W[getIndexFromCoords4D(coord, uniforms.wShape)];\n let v1 = W[getIndexFromCoords4D(coord1, uniforms.wShape)];\n let v2 = W[getIndexFromCoords4D(coord2, uniforms.wShape)];\n let v3 = W[getIndexFromCoords4D(coord3, uniforms.wShape)];\n return vec4(v0, v1, v2, v3);\n "; default: throw new Error(`innerElementSize ${e} is not supported.`) } })(e)}\n }\n return ${az(e)}(0.0);\n }\n\n fn mm_write(batch: i32, row : i32, col : i32, valueInput : ${az(e)}) {\n if (row < uniforms.dimAOuter && col < uniforms.dimBOuter) {\n var value = valueInput;\n let outCoord = vec4(\n batch,\n row / uniforms.outShape[2],\n row % uniforms.outShape[2],\n col);\n result[getIndexFromCoords4D(outCoord, uniforms.outShape)/${e}] = value;\n }\n }` }(this.isVec4 ? 4 : 1)}\n ${e}\n ` + } + } const TL = { + kernelName: P.Conv2DBackpropInput, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { inputShape: o, strides: s, pad: u, dataFormat: l, dimRoundingMode: c } = r, h = P.backend_util.convertConv2DDataFormat(l), d = P.backend_util.computeConv2DInfo(o, a.shape, s, 1, u, c, !1, h), f = [{ type: "int32", data: [d.filterHeight, d.filterWidth] }, { type: "int32", data: [d.filterHeight - 1 - d.padInfo.top, d.filterWidth - 1 - d.padInfo.left] }, { type: "int32", data: [d.strideHeight, d.strideWidth] }, { type: "int32", data: [d.batchSize, d.outHeight, d.outWidth, d.outChannels] }]; let p; if ((0, P.env)().getBool("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE") || "channelsLast" !== d.dataFormat) p = new wL(d); else { p = new AL(d); const e = d.inHeight * d.inWidth, t = d.inChannels, n = d.filterHeight * d.filterWidth * d.outChannels; f.push({ type: "uint32", data: [e] }, { type: "uint32", data: [t] }, { type: "uint32", data: [n] }) } return n.runWebGPUProgram(p, [i, a], "float32", f) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class EL { constructor(e) { this.variableNames = ["x", "W"], this.uniforms = "filterDims: vec3, pads: vec3, strides: vec3, dilations: vec3,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.outShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "conv3dnaive" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let batch = coords.x;\n let d2 = coords.u;\n\n let xFRCCorner = vec3(coords.y, coords.z, coords.w) * uniforms.strides - uniforms.pads;\n let xFCorner = xFRCCorner.x;\n let xRCorner = xFRCCorner.y;\n let xCCorner = xFRCCorner.z;\n\n let inputDepthNearestVec4 = (uniforms.xShape.u / 4) * 4;\n let inputDepthVec4Remainder = uniforms.xShape.u % 4;\n\n var dotProd = 0.0;\n for (var wF = 0; wF < uniforms.filterDims[0]; wF++) {\n let xF = xFCorner + wF * uniforms.dilations[0];\n if (xF < 0 || xF >= uniforms.xShape.y) {\n continue;\n }\n\n for (var wR = 0; wR < uniforms.filterDims[1]; wR++) {\n let xR = xRCorner + wR * uniforms.dilations[1];\n if (xR < 0 || xR >= uniforms.xShape.z) {\n continue;\n }\n\n for (var wC = 0; wC < uniforms.filterDims[2]; wC++) {\n let xC = xCCorner + wC * uniforms.dilations[2];\n if (xC < 0 || xC >= uniforms.xShape.w) {\n continue;\n }\n\n for (var d1 = 0; d1 < inputDepthNearestVec4; d1 += 4) {\n let xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n let wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (inputDepthVec4Remainder == 1) {\n dotProd += getX(batch, xF, xR, xC, inputDepthNearestVec4) *\n getW(wF, wR, wC, inputDepthNearestVec4, d2);\n } else if (inputDepthVec4Remainder == 2) {\n let xValues = vec2(\n getX(batch, xF, xR, xC, inputDepthNearestVec4),\n getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1)\n );\n let wValues = vec2(\n getW(wF, wR, wC, inputDepthNearestVec4, d2),\n getW(wF, wR, wC, inputDepthNearestVec4 + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (inputDepthVec4Remainder == 3) {\n let xValues = vec3(\n getX(batch, xF, xR, xC, inputDepthNearestVec4),\n getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1),\n getX(batch, xF, xR, xC, inputDepthNearestVec4 + 2)\n );\n let wValues = vec3(\n getW(wF, wR, wC, inputDepthNearestVec4, d2),\n getW(wF, wR, wC, inputDepthNearestVec4 + 1, d2),\n getW(wF, wR, wC, inputDepthNearestVec4 + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }` } } const NL = { + kernelName: P.Conv3D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r, l = P.backend_util.computeConv3DInfo(i.shape, a.shape, o, u, s), c = [l.padInfo.front, l.padInfo.top, l.padInfo.left], h = [{ type: "int32", data: [l.filterDepth, l.filterHeight, l.filterWidth] }, { type: "int32", data: [...c] }, { type: "int32", data: [l.strideDepth, l.strideHeight, l.strideWidth] }, { type: "int32", data: [l.dilationDepth, l.dilationHeight, l.dilationWidth] }], d = new EL(l), f = (0, P.upcastType)(i.dtype, a.dtype); return n.runWebGPUProgram(d, [i, a], f, h) } + }; const IL = { + kernelName: P.Conv3DBackpropFilterV2, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, filterShape: u } = r, l = P.backend_util.computeConv3DInfo(i.shape, u, o, 1, s), c = new SL(l), h = [{ type: "int32", data: [l.padInfo.front, l.padInfo.top, l.padInfo.left] }, { type: "int32", data: [l.strideDepth, l.strideHeight, l.strideWidth] }, { type: "int32", data: [l.batchSize] }, { type: "int32", data: [l.outDepth] }, { type: "int32", data: [l.outHeight] }, { type: "int32", data: [l.outWidth] }, { type: "int32", data: [l.inDepth] }, { type: "int32", data: [l.inHeight] }, { type: "int32", data: [l.inWidth] }]; return n.runWebGPUProgram(c, [i, a], a.dtype, h) } + }; const ML = { + kernelName: P.Conv3DBackpropInputV2, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { strides: o, pad: s, inputShape: u } = r, l = P.backend_util.computeConv3DInfo(u, a.shape, o, 1, s), c = new _L(l), h = [{ type: "int32", data: [l.filterDepth, l.filterHeight, l.filterWidth] }, { type: "int32", data: [l.filterDepth - 1 - l.padInfo.front, l.filterHeight - 1 - l.padInfo.top, l.filterWidth - 1 - l.padInfo.left] }, { type: "int32", data: [l.strideDepth, l.strideHeight, l.strideWidth] }, { type: "int32", data: [l.outDepth] }, { type: "int32", data: [l.outHeight] }, { type: "int32", data: [l.outWidth] }, { type: "int32", data: [l.outChannels] }]; return n.runWebGPUProgram(c, [i, a], i.dtype, h) } + }, FL = lP({ opType: Fz.COS }), DL = { kernelName: P.Cos, backendName: "webgpu", kernelFunc: FL }, $L = lP({ opType: Fz.COSH }), RL = { kernelName: P.Cosh, backendName: "webgpu", kernelFunc: $L }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class OL { constructor(e, t, n, r) { this.variableNames = ["Image", "Boxes", "BoxInd"], this.uniforms = "extrapolationValue : f32,", this.workgroupSize = [64, 1, 1], this.size = !0; const [i] = t; this.outputShape = [i, n[0], n[1], e], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.methodId = "bilinear" === r ? 1 : 0, this.cropHeightBiggerThan1 = this.outputShape[1] > 1, this.cropWidthBiggerThan1 = this.outputShape[2] > 1, this.shaderKey = `cropAndResize_${this.methodId}_${this.cropHeightBiggerThan1}_${this.cropWidthBiggerThan1}` } getUserCode() { const [e, t] = ["f32(uniforms.imageShape[1] - 1)", "f32(uniforms.imageShape[2] - 1)"], [n, r, i] = this.cropHeightBiggerThan1 ? [`(${e} / f32(uniforms.outShape[1] - 1))`, "(y2-y1) * height_ratio", `y1*${e} + f32(y)*(height_scale)`] : ["0.0", "0.0", `0.5 * (y1+y2) * ${e}`], [a, o, s] = this.cropWidthBiggerThan1 ? [`(${t} / f32(uniforms.outShape[2] - 1))`, "(x2-x1) * width_ratio", `x1*${t} + f32(x)*(width_scale)`] : ["0.0", "0.0", `0.5 * (x1+x2) * ${t}`]; return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let height_ratio = f32(${n});\n let width_ratio = f32(${a});\n let b = coords[0];\n let y = coords[1];\n let x = coords[2];\n let d = coords[3];\n // get box vals\n let y1 = getBoxes(b, 0);\n let x1 = getBoxes(b, 1);\n let y2 = getBoxes(b, 2);\n let x2 = getBoxes(b, 3);\n // get image in batch index\n let bInd = i32(round(getBoxInd(b)));\n if(bInd < 0 || bInd >= uniforms.outShape[0]) {\n return;\n }\n let height_scale = ${r};\n let width_scale = ${o};\n let in_y = ${i};\n if( in_y < 0.0 || in_y > ${e} ) {\n setOutputAtIndex(index, uniforms.extrapolationValue);\n return;\n }\n let in_x = ${s};\n if( in_x < 0.0 || in_x > ${t} ) {\n setOutputAtIndex(index, uniforms.extrapolationValue);\n return;\n }\n let sourceFracIndexCR = vec2(in_x,in_y);\n if(${this.methodId} == 1) {\n // Compute the four integer indices.\n let sourceFloorCR = vec2(sourceFracIndexCR);\n let sourceCeilCR = vec2(ceil(sourceFracIndexCR));\n let topLeft = getImage(bInd, sourceFloorCR.y, sourceFloorCR.x, d);\n let bottomLeft = getImage(bInd, sourceCeilCR.y, sourceFloorCR.x, d);\n let topRight = getImage(bInd, sourceFloorCR.y, sourceCeilCR.x, d);\n let bottomRight = getImage(bInd, sourceCeilCR.y, sourceCeilCR.x, d);\n let fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n let top = topLeft + (topRight - topLeft) * fracCR.x;\n let bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n let newValue = top + (bottom - top) * fracCR.y;\n setOutputAtIndex(index, newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n let sourceNearestCR = vec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n let newValue = getImage(\n bInd, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutputAtIndex(index, newValue);\n }\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const zL = { kernelName: P.CropAndResize, backendName: "webgpu", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { image: i, boxes: a, boxInd: o } = t, { cropSize: s, method: u, extrapolationValue: l } = r, c = new OL(i.shape[3], a.shape, s, u), h = [{ type: "float32", data: [l] }]; return n.runWebGPUProgram(c, [i, a, o], "float32", h) } }; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var PL; !function (e) { e.Prod = "*", e.Sum = "+" }(PL || (PL = {})); class BL { constructor(e, t, n, r) { this.variableNames = ["x"], this.uniforms = "index : f32,", this.size = !0, this.workgroupSize = [128, 1, 1], this.outputShape = t, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.exclusive = n, this.reverse = r, this.op = e, this.shaderKey = `cum_${this.op}_${this.exclusive}_${this.reverse}` } getUserCode() { const e = this.outputShape.length, t = this.op === PL.Prod ? "1.0" : "0.0", n = this.exclusive ? t : `getX(${LL(e, "coords", this.op)})`, r = this.outputShape[this.outputShape.length - 1]; let i = "", a = ""; return this.exclusive ? (i = this.reverse ? "end != " + (r - 1) : "end != 0", a = this.reverse ? "end + 1" : "end - 1") : (i = this.reverse ? `end + pow2 < ${r}` : "end >= pow2", a = this.reverse ? "end + pow2" : "end - pow2"), `\n ${uz("index")} {\n if (index < uniforms.size) {\n var coords = getCoordsFromIndex(index);\n\n let end = ${jL(e, "coords", this.op)};\n var val = ${n};\n let pow2 = i32(pow(2.0, uniforms.index));\n if (${i}) {\n let idx = ${a};\n ${jL(e, "coords", this.op)} = idx;\n val ${this.op}= getX(${LL(e, "coords", this.op)});\n }\n setOutputAtIndex(index, val);\n }\n }\n ` } } function LL(e, t, n) { if (1 === e) return `${t}`; if (2 === e) return `${t}.x, ${t}.y`; if (3 === e) return `${t}.x, ${t}.y, ${t}.z`; if (4 === e) return `${t}.x, ${t}.y, ${t}.z, ${t}.w`; throw Error(`Cumulative ${n} for rank ${e} is not yet supported`) } function jL(e, t, n) { if (1 === e) return `${t}`; if (2 === e) return `${t}.y`; if (3 === e) return `${t}.z`; if (4 === e) return `${t}.w`; throw Error(`Cumulative ${n} for rank ${e} is not yet supported`) } + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function UL(e, t, n, r, i, a) { const o = t.shape.length, s = P.backend_util.getAxesPermutation([r], o); let u = t; null != s && (u = aB({ inputs: { x: t }, backend: n, attrs: { perm: s } })); const l = P.backend_util.getInnerMostAxes(1, o)[0]; if (l !== o - 1) throw new Error(`WebGPU cumprod shader expects an inner-most axis=${t.shape.length - 1} but got axis=${r}`); const c = u.shape[l]; let h = iP({ inputs: { x: u }, backend: n }); for (let t = 0; t <= Math.ceil(Math.log2(c)) - 1; t++) { const r = new BL(e, u.shape, !1, a), i = h, o = [{ type: "float32", data: [t] }]; h = n.runWebGPUProgram(r, [h], h.dtype, o), n.disposeData(i.dataId) } if (i) { const t = new BL(e, u.shape, i, a), r = h, o = [{ type: "float32", data: [0] }]; h = n.runWebGPUProgram(t, [h], h.dtype, o), n.disposeData(r.dataId) } if (null != s) { const e = aB({ inputs: { x: h }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(s) } }); return n.disposeData(h.dataId), n.disposeData(u.dataId), e } return h } const WL = { + kernelName: P.Cumprod, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; return UL(PL.Prod, i, n, a, o, s) } + }; const VL = { + kernelName: P.Cumsum, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; return UL(PL.Sum, i, n, a, o, s) } + }; const GL = { + kernelName: P.DenseBincount, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o, binaryOutput: s } = r, u = 1 === i.shape.length, l = P.util.sizeFromShape(a.shape) > 0, c = a.dtype, h = u ? [i.shape[0]] : [i.shape[0], i.shape[1]], d = Kz({ backend: n, attrs: { shape: u ? [o] : [i.shape[0], o], value: 0, dtype: c } }), f = new HB(h, l, s), p = [{ type: "int32", data: [o] }], m = l ? [i, a] : [i]; return n.runWebGPUProgram(f, m, c, p, d) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class HL { constructor(e, t) { this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.uniforms = "blockSize : i32,", this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = `depthToSpace_${t}`, this.dataFormat = t } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let b = coords[0];\n let h = ${this.getHeightCoordString()};\n let w = ${this.getWidthCoordString()};\n let d = ${this.getDepthCoordString()};\n\n let in_h = h / uniforms.blockSize;\n let offset_h = h % uniforms.blockSize;\n let in_w = w / uniforms.blockSize;\n let offset_w = w % uniforms.blockSize;\n let offset_d = (offset_h * uniforms.blockSize + offset_w) *\n ${this.getOutputDepthSize()};\n let in_d = d + offset_d;\n\n let rlt = ${this.getInputSamplingString()};\n setOutputAtIndex(index, rlt);\n }\n }` } getHeightCoordString() { return "NHWC" === this.dataFormat ? "coords[1]" : "coords[2]" } getWidthCoordString() { return "NHWC" === this.dataFormat ? "coords[2]" : "coords[3]" } getDepthCoordString() { return "NHWC" === this.dataFormat ? "coords[3]" : "coords[1]" } getOutputDepthSize() { return "NHWC" === this.dataFormat ? "uniforms.outShape[3]" : "uniforms.outShape[1]" } getInputSamplingString() { return "NHWC" === this.dataFormat ? "getX(b, in_h, in_w, in_d)" : "getX(b, in_d, in_h, in_w)" } } const qL = { + kernelName: P.DepthToSpace, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockSize: a, dataFormat: o } = r, s = i.shape[0], u = ("NHWC" === o ? i.shape[1] : i.shape[2]) * a, l = ("NHWC" === o ? i.shape[2] : i.shape[3]) * a, c = ("NHWC" === o ? i.shape[3] : i.shape[1]) / (a * a), h = [{ type: "int32", data: [a] }], d = new HL("NHWC" === o ? [s, u, l, c] : [s, c, u, l], o); return n.runWebGPUProgram(d, [i], i.dtype, h) } + }; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class YL { constructor(e, t, n, r = !1, i = null, a = !1) { this.variableNames = ["x", "W"], this.uniforms = "pads : vec2, inDims : vec2,", this.workgroupSize = [16, 16, 1], this.outputShape = e, this.dispatchLayout = { x: [3], y: [2], z: [0, 1] }, this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), r && this.variableNames.push("bias"), a && this.variableNames.push("preluActivationWeights"), this.addBias = r, this.activation = i, this.hasPreluActivation = a, this.filterHeight = t, this.filterWidth = n, this.shaderKey = `depthwiseNCHW_${this.activation}_${this.filterHeight}_${this.filterWidth}` } getUserCode() { const e = this.filterWidth * this.filterHeight, t = this.workgroupSize[0] * this.workgroupSize[1] * this.workgroupSize[2], n = this.workgroupSize[1] + this.filterHeight - 1, r = this.workgroupSize[0] + this.filterWidth - 1; return `\n ${zz(this.activation, this.hasPreluActivation, !1, 4)}\n\n var mm_Asub : array, ${n}>;\n var mm_Bsub : array, ${this.filterHeight}>;\n fn readX(batch : i32, channel : i32, row : i32, col : i32) -> f32 {\n var value = 0.0;\n if (row >=0 && row < uniforms.inDims[0] && col >=0 && col < uniforms.inDims[1])\n {\n value = getX(batch, channel, row, col);\n }\n return value;\n }\n\n ${uz()} {\n let coords = getOutputCoords();\n let batch = coords[0];\n let xRCCorner = vec2(coords.zw) - uniforms.pads;\n let channelMul = uniforms.wShape[3];\n let d1 = coords[1] / channelMul;\n let q = coords[1] % channelMul;\n\n let inputRowStart = xRCCorner.x;\n let inputColStart = xRCCorner.y;\n\n let localRow = i32(localId.y);\n let localCol = i32(localId.x);\n\n // Load one tile of X into local memory.\n for (var inputRow = localRow; inputRow < ${n}; inputRow = inputRow + ${this.workgroupSize[1]}) {\n for (var inputCol = localCol; inputCol < ${r}; inputCol = inputCol + ${this.workgroupSize[0]}) {\n let rowOffset = inputRow - localRow;\n let colOffset = inputCol - localCol;\n mm_Asub[inputRow][inputCol] = readX(batch, d1, inputRowStart + rowOffset, inputColStart + colOffset);\n }\n }\n\n // Load one tile of W into local memory.\n var wIndex = i32(localIndex);\n ${e < t ? `if (wIndex < ${e})` : `for(; wIndex < ${e}; wIndex = wIndex + ${t})`}\n\n {\n let wRow = wIndex / ${this.filterWidth};\n let wCol = wIndex % ${this.filterWidth};\n mm_Bsub[wRow][wCol] = getW(wRow, wCol, d1, q);\n }\n\n workgroupBarrier();\n\n var value = 0.0;\n for (var wR = 0; wR < ${this.filterHeight}; wR = wR + 1) {\n for (var wC = 0; wC < ${this.filterWidth}; wC = wC + 1) {\n let xVal = mm_Asub[localRow + wR][localCol + wC];\n let wVal = mm_Bsub[wR][wC];\n value = fma(xVal, wVal, value);\n }\n }\n ${Pz(this.addBias, this.activation)}\n if (coordsInBounds4D(coords, uniforms.outShape)) {\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class XL { constructor(e, t = !1, n = null, r = !1) { this.variableNames = ["x", "W"], this.uniforms = "pads : vec2, inDims : vec2, virtualWidth : i32,", this.workgroupSize = [64, 1, 1], this.workPerThread = 4, this.outputComponent = 4, this.outputShape = e.outShape, this.virtualWidth = Math.ceil(this.outputShape[2] / this.workPerThread) * this.workPerThread; const i = [this.outputShape[0], this.outputShape[1], this.virtualWidth, this.outputShape[3]]; this.dispatchLayout = wz(i), this.dispatch = bz(this.dispatchLayout, i, this.workgroupSize, [this.outputComponent * this.workPerThread, 1, 1]), P.util.assert("channelsLast" === e.dataFormat, (() => "TODO: NCHW is unimplemented")), t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), this.convInfo = e, this.addBias = t, this.activation = n, this.hasPreluActivation = r, this.shaderKey = `depthwiseVec4_${n}_${this.convInfo.filterHeight}_${this.convInfo.filterWidth}_${this.convInfo.strideHeight}_${this.convInfo.strideWidth}_${this.workPerThread}` } getUserCode() { const e = (this.workPerThread - 1) * this.convInfo.strideWidth + this.convInfo.filterWidth, t = this.convInfo.strideHeight, n = this.convInfo.strideWidth; return `\n ${zz(this.activation, this.hasPreluActivation, !0, 4)}\n fn readX(batch : i32, row : i32, col : i32, channel : i32) -> vec4 {\n var value = vec4(0.0);\n if (col >=0 && col < uniforms.inDims[1]) {\n value = getX(batch, row, col, channel);\n }\n return value;\n }\n\n ${uz("index")} {\n let width0 = uniforms.outShape[3] / ${this.outputComponent};\n let d1 = (index % width0) * ${this.outputComponent};\n var index1 = index / width0;\n let width1 = uniforms.virtualWidth / ${this.workPerThread};\n let c = (index1 % width1) * ${this.workPerThread};\n index1 = index1 / width1;\n let r = index1 % uniforms.outShape[1];\n let batch = index1 / uniforms.outShape[1];\n\n let xRCCorner = vec2(r, c) * vec2(${t}, ${n}) - uniforms.pads;\n\n let xRCorner = xRCCorner.x;\n let xCCorner = xRCCorner.y;\n var xVals : array, ${e}>;\n var dotProd : array, ${this.workPerThread}>;\n for (var i = 0; i < ${this.workPerThread}; i++) {\n dotProd[i] = vec4(0.0);\n }\n\n // Use constant instead of uniform can give better performance.\n for (var wR = 0; wR < ${this.convInfo.filterHeight}; wR = wR + 1) {\n let xR = xRCorner + wR;\n if (xR >=0 && xR < uniforms.inDims[0]) {\n for (var i = 0; i < ${e}; i++) {\n xVals[i] = readX(batch, xR, xCCorner + i, d1);\n }\n for (var wC = 0; wC < ${this.convInfo.filterWidth}; wC = wC + 1) {\n let wValue = getW(wR, wC, d1, 0);\n for (var i = 0; i < ${this.workPerThread}; i++) {\n dotProd[i] = fma(xVals[i * ${n} + wC], wValue, dotProd[i]);\n }\n }\n }\n }\n\n for (var i = 0; i < ${this.workPerThread}; i = i + 1) {\n let coords = vec4(batch, r, c + i, d1);\n if (coordsInBounds4D(coords, uniforms.outShape)) {\n var value = dotProd[i];\n ${Pz(this.addBias, this.activation)}\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);\n }\n }\n }\n ` } } + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class KL { constructor(e, t = !1, n = null, r = !1) { this.variableNames = ["x", "W"], this.uniforms = "pads : vec2, inDims : vec2, filterHeight : i32,\n filterWidth : i32, strides : vec2, dilations : vec2,", this.workgroupSize = [256, 1, 1], this.size = !0, this.outputShape = e.outShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.isChannelsLast = "channelsLast" === e.dataFormat, t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), this.convInfo = e, this.addBias = t, this.activation = n, this.hasPreluActivation = r, this.shaderKey = `depthwise_${this.activation}_${this.isChannelsLast}` } getUserCode() { const e = this.isChannelsLast ? "getX(batch, xR, xC, d1);" : "getX(batch, d1, xR, xC);"; return `\n ${zz(this.activation, this.hasPreluActivation, !1, 4)}\n\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let batch = coords[0];\n let xRCCorner = vec2(coords.${this.isChannelsLast ? "yz" : "zw"}) * uniforms.strides - uniforms.pads;\n let d2 = coords[${this.isChannelsLast ? 3 : 1}];\n let channelMul = uniforms.wShape[3];\n let d1 = d2 / channelMul;\n let q = d2 % channelMul;\n\n let inputRowStart = xRCCorner.x;\n let inputColStart = xRCCorner.y;\n let inputRowEnd = inputRowStart + uniforms.filterHeight *\n uniforms.dilations[0];\n let inputColEnd = inputColStart + uniforms.filterWidth *\n uniforms.dilations[1];\n\n // Convolve x(?, ?, d1)|x(d1, ?, ?) with w(:, :, d1, q) to get\n // y(yR, yC, d2)|y(d2, yR, yC). ? = to be determined. : = across all\n // values in that axis. x(?, ?, d1) and y(yR, yC, d2) is for NHWC.\n // x(d1, ?, ?) and y(d2, yR, yC) is for NCHW.\n var value = 0.0;\n\n // Extract if checking out of for loop for performance.\n if (inputRowStart >= 0 && inputColStart >= 0 &&\n inputRowEnd < uniforms.inDims[0] &&\n inputColEnd < uniforms.inDims[1]) {\n for (var wR = 0; wR < uniforms.filterHeight; wR = wR + 1) {\n let xR = inputRowStart + wR * uniforms.dilations[0];\n\n for (var wC = 0; wC < uniforms.filterWidth; wC = wC + 1) {\n let xC = inputColStart + wC * uniforms.dilations[1];\n\n let xVal = ${e};\n let wVal = getW(wR, wC, d1, q);\n value = value + xVal * wVal;\n }\n }\n } else {\n for (var wR = 0; wR < uniforms.filterHeight; wR = wR + 1) {\n let xR = inputRowStart + wR * uniforms.dilations[0];\n\n if (xR < 0 || xR >= uniforms.inDims[0]) {\n continue;\n }\n\n for (var wC = 0; wC < uniforms.filterWidth; wC = wC + 1) {\n let xC = inputColStart + wC * uniforms.dilations[1];\n\n if (xC < 0 || xC >= uniforms.inDims[1]) {\n continue;\n }\n\n let xVal = ${e};\n let wVal = getW(wR, wC, d1, q);\n value = value + xVal * wVal;\n }\n }\n }\n ${Pz(this.addBias, this.activation)}\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);\n }\n }\n ` } } const ZL = { + kernelName: P.DepthwiseConv2dNative, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dataFormat: u, dilations: l, dimRoundingMode: c } = r, h = P.backend_util.convertConv2DDataFormat(u); let d = l; null == d && (d = [1, 1]); const f = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, d, s, c, !0, h), p = [{ type: "int32", data: [f.padInfo.top, f.padInfo.left] }, { type: "int32", data: [f.inHeight, f.inWidth] }], m = "channelsLast" === f.dataFormat; let g; return !m && f.inHeight > 16 && f.inWidth > 16 && 1 === f.strideHeight && 1 === f.strideWidth && 1 === f.dilationWidth && 1 === f.dilationHeight && f.inChannels === f.outChannels ? g = new YL(f.outShape, f.filterHeight, f.filterWidth) : m && f.outHeight > 4 && f.outWidth > 4 && f.strideWidth <= 2 && f.inChannels === f.outChannels && 1 === f.dilationHeight && 1 === f.dilationWidth && f.inChannels % 4 == 0 ? (g = new XL(f), p.push({ type: "int32", data: [g.virtualWidth] })) : (g = new KL(f), p.push({ type: "int32", data: [f.filterHeight] }, { type: "int32", data: [f.filterWidth] }, { type: "int32", data: [f.strideHeight, f.strideWidth] }, { type: "int32", data: [f.dilationHeight, f.dilationWidth] })), n.runWebGPUProgram(g, [i, a], i.dtype, p) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class JL { constructor(e) { this.variableNames = ["x", "dy"], this.uniforms = "strides : vec2, pads : vec2, filterDims : vec2, outHeight : i32,\n outWidth : i32, inHeight : i32, inWidth : i32, batchSize : i32, channelMul : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.filterShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "depthwise_conv2d_backprop_filter" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let wR = coords[0];\n let wC = coords[1];\n let d1 = coords[2];\n let dm = coords[3];\n let d2 = d1 * uniforms.channelMul + dm;\n\n var dotProd = 0.0;\n for (var b = 0; b < uniforms.batchSize; b++) {\n for (var yR = 0; yR < uniforms.outHeight; yR++) {\n let xR = wR + yR * uniforms.strides[0] - uniforms.pads[0];\n\n if (xR < 0 || xR >= uniforms.inHeight) {\n continue;\n }\n\n for (var yC = 0; yC < uniforms.outWidth; yC++) {\n let xC = wC + yC * uniforms.strides[1] - uniforms.pads[1];\n\n if (xC < 0 || xC >= uniforms.inWidth) {\n continue;\n }\n\n let dyValue = getDy(b, yR, yC, d2);\n let xValue = getX(b, xR, xC, d1);\n dotProd += xValue * dyValue;\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } class QL { constructor(e) { this.variableNames = ["dy", "W"], this.uniforms = "strides : vec2, pads : vec2, filterDims : vec2,\n outHeight : i32, outWidth : i32, channelMul : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "depthwise_conv2d_backprop_input" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords[0];\n let d1 = coords[3];\n let dyCorner = coords.yz - uniforms.pads;\n let dyRCorner = dyCorner.x;\n let dyCCorner = dyCorner.y;\n\n var dotProd = 0.0;\n for (var wR = 0; wR < uniforms.filterDims[0]; wR++) {\n let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[0]);\n\n if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) {\n continue;\n }\n\n let idyR = i32(dyR);\n let wRPerm = uniforms.filterDims[0] - 1 - wR;\n\n for (var wC = 0; wC < uniforms.filterDims[1]; wC++) {\n let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[1]);\n\n if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) {\n continue;\n }\n\n let idyC = i32(dyC);\n let wCPerm = uniforms.filterDims[1] - 1 - wC;\n\n for (var dm = 0; dm < uniforms.channelMul; dm++) {\n let d2 = d1 * uniforms.channelMul + dm;\n let xValue = getDy(batch, idyR, idyC, d2);\n let wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } const ej = { + kernelName: P.DepthwiseConv2dNativeBackpropFilter, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, filterShape: c } = r, h = P.backend_util.computeConv2DInfo(i.shape, c, o, s, u, l, !0), d = new JL(h), f = [{ type: "int32", data: [h.strideHeight, h.strideWidth] }, { type: "int32", data: [h.padInfo.top, h.padInfo.left] }, { type: "int32", data: [h.filterHeight, h.filterWidth] }, { type: "int32", data: [h.outHeight] }, { type: "int32", data: [h.outWidth] }, { type: "int32", data: [h.inHeight] }, { type: "int32", data: [h.inWidth] }, { type: "int32", data: [h.batchSize] }, { type: "int32", data: [h.outChannels / h.inChannels] }]; return n.runWebGPUProgram(d, [i, a], "float32", f) } + }; const tj = { + kernelName: P.DepthwiseConv2dNativeBackpropInput, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, inputShape: c } = r, h = P.backend_util.computeConv2DInfo(c, a.shape, o, s, u, l, !0), d = new QL(h), f = [{ type: "int32", data: [h.strideHeight, h.strideWidth] }, { type: "int32", data: [h.filterHeight - 1 - h.padInfo.top, h.filterWidth - 1 - h.padInfo.left] }, { type: "int32", data: [h.filterHeight, h.filterWidth] }, { type: "int32", data: [h.outHeight] }, { type: "int32", data: [h.outWidth] }, { type: "int32", data: [h.outChannels / h.inChannels] }]; return n.runWebGPUProgram(d, [i, a], i.dtype, f) } + }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class nj { constructor(e) { this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e, e], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "diag" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let value = select(0.0, getX(coords[0]), coords[0] == coords[1]);\n setOutputAtIndex(index, value);\n }\n }\n ` } } const rj = { + kernelName: P.Diag, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = [...r.shape, ...r.shape], a = P.util.sizeFromShape(r.shape), o = Jz({ inputs: { x: r }, backend: n, attrs: { shape: [a] } }), s = new nj(a), u = n.runWebGPUProgram(s, [o], o.dtype), l = Jz({ inputs: { x: u }, backend: n, attrs: { shape: i } }); return n.disposeData(o.dataId), n.disposeData(u.dataId), l } + }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class ij { constructor(e) { this.variableNames = ["x", "w"], this.uniforms = "filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.outShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "dilation2d" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let neg_infinity = -3.4e38;\n let coords = getOutputCoords();\n let batch = coords.x;\n let d1 = coords.w;\n let outTopLeftCorner = coords.yz * uniforms.strides - uniforms.pads;\n let hBeg = outTopLeftCorner.x;\n let wBeg = outTopLeftCorner.y;\n\n var curVal = neg_infinity;\n for (var h = 0; h < uniforms.filterDims[0]; h = h + 1) {\n let hIn = hBeg + h * uniforms.dilations[0];\n\n if (hIn >= 0 && hIn < uniforms.xShape[1]) {\n for (var w = 0; w < uniforms.filterDims[1]; w = w + 1) {\n let wIn = wBeg + w * uniforms.dilations[1];\n\n if (wIn >= 0 && wIn < uniforms.xShape[2]) {\n let val = getX(batch, hIn, wIn, d1) + getW(h, w, d1);\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n setOutputAtIndex(index, curVal);\n }\n }\n ` } } const aj = { + kernelName: P.Dilation2D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r, l = P.backend_util.computeDilation2DInfo(i.shape, a.shape, o, s, "NHWC", u), c = [l.padInfo.top, l.padInfo.left], h = [{ type: "int32", data: [l.filterHeight, l.filterWidth] }, { type: "int32", data: [...c] }, { type: "int32", data: [l.strideHeight, l.strideWidth] }, { type: "int32", data: [l.dilationHeight, l.dilationWidth] }], d = new ij(l); return n.runWebGPUProgram(d, [i, a], i.dtype, h) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class oj { constructor(e, t) { if (this.variableNames = ["x", "w", "dy"], this.uniforms = "filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2, dySize: i32,", this.workgroupSize = [64, 1, 1], this.atomic = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(e.outShape), this.dispatch = bz(this.dispatchLayout, e.outShape, this.workgroupSize), "float32" !== t && "int32" !== t) throw new Error(`Dilation2DBackpropInput only supports float32 and int32\n types, does not support ${t} type.`); this.type = t, this.shaderKey = "dilation2DBackpropInput" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.dySize) {\n let coords = getDyCoordsFromIndex(index);\n let b = coords[0];\n let r = coords[1];\n let c = coords[2];\n let d = coords[3];\n\n let dyCorner = vec2(r, c) * uniforms.strides - uniforms.pads;\n var curVal = -3.4e38; // neg_infinity\n var xRMax = 0;\n var xCMax = 0;\n\n // In the case of multiple argmax branches, we only back-propagate\n // along the last branch, i.e., the one with largest value of\n // 'wR * uniforms.filterDims[1] + wC', similarly to the max-pooling\n // backward routines.\n for (var wR = 0; wR < uniforms.filterDims[0]; wR++) {\n let xR = dyCorner.x + wR * uniforms.dilations[0];\n\n if (xR >= 0 && xR < uniforms.xShape[1]) {\n for (var wC = 0; wC < uniforms.filterDims[1]; wC++) {\n let xC = dyCorner.y + wC * uniforms.dilations[1];\n\n if (xC >= 0 && xC < uniforms.xShape[2]) {\n let val = getX(b, xR, xC, d) + getW(wR, wC, d);\n if (val > curVal) {\n curVal = val;\n xRMax = xR;\n xCMax = xC;\n }\n }\n }\n }\n }\n\n let flatIndexIn = d + uniforms.xShape[3] *\n (xCMax + uniforms.xShape[2] * (xRMax + uniforms.xShape[1] * b));\n let value = getDy(b, r, c, d);\n ${tz("&result[flatIndexIn]", "value", this.type)}\n }\n }\n ` } } class sj { constructor(e, t, n) { if (this.variableNames = ["x", "w", "dy"], this.uniforms = "filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2, dySize: i32,", this.workgroupSize = [64, 1, 1], this.atomic = !0, this.outputShape = e.filterShape, this.dispatchLayout = wz(e.outShape), this.dispatch = bz(this.dispatchLayout, e.outShape, this.workgroupSize), "float32" !== n && "int32" !== n) throw new Error(`Dilation2DBackpropFilter only supports float32 and int32\n types, does not support ${n} type.`); this.type = n, this.shaderKey = "dilation2DBackpropFilter" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.dySize) {\n let coords = getDyCoordsFromIndex(index);\n let b = coords[0];\n let r = coords[1];\n let c = coords[2];\n let d = coords[3];\n\n let dyCorner = vec2(r, c) * uniforms.strides - uniforms.pads;\n var curVal = -3.4e38; // neg_infinity\n var wRMax = 0;\n var wCMax = 0;\n\n // In the case of multiple argmax branches, we only back-propagate\n // along the last branch, i.e., the one with largest value of\n // 'wR * uniforms.filterDims[1] + wC', similarly to the max-pooling\n // backward routines.\n for (var wR = 0; wR < uniforms.filterDims[0]; wR++) {\n let xR = dyCorner.x + wR * uniforms.dilations[0];\n\n if (xR >= 0 && xR < uniforms.xShape[1]) {\n for (var wC = 0; wC < uniforms.filterDims[1]; wC++) {\n let xC = dyCorner.y + wC * uniforms.dilations[1];\n\n if (xC >= 0 && xC < uniforms.xShape[2]) {\n let val = getX(b, xR, xC, d) + getW(wR, wC, d);\n if (val > curVal) {\n curVal = val;\n wRMax = wR;\n wCMax = wC;\n }\n }\n }\n }\n }\n\n let flatIndexIn = d + uniforms.wShape[2] * (wCMax + wRMax * uniforms.wShape[1]);\n let value = getDy(b, r, c, d);\n ${tz("&result[flatIndexIn]", "value", this.type)}\n }\n }\n ` } } const uj = { + kernelName: P.Dilation2DBackpropFilter, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, dy: o } = t, { strides: s, pad: u, dilations: l } = r, c = P.backend_util.computeDilation2DInfo(i.shape, a.shape, s, u, "NHWC", l), h = a.dtype, d = new sj(c, a.shape, h), f = [{ type: "int32", data: [c.filterHeight, c.filterWidth] }, { type: "int32", data: [c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.dilationHeight, c.dilationWidth] }, { type: "int32", data: [P.util.sizeFromShape(c.outShape)] }], p = Kz({ backend: n, attrs: { shape: a.shape, value: 0, dtype: h } }); return n.runWebGPUProgram(d, [i, a, o], h, f, p) } + }; const lj = { + kernelName: P.Dilation2DBackpropInput, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, dy: o } = t, { strides: s, pad: u, dilations: l } = r, c = P.backend_util.computeDilation2DInfo(i.shape, a.shape, s, u, "NHWC", l), h = i.dtype, d = new oj(c, h), f = [{ type: "int32", data: [c.filterHeight, c.filterWidth] }, { type: "int32", data: [c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.dilationHeight, c.dilationWidth] }, { type: "int32", data: [P.util.sizeFromShape(c.outShape)] }], p = Kz({ backend: n, attrs: { shape: c.inShape, value: 0, dtype: h } }); return n.runWebGPUProgram(d, [i, a, o], h, f, p) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class cj { constructor(e, t, n) { this.variableNames = ["Image"], this.uniforms = "alpha: f32,", this.workgroupSize = [64, 1, 1], this.pixelsOpType = nz.DRAW, this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.type = t, this.textureFormat = n, this.shaderKey = `draw_${t}_${n}` } getUserCode() { let e; const t = "float32" === this.type ? "value" : "value / 255.0"; e = `\n if (uniforms.numChannels == 1) {\n rgba[0] = ${t};\n rgba[1] = ${t};\n rgba[2] = ${t};\n } else {\n rgba[d] = ${t};\n }`; return `\n @group(0) @binding(0) var outImage : texture_storage_2d<${this.textureFormat}, write>;\n ${uz("index")} {\n if (index < uniforms.size) {\n var rgba = vec4(0.0, 0.0, 0.0, uniforms.alpha);\n for (var d = 0; d < uniforms.numChannels; d = d + 1) {\n let value = f32(inBuf[index * uniforms.numChannels + d]);\n ${e}\n }\n rgba.x = rgba.x * rgba.w;\n rgba.y = rgba.y * rgba.w;\n rgba.z = rgba.z * rgba.w;\n let coords = getCoordsFromIndex(index);\n textureStore(outImage, vec2(coords.yx), rgba);\n }\n }\n ` } } const hj = { + kernelName: P.Draw, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use backend file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i } = t, { canvas: a, options: o } = r, [s, u] = i.shape.slice(0, 2), { imageOptions: l } = o || {}, c = (null == l ? void 0 : l.alpha) || 1, h = n.device.features.has("bgra8unorm-storage") ? "bgra8unorm" : "rgba8unorm", d = [s, u], f = new cj(d, i.dtype, h); a.width = u, a.height = s; const p = "webgpu"; let m, g = a.getContext(p); g || (m = new OffscreenCanvas(u, s), g = m.getContext(p)); const y = 3 === i.shape.length ? i.shape[2] : 1; g.configure({ device: n.device, format: h, usage: GPUTextureUsage.STORAGE_BINDING, alphaMode: "premultiplied" }); const b = "int32", v = n.makeTensorInfo(d, b), x = n.tensorMap.get(v.dataId); x.resource = g.getCurrentTexture(), x.external = !0; const w = [{ type: "uint32", data: [y] }, { type: "float32", data: [c] }]; if (n.runWebGPUProgram(f, [i], b, w, v), m) { const e = a.getContext("2d"); if (!e) throw new Error("Please make sure this canvas has only been used for 2d or webgpu context!"); e.drawImage(m, 0, 0) } return n.disposeData(v.dataId), i } + }, dj = cP({ opType: Nz.MUL, cpuKernelImpl: IP, supportsComplex: !0 }), fj = { kernelName: P.Multiply, backendName: "webgpu", kernelFunc: dj }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function pj(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; return lB(i, a, o, "sum", n) } const mj = { kernelName: P.Sum, backendName: "webgpu", kernelFunc: pj }; const gj = { + kernelName: P.Einsum, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { equation: i } = r, a = t, { allDims: o, summedDims: s, idDims: u } = P.backend_util.decodeEinsumEquation(i, a.length); P.backend_util.checkEinsumDimSizes(o.length, u, a); const { path: l, steps: c } = P.backend_util.getEinsumComputePath(s, u), h = c.length; let d = null, f = o.length; const p = []; for (let e = 0; e < h; ++e) { for (const t of c[e]) { const { permutationIndices: e, expandDims: r } = P.backend_util.getEinsumPermutation(f, u[t]); let i; P.backend_util.isIdentityPermutation(e) ? i = a[t] : (i = aB({ inputs: { x: a[t] }, backend: n, attrs: { perm: e } }), p.push(i)); const o = i.shape.slice(); for (let e = 0; e < r.length; ++e)o.splice(r[e], 0, 1); P.util.arraysEqual(i.shape, o) || (i = Jz({ inputs: { x: i }, backend: n, attrs: { shape: o } }), p.push(i)), null === d ? d = i : (d = dj({ inputs: { a: i, b: d }, backend: n }), p.push(d)) } e < h - 1 && (l[e] >= 0 && (d = pj({ inputs: { x: d }, backend: n, attrs: { axis: l[e] - (o.length - f), keepDims: !1 } }), p.push(d)), f--) } for (const e of p) e !== d && n.disposeData(e.dataId); return d } + }, yj = lP({ opType: Fz.ELU }), bj = { kernelName: P.Elu, backendName: "webgpu", kernelFunc: yj }, vj = { kernelName: P.EluGrad, backendName: "webgpu", kernelFunc: e => { const { inputs: t, backend: n } = e, { dy: r, y: i } = t, a = new rP(Nz.ELU_DER, r.shape, i.shape); return n.runWebGPUProgram(a, [r, i], r.dtype) } }, xj = cP({ opType: Nz.EQUAL, dtype: "bool", cpuKernelImpl: mP }), wj = { kernelName: P.Equal, backendName: "webgpu", kernelFunc: xj }, kj = lP({ opType: Fz.ERF }), Sj = { kernelName: P.Erf, backendName: "webgpu", kernelFunc: kj }, _j = lP({ opType: Fz.EXP, cpuKernelImpl: gP, dtype: "float32" }), Cj = { kernelName: P.Exp, backendName: "webgpu", kernelFunc: _j }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Aj(e) { const { inputs: t, attrs: n, backend: r } = e, { dim: i } = n, { input: a } = t, o = a.shape.length, s = a.shape.slice(); let u = i; return i < 0 && (P.util.assert(-(o + 1) <= i, (() => `Axis must be in the interval [${-(o + 1)}, ${o}]`)), u = o + i + 1), s.splice(u, 0, 1), Jz({ inputs: { x: a }, backend: r, attrs: { shape: s } }) } const Tj = { kernelName: P.ExpandDims, backendName: "webgpu", kernelFunc: Aj }, Ej = lP({ opType: Fz.EXPM1, cpuKernelImpl: yP }), Nj = { kernelName: P.Expm1, backendName: "webgpu", kernelFunc: Ej }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Ij { constructor(e, t) { this.variableNames = ["real", "imag"], this.outputShape = [], this.uniforms = "exponentMultiplier : f32, denominator: f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = t, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.component = e, this.shaderKey = `fft_${e}` } getUserCode() { return `\n fn unaryOpComplex(real: f32, expR: f32, imag: f32, expI: f32) -> f32 {\n ${"real" === this.component ? "return real * expR - imag * expI;" : "return real * expI + imag * expR;"}\n }\n\n fn mulMatDFT(batch: i32, index: i32) -> f32 {\n let indexRatio = f32(index) / f32(uniforms.realShape[1]);\n let exponentMultiplierTimesIndexRatio =\n uniforms.exponentMultiplier * indexRatio;\n\n var result = 0.0;\n\n for (var i = 0; i < uniforms.realShape[1]; i = i + 1) {\n // x = (-2|2 * PI / N) * index * i;\n let x = exponentMultiplierTimesIndexRatio * f32(i);\n let expR = cos(x);\n let expI = sin(x);\n let real = getReal(batch, i);\n let imag = getImag(batch, i);\n\n result = result +\n unaryOpComplex(real, expR, imag, expI) / uniforms.denominator;\n }\n\n return result;\n }\n\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n setOutputAtIndex(index, mulMatDFT(coords[0], coords[1]));\n }\n }\n ` } } + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Mj(e, t, n) { const r = n.tensorMap.get(e.dataId), i = P.util.sizeFromShape(e.shape), a = e.shape[e.shape.length - 1], o = [], s = Jz({ inputs: { x: e }, backend: n, attrs: { shape: [i / a, a] } }); o.push(s); const u = s.shape, l = new Ij("real", u), c = new Ij("imag", u), h = [{ dataId: r.complexTensorInfos.real.dataId, dtype: r.complexTensorInfos.real.dtype, shape: u }, { dataId: r.complexTensorInfos.imag.dataId, dtype: r.complexTensorInfos.imag.dtype, shape: u }], d = [{ type: "float32", data: [t ? 2 * Math.PI : -2 * Math.PI] }, { type: "float32", data: [t ? u[1] : 1] }], f = n.runWebGPUProgram(l, h, "float32", d); o.push(f); const p = n.runWebGPUProgram(c, h, "float32", d); o.push(p); const m = oP({ inputs: { real: f, imag: p }, backend: n }); o.push(m); const g = Jz({ inputs: { x: m }, backend: n, attrs: { shape: e.shape } }); return o.forEach((e => n.disposeData(e.dataId))), g } const Fj = { + kernelName: P.FFT, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { input: r } = t; return Mj(r, !1, n) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Dj { constructor(e) { this.outputShape = [], this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "flipLeftRight" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let coordX = uniforms.xShape[2] - coords[2] - 1;\n let outputValue = getX(coords[0], coords[1], coordX, coords[3]);\n setOutputAtIndex(index, outputValue);\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const $j = { kernelName: P.FlipLeftRight, backendName: "webgpu", kernelFunc: ({ inputs: e, backend: t }) => { const { image: n } = e, r = t, i = new Dj(n.shape); return r.runWebGPUProgram(i, [n], n.dtype) } }, Rj = lP({ opType: Fz.FLOOR, cpuKernelImpl: bP }), Oj = { kernelName: P.Floor, backendName: "webgpu", kernelFunc: Rj }, zj = cP({ opType: Nz.FLOOR_DIV, cpuKernelImpl: vP, dtype: "int32" }), Pj = { kernelName: P.FloorDiv, backendName: "webgpu", kernelFunc: zj }; + /** + * @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Bj { constructor(e, t, n = !1) { this.pixelsOpType = nz.FROM_PIXELS, this.outputShape = [0], this.variableNames = [], this.workgroupSize = [256, 1, 1], this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [t, 1, 1]), this.importVideo = n, this.shaderKey = `fromPixels_${this.importVideo}` } getUserCode() { const e = this.importVideo ? "textureLoad(src, vec2(coords.yx));" : "textureLoad(src, vec2(coords.yx), 0)"; return `\n @binding(1) @group(0) var src: ${this.importVideo ? "texture_external" : "texture_2d"};\n ${uz("index")} {\n let flatIndex = index * uniforms.numChannels;\n if (flatIndex < uniforms.size) {\n let coords = getCoordsFromIndex(flatIndex);\n let values = ${e};\n for (var i = 0; i < uniforms.numChannels; i = i + 1) {\n result[flatIndex + i] = i32(floor(255.0 * values[i]));\n }\n }\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use backend file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Lj = { kernelName: P.FromPixels, backendName: "webgpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e; let { pixels: i } = t; const { numChannels: a } = r; if (null == i) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); const o = "undefined" != typeof HTMLVideoElement && i instanceof HTMLVideoElement, s = "undefined" != typeof HTMLImageElement && i instanceof HTMLImageElement, u = "undefined" != typeof HTMLCanvasElement && i instanceof HTMLCanvasElement || "undefined" != typeof OffscreenCanvas && i instanceof OffscreenCanvas, l = "undefined" != typeof ImageBitmap && i instanceof ImageBitmap, [c, h] = o ? [i.videoWidth, i.videoHeight] : [i.width, i.height], d = [h, c, a], f = (0, P.env)().getBool("WEBGPU_IMPORT_EXTERNAL_TEXTURE") && o, p = o || s; if (l || u || p) { let e; if (f) e = n.device.importExternalTexture({ source: i }); else { if (p) { const e = (0, P.env)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"); null != jj && e === Uj || (Uj = e, jj = document.createElement("canvas").getContext("2d", { willReadFrequently: Uj })), jj.canvas.width = c, jj.canvas.height = h, jj.drawImage(i, 0, 0, c, h), i = jj.canvas } const t = GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING, r = "rgba8unorm", a = n.textureManager.acquireTexture(d[1], d[0], r, t); n.queue.copyExternalImageToTexture({ source: i }, { texture: a }, [d[1], d[0]]), e = a } const t = P.util.sizeFromShape(d), r = P.util.computeStrides(d), o = new Bj(d, a, f), s = [{ type: "uint32", data: [t] }, { type: "uint32", data: [a] }, { type: "uint32", data: [...r] }], u = n.makeTensorInfo([h, c], "int32"); n.tensorMap.get(u.dataId).resource = e; const l = n.runWebGPUProgram(o, [u], "int32", s); return n.disposeData(u.dataId), l } const m = i.data; let g = m; if (null != a && 4 !== a) { g = new Uint8Array(i.width * i.height * a); const e = m.length; let t = 0; for (let n = 0; n < e; n++)n % 4 < a && (g[t++] = m[n]) } const y = n.makeTensorInfo(d, "int32", new Int32Array(g)); return n.uploadToGPU(y.dataId), y } }; let jj, Uj = (0, P.env)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"); + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Wj { constructor(e, t, n, r, i) { this.uniforms = "varianceEpsilon : f32,", this.workgroupSize = [128, 1, 1], this.size = !0, this.variableNames = ["x", "mean", "variance"], P.backend_util.assertAndGetBroadcastShape(e, t), P.backend_util.assertAndGetBroadcastShape(e, n), this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), null != r && (P.backend_util.assertAndGetBroadcastShape(e, r), this.variableNames.push("offset")), null != i && (P.backend_util.assertAndGetBroadcastShape(e, i), this.variableNames.push("scale")), this.offsetShape = r, this.scaleShape = i, this.shaderKey = "batchNorm" } getUserCode() { let e = "0.0"; null != this.offsetShape && (e = "getOffsetByOutputIndex(index)"); let t = "1.0"; null != this.scaleShape && (t = "getScaleByOutputIndex(index)"); return `\n ${uz("index")} {\n if (index < uniforms.size)\n {\n let xValue = getXByOutputIndex(index);\n let meanValue = getMeanByOutputIndex(index);\n let varianValue = getVarianceByOutputIndex(index);\n let offsetValue = ${e};\n let scaleValue = ${t};\n let inv = scaleValue * inverseSqrt(varianValue + f32(uniforms.varianceEpsilon));\n setOutputAtIndex(index,dot(vec3(xValue, -meanValue, offsetValue), vec3(inv, inv, 1.0)));\n }\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const Vj = { kernelName: P.FusedBatchNorm, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { x: r, scale: i, offset: a, mean: o, variance: s } = e, { varianceEpsilon: u } = t, l = n, c = [r, o, s]; let h = null; null != a && (h = a.shape, c.push(a)); let d = null; null != i && (d = i.shape, c.push(i)); const f = new Wj(r.shape, o.shape, s.shape, h, d), p = [{ type: "float32", data: [u] }]; return l.runWebGPUProgram(f, c, r.dtype, p) } }; const Gj = { + kernelName: P.FusedConv2D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r, m = P.backend_util.convertConv2DDataFormat(c); return vL({ x: i, filter: a, convInfo: P.backend_util.computeConv2DInfo(i.shape, a.shape, u, h, l, d, !1, m), backend: n, bias: o, preluActivationWeights: s, leakyreluAlpha: p, activation: f }) } + }; const Hj = { + kernelName: P.FusedDepthwiseConv2D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dilations: c, dimRoundingMode: h, activation: d, leakyreluAlpha: f } = r; let p = c; null == p && (p = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(u, p), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${p}'`)); const m = P.backend_util.computeConv2DInfo(i.shape, a.shape, u, p, l, h, !0), g = [i, a], y = null != o, b = null != s; y && g.push(o), b && g.push(s); const v = [{ type: "int32", data: [m.padInfo.top, m.padInfo.left] }, { type: "int32", data: [m.inHeight, m.inWidth] }]; let x; return m.outHeight > 4 && m.outWidth > 4 && m.strideWidth <= 2 && m.inChannels === m.outChannels && 1 === m.dilationHeight && 1 === m.dilationWidth && m.inChannels % 4 == 0 ? (x = new XL(m, y, d, b), v.push({ type: "int32", data: [x.virtualWidth] })) : (x = new KL(m, y, d, b), v.push({ type: "int32", data: [m.filterHeight] }, { type: "int32", data: [m.filterWidth] }, { type: "int32", data: [m.strideHeight, m.strideWidth] }, { type: "int32", data: [m.dilationHeight, m.dilationWidth] })), "leakyrelu" === d && (v.push({ type: "float32", data: [f] }), x.uniforms += " alpha : f32,"), n.runWebGPUProgram(x, g, "float32", v) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class qj { constructor(e, t) { this.variableNames = ["A", "indices"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = t, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = `gathernd_${e}`, this.sliceDim = e, this.uniforms = `sliceDim : i32, strides : ${oz(e)},` } getUserCode() { let e; e = this.sliceDim > 1 ? "uniforms.strides[j]" : "uniforms.strides"; return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n var flattenIndex = 0;\n for (var j = 0; j < uniforms.sliceDim; j = j + 1) {\n let indexTemp = i32(round(getIndices(coords[0], j)));\n let strideNum = ${e};\n flattenIndex = flattenIndex + indexTemp * strideNum;\n }\n\n setOutputAtIndex(index, getA(flattenIndex, coords[1]));\n }\n }\n ` } } const Yj = { + kernelName: P.GatherNd, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { params: r, indices: i } = t, a = i.shape, o = a[a.length - 1], s = P.util.sizeFromShape(r.shape), [u, l, c, h] = P.backend_util.prepareAndValidate(r, i), d = Jz({ inputs: { x: i }, backend: n, attrs: { shape: [l, o] } }), f = Jz({ inputs: { x: r }, backend: n, attrs: { shape: [P.util.sizeFromShape(r.shape) / c, c] } }); if (n.shouldExecuteOnCPU([r, i]) || "string" === r.dtype) { const e = n.readSync(i.dataId), t = n.bufferSync(r), a = xP(e, t, r.dtype, l, o, c, h, r.shape, s); return n.makeTensorInfo(u, r.dtype, a.values) } const p = new qj(o, [l, c]), m = [{ type: "int32", data: [o] }, { type: "int32", data: h }], g = n.runWebGPUProgram(p, [f, d], f.dtype, m), y = Jz({ inputs: { x: g }, backend: n, attrs: { shape: u } }); return n.disposeData(d.dataId), n.disposeData(f.dataId), n.disposeData(g.dataId), y } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class Xj { constructor(e, t) { this.variableNames = ["A", "indices"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.slice(), this.aShape = e, this.outputShape = t, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "gather" } getUserCode() { const e = function (e) { const t = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], n = []; for (let r = 0; r < e.length; r++)2 === r ? n.push("indexZ") : n.push(`${t[r]}`); return n.join() }(this.aShape); return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let resRC = getCoordsFromIndex(index);\n let indexZ = i32(getIndices(resRC.x, resRC.z));\n let inBounds = select(0.0, 1.0, indexZ >= 0 && indexZ < uniforms.aShape[2]);\n setOutputAtIndex(index, inBounds * getA(${e}));\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function Kj(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, indices: a } = t, { axis: o, batchDims: s } = r, u = P.util.parseAxisParam(o, i.shape)[0], l = P.backend_util.segment_util.collectGatherOpShapeInfo(i, a, u, s), c = P.util.sizeFromShape(a.shape), h = [], d = Jz({ inputs: { x: i }, backend: n, attrs: { shape: [l.batchSize, l.outerSize, l.dimSize, l.sliceSize] } }), f = Jz({ inputs: { x: a }, backend: n, attrs: { shape: [l.batchSize, c / l.batchSize] } }); h.push(d), h.push(f); const p = [l.batchSize, l.outerSize, c / l.batchSize, l.sliceSize]; if (n.shouldExecuteOnCPU([i, a])) { const e = n.tensorMap.get(f.dataId).values, t = (0, P.buffer)(f.shape, f.dtype, e), r = n.tensorMap.get(d.dataId).values, i = (0, P.buffer)(d.shape, d.dtype, r), a = wP(i, t, p); return h.forEach((e => n.disposeData(e.dataId))), n.makeTensorInfo(l.outputShape, a.dtype, a.values) } const m = new Xj(d.shape, p), g = n.runWebGPUProgram(m, [d, f], d.dtype); h.push(g); const y = Jz({ inputs: { x: g }, backend: n, attrs: { shape: l.outputShape } }); return h.forEach((e => n.disposeData(e.dataId))), y } const Zj = { kernelName: P.GatherV2, backendName: "webgpu", kernelFunc: Kj }, Jj = cP({ opType: Nz.GREATER, cpuKernelImpl: SP, dtype: "bool" }), Qj = { kernelName: P.Greater, backendName: "webgpu", kernelFunc: Jj }, eU = cP({ opType: Nz.GREATER_EQUAL, dtype: "bool", cpuKernelImpl: kP }), tU = { kernelName: P.GreaterEqual, backendName: "webgpu", kernelFunc: eU }; const nU = { + kernelName: P.IFFT, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { input: r } = t; return Mj(r, !0, n) } + }, rU = lP({ opType: Fz.IS_FINITE, dtype: "bool" }), iU = { kernelName: P.IsFinite, backendName: "webgpu", kernelFunc: rU }, aU = lP({ opType: Fz.IS_INF, dtype: "bool" }), oU = { kernelName: P.IsInf, backendName: "webgpu", kernelFunc: aU }, sU = lP({ opType: Fz.IS_NAN, dtype: "bool" }), uU = { kernelName: P.IsNan, backendName: "webgpu", kernelFunc: sU }; const lU = { + kernelName: P.LeakyRelu, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { alpha: a } = r, o = [{ type: "float32", data: [a] }], s = new uP(i.shape, Fz.LEAKYRELU, "alpha : f32,"); return n.runWebGPUProgram(s, [i], "float32", o) } + }, cU = cP({ opType: Nz.LESS, dtype: "bool", cpuKernelImpl: CP }), hU = { kernelName: P.Less, backendName: "webgpu", kernelFunc: cU }, dU = cP({ opType: Nz.LESS_EQUAL, dtype: "bool", cpuKernelImpl: _P }), fU = { kernelName: P.LessEqual, backendName: "webgpu", kernelFunc: dU }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class pU { constructor(e) { this.variableNames = [], this.outputShape = [], this.uniforms = "start : f32, step : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "linSpace" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n setOutputAtIndex(index, uniforms.start + f32(index) * uniforms.step);\n }\n }\n ` } } const mU = { + kernelName: P.LinSpace, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, num: a } = n, o = (i - r) / (a - 1), s = new pU(a), u = [{ type: "float32", data: [r] }, { type: "float32", data: [o] }]; return t.runWebGPUProgram(s, [], "float32", u) } + }, gU = lP({ opType: Fz.LOG, cpuKernelImpl: AP }), yU = { kernelName: P.Log, backendName: "webgpu", kernelFunc: gU }, bU = lP({ opType: Fz.LOG1P }), vU = { kernelName: P.Log1p, backendName: "webgpu", kernelFunc: bU }, xU = cP({ opType: Nz.LOGICAL_AND, dtype: "bool" }), wU = { kernelName: P.LogicalAnd, backendName: "webgpu", kernelFunc: xU }, kU = lP({ opType: Fz.LOGICAL_NOT }), SU = { kernelName: P.LogicalNot, backendName: "webgpu", kernelFunc: kU }, _U = cP({ opType: Nz.LOGICAL_OR }), CU = { kernelName: P.LogicalOr, backendName: "webgpu", kernelFunc: _U }, AU = "\n var powValue = 0.0;\n let basis = uniforms.bias + uniforms.alpha * sum;\n if (uniforms.beta == 0.5) {\n powValue = inverseSqrt(basis);\n } else if (uniforms.beta == 1.0) {\n powValue = 1.0 / basis;\n } else {\n powValue = exp(log(basis) * (-uniforms.beta));\n }\n"; class TU { constructor(e) { this.outputShape = [], this.variableNames = ["x"], this.uniforms = "radius : i32, bias : f32, alpha : f32, beta : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "lrn" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let b = coords[0];\n let r = coords[1];\n let c = coords[2];\n let d = coords[3];\n\n let x = getX(b, r, c, d);\n var sum = 0.0;\n for (var i = -uniforms.radius; i <= uniforms.radius; i = i + 1) {\n let idx = d + i;\n if (idx >= 0 && idx < uniforms.xShape[3]) {\n let z = getX(b, r, c, idx);\n sum = sum + z * z;\n }\n }\n ${AU}\n\n setOutputAtIndex(index, x * powValue);\n }\n }\n ` } } class EU { constructor(e, t) { this.outputShape = [], this.variableNames = ["x"], this.uniforms = "radius : i32, bias : f32, alpha : f32, beta : f32,", this.workgroupSize = [256, 1, 1], this.maxAllowRadius = 16, P.util.assert(t <= this.maxAllowRadius, (() => `Radius must be less than or equal to ${this.maxAllowRadius}, current radius is ${t}`)), this.outputShape = e, this.elementsPerWorkgroup = this.workgroupSize[0] - 2 * this.maxAllowRadius, this.dispatchLayout = { x: [3], y: [2], z: [0, 1] }, this.dispatch = bz(this.dispatchLayout, this.outputShape, [this.elementsPerWorkgroup, this.workgroupSize[1], this.workgroupSize[2]]), this.shaderKey = "lrn_shared" } getUserCode() { return `\n var lrnSub: array;\n const elementsPerWorkgroup = ${this.elementsPerWorkgroup};\n const maxAllowRadius = ${this.maxAllowRadius};\n\n ${uz()} {\n let localDepth = i32(localId.x);\n let workgroupDepth = i32(workgroupId.x) * elementsPerWorkgroup;\n let xDepth = workgroupDepth + localDepth - maxAllowRadius;\n let b = i32(globalId.z) / uniforms.xShape[1];\n let r = i32(globalId.z) - b * uniforms.xShape[1];\n let c = i32(globalId.y);\n let d = workgroupDepth + localDepth;\n\n var x = 0.0;\n if (xDepth >= 0 && xDepth < uniforms.xShape[3]) {\n x = getX(b, r, c, xDepth);\n }\n lrnSub[localDepth] = x;\n workgroupBarrier();\n\n if (localDepth < elementsPerWorkgroup && d < uniforms.outShape[3]) {\n var sum = 0.0;\n let index = localDepth + maxAllowRadius;\n for (var i = -uniforms.radius; i <= uniforms.radius; i = i + 1) {\n let z = lrnSub[index + i];\n sum = sum + z * z;\n }\n ${AU}\n\n setOutputAtCoords(b, r, c, d, lrnSub[index] * powValue);\n }\n } ` } } const NU = { + kernelName: P.LRN, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { depthRadius: a, bias: o, alpha: s, beta: u } = r; let l; l = a > 16 ? new TU(i.shape) : new EU(i.shape, a); const c = [{ type: "int32", data: [a] }, { type: "float32", data: [o] }, { type: "float32", data: [s] }, { type: "float32", data: [u] }]; return n.runWebGPUProgram(l, [i], i.dtype, c) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class IU { constructor(e) { this.outputShape = [], this.variableNames = ["inputImage", "outputImage", "dy"], this.uniforms = "depthRadius : i32, bias : f32, alpha : f32, beta : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "lrn_grad" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let b = coords[0];\n let r = coords[1];\n let c = coords[2];\n\n let MIN_DEPTH_BEGIN = 0;\n let MAX_DEPTH_END = uniforms.outShape[3];\n var result = 0.0;\n for (var d = MIN_DEPTH_BEGIN; d < MAX_DEPTH_END; d++) {\n let depthBegin = max(MIN_DEPTH_BEGIN, d - uniforms.depthRadius);\n let depthEnd = min(MAX_DEPTH_END, d + uniforms.depthRadius + 1);\n\n var norm = 0.0;\n for (var k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; k++) {\n if (k < depthBegin) {\n continue;\n } else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n } else {\n break;\n }\n }\n\n norm = uniforms.alpha * norm + uniforms.bias;\n\n for (var k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; k++) {\n if (k < depthBegin) {\n continue;\n } else if (k >= depthBegin && k < depthEnd) {\n var dyi = -2.0 * uniforms.alpha * uniforms.beta\n * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d) / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * uniforms.beta);\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n } else {\n break;\n }\n }\n }\n\n setOutputAtIndex(index, result);\n }\n }\n ` } } const MU = { + kernelName: P.LRNGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, y: a, dy: o } = t, { depthRadius: s, bias: u, alpha: l, beta: c } = r, h = new IU(i.shape), d = [{ type: "int32", data: [s] }, { type: "float32", data: [u] }, { type: "float32", data: [l] }, { type: "float32", data: [c] }]; return n.runWebGPUProgram(h, [i, a, o], i.dtype, d) } + }, FU = cP({ opType: Nz.MAX, cpuKernelImpl: EP }), DU = { kernelName: P.Maximum, backendName: "webgpu", kernelFunc: FU }; const $U = { + kernelName: P.MaxPool, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; return FB(i, P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u), "max", n) } + }; const RU = { + kernelName: P.MaxPool3D, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dataFormat: u, dimRoundingMode: l } = r, c = P.backend_util.computePool3DInfo(i.shape, a, o, [1, 1, 1], s, l, u), h = new TB(c, "max"), d = [{ type: "int32", data: [c.strideDepth, c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.padInfo.front, c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.inDepth, c.inHeight, c.inWidth] }, { type: "int32", data: [c.effectiveFilterDepth, c.effectiveFilterHeight, c.effectiveFilterWidth] }]; return n.runWebGPUProgram(h, [i], i.dtype, d) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class OU { constructor(e) { this.variableNames = ["dy", "maxPos"], this.uniforms = "strides : vec2, pads : vec2, dilations : vec2, filterDims : vec2,\n outHeight : i32, outWidth : i32", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "maxPool2DBackprop" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords[0];\n let d = coords[3];\n\n let dyRCCorner = vec2(coords.yz) - uniforms.pads;\n let dyRCorner = dyRCCorner.x;\n let dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = 0.0;\n let lastIndex = uniforms.filterDims[0] * uniforms.filterDims[1] - 1;\n for (var wR = 0; wR < uniforms.filterDims[0]; wR += uniforms.dilations[0]) {\n let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[0]);\n\n if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) {\n continue;\n }\n let idyR = i32(dyR);\n\n for (var wC = 0; wC < uniforms.filterDims[1]; wC += uniforms.dilations[1]) {\n let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[1]);\n\n if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) {\n continue;\n }\n let idyC = i32(dyC);\n\n let dyValue = getDy(batch, idyR, idyC, d);\n let maxPosValue = lastIndex - i32(getMaxPos(batch, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n let curPosValue = wR * uniforms.filterDims[1] + wC;\n let mask = select(0.0, 1.0, maxPosValue == curPosValue);\n dotProd += dyValue * mask;\n }\n }\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } class zU { constructor(e) { this.variableNames = ["dy", "maxPos"], this.uniforms = "strides : vec3, pads : vec3, filterDims : vec3,\n outDepth : i32, outHeight : i32, outWidth : i32", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e.inShape, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "maxPool3DBackprop" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let batch = coords.x;\n let ch = coords.u;\n\n let dyCorner = vec3(coords.y, coords.z, coords.w) - uniforms.pads;\n let dyDCorner = dyCorner.x;\n let dyRCorner = dyCorner.y;\n let dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = 0.0;\n let lastIndex = uniforms.filterDims[0] * uniforms.filterDims[1] * uniforms.filterDims[2] - 1;\n\n for (var wD = 0; wD < uniforms.filterDims[0]; wD++) {\n let dyD = f32(dyDCorner + wD) / f32(uniforms.strides[0]);\n\n if (dyD < 0.0 || dyD >= f32(uniforms.outDepth) || fract(dyD) > 0.0) {\n continue;\n }\n let idyD = i32(dyD);\n\n for (var wR = 0; wR < uniforms.filterDims[1]; wR++) {\n let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[1]);\n\n if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) {\n continue;\n }\n let idyR = i32(dyR);\n\n for (var wC = 0; wC < uniforms.filterDims[2]; wC++) {\n let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[2]);\n\n if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) {\n continue;\n }\n let idyC = i32(dyC);\n\n let dyValue = getDy(batch, idyD, idyR, idyC, ch);\n let maxPosValue = lastIndex - i32(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n let curPosValue = wD * uniforms.filterDims[1] * uniforms.filterDims[2] + wR * uniforms.filterDims[2] + wC;\n let mask = select(0.0, 1.0, maxPosValue == curPosValue);\n dotProd += dyValue * mask;\n }\n }\n }\n\n setOutputAtIndex(index, dotProd);\n }\n }\n ` } } const PU = { + kernelName: P.MaxPool3DGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a, { filterSize: s, strides: u, pad: l, dimRoundingMode: c } = r, h = P.backend_util.computePool3DInfo(o.shape, s, u, [1, 1, 1], l, c), d = new TB(h, "max", !0); let f = [{ type: "int32", data: [h.strideDepth, h.strideHeight, h.strideWidth] }, { type: "int32", data: [h.padInfo.front, h.padInfo.top, h.padInfo.left] }, { type: "int32", data: [h.inDepth, h.inHeight, h.inWidth] }, { type: "int32", data: [h.effectiveFilterDepth, h.effectiveFilterHeight, h.effectiveFilterWidth] }]; const p = n.runWebGPUProgram(d, [o], "int32", f), m = new zU(h); f = [{ type: "int32", data: [h.strideDepth, h.strideHeight, h.strideWidth] }, { type: "int32", data: [h.effectiveFilterDepth - 1 - h.padInfo.front, h.effectiveFilterHeight - 1 - h.padInfo.top, h.effectiveFilterWidth - 1 - h.padInfo.left] }, { type: "int32", data: [h.effectiveFilterDepth, h.effectiveFilterHeight, h.effectiveFilterWidth] }, { type: "int32", data: [h.outDepth] }, { type: "int32", data: [h.outHeight] }, { type: "int32", data: [h.outWidth] }]; const g = n.runWebGPUProgram(m, [i, p], o.dtype, f); return n.disposeData(p.dataId), g } + }; const BU = { + kernelName: P.MaxPoolGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a, output: o } = t, s = a; _z([a, o], "maxPoolGrad"); const { filterSize: u, strides: l, pad: c, dimRoundingMode: h } = r, d = P.backend_util.computePool2DInfo(s.shape, u, l, 1, c, h), f = new AB(d, "max", !0); let p = [{ type: "int32", data: [d.strideHeight, d.strideWidth] }, { type: "int32", data: [d.padInfo.top, d.padInfo.left] }, { type: "int32", data: [d.dilationHeight, d.dilationWidth] }, { type: "int32", data: [d.inHeight, d.inWidth] }, { type: "int32", data: [d.effectiveFilterHeight, d.effectiveFilterWidth] }]; const m = n.runWebGPUProgram(f, [s], "int32", p), g = new OU(d); p = [{ type: "int32", data: [d.strideHeight, d.strideWidth] }, { type: "int32", data: [d.effectiveFilterHeight - 1 - d.padInfo.top, d.effectiveFilterWidth - 1 - d.padInfo.left] }, { type: "int32", data: [d.dilationHeight, d.dilationWidth] }, { type: "int32", data: [d.effectiveFilterHeight, d.effectiveFilterWidth] }, { type: "int32", data: [d.outHeight] }, { type: "int32", data: [d.outWidth] }]; const y = n.runWebGPUProgram(g, [i, m], s.dtype, p); return n.disposeData(m.dataId), y } + }; const LU = { + kernelName: P.MaxPoolWithArgmax, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { filterSize: i, strides: a, pad: o, includeBatchInIndex: s } = r, { x: u } = t; P.util.assert(4 === u.shape.length, (() => `Error in maxPool: input must be rank 4 but got rank ${u.shape.length}.`)); const l = [1, 1]; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(a, l), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${l}'`)); const c = P.backend_util.computePool2DInfo(u.shape, i, a, l, o), h = [{ type: "int32", data: [c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.dilationHeight, c.dilationWidth] }, { type: "int32", data: [c.inHeight, c.inWidth] }, { type: "int32", data: [c.effectiveFilterHeight, c.effectiveFilterWidth] }]; let d = new AB(c, "max", !1); const f = n.runWebGPUProgram(d, [u], u.dtype, h); return d = new AB(c, "max", !0, !0, s), [f, n.runWebGPUProgram(d, [u], "int32", h)] } + }; const jU = { + kernelName: P.Min, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; return lB(i, a, o, "min", n) } + }, UU = cP({ opType: Nz.MIN, cpuKernelImpl: NP }), WU = { kernelName: P.Minimum, backendName: "webgpu", kernelFunc: UU }; + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class VU { constructor(e, t, n) { this.uniforms = "", this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])), this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.xShape = e, t.map(((e, t) => { this.uniforms += ` pad${t} : vec2,` })), this.offset = "reflect" === n ? 0 : 1, this.shaderKey = `mirrorPad_${n}` } getUserCode() { const e = this.xShape.length, t = this.xShape.map(((e, t) => `uniforms.pad${t}[0]`)).join(","), n = this.xShape.map(((t, n) => `uniforms.pad${n}[0] + uniforms.xShape${e > 1 ? `[${n}]` : ""}`)).join(","), r = 1 === e ? "start" : "start[i]", i = 1 === e ? "end" : "end[i]", a = 1 === e ? "outC" : "outC[i]", o = oz(e), s = e > 1 ? ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, e) : "coords"; return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let start = ${o}(${t});\n let end = ${o}(${n});\n var outC = getCoordsFromIndex(index);\n for (var i = 0; i < ${e}; i = i + 1) {\n if (${a} < ${r}) {\n ${a} = ${r} * 2 - ${a} - ${this.offset};\n } else if(${a} >= ${i}) {\n ${a} = (${i} - 1) * 2 - ${a} + ${this.offset};\n }\n }\n let coords = outC - start;\n setOutputAtIndex(index, getX(${s}));\n }\n }\n ` } } + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const GU = { kernelName: P.MirrorPad, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { x: r } = e, { paddings: i, mode: a } = t, o = n, s = i.map((e => ({ type: "int32", data: [e[0], e[1]] }))), u = new VU(r.shape, i, a); return o.runWebGPUProgram(u, [r], r.dtype, s) } }, HU = cP({ opType: Nz.MOD }), qU = { kernelName: P.Mod, backendName: "webgpu", kernelFunc: HU }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class YU { constructor(e, t) { this.variableNames = ["probs"], this.outputShape = [], this.uniforms = "seed : f32, numOutcomes: i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e, t], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "multinomial" } getUserCode() { return `\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n fn random (seed : f32, resultUV : vec2) -> f32 {\n let HASHSCALE1 = 443.8975;\n let p = resultUV * seed;\n var p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 = p3 + dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let batch = coords[0];\n\n let resUV = vec2(f32(coords[1]) / f32(uniforms.outShape[1]),\n f32(coords[0]) / f32(uniforms.outShape[0]));\n let r = random(uniforms.seed, resUV);\n var cdf = 0.0;\n for (var i = 0; i < uniforms.numOutcomes - 1; i = i + 1) {\n cdf = cdf + getProbs(batch, i);\n\n if (r < cdf) {\n setOutputAtIndexI32(index, i);\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutputAtIndexI32(index, uniforms.numOutcomes - 1);\n }\n }\n ` } } + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class XU { constructor(e) { this.variableNames = ["logits"], this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = [this.outputShape[0], 1, 1], this.outputShape[1] >= 4096 ? this.workgroupSize = [256, 1, 1] : this.workgroupSize = [64, 1, 1], this.shaderKey = "softmax" } getUserCode() { return `\n var buf : array;\n var rowMaxShared : f32;\n var rowSumShared : f32;\n const blockSize = ${this.workgroupSize[0]};\n ${uz("index")} {\n let row = index / blockSize;\n let tid = i32(localId.x);\n let cols = uniforms.outShape[1];\n\n var threadMax = -3.402823e+38f;\n for (var col = tid; col < cols; col += blockSize) {\n let value = getLogits(row, col);\n threadMax = max(threadMax, value);\n }\n if (tid < cols) {\n buf[tid] = threadMax;\n }\n workgroupBarrier();\n\n var reduceSize = min(cols, blockSize);\n for (var currSize = reduceSize >> 1; currSize > 0; currSize = reduceSize >> 1) {\n reduceSize = currSize + (reduceSize & 1);\n if (tid < currSize) {\n buf[tid] = max(buf[tid], buf[tid + reduceSize]);\n }\n workgroupBarrier();\n }\n\n if (tid == 0) {\n rowMaxShared = buf[0];\n }\n workgroupBarrier();\n\n var threadSum = 0.0;\n for (var col = tid; col < cols; col += blockSize) {\n let subExp = exp(getLogits(row, col) - rowMaxShared);\n threadSum += subExp;\n }\n buf[tid] = threadSum;\n workgroupBarrier();\n\n for (var currSize = blockSize >> 1; currSize > 0; currSize = currSize >> 1) {\n if (tid < currSize) {\n buf[tid] = buf[tid] + buf[tid + currSize];\n }\n workgroupBarrier();\n }\n\n if (tid == 0) {\n rowSumShared = buf[0];\n }\n workgroupBarrier();\n\n for (var col = tid; col < cols; col += blockSize) {\n let value = exp(getLogits(row, col) - rowMaxShared) / rowSumShared;\n setOutputAtCoords(row, col, value);\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function KU(e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { dim: a } = r, o = Jz({ inputs: { x: i }, backend: n, attrs: { shape: [P.util.sizeFromShape(i.shape) / i.shape[a], i.shape[a]] } }), s = new XU(o.shape), u = n.runWebGPUProgram(s, [o], i.dtype), l = Jz({ inputs: { x: u }, backend: n, attrs: { shape: i.shape } }); return n.disposeData(o.dataId), n.disposeData(u.dataId), l } const ZU = { kernelName: P.Softmax, backendName: "webgpu", kernelFunc: KU }; const JU = { + kernelName: P.Multinomial, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { numSamples: a, seed: o, normalized: s } = r, u = s ? i : KU({ inputs: { logits: i }, backend: n, attrs: { dim: i.shape.length - 1 } }), l = u.shape[0], c = u.shape[1], h = new YU(l, a), d = [{ type: "float32", data: [o] }, { type: "int32", data: [c] }], f = n.runWebGPUProgram(h, [u], "int32", d); return s || n.disposeData(u.dataId), f } + }; const QU = { + kernelName: P.Neg, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { x: r } = t; if (n.shouldExecuteOnCPU([r])) { const e = n.tensorMap.get(r.dataId), [t, i] = MP(e.values, r.shape, r.dtype); return n.makeTensorInfo(i, r.dtype, t) } const i = new uP(r.shape, Fz.NEG); return n.runWebGPUProgram(i, [r], r.dtype) } + }; const eW = { + kernelName: P.NonMaxSuppressionV3, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { console.warn("tf.nonMaxSuppression() in webgpu locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = r, l = n.readSync(i.dataId), c = n.readSync(a.dataId), { selectedIndices: h } = P.kernel_impls.nonMaxSuppressionV3Impl(l, c, o, s, u); return n.makeTensorInfo([h.length], "int32", new Int32Array(h)) } + }; const tW = { + kernelName: P.NonMaxSuppressionV5, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { console.warn("tf.nonMaxSuppression() in webgpu locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = r, c = n.readSync(i.dataId), h = n.readSync(a.dataId), d = o, f = s, p = u, m = l, { selectedIndices: g, selectedScores: y } = P.kernel_impls.nonMaxSuppressionV5Impl(c, h, d, f, p, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([y.length], "float32", new Float32Array(y))] } + }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class nW { constructor(e, t) { this.variableNames = ["x"], this.uniforms = "onValue : f32, offValue : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e, t], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "onehot" } getUserCode() { return `\n ${uz("index")} {\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n setOutputAtIndex(index, mix(uniforms.offValue, uniforms.onValue,\n f32(i32(round(getX(coords.x))) == coords.y)));\n }\n }\n ` } } const rW = { + kernelName: P.OneHot, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i } = t, { dtype: a, depth: o, onValue: s, offValue: u } = r, l = P.util.sizeFromShape(i.shape), c = new nW(l, o), h = Jz({ inputs: { x: i }, backend: n, attrs: { shape: [l] } }), d = [{ type: "float32", data: [s] }, { type: "float32", data: [u] }], f = n.runWebGPUProgram(c, [h], a, d); n.disposeData(h.dataId); const p = Jz({ inputs: { x: f }, backend: n, attrs: { shape: [...i.shape, o] } }); return n.disposeData(f.dataId), p } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function iW(e) { const { inputs: t, backend: n } = e, { x: r } = t; if ("complex64" === r.dtype) { const e = JB({ inputs: { input: r }, backend: n }), t = iW({ inputs: { x: e }, backend: n }), i = cL({ inputs: { input: r }, backend: n }), a = iW({ inputs: { x: i }, backend: n }), o = oP({ inputs: { real: t, imag: a }, backend: n }); return n.disposeData(e.dataId), n.disposeData(t.dataId), n.disposeData(i.dataId), n.disposeData(a.dataId), o } return Kz({ attrs: { shape: r.shape, dtype: r.dtype, value: "string" === r.dtype ? "" : 0 }, backend: n }) } const aW = { kernelName: P.ZerosLike, backendName: "webgpu", kernelFunc: iW }; const oW = { + kernelName: P.OnesLike, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function e(t) { const { inputs: n, backend: r } = t, { x: i } = n; if ("string" === i.dtype) throw new Error("onesLike is not supported under string dtype"); if ("complex64" === i.dtype) { const t = JB({ inputs: { input: i }, backend: r }), n = e({ inputs: { x: t }, backend: r }), a = cL({ inputs: { input: i }, backend: r }), o = iW({ inputs: { x: a }, backend: r }), s = oP({ inputs: { real: n, imag: o }, backend: r }); return r.disposeData(t.dataId), r.disposeData(n.dataId), r.disposeData(a.dataId), r.disposeData(o.dataId), s } return Kz({ attrs: { shape: i.shape, dtype: i.dtype, value: 1 }, backend: r }) } + }; const sW = { + kernelName: P.Pack, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r; if (1 === t.length) return Aj({ inputs: { input: t[0] }, backend: n, attrs: { dim: i } }); const a = t[0].shape, o = t[0].dtype; t.forEach((e => { P.util.assertShapesMatch(a, e.shape, "All tensors passed to stack must have matching shapes"), P.util.assert(o === e.dtype, (() => "All tensors passed to stack must have matching dtypes")) })); const s = [], u = t.map((e => { const t = Aj({ inputs: { input: e }, backend: n, attrs: { dim: i } }); return s.push(t), t })), l = fL({ inputs: u, backend: n, attrs: { axis: i } }); return s.forEach((e => n.disposeData(e.dataId))), l } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function uW(e, t = !1) { const n = e.length, r = oz(n), i = e.map(((e, t) => `uniforms.pad${t}[0]`)).join(","), a = e.map(((e, t) => `uniforms.pad${t}[0] + uniforms.xShape${n > 1 ? `[${t}]` : ""}`)).join(","); return `\n let start = ${n > 1 ? `${r}(${i})` : `${i}`};\n let end = ${n > 1 ? `${r}(${a})` : `${a}`};\n if (${n > 1 ? "any(paddedCoords < start)" : "paddedCoords < start"} || ${n > 1 ? "any(paddedCoords >= end)" : "paddedCoords >= end"}) {\n setOutputAtIndex(index, ${t ? 0 : "uniforms.constantValue"});\n } else {\n let coords = paddedCoords - start;\n setOutputAtIndex(index, getX(${n > 1 ? ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, n) : "coords"}));\n }\n ` } class lW { constructor(e, t) { this.variableNames = ["x"], this.uniforms = "constantValue : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])), this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), t.map(((e, t) => { this.uniforms += ` pad${t} : vec2,` })), this.xShape = e, this.shaderKey = "pad" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let paddedCoords = getCoordsFromIndex(index);\n ${uW(this.xShape)}\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const cW = { kernelName: P.PadV2, backendName: "webgpu", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, constantValue: o } = r; if (a.every((e => P.util.arraysEqual(e, [0, 0])))) return iP({ inputs: { x: i }, backend: n }); if (0 === P.util.sizeFromShape(i.shape)) { return Kz({ backend: n, attrs: { shape: a.map(((e, t) => e[0] + i.shape[t] + e[1])), value: o, dtype: i.dtype } }) } const s = [{ type: "float32", data: [o] }]; a.map((e => s.push({ type: "int32", data: [e[0], e[1]] }))); const u = new lW(i.shape, a); return n.runWebGPUProgram(u, [i], i.dtype, s) } }, hW = cP({ opType: Nz.POW }), dW = { kernelName: P.Pow, backendName: "webgpu", kernelFunc: hW }; const fW = { + kernelName: P.Prelu, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { x: r, alpha: i } = t, a = new rP(Nz.PRELU, r.shape, i.shape); return n.runWebGPUProgram(a, [r, i], "float32") } + }; const pW = { + kernelName: P.Prod, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; return lB(i, a, o, "prod", n) } + }, mW = { kernelName: P.Range, backendName: "webgpu", kernelFunc: e => { const { backend: t, attrs: n } = e, { start: r, stop: i, step: a, dtype: o } = n, s = $P(r, i, a, o); return t.makeTensorInfo([s.length], o, s) } }, gW = cP({ opType: Nz.DIV }), yW = { kernelName: P.RealDiv, backendName: "webgpu", kernelFunc: gW }, bW = lP({ opType: Fz.RECIPROCAL }), vW = { kernelName: P.Reciprocal, backendName: "webgpu", kernelFunc: bW }, xW = lP({ opType: Fz.RELU }), wW = { kernelName: P.Relu, backendName: "webgpu", kernelFunc: xW }, kW = lP({ opType: Fz.RELU6 }), SW = { kernelName: P.Relu6, backendName: "webgpu", kernelFunc: kW }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class _W { constructor(e, t, n) { this.variableNames = ["x"], this.uniforms = "adjustHeightWidth : vec2, halfPixelCenters : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e[0], t, n, e[3]], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "resizeBilinear" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let b = coords[0];\n let d = coords[3];\n let rc = coords.yz;\n\n let effectiveInSize = vec2(\n f32(uniforms.xShape.y) - uniforms.adjustHeightWidth[0],\n f32(uniforms.xShape.z) - uniforms.adjustHeightWidth[1]);\n\n let effectiveOutSize = vec2(\n f32(uniforms.outShape.y) - uniforms.adjustHeightWidth[0],\n f32(uniforms.outShape.z) - uniforms.adjustHeightWidth[1]);\n\n let effectiveInputOverOutputRatioRC =\n effectiveInSize / effectiveOutSize;\n\n // Fractional source index\n let sourceFracIndexRC =\n (vec2(rc) + vec2(uniforms.halfPixelCenters)) *\n effectiveInputOverOutputRatioRC - vec2(uniforms.halfPixelCenters);\n\n // Compute the four integer indices.\n let sourceFloorRC = vec2(sourceFracIndexRC);\n let sourceCeilRC = vec2(\n min(vec2(uniforms.xShape.yz) - vec2(1.0), ceil(sourceFracIndexRC)));\n\n let topLeft = getX(b, sourceFloorRC.x, sourceFloorRC.y, d);\n let bottomLeft = getX(b, sourceCeilRC.x, sourceFloorRC.y, d);\n let topRight = getX(b, sourceFloorRC.x, sourceCeilRC.y, d);\n let bottomRight = getX(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n let fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n let top = topLeft + (topRight - topLeft) * fracRC.y;\n let bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n let newValue = top + (bottom - top) * fracRC.x;\n\n setOutputAtIndex(index, newValue);\n }\n }\n ` } } const CW = { + kernelName: P.ResizeBilinear, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, size: o, halfPixelCenters: s } = r, [u, l] = o, c = [{ type: "float32", data: [a && u > 1 ? 1 : 0, a && l > 1 ? 1 : 0] }, { type: "float32", data: [s ? .5 : 0] }], h = new _W(i.shape, u, l); return n.runWebGPUProgram(h, [i], "float32", c) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class AW { constructor(e, t) { this.variableNames = ["dy"], this.uniforms = "effectiveXSize : vec2, effectiveYSize : vec2, heightScale : f32, widthScale : f32,\n invHeightScale : f32, invWidthScale : f32, winHeight : i32, winWidth : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.alignCorners = t, this.shaderKey = `resizeBilinearBackprop_${t}` } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let b = coords[0];\n let d = coords[3];\n let r = coords[1];\n let c = coords[2];\n\n var accumulator = 0.0;\n\n // Compute bounds for where in dy we will look\n let startRLerp = floor(f32(r) * uniforms.invHeightScale);\n let startDyR = i32(startRLerp - f32(uniforms.winHeight / 2));\n\n let startCLerp = floor(f32(c) * uniforms.invWidthScale);\n let startDyC = i32(startCLerp - f32(uniforms.winWidth / 2));\n\n // Loop over dy\n for (var dyROffset = 0; dyROffset < uniforms.winHeight; dyROffset++) {\n let dyR = startDyR + dyROffset;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= uniforms.dyShape[1]) {\n continue;\n }\n\n for (var dyCOffset = 0; dyCOffset < uniforms.winWidth; dyCOffset++) {\n let dyC = startDyC + dyCOffset;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= uniforms.dyShape[2]) {\n continue;\n }\n\n let dxR = f32(dyR) * uniforms.heightScale;\n let topDxRIndex = i32(floor(dxR));\n let bottomDxRIndex = i32(min(ceil(dxR), f32(uniforms.outShape[1] - 1)));\n let dxRLerp = dxR - f32(topDxRIndex);\n let inverseDxRLerp = 1.0 - dxRLerp;\n\n let dxC = f32(dyC) * uniforms.widthScale;\n let leftDxCIndex = i32(floor(dxC));\n let rightDxCIndex = i32(min(ceil(dxC), f32(uniforms.outShape[2] - 1)));\n let dxCLerp = dxC - f32(leftDxCIndex);\n let inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutputAtIndex(index, accumulator);\n }\n }\n ` } } const TW = { + kernelName: P.ResizeBilinearGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r, [, s, u] = i.shape, [, l, c] = a.shape, h = [o && l > 1 ? s - 1 : s, o && c > 1 ? u - 1 : u], d = [o && l > 1 ? l - 1 : l, o && c > 1 ? c - 1 : c], f = h[0] / d[0], p = h[1] / d[1], m = 1 / f, g = 1 / p, y = 2 * Math.ceil(m) + 2, b = 2 * Math.ceil(g) + 2, v = new AW(i.shape, o), x = [{ type: "int32", data: h }, { type: "int32", data: d }, { type: "float32", data: [f] }, { type: "float32", data: [p] }, { type: "float32", data: [m] }, { type: "float32", data: [g] }, { type: "int32", data: [y] }, { type: "int32", data: [b] }]; return n.runWebGPUProgram(v, [a], a.dtype, x) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class EW { constructor(e, t, n, r) { this.variableNames = ["x"], this.uniforms = "adjustHeightWidth : vec2, roundBase : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = [e[0], t, n, e[3]], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.halfPixelCenters = r, this.shaderKey = `resizeNearest_${r}` } getUserCode() { let e; e = this.halfPixelCenters ? "max((vec2(rc) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))" : "vec2(rc) * effectiveInputOverOutputRatioRC"; return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let b = coords[0];\n let d = coords[3];\n let rc = coords.yz;\n\n let effectiveInSize = vec2(\n f32(uniforms.xShape.y) - uniforms.adjustHeightWidth[0],\n f32(uniforms.xShape.z) - uniforms.adjustHeightWidth[1]);\n\n let effectiveOutSize = vec2(\n f32(uniforms.outShape.y) - uniforms.adjustHeightWidth[0],\n f32(uniforms.outShape.z) - uniforms.adjustHeightWidth[1]);\n\n let effectiveInputOverOutputRatioRC =\n effectiveInSize / effectiveOutSize;\n\n // Fractional source index\n let sourceFracIndexRC = ${e};\n\n // Compute the coordinators of nearest neighbor point.\n let inputShapeRC = vec2(f32(uniforms.xShape.y), f32(uniforms.xShape.z));\n let sourceNearestRC = vec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + uniforms.roundBase)));\n let newValue = getX(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutputAtIndex(index, newValue);\n }\n }\n ` } } const NW = { + kernelName: P.ResizeNearestNeighbor, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r, [u, l] = s, c = [{ type: "float32", data: [a && u > 1 ? 1 : 0, a && l > 1 ? 1 : 0] }, { type: "float32", data: [a ? .5 : 0] }], h = new EW(i.shape, u, l, o); return n.runWebGPUProgram(h, [i], i.dtype, c) } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class IW { constructor(e, t) { this.variableNames = ["dy"], this.uniforms = "effectiveXSize : vec2, effectiveYSize : vec2, invHeightScale : f32, invWidthScale : f32,\n winHeight : i32, winWidth : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.alignCorners = t, this.shaderKey = `resizeNearestNeigborBackprop_${t}` } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getOutputCoords();\n let b = coords[0];\n let d = coords[3];\n let r = coords[1];\n let c = coords[2];\n\n var accumulator = 0.0;\n\n // Compute bounds for where in dy we will look\n let startRLerp = floor(f32(r) * uniforms.invHeightScale);\n let startDyR = i32(floor(startRLerp - f32(uniforms.winHeight / 2)));\n\n let startCLerp = floor(f32(c) * uniforms.invWidthScale);\n let startDyC = i32(floor(startCLerp - f32(uniforms.winWidth / 2)));\n\n // Loop over dy\n for (var dyROffset = 0; dyROffset < uniforms.winHeight; dyROffset++) {\n let dyR = startDyR + dyROffset;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= uniforms.dyShape[1]) {\n continue;\n }\n\n for (var dyCOffset = 0; dyCOffset < uniforms.winWidth; dyCOffset++) {\n let dyC = startDyC + dyCOffset;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= uniforms.dyShape[2]) {\n continue;\n }\n\n let sourceFracRow = f32(uniforms.effectiveXSize[0]) *\n (f32(dyR) / f32(uniforms.effectiveYSize[0]));\n\n let sourceFracCol = f32(uniforms.effectiveXSize[1]) *\n (f32(dyC) / f32(uniforms.effectiveYSize[1]));\n\n let sourceNearestRow =\n i32(min(f32(uniforms.outShape[1] - 1),\n ${this.alignCorners ? "floor(sourceFracRow + 0.5)" : "floor(sourceFracRow)"}));\n\n let sourceNearestCol =\n i32(min(f32(uniforms.outShape[2] - 1),\n ${this.alignCorners ? "floor(sourceFracCol + 0.5)" : "floor(sourceFracCol)"}));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutputAtIndex(index, accumulator);\n }\n }\n ` } } const MW = { + kernelName: P.ResizeNearestNeighborGrad, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r, [, s, u] = i.shape, [, l, c] = a.shape, h = [o && l > 1 ? s - 1 : s, o && c > 1 ? u - 1 : u], d = [o && l > 1 ? l - 1 : l, o && c > 1 ? c - 1 : c], f = 1 / (h[0] / d[0]), p = 1 / (h[1] / d[1]), m = 2 * Math.ceil(f) + 2, g = 2 * Math.ceil(p) + 2, y = new IW(i.shape, o), b = [{ type: "int32", data: h }, { type: "int32", data: d }, { type: "float32", data: [f] }, { type: "float32", data: [p] }, { type: "int32", data: [m] }, { type: "int32", data: [g] }]; return n.runWebGPUProgram(y, [a], a.dtype, b) } + }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class FW { constructor(e) { this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.uniforms = " axis : vec4,", this.shaderKey = "reverse" } getUserCode() { return `\n \n // Using uniform variables as judging conditions, so the function has\n // coherent execution within all threads.\n fn getReverseCoords(coords : vec4) -> vec4 {\n var reverseCoords = coords;\n if (uniforms.axis[0] == 1) {\n reverseCoords[0] = uniforms.xShape[0] - coords[0] - 1;\n }\n if (uniforms.axis[1] == 1) {\n reverseCoords[1] = uniforms.xShape[1] - coords[1] - 1;\n }\n if (uniforms.axis[2] == 1) {\n reverseCoords[2] = uniforms.xShape[2] - coords[2] - 1;\n }\n if (uniforms.axis[3] == 1) {\n reverseCoords[3] = uniforms.xShape[3] - coords[3] - 1;\n }\n\n return reverseCoords;\n }\n \n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let reverseCoords = getReverseCoords(coords);\n setOutputAtIndex(index, getX(reverseCoords[0],\n reverseCoords[1], reverseCoords[2], reverseCoords[3]));\n }\n }\n ` } } const DW = { + kernelName: P.Reverse, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dims: a } = r, o = i.shape.length; if (0 === o) return iP({ inputs: { x: i }, backend: n }); const s = i.shape, u = [1, 1, 1, 1]; s.forEach(((e, t) => { u[t + 4 - o] = e })); const l = P.util.parseAxisParam(a, i.shape), c = [0, 0, 0, 0]; l.forEach((e => { c[e + 4 - o] = 1 })); const h = [{ type: "int32", data: c }], d = Jz({ inputs: { x: i }, backend: n, attrs: { shape: u } }), f = new FW(u), p = n.runWebGPUProgram(f, [d], d.dtype, h); n.disposeData(d.dataId); const m = Jz({ inputs: { x: p }, backend: n, attrs: { shape: s } }); return n.disposeData(p.dataId), m } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class $W { constructor(e, t) { this.outputShape = [], this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.uniforms = "centerX : f32, centerY : f32, sinRadians : f32,\n cosRadians : f32,", this.shaderKey = "rotate", this.outputShape = e, "number" == typeof t ? (this.uniforms += " fillValue : f32,", this.fillSnippet = "var outputValue = uniforms.fillValue;", this.shaderKey += "_float") : (this.uniforms += " fillValue : vec3,", this.fillSnippet = "var outputValue = uniforms.fillValue[coords[3]];", this.shaderKey += "_vec3") } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let coordXFloat = (f32(coords[2]) - uniforms.centerX) *\n uniforms.cosRadians - (f32(coords[1]) - uniforms.centerY) *\n uniforms.sinRadians;\n let coordYFloat = (f32(coords[2]) - uniforms.centerX) *\n uniforms.sinRadians + (f32(coords[1]) - uniforms.centerY) *\n uniforms.cosRadians;\n let coordX = i32(round(coordXFloat + uniforms.centerX));\n let coordY = i32(round(coordYFloat + uniforms.centerY));\n ${this.fillSnippet}\n if(coordX >= 0 && coordX < uniforms.xShape[2] && coordY >= 0 &&\n coordY < uniforms.xShape[1]) {\n outputValue = getX(coords[0], coordY, coordX, coords[3]);\n }\n setOutputAtIndex(index, outputValue);\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const RW = { kernelName: P.RotateWithOffset, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, { radians: i, fillValue: a, center: o } = t, s = n, u = new $W(r.shape, a), [l, c] = P.backend_util.getImageCenter(o, r.shape[1], r.shape[2]), h = [{ type: "float32", data: [l] }, { type: "float32", data: [c] }, { type: "float32", data: [Math.sin(i)] }, { type: "float32", data: [Math.cos(i)] }]; "number" == typeof a ? h.push({ type: "float32", data: [Number.parseFloat(a.toFixed(2))] }) : h.push({ type: "float32", data: a }); return s.runWebGPUProgram(u, [r], r.dtype, h) } }, OW = lP({ opType: Fz.ROUND }), zW = { kernelName: P.Round, backendName: "webgpu", kernelFunc: OW }, PW = lP({ opType: Fz.RSQRT, cpuKernelImpl: RP }), BW = { kernelName: P.Rsqrt, backendName: "webgpu", kernelFunc: PW }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class LW { constructor(e, t, n, r, i, a, o, s = !0) { this.variableNames = ["updates", "indices"], this.workgroupSize = [64, 1, 1], this.atomic = !0, this.outputShape = a, this.type = o, this.sumDupeIndices = s, this.dispatchLayout = wz(e), this.dispatch = bz(this.dispatchLayout, e, this.workgroupSize), this.sliceDimGreaterThanOne = t > 1, this.shaderKey = `scatter_${n}_${r}_${this.sliceDimGreaterThanOne}_${o}_${s}_${i.length}`; const u = oz(i.length); this.uniforms = `sliceDim : i32, strides: ${u}, updatesSize: i32,`, this.updatesRank = r, this.indicesRank = n } getUserCode() { let e = ""; 1 === this.indicesRank ? e = "coords[0]" : 2 === this.indicesRank && (e = "coords[0], j"); const t = `getIndices(${e})`, n = this.sliceDimGreaterThanOne ? "uniforms.strides[j]" : "uniforms.strides"; let r = "", i = ""; 1 === this.dispatchLayout.x.length ? (r = "flattenedIndex", i = "\n fn getUpdatesCoordsFromFlatIndex(index : i32) -> i32 {\n return index;\n }\n ") : 2 === this.dispatchLayout.x.length && (r = "vec2(flattenedIndex, coords[1])", i = "\n fn getUpdatesCoordsFromFlatIndex(index : i32) -> vec2 {\n // N.B. |updates| could be a scalar tensor, conceptually representing a\n // 2D tensor with all values equal to that. By design, its size must be\n // the same as |outShape[1]| in one dimension, and |indicesShape[0]|\n // gives the other.\n let sliceSize = uniforms.outShape[1];\n let d0 = index / sliceSize;\n let d1 = index - d0 * sliceSize;\n return vec2(d0, d1);\n }\n "); const a = `getUpdates(${Array.from({ length: this.updatesRank }, ((e, t) => `coords[${t}]`)).join(", ")})`; return `\n ${i}\n ${uz("index")} {\n if (index < uniforms.updatesSize) {\n let coords = getUpdatesCoordsFromFlatIndex(index);\n var flattenedIndex = 0;\n for (var j = 0; j < uniforms.sliceDim; j = j + 1) {\n let indexInside = i32(round(${t}));\n flattenedIndex = flattenedIndex + indexInside * ${n};\n }\n let updateValue =\n ${mz(this.type)}(${a});\n let flatIndex = getOutputIndexFromCoords(${r});\n\n ${this.sumDupeIndices ? tz("&result[flatIndex]", "updateValue", this.type) : "atomicStore(&result[flatIndex], bitcast(updateValue));"}\n }\n }` } } const jW = { + kernelName: P.ScatterNd, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i, updates: a } = t, { shape: o } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(a, i, o), d = [h / l, l]; if (0 === h) return n.makeTensorInfo(o, i.dtype); const f = Jz({ inputs: { x: i }, backend: n, attrs: { shape: [u, s] } }), p = Jz({ inputs: { x: a }, backend: n, attrs: { shape: [u, l] } }), m = p.dtype, g = Kz({ backend: n, attrs: { shape: d, value: 0, dtype: m } }), y = [{ type: "int32", data: [s] }, { type: "int32", data: c }, { type: "int32", data: [P.util.sizeFromShape(p.shape)] }], b = new LW(p.shape, s, f.shape.length, p.shape.length, c, d, m), v = n.runWebGPUProgram(b, [p, f], m, y, g), x = Jz({ inputs: { x: v }, backend: n, attrs: { shape: o } }); return n.disposeData(f.dataId), n.disposeData(p.dataId), n.disposeData(v.dataId), x } + }; + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class UW { constructor(e, t) { this.outputShape = [], this.variableNames = ["sortedSequence", "values"], this.uniforms = "numInputs : i32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.side = t, this.shaderKey = `search_sorted_${t}` } getUserCode() { return `\n fn findBound(batch: i32, value: f32) -> i32 {\n var left = i32(0);\n var right = uniforms.numInputs;\n while (left < right) {\n var mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${"left" === this.side ? "<" : "<="} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let value = getValuesByOutputIndex(index);\n setOutputAtIndexI32(index, findBound(coords[0], value));\n }\n }\n ` } } const WW = { + kernelName: P.SearchSorted, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { sortedSequence: i, values: a } = t, { side: o } = r, s = new UW([a.shape[0], a.shape[1]], o), u = [{ type: "int32", data: [i.shape[1]] }]; return n.runWebGPUProgram(s, [i, a], "int32", u) } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class VW { constructor(e, t, n) { this.variableNames = ["c", "a", "b"], this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = t, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.cRank = e, this.rank = n, this.shaderKey = "select" } getUserCode() { let e, t; if (this.rank > 4) throw Error(`Where for rank ${this.rank} is not yet supported`); if (1 === this.rank) t = "resRC", e = "resRC"; else { const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], r = [], i = []; for (let e = 0; e < this.outputShape.length; e++)i.push(`${n[e]}`), e < this.cRank && r.push(`${n[e]}`); e = r.join(), t = i.join() } return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let resRC = getCoordsFromIndex(index);\n let cVal = getC(${e});\n if (cVal >= 1.0) {\n setOutputAtIndex(index, getA(${t}));\n } else {\n setOutputAtIndex(index, getB(${t}));\n }\n }\n }\n ` } } const GW = { + kernelName: P.Select, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { condition: r, t: i, e: a } = t, o = new VW(r.shape.length, i.shape, i.shape.length); return n.runWebGPUProgram(o, [r, i, a], (0, P.upcastType)(i.dtype, a.dtype)) } + }, HW = lP({ opType: Fz.SELU }), qW = { kernelName: P.Selu, backendName: "webgpu", kernelFunc: HW }, YW = lP({ opType: Fz.SIGMOID }), XW = { kernelName: P.Sigmoid, backendName: "webgpu", kernelFunc: YW }, KW = lP({ opType: Fz.SIGN }), ZW = { kernelName: P.Sign, backendName: "webgpu", kernelFunc: KW }, JW = lP({ opType: Fz.SIN }), QW = { kernelName: P.Sin, backendName: "webgpu", kernelFunc: JW }, eV = lP({ opType: Fz.SINH }), tV = { kernelName: P.Sinh, backendName: "webgpu", kernelFunc: eV }, nV = lP({ opType: Fz.SOFTPLUS }), rV = { kernelName: P.Softplus, backendName: "webgpu", kernelFunc: nV }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class iV { constructor(e, t, n, r, i, a) { this.variableNames = ["x"], this.outputShape = [], this.uniforms = "", this.workgroupSize = [64, 1, 1], this.size = !0; const o = new Array(r.length); for (let e = 0; e < o.length; e++)o[e] = r[i[e]]; this.outputShape = o, this.newDim = i, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.xShape = e, this.paddedXShape = t, this.uniforms += `reshapedPaddedXShape : ${oz(r.length)}, paddedXShapeStrides : ${oz(a)}, `, n.map(((e, t) => { this.uniforms += ` pad${t} : vec2,` })), this.shaderKey = `spaceToBatchND_${i}` } getUserCode() { const e = oz(this.outputShape.length), t = iB(this.newDim); return `\n ${dz(this.paddedXShape, "PaddedX")}\n ${uz("index")} {\n if(index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n let switchedIndex = getIndexFromCoords${this.outputShape.length}D(${e}(${t}), uniforms.reshapedPaddedXShape);\n let paddedCoords = getPaddedXCoordsFromIndex(switchedIndex);\n ${uW(this.xShape, !0)}\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + const aV = { kernelName: P.SpaceToBatchND, backendName: "webgpu", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, paddings: o } = r; P.util.assert(i.shape.length <= 4, (() => "spaceToBatchND for rank > 4 with a WebGPU backend not implemented yet")); const s = a.reduce(((e, t) => e * t)), u = [[0, 0]]; u.push(...o); for (let e = 1 + a.length; e < i.shape.length; ++e)u.push([0, 0]); const l = u.map(((e, t) => e[0] + i.shape[t] + e[1])), c = P.backend_util.getReshaped(l, a, s, !1), h = P.backend_util.getPermuted(c.length, a.length, !1), d = P.backend_util.getReshapedPermuted(l, a, s, !1), f = P.util.computeStrides(l), p = new iV(i.shape, l, u, c, h, f.length), m = [{ type: "int32", data: c }, { type: "int32", data: f }]; u.map((e => m.push({ type: "int32", data: [e[0], e[1]] }))); const g = n.runWebGPUProgram(p, [i], i.dtype, m), y = Jz({ inputs: { x: g }, backend: n, attrs: { shape: d } }); return n.disposeData(g.dataId), y } }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class oV { constructor(e, t, n) { this.variableNames = ["input", "indices", "segmentIds"], this.outputShape = [], this.uniforms = "segmentSize : i32, sparseSize : i32,", this.workgroupSize = [64, 1, 1], this.atomic = !0, this.outputShape = e, this.type = n, this.dispatchLayout = wz([t]), this.dispatch = bz(this.dispatchLayout, [t], this.workgroupSize), this.shaderKey = "sparseSegmentSum" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.sparseSize) {\n let indexInSegmentIds = index / uniforms.segmentSize;\n let indexInSegment = index % uniforms.segmentSize;\n let indexInInput = indices[indexInSegmentIds];\n let segmentId = segmentIds[indexInSegmentIds];\n\n let value = input[indexInInput * uniforms.segmentSize + indexInSegment];\n let outIndex = segmentId * uniforms.segmentSize + indexInSegment;\n ${tz("&result[outIndex]", "value", this.type)}\n }\n }\n ` } } class sV { constructor(e, t) { this.variableNames = ["segmentIds"], this.outputShape = [], this.workgroupSize = [64, 1, 1], this.atomic = !0, this.outputShape = [e], this.dispatchLayout = wz(t), this.dispatch = bz(this.dispatchLayout, t, this.workgroupSize), this.shaderKey = "sparseSegmentIdCountProgram" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.segmentIdsShape) {\n let segmentId = segmentIds[index];\n ${tz("&result[segmentId]", "1", "int32")}\n }\n }\n ` } } class uV { constructor(e, t) { this.variableNames = ["segmentSum", "sameSegmentIdCount"], this.outputShape = [], this.uniforms = "segmentSize : i32", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.type = t, this.dispatchLayout = wz(e), this.dispatch = bz(this.dispatchLayout, e, this.workgroupSize), this.shaderKey = "sparseSegmentMean" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let segmentId = index / uniforms.segmentSize;\n let count = sameSegmentIdCount[segmentId];\n if (count != 0) {\n ${"float32" === this.type ? "setOutputAtIndex(index, segmentSum[index] / f32(count));" : "setOutputAtIndexI32(index, segmentSum[index] / count);"}\n }\n }\n }\n ` } } + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function lV(e, t, n, r = !1, i) { const a = P.util.sizeFromShape(e.shape) / e.shape[0], o = e.dtype, s = P.util.sizeFromShape(t.shape), u = i.readSync(n.dataId), l = s > 0 ? u[s - 1] + 1 : 0; let c; const h = e.shape.slice(); h[0] = l; const d = s * a, f = Kz({ backend: i, attrs: { shape: h, value: 0, dtype: o } }); c = new oV(h, d, o); let p = [{ type: "int32", data: [a] }, { type: "int32", data: [d] }]; const m = i.runWebGPUProgram(c, [e, t, n], o, p, f); if (r) return m; const g = Kz({ backend: i, attrs: { shape: [l], value: 0, dtype: "int32" } }); c = new sV(l, n.shape); const y = i.runWebGPUProgram(c, [n], "int32", null, g), b = Kz({ backend: i, attrs: { shape: h, value: 0, dtype: o } }); c = new uV(h, o), p = [{ type: "int32", data: [a] }]; const v = i.runWebGPUProgram(c, [m, y], o, p, b); return i.disposeData(m.dataId), i.disposeData(y.dataId), v } const cV = { + kernelName: P.SparseSegmentMean, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; return lV(r, i, a, !1, n) } + }; const hV = { + kernelName: P.SparseSegmentSum, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; return lV(r, i, a, !0, n) } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class dV { constructor(e, t) { this.variableNames = ["A"], this.workgroupSize = [64, 1, 1], this.size = !0; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[r] * t[r]; this.outputShape = n, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.rank = this.outputShape.length, this.shaderKey = "tile" } getUserCode() { const e = function (e, t = "") { if (e >= 5) throw Error(`Tile for rank ${e} is not yet supported`); if (1 === e) return `(resRC % ${t}aShape)`; const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], r = []; for (let i = 0; i < e; i++)r.push(`(${n[i]} % ${t}aShape[${i}])`); return r.join() }(this.rank, "uniforms."); return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let resRC = getCoordsFromIndex(index);\n setOutputAtIndex(index, getA(${e}));\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function fV(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reps: a } = r; if (n.shouldExecuteOnCPU([i]) || "string" === i.dtype || i.shape.length >= 5) { const e = n.readSync(i.dataId), t = "string" === i.dtype ? e.map((e => P.util.decodeString(e))) : e, r = (0, P.buffer)(i.shape, i.dtype, t), o = UP(r, a); return n.makeTensorInfo(o.shape, o.dtype, o.values) } const o = new dV(i.shape, a); return n.runWebGPUProgram(o, [i], i.dtype) } const pV = { kernelName: P.Tile, backendName: "webgpu", kernelFunc: fV }; const mV = { + kernelName: P.SparseToDense, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { sparseIndices: i, sparseValues: a, defaultValue: o } = t, { outputShape: s } = r, { sliceRank: u, numUpdates: l, sliceSize: c, strides: h, outputSize: d } = P.backend_util.calculateShapes(a, i, s), f = !1; if ("string" === a.dtype) { const e = n.bufferSync(i), t = n.bufferSync(a), r = P.util.decodeString(n.readSync(o.dataId)[0]), p = OP(e, t, s, d, c, l, u, h, r, f); return n.makeTensorInfo(s, p.dtype, p.values) } const p = [d / c, c], m = Jz({ inputs: { x: i }, backend: n, attrs: { shape: [l, u] } }), g = a.shape.length ? Jz({ inputs: { x: a }, backend: n, attrs: { shape: [l, c] } }) : iP({ inputs: { x: a }, backend: n }), y = g.dtype, b = n.makeTensorInfo([], y, P.util.makeZerosTypedArray(1, y)), v = Jz({ inputs: { x: o }, backend: n, attrs: { shape: Array(p.length).fill(1) } }), x = fV({ inputs: { x: v }, backend: n, attrs: { reps: p } }), w = [{ type: "int32", data: [u] }, { type: "int32", data: h }, { type: "int32", data: [P.util.sizeFromShape([l, c])] }]; switch (l) { case 0: break; case 1: { const e = new LW([l, c], u, m.shape.length, g.shape.length, h, p, y, f); n.runWebGPUProgram(e, [g, m], y, w, x) } break; default: { const e = new LW([l, c], u, m.shape.length, b.shape.length, h, p, y, f); n.runWebGPUProgram(e, [b, m], y, w, x) } { const e = new LW([l, c], u, m.shape.length, g.shape.length, h, p, y); n.runWebGPUProgram(e, [g, m], y, w, x) } }const k = Jz({ inputs: { x }, backend: n, attrs: { shape: s } }); return n.disposeData(m.dataId), n.disposeData(g.dataId), n.disposeData(v.dataId), n.disposeData(b.dataId), n.disposeData(x.dataId), k } + }; const gV = { + kernelName: P.SplitV, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { numOrSizeSplits: a, axis: o } = r, s = P.util.parseAxisParam(o, i.shape)[0], u = P.backend_util.prepareSplitSize(i, a, s), l = i.shape.length, c = new Array(l).fill(0), h = i.shape.slice(); return u.map((e => { const t = [...h]; t[s] = e; const r = UB({ inputs: { x: i }, backend: n, attrs: { begin: c, size: t } }); return c[s] += e, r })) } + }, yV = lP({ opType: Fz.SQRT }), bV = { kernelName: P.Sqrt, backendName: "webgpu", kernelFunc: yV }, vV = { kernelName: P.Square, backendName: "webgpu", kernelFunc: ({ inputs: e, backend: t }) => { const { x: n } = e, r = t, i = new uP(n.shape, Fz.SQUARE); return r.runWebGPUProgram(i, [n], n.dtype) } }, xV = cP({ opType: Nz.SQUARED_DIFFERENCE }), wV = { kernelName: P.SquaredDifference, backendName: "webgpu", kernelFunc: xV }; const kV = { + kernelName: P.Step, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2022 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function ({ inputs: e, attrs: t, backend: n }) { const { x: r } = e, i = new uP(r.shape, Fz.STEP, "stepAlpha : f32,"), a = [{ type: "float32", data: [t.alpha] }]; return n.runWebGPUProgram(i, [r], r.dtype, a) } + }; + /** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class SV { constructor(e) { this.variableNames = ["x"], this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]); const t = oz(this.outputShape.length); this.uniforms = `begin : ${t}, strides : ${t}, `, this.shaderKey = "stridedSlice" } getUserCode() { let e = ""; if (1 === this.outputShape.length) e = "coords * uniforms.strides + uniforms.begin"; else { let t = 0; e = this.outputShape.map(((e, n) => (t++, 1 === this.outputShape.length ? `coords * uniforms.strides[${n}] + uniforms.begin[${n}]` : `coords[${t - 1}] * uniforms.strides[${n}] + uniforms.begin[${n}]`))).join(",") } return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n setOutputAtIndex(index, getX(${e}));\n }\n }\n ` } } const _V = { + kernelName: P.StridedSlice, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, end: o, strides: s, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: h, shrinkAxisMask: d } = r, { finalShapeSparse: f, finalShape: p, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: b, end: v, strides: x } = P.slice_util.sliceInfo(i.shape, a, o, s, u, l, c, h, d); let w; if (m) w = Jz({ inputs: { x: i }, backend: n, attrs: { shape: p } }); else if (g || y) { P.util.assert(i.shape.length >= 1, (() => `Input must have rank at least 1, got: ${i.shape.length}`)); const e = P.slice_util.computeOutShape(b, v, x), t = UB({ inputs: { x: i }, backend: n, attrs: { begin: b, size: e } }); w = Jz({ inputs: { x: t }, backend: n, attrs: { shape: p } }), n.disposeData(t.dataId) } else { if (n.shouldExecuteOnCPU([i])) { const e = n.readSync(i.dataId), t = (0, P.buffer)(i.shape, i.dtype, e), r = BP(f, t, x, b); w = n.makeTensorInfo(p, i.dtype, r.values) } else { const e = new SV(f), t = [{ type: "int32", data: b }, { type: "int32", data: x }], r = n.runWebGPUProgram(e, [i], i.dtype, t); w = Jz({ inputs: { x: r }, backend: n, attrs: { shape: p } }), n.disposeData(r.dataId) } } return w } + }; const CV = { + kernelName: P.StringNGrams, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { separator: i, nGramWidths: a, leftPad: o, rightPad: s, padWidth: u, preserveShortSequences: l } = r, { data: c, dataSplits: h } = t, d = n.readSync(c.dataId), f = n.readSync(h.dataId), [p, m] = LP(d, f, i, a, o, s, u, l); return [n.makeTensorInfo([p.length], "string", p), n.makeTensorInfo(h.shape, "int32", m)] } + }, AV = cP({ opType: Nz.SUB, cpuKernelImpl: jP, supportsComplex: !0 }), TV = { kernelName: P.Sub, backendName: "webgpu", kernelFunc: AV }, EV = lP({ opType: Fz.TAN }), NV = { kernelName: P.Tan, backendName: "webgpu", kernelFunc: EV }, IV = lP({ opType: Fz.TANH }), MV = { kernelName: P.Tanh, backendName: "webgpu", kernelFunc: IV }; const FV = { + kernelName: P.TensorScatterUpdate, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { tensor: i, indices: a, updates: o } = t, { } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(o, a, i.shape), d = [h / l, l]; if (0 === h) return n.makeTensorInfo(i.shape, a.dtype); const f = [], p = Jz({ inputs: { x: a }, backend: n, attrs: { shape: [u, s] } }); f.push(p); const m = Jz({ inputs: { x: o }, backend: n, attrs: { shape: [u, l] } }); f.push(m); const g = Jz({ inputs: { x: i }, backend: n, attrs: { shape: d } }); f.push(g); const y = fV({ inputs: { x: g }, backend: n, attrs: { reps: Array(d.length).fill(1) } }), b = new LW([u, l], s, p.shape.length, m.shape.length, c, d, i.dtype, !1), v = [{ type: "int32", data: [s] }, { type: "int32", data: c }, { type: "int32", data: [P.util.sizeFromShape([u, l])] }], x = n.runWebGPUProgram(b, [m, p], g.dtype, v, y); f.push(x); const w = Jz({ inputs: { x }, backend: n, attrs: { shape: i.shape } }); return f.forEach((e => n.disposeData(e.dataId))), w } + }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class DV { constructor(e) { this.variableNames = ["x", "indices"], this.workgroupSize = [256, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.uniforms = "inputSize : i32, firstPass : i32, negativeInf : f32,\n dir : i32, inc : i32,", this.shaderKey = "swap" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let outC = getCoordsFromIndex(index);\n let batch = outC[0];\n let elemIdx = outC[1];\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced\n // above, Figure5(a) shows that element[1] is in the second half of\n // the group when group size is 2, but it is in the first half of\n // the group when group size is 4.\n let isFirstInPair = elemIdx % (2 * uniforms.inc) < uniforms.inc;\n var i = 0;\n if (isFirstInPair) {\n i = elemIdx;\n } else {\n i = elemIdx - uniforms.inc;\n }\n\n var i0 = 0;\n if (uniforms.firstPass == 1) {\n i0 = i;\n } else {\n i0 = i32(getIndices(batch, i));\n }\n\n var i1 = 0;\n if (uniforms.firstPass == 1) {\n i1 = i + uniforms.inc;\n } else {\n i1 = i32(getIndices(batch, i + uniforms.inc));\n }\n\n var x0 = f32(0.0);\n var x1 = f32(0.0);\n if (i0 < uniforms.inputSize) {\n x0 = getX(batch, i0);\n } else {\n x0 = uniforms.negativeInf;\n }\n if (i1 < uniforms.inputSize) {\n x1 = getX(batch, i1);\n } else {\n x1 = uniforms.negativeInf;\n }\n\n let reverse = elemIdx % (2 * uniforms.dir) >= uniforms.dir;\n let isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) {\n // Elements in opposite order of direction\n let iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutputAtIndex(index, f32(i0));\n } else {\n setOutputAtIndex(index, f32(i1));\n }\n }\n }\n ` } } class $V { constructor(e) { this.variableNames = ["x", "indices"], this.workgroupSize = [256, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.uniforms = "inputSize : i32, firstPass : i32, k : i32,", this.shaderKey = "merge" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.size) {\n let outC = getCoordsFromIndex(index);\n let batch = outC[0];\n let elemIdx = outC[1];\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _\n // (k=4), we only need to output the indices at positions |, the\n // indices at positions _ can be thrown away, see Figure5(b) After\n // Phase 2 (Merge phase) in the Bitonic Top K paper referenced\n // above.\n // For example, the paper shows we only need to output the orange\n // bars. The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back to\n // the previous sequence to find the corresponding value, we need\n // to double the index. When we double the index, we basically\n // interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k\n // position of each 2k positions by - elemIdx % k. E.g. for output\n // at index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n var i = 0;\n if (elemIdx < uniforms.k) {\n i = elemIdx;\n } else {\n i = elemIdx * 2 - elemIdx % uniforms.k;\n }\n var i0 = 0;\n if (uniforms.firstPass == 1) {\n i0 = i;\n } else {\n i0 = i32(getIndices(batch, i));\n }\n var i1 = 0;\n if (uniforms.firstPass == 1) {\n i1 = i + uniforms.k;\n } else {\n i1 = i32(getIndices(batch, i + uniforms.k));\n }\n\n let x0 = getX(batch, i0);\n var x1 = f32(0.0);\n if (i1 < uniforms.inputSize) {\n x1 = getX(batch, i1);\n } else {\n x1 = x0;\n }\n\n if (x0 >= x1) {\n setOutputAtIndex(index, f32(i0));\n } else {\n setOutputAtIndex(index, f32(i1));\n }\n }\n }\n ` } } + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function RV(e, t) { null !== t && e.disposeData(t.dataId) } function OV(e) { let t = 1; for (; t < e;)t *= 2; return t } const zV = { kernelName: P.TopK, backendName: "webgpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { k: a, sorted: o } = r, s = i.shape, u = s[s.length - 1]; if (n.shouldExecuteOnCPU([i])) { const e = n.readSync(i.dataId), [t, r] = WP(e, s, i.dtype, a, o); return [n.makeTensorInfo(t.shape, t.dtype, t.values), n.makeTensorInfo(r.shape, r.dtype, r.values)] } if (0 === a) return s[s.length - 1] = 0, [n.makeTensorInfo(s, i.dtype, []), n.makeTensorInfo(s, "int32", [])]; if (1 === u) return [i, Kz({ attrs: { shape: s, dtype: "int32", value: 0 }, backend: n })]; const l = P.util.sizeFromShape(s) / u, c = Jz({ inputs: { x: i }, attrs: { shape: [l, u] }, backend: n }), h = OV(a), d = OV(u); let f = null; const p = () => null === f ? [c, c] : [c, f], m = (e, t, r) => { const i = p(), a = new DV(r), o = [{ type: "int32", data: [u] }, { type: "int32", data: [null === f ? 1 : 0] }, { type: "float32", data: [Number.NEGATIVE_INFINITY] }, { type: "int32", data: [e] }, { type: "int32", data: [t] }], s = f; f = n.runWebGPUProgram(a, i, "int32", o), RV(n, s) }; for (let e = 1; e < h; e *= 2) { const t = 2 * e; for (let n = e; n >= 1; n /= 2)m(t, n, [l, d]) } for (let e = d; e > h; e /= 2) { const t = p(), r = new $V([l, e / 2]), i = [{ type: "int32", data: [u] }, { type: "int32", data: [null === f ? 1 : 0] }, { type: "int32", data: [h] }], a = f; f = n.runWebGPUProgram(r, t, "int32", i), RV(n, a); const o = h / 2, s = 2 * o; for (let e = o; e >= 1; e /= 2)m(s, e, f.shape) } let g = f; f = UB({ inputs: { x: f }, backend: n, attrs: { begin: 0, size: [l, a] } }), RV(n, g); let y = Kj({ inputs: { x: c, indices: f }, backend: n, attrs: { axis: 1, batchDims: 1 } }); RV(n, c); const b = s.slice(0, -1); b.push(a), g = f, f = Jz({ inputs: { x: f }, attrs: { shape: b }, backend: n }), RV(n, g); const v = y; return y = Jz({ inputs: { x: y }, attrs: { shape: b }, backend: n }), RV(n, v), [y, f] } }; + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class PV { constructor(e) { this.variableNames = ["Image", "Transforms"], this.uniforms = "interpolationModeId : i32, fillModeId : i32, fillValue : f32,", this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = e, this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "transform" } getUserCode() { return `\n fn mapCoord(outCoord : f32, len : f32) -> f32{\n var inCoord = outCoord;\n if(uniforms.fillModeId == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n let sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * f32(i32(f32(-inCoord / sz2))) +\n inCoord;\n }\n if (inCoord < -len) {\n inCoord = inCoord + sz2;\n } else {\n inCoord = -inCoord - 1.0;\n }\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n let sz2 = 2.0 * len;\n inCoord = inCoord - sz2 * f32(i32(f32(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (uniforms.fillModeId == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n let sz = len - 1.0;\n inCoord = inCoord + len * (f32(i32(f32(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n let sz = len - 1.0;\n inCoord = inCoord - len * f32(i32(f32(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (uniforms.fillModeId == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n }\n return outCoord;\n }\n fn readWithFillValue(batch : i32, coordY : i32, coordX : i32,\n channel : i32) -> f32 {\n var outputValue : f32;\n if (0 <= coordY && coordY < uniforms.imageShape[1] && 0 <= coordX && coordX < uniforms.imageShape[2]) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = uniforms.fillValue;\n }\n return outputValue;\n }\n\n ${uz("index")} {\n if (index < uniforms.size) {\n let coords = getCoordsFromIndex(index);\n var outputValue : f32;\n let batch = coords[0];\n let x = coords[2];\n let y = coords[1];\n let channel = coords[3];\n let xf = f32(x);\n let yf = f32(y);\n let a1 = getTransforms(batch, 0);\n let a2 = getTransforms(batch, 1);\n let a3 = getTransforms(batch, 2);\n let b1 = getTransforms(batch, 3);\n let b2 = getTransforms(batch, 4);\n let b3 = getTransforms(batch, 5);\n let c1 = getTransforms(batch, 6);\n let c2 = getTransforms(batch, 7);\n let projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = uniforms.fillValue;\n } else {\n let inX = (a1 * xf + a2 * yf + a3) / projection;\n let inY = (b1 * xf + b2 * yf + b3) / projection;\n let mapX = mapCoord(inX, f32(uniforms.imageShape[2]));\n let mapY = mapCoord(inY, f32(uniforms.imageShape[1]));\n\n if (uniforms.interpolationModeId == 1) {\n let coordY = i32(round(mapY));\n let coordX = i32(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n let yFloor = floor(mapY);\n let xFloor = floor(mapX);\n let yCeil = yFloor + 1.0;\n let xCeil = xFloor + 1.0;\n let valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, i32(yFloor), i32(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, i32(yFloor), i32(xCeil), channel);\n let valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, i32(yCeil), i32(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, i32(yCeil), i32(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutputAtIndex(index, outputValue);\n }\n }\n ` } } const BV = { + kernelName: P.Transform, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i, transforms: a } = t, { interpolation: o, fillMode: s, fillValue: u, outputShape: l } = r, [c, h, d, f] = i.shape, [p, m] = null != l ? l : [h, d], g = new PV([c, p, m, f]), y = "nearest" === o ? 1 : 2; let b; switch (s) { case "constant": default: b = 1; break; case "reflect": b = 2; break; case "wrap": b = 3; break; case "nearest": b = 4 }const v = [{ type: "int32", data: [y] }, { type: "int32", data: [b] }, { type: "float32", data: [u] }]; return n.runWebGPUProgram(g, [i, a], "float32", v) } + }; const LV = { + kernelName: P.Unpack, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { value: i } = t; let { axis: a } = r; a < 0 && (a += i.shape.length); const o = i, s = o.shape.length, u = i.shape[a], l = new Array(s - 1); let c = 0; for (let e = 0; e < s; e++)e !== a && (l[c++] = o.shape[e]); const h = [], d = new Array(s).fill(0), f = o.shape.slice(); f[a] = 1; const p = new Array(u); for (let e = 0; e < p.length; e++) { d[a] = e; const t = UB({ inputs: { x: o }, backend: n, attrs: { begin: d, size: f } }), r = Jz({ inputs: { x: t }, backend: n, attrs: { shape: l } }); p[e] = r, h.push(t) } return h.forEach((e => n.disposeData(e.dataId))), p } + }; + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + class jV { constructor(e, t, n) { if (this.outputShape = [], this.variableNames = ["x", "segmentIds"], this.uniforms = "numSegments : i32, xSize: i32,", this.workgroupSize = [64, 1, 1], this.atomic = !0, this.outputShape = t, this.dispatchLayout = wz(e), this.dispatch = bz(this.dispatchLayout, e, this.workgroupSize), "float32" !== n && "int32" !== n) throw new Error(`UnsortedSegmentSum only supports float32 and int32\n types, does not support ${n} type.`); this.type = n, this.shaderKey = "unsortedSegmentSum" } getUserCode() { return `\n ${uz("index")} {\n if (index < uniforms.xSize) {\n let coords = getXCoordsFromIndex(index);\n let b = coords[0];\n let inCol = coords[1];\n\n let segmentId = i32(getSegmentIds(inCol));\n if (segmentId >= 0) {\n let flatIndex = b * uniforms.numSegments + segmentId % uniforms.numSegments;\n let value = getX(b, inCol);\n\n ${tz("&result[flatIndex]", "value", this.type)}\n }\n }\n }\n ` } } const UV = { + kernelName: P.UnsortedSegmentSum, backendName: "webgpu", kernelFunc: + /** + * @license + * Copyright 2023 Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, segmentIds: a } = t, { numSegments: o } = r, s = i.shape.length, u = []; let l = 0; const c = P.backend_util.getAxesPermutation([l], s); let h = i; null != c && (h = aB({ inputs: { x: i }, backend: n, attrs: { perm: c } }), u.push(h), l = P.backend_util.getInnerMostAxes(1, s)[0]); const d = P.backend_util.segment_util.computeOutShape(h.shape, l, o), f = P.util.sizeFromShape([h.shape[l]]), p = Jz({ inputs: { x: h }, backend: n, attrs: { shape: [-1, f] } }); u.push(p); const m = i.dtype, g = [p.shape[0], o], y = Kz({ backend: n, attrs: { shape: g, value: 0, dtype: m } }), b = new jV(p.shape, g, m), v = [{ type: "int32", data: [o] }, { type: "int32", data: [P.util.sizeFromShape(p.shape)] }], x = n.runWebGPUProgram(b, [p, a], m, v, y), w = Jz({ inputs: { x }, backend: n, attrs: { shape: d } }); u.push(x); let k = w; if (null != c) { u.push(w); const e = P.backend_util.getUndoAxesPermutation(c); k = aB({ inputs: { x: k }, backend: n, attrs: { perm: e } }) } return u.forEach((e => n.disposeData(e.dataId))), k } + }, WV = [tP, qP, XP, ZP, QP, tB, cB, hB, fB, pB, gB, bB, xB, kB, _B, DB, $B, zB, PB, BB, VB, qB, XB, eL, nL, aL, sP, uL, pL, xL, CL, TL, NL, IL, ML, DL, RL, zL, WL, VL, GL, qL, ej, tj, ZL, rj, aj, uj, lj, hj, gj, bj, vj, wj, Sj, Cj, Tj, Nj, Fj, Zz, $j, Lj, Oj, Pj, Vj, Gj, Hj, Yj, Zj, Qj, tU, aP, nU, hL, iU, oU, uU, lU, hU, fU, mU, vU, yU, wU, SU, CU, NU, MU, NB, DU, $U, BU, RU, PU, LU, MB, jU, WU, GU, qU, JU, fj, QU, eW, tW, ZB, rW, oW, sW, cW, dW, fW, pW, mW, QB, yW, vW, wW, SW, Qz, CW, TW, NW, MW, DW, RW, zW, BW, jW, WW, GW, qW, XW, ZW, QW, tV, WB, kV, _V, CV, ZU, rV, aV, cV, hV, mV, gV, bV, vV, wV, TV, mj, NV, MV, FV, pV, zV, BV, oB, LV, UV, aW]; for (const e of WV) (0, P.registerKernel)(e); + /** + * @license + * Copyright 2023 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + var VV = function (e, t) { return (VV = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (e, t) { e.__proto__ = t } || function (e, t) { for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]) })(e, t) }; function GV(e, t) { if ("function" != typeof t && null !== t) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null"); function n() { this.constructor = e } VV(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n) } var HV = function () { return (HV = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }).apply(this, arguments) }; function qV(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function YV(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(a) { return function (s) { return function (a) { if (n) throw new TypeError("Generator is already executing."); for (; o;)try { if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i; switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) { case 0: case 1: i = a; break; case 4: return o.label++, { value: a[1], done: !1 }; case 5: o.label++, r = a[1], a = [0]; continue; case 7: a = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== a[0] && 2 !== a[0])) { o = 0; continue } if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) { o.label = a[1]; break } if (6 === a[0] && o.label < i[1]) { o.label = i[1], i = a; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(a); break } i[2] && o.ops.pop(), o.trys.pop(); continue }a = t.call(e, o) } catch (e) { a = [6, e], r = 0 } finally { n = i = 0 } if (5 & a[0]) throw a[1]; return { value: a[0] ? a[1] : void 0, done: !0 } }([a, s]) } } } function XV(e, t, n) { if (n || 2 === arguments.length) for (var r, i = 0, a = t.length; i < a; i++)!r && i in t || (r || (r = Array.prototype.slice.call(t, 0, i)), r[i] = t[i]); return e.concat(r || Array.prototype.slice.call(t)) } var KV = ["nose", "left_eye", "right_eye", "left_ear", "right_ear", "left_shoulder", "right_shoulder", "left_elbow", "right_elbow", "left_wrist", "right_wrist", "left_hip", "right_hip", "left_knee", "right_knee", "left_ankle", "right_ankle"], ZV = ["nose", "left_eye_inner", "left_eye", "left_eye_outer", "right_eye_inner", "right_eye", "right_eye_outer", "left_ear", "right_ear", "mouth_left", "mouth_right", "left_shoulder", "right_shoulder", "left_elbow", "right_elbow", "left_wrist", "right_wrist", "left_pinky", "right_pinky", "left_index", "right_index", "left_thumb", "right_thumb", "left_hip", "right_hip", "left_knee", "right_knee", "left_ankle", "right_ankle", "left_heel", "right_heel", "left_foot_index", "right_foot_index"], JV = { left: [1, 2, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31], right: [4, 5, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32], middle: [0] }, QV = { left: [1, 3, 5, 7, 9, 11, 13, 15], right: [2, 4, 6, 8, 10, 12, 14, 16], middle: [0] }, eG = [[0, 1], [0, 2], [1, 3], [2, 4], [5, 6], [5, 7], [5, 11], [6, 8], [6, 12], [7, 9], [8, 10], [11, 12], [11, 13], [12, 14], [13, 15], [14, 16]], tG = [[0, 1], [0, 4], [1, 2], [2, 3], [3, 7], [4, 5], [5, 6], [6, 8], [9, 10], [11, 12], [11, 13], [11, 23], [12, 14], [14, 16], [12, 24], [13, 15], [15, 17], [16, 18], [16, 20], [15, 17], [15, 19], [15, 21], [16, 22], [17, 19], [18, 20], [23, 25], [23, 24], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [27, 31], [28, 32], [29, 31], [30, 32]]; function nG(e) { return e instanceof SVGAnimatedLength ? e.baseVal.value : e } function rG(e) { return qV(this, void 0, void 0, (function () { var t, n; return YV(this, (function (r) { switch (r.label) { case 0: return t = document.createElement("canvas"), e instanceof P.Tensor ? [4, P.browser.toPixels(e, t)] : [3, 2]; case 1: return r.sent(), [3, 3]; case 2: t.width = nG(e.width), t.height = nG(e.height), n = t.getContext("2d"), e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0), r.label = 3; case 3: return [2, t] } })) })) } function iG(e) { return qV(this, void 0, void 0, (function () { var t, n, r, i, a, o; return YV(this, (function (s) { switch (s.label) { case 0: return e instanceof P.Tensor ? (t = e.shape.slice(0, 2), n = t[0], r = t[1], i = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return [2, new (i.apply(ImageData, [void 0, s.sent(), r, n]))]; case 2: return a = document.createElement("canvas"), o = a.getContext("2d"), a.width = nG(e.width), a.height = nG(e.height), o.drawImage(e, 0, 0), [2, o.getImageData(0, 0, a.width, a.height)] } })) })) } function aG(e) { return qV(this, void 0, void 0, (function () { var t, n; return YV(this, (function (r) { switch (r.label) { case 0: return e instanceof SVGImageElement || e instanceof OffscreenCanvas ? [4, rG(e)] : [3, 2]; case 1: return n = r.sent(), [3, 3]; case 2: n = e, r.label = 3; case 3: return t = n, [2, P.browser.fromPixels(t, 4)] } })) })) } function oG(e) { if (e < 0 || e >= 256) throw new Error("Mask value must be in range [0, 255] but got ".concat(e)); if (!Number.isInteger(e)) throw new Error("Mask value must be an integer but got ".concat(e)) } var sG = { runtime: "mediapipe", enableSmoothing: !0, enableSegmentation: !1, smoothSegmentation: !0, modelType: "full" }, uG = function () { function e(e) { this.mask = e } return e.prototype.toCanvasImageSource = function () { return qV(this, void 0, void 0, (function () { return YV(this, (function (e) { return [2, this.mask] })) })) }, e.prototype.toImageData = function () { return qV(this, void 0, void 0, (function () { return YV(this, (function (e) { return [2, iG(this.mask)] })) })) }, e.prototype.toTensor = function () { return qV(this, void 0, void 0, (function () { return YV(this, (function (e) { return [2, aG(this.mask)] })) })) }, e.prototype.getUnderlyingType = function () { return "canvasimagesource" }, e }(); function lG(e) { return oG(e), "person" } var cG = function () { function e(e) { var t, n = this; switch (this.width = 0, this.height = 0, this.selfieMode = !1, this.poseSolution = new HO.Pose({ locateFile: function (t, n) { if (e.solutionPath) { var r = e.solutionPath.replace(/\/+$/, ""); return "".concat(r, "/").concat(t) } return "".concat(n, "/").concat(t) } }), e.modelType) { case "lite": t = 0; break; case "heavy": t = 2; break; default: t = 1 }this.poseSolution.setOptions({ modelComplexity: t, smoothLandmarks: e.enableSmoothing, enableSegmentation: e.enableSegmentation, smoothSegmentation: e.smoothSegmentation, selfieMode: this.selfieMode }), this.poseSolution.onResults((function (e) { if (n.height = e.image.height, n.width = e.image.width, null == e.poseLandmarks) n.poses = []; else { var t = n.translateOutput(e.poseLandmarks, e.poseWorldLandmarks); e.segmentationMask && (t.segmentation = { maskValueToLabel: lG, mask: new uG(e.segmentationMask) }), n.poses = [t] } })) } return e.prototype.translateOutput = function (e, t) { var n = this, r = { keypoints: e.map((function (e, t) { return { x: e.x * n.width, y: e.y * n.height, z: e.z, score: e.visibility, name: ZV[t] } })) }; return null != t && (r.keypoints3D = t.map((function (e, t) { return { x: e.x, y: e.y, z: e.z, score: e.visibility, name: ZV[t] } }))), r }, e.prototype.estimatePoses = function (e, t, n) { return qV(this, void 0, void 0, (function () { var r, i; return YV(this, (function (a) { switch (a.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.poseSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (i = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return r = new (i.apply(ImageData, [void 0, a.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: r = e, a.label = 3; case 3: return e = r, [4, this.poseSolution.send({ image: e }, n)]; case 4: return a.sent(), [2, this.poses] } })) })) }, e.prototype.dispose = function () { this.poseSolution.close() }, e.prototype.reset = function () { this.poseSolution.reset() }, e.prototype.initialize = function () { return this.poseSolution.initialize() }, e }(); function hG(e) { return qV(this, void 0, void 0, (function () { var t, n; return YV(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return HV({}, sG); var t = HV({}, e); return t.runtime = "mediapipe", null == t.enableSegmentation && (t.enableSegmentation = sG.enableSegmentation), null == t.enableSmoothing && (t.enableSmoothing = sG.enableSmoothing), null == t.smoothSegmentation && (t.smoothSegmentation = sG.smoothSegmentation), null == t.modelType && (t.modelType = sG.modelType), t }(e), [4, (n = new cG(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } function dG(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function fG(e) { return e - 2 * Math.PI * Math.floor((e + Math.PI) / (2 * Math.PI)) } function pG(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function mG(e, t, n) { return gG(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] } function gG(e, t) { P.util.assert(0 !== e.width, (function () { return "".concat(t, " width cannot be 0.") })), P.util.assert(0 !== e.height, (function () { return "".concat(t, " height cannot be 0.") })) } function yG(e, t, n) { var r = n.rotationVectorStartKeypointIndex, i = n.rotationVectorEndKeypointIndex, a = e.locationData, o = a.relativeKeypoints[r].x * t.width, s = a.relativeKeypoints[r].y * t.height, u = a.relativeKeypoints[i].x * t.width, l = a.relativeKeypoints[i].y * t.height, c = 2 * Math.sqrt((u - o) * (u - o) + (l - s) * (l - s)), h = function (e, t, n) { var r, i = e.locationData, a = n.rotationVectorStartKeypointIndex, o = n.rotationVectorEndKeypointIndex; r = n.rotationVectorTargetAngle ? n.rotationVectorTargetAngle : Math.PI * n.rotationVectorTargetAngleDegree / 180; var s = i.relativeKeypoints[a].x * t.width, u = i.relativeKeypoints[a].y * t.height, l = i.relativeKeypoints[o].x * t.width, c = i.relativeKeypoints[o].y * t.height; return fG(r - Math.atan2(-(c - u), l - s)) }(e, t, n); return { xCenter: o / t.width, yCenter: s / t.height, width: c / t.width, height: c / t.height, rotation: h } } function bG(e) { if (16 !== e.length) throw new Error("Array length must be 16 but got ".concat(e.length)); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] } function vG(e, t, n, r, i, a, o) { return e[t][i] * (e[n][a] * e[r][o] - e[n][o] * e[r][a]) } function xG(e, t, n) { var r = (t + 1) % 4, i = (t + 2) % 4, a = (t + 3) % 4, o = (n + 1) % 4, s = (n + 2) % 4, u = (n + 3) % 4; return vG(e, r, i, a, o, s, u) + vG(e, i, a, r, o, s, u) + vG(e, a, r, i, o, s, u) } function wG(e, t, n) { void 0 === n && (n = { ignoreRotation: !1 }); for (var r = [], i = 0, a = e; i < a.length; i++) { var o = a[i], s = o.x - .5, u = o.y - .5, l = n.ignoreRotation ? 0 : t.rotation, c = Math.cos(l) * s - Math.sin(l) * u, h = Math.sin(l) * s + Math.cos(l) * u; c = c * t.width + t.xCenter, h = h * t.height + t.yCenter; var d = o.z * t.width, f = HV({}, o); f.x = c, f.y = h, f.z = d, r.push(f) } return r } function kG(e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return (0, P.tidy)((function () { return (0, P.add)((0, P.mul)(e, n.scale), n.offset) })) } function SG(e, t, n) { var r, i, a, o, s, u, l, c, h, d, f, p, m = t.outputTensorSize, g = t.keepAspectRatio, y = t.borderMode, b = t.outputTensorFloatRange, v = dG(e), x = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(v, n), w = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; gG(t, "targetSize"), gG(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(x, m, g), k = (r = x, i = v.width, a = v.height, o = r.width, s = r.height, u = Math.cos(r.rotation), l = Math.sin(r.rotation), c = r.xCenter, h = r.yCenter, d = 1 / i, f = 1 / a, (p = new Array(16))[0] = o * u * 1 * d, p[1] = -s * l * d, p[2] = 0, p[3] = (-.5 * o * u * 1 + .5 * s * l + c) * d, p[4] = o * l * 1 * f, p[5] = s * u * f, p[6] = 0, p[7] = (-.5 * s * u - .5 * o * l * 1 + h) * f, p[8] = 0, p[9] = 0, p[10] = o * d, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, bG(p)); return { imageTensor: (0, P.tidy)((function () { var t = pG(e), n = (0, P.tensor2d)(mG(k, v, m), [1, 8]), r = "zero" === y ? "constant" : "nearest", i = P.image.transform((0, P.expandDims)((0, P.cast)(t, "float32")), n, "bilinear", r, 0, [m.height, m.width]); return null != b ? kG(i, b) : i })), padding: w, transformationMatrix: k } } function _G(e, t, n, r) { return 1 === r ? .5 * (e + t) : e + (t - e) * n / (r - 1) } function CG(e) { return null != e && null != e.currentTime } function AG(e) { for (var t = { locationData: { relativeKeypoints: [] } }, n = Number.MAX_SAFE_INTEGER, r = Number.MIN_SAFE_INTEGER, i = Number.MAX_SAFE_INTEGER, a = Number.MIN_SAFE_INTEGER, o = 0; o < e.length; ++o) { var s = e[o]; n = Math.min(n, s.x), r = Math.max(r, s.x), i = Math.min(i, s.y), a = Math.max(a, s.y), t.locationData.relativeKeypoints.push({ x: s.x, y: s.y }) } return t.locationData.relativeBoundingBox = { xMin: n, yMin: i, xMax: r, yMax: a, width: r - n, height: a - i }, t } function TG(e, t, n, r) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s; return YV(this, (function (u) { switch (u.label) { case 0: return e.sort((function (e, t) { return Math.max.apply(Math, t.score) - Math.max.apply(Math, e.score) })), r = (0, P.tensor2d)(e.map((function (e) { return [e.locationData.relativeBoundingBox.yMin, e.locationData.relativeBoundingBox.xMin, e.locationData.relativeBoundingBox.yMax, e.locationData.relativeBoundingBox.xMax] }))), i = (0, P.tensor1d)(e.map((function (e) { return e.score[0] }))), [4, P.image.nonMaxSuppressionAsync(r, i, t, n)]; case 1: return [4, (a = u.sent()).array()]; case 2: return o = u.sent(), s = e.filter((function (e, t) { return o.indexOf(t) > -1 })), (0, P.dispose)([r, i, a]), [2, s] } })) })) } function EG(e, t) { return e.map((function (e) { var n = HV(HV({}, e), { x: e.x * t.width, y: e.y * t.height }); return null != e.z && (n.z = e.z * t.width), n })) } function NG(e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p, m, g, y, b, v, x, w, k, S, _, C, A; return YV(this, (function (T) { switch (T.label) { case 0: if (r = (0, P.squeeze)(t, [0]), i = r.shape, a = i[0], o = i[1], s = i[2], e.length !== s) throw new Error("Expected heatmap to have same number of channels as the number of landmarks. But got landmarks length: " + "".concat(e.length, ", heatmap length: ").concat(s)); return u = [], [4, r.buffer()]; case 1: for (l = T.sent(), c = 0; c < e.length; c++)if (h = e[c], d = HV({}, h), u.push(d), f = Math.trunc(d.x * o), p = Math.trunc(d.y * a), !(f < 0 || f >= o || p < 0 || f >= a)) { for (m = Math.trunc((n.kernelSize - 1) / 2), g = Math.max(0, f - m), y = Math.min(o, f + m + 1), b = Math.max(0, p - m), v = Math.min(a, p + m + 1), x = 0, w = 0, k = 0, S = 0, _ = b; _ < v; ++_)for (C = g; C < y; ++C)A = l.get(_, C, c), x += A, S = Math.max(S, A), w += C * A, k += _ * A; S >= n.minConfidenceToRefine && x > 0 && (d.x = w / o / x, d.y = k / a / x) } return r.dispose(), [2, u] } })) })) } function IG(e, t) { var n = t.left, r = t.top, i = t.left + t.right, a = t.top + t.bottom; return e.map((function (e) { return HV(HV({}, e), { x: (e.x - n) / (1 - i), y: (e.y - r) / (1 - a), z: e.z / (1 - i) }) })) } function MG(e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s; return YV(this, (function (u) { switch (u.label) { case 0: return r = e[0], i = e[1], a = function (e, t, n) { return (0, P.tidy)((function () { var r, i, a, o; n.reverseOutputOrder ? (i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))) : (r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))), i = (0, P.add)((0, P.mul)((0, P.div)(i, n.xScale), t.w), t.x), r = (0, P.add)((0, P.mul)((0, P.div)(r, n.yScale), t.h), t.y), n.applyExponentialOnBoxSize ? (a = (0, P.mul)((0, P.exp)((0, P.div)(a, n.hScale)), t.h), o = (0, P.mul)((0, P.exp)((0, P.div)(o, n.wScale)), t.w)) : (a = (0, P.mul)((0, P.div)(a, n.hScale), t.h), o = (0, P.mul)((0, P.div)(o, n.wScale), t.h)); var s = (0, P.sub)(r, (0, P.div)(a, 2)), u = (0, P.sub)(i, (0, P.div)(o, 2)), l = (0, P.add)(r, (0, P.div)(a, 2)), c = (0, P.add)(i, (0, P.div)(o, 2)), h = (0, P.concat)([(0, P.reshape)(s, [n.numBoxes, 1]), (0, P.reshape)(u, [n.numBoxes, 1]), (0, P.reshape)(l, [n.numBoxes, 1]), (0, P.reshape)(c, [n.numBoxes, 1])], 1); if (n.numKeypoints) for (var d = 0; d < n.numKeypoints; ++d) { var f = n.keypointCoordOffset + d * n.numValuesPerKeypoint, p = void 0, m = void 0; n.reverseOutputOrder ? (p = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), m = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))) : (m = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), p = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))); var g = (0, P.add)((0, P.mul)((0, P.div)(p, n.xScale), t.w), t.x), y = (0, P.add)((0, P.mul)((0, P.div)(m, n.yScale), t.h), t.y); h = (0, P.concat)([h, (0, P.reshape)(g, [n.numBoxes, 1]), (0, P.reshape)(y, [n.numBoxes, 1])], 1) } return h })) }(i, t, n), o = (0, P.tidy)((function () { var e = r; return n.sigmoidScore ? (null != n.scoreClippingThresh && (e = (0, P.clipByValue)(r, -n.scoreClippingThresh, n.scoreClippingThresh)), e = (0, P.sigmoid)(e)) : e })), [4, FG(a, o, n)]; case 1: return s = u.sent(), (0, P.dispose)([a, o]), [2, s] } })) })) } function FG(e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p; return YV(this, (function (m) { switch (m.label) { case 0: return r = [], [4, e.data()]; case 1: return i = m.sent(), [4, t.data()]; case 2: for (a = m.sent(), o = 0; o < n.numBoxes; ++o)if (!(null != n.minScoreThresh && a[o] < n.minScoreThresh || (s = o * n.numCoords, u = DG(i[s + 0], i[s + 1], i[s + 2], i[s + 3], a[o], n.flipVertically, o), (l = u.locationData.relativeBoundingBox).width < 0 || l.height < 0))) { if (n.numKeypoints > 0) for ((c = u.locationData).relativeKeypoints = [], h = n.numKeypoints * n.numValuesPerKeypoint, d = 0; d < h; d += n.numValuesPerKeypoint)f = s + n.keypointCoordOffset + d, p = { x: i[f + 0], y: n.flipVertically ? 1 - i[f + 1] : i[f + 1] }, c.relativeKeypoints.push(p); r.push(u) } return [2, r] } })) })) } function DG(e, t, n, r, i, a, o) { return { score: [i], ind: o, locationData: { relativeBoundingBox: { xMin: t, yMin: a ? 1 - n : e, xMax: r, yMax: a ? 1 - e : n, width: r - t, height: n - e } } } } function $G(e, t) { return "none" === e ? t : function (e) { return 1 / (1 + Math.exp(-e)) }(t) } function RG(e, t, n, r) { return qV(this, void 0, void 0, (function () { var i, a, o, s, u, l, c, h; return YV(this, (function (d) { switch (d.label) { case 0: return n = n || t.flipHorizontally || !1, r = r || t.flipVertically || !1, i = e.size, a = i / t.numLandmarks, [4, e.data()]; case 1: for (o = d.sent(), s = [], u = 0; u < t.numLandmarks; ++u)l = u * a, (h = { x: 0, y: 0 }).x = n ? t.inputImageWidth - o[l] : o[l], a > 1 && (h.y = r ? t.inputImageHeight - o[l + 1] : o[l + 1]), a > 2 && (h.z = o[l + 2]), a > 3 && (h.score = $G(t.visibilityActivation, o[l + 3])), s.push(h); for (c = 0; c < s.length; ++c)(h = s[c]).x = h.x / t.inputImageWidth, h.y = h.y / t.inputImageHeight, h.z = h.z / t.inputImageWidth / (t.normalizeZ || 1); return [2, s] } })) })) } function OG(e, t, n) { var r = e.width, i = e.height, a = e.rotation; if (null == n.rotation && null == n.rotationDegree || (a = function (e, t) { return null != t.rotation ? e += t.rotation : null != t.rotationDegree && (e += Math.PI * t.rotationDegree / 180), fG(e) }(a, n)), 0 === a) e.xCenter = e.xCenter + r * n.shiftX, e.yCenter = e.yCenter + i * n.shiftY; else { var o = (t.width * r * n.shiftX * Math.cos(a) - t.height * i * n.shiftY * Math.sin(a)) / t.width, s = (t.width * r * n.shiftX * Math.sin(a) + t.height * i * n.shiftY * Math.cos(a)) / t.height; e.xCenter = e.xCenter + o, e.yCenter = e.yCenter + s } if (n.squareLong) { var u = Math.max(r * t.width, i * t.height); r = u / t.width, i = u / t.height } else if (n.squareShort) { var l = Math.min(r * t.width, i * t.height); r = l / t.width, i = l / t.height } return e.width = r * n.scaleX, e.height = i * n.scaleY, e } function zG(e, t) { return e.map((function (e) { var n = HV(HV({}, e), { x: e.x / t.width, y: e.y / t.height }); return null != e.z && (e.z = e.z / t.width), n })) } var PG = function () { function e(e) { this.alpha = e, this.initialized = !1 } return e.prototype.apply = function (e, t) { var n; return this.initialized ? n = null == t ? this.storedValue + this.alpha * (e - this.storedValue) : this.storedValue + this.alpha * t * Math.asinh((e - this.storedValue) / t) : (n = e, this.initialized = !0), this.rawValue = e, this.storedValue = n, n }, e.prototype.applyWithAlpha = function (e, t, n) { return this.alpha = t, this.apply(e, n) }, e.prototype.hasLastRawValue = function () { return this.initialized }, e.prototype.lastRawValue = function () { return this.rawValue }, e.prototype.reset = function () { this.initialized = !1 }, e }(), BG = function () { function e(e) { this.frequency = e.frequency, this.minCutOff = e.minCutOff, this.beta = e.beta, this.thresholdCutOff = e.thresholdCutOff, this.thresholdBeta = e.thresholdBeta, this.derivateCutOff = e.derivateCutOff, this.x = new PG(this.getAlpha(this.minCutOff)), this.dx = new PG(this.getAlpha(this.derivateCutOff)), this.lastTimestamp = 0 } return e.prototype.apply = function (e, t, n) { if (null == e) return e; var r = Math.trunc(t); if (this.lastTimestamp >= r) return e; 0 !== this.lastTimestamp && 0 !== r && (this.frequency = 1 / (1e-6 * (r - this.lastTimestamp))), this.lastTimestamp = r; var i = this.x.hasLastRawValue() ? (e - this.x.lastRawValue()) * n * this.frequency : 0, a = this.dx.applyWithAlpha(i, this.getAlpha(this.derivateCutOff)), o = this.minCutOff + this.beta * Math.abs(a), s = null != this.thresholdCutOff ? this.thresholdCutOff + this.thresholdBeta * Math.abs(a) : null; return this.x.applyWithAlpha(e, this.getAlpha(o), s) }, e.prototype.getAlpha = function (e) { return 1 / (1 + this.frequency / (2 * Math.PI * e)) }, e }(), LG = function () { function e(e) { this.config = e } return e.prototype.apply = function (e, t, n) { var r = this; if (null == e) return this.reset(), null; this.initializeFiltersIfEmpty(e); var i = 1; if (!this.config.disableValueScaling) { if (n < this.config.minAllowedObjectScale) return XV([], e, !0); i = 1 / n } return e.map((function (e, n) { var a = HV(HV({}, e), { x: r.xFilters[n].apply(e.x, t, i), y: r.yFilters[n].apply(e.y, t, i) }); return null != e.z && (a.z = r.zFilters[n].apply(e.z, t, i)), a })) }, e.prototype.reset = function () { this.xFilters = null, this.yFilters = null, this.zFilters = null }, e.prototype.initializeFiltersIfEmpty = function (e) { var t = this; null != this.xFilters && this.xFilters.length === e.length || (this.xFilters = e.map((function (e) { return new BG(t.config) })), this.yFilters = e.map((function (e) { return new BG(t.config) })), this.zFilters = e.map((function (e) { return new BG(t.config) }))) }, e }(), jG = function () { function e(e) { this.config = e, this.window = [], this.lowPassFilter = new PG(1), this.lastValue = 0, this.lastValueScale = 1, this.lastTimestamp = -1 } return e.prototype.apply = function (e, t, n) { if (null == e) return e; var r, i = Math.trunc(t); if (this.lastTimestamp >= i) return e; if (-1 === this.lastTimestamp) r = 1; else { for (var a = e * n - this.lastValue * this.lastValueScale, o = i - this.lastTimestamp, s = a, u = o, l = (1 + this.window.length) * (1e6 / 30), c = 0, h = this.window; c < h.length; c++) { var d = h[c]; if (u + d.duration > l) break; s += d.distance, u += d.duration } var f = s / (1e-6 * u); r = 1 - 1 / (1 + this.config.velocityScale * Math.abs(f)), this.window.unshift({ distance: a, duration: o }), this.window.length > this.config.windowSize && this.window.pop() } return this.lastValue = e, this.lastValueScale = n, this.lastTimestamp = i, this.lowPassFilter.applyWithAlpha(e, r) }, e }(), UG = function () { function e(e) { this.config = e } return e.prototype.apply = function (e, t, n) { var r = this; if (null == e) return this.reset(), null; var i = 1; if (!this.config.disableValueScaling) { if (n < this.config.minAllowedObjectScale) return XV([], e, !0); i = 1 / n } return this.initializeFiltersIfEmpty(e), e.map((function (e, n) { var a = HV(HV({}, e), { x: r.xFilters[n].apply(e.x, t, i), y: r.yFilters[n].apply(e.y, t, i) }); return null != e.z && (a.z = r.zFilters[n].apply(e.z, t, i)), a })) }, e.prototype.reset = function () { this.xFilters = null, this.yFilters = null, this.zFilters = null }, e.prototype.initializeFiltersIfEmpty = function (e) { var t = this; null != this.xFilters && this.xFilters.length === e.length || (this.xFilters = e.map((function (e) { return new jG(t.config) })), this.yFilters = e.map((function (e) { return new jG(t.config) })), this.zFilters = e.map((function (e) { return new jG(t.config) }))) }, e }(), WG = function () { function e(e) { if (null != e.velocityFilter) this.keypointsFilter = new UG(e.velocityFilter); else { if (null == e.oneEuroFilter) throw new Error("Either configure velocityFilter or oneEuroFilter, but got " + "".concat(e, ".")); this.keypointsFilter = new LG(e.oneEuroFilter) } } return e.prototype.apply = function (e, t, n, r, i) { if (void 0 === r && (r = !1), null == e) return this.keypointsFilter.reset(), null; var a = null != i ? function (e, t) { return (e.width * t.width + e.height * t.height) / 2 }(i, n) : 1, o = r ? EG(e, n) : e, s = this.keypointsFilter.apply(o, t, a); return r ? zG(s, n) : s }, e }(), VG = function () { function e(e) { this.alpha = e.alpha } return e.prototype.apply = function (e) { var t = this; if (null == e) return this.visibilityFilters = null, null; null != this.visibilityFilters && this.visibilityFilters.length === e.length || (this.visibilityFilters = e.map((function (e) { return new PG(t.alpha) }))); for (var n = [], r = 0; r < e.length; ++r) { var i = e[r], a = HV({}, i); a.score = this.visibilityFilters[r].apply(i.score), n.push(a) } return n }, e }(), GG = { reduceBoxesInLowestlayer: !1, interpolatedScaleAspectRatio: 1, featureMapHeight: [], featureMapWidth: [], numLayers: 5, minScale: .1484375, maxScale: .75, inputSizeHeight: 224, inputSizeWidth: 224, anchorOffsetX: .5, anchorOffsetY: .5, strides: [8, 16, 32, 32, 32], aspectRatios: [1], fixedAnchorSize: !0 }, HG = { runtime: "tfjs", modelType: "full", enableSmoothing: !0, enableSegmentation: !1, smoothSegmentation: !0, detectorModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/detector/1", landmarkModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/full/2" }, qG = { maxPoses: 1, flipHorizontal: !1 }, YG = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 2254, numCoords: 12, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 4, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 224, yScale: 224, hScale: 224, wScale: 224, minScoreThresh: .5 }, XG = { shiftX: 0, shiftY: 0, scaleX: 1.25, scaleY: 1.25, squareLong: !0 }, KG = { outputTensorSize: { width: 224, height: 224 }, keepAspectRatio: !0, outputTensorFloatRange: [-1, 1], borderMode: "zero" }, ZG = { outputTensorSize: { width: 256, height: 256 }, keepAspectRatio: !0, outputTensorFloatRange: [0, 1], borderMode: "zero" }, JG = { numLandmarks: 39, inputImageWidth: 256, inputImageHeight: 256, visibilityActivation: "sigmoid", flipHorizontally: !1, flipVertically: !1 }, QG = { numLandmarks: 39, inputImageWidth: 1, inputImageHeight: 1, visibilityActivation: "sigmoid", flipHorizontally: !1, flipVertically: !1 }, eH = { kernelSize: 7, minConfidenceToRefine: .5 }, tH = { alpha: .1 }, nH = { oneEuroFilter: { frequency: 30, minCutOff: .05, beta: 80, derivateCutOff: 1, minAllowedObjectScale: 1e-6 } }, rH = { oneEuroFilter: { frequency: 30, minCutOff: .01, beta: 10, derivateCutOff: 1, minAllowedObjectScale: 1e-6 } }, iH = { oneEuroFilter: { frequency: 30, minCutOff: .1, beta: 40, derivateCutOff: 1, minAllowedObjectScale: 1e-6, disableValueScaling: !0 } }, aH = { activation: "none" }, oH = { combineWithPreviousRatio: .7 }, sH = function () { function e(e) { this.mask = e } return e.prototype.toCanvasImageSource = function () { return qV(this, void 0, void 0, (function () { return YV(this, (function (e) { return [2, rG(this.mask)] })) })) }, e.prototype.toImageData = function () { return qV(this, void 0, void 0, (function () { return YV(this, (function (e) { return [2, iG(this.mask)] })) })) }, e.prototype.toTensor = function () { return qV(this, void 0, void 0, (function () { return YV(this, (function (e) { return [2, this.mask] })) })) }, e.prototype.getUnderlyingType = function () { return "tensor" }, e }(); function uH(e) { return oG(e), "person" } var lH = function () { function e(e, t, n, r, i, a) { this.detectorModel = e, this.landmarkModel = t, this.enableSmoothing = n, this.enableSegmentation = r, this.smoothSegmentation = i, this.modelType = a, this.regionOfInterest = null, this.prevFilteredSegmentationMask = null, this.anchors = function (e) { null == e.reduceBoxesInLowestLayer && (e.reduceBoxesInLowestLayer = !1), null == e.interpolatedScaleAspectRatio && (e.interpolatedScaleAspectRatio = 1), null == e.fixedAnchorSize && (e.fixedAnchorSize = !1); for (var t = [], n = 0; n < e.numLayers;) { for (var r = [], i = [], a = [], o = [], s = n; s < e.strides.length && e.strides[s] === e.strides[n];) { var u = _G(e.minScale, e.maxScale, s, e.strides.length); if (0 === s && e.reduceBoxesInLowestLayer) a.push(1), a.push(2), a.push(.5), o.push(.1), o.push(u), o.push(u); else { for (var l = 0; l < e.aspectRatios.length; ++l)a.push(e.aspectRatios[l]), o.push(u); if (e.interpolatedScaleAspectRatio > 0) { var c = s === e.strides.length - 1 ? 1 : _G(e.minScale, e.maxScale, s + 1, e.strides.length); o.push(Math.sqrt(u * c)), a.push(e.interpolatedScaleAspectRatio) } } s++ } for (var h = 0; h < a.length; ++h) { var d = Math.sqrt(a[h]); r.push(o[h] / d), i.push(o[h] * d) } var f = 0, p = 0; if (e.featureMapHeight.length > 0) f = e.featureMapHeight[n], p = e.featureMapWidth[n]; else { var m = e.strides[n]; f = Math.ceil(e.inputSizeHeight / m), p = Math.ceil(e.inputSizeWidth / m) } for (var g = 0; g < f; ++g)for (var y = 0; y < p; ++y)for (var b = 0; b < r.length; ++b) { var v = { xCenter: (y + e.anchorOffsetX) / p, yCenter: (g + e.anchorOffsetY) / f, width: 0, height: 0 }; e.fixedAnchorSize ? (v.width = 1, v.height = 1) : (v.width = i[b], v.height = r[b]), t.push(v) } n = s } return t }(GG); var o = (0, P.tensor1d)(this.anchors.map((function (e) { return e.width }))), s = (0, P.tensor1d)(this.anchors.map((function (e) { return e.height }))), u = (0, P.tensor1d)(this.anchors.map((function (e) { return e.xCenter }))), l = (0, P.tensor1d)(this.anchors.map((function (e) { return e.yCenter }))); this.anchorTensor = { x: u, y: l, w: o, h: s }, this.prevFilteredSegmentationMask = this.enableSegmentation ? (0, P.tensor2d)([], [0, 0]) : null } return e.prototype.estimatePoses = function (e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p, m, g, y, b, v, x, w, k, S, _, C; return YV(this, (function (A) { switch (A.label) { case 0: return r = function (e) { var t; if (null == (t = null == e ? qG : HV({}, e)).maxPoses && (t.maxPoses = 1), t.maxPoses <= 0) throw new Error("Invalid maxPoses ".concat(t.maxPoses, ". Should be > 0.")); if (t.maxPoses > 1) throw new Error("Multi-pose detection is not implemented yet. Please set maxPoses to 1."); return t }(t), null == e ? (this.reset(), [2, []]) : (this.maxPoses = r.maxPoses, this.timestamp = null != n ? 1e3 * n : CG(e) ? 1e6 * e.currentTime : null, i = dG(e), a = (0, P.tidy)((function () { return (0, P.cast)(pG(e), "float32") })), null != (o = this.regionOfInterest) ? [3, 2] : [4, this.detectPose(a)]); case 1: if (0 === (s = A.sent()).length) return this.reset(), a.dispose(), [2, []]; u = s[0], o = this.poseDetectionToRoi(u, i), A.label = 2; case 2: return [4, this.poseLandmarksByRoi(o, a)]; case 3: return l = A.sent(), a.dispose(), null == l ? (this.reset(), [2, []]) : (c = l.landmarks, h = l.auxiliaryLandmarks, d = l.poseScore, f = l.worldLandmarks, p = l.segmentationMask, m = this.poseLandmarkFiltering(c, h, f, i), g = m.actualLandmarksFiltered, y = m.auxiliaryLandmarksFiltered, b = m.actualWorldLandmarksFiltered, v = this.poseLandmarksToRoi(y, i), this.regionOfInterest = v, x = this.smoothSegmentation && null != p ? this.poseSegmentationFiltering(p) : p, null != (w = null != g ? EG(g, i) : null) && w.forEach((function (e, t) { e.name = ZV[t] })), null != (k = b) && k.forEach((function (e, t) { e.name = ZV[t] })), S = { score: d, keypoints: w, keypoints3D: k }, null !== x && (_ = (0, P.tidy)((function () { var e = (0, P.expandDims)(x, 2), t = (0, P.pad)(e, [[0, 0], [0, 0], [0, 1]]); return (0, P.mirrorPad)(t, [[0, 0], [0, 0], [0, 2]], "symmetric") })), this.smoothSegmentation || (0, P.dispose)(x), C = { maskValueToLabel: uH, mask: new sH(_) }, S.segmentation = C), [2, [S]]) } })) })) }, e.prototype.poseSegmentationFiltering = function (e) { var t = this.prevFilteredSegmentationMask; return 0 === t.size ? this.prevFilteredSegmentationMask = e : (this.prevFilteredSegmentationMask = function (e, t, n) { return "webgl" === (0, P.getBackend)() ? function (e, t, n) { var r = n.combineWithPreviousRatio.toFixed(2), i = { variableNames: ["prevMask", "newMask"], outputShape: e.shape, userCode: "\n void main() {\n ivec2 coords = getOutputCoords();\n int height = coords[0];\n int width = coords[1];\n\n float prevMaskValue = getPrevMask(height, width);\n float newMaskValue = getNewMask(height, width);\n\n /*\n * Assume p := newMaskValue\n * H(p) := 1 + (p * log(p) + (1-p) * log(1-p)) / log(2)\n * uncertainty alpha(p) =\n * Clamp(1 - (1 - H(p)) * (1 - H(p)), 0, 1) [squaring the\n * uncertainty]\n *\n * The following polynomial approximates uncertainty alpha as a\n * function of (p + 0.5):\n */\n const float c1 = 5.68842;\n const float c2 = -0.748699;\n const float c3 = -57.8051;\n const float c4 = 291.309;\n const float c5 = -624.717;\n float t = newMaskValue - 0.5;\n float x = t * t;\n\n float uncertainty =\n 1.0 - min(1.0, x * (c1 + x * (c2 + x * (c3 + x * (c4 + x * c5)))));\n\n float outputValue = newMaskValue + (prevMaskValue - newMaskValue) *\n (uncertainty * ".concat(r, ");\n\n setOutput(outputValue);\n }\n") }, a = (0, P.backend)(); return (0, P.tidy)((function () { var n = a.compileAndRun(i, [e, t]); return (0, P.engine)().makeTensorFromDataId(n.dataId, n.shape, n.dtype) })) }(e, t, n) : (0, P.tidy)((function () { var r = (0, P.sub)(t, .5), i = (0, P.square)(r), a = (0, P.sub)(1, (0, P.minimum)(1, (0, P.mul)(i, (0, P.add)(5.68842, (0, P.mul)(i, (0, P.add)(-.748699, (0, P.mul)(i, (0, P.add)(-57.8051, (0, P.mul)(i, (0, P.add)(291.309, (0, P.mul)(i, -624.717))))))))))); return (0, P.add)(t, (0, P.mul)((0, P.sub)(e, t), (0, P.mul)(a, n.combineWithPreviousRatio))) })) }(t, e, oH), (0, P.dispose)(e)), (0, P.dispose)(t), this.prevFilteredSegmentationMask }, e.prototype.dispose = function () { this.detectorModel.dispose(), this.landmarkModel.dispose(), (0, P.dispose)([this.anchorTensor.x, this.anchorTensor.y, this.anchorTensor.w, this.anchorTensor.h, this.prevFilteredSegmentationMask]) }, e.prototype.reset = function () { this.regionOfInterest = null, this.enableSegmentation && ((0, P.dispose)(this.prevFilteredSegmentationMask), this.prevFilteredSegmentationMask = (0, P.tensor2d)([], [0, 0])), this.visibilitySmoothingFilterActual = null, this.visibilitySmoothingFilterAuxiliary = null, this.landmarksSmoothingFilterActual = null, this.landmarksSmoothingFilterAuxiliary = null }, e.prototype.detectPose = function (e) { return qV(this, void 0, void 0, (function () { var t, n, r, i, a, o, s, u, l, c; return YV(this, (function (h) { switch (h.label) { case 0: return t = SG(e, KG), n = t.imageTensor, r = t.padding, i = this.detectorModel.predict(n), a = function (e) { return (0, P.tidy)((function () { var t = function (e) { return (0, P.tidy)((function () { return [(0, P.slice)(e, [0, 0, 0], [1, -1, 1]), (0, P.slice)(e, [0, 0, 1], [1, -1, -1])] })) }(e), n = t[0], r = t[1]; return { boxes: (0, P.squeeze)(r), logits: (0, P.squeeze)(n) } })) }(i), o = a.boxes, [4, MG([s = a.logits, o], this.anchorTensor, YG)]; case 1: return 0 === (u = h.sent()).length ? ((0, P.dispose)([n, i, s, o]), [2, u]) : [4, TG(u, this.maxPoses, .3)]; case 2: return l = h.sent(), c = function (e, t) { void 0 === e && (e = []); for (var n = t.left, r = t.top, i = t.left + t.right, a = t.top + t.bottom, o = 0; o < e.length; o++) { var s = e[o], u = s.locationData.relativeBoundingBox, l = (u.xMin - n) / (1 - i), c = (u.yMin - r) / (1 - a), h = u.width / (1 - i), d = u.height / (1 - a); u.xMin = l, u.yMin = c, u.width = h, u.height = d, u.xMax = l + h, u.yMax = c + d; var f = s.locationData.relativeKeypoints; f && f.forEach((function (e) { var t = (e.x - n) / (1 - i), o = (e.y - r) / (1 - a); e.x = t, e.y = o })) } return e }(l, r), (0, P.dispose)([n, i, s, o]), [2, c] } })) })) }, e.prototype.poseDetectionToRoi = function (e, t) { return OG(yG(e, t, { rotationVectorEndKeypointIndex: 1, rotationVectorStartKeypointIndex: 0, rotationVectorTargetAngleDegree: 90 }), t, XG) }, e.prototype.poseLandmarksByRoi = function (e, t) { return qV(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m; return YV(this, (function (g) { switch (g.label) { case 0: if (n = dG(t), r = SG(t, ZG, e), i = r.imageTensor, a = r.padding, o = r.transformationMatrix, "lite" !== this.modelType && "full" !== this.modelType && "heavy" !== this.modelType) throw new Error("Model type must be one of lite, full or heavy," + "but got ".concat(this.modelType)); return s = ["ld_3d", "output_poseflag", "activation_heatmap", "world_3d"], this.enableSegmentation && s.push("activation_segmentation"), u = this.landmarkModel.execute(i, s), [4, this.tensorsToPoseLandmarksAndSegmentation(u)]; case 1: return null == (l = g.sent()) ? ((0, P.dispose)(u), (0, P.dispose)(i), [2, null]) : (c = l.landmarks, h = l.auxiliaryLandmarks, d = l.poseScore, f = l.worldLandmarks, p = l.segmentationMask, [4, this.poseLandmarksAndSegmentationInverseProjection(n, e, a, o, c, h, f, p)]); case 2: return m = g.sent(), (0, P.dispose)(u), (0, P.dispose)(i), [2, HV({ poseScore: d }, m)] } })) })) }, e.prototype.poseLandmarksAndSegmentationInverseProjection = function (e, t, n, r, i, a, o, s) { return qV(this, void 0, void 0, (function () { var u, l, c, h, d, f; return YV(this, (function (p) { return u = IG(i, n), l = IG(a, n), c = wG(u, t), h = wG(l, t), d = function (e, t) { for (var n = [], r = 0, i = e; r < i.length; r++) { var a = i[r], o = a.x, s = a.y, u = t.rotation, l = Math.cos(u) * o - Math.sin(u) * s, c = Math.sin(u) * o + Math.cos(u) * s, h = HV({}, a); h.x = l, h.y = c, n.push(h) } return n }(o, t), f = null, this.enableSegmentation && (f = (0, P.tidy)((function () { var t = s.shape, n = t[0], i = t[1], a = function (e) { var t = bG(new Array(16).fill(0)); t[0][0] = xG(e, 0, 0), t[1][0] = -xG(e, 0, 1), t[2][0] = xG(e, 0, 2), t[3][0] = -xG(e, 0, 3), t[0][2] = xG(e, 2, 0), t[1][2] = -xG(e, 2, 1), t[2][2] = xG(e, 2, 2), t[3][2] = -xG(e, 2, 3), t[0][1] = -xG(e, 1, 0), t[1][1] = xG(e, 1, 1), t[2][1] = -xG(e, 1, 2), t[3][1] = xG(e, 1, 3), t[0][3] = -xG(e, 3, 0), t[1][3] = xG(e, 3, 1), t[2][3] = -xG(e, 3, 2), t[3][3] = xG(e, 3, 3); for (var n = e[0][0] * t[0][0] + e[1][0] * t[0][1] + e[2][0] * t[0][2] + e[3][0] * t[0][3], r = 0; r < t.length; r++)for (var i = 0; i < t.length; i++)t[r][i] /= n; return t }(r), o = (0, P.tensor2d)(mG(a, { width: i, height: n }, e), [1, 8]), u = [1, n, i, 1]; return (0, P.squeeze)(P.image.transform((0, P.reshape)(s, u), o, "bilinear", "constant", 0, [e.height, e.width]), [0, 3]) })), (0, P.dispose)(s)), [2, { landmarks: c, auxiliaryLandmarks: h, worldLandmarks: d, segmentationMask: f }] })) })) }, e.prototype.tensorsToPoseLandmarksAndSegmentation = function (e) { return qV(this, void 0, void 0, (function () { var t, n, r, i, a, o, s, u, l, c, h, d, f; return YV(this, (function (p) { switch (p.label) { case 0: return t = e[0], n = e[1], r = e[2], i = e[3], a = this.enableSegmentation ? e[4] : null, [4, n.data()]; case 1: return (o = p.sent()[0]) < .5 ? [2, null] : [4, RG(t, JG)]; case 2: return [4, NG(p.sent(), r, eH)]; case 3: return s = p.sent(), u = s.slice(0, 33), l = s.slice(33, 35), [4, RG(i, QG)]; case 4: return c = p.sent(), h = c.slice(0, 33), d = function (e, t, n) { void 0 === n && (n = !0); for (var r = [], i = 0; i < e.length; i++) { var a = HV({}, t[i]); n && (a.score = e[i].score), r.push(a) } return r }(u, h, !0), f = this.enableSegmentation ? function (e, t) { return (0, P.tidy)((function () { var n = (0, P.squeeze)(e, [0]), r = n.shape[2]; if (1 === r) { var i = n; switch (t.activation) { case "none": break; case "sigmoid": i = (0, P.sigmoid)(i); break; case "softmax": throw new Error("Softmax activation requires two channels."); default: throw new Error("Activation not supported (".concat(t.activation, ")")) }var a = i; return (0, P.squeeze)(a, [2]) } throw new Error("Unsupported number of tensor channels ".concat(r)) })) }(a, aH) : null, [2, { landmarks: u, auxiliaryLandmarks: l, poseScore: o, worldLandmarks: d, segmentationMask: f }] } })) })) }, e.prototype.poseLandmarksToRoi = function (e, t) { return OG(yG(AG(e), t, { rotationVectorStartKeypointIndex: 0, rotationVectorEndKeypointIndex: 1, rotationVectorTargetAngleDegree: 90 }), t, XG) }, e.prototype.poseLandmarkFiltering = function (e, t, n, r) { var i, a, o; if (null != this.timestamp && this.enableSmoothing) { var s = yG(AG(t), r, { rotationVectorEndKeypointIndex: 0, rotationVectorStartKeypointIndex: 1, rotationVectorTargetAngleDegree: 90 }); null == this.visibilitySmoothingFilterActual && (this.visibilitySmoothingFilterActual = new VG(tH)), i = this.visibilitySmoothingFilterActual.apply(e), null == this.visibilitySmoothingFilterAuxiliary && (this.visibilitySmoothingFilterAuxiliary = new VG(tH)), a = this.visibilitySmoothingFilterAuxiliary.apply(t), o = this.visibilitySmoothingFilterActual.apply(n), null == this.landmarksSmoothingFilterActual && (this.landmarksSmoothingFilterActual = new WG(nH)), i = this.landmarksSmoothingFilterActual.apply(i, this.timestamp, r, !0, s), null == this.landmarksSmoothingFilterAuxiliary && (this.landmarksSmoothingFilterAuxiliary = new WG(rH)), a = this.landmarksSmoothingFilterAuxiliary.apply(a, this.timestamp, r, !0, s), null == this.worldLandmarksSmoothingFilterActual && (this.worldLandmarksSmoothingFilterActual = new WG(iH)), o = this.worldLandmarksSmoothingFilterActual.apply(n, this.timestamp) } else i = e, a = t, o = n; return { actualLandmarksFiltered: i, auxiliaryLandmarksFiltered: a, actualWorldLandmarksFiltered: o } }, e }(); function cH(e) { return qV(this, void 0, void 0, (function () { var t, n, r, i, a, o; return YV(this, (function (s) { switch (s.label) { case 0: return t = function (e) { var t = HV({}, null == e ? HG : e); if (null == t.enableSmoothing && (t.enableSmoothing = HG.enableSmoothing), null == t.enableSegmentation && (t.enableSegmentation = HG.enableSegmentation), null == t.smoothSegmentation && (t.smoothSegmentation = HG.smoothSegmentation), null == t.modelType && (t.modelType = HG.modelType), null == t.detectorModelUrl && (t.detectorModelUrl = HG.detectorModelUrl), null == t.landmarkModelUrl) switch (t.modelType) { case "lite": t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/lite/2"; break; case "heavy": t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/heavy/2"; break; default: t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/full/2" }return t }(e), n = "string" == typeof t.detectorModelUrl && t.detectorModelUrl.indexOf("https://tfhub.dev") > -1, r = "string" == typeof t.landmarkModelUrl && t.landmarkModelUrl.indexOf("https://tfhub.dev") > -1, [4, Promise.all([Ud(t.detectorModelUrl, { fromTFHub: n }), Ud(t.landmarkModelUrl, { fromTFHub: r })])]; case 1: return i = s.sent(), a = i[0], o = i[1], [2, new lH(a, o, t.enableSmoothing, t.enableSegmentation, t.smoothSegmentation, t.modelType)] } })) })) } var hH, dH, fH = function () { function e(e) { !function (e) { if (e.maxTracks < 1) throw new Error("Must specify 'maxTracks' to be at least 1, but " + "encountered ".concat(e.maxTracks)); if (e.maxAge <= 0) throw new Error("Must specify 'maxAge' to be positive, but " + "encountered ".concat(e.maxAge)); if (void 0 !== e.keypointTrackerParams) { if (e.keypointTrackerParams.keypointConfidenceThreshold < 0 || e.keypointTrackerParams.keypointConfidenceThreshold > 1) throw new Error("Must specify 'keypointConfidenceThreshold' to be in the range [0, 1], but encountered " + "".concat(e.keypointTrackerParams.keypointConfidenceThreshold)); if (e.keypointTrackerParams.minNumberOfKeypoints < 1) throw new Error("Must specify 'minNumberOfKeypoints' to be at least 1, but " + "encountered ".concat(e.keypointTrackerParams.minNumberOfKeypoints)); for (var t = 0, n = e.keypointTrackerParams.keypointFalloff; t < n.length; t++) { var r = n[t]; if (r <= 0) throw new Error("Must specify each keypoint falloff parameterto be positive " + "but encountered ".concat(r)) } } }(e), this.tracks = [], this.maxTracks = e.maxTracks, this.maxAge = 1e3 * e.maxAge, this.minSimilarity = e.minSimilarity, this.nextID = 1 } return e.prototype.apply = function (e, t) { this.filterOldTracks(t); var n = this.computeSimilarity(e); return this.assignTracks(e, n, t), this.updateTracks(t), e }, e.prototype.getTracks = function () { return this.tracks.slice() }, e.prototype.getTrackIDs = function () { return new Set(this.tracks.map((function (e) { return e.id }))) }, e.prototype.filterOldTracks = function (e) { var t = this; this.tracks = this.tracks.filter((function (n) { return e - n.lastTimestamp <= t.maxAge })) }, e.prototype.assignTracks = function (e, t, n) { for (var r = Array.from(Array(t[0].length).keys()), i = [], a = 0, o = Array.from(Array(e.length).keys()); a < o.length; a++) { var s = o[a]; if (0 !== r.length) { for (var u = -1, l = -1, c = 0, h = r; c < h.length; c++) { var d = h[c], f = t[s][d]; f >= this.minSimilarity && f > l && (u = d, l = f) } if (u >= 0) { var p = this.tracks[u]; p = Object.assign(p, this.createTrack(e[s], n, p.id)), e[s].id = p.id; var m = r.indexOf(u); r.splice(m, 1) } else i.push(s) } else i.push(s) } for (var g = 0, y = i; g < y.length; g++) { s = y[g]; var b = this.createTrack(e[s], n); this.tracks.push(b), e[s].id = b.id } }, e.prototype.updateTracks = function (e) { this.tracks.sort((function (e, t) { return t.lastTimestamp - e.lastTimestamp })), this.tracks = this.tracks.slice(0, this.maxTracks) }, e.prototype.createTrack = function (e, t, n) { var r = { id: n || this.nextTrackID(), lastTimestamp: t, keypoints: XV([], e.keypoints, !0).map((function (e) { return HV({}, e) })) }; return void 0 !== e.box && (r.box = HV({}, e.box)), r }, e.prototype.nextTrackID = function () { var e = this.nextID; return this.nextID += 1, e }, e.prototype.remove = function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; this.tracks = this.tracks.filter((function (t) { return !e.includes(t.id) })) }, e.prototype.reset = function () { this.tracks = [] }, e }(), pH = function (e) { function t(t) { return e.call(this, t) || this } return GV(t, e), t.prototype.computeSimilarity = function (e) { var t = this; return 0 === e.length || 0 === this.tracks.length ? [[]] : e.map((function (e) { return t.tracks.map((function (n) { return t.iou(e, n) })) })) }, t.prototype.iou = function (e, t) { var n = Math.max(e.box.xMin, t.box.xMin), r = Math.max(e.box.yMin, t.box.yMin), i = Math.min(e.box.xMax, t.box.xMax), a = Math.min(e.box.yMax, t.box.yMax); if (n >= i || r >= a) return 0; var o = (i - n) * (a - r); return o / (e.box.width * e.box.height + t.box.width * t.box.height - o) }, t }(fH), mH = function (e) { function t(t) { var n = e.call(this, t) || this; return n.keypointThreshold = t.keypointTrackerParams.keypointConfidenceThreshold, n.keypointFalloff = t.keypointTrackerParams.keypointFalloff, n.minNumKeyoints = t.keypointTrackerParams.minNumberOfKeypoints, n } return GV(t, e), t.prototype.computeSimilarity = function (e) { if (0 === e.length || 0 === this.tracks.length) return [[]]; for (var t = [], n = 0, r = e; n < r.length; n++) { for (var i = r[n], a = [], o = 0, s = this.tracks; o < s.length; o++) { var u = s[o]; a.push(this.oks(i, u)) } t.push(a) } return t }, t.prototype.oks = function (e, t) { for (var n = this.area(t.keypoints) + 1e-6, r = 0, i = 0, a = 0; a < e.keypoints.length; ++a) { var o = e.keypoints[a], s = t.keypoints[a]; if (!(o.score < this.keypointThreshold || s.score < this.keypointThreshold)) { i += 1; var u = Math.pow(o.x - s.x, 2) + Math.pow(o.y - s.y, 2), l = 2 * this.keypointFalloff[a]; r += Math.exp(-1 * u / (2 * n * Math.pow(l, 2))) } } return i < this.minNumKeyoints ? 0 : r / i }, t.prototype.area = function (e) { var t = this, n = e.filter((function (e) { return e.score > t.keypointThreshold })), r = Math.min.apply(Math, XV([1], n.map((function (e) { return e.x })), !1)), i = Math.max.apply(Math, XV([0], n.map((function (e) { return e.x })), !1)), a = Math.min.apply(Math, XV([1], n.map((function (e) { return e.y })), !1)); return (i - r) * (Math.max.apply(Math, XV([0], n.map((function (e) { return e.y })), !1)) - a) }, t }(fH); function gH(e) { switch (e) { case dH.BlazePose: return ZV.reduce((function (e, t, n) { return e[t] = n, e }), {}); case dH.PoseNet: case dH.MoveNet: return KV.reduce((function (e, t, n) { return e[t] = n, e }), {}); default: throw new Error("Model ".concat(e, " is not supported.")) } } !function (e) { e.Keypoint = "keypoint", e.BoundingBox = "boundingBox" }(hH || (hH = {})), function (e) { e.MoveNet = "MoveNet", e.BlazePose = "BlazePose", e.PoseNet = "PoseNet" }(dH || (dH = {})); var yH = Object.freeze({ __proto__: null, getKeypointIndexBySide: function (e) { switch (e) { case dH.BlazePose: return JV; case dH.PoseNet: case dH.MoveNet: return QV; default: throw new Error("Model ".concat(e, " is not supported.")) } }, getAdjacentPairs: function (e) { switch (e) { case dH.BlazePose: return tG; case dH.PoseNet: case dH.MoveNet: return eG; default: throw new Error("Model ".concat(e, " is not supported.")) } }, getKeypointIndexByName: gH }), bH = ["SinglePose.Lightning", "SinglePose.Thunder", "MultiPose.Lightning"], vH = { modelType: "SinglePose.Lightning", enableSmoothing: !0 }, xH = {}, wH = { frequency: 30, minCutOff: 2.5, beta: 300, derivateCutOff: 2.5, thresholdCutOff: .5, thresholdBeta: 5, disableValueScaling: !0 }, kH = { maxTracks: 18, maxAge: 1e3, minSimilarity: .2, keypointTrackerParams: { keypointConfidenceThreshold: .3, keypointFalloff: [.026, .025, .025, .035, .035, .079, .079, .072, .072, .062, .062, .107, .107, .087, .087, .089, .089], minNumberOfKeypoints: 4 } }, SH = { maxTracks: 18, maxAge: 1e3, minSimilarity: .15, trackerParams: {} }; function _H(e, t) { var n, r, i, a; return e ? t.width > t.height ? (n = 1, r = t.height / t.width, i = 0, a = (t.width / 2 - t.height / 2) / t.width) : (n = t.width / t.height, r = 1, i = (t.height / 2 - t.width / 2) / t.height, a = 0) : t.width > t.height ? (n = t.width / t.height, r = 1, i = (t.height / 2 - t.width / 2) / t.height, a = 0) : (n = 1, r = t.height / t.width, i = 0, a = (t.width / 2 - t.height / 2) / t.width), { yMin: i, xMin: a, yMax: i + n, xMax: a + r, height: n, width: r } } function CH(e, t) { var n = { maxTracks: e.maxTracks, maxAge: e.maxAge, minSimilarity: e.minSimilarity }; return null != t.maxTracks && (n.maxTracks = t.maxTracks), null != t.maxAge && (n.maxAge = t.maxAge), null != t.minSimilarity && (n.minSimilarity = t.minSimilarity), n } var AH = function () { function e(e, t) { this.moveNetModel = e, this.modelInputResolution = { height: 0, width: 0 }, this.keypointIndexByName = gH(dH.MoveNet), "SinglePose.Lightning" === t.modelType ? (this.modelInputResolution.width = 192, this.modelInputResolution.height = 192) : "SinglePose.Thunder" === t.modelType && (this.modelInputResolution.width = 256, this.modelInputResolution.height = 256), this.multiPoseModel = "MultiPose.Lightning" === t.modelType, this.multiPoseModel || (this.keypointFilter = new LG(wH), this.cropRegionFilterYMin = new PG(.9), this.cropRegionFilterXMin = new PG(.9), this.cropRegionFilterYMax = new PG(.9), this.cropRegionFilterXMax = new PG(.9)), this.enableSmoothing = t.enableSmoothing, t.minPoseScore ? this.minPoseScore = t.minPoseScore : this.minPoseScore = .25, t.multiPoseMaxDimension ? this.multiPoseMaxDimension = t.multiPoseMaxDimension : this.multiPoseMaxDimension = 256, this.enableTracking = t.enableTracking, this.multiPoseModel && this.enableTracking && (t.trackerType === hH.Keypoint ? this.tracker = new mH(t.trackerConfig) : t.trackerType === hH.BoundingBox && (this.tracker = new pH(t.trackerConfig)), this.enableSmoothing && (this.keypointFilterMap = new Map)) } return e.prototype.runSinglePersonPoseModel = function (e) { return qV(this, void 0, void 0, (function () { var t, n, r, i, a; return YV(this, (function (o) { switch (o.label) { case 0: if (4 !== (t = this.moveNetModel.execute(e)).shape.length || 1 !== t.shape[0] || 1 !== t.shape[1] || 17 !== t.shape[2] || 3 !== t.shape[3]) throw t.dispose(), new Error("Unexpected output shape from model: [".concat(t.shape, "]")); return "webgpu" === (0, P.getBackend)() ? [3, 1] : (n = t.dataSync(), [3, 3]); case 1: return [4, t.data()]; case 2: n = o.sent(), o.label = 3; case 3: for (t.dispose(), r = { keypoints: [], score: 0 }, i = 0, a = 0; a < 17; ++a)r.keypoints[a] = { y: n[3 * a], x: n[3 * a + 1], score: n[3 * a + 2] }, r.keypoints[a].score > .2 && (++i, r.score += r.keypoints[a].score); return i > 0 && (r.score /= i), [2, r] } })) })) }, e.prototype.runMultiPersonPoseModel = function (e) { return qV(this, void 0, void 0, (function () { var t, n, r, i, a, o, s, u; return YV(this, (function (l) { switch (l.label) { case 0: if (3 !== (t = this.moveNetModel.execute(e)).shape.length || 1 !== t.shape[0] || 56 !== t.shape[2]) throw t.dispose(), new Error("Unexpected output shape from model: [".concat(t.shape, "]")); return "webgpu" === (0, P.getBackend)() ? [3, 1] : (n = t.dataSync(), [3, 3]); case 1: return [4, t.data()]; case 2: n = l.sent(), l.label = 3; case 3: for (t.dispose(), r = [], i = n.length / 56, a = 0; a < i; ++a)for (r[a] = { keypoints: [] }, o = 56 * a + 51, r[a].box = { yMin: n[o], xMin: n[o + 1], yMax: n[o + 2], xMax: n[o + 3], width: n[o + 3] - n[o + 1], height: n[o + 2] - n[o] }, s = 56 * a + 55, r[a].score = n[s], r[a].keypoints = [], u = 0; u < 17; ++u)r[a].keypoints[u] = { y: n[56 * a + 3 * u], x: n[56 * a + 3 * u + 1], score: n[56 * a + 3 * u + 2] }; return [2, r] } })) })) }, e.prototype.estimatePoses = function (e, t, n) { return void 0 === t && (t = xH), qV(this, void 0, void 0, (function () { var r, i, a, o, s, u; return YV(this, (function (l) { switch (l.label) { case 0: return t = function (e) { return null == e ? xH : HV({}, e) }(t), null == e ? (this.reset(), [2, []]) : (null == n ? CG(e) && (n = 1e6 * e.currentTime) : n *= 1e3, r = pG(e), i = dG(r), a = (0, P.expandDims)(r, 0), e instanceof P.Tensor || r.dispose(), o = [], this.multiPoseModel ? [3, 2] : [4, this.estimateSinglePose(a, i, n)]); case 1: return o = l.sent(), [3, 4]; case 2: return [4, this.estimateMultiplePoses(a, i, n)]; case 3: o = l.sent(), l.label = 4; case 4: for (s = 0; s < o.length; ++s)for (u = 0; u < o[s].keypoints.length; ++u)o[s].keypoints[u].name = KV[u], o[s].keypoints[u].y *= i.height, o[s].keypoints[u].x *= i.width; return [2, o] } })) })) }, e.prototype.estimateSinglePose = function (e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s = this; return YV(this, (function (u) { switch (u.label) { case 0: return this.cropRegion || (this.cropRegion = _H(null == this.cropRegion, t)), r = (0, P.tidy)((function () { var t = (0, P.tensor2d)([[s.cropRegion.yMin, s.cropRegion.xMin, s.cropRegion.yMax, s.cropRegion.xMax]]), n = (0, P.zeros)([1], "int32"), r = [s.modelInputResolution.height, s.modelInputResolution.width]; return (0, P.cast)(P.image.cropAndResize(e, t, n, r, "bilinear", 0), "int32") })), e.dispose(), [4, this.runSinglePersonPoseModel(r)]; case 1: if (i = u.sent(), r.dispose(), i.score < this.minPoseScore) return this.reset(), [2, []]; for (a = 0; a < i.keypoints.length; ++a)i.keypoints[a].y = this.cropRegion.yMin + i.keypoints[a].y * this.cropRegion.height, i.keypoints[a].x = this.cropRegion.xMin + i.keypoints[a].x * this.cropRegion.width; return null != n && this.enableSmoothing && (i.keypoints = this.keypointFilter.apply(i.keypoints, n, 1)), o = function (e, t, n, r) { for (var i = {}, a = 0, o = KV; a < o.length; a++) { var s = o[a]; i[s] = [t[n[s]].y * r.height, t[n[s]].x * r.width] } if (function (e, t) { return (e[t.left_hip].score > .2 || e[t.right_hip].score > .2) && (e[t.left_shoulder].score > .2 || e[t.right_shoulder].score > .2) }(t, n)) { var u = (i.left_hip[0] + i.right_hip[0]) / 2, l = (i.left_hip[1] + i.right_hip[1]) / 2, c = function (e, t, n, r, i) { for (var a = ["left_shoulder", "right_shoulder", "left_hip", "right_hip"], o = 0, s = 0, u = 0; u < a.length; u++)(f = Math.abs(r - n[a[u]][0])) > o && (o = f), (p = Math.abs(i - n[a[u]][1])) > s && (s = p); for (var l = 0, c = 0, h = 0, d = Object.keys(n); h < d.length; h++) { var f, p, m = d[h]; e[t[m]].score < .2 || ((f = Math.abs(r - n[m][0])) > l && (l = f), (p = Math.abs(i - n[m][1])) > c && (c = p)) } return [o, s, l, c] }(t, n, i, u, l), h = c[0], d = c[1], f = c[2], p = c[3], m = Math.max(1.9 * d, 1.9 * h, 1.2 * f, 1.2 * p), g = [u - (m = Math.min(m, Math.max(l, r.width - l, u, r.height - u))), l - m]; if (m > Math.max(r.width, r.height) / 2) return _H(null == e, r); var y = 2 * m; return { yMin: g[0] / r.height, xMin: g[1] / r.width, yMax: (g[0] + y) / r.height, xMax: (g[1] + y) / r.width, height: (g[0] + y) / r.height - g[0] / r.height, width: (g[1] + y) / r.width - g[1] / r.width } } return _H(null == e, r) }(this.cropRegion, i.keypoints, this.keypointIndexByName, t), this.cropRegion = this.filterCropRegion(o), [2, [i]] } })) })) }, e.prototype.estimateMultiplePoses = function (e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p = this; return YV(this, (function (m) { switch (m.label) { case 0: return t.width > t.height ? (i = this.multiPoseMaxDimension, a = Math.round(this.multiPoseMaxDimension * t.height / t.width), r = P.image.resizeBilinear(e, [a, i]), s = i, u = 32 * Math.ceil(a / 32), o = (0, P.pad)(r, [[0, 0], [0, u - a], [0, 0], [0, 0]])) : (i = Math.round(this.multiPoseMaxDimension * t.width / t.height), a = this.multiPoseMaxDimension, r = P.image.resizeBilinear(e, [a, i]), s = 32 * Math.ceil(i / 32), u = a, o = (0, P.pad)(r, [[0, 0], [0, 0], [0, s - i], [0, 0]])), r.dispose(), e.dispose(), l = (0, P.cast)(o, "int32"), o.dispose(), [4, this.runMultiPersonPoseModel(l)]; case 1: for (c = m.sent(), l.dispose(), c = c.filter((function (e) { return e.score >= p.minPoseScore })), d = 0; d < c.length; ++d)for (h = 0; h < c[d].keypoints.length; ++h)c[d].keypoints[h].y *= u / a, c[d].keypoints[h].x *= s / i; if (this.enableTracking && (this.tracker.apply(c, n), this.enableSmoothing)) { for (d = 0; d < c.length; ++d)this.keypointFilterMap.has(c[d].id) || this.keypointFilterMap.set(c[d].id, new LG(wH)), c[d].keypoints = this.keypointFilterMap.get(c[d].id).apply(c[d].keypoints, n, 1); f = this.tracker.getTrackIDs(), this.keypointFilterMap.forEach((function (e, t) { f.has(t) || p.keypointFilterMap.delete(t) })) } return [2, c] } })) })) }, e.prototype.filterCropRegion = function (e) { if (e) { var t = this.cropRegionFilterYMin.apply(e.yMin), n = this.cropRegionFilterXMin.apply(e.xMin), r = this.cropRegionFilterYMax.apply(e.yMax), i = this.cropRegionFilterXMax.apply(e.xMax); return { yMin: t, xMin: n, yMax: r, xMax: i, height: r - t, width: i - n } } return this.cropRegionFilterYMin.reset(), this.cropRegionFilterXMin.reset(), this.cropRegionFilterYMax.reset(), this.cropRegionFilterXMax.reset(), null }, e.prototype.dispose = function () { this.moveNetModel.dispose() }, e.prototype.reset = function () { this.cropRegion = null, this.resetFilters() }, e.prototype.resetFilters = function () { this.keypointFilter.reset(), this.cropRegionFilterYMin.reset(), this.cropRegionFilterXMin.reset(), this.cropRegionFilterYMax.reset(), this.cropRegionFilterXMax.reset() }, e }(); function TH(e) { return void 0 === e && (e = vH), qV(this, void 0, void 0, (function () { var t, n, r, i; return YV(this, (function (a) { switch (a.label) { case 0: return t = function (e) { var t, n = null == e ? vH : HV({}, e); if (null == n.modelType) n.modelType = "SinglePose.Lightning"; else if (bH.indexOf(n.modelType) < 0) throw new Error("Invalid architecture ".concat(n.modelType, ". ") + "Should be one of ".concat(bH)); if (null == n.enableSmoothing && (n.enableSmoothing = !0), null != n.minPoseScore && (n.minPoseScore < 0 || n.minPoseScore > 1)) throw new Error("minPoseScore should be between 0.0 and 1.0"); if (null != n.multiPoseMaxDimension && (n.multiPoseMaxDimension % 32 != 0 || n.multiPoseMaxDimension < 32)) throw new Error("multiPoseMaxDimension must be a multiple of 32 and higher than 0"); if ("MultiPose.Lightning" === n.modelType && null == n.enableTracking && (n.enableTracking = !0), "MultiPose.Lightning" === n.modelType && !0 === n.enableTracking) if (null == n.trackerType && (n.trackerType = hH.BoundingBox), n.trackerType === hH.Keypoint) null != n.trackerConfig ? n.trackerConfig = function (e) { var t = CH(kH, e); return t.keypointTrackerParams = HV({}, kH.keypointTrackerParams), null != e.keypointTrackerParams && (null != e.keypointTrackerParams.keypointConfidenceThreshold && (t.keypointTrackerParams.keypointConfidenceThreshold = e.keypointTrackerParams.keypointConfidenceThreshold), null != e.keypointTrackerParams.keypointFalloff && (t.keypointTrackerParams.keypointFalloff = e.keypointTrackerParams.keypointFalloff), null != e.keypointTrackerParams.minNumberOfKeypoints && (t.keypointTrackerParams.minNumberOfKeypoints = e.keypointTrackerParams.minNumberOfKeypoints)), t }(n.trackerConfig) : n.trackerConfig = kH; else { if (n.trackerType !== hH.BoundingBox) throw new Error("Tracker type not supported by MoveNet"); null != n.trackerConfig ? n.trackerConfig = (t = n.trackerConfig, CH(SH, t)) : n.trackerConfig = SH } return n }(e), r = !0, t.modelUrl ? (r = "string" == typeof t.modelUrl && t.modelUrl.indexOf("https://tfhub.dev") > -1, [4, Ud(t.modelUrl, { fromTFHub: r })]) : [3, 2]; case 1: return n = a.sent(), [3, 4]; case 2: return i = void 0, "SinglePose.Lightning" === t.modelType ? i = "https://tfhub.dev/google/tfjs-model/movenet/singlepose/lightning/4" : "SinglePose.Thunder" === t.modelType ? i = "https://tfhub.dev/google/tfjs-model/movenet/singlepose/thunder/4" : "MultiPose.Lightning" === t.modelType && (i = "https://tfhub.dev/google/tfjs-model/movenet/multipose/lightning/1"), [4, Ud(i, { fromTFHub: r })]; case 3: n = a.sent(), a.label = 4; case 4: return "webgl" === (0, P.getBackend)() && (0, P.env)().set("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD", 0), [2, new AH(n, t)] } })) })) } var EH = { architecture: "MobileNetV1", outputStride: 16, multiplier: .75, inputResolution: { height: 257, width: 257 } }, NH = ["MobileNetV1", "ResNet50"], IH = { MobileNetV1: [8, 16], ResNet50: [16] }, MH = [8, 16, 32], FH = { MobileNetV1: [.5, .75, 1], ResNet50: [1] }, DH = [1, 2, 4], $H = { maxPoses: 1, flipHorizontal: !1 }, RH = { maxPoses: 5, flipHorizontal: !1, scoreThreshold: .5, nmsRadius: 20 }, OH = [-123.15, -115.9, -103.06]; function zH(e) { return Math.floor(e / 2) } var PH = function () { function e(e, t) { this.priorityQueue = new Array(e), this.numberOfElements = -1, this.getElementValue = t } return e.prototype.enqueue = function (e) { this.priorityQueue[++this.numberOfElements] = e, this.swim(this.numberOfElements) }, e.prototype.dequeue = function () { var e = this.priorityQueue[0]; return this.exchange(0, this.numberOfElements--), this.sink(0), this.priorityQueue[this.numberOfElements + 1] = null, e }, e.prototype.empty = function () { return -1 === this.numberOfElements }, e.prototype.size = function () { return this.numberOfElements + 1 }, e.prototype.all = function () { return this.priorityQueue.slice(0, this.numberOfElements + 1) }, e.prototype.max = function () { return this.priorityQueue[0] }, e.prototype.swim = function (e) { for (; e > 0 && this.less(zH(e), e);)this.exchange(e, zH(e)), e = zH(e) }, e.prototype.sink = function (e) { for (; 2 * e <= this.numberOfElements;) { var t = 2 * e; if (t < this.numberOfElements && this.less(t, t + 1) && t++, !this.less(e, t)) break; this.exchange(e, t), e = t } }, e.prototype.getValueAt = function (e) { return this.getElementValue(this.priorityQueue[e]) }, e.prototype.less = function (e, t) { return this.getValueAt(e) < this.getValueAt(t) }, e.prototype.exchange = function (e, t) { var n = this.priorityQueue[e]; this.priorityQueue[e] = this.priorityQueue[t], this.priorityQueue[t] = n }, e }(); function BH(e, t, n, r, i, a) { for (var o = a.shape, s = o[0], u = o[1], l = !0, c = Math.max(n - i, 0), h = Math.min(n + i + 1, s), d = c; d < h; ++d) { for (var f = Math.max(r - i, 0), p = Math.min(r + i + 1, u), m = f; m < p; ++m)if (a.get(d, m, e) > t) { l = !1; break } if (!l) break } return l } function LH(e) { return qV(this, void 0, void 0, (function () { return YV(this, (function (t) { return [2, Promise.all(e.map((function (e) { return e.buffer() })))] })) })) } function jH(e, t, n, r) { return { y: r.get(e, t, n), x: r.get(e, t, n + 17) } } function UH(e, t, n) { var r = jH(e.heatmapY, e.heatmapX, e.id, n), i = r.y, a = r.x; return { x: e.heatmapX * t + a, y: e.heatmapY * t + i } } function WH(e, t, n, r) { var i = n.x, a = n.y; return e.some((function (e) { var n, o, s, u, l = e.keypoints; return n = a, o = i, (s = l[r].y - n) * s + (u = l[r].x - o) * u <= t })) } var VH = KV.reduce((function (e, t, n) { return e[t] = n, e }), {}), GH = [["nose", "left_eye"], ["left_eye", "left_ear"], ["nose", "right_eye"], ["right_eye", "right_ear"], ["nose", "left_shoulder"], ["left_shoulder", "left_elbow"], ["left_elbow", "left_wrist"], ["left_shoulder", "left_hip"], ["left_hip", "left_knee"], ["left_knee", "left_ankle"], ["nose", "right_shoulder"], ["right_shoulder", "right_elbow"], ["right_elbow", "right_wrist"], ["right_shoulder", "right_hip"], ["right_hip", "right_knee"], ["right_knee", "right_ankle"]].map((function (e) { var t = e[0], n = e[1]; return [VH[t], VH[n]] })), HH = GH.map((function (e) { return e[1] })), qH = GH.map((function (e) { return e[0] })); function YH(e, t, n) { return e < t ? t : e > n ? n : e } function XH(e, t, n, r) { return { y: YH(Math.round(e.y / t), 0, n - 1), x: YH(Math.round(e.x / t), 0, r - 1) } } function KH(e, t) { return { x: e.x + t.x, y: e.y + t.y } } function ZH(e, t, n, r, i, a, o, s) { void 0 === s && (s = 2); for (var u = r.shape, l = u[0], c = u[1], h = { y: t.y, x: t.x }, d = KH(h, function (e, t, n) { var r = n.shape[2] / 2; return { y: n.get(t.y, t.x, e), x: n.get(t.y, t.x, r + e) } }(e, XH(h, a, l, c), o)), f = 0; f < s; f++) { var p = XH(d, a, l, c), m = jH(p.y, p.x, n, i); d = KH({ x: p.x * a, y: p.y * a }, { x: m.x, y: m.y }) } var g = XH(d, a, l, c), y = r.get(g.y, g.x, n); return { y: d.y, x: d.x, name: KV[n], score: y } } function JH(e, t, n, r, i, a) { var o = t.shape[2], s = HH.length, u = new Array(o), l = e.part, c = e.score, h = UH(l, r, n); u[l.id] = { score: c, name: KV[l.id], y: h.y, x: h.x }; for (var d = s - 1; d >= 0; --d) { var f = HH[d], p = qH[d]; u[f] && !u[p] && (u[p] = ZH(d, u[f], p, t, n, r, a)) } for (d = 0; d < s; ++d)f = qH[d], p = HH[d], u[f] && !u[p] && (u[p] = ZH(d, u[f], p, t, n, r, i)); return u } function QH(e, t, n) { return n.reduce((function (n, r, i) { var a = r.y, o = r.x, s = r.score; return WH(e, t, { y: a, x: o }, i) || (n += s), n }), 0) / n.length } function eq(e, t, n, r, i, a, o, s) { return void 0 === o && (o = .5), void 0 === s && (s = 20), qV(this, void 0, void 0, (function () { var u, l, c, h, d, f, p, m, g, y, b, v; return YV(this, (function (x) { switch (x.label) { case 0: return [4, LH([e, t, n, r])]; case 1: for (u = x.sent(), l = u[0], c = u[1], h = u[2], d = u[3], f = [], p = function (e, t, n) { for (var r = n.shape, i = r[0], a = r[1], o = r[2], s = new PH(i * a * o, (function (e) { return e.score })), u = 0; u < i; ++u)for (var l = 0; l < a; ++l)for (var c = 0; c < o; ++c) { var h = n.get(u, l, c); h < e || BH(c, h, u, l, 1, n) && s.enqueue({ score: h, part: { heatmapY: u, heatmapX: l, id: c } }) } return s }(o, 0, l), m = s * s; f.length < a && !p.empty();)g = p.dequeue(), y = UH(g.part, i, c), WH(f, m, y, g.part.id) || (b = JH(g, l, c, i, h, d), v = QH(f, m, b), f.push({ keypoints: b, score: v })); return [2, f] } })) })) } function tq() { for (var e, t = [], n = 0; n < arguments.length; n++)t[n] = arguments[n]; switch (t.length) { case 0: e = "fn main() "; break; case 1: e = "fn main(".concat(t[0], " : i32)"); break; default: throw Error("Unreachable") }return e } var nq = function () { function e(e) { this.variableNames = ["A", "B"], this.size = !0, this.workgroupSize = [32, 1, 1], this.outputShape = [e[0], 1], this.dispatchLayout = wz(this.outputShape), this.dispatch = bz(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "getpointsConfidenceOp" } return e.prototype.getUserCode = function () { return "\n ".concat(tq("index"), " {\n if (index < uniforms.size) {\n let y = B[index * 2];\n let x = B[index * 2 + 1];\n let outIndex = y * uniforms.aShape.x * uniforms.aShape.z + x * uniforms.aShape.z + index;\n result[index] = A[outIndex];\n }\n }\n ") }, e }(); var rq = function () { function e(e) { if (this.variableNames = ["A", "B"], this.size = !0, this.supportedLastDimension = 2, 2 !== e.length || e[1] !== this.supportedLastDimension) throw new Error("GetOffsetVectorsProgram only supports shape of [x, ".concat(this.supportedLastDimension, "], but current shape is ").concat(e)); this.workgroupSize = [32, 1, 1], this.outputShape = e; var t = [e[0], 1]; this.dispatchLayout = wz(t), this.dispatch = bz(this.dispatchLayout, t, this.workgroupSize), this.shaderKey = "GetOffsetVectors" } return e.prototype.getUserCode = function () { return "\n fn getOffsetPoint(y: i32, x: i32, index: i32) -> vec2 {\n let outIndexY = y * uniforms.bShape.x * uniforms.bShape.y + x * uniforms.bShape.y + index;\n let outIndexX = outIndexY + uniforms.bShape.z;\n let outY = i32(B[outIndexY]);\n let outX = i32(B[outIndexX]);\n return vec2(outY, outX);\n }\n\n ".concat(tq("index"), " {\n if (index < uniforms.size) {\n let indexY = index * ").concat(this.supportedLastDimension, ";\n let indexX = indexY + 1;\n let heatmapY = A[indexY];\n let heatmapX = A[indexX];\n let out = getOffsetPoint(i32(heatmapY), i32(heatmapX), index);\n result[indexY] = f32(out[0]);\n result[indexX] = f32(out[1]);\n }\n }\n ") }, e }(); function iq(e) { var t = e.shape, n = t[0], r = t[1], i = t[2]; return (0, P.tidy)((function () { var t, a, o = (0, P.reshape)(e, [n * r, i]), s = (0, P.argMax)(o, 0), u = (0, P.expandDims)((0, P.div)(s, (0, P.scalar)(r, "int32")), 1), l = (0, P.expandDims)((t = s, a = r, (0, P.tidy)((function () { var e = (0, P.div)(t, (0, P.scalar)(a, "int32")); return (0, P.sub)(t, (0, P.mul)(e, (0, P.scalar)(a, "int32"))) }))), 1); return (0, P.concat)([u, l], 1) })) } function aq(e, t, n) { return (0, P.tidy)((function () { var r = function (e, t) { for (var n = [], r = 0; r < KV.length; r++) { var i = oq(e.get(r, 0).valueOf(), e.get(r, 1).valueOf(), r, t), a = i.x, o = i.y; n.push(o), n.push(a) } return (0, P.tensor2d)(n, [KV.length, 2]) }(e, n); return (0, P.add)((0, P.cast)((0, P.mul)(e.toTensor(), (0, P.scalar)(t, "int32")), "float32"), r) })) } function oq(e, t, n, r) { return { y: r.get(e, t, n), x: r.get(e, t, n + KV.length) } } function sq(e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d; return YV(this, (function (f) { switch (f.label) { case 0: return r = 0, i = iq(e), [4, Promise.all([e.buffer(), t.buffer(), i.buffer()])]; case 1: return a = f.sent(), o = a[0], s = a[1], u = a[2], [4, (l = aq(u, n, s)).buffer()]; case 2: return c = f.sent(), h = Array.from(function (e, t) { for (var n = t.shape[0], r = new Float32Array(n), i = 0; i < n; i++) { var a = t.get(i, 0), o = t.get(i, 1); r[i] = e.get(a, o, i) } return r }(o, u)), d = h.map((function (e, t) { return r += e, { y: c.get(t, 0), x: c.get(t, 1), score: e, name: KV[t] } })), i.dispose(), l.dispose(), [2, { keypoints: d, score: r / d.length }] } })) })) } function uq(e, t, n) { return qV(this, void 0, void 0, (function () { var r, i, a; return YV(this, (function (o) { return r = iq(e), i = function (e, t, n) { return (0, P.tidy)((function () { var r = function (e, t) { if ((0, P.backend)() instanceof Ez) return function (e, t) { var n = (0, P.backend)(), r = new rq(e.shape), i = n.runWebGPUProgram(r, [e, t], "float32"); return (0, P.engine)().makeTensorFromTensorInfo(i) }(e, t); throw new Error("getOffsetVectorsGPU is not supported in this backend!") }(e, n); return (0, P.add)((0, P.cast)((0, P.mul)(e, (0, P.scalar)(t, "int32")), "float32"), r) })) }(r, n, t), a = function (e, t) { if ((0, P.backend)() instanceof Ez) return function (e, t) { var n = (0, P.backend)(), r = new nq(t.shape), i = n.runWebGPUProgram(r, [e, t], "float32"); return (0, P.engine)().makeTensorFromTensorInfo(i) }(e, t); throw new Error("getPointsConfidenceWebGPU is not supported in this backend!") }(e, r), [2, [i, a]] })) })) } function lq(e, t) { return (e - 1) % t == 0 } var cq = "https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/", hq = "https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/"; function dq(e, t) { return function (e, t) { return (e - 1) % t == 0 }(e, t) ? e : Math.floor(e / t) * t + 1 } var fq = function () { function e(e, t) { this.posenetModel = e; var n = this.posenetModel.inputs[0].shape; P.util.assert(-1 === n[1] && -1 === n[2], (function () { return "Input shape [".concat(n[1], ", ").concat(n[2], "] ") + "must both be equal to or -1" })); var r, i, a = (r = t.inputResolution, i = t.outputStride, { height: dq(r.height, i), width: dq(r.width, i) }); !function (e) { P.util.assert(MH.indexOf(e) >= 0, (function () { return "outputStride of ".concat(e, " is invalid. ") + "It must be either 8 or 16." })) }(t.outputStride), function (e, t) { P.util.assert(lq(e.height, t), (function () { return "height of ".concat(e.height, " is invalid for output stride ") + "".concat(t, ".") })), P.util.assert(lq(e.width, t), (function () { return "width of ".concat(e.width, " is invalid for output stride ") + "".concat(t, ".") })) }(a, t.outputStride), this.inputResolution = a, this.outputStride = t.outputStride, this.architecture = t.architecture } return e.prototype.estimatePoses = function (e, t) { return void 0 === t && (t = $H), qV(this, void 0, void 0, (function () { return YV(this, (function (n) { return [2, this.estimatePosesGPU(e, t, !1)] })) })) }, e.prototype.estimatePosesGPU = function (e, t, n) { return void 0 === t && (t = $H), void 0 === n && (n = !1), qV(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p, m, g, y, b, v, x; return YV(this, (function (w) { switch (w.label) { case 0: return r = function (e) { var t = e; if (null == t.maxPoses && (t.maxPoses = 1), t.maxPoses <= 0) throw new Error("Invalid maxPoses ".concat(t.maxPoses, ". Should be > 0.")); if (t.maxPoses > 1) { if ((t = HV(HV({}, RH), t)).scoreThreshold < 0 || t.scoreThreshold > 1) throw new Error("Invalid scoreThreshold ".concat(t.scoreThreshold, ". ") + "Should be in range [0.0, 1.0]"); if (t.nmsRadius <= 0) throw new Error("Invalid nmsRadius ".concat(t.nmsRadius, ".")) } return t }(t), null == e ? [2, n ? [[], []] : []] : (this.maxPoses = r.maxPoses, i = SG(e, { outputTensorSize: this.inputResolution, keepAspectRatio: !0, borderMode: "replicate" }), a = i.imageTensor, o = i.padding, s = "ResNet50" === this.architecture ? (0, P.add)(a, OH) : kG(a, [-1, 1]), u = this.posenetModel.predict(s), "ResNet50" === this.architecture ? (l = (0, P.squeeze)(u[2], [0]), c = (0, P.squeeze)(u[3], [0]), h = (0, P.squeeze)(u[0], [0]), d = (0, P.squeeze)(u[1], [0])) : (l = (0, P.squeeze)(u[0], [0]), c = (0, P.squeeze)(u[1], [0]), h = (0, P.squeeze)(u[2], [0]), d = (0, P.squeeze)(u[3], [0])), f = (0, P.sigmoid)(c), 1 !== this.maxPoses ? [3, 5] : n ? [4, uq(f, l, this.outputStride)] : [3, 2]); case 1: return m = w.sent(), y = m[0], g = m[1], p = [y, g], [3, 4]; case 2: return [4, sq(f, l, this.outputStride)]; case 3: y = w.sent(), p = [y], w.label = 4; case 4: return [3, 7]; case 5: if (n) throw new Error("GPU renderer only supports single pose!"); return [4, eq(f, l, h, d, this.outputStride, this.maxPoses, r.scoreThreshold, r.nmsRadius)]; case 6: p = w.sent(), w.label = 7; case 7: if (n) { if (!0 === r.flipHorizontal) throw new Error("flipHorizontal is not supported!"); b = this.getCanvasInfo(dG(e), this.inputResolution, o) } else x = dG(e), v = function (e, t, n, r) { var i = t.height, a = t.width, o = i / (n.height * (1 - r.top - r.bottom)), s = a / (n.width * (1 - r.left - r.right)), u = -r.top * n.height, l = -r.left * n.width; if (1 === s && 1 === o && 0 === u && 0 === l) return e; for (var c = 0, h = e; c < h.length; c++)for (var d = 0, f = h[c].keypoints; d < f.length; d++) { var p = f[d]; p.x = (p.x + l) * s, p.y = (p.y + u) * o } return e }(p, x, this.inputResolution, o), r.flipHorizontal && (v = function (e, t) { for (var n = 0, r = e; n < r.length; n++)for (var i = 0, a = r[n].keypoints; i < a.length; i++) { var o = a[i]; o.x = t.width - 1 - o.x } return e }(v, x)); return a.dispose(), s.dispose(), (0, P.dispose)(u), l.dispose(), c.dispose(), h.dispose(), d.dispose(), f.dispose(), [2, n ? [p, b] : v] } })) })) }, e.prototype.getCanvasInfo = function (e, t, n) { var r = e.height, i = e.width, a = r / (t.height * (1 - n.top - n.bottom)), o = i / (t.width * (1 - n.left - n.right)), s = -n.top * t.height; return [-n.left * t.width, s, o, a, e.width, e.height] }, e.prototype.dispose = function () { this.posenetModel.dispose() }, e.prototype.reset = function () { }, e }(); function pq(e) { return void 0 === e && (e = EH), qV(this, void 0, void 0, (function () { var t, n, r, i, a; return YV(this, (function (o) { switch (o.label) { case 0: return "ResNet50" !== (t = function (e) { var t = e || EH; if (null == t.architecture && (t.architecture = "MobileNetV1"), NH.indexOf(t.architecture) < 0) throw new Error("Invalid architecture ".concat(t.architecture, ". ") + "Should be one of ".concat(NH)); if (null == t.inputResolution && (t.inputResolution = { height: 257, width: 257 }), null == t.outputStride && (t.outputStride = 16), IH[t.architecture].indexOf(t.outputStride) < 0) throw new Error("Invalid outputStride ".concat(t.outputStride, ". ") + "Should be one of ".concat(IH[t.architecture], " ") + "for architecture ".concat(t.architecture, ".")); if (null == t.multiplier && (t.multiplier = 1), FH[t.architecture].indexOf(t.multiplier) < 0) throw new Error("Invalid multiplier ".concat(t.multiplier, ". ") + "Should be one of ".concat(FH[t.architecture], " ") + "for architecture ".concat(t.architecture, ".")); if (null == t.quantBytes && (t.quantBytes = 4), DH.indexOf(t.quantBytes) < 0) throw new Error("Invalid quantBytes ".concat(t.quantBytes, ". ") + "Should be one of ".concat(DH, " ") + "for architecture ".concat(t.architecture, ".")); if ("MobileNetV1" === t.architecture && 32 === t.outputStride && 1 !== t.multiplier) throw new Error("When using an output stride of 32, you must select 1 as the multiplier."); return t }(e)).architecture ? [3, 2] : (s = t.outputStride, u = t.quantBytes, l = "model-stride".concat(s, ".json"), n = 4 === u ? hq + "float/" + l : hq + "quant".concat(u, "/") + l, [4, Ud(t.modelUrl || n)]); case 1: return r = o.sent(), [2, new fq(r, t)]; case 2: return i = function (e, t, n) { var r = { 1: "100", .75: "075", .5: "050" }, i = "model-stride".concat(e, ".json"); return 4 === n ? cq + "float/".concat(r[t], "/") + i : cq + "quant".concat(n, "/").concat(r[t], "/") + i }(t.outputStride, t.multiplier, t.quantBytes), [4, Ud(t.modelUrl || i)]; case 3: return a = o.sent(), [2, new fq(a, t)] }var s, u, l })) })) } var mq = { SINGLEPOSE_LIGHTNING: "SinglePose.Lightning", SINGLEPOSE_THUNDER: "SinglePose.Thunder", MULTIPOSE_LIGHTNING: "MultiPose.Lightning" }; + /** + * @license + * Copyright (c) 2018-2024 ml5 + * This software is released under the ml5.js License. + * https://github.com/ml5js/ml5-next-gen/blob/main/LICENSE.md + */ + const gq = { modelType: { type: "enum", enums: ["SINGLEPOSE_LIGHTNING", "SINGLEPOSE_THUNDER", "MULTIPOSE_LIGHTNING"], default: "MULTIPOSE_LIGHTNING" }, enableSmoothing: { type: "boolean", default: !0 }, minPoseScore: { type: "number", min: 0, max: 1, default: .25 }, multiPoseMaxDimension: { type: "number", default: 256, min: 32, integer: !0, multipleOf: 32 }, enableTracking: { type: "boolean", default: !0 }, trackerType: { type: "enum", enums: ["boundingBox", "keypoint"], default: "boundingBox" }, trackerConfig: { type: "object", default: void 0 }, modelUrl: { type: "string", default: void 0 } }, yq = { runtime: { type: "enum", enums: ["mediapipe", "tfjs"], default: "tfjs" }, enableSmoothing: { type: "boolean", default: !0 }, enableSegmentation: { type: "boolean", default: !1, ignore: e => "mediapipe" !== e.runtime }, smoothSegmentation: { type: "boolean", default: !0, ignore: e => "mediapipe" !== e.runtime }, modelType: { type: "enum", enums: ["lite", "full", "heavy"], default: "full" }, solutionPath: { type: "string", default: "https://cdn.jsdelivr.net/npm/@mediapipe/pose", ignore: e => "mediapipe" !== e.runtime }, detectorModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime }, landmarkModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime } }, bq = { flipHorizontal: { type: "boolean", alias: "flipped", default: !1 } }; class vq { constructor(e, t, n) { this.modelName = uR(e, ["BlazePose", "MoveNet"], "MoveNet", "bodyPose"), this.model = null, this.userOptions = t, this.runtimeConfig = {}, this.detectMedia = null, this.detectCallback = null, this.detecting = !1, this.signalStop = !1, this.prevCall = "", this.ready = hM(this.loadModel(), n) } async loadModel() { let e, t; if ("BlazePose" === this.modelName) e = dH.BlazePose, t = lR(this.userOptions, yq, "bodyPose"); else switch (e = dH.MoveNet, t = lR(this.userOptions, gq, "bodyPose"), t.modelType) { case "SINGLEPOSE_LIGHTNING": t.modelType = mq.SINGLEPOSE_LIGHTNING; break; case "SINGLEPOSE_THUNDER": t.modelType = mq.SINGLEPOSE_THUNDER; break; default: t.modelType = mq.MULTIPOSE_LIGHTNING }return this.runtimeConfig = lR(this.userOptions, bq, "bodyPose"), await P.ready(), this.model = await function (e, t) { return qV(this, void 0, void 0, (function () { var n, r; return YV(this, (function (i) { switch (e) { case dH.PoseNet: return [2, pq(t)]; case dH.BlazePose: if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, cH(t)]; if ("mediapipe" === n.runtime) return [2, hG(t)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' " + "or 'mediapipe', but got ".concat(r)); case dH.MoveNet: return [2, TH(t)]; default: throw new Error("".concat(e, " is not a supported model name.")) } })) })) }(e, t), this } async detect(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detect()."); const { image: n, callback: r } = t; await AM(n, !1); let i = await this.model.estimatePoses(n); return this.renameScoreToConfidence(i), "MoveNet" === this.modelName && dM(n) && this.resizeKeypoints(i, n.videoWidth, n.videoHeight, n.width, n.height), this.runtimeConfig.flipHorizontal && (this.mirrorKeypoints(i, n.width), this.mirrorBoundingBoxes(i)), this.addKeypoints(i), this.resizeBoundingBoxes(i, n.width, n.height), "function" == typeof r && r(i), i } detectStart(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detectStart()."), t.require("callback", "A callback function argument is required for detectStart()."), this.detectMedia = t.image, this.detectCallback = t.callback, this.signalStop = !1, this.detecting || (this.detecting = !0, this.detectLoop()), "start" === this.prevCall && console.warn("detectStart() was called more than once without calling detectStop(). The lastest detectStart() call will be used and the previous calls will be ignored."), this.prevCall = "start" } async detectLoop() { for (await AM(this.detectMedia, !1); !this.signalStop;) { let e = await this.model.estimatePoses(this.detectMedia); this.renameScoreToConfidence(e), "MoveNet" === this.modelName && dM(this.detectMedia) && this.resizeKeypoints(e, this.detectMedia.videoWidth, this.detectMedia.videoHeight, this.detectMedia.width, this.detectMedia.height), this.runtimeConfig.flipHorizontal && (this.mirrorKeypoints(e, this.detectMedia.width), this.mirrorBoundingBoxes(e)), this.addKeypoints(e), this.resizeBoundingBoxes(e, this.detectMedia.width, this.detectMedia.height), this.detectCallback(e), await P.nextFrame() } this.detecting = !1, this.signalStop = !1 } detectStop() { this.detecting && (this.signalStop = !0), this.prevCall = "stop" } renameScoreToConfidence(e) { e.forEach((e => { e.keypoints.forEach((e => { cR(e, "score", "confidence") })), e.keypoints3D && e.keypoints3D.forEach((e => { cR(e, "score", "confidence") })), e.score && cR(e, "score", "confidence") })) } mirrorKeypoints(e, t) { e.forEach((e => { e.keypoints.forEach((e => { e.x = t - e.x })) })) } mirrorBoundingBoxes(e) { e.forEach((e => { if (!e.box) return; const t = e.box.xMin; e.box.xMin = 1 - e.box.xMax, e.box.xMax = 1 - t })) } resizeKeypoints(e, t, n, r, i) { e.forEach((e => { e.keypoints.forEach((e => { e.x = e.x / t * r, e.y = e.y / n * i })) })) } addKeypoints(e) { e.forEach((e => { e.keypoints.forEach((t => { t.z && delete t.z, e[t.name] = { x: t.x, y: t.y, confidence: t.confidence } })), e.keypoints3D && e.keypoints3D.forEach((t => { e[t.name].keypoint3D = { x: t.x, y: t.y, z: t.z, confidence: t.confidence } })) })) } resizeBoundingBoxes(e, t, n) { e[0] && e[0].box && e.forEach((e => { e.box.height = e.box.height * n, e.box.width = e.box.width * t, e.box.xMax = e.box.xMax * t, e.box.xMin = e.box.xMin * t, e.box.yMax = e.box.yMax * n, e.box.yMin = e.box.yMin * n })) } getConnections() { return "BlazePose" === this.modelName ? yH.getAdjacentPairs(dH.BlazePose) : yH.getAdjacentPairs(dH.MoveNet) } getSkeleton() { return this.getConnections() } } const xq = (...e) => { const { string: t, options: n = {}, callback: r } = xM(...e); return new vq(t, n, r) }; + /** + * @license + * Copyright 2023 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + function wq(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function kq(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(a) { return function (s) { return function (a) { if (n) throw new TypeError("Generator is already executing."); for (; o;)try { if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i; switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) { case 0: case 1: i = a; break; case 4: return o.label++, { value: a[1], done: !1 }; case 5: o.label++, r = a[1], a = [0]; continue; case 7: a = o.ops.pop(), o.trys.pop(); continue; default: if (!(i = (i = o.trys).length > 0 && i[i.length - 1]) && (6 === a[0] || 2 === a[0])) { o = 0; continue } if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) { o.label = a[1]; break } if (6 === a[0] && o.label < i[1]) { o.label = i[1], i = a; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(a); break } i[2] && o.ops.pop(), o.trys.pop(); continue }a = t.call(e, o) } catch (e) { a = [6, e], r = 0 } finally { n = i = 0 } if (5 & a[0]) throw a[1]; return { value: a[0] ? a[1] : void 0, done: !0 } }([a, s]) } } } var Sq = { 0: "tench, Tinca tinca", 1: "goldfish, Carassius auratus", 2: "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias", 3: "tiger shark, Galeocerdo cuvieri", 4: "hammerhead, hammerhead shark", 5: "electric ray, crampfish, numbfish, torpedo", 6: "stingray", 7: "cock", 8: "hen", 9: "ostrich, Struthio camelus", 10: "brambling, Fringilla montifringilla", 11: "goldfinch, Carduelis carduelis", 12: "house finch, linnet, Carpodacus mexicanus", 13: "junco, snowbird", 14: "indigo bunting, indigo finch, indigo bird, Passerina cyanea", 15: "robin, American robin, Turdus migratorius", 16: "bulbul", 17: "jay", 18: "magpie", 19: "chickadee", 20: "water ouzel, dipper", 21: "kite", 22: "bald eagle, American eagle, Haliaeetus leucocephalus", 23: "vulture", 24: "great grey owl, great gray owl, Strix nebulosa", 25: "European fire salamander, Salamandra salamandra", 26: "common newt, Triturus vulgaris", 27: "eft", 28: "spotted salamander, Ambystoma maculatum", 29: "axolotl, mud puppy, Ambystoma mexicanum", 30: "bullfrog, Rana catesbeiana", 31: "tree frog, tree-frog", 32: "tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui", 33: "loggerhead, loggerhead turtle, Caretta caretta", 34: "leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea", 35: "mud turtle", 36: "terrapin", 37: "box turtle, box tortoise", 38: "banded gecko", 39: "common iguana, iguana, Iguana iguana", 40: "American chameleon, anole, Anolis carolinensis", 41: "whiptail, whiptail lizard", 42: "agama", 43: "frilled lizard, Chlamydosaurus kingi", 44: "alligator lizard", 45: "Gila monster, Heloderma suspectum", 46: "green lizard, Lacerta viridis", 47: "African chameleon, Chamaeleo chamaeleon", 48: "Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis", 49: "African crocodile, Nile crocodile, Crocodylus niloticus", 50: "American alligator, Alligator mississipiensis", 51: "triceratops", 52: "thunder snake, worm snake, Carphophis amoenus", 53: "ringneck snake, ring-necked snake, ring snake", 54: "hognose snake, puff adder, sand viper", 55: "green snake, grass snake", 56: "king snake, kingsnake", 57: "garter snake, grass snake", 58: "water snake", 59: "vine snake", 60: "night snake, Hypsiglena torquata", 61: "boa constrictor, Constrictor constrictor", 62: "rock python, rock snake, Python sebae", 63: "Indian cobra, Naja naja", 64: "green mamba", 65: "sea snake", 66: "horned viper, cerastes, sand viper, horned asp, Cerastes cornutus", 67: "diamondback, diamondback rattlesnake, Crotalus adamanteus", 68: "sidewinder, horned rattlesnake, Crotalus cerastes", 69: "trilobite", 70: "harvestman, daddy longlegs, Phalangium opilio", 71: "scorpion", 72: "black and gold garden spider, Argiope aurantia", 73: "barn spider, Araneus cavaticus", 74: "garden spider, Aranea diademata", 75: "black widow, Latrodectus mactans", 76: "tarantula", 77: "wolf spider, hunting spider", 78: "tick", 79: "centipede", 80: "black grouse", 81: "ptarmigan", 82: "ruffed grouse, partridge, Bonasa umbellus", 83: "prairie chicken, prairie grouse, prairie fowl", 84: "peacock", 85: "quail", 86: "partridge", 87: "African grey, African gray, Psittacus erithacus", 88: "macaw", 89: "sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita", 90: "lorikeet", 91: "coucal", 92: "bee eater", 93: "hornbill", 94: "hummingbird", 95: "jacamar", 96: "toucan", 97: "drake", 98: "red-breasted merganser, Mergus serrator", 99: "goose", 100: "black swan, Cygnus atratus", 101: "tusker", 102: "echidna, spiny anteater, anteater", 103: "platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus", 104: "wallaby, brush kangaroo", 105: "koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus", 106: "wombat", 107: "jelly fish", 108: "sea anemone, anemone", 109: "brain coral", 110: "flatworm, platyhelminth", 111: "nematode, nematode worm, roundworm", 112: "conch", 113: "snail", 114: "slug", 115: "sea slug, nudibranch", 116: "chiton, coat-of-mail shell, sea cradle, polyplacophore", 117: "chambered nautilus, pearly nautilus, nautilus", 118: "Dungeness crab, Cancer magister", 119: "rock crab, Cancer irroratus", 120: "fiddler crab", 121: "king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica", 122: "American lobster, Northern lobster, Maine lobster, Homarus americanus", 123: "spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish", 124: "crayfish, crawfish, crawdad, crawdaddy", 125: "hermit crab", 126: "isopod", 127: "white stork, Ciconia ciconia", 128: "black stork, Ciconia nigra", 129: "spoonbill", 130: "flamingo", 131: "little blue heron, Egretta caerulea", 132: "American egret, great white heron, Egretta albus", 133: "bittern", 134: "crane", 135: "limpkin, Aramus pictus", 136: "European gallinule, Porphyrio porphyrio", 137: "American coot, marsh hen, mud hen, water hen, Fulica americana", 138: "bustard", 139: "ruddy turnstone, Arenaria interpres", 140: "red-backed sandpiper, dunlin, Erolia alpina", 141: "redshank, Tringa totanus", 142: "dowitcher", 143: "oystercatcher, oyster catcher", 144: "pelican", 145: "king penguin, Aptenodytes patagonica", 146: "albatross, mollymawk", 147: "grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus", 148: "killer whale, killer, orca, grampus, sea wolf, Orcinus orca", 149: "dugong, Dugong dugon", 150: "sea lion", 151: "Chihuahua", 152: "Japanese spaniel", 153: "Maltese dog, Maltese terrier, Maltese", 154: "Pekinese, Pekingese, Peke", 155: "Shih-Tzu", 156: "Blenheim spaniel", 157: "papillon", 158: "toy terrier", 159: "Rhodesian ridgeback", 160: "Afghan hound, Afghan", 161: "basset, basset hound", 162: "beagle", 163: "bloodhound, sleuthhound", 164: "bluetick", 165: "black-and-tan coonhound", 166: "Walker hound, Walker foxhound", 167: "English foxhound", 168: "redbone", 169: "borzoi, Russian wolfhound", 170: "Irish wolfhound", 171: "Italian greyhound", 172: "whippet", 173: "Ibizan hound, Ibizan Podenco", 174: "Norwegian elkhound, elkhound", 175: "otterhound, otter hound", 176: "Saluki, gazelle hound", 177: "Scottish deerhound, deerhound", 178: "Weimaraner", 179: "Staffordshire bullterrier, Staffordshire bull terrier", 180: "American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier", 181: "Bedlington terrier", 182: "Border terrier", 183: "Kerry blue terrier", 184: "Irish terrier", 185: "Norfolk terrier", 186: "Norwich terrier", 187: "Yorkshire terrier", 188: "wire-haired fox terrier", 189: "Lakeland terrier", 190: "Sealyham terrier, Sealyham", 191: "Airedale, Airedale terrier", 192: "cairn, cairn terrier", 193: "Australian terrier", 194: "Dandie Dinmont, Dandie Dinmont terrier", 195: "Boston bull, Boston terrier", 196: "miniature schnauzer", 197: "giant schnauzer", 198: "standard schnauzer", 199: "Scotch terrier, Scottish terrier, Scottie", 200: "Tibetan terrier, chrysanthemum dog", 201: "silky terrier, Sydney silky", 202: "soft-coated wheaten terrier", 203: "West Highland white terrier", 204: "Lhasa, Lhasa apso", 205: "flat-coated retriever", 206: "curly-coated retriever", 207: "golden retriever", 208: "Labrador retriever", 209: "Chesapeake Bay retriever", 210: "German short-haired pointer", 211: "vizsla, Hungarian pointer", 212: "English setter", 213: "Irish setter, red setter", 214: "Gordon setter", 215: "Brittany spaniel", 216: "clumber, clumber spaniel", 217: "English springer, English springer spaniel", 218: "Welsh springer spaniel", 219: "cocker spaniel, English cocker spaniel, cocker", 220: "Sussex spaniel", 221: "Irish water spaniel", 222: "kuvasz", 223: "schipperke", 224: "groenendael", 225: "malinois", 226: "briard", 227: "kelpie", 228: "komondor", 229: "Old English sheepdog, bobtail", 230: "Shetland sheepdog, Shetland sheep dog, Shetland", 231: "collie", 232: "Border collie", 233: "Bouvier des Flandres, Bouviers des Flandres", 234: "Rottweiler", 235: "German shepherd, German shepherd dog, German police dog, alsatian", 236: "Doberman, Doberman pinscher", 237: "miniature pinscher", 238: "Greater Swiss Mountain dog", 239: "Bernese mountain dog", 240: "Appenzeller", 241: "EntleBucher", 242: "boxer", 243: "bull mastiff", 244: "Tibetan mastiff", 245: "French bulldog", 246: "Great Dane", 247: "Saint Bernard, St Bernard", 248: "Eskimo dog, husky", 249: "malamute, malemute, Alaskan malamute", 250: "Siberian husky", 251: "dalmatian, coach dog, carriage dog", 252: "affenpinscher, monkey pinscher, monkey dog", 253: "basenji", 254: "pug, pug-dog", 255: "Leonberg", 256: "Newfoundland, Newfoundland dog", 257: "Great Pyrenees", 258: "Samoyed, Samoyede", 259: "Pomeranian", 260: "chow, chow chow", 261: "keeshond", 262: "Brabancon griffon", 263: "Pembroke, Pembroke Welsh corgi", 264: "Cardigan, Cardigan Welsh corgi", 265: "toy poodle", 266: "miniature poodle", 267: "standard poodle", 268: "Mexican hairless", 269: "timber wolf, grey wolf, gray wolf, Canis lupus", 270: "white wolf, Arctic wolf, Canis lupus tundrarum", 271: "red wolf, maned wolf, Canis rufus, Canis niger", 272: "coyote, prairie wolf, brush wolf, Canis latrans", 273: "dingo, warrigal, warragal, Canis dingo", 274: "dhole, Cuon alpinus", 275: "African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus", 276: "hyena, hyaena", 277: "red fox, Vulpes vulpes", 278: "kit fox, Vulpes macrotis", 279: "Arctic fox, white fox, Alopex lagopus", 280: "grey fox, gray fox, Urocyon cinereoargenteus", 281: "tabby, tabby cat", 282: "tiger cat", 283: "Persian cat", 284: "Siamese cat, Siamese", 285: "Egyptian cat", 286: "cougar, puma, catamount, mountain lion, painter, panther, Felis concolor", 287: "lynx, catamount", 288: "leopard, Panthera pardus", 289: "snow leopard, ounce, Panthera uncia", 290: "jaguar, panther, Panthera onca, Felis onca", 291: "lion, king of beasts, Panthera leo", 292: "tiger, Panthera tigris", 293: "cheetah, chetah, Acinonyx jubatus", 294: "brown bear, bruin, Ursus arctos", 295: "American black bear, black bear, Ursus americanus, Euarctos americanus", 296: "ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus", 297: "sloth bear, Melursus ursinus, Ursus ursinus", 298: "mongoose", 299: "meerkat, mierkat", 300: "tiger beetle", 301: "ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle", 302: "ground beetle, carabid beetle", 303: "long-horned beetle, longicorn, longicorn beetle", 304: "leaf beetle, chrysomelid", 305: "dung beetle", 306: "rhinoceros beetle", 307: "weevil", 308: "fly", 309: "bee", 310: "ant, emmet, pismire", 311: "grasshopper, hopper", 312: "cricket", 313: "walking stick, walkingstick, stick insect", 314: "cockroach, roach", 315: "mantis, mantid", 316: "cicada, cicala", 317: "leafhopper", 318: "lacewing, lacewing fly", 319: "dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk", 320: "damselfly", 321: "admiral", 322: "ringlet, ringlet butterfly", 323: "monarch, monarch butterfly, milkweed butterfly, Danaus plexippus", 324: "cabbage butterfly", 325: "sulphur butterfly, sulfur butterfly", 326: "lycaenid, lycaenid butterfly", 327: "starfish, sea star", 328: "sea urchin", 329: "sea cucumber, holothurian", 330: "wood rabbit, cottontail, cottontail rabbit", 331: "hare", 332: "Angora, Angora rabbit", 333: "hamster", 334: "porcupine, hedgehog", 335: "fox squirrel, eastern fox squirrel, Sciurus niger", 336: "marmot", 337: "beaver", 338: "guinea pig, Cavia cobaya", 339: "sorrel", 340: "zebra", 341: "hog, pig, grunter, squealer, Sus scrofa", 342: "wild boar, boar, Sus scrofa", 343: "warthog", 344: "hippopotamus, hippo, river horse, Hippopotamus amphibius", 345: "ox", 346: "water buffalo, water ox, Asiatic buffalo, Bubalus bubalis", 347: "bison", 348: "ram, tup", 349: "bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis", 350: "ibex, Capra ibex", 351: "hartebeest", 352: "impala, Aepyceros melampus", 353: "gazelle", 354: "Arabian camel, dromedary, Camelus dromedarius", 355: "llama", 356: "weasel", 357: "mink", 358: "polecat, fitch, foulmart, foumart, Mustela putorius", 359: "black-footed ferret, ferret, Mustela nigripes", 360: "otter", 361: "skunk, polecat, wood pussy", 362: "badger", 363: "armadillo", 364: "three-toed sloth, ai, Bradypus tridactylus", 365: "orangutan, orang, orangutang, Pongo pygmaeus", 366: "gorilla, Gorilla gorilla", 367: "chimpanzee, chimp, Pan troglodytes", 368: "gibbon, Hylobates lar", 369: "siamang, Hylobates syndactylus, Symphalangus syndactylus", 370: "guenon, guenon monkey", 371: "patas, hussar monkey, Erythrocebus patas", 372: "baboon", 373: "macaque", 374: "langur", 375: "colobus, colobus monkey", 376: "proboscis monkey, Nasalis larvatus", 377: "marmoset", 378: "capuchin, ringtail, Cebus capucinus", 379: "howler monkey, howler", 380: "titi, titi monkey", 381: "spider monkey, Ateles geoffroyi", 382: "squirrel monkey, Saimiri sciureus", 383: "Madagascar cat, ring-tailed lemur, Lemur catta", 384: "indri, indris, Indri indri, Indri brevicaudatus", 385: "Indian elephant, Elephas maximus", 386: "African elephant, Loxodonta africana", 387: "lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens", 388: "giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca", 389: "barracouta, snoek", 390: "eel", 391: "coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch", 392: "rock beauty, Holocanthus tricolor", 393: "anemone fish", 394: "sturgeon", 395: "gar, garfish, garpike, billfish, Lepisosteus osseus", 396: "lionfish", 397: "puffer, pufferfish, blowfish, globefish", 398: "abacus", 399: "abaya", 400: "academic gown, academic robe, judge's robe", 401: "accordion, piano accordion, squeeze box", 402: "acoustic guitar", 403: "aircraft carrier, carrier, flattop, attack aircraft carrier", 404: "airliner", 405: "airship, dirigible", 406: "altar", 407: "ambulance", 408: "amphibian, amphibious vehicle", 409: "analog clock", 410: "apiary, bee house", 411: "apron", 412: "ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin", 413: "assault rifle, assault gun", 414: "backpack, back pack, knapsack, packsack, rucksack, haversack", 415: "bakery, bakeshop, bakehouse", 416: "balance beam, beam", 417: "balloon", 418: "ballpoint, ballpoint pen, ballpen, Biro", 419: "Band Aid", 420: "banjo", 421: "bannister, banister, balustrade, balusters, handrail", 422: "barbell", 423: "barber chair", 424: "barbershop", 425: "barn", 426: "barometer", 427: "barrel, cask", 428: "barrow, garden cart, lawn cart, wheelbarrow", 429: "baseball", 430: "basketball", 431: "bassinet", 432: "bassoon", 433: "bathing cap, swimming cap", 434: "bath towel", 435: "bathtub, bathing tub, bath, tub", 436: "beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon", 437: "beacon, lighthouse, beacon light, pharos", 438: "beaker", 439: "bearskin, busby, shako", 440: "beer bottle", 441: "beer glass", 442: "bell cote, bell cot", 443: "bib", 444: "bicycle-built-for-two, tandem bicycle, tandem", 445: "bikini, two-piece", 446: "binder, ring-binder", 447: "binoculars, field glasses, opera glasses", 448: "birdhouse", 449: "boathouse", 450: "bobsled, bobsleigh, bob", 451: "bolo tie, bolo, bola tie, bola", 452: "bonnet, poke bonnet", 453: "bookcase", 454: "bookshop, bookstore, bookstall", 455: "bottlecap", 456: "bow", 457: "bow tie, bow-tie, bowtie", 458: "brass, memorial tablet, plaque", 459: "brassiere, bra, bandeau", 460: "breakwater, groin, groyne, mole, bulwark, seawall, jetty", 461: "breastplate, aegis, egis", 462: "broom", 463: "bucket, pail", 464: "buckle", 465: "bulletproof vest", 466: "bullet train, bullet", 467: "butcher shop, meat market", 468: "cab, hack, taxi, taxicab", 469: "caldron, cauldron", 470: "candle, taper, wax light", 471: "cannon", 472: "canoe", 473: "can opener, tin opener", 474: "cardigan", 475: "car mirror", 476: "carousel, carrousel, merry-go-round, roundabout, whirligig", 477: "carpenter's kit, tool kit", 478: "carton", 479: "car wheel", 480: "cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM", 481: "cassette", 482: "cassette player", 483: "castle", 484: "catamaran", 485: "CD player", 486: "cello, violoncello", 487: "cellular telephone, cellular phone, cellphone, cell, mobile phone", 488: "chain", 489: "chainlink fence", 490: "chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour", 491: "chain saw, chainsaw", 492: "chest", 493: "chiffonier, commode", 494: "chime, bell, gong", 495: "china cabinet, china closet", 496: "Christmas stocking", 497: "church, church building", 498: "cinema, movie theater, movie theatre, movie house, picture palace", 499: "cleaver, meat cleaver, chopper", 500: "cliff dwelling", 501: "cloak", 502: "clog, geta, patten, sabot", 503: "cocktail shaker", 504: "coffee mug", 505: "coffeepot", 506: "coil, spiral, volute, whorl, helix", 507: "combination lock", 508: "computer keyboard, keypad", 509: "confectionery, confectionary, candy store", 510: "container ship, containership, container vessel", 511: "convertible", 512: "corkscrew, bottle screw", 513: "cornet, horn, trumpet, trump", 514: "cowboy boot", 515: "cowboy hat, ten-gallon hat", 516: "cradle", 517: "crane", 518: "crash helmet", 519: "crate", 520: "crib, cot", 521: "Crock Pot", 522: "croquet ball", 523: "crutch", 524: "cuirass", 525: "dam, dike, dyke", 526: "desk", 527: "desktop computer", 528: "dial telephone, dial phone", 529: "diaper, nappy, napkin", 530: "digital clock", 531: "digital watch", 532: "dining table, board", 533: "dishrag, dishcloth", 534: "dishwasher, dish washer, dishwashing machine", 535: "disk brake, disc brake", 536: "dock, dockage, docking facility", 537: "dogsled, dog sled, dog sleigh", 538: "dome", 539: "doormat, welcome mat", 540: "drilling platform, offshore rig", 541: "drum, membranophone, tympan", 542: "drumstick", 543: "dumbbell", 544: "Dutch oven", 545: "electric fan, blower", 546: "electric guitar", 547: "electric locomotive", 548: "entertainment center", 549: "envelope", 550: "espresso maker", 551: "face powder", 552: "feather boa, boa", 553: "file, file cabinet, filing cabinet", 554: "fireboat", 555: "fire engine, fire truck", 556: "fire screen, fireguard", 557: "flagpole, flagstaff", 558: "flute, transverse flute", 559: "folding chair", 560: "football helmet", 561: "forklift", 562: "fountain", 563: "fountain pen", 564: "four-poster", 565: "freight car", 566: "French horn, horn", 567: "frying pan, frypan, skillet", 568: "fur coat", 569: "garbage truck, dustcart", 570: "gasmask, respirator, gas helmet", 571: "gas pump, gasoline pump, petrol pump, island dispenser", 572: "goblet", 573: "go-kart", 574: "golf ball", 575: "golfcart, golf cart", 576: "gondola", 577: "gong, tam-tam", 578: "gown", 579: "grand piano, grand", 580: "greenhouse, nursery, glasshouse", 581: "grille, radiator grille", 582: "grocery store, grocery, food market, market", 583: "guillotine", 584: "hair slide", 585: "hair spray", 586: "half track", 587: "hammer", 588: "hamper", 589: "hand blower, blow dryer, blow drier, hair dryer, hair drier", 590: "hand-held computer, hand-held microcomputer", 591: "handkerchief, hankie, hanky, hankey", 592: "hard disc, hard disk, fixed disk", 593: "harmonica, mouth organ, harp, mouth harp", 594: "harp", 595: "harvester, reaper", 596: "hatchet", 597: "holster", 598: "home theater, home theatre", 599: "honeycomb", 600: "hook, claw", 601: "hoopskirt, crinoline", 602: "horizontal bar, high bar", 603: "horse cart, horse-cart", 604: "hourglass", 605: "iPod", 606: "iron, smoothing iron", 607: "jack-o'-lantern", 608: "jean, blue jean, denim", 609: "jeep, landrover", 610: "jersey, T-shirt, tee shirt", 611: "jigsaw puzzle", 612: "jinrikisha, ricksha, rickshaw", 613: "joystick", 614: "kimono", 615: "knee pad", 616: "knot", 617: "lab coat, laboratory coat", 618: "ladle", 619: "lampshade, lamp shade", 620: "laptop, laptop computer", 621: "lawn mower, mower", 622: "lens cap, lens cover", 623: "letter opener, paper knife, paperknife", 624: "library", 625: "lifeboat", 626: "lighter, light, igniter, ignitor", 627: "limousine, limo", 628: "liner, ocean liner", 629: "lipstick, lip rouge", 630: "Loafer", 631: "lotion", 632: "loudspeaker, speaker, speaker unit, loudspeaker system, speaker system", 633: "loupe, jeweler's loupe", 634: "lumbermill, sawmill", 635: "magnetic compass", 636: "mailbag, postbag", 637: "mailbox, letter box", 638: "maillot", 639: "maillot, tank suit", 640: "manhole cover", 641: "maraca", 642: "marimba, xylophone", 643: "mask", 644: "matchstick", 645: "maypole", 646: "maze, labyrinth", 647: "measuring cup", 648: "medicine chest, medicine cabinet", 649: "megalith, megalithic structure", 650: "microphone, mike", 651: "microwave, microwave oven", 652: "military uniform", 653: "milk can", 654: "minibus", 655: "miniskirt, mini", 656: "minivan", 657: "missile", 658: "mitten", 659: "mixing bowl", 660: "mobile home, manufactured home", 661: "Model T", 662: "modem", 663: "monastery", 664: "monitor", 665: "moped", 666: "mortar", 667: "mortarboard", 668: "mosque", 669: "mosquito net", 670: "motor scooter, scooter", 671: "mountain bike, all-terrain bike, off-roader", 672: "mountain tent", 673: "mouse, computer mouse", 674: "mousetrap", 675: "moving van", 676: "muzzle", 677: "nail", 678: "neck brace", 679: "necklace", 680: "nipple", 681: "notebook, notebook computer", 682: "obelisk", 683: "oboe, hautboy, hautbois", 684: "ocarina, sweet potato", 685: "odometer, hodometer, mileometer, milometer", 686: "oil filter", 687: "organ, pipe organ", 688: "oscilloscope, scope, cathode-ray oscilloscope, CRO", 689: "overskirt", 690: "oxcart", 691: "oxygen mask", 692: "packet", 693: "paddle, boat paddle", 694: "paddlewheel, paddle wheel", 695: "padlock", 696: "paintbrush", 697: "pajama, pyjama, pj's, jammies", 698: "palace", 699: "panpipe, pandean pipe, syrinx", 700: "paper towel", 701: "parachute, chute", 702: "parallel bars, bars", 703: "park bench", 704: "parking meter", 705: "passenger car, coach, carriage", 706: "patio, terrace", 707: "pay-phone, pay-station", 708: "pedestal, plinth, footstall", 709: "pencil box, pencil case", 710: "pencil sharpener", 711: "perfume, essence", 712: "Petri dish", 713: "photocopier", 714: "pick, plectrum, plectron", 715: "pickelhaube", 716: "picket fence, paling", 717: "pickup, pickup truck", 718: "pier", 719: "piggy bank, penny bank", 720: "pill bottle", 721: "pillow", 722: "ping-pong ball", 723: "pinwheel", 724: "pirate, pirate ship", 725: "pitcher, ewer", 726: "plane, carpenter's plane, woodworking plane", 727: "planetarium", 728: "plastic bag", 729: "plate rack", 730: "plow, plough", 731: "plunger, plumber's helper", 732: "Polaroid camera, Polaroid Land camera", 733: "pole", 734: "police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria", 735: "poncho", 736: "pool table, billiard table, snooker table", 737: "pop bottle, soda bottle", 738: "pot, flowerpot", 739: "potter's wheel", 740: "power drill", 741: "prayer rug, prayer mat", 742: "printer", 743: "prison, prison house", 744: "projectile, missile", 745: "projector", 746: "puck, hockey puck", 747: "punching bag, punch bag, punching ball, punchball", 748: "purse", 749: "quill, quill pen", 750: "quilt, comforter, comfort, puff", 751: "racer, race car, racing car", 752: "racket, racquet", 753: "radiator", 754: "radio, wireless", 755: "radio telescope, radio reflector", 756: "rain barrel", 757: "recreational vehicle, RV, R.V.", 758: "reel", 759: "reflex camera", 760: "refrigerator, icebox", 761: "remote control, remote", 762: "restaurant, eating house, eating place, eatery", 763: "revolver, six-gun, six-shooter", 764: "rifle", 765: "rocking chair, rocker", 766: "rotisserie", 767: "rubber eraser, rubber, pencil eraser", 768: "rugby ball", 769: "rule, ruler", 770: "running shoe", 771: "safe", 772: "safety pin", 773: "saltshaker, salt shaker", 774: "sandal", 775: "sarong", 776: "sax, saxophone", 777: "scabbard", 778: "scale, weighing machine", 779: "school bus", 780: "schooner", 781: "scoreboard", 782: "screen, CRT screen", 783: "screw", 784: "screwdriver", 785: "seat belt, seatbelt", 786: "sewing machine", 787: "shield, buckler", 788: "shoe shop, shoe-shop, shoe store", 789: "shoji", 790: "shopping basket", 791: "shopping cart", 792: "shovel", 793: "shower cap", 794: "shower curtain", 795: "ski", 796: "ski mask", 797: "sleeping bag", 798: "slide rule, slipstick", 799: "sliding door", 800: "slot, one-armed bandit", 801: "snorkel", 802: "snowmobile", 803: "snowplow, snowplough", 804: "soap dispenser", 805: "soccer ball", 806: "sock", 807: "solar dish, solar collector, solar furnace", 808: "sombrero", 809: "soup bowl", 810: "space bar", 811: "space heater", 812: "space shuttle", 813: "spatula", 814: "speedboat", 815: "spider web, spider's web", 816: "spindle", 817: "sports car, sport car", 818: "spotlight, spot", 819: "stage", 820: "steam locomotive", 821: "steel arch bridge", 822: "steel drum", 823: "stethoscope", 824: "stole", 825: "stone wall", 826: "stopwatch, stop watch", 827: "stove", 828: "strainer", 829: "streetcar, tram, tramcar, trolley, trolley car", 830: "stretcher", 831: "studio couch, day bed", 832: "stupa, tope", 833: "submarine, pigboat, sub, U-boat", 834: "suit, suit of clothes", 835: "sundial", 836: "sunglass", 837: "sunglasses, dark glasses, shades", 838: "sunscreen, sunblock, sun blocker", 839: "suspension bridge", 840: "swab, swob, mop", 841: "sweatshirt", 842: "swimming trunks, bathing trunks", 843: "swing", 844: "switch, electric switch, electrical switch", 845: "syringe", 846: "table lamp", 847: "tank, army tank, armored combat vehicle, armoured combat vehicle", 848: "tape player", 849: "teapot", 850: "teddy, teddy bear", 851: "television, television system", 852: "tennis ball", 853: "thatch, thatched roof", 854: "theater curtain, theatre curtain", 855: "thimble", 856: "thresher, thrasher, threshing machine", 857: "throne", 858: "tile roof", 859: "toaster", 860: "tobacco shop, tobacconist shop, tobacconist", 861: "toilet seat", 862: "torch", 863: "totem pole", 864: "tow truck, tow car, wrecker", 865: "toyshop", 866: "tractor", 867: "trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi", 868: "tray", 869: "trench coat", 870: "tricycle, trike, velocipede", 871: "trimaran", 872: "tripod", 873: "triumphal arch", 874: "trolleybus, trolley coach, trackless trolley", 875: "trombone", 876: "tub, vat", 877: "turnstile", 878: "typewriter keyboard", 879: "umbrella", 880: "unicycle, monocycle", 881: "upright, upright piano", 882: "vacuum, vacuum cleaner", 883: "vase", 884: "vault", 885: "velvet", 886: "vending machine", 887: "vestment", 888: "viaduct", 889: "violin, fiddle", 890: "volleyball", 891: "waffle iron", 892: "wall clock", 893: "wallet, billfold, notecase, pocketbook", 894: "wardrobe, closet, press", 895: "warplane, military plane", 896: "washbasin, handbasin, washbowl, lavabo, wash-hand basin", 897: "washer, automatic washer, washing machine", 898: "water bottle", 899: "water jug", 900: "water tower", 901: "whiskey jug", 902: "whistle", 903: "wig", 904: "window screen", 905: "window shade", 906: "Windsor tie", 907: "wine bottle", 908: "wing", 909: "wok", 910: "wooden spoon", 911: "wool, woolen, woollen", 912: "worm fence, snake fence, snake-rail fence, Virginia fence", 913: "wreck", 914: "yawl", 915: "yurt", 916: "web site, website, internet site, site", 917: "comic book", 918: "crossword puzzle, crossword", 919: "street sign", 920: "traffic light, traffic signal, stoplight", 921: "book jacket, dust cover, dust jacket, dust wrapper", 922: "menu", 923: "plate", 924: "guacamole", 925: "consomme", 926: "hot pot, hotpot", 927: "trifle", 928: "ice cream, icecream", 929: "ice lolly, lolly, lollipop, popsicle", 930: "French loaf", 931: "bagel, beigel", 932: "pretzel", 933: "cheeseburger", 934: "hotdog, hot dog, red hot", 935: "mashed potato", 936: "head cabbage", 937: "broccoli", 938: "cauliflower", 939: "zucchini, courgette", 940: "spaghetti squash", 941: "acorn squash", 942: "butternut squash", 943: "cucumber, cuke", 944: "artichoke, globe artichoke", 945: "bell pepper", 946: "cardoon", 947: "mushroom", 948: "Granny Smith", 949: "strawberry", 950: "orange", 951: "lemon", 952: "fig", 953: "pineapple, ananas", 954: "banana", 955: "jackfruit, jak, jack", 956: "custard apple", 957: "pomegranate", 958: "hay", 959: "carbonara", 960: "chocolate sauce, chocolate syrup", 961: "dough", 962: "meat loaf, meatloaf", 963: "pizza, pizza pie", 964: "potpie", 965: "burrito", 966: "red wine", 967: "espresso", 968: "cup", 969: "eggnog", 970: "alp", 971: "bubble", 972: "cliff, drop, drop-off", 973: "coral reef", 974: "geyser", 975: "lakeside, lakeshore", 976: "promontory, headland, head, foreland", 977: "sandbar, sand bar", 978: "seashore, coast, seacoast, sea-coast", 979: "valley, vale", 980: "volcano", 981: "ballplayer, baseball player", 982: "groom, bridegroom", 983: "scuba diver", 984: "rapeseed", 985: "daisy", 986: "yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum", 987: "corn", 988: "acorn", 989: "hip, rose hip, rosehip", 990: "buckeye, horse chestnut, conker", 991: "coral fungus", 992: "agaric", 993: "gyromitra", 994: "stinkhorn, carrion fungus", 995: "earthstar", 996: "hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa", 997: "bolete", 998: "ear, spike, capitulum", 999: "toilet tissue, toilet paper, bathroom tissue" }, _q = "2.1.1", Cq = 224, Aq = { "1.00": "module_apply_default/MobilenetV1/Logits/global_pool", "2.00": "module_apply_default/MobilenetV2/Logits/AvgPool" }, Tq = { "1.00": { .25: { url: "https://tfhub.dev/google/imagenet/mobilenet_v1_025_224/classification/1", inputRange: [0, 1] }, "0.50": { url: "https://tfhub.dev/google/imagenet/mobilenet_v1_050_224/classification/1", inputRange: [0, 1] }, .75: { url: "https://tfhub.dev/google/imagenet/mobilenet_v1_075_224/classification/1", inputRange: [0, 1] }, "1.00": { url: "https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1", inputRange: [0, 1] } }, "2.00": { "0.50": { url: "https://tfhub.dev/google/imagenet/mobilenet_v2_050_224/classification/2", inputRange: [0, 1] }, .75: { url: "https://tfhub.dev/google/imagenet/mobilenet_v2_075_224/classification/2", inputRange: [0, 1] }, "1.00": { url: "https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2", inputRange: [0, 1] } } }; function Eq(e) { return void 0 === e && (e = { version: 1, alpha: 1 }), wq(this, void 0, void 0, (function () { var t, n, r, i, a, o, s; return kq(this, (function (u) { switch (u.label) { case 0: if (null == P) throw new Error("Cannot find TensorFlow.js. If you are using a