/* Human homepage: author: ' */ var __defProp = Object.defineProperty; var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); var __require = typeof require !== "undefined" ? require : (x) => { throw new Error('Dynamic require of "' + x + '" is not supported'); }; var __export = (target, all2) => { __markAsModule(target); for (var name in all2) __defProp(target, name, { get: all2[name], enumerable: true }); }; var __accessCheck = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet = (obj, member, getter) => { __accessCheck(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet = (obj, member, value, setter) => { __accessCheck(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; // src/helpers.ts function join(folder, file) { const separator = folder.endsWith("/") ? "" : "/"; const skipJoin = file.startsWith(".") || file.startsWith("/") || file.startsWith("http:") || file.startsWith("https:") || file.startsWith("file:"); const path = skipJoin ? `${file}` : `${folder}${separator}${file}`; if (!path.toLocaleLowerCase().includes(".json")) throw new Error(`Human: ModelPath Error: ${path} Expecting JSON file`); return path; } function log(...msg) { const dt = new Date(); const ts2 = `${dt.getHours().toString().padStart(2, "0")}:${dt.getMinutes().toString().padStart(2, "0")}:${dt.getSeconds().toString().padStart(2, "0")}.${dt.getMilliseconds().toString().padStart(3, "0")}`; if (msg) console.log(ts2, "Human:", ...msg); } var now = () => { if (typeof performance !== "undefined") return performance.now(); return parseInt((Number(process.hrtime.bigint()) / 1e3 / 1e3).toString()); }; function mergeDeep(...objects) { const isObject = (obj) => obj && typeof obj === "object"; return objects.reduce((prev, obj) => { Object.keys(obj || {}).forEach((key) => { const pVal = prev[key]; const oVal = obj[key]; if (Array.isArray(pVal) && Array.isArray(oVal)) prev[key] = pVal.concat(...oVal); else if (isObject(pVal) && isObject(oVal)) prev[key] = mergeDeep(pVal, oVal); else prev[key] = oVal; }); return prev; }, {}); } // src/config.ts var config = { backend: "webgl", modelBasePath: "../models/", wasmPath: "", debug: true, async: true, warmup: "full", cacheSensitivity: 0.75, skipFrame: false, filter: { enabled: true, width: 0, height: 0, flip: false, return: true, brightness: 0, contrast: 0, sharpness: 0, blur: 0, saturation: 0, hue: 0, negative: false, sepia: false, vintage: false, kodachrome: false, technicolor: false, polaroid: false, pixelate: 0 }, gesture: { enabled: true }, face: { enabled: true, detector: { modelPath: "blazeface.json", rotation: true, maxDetected: 15, skipFrames: 15, minConfidence: 0.2, iouThreshold: 0.1, return: false }, mesh: { enabled: true, modelPath: "facemesh.json" }, iris: { enabled: true, modelPath: "iris.json" }, description: { enabled: true, modelPath: "faceres.json", skipFrames: 11, minConfidence: 0.1 }, emotion: { enabled: true, minConfidence: 0.1, skipFrames: 17, modelPath: "emotion.json" } }, body: { enabled: true, modelPath: "movenet-lightning.json", maxDetected: 1, minConfidence: 0.2, skipFrames: 1 }, hand: { enabled: true, rotation: true, skipFrames: 18, minConfidence: 0.8, iouThreshold: 0.2, maxDetected: 1, landmarks: true, detector: { modelPath: "handdetect.json" }, skeleton: { modelPath: "handskeleton.json" } }, object: { enabled: false, modelPath: "mb3-centernet.json", minConfidence: 0.2, iouThreshold: 0.4, maxDetected: 10, skipFrames: 19 }, segmentation: { enabled: false, modelPath: "selfie.json" } }; // src/sysinfo.ts function info() { let platform = ""; let agent = ""; if (typeof navigator !== "undefined") { const raw = navigator.userAgent.match(/\(([^()]+)\)/g); if (raw && raw[0]) { const platformMatch = raw[0].match(/\(([^()]+)\)/g); platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : ""; agent = navigator.userAgent.replace(raw[0], ""); if (platform[1]) agent = agent.replace(raw[1], ""); agent = agent.replace(/ /g, " "); } } else if (typeof process !== "undefined") { platform = `${process.platform} ${process.arch}`; agent = `NodeJS ${process.version}`; } return { platform, agent }; } // dist/tfjs.esm.js var tfjs_esm_exports = {}; __export(tfjs_esm_exports, { Abs: () => Vs, Acos: () => Ni, Acosh: () => Ti, AdadeltaOptimizer: () => xp, AdagradOptimizer: () => yp, AdamOptimizer: () => bp, AdamaxOptimizer: () => wp, Add: () => Wn, AddN: () => So, All: () => Ei, Any: () => Ai, ArgMax: () => Io, ArgMin: () => Xa, Asin: () => $i, Asinh: () => Di, Atan: () => Ri, Atan2: () => Oi, Atanh: () => Fi, AvgPool: () => No, AvgPool3D: () => Ya, AvgPool3DGrad: () => xc, AvgPoolGrad: () => gc, BackendWasm: () => My, BatchMatMul: () => To, BatchToSpaceND: () => Ws, Bincount: () => yc, BroadcastArgs: () => Zh, BroadcastTo: () => XI, Callback: () => mv, CallbackList: () => C_, Cast: () => Qn, Ceil: () => Eo, ClipByValue: () => eo, Complex: () => bc, ComplexAbs: () => Za, Concat: () => js, Conv2D: () => Ao, Conv2DBackpropFilter: () => wc, Conv2DBackpropInput: () => $o, Conv3D: () => Ja, Conv3DBackpropFilterV2: () => kc, Conv3DBackpropInputV2: () => _c, Cos: () => Do, Cosh: () => Ro, CropAndResize: () => Pi, Cumsum: () => Fo, CustomCallback: () => I_, DataStorage: () => Ka, DenseBincount: () => vc, DepthToSpace: () => Mi, DepthwiseConv2dNative: () => Oo, DepthwiseConv2dNativeBackpropFilter: () => Cc, DepthwiseConv2dNativeBackpropInput: () => Sc, Diag: () => Ic, Dilation2D: () => Qa, Dilation2DBackpropFilter: () => Dm, Dilation2DBackpropInput: () => $m, ENV: () => gw, EarlyStopping: () => fv, Einsum: () => Nc, Elu: () => Mo, EluGrad: () => Tc, Environment: () => Yh, Equal: () => zi, Erf: () => Li, Exp: () => Lo, ExpandDims: () => Gs, Expm1: () => Bi, FFT: () => Ec, Fill: () => el, FlipLeftRight: () => Vi, Floor: () => zo, FloorDiv: () => Bo, FromPixels: () => Rm, FusedBatchNorm: () => Vo, FusedConv2D: () => ni, FusedDepthwiseConv2D: () => oi, GPGPUContext: () => hy, GatherNd: () => Wi, GatherV2: () => Us, GraphModel: () => jv, Greater: () => ji, GreaterEqual: () => Wo, History: () => S_, IFFT: () => Ac, Identity: () => to, Imag: () => $c, InputSpec: () => _t, IsFinite: () => Gi, IsInf: () => Ui, IsNan: () => Hi, KernelBackend: () => Ls, LRN: () => tl, LRNGrad: () => Rc, LayerVariable: () => Yg, LayersModel: () => Xn, LeakyRelu: () => jo, Less: () => qi, LessEqual: () => Ki, LinSpace: () => Dc, Log: () => Go, Log1p: () => Xi, LogSoftmax: () => YI, LogicalAnd: () => Yi, LogicalNot: () => jl, LogicalOr: () => Gl, MathBackendCPU: () => Pu, MathBackendWebGL: () => Hu, Max: () => Uo, MaxPool: () => qo, MaxPool3D: () => rl, MaxPool3DGrad: () => Oc, MaxPoolGrad: () => Fc, MaxPoolWithArgmax: () => Pc, Maximum: () => Ho, Mean: () => Ko, Min: () => Xo, Minimum: () => Yo, MirrorPad: () => Zo, Mod: () => Zi, MomentumOptimizer: () => kp, Multinomial: () => Mc, Multiply: () => Jo, Neg: () => Hs, NonMaxSuppressionV3: () => Qi, NonMaxSuppressionV4: () => ea, NonMaxSuppressionV5: () => ta, NotEqual: () => Ji, OP_SCOPE_SUFFIX: () => S1, OneHot: () => Qo, OnesLike: () => qs, Optimizer: () => Wr, Pack: () => Ks, PadV2: () => es, Pool: () => fse, Pow: () => ts, Prelu: () => rs, Prod: () => ra, RMSPropOptimizer: () => _p, RNN: () => On, Range: () => nl, Rank: () => Iw, Real: () => Lc, RealDiv: () => Po, Reciprocal: () => na, Reduction: () => qt, Relu: () => ns, Relu6: () => ss, Reshape: () => Xs, ResizeBilinear: () => os, ResizeBilinearGrad: () => Bc, ResizeNearestNeighbor: () => ol, ResizeNearestNeighborGrad: () => zc, Reverse: () => is, RotateWithOffset: () => ma, Round: () => as, Rsqrt: () => ls, SGDOptimizer: () => dl, ScatterNd: () => oa, Select: () => Ys, Selu: () => sa, Sequential: () => $a, Sigmoid: () => cs, Sign: () => aa, Sin: () => us, Sinh: () => ia, Slice: () => Zs, Softmax: () => fs, Softplus: () => la, SpaceToBatchND: () => Js, SparseFillEmptyRows: () => Vc, SparseReshape: () => Wc, SparseSegmentMean: () => jc, SparseSegmentSum: () => Gc, SparseToDense: () => Uc, SplitV: () => Qs, Sqrt: () => ps, Square: () => sl, SquaredDifference: () => ds, Step: () => ro, StridedSlice: () => ua, StringNGrams: () => Hc, StringSplit: () => qc, StringToHashBucketFast: () => Kc, Sub: () => hs, Sum: () => ms, SymbolicTensor: () => on, Tan: () => gs, Tanh: () => xs, Tensor: () => je, TensorBuffer: () => ct, Tile: () => jn, TopK: () => ca, Transform: () => pa, Transpose: () => ys, Unique: () => Xc, Unpack: () => ei, UnsortedSegmentSum: () => il, Variable: () => ul, ZerosLike: () => ti, _FusedMatMul: () => ri, abs: () => Tt, acos: () => tk, acosh: () => rk, add: () => Y, addN: () => nk, all: () => Gm, any: () => lp, argMax: () => ba, argMin: () => ok, asin: () => sk, asinh: () => ik, atan: () => ak, atan2: () => lk, atanh: () => uk, avgPool: () => nu, avgPool3d: () => Um, backend: () => kN, backend_util: () => S, basicLSTMCell: () => b4, batchNorm: () => ai, batchNorm2d: () => fk, batchNorm3d: () => dk, batchNorm4d: () => hk, batchToSpaceND: () => ou, bincount: () => Hm, booleanMaskAsync: () => XIe, broadcastArgs: () => gk, broadcastTo: () => su, browser: () => cg, buffer: () => Se, callbacks: () => PX, cast: () => J, ceil: () => xk, clipByValue: () => Sr, clone: () => hn, complex: () => $n, concat: () => tt, concat1d: () => yk, concat2d: () => bk, concat3d: () => wk, concat4d: () => kk, constraints: () => PE, conv1d: () => qm, conv2d: () => Dn, conv2dTranspose: () => Km, conv3d: () => Xm, conv3dTranspose: () => _k, copyRegisteredKernels: () => wse, cos: () => iu, cosh: () => Ym, cosineWindow: () => Tg, cumsum: () => Zm, customGrad: () => Qr, data: () => s0, denseBincount: () => vk, deprecationWarn: () => ek, depthToSpace: () => Ck, depthwiseConv2d: () => ka, deregisterOp: () => LX, device_util: () => Ql, diag: () => K4, dilation2d: () => Sk, disableDeprecationWarnings: () => nue, dispose: () => Ae, disposeVariables: () => oue, div: () => ue, divNoNan: () => Ik, dot: () => rU, dropout: () => UN, einsum: () => Nk, elu: () => _a, enableDebugMode: () => rue, enableProdMode: () => tue, enclosingPowerOfTwo: () => HN, engine: () => ks, env: () => j, equal: () => Dr, erf: () => Tk, exp: () => tr, expandDims: () => gr, expm1: () => Ek, eye: () => pp, fft: () => gu, fill: () => _s, findBackend: () => cue, findBackendFactory: () => pue, floor: () => va, floorDiv: () => jm, forceHalfFloat: () => BP, fused: () => lo, gather: () => li, gatherND: () => jN, gather_util: () => pg, getBackend: () => lue, getGradient: () => bw, getKernel: () => Om, getKernelsForBackend: () => Jh, gpgpu_util: () => VO, grad: () => NU, grads: () => TU, greater: () => Ht, greaterEqual: () => Un, ifft: () => fl, imag: () => au, image: () => bn, inTopKAsync: () => sNe, initializers: () => rA, input: () => O_, io: () => $r, irfft: () => ff, isFinite: () => xU, isInf: () => bU, isNaN: () => Ak, keep: () => Dt, kernel_impls: () => Mr, layers: () => MA, leakyRelu: () => lu, less: () => Jm, lessEqual: () => Hn, linalg: () => RT, linspace: () => $k, loadGraphModel: () => m7, loadLayersModel: () => K5, localResponseNormalization: () => Dk, log: () => Ir, log1p: () => uu, logSigmoid: () => FU, logSoftmax: () => Qm, logSumExp: () => Pk, logicalAnd: () => Fr, logicalNot: () => cu, logicalOr: () => tf, logicalXor: () => HU, losses: () => tFe, matMul: () => Me, math: () => oN, max: () => Vr, maxPool: () => pu, maxPool3d: () => rf, maxPoolWithArgmax: () => Mk, maximum: () => Rn, mean: () => Ct, memory: () => Wm, meshgrid: () => JU, metrics: () => LA, min: () => mp, minimum: () => Ca, mirrorPad: () => Lk, mod: () => zk, model: () => H5, models: () => zA, moments: () => fp, movingAverage: () => k1e, mul: () => F, multiRNNCell: () => iH, multinomial: () => Bk, neg: () => Ke, nextFrame: () => xf, norm: () => Ig, notEqual: () => ci, oneHot: () => xa, ones: () => rr, onesLike: () => xr, op: () => I, outerProduct: () => pH, pad: () => xn, pad1d: () => dH, pad2d: () => gH, pad3d: () => yH, pad4d: () => wH, pool: () => SH, pow: () => yn, prelu: () => fu, print: () => Gw, prod: () => nf, profile: () => sue, rand: () => AH, randomGamma: () => LH, randomNormal: () => _g, randomUniform: () => vs, range: () => Sa, ready: () => aue, real: () => ml, reciprocal: () => Zk, registerBackend: () => ap, registerCallbackConstructor: () => X5, registerGradient: () => ZI, registerKernel: () => Ul, registerOp: () => MX, regularizers: () => BA, relu: () => Or, relu6: () => of, removeBackend: () => uue, reshape: () => O, reverse: () => lr, reverse1d: () => qH, reverse2d: () => XH, reverse3d: () => ZH, reverse4d: () => QH, rfft: () => xu, round: () => sf, rsqrt: () => af, scalar: () => ce, scatterND: () => VN, scatter_util: () => fg, selu: () => lf, separableConv2d: () => Jk, sequential: () => q5, serialization: () => ee, setBackend: () => VG, setPlatform: () => mue, setWasmPath: () => Hoe, setWasmPaths: () => qoe, setWebGLContext: () => W0, setdiff1dAsync: () => Qk, shared: () => Yx, sigmoid: () => Jr, sign: () => e_, signal: () => TRe, sin: () => uf, sinh: () => cf, slice: () => Oe, slice1d: () => pf, slice2d: () => vg, slice3d: () => mf, slice4d: () => hp, slice_util: () => ar, softmax: () => hu, softplus: () => ui, spaceToBatchND: () => mu, sparse: () => gf, sparseToDense: () => Ng, spectral: () => vRe, split: () => mr, sqrt: () => St, square: () => We, squaredDifference: () => df, squeeze: () => en, stack: () => nr, step: () => Ia, stridedSlice: () => t_, string: () => Pg, sub: () => le, sum: () => me, sumOutType: () => Zl, tan: () => r_, tanh: () => wa, tensor: () => vr, tensor1d: () => At, tensor2d: () => pi, tensor3d: () => Kw, tensor4d: () => Sq, tensor5d: () => Iq, tensor6d: () => Nq, tensor_util: () => io, test_util: () => wN, tidy: () => z, tile: () => Rr, time: () => iue, topk: () => n_, train: () => vu, transpose: () => Ve, truncatedNormal: () => yu, unique: () => Cg, unregisterGradient: () => bse, unregisterKernel: () => yse, unsortedSegmentSum: () => o_, unstack: () => Nr, upcastType: () => pr, util: () => b, valueAndGrad: () => EU, valueAndGrads: () => AU, variable: () => s_, variableGrads: () => yg, version: () => FWt, version_converter: () => f7, version_core: () => BG, version_cpu: () => q7, version_layers: () => Vf, version_wasm: () => Koe, version_webgl: () => PJ, webgl: () => Cwt, webgl_util: () => $O, where: () => Et, whereAsync: () => hf, zeros: () => ht, zerosLike: () => Ie }); var jW = Object.create; var qh = Object.defineProperty; var GW = Object.getOwnPropertyDescriptor; var UW = Object.getOwnPropertyNames; var HW = Object.getPrototypeOf; var qW = Object.prototype.hasOwnProperty; var FI = (r) => qh(r, "__esModule", { value: true }); var pc = typeof __require != "undefined" ? __require : (r) => { throw new Error('Dynamic require of "' + r + '" is not supported'); }; var Ut = (r, e) => () => (e || r((e = { exports: {} }).exports, e), e.exports); var He = (r, e) => { FI(r); for (var t in e) qh(r, t, { get: e[t], enumerable: true }); }; var KW = (r, e, t) => { if (e && typeof e == "object" || typeof e == "function") for (let n of UW(e)) !qW.call(r, n) && n !== "default" && qh(r, n, { get: () => e[n], enumerable: !(t = GW(e, n)) || t.enumerable }); return r; }; var Bl = (r) => KW(FI(qh(r != null ? jW(HW(r)) : {}, "default", r && r.__esModule && "default" in r ? { get: () => r.default, enumerable: true } : { value: r, enumerable: true })), r); var l1 = Ut((_se, a1) => { a1.exports = Vt; var no = null; try { no = 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 (r) { } function Vt(r, e, t) { this.low = r | 0, this.high = e | 0, this.unsigned = !!t; } Vt.prototype.__isLong__; Object.defineProperty(Vt.prototype, "__isLong__", { value: true }); function En(r) { return (r && r.__isLong__) === true; } Vt.isLong = En; var JI = {}, QI = {}; function Hl(r, e) { var t, n, o; return e ? (r >>>= 0, (o = 0 <= r && r < 256) && (n = QI[r], n) ? n : (t = Wt(r, (r | 0) < 0 ? -1 : 0, true), o && (QI[r] = t), t)) : (r |= 0, (o = -128 <= r && r < 128) && (n = JI[r], n) ? n : (t = Wt(r, r < 0 ? -1 : 0, false), o && (JI[r] = t), t)); } Vt.fromInt = Hl; function oo(r, e) { if (isNaN(r)) return e ? ql : so; if (e) { if (r < 0) return ql; if (r >= t1) return i1; } else { if (r <= -r1) return An; if (r + 1 >= r1) return s1; } return r < 0 ? oo(-r, e).neg() : Wt(r % Zc | 0, r / Zc | 0, e); } Vt.fromNumber = oo; function Wt(r, e, t) { return new Vt(r, e, t); } Vt.fromBits = Wt; var Qh = Math.pow; function kw(r, e, t) { if (r.length === 0) throw Error("empty string"); if (r === "NaN" || r === "Infinity" || r === "+Infinity" || r === "-Infinity") return so; if (typeof e == "number" ? (t = e, e = false) : e = !!e, t = t || 10, t < 2 || 36 < t) throw RangeError("radix"); var n; if ((n = r.indexOf("-")) > 0) throw Error("interior hyphen"); if (n === 0) return kw(r.substring(1), e, t).neg(); for (var o = oo(Qh(t, 8)), s = so, a = 0; a < r.length; a += 8) { var i = Math.min(8, r.length - a), l = parseInt(r.substring(a, a + i), t); if (i < 8) { var u = oo(Qh(t, i)); s = s.mul(u).add(oo(l)); } else s = s.mul(o), s = s.add(oo(l)); } return s.unsigned = e, s; } Vt.fromString = kw; function bs(r, e) { return typeof r == "number" ? oo(r, e) : typeof r == "string" ? kw(r, e) : Wt(r.low, r.high, typeof e == "boolean" ? e : r.unsigned); } Vt.fromValue = bs; var e1 = 1 << 16, Sj = 1 << 24, Zc = e1 * e1, t1 = Zc * Zc, r1 = t1 / 2, n1 = Hl(Sj), so = Hl(0); Vt.ZERO = so; var ql = Hl(0, true); Vt.UZERO = ql; var Jc = Hl(1); Vt.ONE = Jc; var o1 = Hl(1, true); Vt.UONE = o1; var _w = Hl(-1); Vt.NEG_ONE = _w; var s1 = Wt(4294967295 | 0, 2147483647 | 0, false); Vt.MAX_VALUE = s1; var i1 = Wt(4294967295 | 0, 4294967295 | 0, true); Vt.MAX_UNSIGNED_VALUE = i1; var An = Wt(0, 2147483648 | 0, false); Vt.MIN_VALUE = An; var be = Vt.prototype; be.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low; }; be.toNumber = function() { return this.unsigned ? (this.high >>> 0) * Zc + (this.low >>> 0) : this.high * Zc + (this.low >>> 0); }; be.toString = function(e) { if (e = e || 10, e < 2 || 36 < e) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) if (this.eq(An)) { var t = oo(e), n = this.div(t), o = n.mul(t).sub(this); return n.toString(e) + o.toInt().toString(e); } else return "-" + this.neg().toString(e); for (var s = oo(Qh(e, 6), this.unsigned), a = this, i = ""; ; ) { var l = a.div(s), u = a.sub(l.mul(s)).toInt() >>> 0, c = u.toString(e); if (a = l, a.isZero()) return c + i; for (; c.length < 6; ) c = "0" + c; i = "" + c + i; } }; be.getHighBits = function() { return this.high; }; be.getHighBitsUnsigned = function() { return this.high >>> 0; }; be.getLowBits = function() { return this.low; }; be.getLowBitsUnsigned = function() { return this.low >>> 0; }; be.getNumBitsAbs = function() { if (this.isNegative()) return this.eq(An) ? 64 : this.neg().getNumBitsAbs(); for (var e = this.high != 0 ? this.high : this.low, t = 31; t > 0 && (e & 1 << t) == 0; t--) ; return this.high != 0 ? t + 33 : t + 1; }; be.isZero = function() { return this.high === 0 && this.low === 0; }; be.eqz = be.isZero; be.isNegative = function() { return !this.unsigned && this.high < 0; }; be.isPositive = function() { return this.unsigned || this.high >= 0; }; be.isOdd = function() { return (this.low & 1) == 1; }; be.isEven = function() { return (this.low & 1) == 0; }; be.equals = function(e) { return En(e) || (e = bs(e)), this.unsigned !== e.unsigned && this.high >>> 31 == 1 && e.high >>> 31 == 1 ? false : this.high === e.high && this.low === e.low; }; be.eq = be.equals; be.notEquals = function(e) { return !this.eq(e); }; be.neq = be.notEquals; be.ne = be.notEquals; be.lessThan = function(e) { return this.comp(e) < 0; }; be.lt = be.lessThan; be.lessThanOrEqual = function(e) { return this.comp(e) <= 0; }; be.lte = be.lessThanOrEqual; be.le = be.lessThanOrEqual; be.greaterThan = function(e) { return this.comp(e) > 0; }; be.gt = be.greaterThan; be.greaterThanOrEqual = function(e) { return this.comp(e) >= 0; }; be.gte = be.greaterThanOrEqual; be.ge = be.greaterThanOrEqual; be.compare = function(e) { if (En(e) || (e = bs(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; }; be.comp = be.compare; be.negate = function() { return !this.unsigned && this.eq(An) ? An : this.not().add(Jc); }; be.neg = be.negate; be.add = function(e) { En(e) || (e = bs(e)); var t = this.high >>> 16, n = this.high & 65535, o = this.low >>> 16, s = this.low & 65535, a = e.high >>> 16, i = e.high & 65535, l = e.low >>> 16, u = e.low & 65535, c = 0, p = 0, m = 0, f = 0; return f += s + u, m += f >>> 16, f &= 65535, m += o + l, p += m >>> 16, m &= 65535, p += n + i, c += p >>> 16, p &= 65535, c += t + a, c &= 65535, Wt(m << 16 | f, c << 16 | p, this.unsigned); }; be.subtract = function(e) { return En(e) || (e = bs(e)), this.add(e.neg()); }; be.sub = be.subtract; be.multiply = function(e) { if (this.isZero()) return so; if (En(e) || (e = bs(e)), no) { var t = no.mul(this.low, this.high, e.low, e.high); return Wt(t, no.get_high(), this.unsigned); } if (e.isZero()) return so; if (this.eq(An)) return e.isOdd() ? An : so; if (e.eq(An)) return this.isOdd() ? An : so; 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(n1) && e.lt(n1)) return oo(this.toNumber() * e.toNumber(), this.unsigned); var n = this.high >>> 16, o = this.high & 65535, s = this.low >>> 16, a = this.low & 65535, i = e.high >>> 16, l = e.high & 65535, u = e.low >>> 16, c = e.low & 65535, p = 0, m = 0, f = 0, d = 0; return d += a * c, f += d >>> 16, d &= 65535, f += s * c, m += f >>> 16, f &= 65535, f += a * u, m += f >>> 16, f &= 65535, m += o * c, p += m >>> 16, m &= 65535, m += s * u, p += m >>> 16, m &= 65535, m += a * l, p += m >>> 16, m &= 65535, p += n * c + o * u + s * l + a * i, p &= 65535, Wt(f << 16 | d, p << 16 | m, this.unsigned); }; be.mul = be.multiply; be.divide = function(e) { if (En(e) || (e = bs(e)), e.isZero()) throw Error("division by zero"); if (no) { if (!this.unsigned && this.high === -2147483648 && e.low === -1 && e.high === -1) return this; var t = (this.unsigned ? no.div_u : no.div_s)(this.low, this.high, e.low, e.high); return Wt(t, no.get_high(), this.unsigned); } if (this.isZero()) return this.unsigned ? ql : so; var n, o, s; if (this.unsigned) { if (e.unsigned || (e = e.toUnsigned()), e.gt(this)) return ql; if (e.gt(this.shru(1))) return o1; s = ql; } else { if (this.eq(An)) { if (e.eq(Jc) || e.eq(_w)) return An; if (e.eq(An)) return Jc; var a = this.shr(1); return n = a.div(e).shl(1), n.eq(so) ? e.isNegative() ? Jc : _w : (o = this.sub(e.mul(n)), s = n.add(o.div(e)), s); } else if (e.eq(An)) return this.unsigned ? ql : so; 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(); s = so; } for (o = this; o.gte(e); ) { n = Math.max(1, Math.floor(o.toNumber() / e.toNumber())); for (var i = Math.ceil(Math.log(n) / Math.LN2), l = i <= 48 ? 1 : Qh(2, i - 48), u = oo(n), c = u.mul(e); c.isNegative() || c.gt(o); ) n -= l, u = oo(n, this.unsigned), c = u.mul(e); u.isZero() && (u = Jc), s = s.add(u), o = o.sub(c); } return s; }; be.div = be.divide; be.modulo = function(e) { if (En(e) || (e = bs(e)), no) { var t = (this.unsigned ? no.rem_u : no.rem_s)(this.low, this.high, e.low, e.high); return Wt(t, no.get_high(), this.unsigned); } return this.sub(this.div(e).mul(e)); }; be.mod = be.modulo; be.rem = be.modulo; be.not = function() { return Wt(~this.low, ~this.high, this.unsigned); }; be.and = function(e) { return En(e) || (e = bs(e)), Wt(this.low & e.low, this.high & e.high, this.unsigned); }; be.or = function(e) { return En(e) || (e = bs(e)), Wt(this.low | e.low, this.high | e.high, this.unsigned); }; be.xor = function(e) { return En(e) || (e = bs(e)), Wt(this.low ^ e.low, this.high ^ e.high, this.unsigned); }; be.shiftLeft = function(e) { return En(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? Wt(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : Wt(0, this.low << e - 32, this.unsigned); }; be.shl = be.shiftLeft; be.shiftRight = function(e) { return En(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? Wt(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : Wt(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned); }; be.shr = be.shiftRight; be.shiftRightUnsigned = function(e) { if (En(e) && (e = e.toInt()), e &= 63, e === 0) return this; var t = this.high; if (e < 32) { var n = this.low; return Wt(n >>> e | t << 32 - e, t >>> e, this.unsigned); } else return e === 32 ? Wt(t, 0, this.unsigned) : Wt(t >>> e - 32, 0, this.unsigned); }; be.shru = be.shiftRightUnsigned; be.shr_u = be.shiftRightUnsigned; be.toSigned = function() { return this.unsigned ? Wt(this.low, this.high, false) : this; }; be.toUnsigned = function() { return this.unsigned ? this : Wt(this.low, this.high, true); }; be.toBytes = function(e) { return e ? this.toBytesLE() : this.toBytesBE(); }; be.toBytesLE = function() { var e = this.high, t = this.low; return [t & 255, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, e & 255, e >>> 8 & 255, e >>> 16 & 255, e >>> 24]; }; be.toBytesBE = function() { var e = this.high, t = this.low; return [e >>> 24, e >>> 16 & 255, e >>> 8 & 255, e & 255, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, t & 255]; }; Vt.fromBytes = function(e, t, n) { return n ? Vt.fromBytesLE(e, t) : Vt.fromBytesBE(e, t); }; Vt.fromBytesLE = function(e, t) { return new Vt(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t); }; Vt.fromBytesBE = function(e, t) { return new Vt(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t); }; }); var H1 = Ut(() => { }); var NN = Ut((IN, Vk) => { (function(r, e, t) { function n(i) { var l = this, u = a(); l.next = function() { var c = 2091639 * l.s0 + l.c * 23283064365386963e-26; return l.s0 = l.s1, l.s1 = l.s2, l.s2 = c - (l.c = c | 0); }, l.c = 1, l.s0 = u(" "), l.s1 = u(" "), l.s2 = u(" "), l.s0 -= u(i), l.s0 < 0 && (l.s0 += 1), l.s1 -= u(i), l.s1 < 0 && (l.s1 += 1), l.s2 -= u(i), l.s2 < 0 && (l.s2 += 1), u = null; } function o(i, l) { return l.c = i.c, l.s0 = i.s0, l.s1 = i.s1, l.s2 = i.s2, l; } function s(i, l) { var u = new n(i), c = l && l.state, p = u.next; return p.int32 = function() { return u.next() * 4294967296 | 0; }, p.double = function() { return p() + (p() * 2097152 | 0) * 11102230246251565e-32; }, p.quick = p, c && (typeof c == "object" && o(c, u), p.state = function() { return o(u, {}); }), p; } function a() { var i = 4022871197, l = function(u) { u = u.toString(); for (var c = 0; c < u.length; c++) { i += u.charCodeAt(c); var p = 0.02519603282416938 * i; i = p >>> 0, p -= i, p *= i, i = p >>> 0, p -= i, i += p * 4294967296; } return (i >>> 0) * 23283064365386963e-26; }; return l; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.alea = s; })(IN, typeof Vk == "object" && Vk, typeof define == "function" && define); }); var EN = Ut((TN, Wk) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.next = function() { var c = i.x ^ i.x << 11; return i.x = i.y, i.y = i.z, i.z = i.w, i.w ^= i.w >>> 19 ^ c ^ c >>> 8; }, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor128 = s; })(TN, typeof Wk == "object" && Wk, typeof define == "function" && define); }); var $N = Ut((AN, jk) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.x ^ i.x >>> 2; return i.x = i.y, i.y = i.z, i.z = i.w, i.w = i.v, (i.d = i.d + 362437 | 0) + (i.v = i.v ^ i.v << 4 ^ (c ^ c << 1)) | 0; }, i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.v = 0, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, u == l.length && (i.d = i.x << 10 ^ i.x >>> 4), i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i.v = a.v, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorwow = s; })(AN, typeof jk == "object" && jk, typeof define == "function" && define); }); var RN = Ut((DN, Gk) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.x, c = i.i, p, m, f; return p = u[c], p ^= p >>> 7, m = p ^ p << 24, p = u[c + 1 & 7], m ^= p ^ p >>> 10, p = u[c + 3 & 7], m ^= p ^ p >>> 3, p = u[c + 4 & 7], m ^= p ^ p << 7, p = u[c + 7 & 7], p = p ^ p << 13, m ^= p ^ p << 9, u[c] = m, i.i = c + 1 & 7, m; }; function l(u, c) { var p, m, f = []; if (c === (c | 0)) m = f[0] = c; else for (c = "" + c, p = 0; p < c.length; ++p) f[p & 7] = f[p & 7] << 15 ^ c.charCodeAt(p) + f[p + 1 & 7] << 13; for (; f.length < 8; ) f.push(0); for (p = 0; p < 8 && f[p] === 0; ++p) ; for (p == 8 ? m = f[7] = -1 : m = f[p], u.x = f, u.i = 0, p = 256; p > 0; --p) u.next(); } l(i, a); } function o(a, i) { return i.x = a.x.slice(), i.i = a.i, i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.x && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorshift7 = s; })(DN, typeof Gk == "object" && Gk, typeof define == "function" && define); }); var ON = Ut((FN, Uk) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.w, c = i.X, p = i.i, m, f; return i.w = u = u + 1640531527 | 0, f = c[p + 34 & 127], m = c[p = p + 1 & 127], f ^= f << 13, m ^= m << 17, f ^= f >>> 15, m ^= m >>> 12, f = c[p] = f ^ m, i.i = p, f + (u ^ u >>> 16) | 0; }; function l(u, c) { var p, m, f, d, h, g = [], y = 128; for (c === (c | 0) ? (m = c, c = null) : (c = c + "\0", m = 0, y = Math.max(y, c.length)), f = 0, d = -32; d < y; ++d) c && (m ^= c.charCodeAt((d + 32) % c.length)), d === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, d >= 0 && (h = h + 1640531527 | 0, p = g[d & 127] ^= m + h, f = p == 0 ? f + 1 : 0); for (f >= 128 && (g[(c && c.length || 0) & 127] = -1), f = 127, d = 4 * 128; d > 0; --d) m = g[f + 34 & 127], p = g[f = f + 1 & 127], m ^= m << 13, p ^= p << 17, m ^= m >>> 15, p ^= p >>> 12, g[f] = m ^ p; u.w = h, u.X = g, u.i = f; } l(i, a); } function o(a, i) { return i.i = a.i, i.w = a.w, i.X = a.X.slice(), i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.X && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor4096 = s; })(FN, typeof Uk == "object" && Uk, typeof define == "function" && define); }); var MN = Ut((PN, Hk) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.b, p = i.c, m = i.d, f = i.a; return c = c << 25 ^ c >>> 7 ^ p, p = p - m | 0, m = m << 24 ^ m >>> 8 ^ f, f = f - c | 0, i.b = c = c << 20 ^ c >>> 12 ^ p, i.c = p = p - m | 0, i.d = m << 16 ^ p >>> 16 ^ f, i.a = f - c | 0; }, i.a = 0, i.b = 0, i.c = 2654435769 | 0, i.d = 1367130551, a === Math.floor(a) ? (i.a = a / 4294967296 | 0, i.b = a | 0) : l += a; for (var u = 0; u < l.length + 20; u++) i.b ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.a = a.a, i.b = a.b, i.c = a.c, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.tychei = s; })(PN, typeof Hk == "object" && Hk, typeof define == "function" && define); }); var qk = Ut(() => { }); var LN = Ut((X_e, wg) => { (function(r, e) { var t = this, n = 256, o = 6, s = 52, a = "random", i = e.pow(n, o), l = e.pow(2, s), u = l * 2, c = n - 1, p; function m(x, k, C) { var A = []; k = k == true ? { entropy: true } : k || {}; var $ = g(h(k.entropy ? [x, w(r)] : x == null ? y() : x, 3), A), R = new f(A), P = function() { for (var M = R.g(o), V = i, W = 0; M < l; ) M = (M + W) * n, V *= n, W = R.g(1); for (; M >= u; ) M /= 2, V /= 2, W >>>= 1; return (M + W) / V; }; return P.int32 = function() { return R.g(4) | 0; }, P.quick = function() { return R.g(4) / 4294967296; }, P.double = P, g(w(R.S), r), (k.pass || C || function(M, V, W, G) { return G && (G.S && d(G, R), M.state = function() { return d(R, {}); }), W ? (e[a] = M, V) : M; })(P, $, "global" in k ? k.global : this == e, k.state); } e["seed" + a] = m; function f(x) { var k, C = x.length, A = this, $ = 0, R = A.i = A.j = 0, P = A.S = []; for (C || (x = [C++]); $ < n; ) P[$] = $++; for ($ = 0; $ < n; $++) P[$] = P[R = c & R + x[$ % C] + (k = P[$])], P[R] = k; (A.g = function(M) { for (var V, W = 0, G = A.i, U = A.j, H = A.S; M--; ) V = H[G = c & G + 1], W = W * n + H[c & (H[G] = H[U = c & U + V]) + (H[U] = V)]; return A.i = G, A.j = U, W; })(n); } function d(x, k) { return k.i = x.i, k.j = x.j, k.S = x.S.slice(), k; } function h(x, k) { var C = [], A = typeof x, $; if (k && A == "object") for ($ in x) try { C.push(h(x[$], k - 1)); } catch (R) { } return C.length ? C : A == "string" ? x : x + "\0"; } function g(x, k) { for (var C = x + "", A, $ = 0; $ < C.length; ) k[c & $] = c & (A ^= k[c & $] * 19) + C.charCodeAt($++); return w(k); } function y() { try { var x; return p && (x = p.randomBytes) ? x = x(n) : (x = new Uint8Array(n), (t.crypto || t.msCrypto).getRandomValues(x)), w(x); } catch (A) { var k = t.navigator, C = k && k.plugins; return [+new Date(), t, C, t.screen, w(r)]; } } function w(x) { return String.fromCharCode.apply(0, x); } if (g(e.random(), r), typeof wg == "object" && wg.exports) { wg.exports = m; try { p = qk(); } catch (x) { } } else typeof define == "function" && define.amd && define(function() { return m; }); })([], Math); }); var Kk = Ut((Y_e, zN) => { var $H = NN(), DH = EN(), RH = $N(), FH = RN(), OH = ON(), PH = MN(), du = LN(); du.alea = $H; du.xor128 = DH; du.xorwow = RH; du.xorshift7 = FH; du.xor4096 = OH; du.tychei = PH; zN.exports = du; }); var w$ = Ut((b$, Gv) => { (function(r, e, t) { function n(i) { var l = this, u = a(); l.next = function() { var c = 2091639 * l.s0 + l.c * 23283064365386963e-26; return l.s0 = l.s1, l.s1 = l.s2, l.s2 = c - (l.c = c | 0); }, l.c = 1, l.s0 = u(" "), l.s1 = u(" "), l.s2 = u(" "), l.s0 -= u(i), l.s0 < 0 && (l.s0 += 1), l.s1 -= u(i), l.s1 < 0 && (l.s1 += 1), l.s2 -= u(i), l.s2 < 0 && (l.s2 += 1), u = null; } function o(i, l) { return l.c = i.c, l.s0 = i.s0, l.s1 = i.s1, l.s2 = i.s2, l; } function s(i, l) { var u = new n(i), c = l && l.state, p = u.next; return p.int32 = function() { return u.next() * 4294967296 | 0; }, p.double = function() { return p() + (p() * 2097152 | 0) * 11102230246251565e-32; }, p.quick = p, c && (typeof c == "object" && o(c, u), p.state = function() { return o(u, {}); }), p; } function a() { var i = 4022871197, l = function(u) { u = String(u); for (var c = 0; c < u.length; c++) { i += u.charCodeAt(c); var p = 0.02519603282416938 * i; i = p >>> 0, p -= i, p *= i, i = p >>> 0, p -= i, i += p * 4294967296; } return (i >>> 0) * 23283064365386963e-26; }; return l; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.alea = s; })(b$, typeof Gv == "object" && Gv, typeof define == "function" && define); }); var _$ = Ut((k$, Uv) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.next = function() { var c = i.x ^ i.x << 11; return i.x = i.y, i.y = i.z, i.z = i.w, i.w ^= i.w >>> 19 ^ c ^ c >>> 8; }, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor128 = s; })(k$, typeof Uv == "object" && Uv, typeof define == "function" && define); }); var C$ = Ut((v$, Hv) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.x ^ i.x >>> 2; return i.x = i.y, i.y = i.z, i.z = i.w, i.w = i.v, (i.d = i.d + 362437 | 0) + (i.v = i.v ^ i.v << 4 ^ (c ^ c << 1)) | 0; }, i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.v = 0, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, u == l.length && (i.d = i.x << 10 ^ i.x >>> 4), i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i.v = a.v, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorwow = s; })(v$, typeof Hv == "object" && Hv, typeof define == "function" && define); }); var I$ = Ut((S$, qv) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.x, c = i.i, p, m, f; return p = u[c], p ^= p >>> 7, m = p ^ p << 24, p = u[c + 1 & 7], m ^= p ^ p >>> 10, p = u[c + 3 & 7], m ^= p ^ p >>> 3, p = u[c + 4 & 7], m ^= p ^ p << 7, p = u[c + 7 & 7], p = p ^ p << 13, m ^= p ^ p << 9, u[c] = m, i.i = c + 1 & 7, m; }; function l(u, c) { var p, m, f = []; if (c === (c | 0)) m = f[0] = c; else for (c = "" + c, p = 0; p < c.length; ++p) f[p & 7] = f[p & 7] << 15 ^ c.charCodeAt(p) + f[p + 1 & 7] << 13; for (; f.length < 8; ) f.push(0); for (p = 0; p < 8 && f[p] === 0; ++p) ; for (p == 8 ? m = f[7] = -1 : m = f[p], u.x = f, u.i = 0, p = 256; p > 0; --p) u.next(); } l(i, a); } function o(a, i) { return i.x = a.x.slice(), i.i = a.i, i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.x && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorshift7 = s; })(S$, typeof qv == "object" && qv, typeof define == "function" && define); }); var T$ = Ut((N$, Kv) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.w, c = i.X, p = i.i, m, f; return i.w = u = u + 1640531527 | 0, f = c[p + 34 & 127], m = c[p = p + 1 & 127], f ^= f << 13, m ^= m << 17, f ^= f >>> 15, m ^= m >>> 12, f = c[p] = f ^ m, i.i = p, f + (u ^ u >>> 16) | 0; }; function l(u, c) { var p, m, f, d, h, g = [], y = 128; for (c === (c | 0) ? (m = c, c = null) : (c = c + "\0", m = 0, y = Math.max(y, c.length)), f = 0, d = -32; d < y; ++d) c && (m ^= c.charCodeAt((d + 32) % c.length)), d === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, d >= 0 && (h = h + 1640531527 | 0, p = g[d & 127] ^= m + h, f = p == 0 ? f + 1 : 0); for (f >= 128 && (g[(c && c.length || 0) & 127] = -1), f = 127, d = 4 * 128; d > 0; --d) m = g[f + 34 & 127], p = g[f = f + 1 & 127], m ^= m << 13, p ^= p << 17, m ^= m >>> 15, p ^= p >>> 12, g[f] = m ^ p; u.w = h, u.X = g, u.i = f; } l(i, a); } function o(a, i) { return i.i = a.i, i.w = a.w, i.X = a.X.slice(), i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.X && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor4096 = s; })(N$, typeof Kv == "object" && Kv, typeof define == "function" && define); }); var A$ = Ut((E$, Xv) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.b, p = i.c, m = i.d, f = i.a; return c = c << 25 ^ c >>> 7 ^ p, p = p - m | 0, m = m << 24 ^ m >>> 8 ^ f, f = f - c | 0, i.b = c = c << 20 ^ c >>> 12 ^ p, i.c = p = p - m | 0, i.d = m << 16 ^ p >>> 16 ^ f, i.a = f - c | 0; }, i.a = 0, i.b = 0, i.c = 2654435769 | 0, i.d = 1367130551, a === Math.floor(a) ? (i.a = a / 4294967296 | 0, i.b = a | 0) : l += a; for (var u = 0; u < l.length + 20; u++) i.b ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.a = a.a, i.b = a.b, i.c = a.c, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.tychei = s; })(E$, typeof Xv == "object" && Xv, typeof define == "function" && define); }); var D$ = Ut(($$, Ex) => { (function(r, e, t) { var n = 256, o = 6, s = 52, a = "random", i = t.pow(n, o), l = t.pow(2, s), u = l * 2, c = n - 1, p; function m(x, k, C) { var A = []; k = k == true ? { entropy: true } : k || {}; var $ = g(h(k.entropy ? [x, w(e)] : x == null ? y() : x, 3), A), R = new f(A), P = function() { for (var M = R.g(o), V = i, W = 0; M < l; ) M = (M + W) * n, V *= n, W = R.g(1); for (; M >= u; ) M /= 2, V /= 2, W >>>= 1; return (M + W) / V; }; return P.int32 = function() { return R.g(4) | 0; }, P.quick = function() { return R.g(4) / 4294967296; }, P.double = P, g(w(R.S), e), (k.pass || C || function(M, V, W, G) { return G && (G.S && d(G, R), M.state = function() { return d(R, {}); }), W ? (t[a] = M, V) : M; })(P, $, "global" in k ? k.global : this == t, k.state); } function f(x) { var k, C = x.length, A = this, $ = 0, R = A.i = A.j = 0, P = A.S = []; for (C || (x = [C++]); $ < n; ) P[$] = $++; for ($ = 0; $ < n; $++) P[$] = P[R = c & R + x[$ % C] + (k = P[$])], P[R] = k; (A.g = function(M) { for (var V, W = 0, G = A.i, U = A.j, H = A.S; M--; ) V = H[G = c & G + 1], W = W * n + H[c & (H[G] = H[U = c & U + V]) + (H[U] = V)]; return A.i = G, A.j = U, W; })(n); } function d(x, k) { return k.i = x.i, k.j = x.j, k.S = x.S.slice(), k; } function h(x, k) { var C = [], A = typeof x, $; if (k && A == "object") for ($ in x) try { C.push(h(x[$], k - 1)); } catch (R) { } return C.length ? C : A == "string" ? x : x + "\0"; } function g(x, k) { for (var C = x + "", A, $ = 0; $ < C.length; ) k[c & $] = c & (A ^= k[c & $] * 19) + C.charCodeAt($++); return w(k); } function y() { try { var x; return p && (x = p.randomBytes) ? x = x(n) : (x = new Uint8Array(n), (r.crypto || r.msCrypto).getRandomValues(x)), w(x); } catch (A) { var k = r.navigator, C = k && k.plugins; return [+new Date(), r, C, r.screen, w(e)]; } } function w(x) { return String.fromCharCode.apply(0, x); } if (g(t.random(), e), typeof Ex == "object" && Ex.exports) { Ex.exports = m; try { p = qk(); } catch (x) { } } else typeof define == "function" && define.amd ? define(function() { return m; }) : t["seed" + a] = m; })(typeof self != "undefined" ? self : $$, [], Math); }); var Yv = Ut((Pet, R$) => { var d7 = w$(), h7 = _$(), g7 = C$(), x7 = I$(), y7 = T$(), b7 = A$(), Ou = D$(); Ou.alea = d7; Ou.xor128 = h7; Ou.xorwow = g7; Ou.xorshift7 = x7; Ou.xor4096 = y7; Ou.tychei = b7; R$.exports = Ou; }); var Zv = Ut(() => { }); var hm = Ut(() => { }); var qV = Ut(() => { }); var KV = Ut(() => { }); var XV = Ut((Oy, xI) => { var gI = function() { var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (r = r || __filename), function(e) { e = e || {}; function t() { return Q.buffer != Ue && ur(Q.buffer), pt; } function n() { return Q.buffer != Ue && ur(Q.buffer), ft; } function o() { return Q.buffer != Ue && ur(Q.buffer), Qt; } function s() { return Q.buffer != Ue && ur(Q.buffer), pn; } function a() { return Q.buffer != Ue && ur(Q.buffer), Zn; } var i = typeof e != "undefined" ? e : {}, l, u; i.ready = new Promise(function(N, D) { l = N, u = D; }); var c = {}, p; for (p in i) i.hasOwnProperty(p) && (c[p] = i[p]); var m = [], f = "./this.program", d = function(N, D) { throw D; }, h = false, g = false, y = false, w = false; h = typeof window == "object", g = typeof importScripts == "function", y = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", w = !h && !y && !g; var x = i.ENVIRONMENT_IS_PTHREAD || false; x && (Ue = i.buffer); var k = ""; function C(N) { return i.locateFile ? i.locateFile(N, k) : k + N; } var A, $, R, P, M, V; if (y) { g ? k = hm().dirname(k) + "/" : k = __dirname + "/", A = function(D, B) { return M || (M = pc("fs")), V || (V = hm()), D = V.normalize(D), M.readFileSync(D, B ? null : "utf8"); }, R = function(D) { var B = A(D, true); return B.buffer || (B = new Uint8Array(B)), fe(B.buffer), B; }, process.argv.length > 1 && (f = process.argv[1].replace(/\\/g, "/")), m = process.argv.slice(2), process.on("uncaughtException", function(N) { if (!(N instanceof Im)) throw N; }), process.on("unhandledRejection", Ci), d = function(N) { process.exit(N); }, i.inspect = function() { return "[Emscripten Module object]"; }; var W; try { W = qV(); } catch (N) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), N; } global.Worker = W.Worker; } else w ? (typeof read != "undefined" && (A = function(D) { return read(D); }), R = function(D) { var B; return typeof readbuffer == "function" ? new Uint8Array(readbuffer(D)) : (B = read(D, "binary"), fe(typeof B == "object"), B); }, typeof scriptArgs != "undefined" ? m = scriptArgs : typeof arguments != "undefined" && (m = arguments), typeof quit == "function" && (d = function(N) { quit(N); }), typeof print != "undefined" && (typeof console == "undefined" && (console = {}), console.log = print, console.warn = console.error = typeof printErr != "undefined" ? printErr : print)) : (h || g) && (g ? k = self.location.href : typeof document != "undefined" && document.currentScript && (k = document.currentScript.src), typeof r != "undefined" && r && (k = r), k.indexOf("blob:") !== 0 ? k = k.substr(0, k.lastIndexOf("/") + 1) : k = "", y ? (A = function(D, B) { return M || (M = pc("fs")), V || (V = hm()), D = V.normalize(D), M.readFileSync(D, B ? null : "utf8"); }, R = function(D) { var B = A(D, true); return B.buffer || (B = new Uint8Array(B)), fe(B.buffer), B; }) : (A = function(N) { var D = new XMLHttpRequest(); return D.open("GET", N, false), D.send(null), D.responseText; }, g && (R = function(N) { var D = new XMLHttpRequest(); return D.open("GET", N, false), D.responseType = "arraybuffer", D.send(null), new Uint8Array(D.response); }), $ = function(N, D, B) { var q = new XMLHttpRequest(); q.open("GET", N, true), q.responseType = "arraybuffer", q.onload = function() { if (q.status == 200 || q.status == 0 && q.response) { D(q.response); return; } B(); }, q.onerror = B, q.send(null); }), P = function(N) { document.title = N; }); y && typeof performance == "undefined" && (global.performance = KV().performance); var G = i.print || console.log.bind(console), U = i.printErr || console.warn.bind(console); for (p in c) c.hasOwnProperty(p) && (i[p] = c[p]); c = null, i.arguments && (m = i.arguments), i.thisProgram && (f = i.thisProgram), i.quit && (d = i.quit); var H = Atomics.load, K = Atomics.store, re = Atomics.compareExchange, X; i.wasmBinary && (X = i.wasmBinary); var ne = i.noExitRuntime || true; typeof WebAssembly != "object" && Ci("no native wasm support detected"); var Q, se, pe = false, ie; function fe(N, D) { N || Ci("Assertion failed: " + D); } function de(N) { var D = i["_" + N]; return fe(D, "Cannot call unknown function " + N + ", make sure it is exported"), D; } function ge(N, D, B, q, ye) { var he = { string: function(qr) { var cc = 0; if (qr != null && qr !== 0) { var RI = (qr.length << 2) + 1; cc = ac(RI), qe(qr, cc, RI); } return cc; }, array: function(qr) { var cc = ac(qr.length); return It(qr, cc), cc; } }; function xe(qr) { return D === "string" ? Ce(qr) : D === "boolean" ? Boolean(qr) : qr; } var Te = de(N), bt = [], kr = 0; if (q) for (var hr = 0; hr < q.length; hr++) { var qa = he[B[hr]]; qa ? (kr === 0 && (kr = Sm()), bt[hr] = qa(q[hr])) : bt[hr] = q[hr]; } var uc = Te.apply(null, bt); return uc = xe(uc), kr !== 0 && ic(kr), uc; } function we(N, D, B, q) { B = B || []; var ye = B.every(function(xe) { return xe === "number"; }), he = D !== "string"; return he && ye && !q ? de(N) : function() { return ge(N, D, B, arguments, q); }; } function $e(N, D, B) { for (var q = D + B, ye = ""; !(D >= q); ) { var he = N[D++]; if (!he) return ye; if (!(he & 128)) { ye += String.fromCharCode(he); continue; } var xe = N[D++] & 63; if ((he & 224) == 192) { ye += String.fromCharCode((he & 31) << 6 | xe); continue; } var Te = N[D++] & 63; if ((he & 240) == 224 ? he = (he & 15) << 12 | xe << 6 | Te : he = (he & 7) << 18 | xe << 12 | Te << 6 | N[D++] & 63, he < 65536) ye += String.fromCharCode(he); else { var bt = he - 65536; ye += String.fromCharCode(55296 | bt >> 10, 56320 | bt & 1023); } } return ye; } function Ce(N, D) { return N ? $e(n(), N, D) : ""; } function Be(N, D, B, q) { if (!(q > 0)) return 0; for (var ye = B, he = B + q - 1, xe = 0; xe < N.length; ++xe) { var Te = N.charCodeAt(xe); if (Te >= 55296 && Te <= 57343) { var bt = N.charCodeAt(++xe); Te = 65536 + ((Te & 1023) << 10) | bt & 1023; } if (Te <= 127) { if (B >= he) break; D[B++] = Te; } else if (Te <= 2047) { if (B + 1 >= he) break; D[B++] = 192 | Te >> 6, D[B++] = 128 | Te & 63; } else if (Te <= 65535) { if (B + 2 >= he) break; D[B++] = 224 | Te >> 12, D[B++] = 128 | Te >> 6 & 63, D[B++] = 128 | Te & 63; } else { if (B + 3 >= he) break; D[B++] = 240 | Te >> 18, D[B++] = 128 | Te >> 12 & 63, D[B++] = 128 | Te >> 6 & 63, D[B++] = 128 | Te & 63; } } return D[B] = 0, B - ye; } function qe(N, D, B) { return Be(N, n(), D, B); } function lt(N) { for (var D = 0, B = 0; B < N.length; ++B) { var q = N.charCodeAt(B); q >= 55296 && q <= 57343 && (q = 65536 + ((q & 1023) << 10) | N.charCodeAt(++B) & 1023), q <= 127 ? ++D : q <= 2047 ? D += 2 : q <= 65535 ? D += 3 : D += 4; } return D; } function It(N, D) { t().set(N, D); } function Nt(N, D) { return N % D > 0 && (N += D - N % D), N; } var Ue, pt, ft, Bt, In, Qt, pn, Br, Zn; function ur(N) { Ue = N, i.HEAP8 = pt = new Int8Array(N), i.HEAP16 = Bt = new Int16Array(N), i.HEAP32 = Qt = new Int32Array(N), i.HEAPU8 = ft = new Uint8Array(N), i.HEAPU16 = In = new Uint16Array(N), i.HEAPU32 = pn = new Uint32Array(N), i.HEAPF32 = Br = new Float32Array(N), i.HEAPF64 = Zn = new Float64Array(N); } var Nn = i.INITIAL_MEMORY || 16777216; if (x) Q = i.wasmMemory, Ue = i.buffer; else if (i.wasmMemory) Q = i.wasmMemory; else if (Q = new WebAssembly.Memory({ initial: Nn / 65536, maximum: 2147483648 / 65536, shared: true }), !(Q.buffer instanceof SharedArrayBuffer)) throw U("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"), y && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); Q && (Ue = Q.buffer), Nn = Ue.byteLength, ur(Ue); var Hr, wr = [], mn = [], zn = [], Ol = [], Wa = [], Ms = false, _i = false; x || mn.push({ func: function() { Bh(); } }); function gm() { if (!x) { if (i.preRun) for (typeof i.preRun == "function" && (i.preRun = [i.preRun]); i.preRun.length; ) Nh(i.preRun.shift()); rc(wr); } } function Pl() { Ms = true, !x && rc(mn); } function zy() { x || rc(zn); } function Ih() { x || (_i = true); } function fn() { if (!x) { if (i.postRun) for (typeof i.postRun == "function" && (i.postRun = [i.postRun]); i.postRun.length; ) By(i.postRun.shift()); rc(Wa); } } function Nh(N) { wr.unshift(N); } function By(N) { Wa.unshift(N); } var vi = 0, ja = null, Ml = null; function Vy(N) { fe(!x, "addRunDependency cannot be used in a pthread worker"), vi++, i.monitorRunDependencies && i.monitorRunDependencies(vi); } function Wy(N) { if (vi--, i.monitorRunDependencies && i.monitorRunDependencies(vi), vi == 0 && (ja !== null && (clearInterval(ja), ja = null), Ml)) { var D = Ml; Ml = null, D(); } } i.preloadedImages = {}, i.preloadedAudios = {}; function Ci(N) { i.onAbort && i.onAbort(N), x && console.error("Pthread aborting at " + new Error().stack), N += "", U(N), pe = true, ie = 1, N = "abort(" + N + "). Build with -s ASSERTIONS=1 for more info."; var D = new WebAssembly.RuntimeError(N); throw u(D), D; } function Th(N, D) { return String.prototype.startsWith ? N.startsWith(D) : N.indexOf(D) === 0; } var tc = "data:application/octet-stream;base64,"; function Eh(N) { return Th(N, tc); } var jy = "file://"; function Ah(N) { return Th(N, jy); } var dn = "tfjs-backend-wasm-threaded-simd.wasm"; Eh(dn) || (dn = C(dn)); function $h(N) { try { if (N == dn && X) return new Uint8Array(X); if (R) return R(N); throw "both async and sync fetching of the wasm failed"; } catch (D) { Ci(D); } } function Gy() { if (!X && (h || g)) { if (typeof fetch == "function" && !Ah(dn)) return fetch(dn, { credentials: "same-origin" }).then(function(N) { if (!N.ok) throw "failed to load wasm binary file at '" + dn + "'"; return N.arrayBuffer(); }).catch(function() { return $h(dn); }); if ($) return new Promise(function(N, D) { $(dn, function(B) { N(new Uint8Array(B)); }, D); }); } return Promise.resolve().then(function() { return $h(dn); }); } function Uy() { var N = { a: Ob }; function D(xe, Te) { var bt = xe.exports; if (i.asm = bt, Hr = i.asm.F, se = Te, !x) { var kr = Ee.unusedWorkers.length; Ee.unusedWorkers.forEach(function(hr) { Ee.loadWasmModuleToWorker(hr, function() { --kr || Wy("wasm-instantiate"); }); }); } } x || Vy("wasm-instantiate"); function B(xe) { D(xe.instance, xe.module); } function q(xe) { return Gy().then(function(Te) { return WebAssembly.instantiate(Te, N); }).then(xe, function(Te) { U("failed to asynchronously prepare wasm: " + Te), Ci(Te); }); } function ye() { return !X && typeof WebAssembly.instantiateStreaming == "function" && !Eh(dn) && !Ah(dn) && typeof fetch == "function" ? fetch(dn, { credentials: "same-origin" }).then(function(xe) { var Te = WebAssembly.instantiateStreaming(xe, N); return Te.then(B, function(bt) { return U("wasm streaming compile failed: " + bt), U("falling back to ArrayBuffer instantiation"), q(B); }); }) : q(B); } if (i.instantiateWasm) try { var he = i.instantiateWasm(N, D); return he; } catch (xe) { return U("Module.instantiateWasm callback failed with error: " + xe), false; } return ye().catch(u), {}; } var Hy = { 10024: function() { throw "Canceled!"; }, 10042: function(N, D) { setTimeout(function() { NI(N, D); }, 0); } }; function Dh() { Ee.initRuntime(); } function rc(N) { for (; N.length > 0; ) { var D = N.shift(); if (typeof D == "function") { D(i); continue; } var B = D.func; typeof B == "number" ? D.arg === void 0 ? Hr.get(B)() : Hr.get(B)(D.arg) : B(D.arg === void 0 ? null : D.arg); } } function xm(N, D) { if (N <= 0 || N > t().length || N & true || D < 0) return -28; if (D == 0) return 0; D >= 2147483647 && (D = 1 / 0); var B = Atomics.load(o(), lc >> 2), q = 0; if (B == N) { var ye = Atomics.compareExchange(o(), lc >> 2, B, 0); if (ye == B && (--D, q = 1, D <= 0)) return 1; } var he = Atomics.notify(o(), N >> 2, D); if (he >= 0) return he + q; throw "Atomics.notify returned an unexpected value " + he; } i._emscripten_futex_wake = xm; function qy(N) { if (x) throw "Internal Error! killThread() can only ever be called from main application thread!"; if (!N) throw "Internal Error! Null pthread_ptr in killThread!"; o()[N + 12 >> 2] = 0; var D = Ee.pthreads[N]; D.worker.terminate(), Ee.freeThreadData(D), Ee.runningWorkers.splice(Ee.runningWorkers.indexOf(D.worker), 1), D.worker.pthread = void 0; } function Ky(N) { if (x) throw "Internal Error! cancelThread() can only ever be called from main application thread!"; if (!N) throw "Internal Error! Null pthread_ptr in cancelThread!"; var D = Ee.pthreads[N]; D.worker.postMessage({ cmd: "cancel" }); } function Xy(N) { if (x) throw "Internal Error! cleanupThread() can only ever be called from main application thread!"; if (!N) throw "Internal Error! Null pthread_ptr in cleanupThread!"; var D = Ee.pthreads[N]; if (D) { o()[N + 12 >> 2] = 0; var B = D.worker; Ee.returnWorkerToPool(B); } } var Ee = { unusedWorkers: [], runningWorkers: [], initMainThreadBlock: function() { for (var N = Math.min(4, Math.max(1, (navigator.hardwareConcurrency || 1) / 2)), D = 0; D < N; ++D) Ee.allocateUnusedWorker(); }, initRuntime: function() { for (var N = zl(228), D = 0; D < 228 / 4; ++D) s()[N / 4 + D] = 0; o()[N + 12 >> 2] = N; var B = N + 152; o()[B >> 2] = B; for (var q = zl(512), D = 0; D < 128; ++D) s()[q / 4 + D] = 0; Atomics.store(s(), N + 100 >> 2, q), Atomics.store(s(), N + 40 >> 2, N), lw(N, !g, 1), II(N); }, initWorker: function() { }, pthreads: {}, threadExitHandlers: [], setThreadStatus: function() { }, runExitHandlers: function() { for (; Ee.threadExitHandlers.length > 0; ) Ee.threadExitHandlers.pop()(); x && sc() && SI(); }, runExitHandlersAndDeinitThread: function(N, D) { Atomics.store(s(), N + 56 >> 2, 1), Atomics.store(s(), N + 60 >> 2, 0), Ee.runExitHandlers(), Atomics.store(s(), N + 4 >> 2, D), Atomics.store(s(), N + 0 >> 2, 1), xm(N + 0, 2147483647), lw(0, 0, 0); }, threadExit: function(N) { var D = sc(); D && (Ee.runExitHandlersAndDeinitThread(D, N), x && postMessage({ cmd: "exit" })); }, threadCancel: function() { Ee.runExitHandlersAndDeinitThread(sc(), -1), postMessage({ cmd: "cancelDone" }); }, terminateAllThreads: function() { for (var N in Ee.pthreads) { var D = Ee.pthreads[N]; D && D.worker && Ee.returnWorkerToPool(D.worker); } Ee.pthreads = {}; for (var B = 0; B < Ee.unusedWorkers.length; ++B) { var q = Ee.unusedWorkers[B]; q.terminate(); } Ee.unusedWorkers = []; for (var B = 0; B < Ee.runningWorkers.length; ++B) { var q = Ee.runningWorkers[B], D = q.pthread; Ee.freeThreadData(D), q.terminate(); } Ee.runningWorkers = []; }, freeThreadData: function(N) { if (!!N) { if (N.threadInfoStruct) { var D = o()[N.threadInfoStruct + 100 >> 2]; o()[N.threadInfoStruct + 100 >> 2] = 0, Cm(D), Cm(N.threadInfoStruct); } N.threadInfoStruct = 0, N.allocatedOwnStack && N.stackBase && Cm(N.stackBase), N.stackBase = 0, N.worker && (N.worker.pthread = null); } }, returnWorkerToPool: function(N) { Ee.runWithoutMainThreadQueuedCalls(function() { delete Ee.pthreads[N.pthread.threadInfoStruct], Ee.unusedWorkers.push(N), Ee.runningWorkers.splice(Ee.runningWorkers.indexOf(N), 1), Ee.freeThreadData(N.pthread), N.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(N) { o()[DI >> 2] = 0; try { N(); } finally { o()[DI >> 2] = 1; } }, receiveObjectTransfer: function(N) { }, loadWasmModuleToWorker: function(N, D) { N.onmessage = function(B) { var q = B.data, ye = q.cmd; if (N.pthread && (Ee.currentProxiedOperationCallerThread = N.pthread.threadInfoStruct), q.targetThread && q.targetThread != sc()) { var he = Ee.pthreads[q.targetThread]; he ? he.worker.postMessage(B.data, q.transferList) : console.error('Internal error! Worker sent a message "' + ye + '" to target pthread ' + q.targetThread + ", but that thread no longer exists!"), Ee.currentProxiedOperationCallerThread = void 0; return; } if (ye === "processQueuedMainThreadWork") iw(); else if (ye === "spawnThread") Lh(B.data); else if (ye === "cleanupThread") Xy(q.thread); else if (ye === "killThread") qy(q.thread); else if (ye === "cancelThread") Ky(q.thread); else if (ye === "loaded") N.loaded = true, D && D(N), N.runPthread && (N.runPthread(), delete N.runPthread); else if (ye === "print") G("Thread " + q.threadId + ": " + q.text); else if (ye === "printErr") U("Thread " + q.threadId + ": " + q.text); else if (ye === "alert") alert("Thread " + q.threadId + ": " + q.text); else if (ye === "exit") { var xe = N.pthread && Atomics.load(s(), N.pthread.threadInfoStruct + 64 >> 2); xe && Ee.returnWorkerToPool(N); } else if (ye === "exitProcess") try { WW(q.returnCode); } catch (Te) { if (Te instanceof Im) return; throw Te; } else ye === "cancelDone" ? Ee.returnWorkerToPool(N) : ye === "objectTransfer" ? Ee.receiveObjectTransfer(B.data) : B.data.target === "setimmediate" ? N.postMessage(B.data) : U("worker sent an unknown command " + ye); Ee.currentProxiedOperationCallerThread = void 0; }, N.onerror = function(B) { U("pthread sent an error! " + B.filename + ":" + B.lineno + ": " + B.message); }, y && (N.on("message", function(B) { N.onmessage({ data: B }); }), N.on("error", function(B) { N.onerror(B); }), N.on("exit", function(B) { })), N.postMessage({ cmd: "load", urlOrBlob: i.mainScriptUrlOrBlob || r, wasmMemory: Q, wasmModule: se }); }, allocateUnusedWorker: function() { var N = C("tfjs-backend-wasm-threaded-simd.worker.js"); Ee.unusedWorkers.push(new Worker(N)); }, getNewWorker: function() { return Ee.unusedWorkers.length == 0 && (Ee.allocateUnusedWorker(), Ee.loadWasmModuleToWorker(Ee.unusedWorkers[0])), Ee.unusedWorkers.length > 0 ? Ee.unusedWorkers.pop() : null; }, busySpinWait: function(N) { for (var D = performance.now() + N; performance.now() < D; ) ; } }; function Yy(N, D) { AI(N, D), ic(N); } i.establishStackSpace = Yy; function Zy() { return ne; } i.getNoExitRuntime = Zy; function Jy(N, D) { return Hr.get(N)(D); } i.invokeEntryPoint = Jy; function Qy(N, D, B, q) { Ci("Assertion failed: " + Ce(N) + ", at: " + [D ? Ce(D) : "unknown filename", B, q ? Ce(q) : "unknown function"]); } function eb(N, D) { var B = _main(N, D); } var Ll; y ? Ll = function() { var N = process.hrtime(); return N[0] * 1e3 + N[1] / 1e6; } : x ? Ll = function() { return performance.now() - i.__performance_now_clock_drift; } : typeof dateNow != "undefined" ? Ll = dateNow : Ll = function() { return performance.now(); }; function tb(N) { return o()[vI() >> 2] = N, N; } function rb(N, D) { if (x) return Ga(1, 1, N, D); } function nb(N, D) { if (N == D) postMessage({ cmd: "processQueuedMainThreadWork" }); else if (x) postMessage({ targetThread: N, cmd: "processThreadQueue" }); else { var B = Ee.pthreads[N], q = B && B.worker; if (!q) return; q.postMessage({ cmd: "processThreadQueue" }); } return 1; } function ob() { Ci(); } function sb(N, D, B) { var q = cb(D, B); return Hy[N].apply(null, q); } function ib(N, D) { } function ab(N, D, B) { if (N <= 0 || N > t().length || N & true) return -28; if (h) { if (Atomics.load(o(), N >> 2) != D) return -6; for (var ye = performance.now(), he = ye + B, xe = Atomics.exchange(o(), lc >> 2, N); ; ) { if (ye = performance.now(), ye > he) return xe = Atomics.exchange(o(), lc >> 2, 0), -73; if (xe = Atomics.exchange(o(), lc >> 2, 0), xe == 0) break; if (iw(), Atomics.load(o(), N >> 2) != D) return -6; xe = Atomics.exchange(o(), lc >> 2, N); } return 0; } else { var q = Atomics.wait(o(), N >> 2, D, B); if (q === "timed-out") return -73; if (q === "not-equal") return -6; if (q === "ok") return 0; throw "Atomics.wait returned an unexpected value " + q; } } function lb(N, D, B) { n().copyWithin(N, D, D + B); } function ub() { return y ? pc("os").cpus().length : navigator.hardwareConcurrency; } function Ga(N, D) { for (var B = arguments.length - 2, q = Sm(), ye = B, he = ac(ye * 8), xe = he >> 3, Te = 0; Te < B; Te++) { var bt = arguments[2 + Te]; a()[xe + Te] = bt; } var kr = EI(N, ye, he, D); return ic(q), kr; } var ym = [], bm = []; function cb(N, D) { bm.length = 0; var B; for (D >>= 2; B = n()[N++]; ) { var q = B < 105; q && D & 1 && D++, bm.push(q ? a()[D++ >> 1] : o()[D]), ++D; } return bm; } function pb(N, D, B) { ym.length = D; for (var q = B >> 3, ye = 0; ye < D; ye++) ym[ye] = a()[q + ye]; var he = N < 0, xe = he ? Hy[-N - 1] : Fb[N]; return xe.apply(null, ym); } function mb() { return n().length; } function fb(N) { try { return Q.grow(N - Ue.byteLength + 65535 >>> 16), ur(Q.buffer), 1; } catch (D) { } } function db(N) { var D = mb(); if (N <= D) return false; var B = 2147483648; if (N > B) return false; for (var q = 1; q <= 4; q *= 2) { var ye = D * (1 + 0.2 / q); ye = Math.min(ye, N + 100663296); var he = Math.min(B, Nt(Math.max(N, ye), 65536)), xe = fb(he); if (xe) return true; } return false; } var Je = { inEventHandler: 0, removeAllEventListeners: function() { for (var N = Je.eventHandlers.length - 1; N >= 0; --N) Je._removeHandler(N); Je.eventHandlers = [], Je.deferredCalls = []; }, registerRemoveEventListeners: function() { Je.removeEventListenersRegistered || (Ol.push(Je.removeAllEventListeners), Je.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(N, D, B) { function q(xe, Te) { if (xe.length != Te.length) return false; for (var bt in xe) if (xe[bt] != Te[bt]) return false; return true; } for (var ye in Je.deferredCalls) { var he = Je.deferredCalls[ye]; if (he.targetFunction == N && q(he.argsList, B)) return; } Je.deferredCalls.push({ targetFunction: N, precedence: D, argsList: B }), Je.deferredCalls.sort(function(xe, Te) { return xe.precedence < Te.precedence; }); }, removeDeferredCalls: function(N) { for (var D = 0; D < Je.deferredCalls.length; ++D) Je.deferredCalls[D].targetFunction == N && (Je.deferredCalls.splice(D, 1), --D); }, canPerformEventHandlerRequests: function() { return Je.inEventHandler && Je.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { if (!!Je.canPerformEventHandlerRequests()) for (var N = 0; N < Je.deferredCalls.length; ++N) { var D = Je.deferredCalls[N]; Je.deferredCalls.splice(N, 1), --N, D.targetFunction.apply(null, D.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(N, D) { for (var B = 0; B < Je.eventHandlers.length; ++B) Je.eventHandlers[B].target == N && (!D || D == Je.eventHandlers[B].eventTypeString) && Je._removeHandler(B--); }, _removeHandler: function(N) { var D = Je.eventHandlers[N]; D.target.removeEventListener(D.eventTypeString, D.eventListenerFunc, D.useCapture), Je.eventHandlers.splice(N, 1); }, registerOrRemoveHandler: function(N) { var D = function(ye) { ++Je.inEventHandler, Je.currentEventHandler = N, Je.runDeferredCalls(), N.handlerFunc(ye), Je.runDeferredCalls(), --Je.inEventHandler; }; if (N.callbackfunc) N.eventListenerFunc = D, N.target.addEventListener(N.eventTypeString, D, N.useCapture), Je.eventHandlers.push(N), Je.registerRemoveEventListeners(); else for (var B = 0; B < Je.eventHandlers.length; ++B) Je.eventHandlers[B].target == N.target && Je.eventHandlers[B].eventTypeString == N.eventTypeString && Je._removeHandler(B--); }, queueEventHandlerOnThread_iiii: function(N, D, B, q, ye) { var he = Sm(), xe = ac(12); o()[xe >> 2] = B, o()[xe + 4 >> 2] = q, o()[xe + 8 >> 2] = ye, aw(0, N, 637534208, D, q, xe), ic(he); }, getTargetThreadForEventCallback: function(N) { switch (N) { case 1: return 0; case 2: return Ee.currentProxiedOperationCallerThread; default: return N; } }, getNodeNameForTarget: function(N) { return N ? N == window ? "#window" : N == screen ? "#screen" : N && N.nodeName ? N.nodeName : "" : ""; }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; function hb(N) { var D = lt(N) + 1, B = zl(D); return qe(N, B, D), B; } function gb(N, D, B, q) { var ye = Sm(), he = ac(12), xe = 0; D && (xe = hb(D)), o()[he >> 2] = xe, o()[he + 4 >> 2] = B, o()[he + 8 >> 2] = q, aw(0, N, 657457152, 0, xe, he), ic(ye); } function xb(N, D, B, q) { D = D ? Ce(D) : "", gb(N, D, B, q); } function yb(N) { return N > 2 ? Ce(N) : N; } var bb = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; function wb(N) { N = yb(N); var D = bb[N] || (typeof document != "undefined" ? document.querySelector(N) : void 0); return D; } function wm(N) { return wb(N); } function Rh(N, D, B) { var q = wm(N); if (!q) return -4; if (q.canvasSharedPtr && (o()[q.canvasSharedPtr >> 2] = D, o()[q.canvasSharedPtr + 4 >> 2] = B), q.offscreenCanvas || !q.controlTransferredOffscreen) { q.offscreenCanvas && (q = q.offscreenCanvas); var ye = false; if (q.GLctxObject && q.GLctxObject.GLctx) { var he = q.GLctxObject.GLctx.getParameter(2978); ye = he[0] === 0 && he[1] === 0 && he[2] === q.width && he[3] === q.height; } q.width = D, q.height = B, ye && q.GLctxObject.GLctx.viewport(0, 0, D, B); } else if (q.canvasSharedPtr) { var xe = o()[q.canvasSharedPtr + 8 >> 2]; return xb(xe, N, D, B), 1; } else return -4; return 0; } function Fh(N, D, B) { return x ? Ga(2, 1, N, D, B) : Rh(N, D, B); } function kb(N, D, B) { var q = wm(N); return q ? Rh(N, D, B) : Fh(N, D, B); } function _b(N) { } function vb(N, D) { } function Cb(N) { var D = N.getExtension("ANGLE_instanced_arrays"); if (D) return N.vertexAttribDivisor = function(B, q) { D.vertexAttribDivisorANGLE(B, q); }, N.drawArraysInstanced = function(B, q, ye, he) { D.drawArraysInstancedANGLE(B, q, ye, he); }, N.drawElementsInstanced = function(B, q, ye, he, xe) { D.drawElementsInstancedANGLE(B, q, ye, he, xe); }, 1; } function Sb(N) { var D = N.getExtension("OES_vertex_array_object"); if (D) return N.createVertexArray = function() { return D.createVertexArrayOES(); }, N.deleteVertexArray = function(B) { D.deleteVertexArrayOES(B); }, N.bindVertexArray = function(B) { D.bindVertexArrayOES(B); }, N.isVertexArray = function(B) { return D.isVertexArrayOES(B); }, 1; } function Ib(N) { var D = N.getExtension("WEBGL_draw_buffers"); if (D) return N.drawBuffers = function(B, q) { D.drawBuffersWEBGL(B, q); }, 1; } function Nb(N) { return !!(N.multiDrawWebgl = N.getExtension("WEBGL_multi_draw")); } var dt = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], uniforms: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, timerQueriesEXT: [], programInfos: {}, stringCache: {}, unpackAlignment: 4, recordError: function(D) { dt.lastError || (dt.lastError = D); }, getNewId: function(N) { for (var D = dt.counter++, B = N.length; B < D; B++) N[B] = null; return D; }, getSource: function(N, D, B, q) { for (var ye = "", he = 0; he < D; ++he) { var xe = q ? o()[q + he * 4 >> 2] : -1; ye += Ce(o()[B + he * 4 >> 2], xe < 0 ? void 0 : xe); } return ye; }, createContext: function(N, D) { var B = N.getContext("webgl", D); if (!B) return 0; var q = dt.registerContext(B, D); return q; }, registerContext: function(N, D) { var B = zl(8); o()[B + 4 >> 2] = sc(); var q = { handle: B, attributes: D, version: D.majorVersion, GLctx: N }; return N.canvas && (N.canvas.GLctxObject = q), dt.contexts[B] = q, (typeof D.enableExtensionsByDefault == "undefined" || D.enableExtensionsByDefault) && dt.initExtensions(q), B; }, makeContextCurrent: function(N) { return dt.currentContext = dt.contexts[N], i.ctx = Ua = dt.currentContext && dt.currentContext.GLctx, !(N && !Ua); }, getContext: function(N) { return dt.contexts[N]; }, deleteContext: function(N) { dt.currentContext === dt.contexts[N] && (dt.currentContext = null), typeof Je == "object" && Je.removeAllHandlersOnTarget(dt.contexts[N].GLctx.canvas), dt.contexts[N] && dt.contexts[N].GLctx.canvas && (dt.contexts[N].GLctx.canvas.GLctxObject = void 0), Cm(dt.contexts[N].handle), dt.contexts[N] = null; }, initExtensions: function(N) { if (N || (N = dt.currentContext), !N.initExtensionsDone) { N.initExtensionsDone = true; var D = N.GLctx; Cb(D), Sb(D), Ib(D), D.disjointTimerQueryExt = D.getExtension("EXT_disjoint_timer_query"), Nb(D); var B = D.getSupportedExtensions() || []; B.forEach(function(q) { q.indexOf("lose_context") < 0 && q.indexOf("debug") < 0 && D.getExtension(q); }); } }, populateUniformTable: function(N) { for (var D = dt.programs[N], B = dt.programInfos[N] = { uniforms: {}, maxUniformLength: 0, maxAttributeLength: -1, maxUniformBlockNameLength: -1 }, q = B.uniforms, ye = Ua.getProgramParameter(D, 35718), he = 0; he < ye; ++he) { var xe = Ua.getActiveUniform(D, he), Te = xe.name; B.maxUniformLength = Math.max(B.maxUniformLength, Te.length + 1), Te.slice(-1) == "]" && (Te = Te.slice(0, Te.lastIndexOf("["))); var bt = Ua.getUniformLocation(D, Te); if (bt) { var kr = dt.getNewId(dt.uniforms); q[Te] = [xe.size, kr], dt.uniforms[kr] = bt; for (var hr = 1; hr < xe.size; ++hr) { var qa = Te + "[" + hr + "]"; bt = Ua.getUniformLocation(D, qa), kr = dt.getNewId(dt.uniforms), dt.uniforms[kr] = bt; } } } } }, Tb = ["default", "low-power", "high-performance"]; function Eb(N, D) { var B = D >> 2, q = o()[B + (24 >> 2)], ye = { alpha: !!o()[B + (0 >> 2)], depth: !!o()[B + (4 >> 2)], stencil: !!o()[B + (8 >> 2)], antialias: !!o()[B + (12 >> 2)], premultipliedAlpha: !!o()[B + (16 >> 2)], preserveDrawingBuffer: !!o()[B + (20 >> 2)], powerPreference: Tb[q], failIfMajorPerformanceCaveat: !!o()[B + (28 >> 2)], majorVersion: o()[B + (32 >> 2)], minorVersion: o()[B + (36 >> 2)], enableExtensionsByDefault: o()[B + (40 >> 2)], explicitSwapControl: o()[B + (44 >> 2)], proxyContextToMainThread: o()[B + (48 >> 2)], renderViaOffscreenBackBuffer: o()[B + (52 >> 2)] }, he = wm(N); if (!he || ye.explicitSwapControl) return 0; var xe = dt.createContext(he, ye); return xe; } function Ab(N, D) { return Eb(N, D); } var nc = { mappings: {}, buffers: [null, [], []], printChar: function(N, D) { var B = nc.buffers[N]; D === 0 || D === 10 ? ((N === 1 ? G : U)($e(B, 0)), B.length = 0) : B.push(D); }, varargs: void 0, get: function() { nc.varargs += 4; var N = o()[nc.varargs - 4 >> 2]; return N; }, getStr: function(N) { var D = Ce(N); return D; }, get64: function(N, D) { return N; } }; function Oh(N) { return x ? Ga(3, 1, N) : 0; } function Ph(N, D, B, q, ye) { if (x) return Ga(4, 1, N, D, B, q, ye); } function Mh(N, D, B, q) { if (x) return Ga(5, 1, N, D, B, q); for (var ye = 0, he = 0; he < B; he++) { for (var xe = o()[D + he * 8 >> 2], Te = o()[D + (he * 8 + 4) >> 2], bt = 0; bt < Te; bt++) nc.printChar(N, n()[xe + bt]); ye += Te; } return o()[q >> 2] = ye, 0; } function $b(N) { var D = Ee.threadExitHandlers.pop(); N && D(); } function Db(N, D) { Ee.threadExitHandlers.push(function() { Hr.get(N)(D); }); } function Lh(N) { if (x) throw "Internal Error! spawnThread() can only ever be called from main application thread!"; var D = Ee.getNewWorker(); if (D.pthread !== void 0) throw "Internal error!"; if (!N.pthread_ptr) throw "Internal error, no pthread ptr!"; Ee.runningWorkers.push(D); for (var B = zl(128 * 4), q = 0; q < 128; ++q) o()[B + q * 4 >> 2] = 0; var ye = N.stackBase + N.stackSize, he = Ee.pthreads[N.pthread_ptr] = { worker: D, stackBase: N.stackBase, stackSize: N.stackSize, allocatedOwnStack: N.allocatedOwnStack, threadInfoStruct: N.pthread_ptr }, xe = he.threadInfoStruct >> 2; Atomics.store(s(), xe + (64 >> 2), N.detached), Atomics.store(s(), xe + (100 >> 2), B), Atomics.store(s(), xe + (40 >> 2), he.threadInfoStruct), Atomics.store(s(), xe + (80 >> 2), N.stackSize), Atomics.store(s(), xe + (76 >> 2), ye), Atomics.store(s(), xe + (104 >> 2), N.stackSize), Atomics.store(s(), xe + (104 + 8 >> 2), ye), Atomics.store(s(), xe + (104 + 12 >> 2), N.detached); var Te = CI(), bt = Te + 40; Atomics.store(s(), xe + (172 >> 2), bt), D.pthread = he; var kr = { cmd: "run", start_routine: N.startRoutine, arg: N.arg, threadInfoStruct: N.pthread_ptr, stackBase: N.stackBase, stackSize: N.stackSize }; D.runPthread = function() { kr.time = performance.now(), D.postMessage(kr, N.transferList); }, D.loaded && (D.runPthread(), delete D.runPthread); } function Rb(N, D, B, q) { if (typeof SharedArrayBuffer == "undefined") return U("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; if (!N) return U("pthread_create called with a null thread pointer!"), 28; var ye = [], he = 0; if (x && (ye.length === 0 || he)) return TI(687865856, N, D, B, q); if (he) return he; var xe = 0, Te = 0, bt = 0; D && D != -1 ? (xe = o()[D >> 2], xe += 81920, Te = o()[D + 8 >> 2], bt = o()[D + 12 >> 2] !== 0) : xe = 2097152; var kr = Te == 0; kr ? Te = $I(16, xe) : (Te -= xe, fe(Te > 0)); for (var hr = zl(228), qa = 0; qa < 228 >> 2; ++qa) s()[(hr >> 2) + qa] = 0; o()[N >> 2] = hr, o()[hr + 12 >> 2] = hr; var uc = hr + 152; o()[uc >> 2] = uc; var qr = { stackBase: Te, stackSize: xe, allocatedOwnStack: kr, detached: bt, startRoutine: B, pthread_ptr: hr, arg: q, transferList: ye }; return x ? (qr.cmd = "spawnThread", postMessage(qr, ye)) : Lh(qr), 0; } function zh(N) { if (x) return Ga(6, 1, N); switch (N) { case 30: return 16384; case 85: var D = 2147483648; return D / 16384; case 132: case 133: case 12: case 137: case 138: case 15: case 235: case 16: case 17: case 18: case 19: case 20: case 149: case 13: case 10: case 236: case 153: case 9: case 21: case 22: case 159: case 154: case 14: case 77: case 78: case 139: case 82: case 68: case 67: case 164: case 11: case 29: case 47: case 48: case 95: case 52: case 51: case 46: return 200809; case 27: case 246: case 127: case 128: case 23: case 24: case 160: case 161: case 181: case 182: case 242: case 183: case 184: case 243: case 244: case 245: case 165: case 178: case 179: case 49: case 50: case 168: case 169: case 175: case 170: case 171: case 172: case 97: case 76: case 32: case 173: case 35: case 80: case 81: case 79: return -1; case 176: case 177: case 7: case 155: case 8: case 157: case 125: case 126: case 92: case 93: case 129: case 130: case 131: case 94: case 91: return 1; case 74: case 60: case 69: case 70: case 4: return 1024; case 31: case 42: case 72: return 32; case 87: case 26: case 33: return 2147483647; case 34: case 1: return 47839; case 38: case 36: return 99; case 43: case 37: return 2048; case 0: return 2097152; case 3: return 65536; case 28: return 32768; case 44: return 32767; case 75: return 16384; case 39: return 1e3; case 89: return 700; case 71: return 256; case 40: return 255; case 2: return 100; case 180: return 64; case 25: return 20; case 5: return 16; case 6: return 6; case 73: return 4; case 84: return typeof navigator == "object" && navigator.hardwareConcurrency || 1; } return tb(28), -1; } x || Ee.initMainThreadBlock(); var Ua, Fb = [null, rb, Fh, Oh, Ph, Mh, zh], Ob = { e: Qy, r: eb, x: nb, b: ob, y: sb, j: ib, c: ab, d: xm, f: Ll, p: lb, z: ub, u: pb, q: db, v: kb, i: _b, t: vb, w: Ab, m: Oh, n: Ph, g: Mh, o: Dh, a: Q || i.wasmMemory, k: $b, l: Db, h: Rb, s: zh }, _I = Uy(), Bh = i.___wasm_call_ctors = function() { return (Bh = i.___wasm_call_ctors = i.asm.A).apply(null, arguments); }, Pb = i._init = function() { return (Pb = i._init = i.asm.B).apply(null, arguments); }, Mb = i._register_tensor = function() { return (Mb = i._register_tensor = i.asm.C).apply(null, arguments); }, Lb = i._dispose_data = function() { return (Lb = i._dispose_data = i.asm.D).apply(null, arguments); }, zb = i._dispose = function() { return (zb = i._dispose = i.asm.E).apply(null, arguments); }, Bb = i._Abs = function() { return (Bb = i._Abs = i.asm.G).apply(null, arguments); }, Vb = i._Add = function() { return (Vb = i._Add = i.asm.H).apply(null, arguments); }, Wb = i._AddN = function() { return (Wb = i._AddN = i.asm.I).apply(null, arguments); }, jb = i._All = function() { return (jb = i._All = i.asm.J).apply(null, arguments); }, Gb = i._Any = function() { return (Gb = i._Any = i.asm.K).apply(null, arguments); }, Ub = i._ArgMax = function() { return (Ub = i._ArgMax = i.asm.L).apply(null, arguments); }, Hb = i._AvgPool = function() { return (Hb = i._AvgPool = i.asm.M).apply(null, arguments); }, qb = i._BatchMatMul = function() { return (qb = i._BatchMatMul = i.asm.N).apply(null, arguments); }, Kb = i._Ceil = function() { return (Kb = i._Ceil = i.asm.O).apply(null, arguments); }, Xb = i._ClipByValue = function() { return (Xb = i._ClipByValue = i.asm.P).apply(null, arguments); }, Yb = i._Conv2D = function() { return (Yb = i._Conv2D = i.asm.Q).apply(null, arguments); }, Zb = i._Conv2DBackpropInput = function() { return (Zb = i._Conv2DBackpropInput = i.asm.R).apply(null, arguments); }, Jb = i._Cos = function() { return (Jb = i._Cos = i.asm.S).apply(null, arguments); }, Qb = i._Cosh = function() { return (Qb = i._Cosh = i.asm.T).apply(null, arguments); }, ew = i._CropAndResize = function() { return (ew = i._CropAndResize = i.asm.U).apply(null, arguments); }, tw = i._Cumsum = function() { return (tw = i._Cumsum = i.asm.V).apply(null, arguments); }, rw = i._DepthToSpace = function() { return (rw = i._DepthToSpace = i.asm.W).apply(null, arguments); }, nw = i._DepthwiseConv2dNative = function() { return (nw = i._DepthwiseConv2dNative = i.asm.X).apply(null, arguments); }, ow = i._Elu = function() { return (ow = i._Elu = i.asm.Y).apply(null, arguments); }, Vh = i._Equal = function() { return (Vh = i._Equal = i.asm.Z).apply(null, arguments); }, Wh = i._Exp = function() { return (Wh = i._Exp = i.asm._).apply(null, arguments); }, jh = i._FlipLeftRight = function() { return (jh = i._FlipLeftRight = i.asm.$).apply(null, arguments); }, km = i._Floor = function() { return (km = i._Floor = i.asm.aa).apply(null, arguments); }, oc = i._FloorDiv = function() { return (oc = i._FloorDiv = i.asm.ba).apply(null, arguments); }, sw = i._FusedBatchNorm = function() { return (sw = i._FusedBatchNorm = i.asm.ca).apply(null, arguments); }, _m = i._FusedConv2D = function() { return (_m = i._FusedConv2D = i.asm.da).apply(null, arguments); }, Z = i._FusedDepthwiseConv2D = function() { return (Z = i._FusedDepthwiseConv2D = i.asm.ea).apply(null, arguments); }, oe = i._Gather = function() { return (oe = i._Gather = i.asm.fa).apply(null, arguments); }, ve = i._GatherNd = function() { return (ve = i._GatherNd = i.asm.ga).apply(null, arguments); }, ut = i._Greater = function() { return (ut = i._Greater = i.asm.ha).apply(null, arguments); }, er = i._GreaterEqual = function() { return (er = i._GreaterEqual = i.asm.ia).apply(null, arguments); }, Gt = i._LeakyRelu = function() { return (Gt = i._LeakyRelu = i.asm.ja).apply(null, arguments); }, et = i._Less = function() { return (et = i._Less = i.asm.ka).apply(null, arguments); }, rt = i._LessEqual = function() { return (rt = i._LessEqual = i.asm.la).apply(null, arguments); }, Er = i._Log = function() { return (Er = i._Log = i.asm.ma).apply(null, arguments); }, Si = i._LogicalAnd = function() { return (Si = i._LogicalAnd = i.asm.na).apply(null, arguments); }, Ii = i._Max = function() { return (Ii = i._Max = i.asm.oa).apply(null, arguments); }, Gh = i._MaxPool = function() { return (Gh = i._MaxPool = i.asm.pa).apply(null, arguments); }, vm = i._Maximum = function() { return (vm = i._Maximum = i.asm.qa).apply(null, arguments); }, Tn = i._Mean = function() { return (Tn = i._Mean = i.asm.ra).apply(null, arguments); }, Ha = i._Min = function() { return (Ha = i._Min = i.asm.sa).apply(null, arguments); }, Uh = i._Minimum = function() { return (Uh = i._Minimum = i.asm.ta).apply(null, arguments); }, tW = i._MirrorPad = function() { return (tW = i._MirrorPad = i.asm.ua).apply(null, arguments); }, rW = i._Multiply = function() { return (rW = i._Multiply = i.asm.va).apply(null, arguments); }, nW = i._Neg = function() { return (nW = i._Neg = i.asm.wa).apply(null, arguments); }, oW = i._NonMaxSuppressionV3 = function() { return (oW = i._NonMaxSuppressionV3 = i.asm.xa).apply(null, arguments); }, sW = i._NonMaxSuppressionV4 = function() { return (sW = i._NonMaxSuppressionV4 = i.asm.ya).apply(null, arguments); }, iW = i._NonMaxSuppressionV5 = function() { return (iW = i._NonMaxSuppressionV5 = i.asm.za).apply(null, arguments); }, aW = i._NotEqual = function() { return (aW = i._NotEqual = i.asm.Aa).apply(null, arguments); }, lW = i._OneHot = function() { return (lW = i._OneHot = i.asm.Ba).apply(null, arguments); }, uW = i._PadV2 = function() { return (uW = i._PadV2 = i.asm.Ca).apply(null, arguments); }, cW = i._Pow = function() { return (cW = i._Pow = i.asm.Da).apply(null, arguments); }, pW = i._Prelu = function() { return (pW = i._Prelu = i.asm.Ea).apply(null, arguments); }, mW = i._Prod = function() { return (mW = i._Prod = i.asm.Fa).apply(null, arguments); }, fW = i._RealDiv = function() { return (fW = i._RealDiv = i.asm.Ga).apply(null, arguments); }, dW = i._Relu = function() { return (dW = i._Relu = i.asm.Ha).apply(null, arguments); }, hW = i._Relu6 = function() { return (hW = i._Relu6 = i.asm.Ia).apply(null, arguments); }, gW = i._ResizeBilinear = function() { return (gW = i._ResizeBilinear = i.asm.Ja).apply(null, arguments); }, xW = i._Reverse = function() { return (xW = i._Reverse = i.asm.Ka).apply(null, arguments); }, yW = i._RotateWithOffset = function() { return (yW = i._RotateWithOffset = i.asm.La).apply(null, arguments); }, bW = i._Round = function() { return (bW = i._Round = i.asm.Ma).apply(null, arguments); }, wW = i._Rsqrt = function() { return (wW = i._Rsqrt = i.asm.Na).apply(null, arguments); }, kW = i._ScatterNd = function() { return (kW = i._ScatterNd = i.asm.Oa).apply(null, arguments); }, _W = i._SelectV2 = function() { return (_W = i._SelectV2 = i.asm.Pa).apply(null, arguments); }, vW = i._Sigmoid = function() { return (vW = i._Sigmoid = i.asm.Qa).apply(null, arguments); }, CW = i._Sin = function() { return (CW = i._Sin = i.asm.Ra).apply(null, arguments); }, SW = i._Softmax = function() { return (SW = i._Softmax = i.asm.Sa).apply(null, arguments); }, IW = i._Sqrt = function() { return (IW = i._Sqrt = i.asm.Ta).apply(null, arguments); }, NW = i._Square = function() { return (NW = i._Square = i.asm.Ua).apply(null, arguments); }, TW = i._SquaredDifference = function() { return (TW = i._SquaredDifference = i.asm.Va).apply(null, arguments); }, EW = i._Step = function() { return (EW = i._Step = i.asm.Wa).apply(null, arguments); }, AW = i._StridedSlice = function() { return (AW = i._StridedSlice = i.asm.Xa).apply(null, arguments); }, $W = i._Sub = function() { return ($W = i._Sub = i.asm.Ya).apply(null, arguments); }, DW = i._Sum = function() { return (DW = i._Sum = i.asm.Za).apply(null, arguments); }, RW = i._Tan = function() { return (RW = i._Tan = i.asm._a).apply(null, arguments); }, FW = i._Tanh = function() { return (FW = i._Tanh = i.asm.$a).apply(null, arguments); }, OW = i._Tile = function() { return (OW = i._Tile = i.asm.ab).apply(null, arguments); }, PW = i._TopK = function() { return (PW = i._TopK = i.asm.bb).apply(null, arguments); }, MW = i._Transform = function() { return (MW = i._Transform = i.asm.cb).apply(null, arguments); }, LW = i._Transpose = function() { return (LW = i._Transpose = i.asm.db).apply(null, arguments); }, zW = i.__FusedMatMul = function() { return (zW = i.__FusedMatMul = i.asm.eb).apply(null, arguments); }, zl = i._malloc = function() { return (zl = i._malloc = i.asm.fb).apply(null, arguments); }, Cm = i._free = function() { return (Cm = i._free = i.asm.gb).apply(null, arguments); }, vI = i.___errno_location = function() { return (vI = i.___errno_location = i.asm.hb).apply(null, arguments); }, CI = i._emscripten_get_global_libc = function() { return (CI = i._emscripten_get_global_libc = i.asm.ib).apply(null, arguments); }, sc = i._pthread_self = function() { return (sc = i._pthread_self = i.asm.jb).apply(null, arguments); }, SI = i.___pthread_tsd_run_dtors = function() { return (SI = i.___pthread_tsd_run_dtors = i.asm.kb).apply(null, arguments); }, iw = i._emscripten_main_thread_process_queued_calls = function() { return (iw = i._emscripten_main_thread_process_queued_calls = i.asm.lb).apply(null, arguments); }, BW = i._emscripten_current_thread_process_queued_calls = function() { return (BW = i._emscripten_current_thread_process_queued_calls = i.asm.mb).apply(null, arguments); }, II = i._emscripten_register_main_browser_thread_id = function() { return (II = i._emscripten_register_main_browser_thread_id = i.asm.nb).apply(null, arguments); }, NI = i.__emscripten_do_dispatch_to_thread = function() { return (NI = i.__emscripten_do_dispatch_to_thread = i.asm.ob).apply(null, arguments); }, TI = i._emscripten_sync_run_in_main_thread_4 = function() { return (TI = i._emscripten_sync_run_in_main_thread_4 = i.asm.pb).apply(null, arguments); }, EI = i._emscripten_run_in_main_runtime_thread_js = function() { return (EI = i._emscripten_run_in_main_runtime_thread_js = i.asm.qb).apply(null, arguments); }, aw = i.__emscripten_call_on_thread = function() { return (aw = i.__emscripten_call_on_thread = i.asm.rb).apply(null, arguments); }, VW = i._emscripten_tls_init = function() { return (VW = i._emscripten_tls_init = i.asm.sb).apply(null, arguments); }, lw = i.__emscripten_thread_init = function() { return (lw = i.__emscripten_thread_init = i.asm.tb).apply(null, arguments); }, Sm = i.stackSave = function() { return (Sm = i.stackSave = i.asm.ub).apply(null, arguments); }, ic = i.stackRestore = function() { return (ic = i.stackRestore = i.asm.vb).apply(null, arguments); }, ac = i.stackAlloc = function() { return (ac = i.stackAlloc = i.asm.wb).apply(null, arguments); }, AI = i._emscripten_stack_set_limits = function() { return (AI = i._emscripten_stack_set_limits = i.asm.xb).apply(null, arguments); }, $I = i._memalign = function() { return ($I = i._memalign = i.asm.yb).apply(null, arguments); }, DI = i.__emscripten_allow_main_runtime_queued_calls = 10016, lc = i.__emscripten_main_thread_futex = 11652; i.cwrap = we, i.PThread = Ee, i.PThread = Ee, i.wasmMemory = Q, i.ExitStatus = Im; var Hh; function Im(N) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + N + ")", this.status = N; } Ml = function N() { Hh || uw(), Hh || (Ml = N); }; function uw(N) { if (N = N || m, vi > 0) return; if (x) { l(i), Pl(), postMessage({ cmd: "loaded" }); return; } if (gm(), vi > 0) return; function D() { Hh || (Hh = true, i.calledRun = true, !pe && (Pl(), zy(), l(i), i.onRuntimeInitialized && i.onRuntimeInitialized(), fn())); } i.setStatus ? (i.setStatus("Running..."), setTimeout(function() { setTimeout(function() { i.setStatus(""); }, 1), D(); }, 1)) : D(); } i.run = uw; function WW(N, D) { if (!(D && ne && N === 0)) { if (!D && x) throw postMessage({ cmd: "exitProcess", returnCode: N }), new Im(N); ne || (Ee.terminateAllThreads(), ie = N, Ih(), i.onExit && i.onExit(N), pe = true), d(N, new Im(N)); } } if (i.preInit) for (typeof i.preInit == "function" && (i.preInit = [i.preInit]); i.preInit.length > 0; ) i.preInit.pop()(); return x && (ne = false, Ee.initWorker()), uw(), e.ready; }; }(); typeof Oy == "object" && typeof xI == "object" ? xI.exports = gI : typeof define == "function" && define.amd ? define([], function() { return gI; }) : typeof Oy == "object" && (Oy.WasmBackendModuleThreadedSimd = gI); }); var ZV = Ut((Py, bI) => { var yI = function() { var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (r = r || __filename), function(e) { e = e || {}; var t = typeof e != "undefined" ? e : {}, n, o; t.ready = new Promise(function(Z, oe) { n = Z, o = oe; }); var s = {}, a; for (a in t) t.hasOwnProperty(a) && (s[a] = t[a]); var i = [], l = "./this.program", u = function(Z, oe) { throw oe; }, c = false, p = false, m = false, f = false; c = typeof window == "object", p = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", f = !c && !m && !p; var d = ""; function h(Z) { return t.locateFile ? t.locateFile(Z, d) : d + Z; } var g, y, w, x, k, C; m ? (p ? d = hm().dirname(d) + "/" : d = __dirname + "/", g = function(oe, ve) { return k || (k = pc("fs")), C || (C = hm()), oe = C.normalize(oe), k.readFileSync(oe, ve ? null : "utf8"); }, w = function(oe) { var ve = g(oe, true); return ve.buffer || (ve = new Uint8Array(ve)), G(ve.buffer), ve; }, process.argv.length > 1 && (l = process.argv[1].replace(/\\/g, "/")), i = process.argv.slice(2), process.on("uncaughtException", function(Z) { if (!(Z instanceof sw)) throw Z; }), process.on("unhandledRejection", Ms), u = function(Z) { process.exit(Z); }, t.inspect = function() { return "[Emscripten Module object]"; }) : f ? (typeof read != "undefined" && (g = function(oe) { return read(oe); }), w = function(oe) { var ve; return typeof readbuffer == "function" ? new Uint8Array(readbuffer(oe)) : (ve = read(oe, "binary"), G(typeof ve == "object"), ve); }, typeof scriptArgs != "undefined" ? i = scriptArgs : typeof arguments != "undefined" && (i = arguments), typeof quit == "function" && (u = function(Z) { quit(Z); }), typeof print != "undefined" && (typeof console == "undefined" && (console = {}), console.log = print, console.warn = console.error = typeof printErr != "undefined" ? printErr : print)) : (c || p) && (p ? d = self.location.href : typeof document != "undefined" && document.currentScript && (d = document.currentScript.src), r && (d = r), d.indexOf("blob:") !== 0 ? d = d.substr(0, d.lastIndexOf("/") + 1) : d = "", g = function(Z) { var oe = new XMLHttpRequest(); return oe.open("GET", Z, false), oe.send(null), oe.responseText; }, p && (w = function(Z) { var oe = new XMLHttpRequest(); return oe.open("GET", Z, false), oe.responseType = "arraybuffer", oe.send(null), new Uint8Array(oe.response); }), y = function(Z, oe, ve) { var ut = new XMLHttpRequest(); ut.open("GET", Z, true), ut.responseType = "arraybuffer", ut.onload = function() { if (ut.status == 200 || ut.status == 0 && ut.response) { oe(ut.response); return; } ve(); }, ut.onerror = ve, ut.send(null); }, x = function(Z) { document.title = Z; }); var A = t.print || console.log.bind(console), $ = t.printErr || console.warn.bind(console); for (a in s) s.hasOwnProperty(a) && (t[a] = s[a]); s = null, t.arguments && (i = t.arguments), t.thisProgram && (l = t.thisProgram), t.quit && (u = t.quit); var R; t.wasmBinary && (R = t.wasmBinary); var P = t.noExitRuntime || true; typeof WebAssembly != "object" && Ms("no native wasm support detected"); var M, V = false, W; function G(Z, oe) { Z || Ms("Assertion failed: " + oe); } function U(Z) { var oe = t["_" + Z]; return G(oe, "Cannot call unknown function " + Z + ", make sure it is exported"), oe; } function H(Z, oe, ve, ut, er) { var Gt = { string: function(Tn) { var Ha = 0; if (Tn != null && Tn !== 0) { var Uh = (Tn.length << 2) + 1; Ha = km(Uh), se(Tn, Ha, Uh); } return Ha; }, array: function(Tn) { var Ha = km(Tn.length); return pe(Tn, Ha), Ha; } }; function et(Tn) { return oe === "string" ? ne(Tn) : oe === "boolean" ? Boolean(Tn) : Tn; } var rt = U(Z), Er = [], Si = 0; if (ut) for (var Ii = 0; Ii < ut.length; Ii++) { var Gh = Gt[ve[Ii]]; Gh ? (Si === 0 && (Si = Wh()), Er[Ii] = Gh(ut[Ii])) : Er[Ii] = ut[Ii]; } var vm = rt.apply(null, Er); return vm = et(vm), Si !== 0 && jh(Si), vm; } function K(Z, oe, ve, ut) { ve = ve || []; var er = ve.every(function(et) { return et === "number"; }), Gt = oe !== "string"; return Gt && er && !ut ? U(Z) : function() { return H(Z, oe, ve, arguments, ut); }; } var re = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; function X(Z, oe, ve) { for (var ut = oe + ve, er = oe; Z[er] && !(er >= ut); ) ++er; if (er - oe > 16 && Z.subarray && re) return re.decode(Z.subarray(oe, er)); for (var Gt = ""; oe < er; ) { var et = Z[oe++]; if (!(et & 128)) { Gt += String.fromCharCode(et); continue; } var rt = Z[oe++] & 63; if ((et & 224) == 192) { Gt += String.fromCharCode((et & 31) << 6 | rt); continue; } var Er = Z[oe++] & 63; if ((et & 240) == 224 ? et = (et & 15) << 12 | rt << 6 | Er : et = (et & 7) << 18 | rt << 12 | Er << 6 | Z[oe++] & 63, et < 65536) Gt += String.fromCharCode(et); else { var Si = et - 65536; Gt += String.fromCharCode(55296 | Si >> 10, 56320 | Si & 1023); } } return Gt; } function ne(Z, oe) { return Z ? X(ge, Z, oe) : ""; } function Q(Z, oe, ve, ut) { if (!(ut > 0)) return 0; for (var er = ve, Gt = ve + ut - 1, et = 0; et < Z.length; ++et) { var rt = Z.charCodeAt(et); if (rt >= 55296 && rt <= 57343) { var Er = Z.charCodeAt(++et); rt = 65536 + ((rt & 1023) << 10) | Er & 1023; } if (rt <= 127) { if (ve >= Gt) break; oe[ve++] = rt; } else if (rt <= 2047) { if (ve + 1 >= Gt) break; oe[ve++] = 192 | rt >> 6, oe[ve++] = 128 | rt & 63; } else if (rt <= 65535) { if (ve + 2 >= Gt) break; oe[ve++] = 224 | rt >> 12, oe[ve++] = 128 | rt >> 6 & 63, oe[ve++] = 128 | rt & 63; } else { if (ve + 3 >= Gt) break; oe[ve++] = 240 | rt >> 18, oe[ve++] = 128 | rt >> 12 & 63, oe[ve++] = 128 | rt >> 6 & 63, oe[ve++] = 128 | rt & 63; } } return oe[ve] = 0, ve - er; } function se(Z, oe, ve) { return Q(Z, ge, oe, ve); } function pe(Z, oe) { de.set(Z, oe); } function ie(Z, oe) { return Z % oe > 0 && (Z += oe - Z % oe), Z; } var fe, de, ge, we, $e, Ce, Be, qe, lt; function It(Z) { fe = Z, t.HEAP8 = de = new Int8Array(Z), t.HEAP16 = we = new Int16Array(Z), t.HEAP32 = Ce = new Int32Array(Z), t.HEAPU8 = ge = new Uint8Array(Z), t.HEAPU16 = $e = new Uint16Array(Z), t.HEAPU32 = Be = new Uint32Array(Z), t.HEAPF32 = qe = new Float32Array(Z), t.HEAPF64 = lt = new Float64Array(Z); } var Nt = t.INITIAL_MEMORY || 16777216, Ue, pt = [], ft = [], Bt = [], In = [], Qt = false; ft.push({ func: function() { Dh(); } }); function pn() { if (t.preRun) for (typeof t.preRun == "function" && (t.preRun = [t.preRun]); t.preRun.length; ) Nn(t.preRun.shift()); ja(pt); } function Br() { Qt = true, ja(ft); } function Zn() { ja(Bt); } function ur() { if (t.postRun) for (typeof t.postRun == "function" && (t.postRun = [t.postRun]); t.postRun.length; ) Hr(t.postRun.shift()); ja(In); } function Nn(Z) { pt.unshift(Z); } function Hr(Z) { In.unshift(Z); } var wr = 0, mn = null, zn = null; function Ol(Z) { wr++, t.monitorRunDependencies && t.monitorRunDependencies(wr); } function Wa(Z) { if (wr--, t.monitorRunDependencies && t.monitorRunDependencies(wr), wr == 0 && (mn !== null && (clearInterval(mn), mn = null), zn)) { var oe = zn; zn = null, oe(); } } t.preloadedImages = {}, t.preloadedAudios = {}; function Ms(Z) { t.onAbort && t.onAbort(Z), Z += "", $(Z), V = true, W = 1, Z = "abort(" + Z + "). Build with -s ASSERTIONS=1 for more info."; var oe = new WebAssembly.RuntimeError(Z); throw o(oe), oe; } function _i(Z, oe) { return String.prototype.startsWith ? Z.startsWith(oe) : Z.indexOf(oe) === 0; } var gm = "data:application/octet-stream;base64,"; function Pl(Z) { return _i(Z, gm); } var zy = "file://"; function Ih(Z) { return _i(Z, zy); } var fn = "tfjs-backend-wasm.wasm"; Pl(fn) || (fn = h(fn)); function Nh(Z) { try { if (Z == fn && R) return new Uint8Array(R); if (w) return w(Z); throw "both async and sync fetching of the wasm failed"; } catch (oe) { Ms(oe); } } function By() { if (!R && (c || p)) { if (typeof fetch == "function" && !Ih(fn)) return fetch(fn, { credentials: "same-origin" }).then(function(Z) { if (!Z.ok) throw "failed to load wasm binary file at '" + fn + "'"; return Z.arrayBuffer(); }).catch(function() { return Nh(fn); }); if (y) return new Promise(function(Z, oe) { y(fn, function(ve) { Z(new Uint8Array(ve)); }, oe); }); } return Promise.resolve().then(function() { return Nh(fn); }); } function vi() { var Z = { a: Uy }; function oe(et, rt) { var Er = et.exports; t.asm = Er, M = t.asm.i, It(M.buffer), Ue = t.asm.o, Wa("wasm-instantiate"); } Ol("wasm-instantiate"); function ve(et) { oe(et.instance); } function ut(et) { return By().then(function(rt) { return WebAssembly.instantiate(rt, Z); }).then(et, function(rt) { $("failed to asynchronously prepare wasm: " + rt), Ms(rt); }); } function er() { return !R && typeof WebAssembly.instantiateStreaming == "function" && !Pl(fn) && !Ih(fn) && typeof fetch == "function" ? fetch(fn, { credentials: "same-origin" }).then(function(et) { var rt = WebAssembly.instantiateStreaming(et, Z); return rt.then(ve, function(Er) { return $("wasm streaming compile failed: " + Er), $("falling back to ArrayBuffer instantiation"), ut(ve); }); }) : ut(ve); } if (t.instantiateWasm) try { var Gt = t.instantiateWasm(Z, oe); return Gt; } catch (et) { return $("Module.instantiateWasm callback failed with error: " + et), false; } return er().catch(o), {}; } function ja(Z) { for (; Z.length > 0; ) { var oe = Z.shift(); if (typeof oe == "function") { oe(t); continue; } var ve = oe.func; typeof ve == "number" ? oe.arg === void 0 ? Ue.get(ve)() : Ue.get(ve)(oe.arg) : ve(oe.arg === void 0 ? null : oe.arg); } } function Ml() { Ms(); } function Vy(Z, oe, ve) { ge.copyWithin(Z, oe, oe + ve); } function Wy() { return ge.length; } function Ci(Z) { try { return M.grow(Z - fe.byteLength + 65535 >>> 16), It(M.buffer), 1; } catch (oe) { } } function Th(Z) { var oe = Wy(), ve = 2147483648; if (Z > ve) return false; for (var ut = 1; ut <= 4; ut *= 2) { var er = oe * (1 + 0.2 / ut); er = Math.min(er, Z + 100663296); var Gt = Math.min(ve, ie(Math.max(Z, er), 65536)), et = Ci(Gt); if (et) return true; } return false; } var tc = { mappings: {}, buffers: [null, [], []], printChar: function(Z, oe) { var ve = tc.buffers[Z]; oe === 0 || oe === 10 ? ((Z === 1 ? A : $)(X(ve, 0)), ve.length = 0) : ve.push(oe); }, varargs: void 0, get: function() { tc.varargs += 4; var Z = Ce[tc.varargs - 4 >> 2]; return Z; }, getStr: function(Z) { var oe = ne(Z); return oe; }, get64: function(Z, oe) { return Z; } }; function Eh(Z) { return 0; } function jy(Z, oe, ve, ut, er) { } function Ah(Z, oe, ve, ut) { for (var er = 0, Gt = 0; Gt < ve; Gt++) { for (var et = Ce[oe + Gt * 8 >> 2], rt = Ce[oe + (Gt * 8 + 4) >> 2], Er = 0; Er < rt; Er++) tc.printChar(Z, ge[et + Er]); er += rt; } return Ce[ut >> 2] = er, 0; } function dn() { return 6; } function $h(Z) { return Ce[Vh() >> 2] = Z, Z; } function Gy(Z) { switch (Z) { case 30: return 16384; case 85: var oe = 2147483648; return oe / 16384; case 132: case 133: case 12: case 137: case 138: case 15: case 235: case 16: case 17: case 18: case 19: case 20: case 149: case 13: case 10: case 236: case 153: case 9: case 21: case 22: case 159: case 154: case 14: case 77: case 78: case 139: case 82: case 68: case 67: case 164: case 11: case 29: case 47: case 48: case 95: case 52: case 51: case 46: return 200809; case 27: case 246: case 127: case 128: case 23: case 24: case 160: case 161: case 181: case 182: case 242: case 183: case 184: case 243: case 244: case 245: case 165: case 178: case 179: case 49: case 50: case 168: case 169: case 175: case 170: case 171: case 172: case 97: case 76: case 32: case 173: case 35: case 80: case 81: case 79: return -1; case 176: case 177: case 7: case 155: case 8: case 157: case 125: case 126: case 92: case 93: case 129: case 130: case 131: case 94: case 91: return 1; case 74: case 60: case 69: case 70: case 4: return 1024; case 31: case 42: case 72: return 32; case 87: case 26: case 33: return 2147483647; case 34: case 1: return 47839; case 38: case 36: return 99; case 43: case 37: return 2048; case 0: return 2097152; case 3: return 65536; case 28: return 32768; case 44: return 32767; case 75: return 16384; case 39: return 1e3; case 89: return 700; case 71: return 256; case 40: return 255; case 2: return 100; case 180: return 64; case 25: return 20; case 5: return 16; case 6: return 6; case 73: return 4; case 84: return typeof navigator == "object" && navigator.hardwareConcurrency || 1; } return $h(28), -1; } var Uy = { a: Ml, d: Vy, e: Th, f: Eh, c: jy, b: Ah, g: dn, h: Gy }, Hy = vi(), Dh = t.___wasm_call_ctors = function() { return (Dh = t.___wasm_call_ctors = t.asm.j).apply(null, arguments); }, rc = t._init = function() { return (rc = t._init = t.asm.k).apply(null, arguments); }, xm = t._register_tensor = function() { return (xm = t._register_tensor = t.asm.l).apply(null, arguments); }, qy = t._dispose_data = function() { return (qy = t._dispose_data = t.asm.m).apply(null, arguments); }, Ky = t._dispose = function() { return (Ky = t._dispose = t.asm.n).apply(null, arguments); }, Xy = t._Abs = function() { return (Xy = t._Abs = t.asm.p).apply(null, arguments); }, Ee = t._Add = function() { return (Ee = t._Add = t.asm.q).apply(null, arguments); }, Yy = t._AddN = function() { return (Yy = t._AddN = t.asm.r).apply(null, arguments); }, Zy = t._All = function() { return (Zy = t._All = t.asm.s).apply(null, arguments); }, Jy = t._Any = function() { return (Jy = t._Any = t.asm.t).apply(null, arguments); }, Qy = t._ArgMax = function() { return (Qy = t._ArgMax = t.asm.u).apply(null, arguments); }, eb = t._AvgPool = function() { return (eb = t._AvgPool = t.asm.v).apply(null, arguments); }, Ll = t._BatchMatMul = function() { return (Ll = t._BatchMatMul = t.asm.w).apply(null, arguments); }, tb = t._Ceil = function() { return (tb = t._Ceil = t.asm.x).apply(null, arguments); }, rb = t._ClipByValue = function() { return (rb = t._ClipByValue = t.asm.y).apply(null, arguments); }, nb = t._Conv2D = function() { return (nb = t._Conv2D = t.asm.z).apply(null, arguments); }, ob = t._Conv2DBackpropInput = function() { return (ob = t._Conv2DBackpropInput = t.asm.A).apply(null, arguments); }, sb = t._Cos = function() { return (sb = t._Cos = t.asm.B).apply(null, arguments); }, ib = t._Cosh = function() { return (ib = t._Cosh = t.asm.C).apply(null, arguments); }, ab = t._CropAndResize = function() { return (ab = t._CropAndResize = t.asm.D).apply(null, arguments); }, lb = t._Cumsum = function() { return (lb = t._Cumsum = t.asm.E).apply(null, arguments); }, ub = t._DepthToSpace = function() { return (ub = t._DepthToSpace = t.asm.F).apply(null, arguments); }, Ga = t._DepthwiseConv2dNative = function() { return (Ga = t._DepthwiseConv2dNative = t.asm.G).apply(null, arguments); }, ym = t._Elu = function() { return (ym = t._Elu = t.asm.H).apply(null, arguments); }, bm = t._Equal = function() { return (bm = t._Equal = t.asm.I).apply(null, arguments); }, cb = t._Exp = function() { return (cb = t._Exp = t.asm.J).apply(null, arguments); }, pb = t._FlipLeftRight = function() { return (pb = t._FlipLeftRight = t.asm.K).apply(null, arguments); }, mb = t._Floor = function() { return (mb = t._Floor = t.asm.L).apply(null, arguments); }, fb = t._FloorDiv = function() { return (fb = t._FloorDiv = t.asm.M).apply(null, arguments); }, db = t._FusedBatchNorm = function() { return (db = t._FusedBatchNorm = t.asm.N).apply(null, arguments); }, Je = t._FusedConv2D = function() { return (Je = t._FusedConv2D = t.asm.O).apply(null, arguments); }, hb = t._FusedDepthwiseConv2D = function() { return (hb = t._FusedDepthwiseConv2D = t.asm.P).apply(null, arguments); }, gb = t._Gather = function() { return (gb = t._Gather = t.asm.Q).apply(null, arguments); }, xb = t._GatherNd = function() { return (xb = t._GatherNd = t.asm.R).apply(null, arguments); }, yb = t._Greater = function() { return (yb = t._Greater = t.asm.S).apply(null, arguments); }, bb = t._GreaterEqual = function() { return (bb = t._GreaterEqual = t.asm.T).apply(null, arguments); }, wb = t._LeakyRelu = function() { return (wb = t._LeakyRelu = t.asm.U).apply(null, arguments); }, wm = t._Less = function() { return (wm = t._Less = t.asm.V).apply(null, arguments); }, Rh = t._LessEqual = function() { return (Rh = t._LessEqual = t.asm.W).apply(null, arguments); }, Fh = t._Log = function() { return (Fh = t._Log = t.asm.X).apply(null, arguments); }, kb = t._LogicalAnd = function() { return (kb = t._LogicalAnd = t.asm.Y).apply(null, arguments); }, _b = t._Max = function() { return (_b = t._Max = t.asm.Z).apply(null, arguments); }, vb = t._MaxPool = function() { return (vb = t._MaxPool = t.asm._).apply(null, arguments); }, Cb = t._Maximum = function() { return (Cb = t._Maximum = t.asm.$).apply(null, arguments); }, Sb = t._Mean = function() { return (Sb = t._Mean = t.asm.aa).apply(null, arguments); }, Ib = t._Min = function() { return (Ib = t._Min = t.asm.ba).apply(null, arguments); }, Nb = t._Minimum = function() { return (Nb = t._Minimum = t.asm.ca).apply(null, arguments); }, dt = t._MirrorPad = function() { return (dt = t._MirrorPad = t.asm.da).apply(null, arguments); }, Tb = t._Multiply = function() { return (Tb = t._Multiply = t.asm.ea).apply(null, arguments); }, Eb = t._Neg = function() { return (Eb = t._Neg = t.asm.fa).apply(null, arguments); }, Ab = t._NonMaxSuppressionV3 = function() { return (Ab = t._NonMaxSuppressionV3 = t.asm.ga).apply(null, arguments); }, nc = t._NonMaxSuppressionV4 = function() { return (nc = t._NonMaxSuppressionV4 = t.asm.ha).apply(null, arguments); }, Oh = t._NonMaxSuppressionV5 = function() { return (Oh = t._NonMaxSuppressionV5 = t.asm.ia).apply(null, arguments); }, Ph = t._NotEqual = function() { return (Ph = t._NotEqual = t.asm.ja).apply(null, arguments); }, Mh = t._OneHot = function() { return (Mh = t._OneHot = t.asm.ka).apply(null, arguments); }, $b = t._PadV2 = function() { return ($b = t._PadV2 = t.asm.la).apply(null, arguments); }, Db = t._Pow = function() { return (Db = t._Pow = t.asm.ma).apply(null, arguments); }, Lh = t._Prelu = function() { return (Lh = t._Prelu = t.asm.na).apply(null, arguments); }, Rb = t._Prod = function() { return (Rb = t._Prod = t.asm.oa).apply(null, arguments); }, zh = t._RealDiv = function() { return (zh = t._RealDiv = t.asm.pa).apply(null, arguments); }, Ua = t._Relu = function() { return (Ua = t._Relu = t.asm.qa).apply(null, arguments); }, Fb = t._Relu6 = function() { return (Fb = t._Relu6 = t.asm.ra).apply(null, arguments); }, Ob = t._ResizeBilinear = function() { return (Ob = t._ResizeBilinear = t.asm.sa).apply(null, arguments); }, _I = t._Reverse = function() { return (_I = t._Reverse = t.asm.ta).apply(null, arguments); }, Bh = t._RotateWithOffset = function() { return (Bh = t._RotateWithOffset = t.asm.ua).apply(null, arguments); }, Pb = t._Round = function() { return (Pb = t._Round = t.asm.va).apply(null, arguments); }, Mb = t._Rsqrt = function() { return (Mb = t._Rsqrt = t.asm.wa).apply(null, arguments); }, Lb = t._ScatterNd = function() { return (Lb = t._ScatterNd = t.asm.xa).apply(null, arguments); }, zb = t._SelectV2 = function() { return (zb = t._SelectV2 = t.asm.ya).apply(null, arguments); }, Bb = t._Sigmoid = function() { return (Bb = t._Sigmoid = t.asm.za).apply(null, arguments); }, Vb = t._Sin = function() { return (Vb = t._Sin = t.asm.Aa).apply(null, arguments); }, Wb = t._Softmax = function() { return (Wb = t._Softmax = t.asm.Ba).apply(null, arguments); }, jb = t._Sqrt = function() { return (jb = t._Sqrt = t.asm.Ca).apply(null, arguments); }, Gb = t._Square = function() { return (Gb = t._Square = t.asm.Da).apply(null, arguments); }, Ub = t._SquaredDifference = function() { return (Ub = t._SquaredDifference = t.asm.Ea).apply(null, arguments); }, Hb = t._Step = function() { return (Hb = t._Step = t.asm.Fa).apply(null, arguments); }, qb = t._StridedSlice = function() { return (qb = t._StridedSlice = t.asm.Ga).apply(null, arguments); }, Kb = t._Sub = function() { return (Kb = t._Sub = t.asm.Ha).apply(null, arguments); }, Xb = t._Sum = function() { return (Xb = t._Sum = t.asm.Ia).apply(null, arguments); }, Yb = t._Tan = function() { return (Yb = t._Tan = t.asm.Ja).apply(null, arguments); }, Zb = t._Tanh = function() { return (Zb = t._Tanh = t.asm.Ka).apply(null, arguments); }, Jb = t._Tile = function() { return (Jb = t._Tile = t.asm.La).apply(null, arguments); }, Qb = t._TopK = function() { return (Qb = t._TopK = t.asm.Ma).apply(null, arguments); }, ew = t._Transform = function() { return (ew = t._Transform = t.asm.Na).apply(null, arguments); }, tw = t._Transpose = function() { return (tw = t._Transpose = t.asm.Oa).apply(null, arguments); }, rw = t.__FusedMatMul = function() { return (rw = t.__FusedMatMul = t.asm.Pa).apply(null, arguments); }, nw = t._malloc = function() { return (nw = t._malloc = t.asm.Qa).apply(null, arguments); }, ow = t._free = function() { return (ow = t._free = t.asm.Ra).apply(null, arguments); }, Vh = t.___errno_location = function() { return (Vh = t.___errno_location = t.asm.Sa).apply(null, arguments); }, Wh = t.stackSave = function() { return (Wh = t.stackSave = t.asm.Ta).apply(null, arguments); }, jh = t.stackRestore = function() { return (jh = t.stackRestore = t.asm.Ua).apply(null, arguments); }, km = t.stackAlloc = function() { return (km = t.stackAlloc = t.asm.Va).apply(null, arguments); }; t.cwrap = K; var oc; function sw(Z) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + Z + ")", this.status = Z; } zn = function Z() { oc || _m(), oc || (zn = Z); }; function _m(Z) { if (Z = Z || i, wr > 0 || (pn(), wr > 0)) return; function oe() { oc || (oc = true, t.calledRun = true, !V && (Br(), Zn(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), ur())); } t.setStatus ? (t.setStatus("Running..."), setTimeout(function() { setTimeout(function() { t.setStatus(""); }, 1), oe(); }, 1)) : oe(); } if (t.run = _m, t.preInit) for (typeof t.preInit == "function" && (t.preInit = [t.preInit]); t.preInit.length > 0; ) t.preInit.pop()(); return _m(), e.ready; }; }(); typeof Py == "object" && typeof bI == "object" ? bI.exports = yI : typeof define == "function" && define.amd ? define([], function() { return yI; }) : typeof Py == "object" && (Py.WasmBackendModule = yI); }); var OI = "3.9.0"; var PI = "3.9.0"; var MI = "3.9.0"; var LI = "3.9.0"; var zI = "3.9.0"; var BI = "3.9.0"; var VI = "3.9.0"; var WI = "3.9.0"; var nj = 1e-7; var oj = 1e-4; var Ka = class { 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; } }; var Ls = class { refCount(e) { return Jn("refCount"); } incRef(e) { return Jn("incRef"); } timerAvailable() { return true; } time(e) { return Jn("time"); } read(e) { return Jn("read"); } readSync(e) { return Jn("readSync"); } numDataIds() { return Jn("numDataIds"); } disposeData(e, t) { return Jn("disposeData"); } write(e, t, n) { return Jn("write"); } move(e, t, n, o, s) { return Jn("move"); } memory() { return Jn("memory"); } floatPrecision() { return Jn("floatPrecision"); } epsilon() { return this.floatPrecision() === 32 ? nj : oj; } dispose() { return Jn("dispose"); } }; function Jn(r) { throw new Error(`'${r}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`); } function jI(r) { let e = r.length, t = 0; for (; e > 0; ) t = Math.random() * e | 0, e--, Kh(r, e, t); } function sj(r, e) { if (r.length !== e.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${r.length}Second array length was ${e.length}`); let t = r.length, n = 0; for (; t > 0; ) n = Math.random() * t | 0, t--, Kh(r, t, n), Kh(e, t, n); } function mc(r, e, t) { return Math.max(r, Math.min(e, t)); } function ij(r) { return r % 2 == 0 ? r : r + 1; } function Kh(r, e, t) { let n = r[e]; r[e] = r[t], r[t] = n; } function aj(r) { let e = 0; for (let t = 0; t < r.length; t++) e += r[t]; return e; } function lj(r, e) { let t = Math.random(); return e * t + (1 - t) * r; } function uj(r, e) { let t = 0; for (let n = 0; n < r.length; n++) { let o = Number(r[n]) - Number(e[n]); t += o * o; } return t; } function E(r, e) { if (!r) throw new Error(typeof e == "string" ? e : e()); } function $t(r, e, t = "") { E(Kr(r, e), () => t + ` Shapes ${r} and ${e} must match`); } function Bn(r) { E(r != null, () => "The input to the tensor constructor must be a non-null value."); } function vo(r, e = [], t = false) { if (e == null && (e = []), Array.isArray(r) || cr(r) && !t) for (let n = 0; n < r.length; ++n) vo(r[n], e, t); else e.push(r); return e; } function nt(r) { if (r.length === 0) return 1; let e = r[0]; for (let t = 1; t < r.length; t++) e *= r[t]; return e; } function cj(r) { return r.length === 0; } function Kr(r, e) { if (r === e) return true; if (r == null || e == null || r.length !== e.length) return false; for (let t = 0; t < r.length; t++) if (r[t] !== e[t]) return false; return true; } function ot(r) { return r % 1 == 0; } function pj(r) { if (Math.tanh != null) return Math.tanh(r); if (r === 1 / 0) return 1; if (r === -1 / 0) return -1; { let e = Math.exp(2 * r); return (e - 1) / (e + 1); } } function mj(r) { let e = Math.ceil(Math.sqrt(r)); return [e, Math.ceil(r / e)]; } function fj(r) { let e = new Uint32Array(r); for (let t = 0; t < r; ++t) e[t] = t; return jI(e), e; } function Vl(r, e) { return e <= r.length ? r : r + " ".repeat(e - r.length); } function dj(r, e = (n) => 0, t) { return new Promise((n, o) => { let s = 0, a = () => { if (r()) { n(); return; } s++; let i = e(s); if (t != null && s >= t) { o(); return; } setTimeout(a, i); }; a(); }); } function hj(r, e) { let t = 1, n = -1; for (let s = 0; s < r.length; ++s) if (r[s] >= 0) t *= r[s]; else if (r[s] === -1) { if (n !== -1) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${s}`); n = s; } else if (r[s] < 0) throw Error(`Shapes can not be < 0. Found ${r[s]} at dim ${s}`); if (n === -1) { if (e > 0 && e !== t) throw Error(`Size(${e}) must match the product of shape ${r}`); return r; } if (t === 0) throw Error(`Cannot infer the missing size in [${r}] when there are 0 elements`); if (e % t != 0) throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`); let o = r.slice(); return o[n] = e / t, o; } function ir(r, e) { let t = e.length; return r = r == null ? e.map((n, o) => o) : [].concat(r), E(r.every((n) => n >= -t && n < t), () => `All values in axis param must be in range [-${t}, ${t}) but got axis ${r}`), E(r.every((n) => ot(n)), () => `All values in axis param must be integers but got axis ${r}`), r.map((n) => n < 0 ? t + n : n); } function cw(r, e) { let t = [], n = [], o = e != null && Array.isArray(e) && e.length === 0, s = e == null || o ? null : ir(e, r).sort(), a = 0; for (let i = 0; i < r.length; ++i) { if (s != null) { if (s[a] === i && r[i] !== 1) throw new Error(`Can't squeeze axis ${i} since its dim '${r[i]}' is not 1`); (s[a] == null || s[a] > i) && r[i] === 1 && (t.push(r[i]), n.push(i)), s[a] <= i && a++; } r[i] !== 1 && (t.push(r[i]), n.push(i)); } return { newShape: t, keptDims: n }; } function pw(r, e) { let t = null; if (r == null || r === "float32") t = new Float32Array(e); else if (r === "int32") t = new Int32Array(e); else if (r === "bool") t = new Uint8Array(e); else throw new Error(`Unknown data type ${r}`); return t; } function mw(r, e) { let t = null; if (r == null || r === "float32") t = new Float32Array(e); else if (r === "int32") t = new Int32Array(e); else if (r === "bool") t = new Uint8Array(e); else if (r === "string") t = new Array(e); else throw new Error(`Unknown data type ${r}`); return t; } function fw(r, e) { for (let t = 0; t < r.length; t++) { let n = r[t]; if (isNaN(n) || !isFinite(n)) throw Error(`A tensor of type ${e} being uploaded contains ${n}.`); } } function dw(r) { return r === "bool" || r === "complex64" || r === "float32" || r === "int32" || r === "string"; } function gj(r, e) { return !(e === "complex64" || e === "float32" && r !== "complex64" || e === "int32" && r !== "float32" && r !== "complex64" || e === "bool" && r === "bool"); } function cr(r) { return r instanceof Float32Array || r instanceof Int32Array || r instanceof Uint8Array; } function Xh(r) { if (r === "float32" || r === "int32") return 4; if (r === "complex64") return 8; if (r === "bool") return 1; throw new Error(`Unknown dtype ${r}`); } function hw(r) { if (r == null) return 0; let e = 0; return r.forEach((t) => e += t.length), e; } function Co(r) { return typeof r == "string" || r instanceof String; } function GI(r) { return typeof r == "boolean"; } function UI(r) { return typeof r == "number"; } function fc(r) { return Array.isArray(r) ? fc(r[0]) : r instanceof Float32Array ? "float32" : r instanceof Int32Array || r instanceof Uint8Array ? "int32" : UI(r) ? "float32" : Co(r) ? "string" : GI(r) ? "bool" : "float32"; } function zs(r) { return !!(r && r.constructor && r.call && r.apply); } function dc(r, e) { for (let t = e; t < r; ++t) if (r % t == 0) return t; return r; } function Bs(r) { let e = r.length; if (e < 2) return []; let t = new Array(e - 1); t[e - 2] = r[e - 1]; for (let n = e - 3; n >= 0; --n) t[n] = t[n + 1] * r[n + 1]; return t; } function HI(r, e, t, n = false) { let o = new Array(); if (e.length === 1) { let s = e[0] * (n ? 2 : 1); for (let a = 0; a < s; a++) o[a] = t[r + a]; } else { let s = e[0], a = e.slice(1), i = a.reduce((l, u) => l * u) * (n ? 2 : 1); for (let l = 0; l < s; l++) o[l] = HI(r + l * i, a, t, n); } return o; } function Wl(r, e, t = false) { if (r.length === 0) return e[0]; let n = r.reduce((o, s) => o * s) * (t ? 2 : 1); if (n === 0) return []; if (n !== e.length) throw new Error(`[${r}] does not match the input size ${e.length}${t ? " for a complex tensor" : ""}.`); return HI(0, r, e, t); } function Nm(r, e) { let t = hc(r, e); for (let n = 0; n < t.length; n++) t[n] = 1; return t; } function hc(r, e) { if (e == null || e === "float32" || e === "complex64") return new Float32Array(r); if (e === "int32") return new Int32Array(r); if (e === "bool") return new Uint8Array(r); throw new Error(`Unknown data type ${e}`); } function xj(r, e) { let t = r.reduce((n, o) => n * o, 1); if (e == null || e === "float32") return Wl(r, new Float32Array(t)); if (e === "int32") return Wl(r, new Int32Array(t)); if (e === "bool") return Wl(r, new Uint8Array(t)); throw new Error(`Unknown data type ${e}`); } function Tm(r) { r.forEach((e) => { E(Number.isInteger(e) && e >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${r}].`); }); } function yj(r, e, t) { if (e === 0) return 0; if (e === 1) return r[0]; let n = r[r.length - 1]; for (let o = 0; o < r.length - 1; ++o) n += t[o] * r[o]; return n; } function bj(r, e, t) { if (e === 0) return []; if (e === 1) return [r]; let n = new Array(e); for (let o = 0; o < n.length - 1; ++o) n[o] = Math.floor(r / t[o]), r -= n[o] * t[o]; return n[n.length - 1] = r, n; } function Em(r) { return r && r.then && typeof r.then == "function"; } function Vn(...r) { j().getBool("IS_TEST") || j().getBool("PROD") || console.warn(...r); } function wj(...r) { j().getBool("IS_TEST") || j().getBool("PROD") || console.log(...r); } var qI = "tfjsflags"; var Yh = class { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = kj, this.populateURLFlags(); } setPlatform(e, t) { this.platform != null && Vn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`), this.platformName = e, this.platform = t; } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, this.urlFlags[e] != null) { let o = this.urlFlags[e]; Vn(`Setting feature override from URL ${e}: ${o}.`), this.set(e, o); } } async getAsync(e) { return e in this.flags ? this.flags[e] : (this.flags[e] = await this.evaluateFlag(e), this.flags[e]); } get(e) { if (e in this.flags) return this.flags[e]; let t = this.evaluateFlag(e); if (Em(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); } getFlags() { return this.flags; } get features() { return this.flags; } set(e, t) { if (this.flagRegistry[e] == null) throw new Error(`Cannot set flag ${e} as it has not been registered.`); this.flags[e] = t, this.flagRegistry[e].setHook != null && this.flagRegistry[e].setHook(t); } evaluateFlag(e) { if (this.flagRegistry[e] == null) 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 (typeof this.global == "undefined" || typeof this.global.location == "undefined" || typeof this.global.location.search == "undefined") return; let e = this.getQueryParams(this.global.location.search); qI in e && e[qI].split(",").forEach((n) => { let [o, s] = n.split(":"); this.urlFlags[o] = vj(o, s); }); } }; function kj(r) { let e = {}; return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (t, ...n) => (_j(e, n[0], n[1]), n.join("="))), e; } function _j(r, e, t) { r[decodeURIComponent(e)] = decodeURIComponent(t || ""); } function vj(r, e) { if (e = e.toLowerCase(), e === "true" || e === "false") return e === "true"; if (`${+e}` === e) return +e; throw new Error(`Could not parse value flag value ${e} for flag ${r}.`); } function j() { return gw; } var gw = null; function KI(r) { gw = r; } var xw; function yw() { if (xw == null) { let r; if (typeof window != "undefined") r = window; else if (typeof global != "undefined") r = global; else if (typeof process != "undefined") r = process; else if (typeof self != "undefined") r = self; else throw new Error("Could not find a global object"); xw = r; } return xw; } function Cj() { let r = yw(); return r._tfGlobals == null && (r._tfGlobals = new Map()), r._tfGlobals; } function Am(r, e) { let t = Cj(); if (t.has(r)) return t.get(r); { let n = e(); return t.set(r, n), t.get(r); } } var Vs = "Abs"; var Ni = "Acos"; var Ti = "Acosh"; var Wn = "Add"; var So = "AddN"; var Ei = "All"; var Ai = "Any"; var Io = "ArgMax"; var Xa = "ArgMin"; var $i = "Asin"; var Di = "Asinh"; var Ri = "Atan"; var Fi = "Atanh"; var Oi = "Atan2"; var No = "AvgPool"; var gc = "AvgPoolGrad"; var Ya = "AvgPool3D"; var xc = "AvgPool3DGrad"; var To = "BatchMatMul"; var Ws = "BatchToSpaceND"; var yc = "Bincount"; var XI = "BroadcastTo"; var Zh = "BroadcastArgs"; var Qn = "Cast"; var Eo = "Ceil"; var eo = "ClipByValue"; var bc = "Complex"; var Za = "ComplexAbs"; var js = "Concat"; var Ao = "Conv2D"; var wc = "Conv2DBackpropFilter"; var $o = "Conv2DBackpropInput"; var Ja = "Conv3D"; var kc = "Conv3DBackpropFilterV2"; var _c = "Conv3DBackpropInputV2"; var Do = "Cos"; var Ro = "Cosh"; var Fo = "Cumsum"; var Pi = "CropAndResize"; var vc = "DenseBincount"; var Mi = "DepthToSpace"; var Oo = "DepthwiseConv2dNative"; var Cc = "DepthwiseConv2dNativeBackpropFilter"; var Sc = "DepthwiseConv2dNativeBackpropInput"; var Ic = "Diag"; var Qa = "Dilation2D"; var $m = "Dilation2DBackpropInput"; var Dm = "Dilation2DBackpropFilter"; var Po = "RealDiv"; var Nc = "Einsum"; var Mo = "Elu"; var Tc = "EluGrad"; var Li = "Erf"; var zi = "Equal"; var Lo = "Exp"; var Gs = "ExpandDims"; var Bi = "Expm1"; var Ec = "FFT"; var el = "Fill"; var Vi = "FlipLeftRight"; var zo = "Floor"; var Bo = "FloorDiv"; var Vo = "FusedBatchNorm"; var Us = "GatherV2"; var Wi = "GatherNd"; var ji = "Greater"; var Wo = "GreaterEqual"; var to = "Identity"; var Ac = "IFFT"; var $c = "Imag"; var Gi = "IsFinite"; var Ui = "IsInf"; var Hi = "IsNan"; var jo = "LeakyRelu"; var qi = "Less"; var Ki = "LessEqual"; var Dc = "LinSpace"; var Go = "Log"; var Xi = "Log1p"; var Yi = "LogicalAnd"; var jl = "LogicalNot"; var Gl = "LogicalOr"; var YI = "LogSoftmax"; var tl = "LRN"; var Rc = "LRNGrad"; var Uo = "Max"; var Ho = "Maximum"; var qo = "MaxPool"; var Fc = "MaxPoolGrad"; var rl = "MaxPool3D"; var Oc = "MaxPool3DGrad"; var Pc = "MaxPoolWithArgmax"; var Ko = "Mean"; var Xo = "Min"; var Yo = "Minimum"; var Zo = "MirrorPad"; var Zi = "Mod"; var Mc = "Multinomial"; var Jo = "Multiply"; var Hs = "Neg"; var Ji = "NotEqual"; var Qi = "NonMaxSuppressionV3"; var ea = "NonMaxSuppressionV4"; var ta = "NonMaxSuppressionV5"; var qs = "OnesLike"; var Qo = "OneHot"; var Ks = "Pack"; var es = "PadV2"; var fse = "Pool"; var ts = "Pow"; var rs = "Prelu"; var ra = "Prod"; var nl = "Range"; var Lc = "Real"; var na = "Reciprocal"; var ns = "Relu"; var Xs = "Reshape"; var ol = "ResizeNearestNeighbor"; var zc = "ResizeNearestNeighborGrad"; var os = "ResizeBilinear"; var Bc = "ResizeBilinearGrad"; var ss = "Relu6"; var is = "Reverse"; var as = "Round"; var ls = "Rsqrt"; var oa = "ScatterNd"; var Ys = "Select"; var sa = "Selu"; var Zs = "Slice"; var us = "Sin"; var ia = "Sinh"; var aa = "Sign"; var cs = "Sigmoid"; var la = "Softplus"; var ps = "Sqrt"; var ms = "Sum"; var Js = "SpaceToBatchND"; var Qs = "SplitV"; var fs = "Softmax"; var Vc = "SparseFillEmptyRows"; var Wc = "SparseReshape"; var jc = "SparseSegmentMean"; var Gc = "SparseSegmentSum"; var Uc = "SparseToDense"; var ds = "SquaredDifference"; var sl = "Square"; var ua = "StridedSlice"; var Hc = "StringNGrams"; var qc = "StringSplit"; var Kc = "StringToHashBucketFast"; var hs = "Sub"; var gs = "Tan"; var xs = "Tanh"; var jn = "Tile"; var ca = "TopK"; var pa = "Transform"; var ys = "Transpose"; var Xc = "Unique"; var ei = "Unpack"; var il = "UnsortedSegmentSum"; var ti = "ZerosLike"; var ro = "Step"; var Rm = "FromPixels"; var ma = "RotateWithOffset"; var ri = "_FusedMatMul"; var ni = "FusedConv2D"; var oi = "FusedDepthwiseConv2D"; var Yc = Am("kernelRegistry", () => new Map()); var Fm = Am("gradRegistry", () => new Map()); function Om(r, e) { let t = ww(r, e); return Yc.get(t); } function bw(r) { return Fm.get(r); } function Jh(r) { let e = Yc.entries(), t = []; for (; ; ) { let { done: n, value: o } = e.next(); if (n) break; let [s, a] = o, [i] = s.split("_"); i === r && t.push(a); } return t; } function Ul(r) { let { kernelName: e, backendName: t } = r, n = ww(e, t); Yc.has(n) && Vn(`The kernel '${e}' for backend '${t}' is already registered`), Yc.set(n, r); } function ZI(r) { let { kernelName: e } = r; Fm.has(e) && j().getBool("DEBUG") && Vn(`Overriding the gradient for '${e}'`), Fm.set(e, r); } function yse(r, e) { let t = ww(r, e); if (!Yc.has(t)) throw new Error(`The kernel '${r}' for backend '${e}' is not registered`); Yc.delete(t); } function bse(r) { if (!Fm.has(r)) throw new Error(`The gradient '${r}' for backend is not registered`); Fm.delete(r); } function wse(r, e) { Jh(r).forEach((n) => { let o = Object.assign({}, n, { backendName: e }); Ul(o); }); } function ww(r, e) { return `${e}_${r}`; } var b = {}; He(b, { arraysEqual: () => Kr, assert: () => E, assertNonNegativeIntegerDimensions: () => Tm, assertNonNull: () => Bn, assertShapesMatch: () => $t, bytesFromStringArray: () => hw, bytesPerElement: () => Xh, checkConversionForErrors: () => fw, clamp: () => mc, computeStrides: () => Bs, createScalarValue: () => $j, createShuffledIndices: () => fj, decodeString: () => ep, distSquared: () => uj, encodeString: () => ll, fetch: () => Rj, fingerPrint64: () => Aj, flatten: () => vo, getArrayFromDType: () => mw, getTypedArrayFromDType: () => pw, hasEncodingLoss: () => gj, hexToLong: () => Pm, indexToLoc: () => bj, inferDtype: () => fc, inferFromImplicitShape: () => hj, isBoolean: () => GI, isFunction: () => zs, isInt: () => ot, isNumber: () => UI, isPromise: () => Em, isScalarShape: () => cj, isString: () => Co, isTypedArray: () => cr, isValidDtype: () => dw, locToIndex: () => yj, makeOnesTypedArray: () => Nm, makeZerosNestedTypedArray: () => xj, makeZerosTypedArray: () => hc, nearestDivisor: () => dc, nearestLargerEven: () => ij, now: () => Yl, parseAxisParam: () => ir, randUniform: () => lj, repeatedTry: () => dj, rightPad: () => Vl, shuffle: () => jI, shuffleCombo: () => sj, sizeFromShape: () => nt, sizeToSquarishShape: () => mj, squeezeShape: () => cw, sum: () => aj, swap: () => Kh, tanh: () => pj, toNestedArray: () => Wl, toTypedArray: () => Qc }); var u1 = Bl(l1()); var Kl = u1.default || u1; function Pm(r) { return Kl.fromString(r, true, 16); } var c1 = Pm("c3a5c85c97cb3127"); var Xl = Pm("b492b66fbe98f273"); var Xr = Pm("9ae16a3b2f90404f"); function vw(r) { return r.xor(r.shru(47)); } function p1(r, e, t) { let n = r.slice(e, e + t); return Kl.fromBytes(Array.from(n), true, true); } function Pt(r, e) { return p1(r, e, 8); } function m1(r, e) { return p1(r, e, 4); } function _r(r, e) { return e === 0 ? r : r.shru(e).or(r.shl(64 - e)); } function al(r, e, t = Pm("9ddfea08eb382d69")) { let n = r.xor(e).mul(t); n = n.xor(n.shru(47)); let o = e.xor(n).mul(t); return o = o.xor(o.shru(47)), o = o.mul(t), o; } function Ij(r, e, t, n, o, s) { o = o.add(r), s = _r(s.add(o).add(n), 21); let a = o; return o = o.add(e), o = o.add(t), s = s.add(_r(o, 44)), [o.add(n), s.add(a)]; } function eg(r, e, t, n) { return Ij(Pt(r, e), Pt(r, e + 8), Pt(r, e + 16), Pt(r, e + 24), t, n); } function Nj(r, e = r.length) { if (e >= 8) { let t = Xr.add(e * 2), n = Pt(r, 0).add(Xr), o = Pt(r, e - 8), s = _r(o, 37).mul(t).add(n), a = _r(n, 25).add(o).mul(t); return al(s, a, t); } if (e >= 4) { let t = Xr.add(e * 2), n = m1(r, 0); return al(n.shl(3).add(e), m1(r, e - 4), t); } if (e > 0) { let t = r[0], n = r[e >> 1], o = r[e - 1], s = t + (n << 8), a = e + (o << 2); return vw(Xr.mul(s).xor(c1.mul(a))).mul(Xr); } return Xr; } function Tj(r, e = r.length) { let t = Xr.add(e * 2), n = Pt(r, 0).mul(Xl), o = Pt(r, 8), s = Pt(r, e - 8).mul(t), a = Pt(r, e - 16).mul(Xr); return al(_r(n.add(o), 43).add(_r(s, 30)).add(a), n.add(_r(o.add(Xr), 18)).add(s), t); } function Ej(r, e = r.length) { let t = Xr.add(e * 2), n = Pt(r, 0).mul(Xr), o = Pt(r, 8), s = Pt(r, e - 8).mul(t), a = Pt(r, e - 16).mul(Xr), i = _r(n.add(o), 43).add(_r(s, 30)).add(a), l = al(i, n.add(_r(o.add(Xr), 18)).add(s), t), u = Pt(r, 16).mul(t), c = Pt(r, 24), p = i.add(Pt(r, e - 32)).mul(t), m = l.add(Pt(r, e - 24)).mul(t); return al(_r(u.add(c), 43).add(_r(p, 30)).add(m), u.add(_r(c.add(n), 18)).add(p), t); } function Aj(r, e = r.length) { let t = Kl.fromNumber(81, true); if (e <= 32) return e <= 16 ? Nj(r, e) : Tj(r, e); if (e <= 64) return Ej(r, e); let n = t, o = t.mul(Xl).add(113), s = vw(o.mul(Xr).add(113)).mul(Xr), a = [Kl.UZERO, Kl.UZERO], i = [Kl.UZERO, Kl.UZERO]; n = n.mul(Xr).add(Pt(r, 0)); let l = 0, u = (e - 1 >> 6) * 64, c = u + (e - 1 & 63) - 63; do n = _r(n.add(o).add(a[0]).add(Pt(r, l + 8)), 37).mul(Xl), o = _r(o.add(a[1]).add(Pt(r, l + 48)), 42).mul(Xl), n = n.xor(i[1]), o = o.add(a[0]).add(Pt(r, l + 40)), s = _r(s.add(i[0]), 33).mul(Xl), a = eg(r, l, a[1].mul(Xl), n.add(i[0])), i = eg(r, l + 32, s.add(i[1]), o.add(Pt(r, l + 16))), [s, n] = [n, s], l += 64; while (l !== u); let p = Xl.add(s.and(255).shl(1)); return l = c, i[0] = i[0].add(e - 1 & 63), a[0] = a[0].add(i[0]), i[0] = i[0].add(a[0]), n = _r(n.add(o).add(a[0]).add(Pt(r, l + 8)), 37).mul(p), o = _r(o.add(a[1]).add(Pt(r, l + 48)), 42).mul(p), n = n.xor(i[1].mul(9)), o = o.add(a[0].mul(9).add(Pt(r, l + 40))), s = _r(s.add(i[0]), 33).mul(p), a = eg(r, l, a[1].mul(p), n.add(i[0])), i = eg(r, l + 32, s.add(i[1]), o.add(Pt(r, l + 16))), [s, n] = [n, s], al(al(a[0], i[0], p).add(vw(o).mul(c1)).add(s), al(a[1], i[1], p).add(n), p); } function $j(r, e) { return e === "string" ? ll(r) : Qc([r], e); } function Dj(r, e) { return r instanceof Float32Array && e === "float32" || r instanceof Int32Array && e === "int32" || r instanceof Uint8Array && e === "bool"; } function Qc(r, e) { if (e === "string") throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(r) && (r = vo(r)), j().getBool("DEBUG") && fw(r, e), Dj(r, e)) return r; if (e == null || e === "float32" || e === "complex64") return new Float32Array(r); if (e === "int32") return new Int32Array(r); if (e === "bool") { let t = new Uint8Array(r.length); for (let n = 0; n < t.length; ++n) Math.round(r[n]) !== 0 && (t[n] = 1); return t; } else throw new Error(`Unknown data type ${e}`); } function Yl() { return j().platform.now(); } function Rj(r, e) { return j().platform.fetch(r, e); } function ll(r, e = "utf-8") { return e = e || "utf-8", j().platform.encode(r, e); } function ep(r, e = "utf-8") { return e = e || "utf-8", j().platform.decode(r, e); } var Cw = class { constructor(e, t) { this.backendTimer = e, this.logger = t, t == null && (this.logger = new f1()); } profileKernel(e, t, n) { let o, s = () => { o = n(); }, a, i = Yl(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(s); else { s(); for (let u of o) u.dataSync(); a = Promise.resolve({ kernelMs: Yl() - i }); } if (j().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < o.length; u++) { let c = o[u]; c.data().then((p) => { Fj(p, c.dtype, e); }); } return { kernelName: e, outputs: o, inputs: t, timeMs: a.then((u) => u.kernelMs), extraInfo: a.then((u) => u.getExtraProfileInfo != null ? u.getExtraProfileInfo() : "") }; } logKernelProfile(e) { let { kernelName: t, outputs: n, timeMs: o, inputs: s, extraInfo: a } = e; n.forEach((i) => { Promise.all([i.data(), o, a]).then((l) => { this.logger.logKernelProfile(t, i, l[0], l[1], s, l[2]); }); }); } }; function Fj(r, e, t) { if (e !== "float32") return false; for (let n = 0; n < r.length; n++) { let o = r[n]; if (isNaN(o) || !isFinite(o)) return console.warn(`Found ${o} in the result of '${t}'`), true; } return false; } var f1 = class { logKernelProfile(e, t, n, o, s, a) { let i = typeof o == "number" ? Vl(`${o}ms`, 9) : o.error, l = Vl(e, 25), u = t.rank, c = t.size, p = Vl(t.shape.toString(), 14), m = ""; for (let f in s) { let d = s[f]; if (d != null) { let h = d.shape || t.shape, g = h.length; m += `${f}: ${g}D ${g > 0 ? h : ""} `; } } console.log(`%c${l} %c${i} %c${u}D ${p} %c${c} %c${m} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; function d1(r, e, t) { let n = {}, o = {}; for (let l = 0; l < e.length; l++) n[e[l].id] = true; for (let l = 0; l < r.length; l++) { let u = r[l], c = u.inputs; for (let p in c) { let m = c[p], f = false; for (let d = 0; d < e.length; d++) if (n[m.id]) { u.outputs.forEach((h) => n[h.id] = true), f = true, o[u.id] = true; break; } if (f) break; } } let s = {}; s[t.id] = true; let a = {}; for (let l = r.length - 1; l >= 0; l--) { let u = r[l], c = u.inputs; for (let p = 0; p < u.outputs.length; p++) if (s[u.outputs[p].id]) { for (let m in c) s[c[m].id] = true, a[u.id] = true; break; } } let i = []; for (let l = 0; l < r.length; l++) { let u = r[l]; if (o[u.id] && a[u.id]) { let c = {}; for (let m in u.inputs) { let f = u.inputs[m]; n[f.id] && (c[m] = f); } let p = Object.assign({}, u); p.inputs = c, p.outputs = u.outputs, i.push(p); } } return i; } function h1(r, e, t, n) { for (let o = e.length - 1; o >= 0; o--) { let s = e[o], a = []; if (s.outputs.forEach((l) => { let u = r[l.id]; u != null ? a.push(u) : a.push(null); }), s.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`); let i = s.gradient(a); for (let l in s.inputs) { if (!(l in i)) throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(i)}.`); let u = t(() => i[l]()); if (u.dtype !== "float32") throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`); let c = s.inputs[l]; if (!Kr(u.shape, c.shape)) throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`); if (r[c.id] == null) r[c.id] = u; else { let p = r[c.id]; r[c.id] = n(p, u), p.dispose(); } } } } var g1 = 20; var Mm = 3; var Sw = 7; function x1(r, e, t, n) { let o = Bs(e), s = Oj(r, e, t, o), a = e.length, i = tg(r, e, t, o, s), l = ["Tensor"]; return n && (l.push(` dtype: ${t}`), l.push(` rank: ${a}`), l.push(` shape: [${e}]`), l.push(" values:")), l.push(i.map((u) => " " + u).join(` `)), l.join(` `); } function Oj(r, e, t, n) { let o = nt(e), s = n[n.length - 1], a = new Array(s).fill(0), i = e.length, l = t === "complex64" ? zm(r) : r; if (i > 1) for (let u = 0; u < o / s; u++) { let c = u * s; for (let p = 0; p < s; p++) a[p] = Math.max(a[p], Lm(l[c + p], 0, t).length); } return a; } function Lm(r, e, t) { let n; return Array.isArray(r) ? n = `${parseFloat(r[0].toFixed(Sw))} + ${parseFloat(r[1].toFixed(Sw))}j` : Co(r) ? n = `'${r}'` : t === "bool" ? n = y1(r) : n = parseFloat(r.toFixed(Sw)).toString(), Vl(n, e); } function y1(r) { return r === 0 ? "false" : "true"; } function tg(r, e, t, n, o, s = true) { let a = t === "complex64" ? 2 : 1, i = e[0], l = e.length; if (l === 0) { if (t === "complex64") { let h = zm(r); return [Lm(h[0], 0, t)]; } return t === "bool" ? [y1(r[0])] : [r[0].toString()]; } if (l === 1) { if (i > g1) { let g = Mm * a, y = Array.from(r.slice(0, g)), w = Array.from(r.slice((i - Mm) * a, i * a)); return t === "complex64" && (y = zm(y), w = zm(w)), ["[" + y.map((x, k) => Lm(x, o[k], t)).join(", ") + ", ..., " + w.map((x, k) => Lm(x, o[i - Mm + k], t)).join(", ") + "]"]; } let h = t === "complex64" ? zm(r) : Array.from(r); return ["[" + h.map((g, y) => Lm(g, o[y], t)).join(", ") + "]"]; } let u = e.slice(1), c = n.slice(1), p = n[0] * a, m = []; if (i > g1) { for (let h = 0; h < Mm; h++) { let g = h * p, y = g + p; m.push(...tg(r.slice(g, y), u, t, c, o, false)); } m.push("..."); for (let h = i - Mm; h < i; h++) { let g = h * p, y = g + p; m.push(...tg(r.slice(g, y), u, t, c, o, h === i - 1)); } } else for (let h = 0; h < i; h++) { let g = h * p, y = g + p; m.push(...tg(r.slice(g, y), u, t, c, o, h === i - 1)); } let f = l === 2 ? "," : ""; m[0] = "[" + m[0] + f; for (let h = 1; h < m.length - 1; h++) m[h] = " " + m[h] + f; let d = `, `; for (let h = 2; h < l; h++) d += ` `; return m[m.length - 1] = " " + m[m.length - 1] + "]" + (s ? "" : d), m; } function zm(r) { let e = []; for (let t = 0; t < r.length; t += 2) e.push([r[t], r[t + 1]]); return e; } var ct = class { constructor(e, t, n) { if (this.dtype = t, this.shape = e.slice(), this.size = nt(e), n != null) { let o = n.length; E(o === this.size, () => `Length of values '${o}' does not match the size inferred by the shape '${this.size}'.`); } if (t === "complex64") 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 || mw(t, this.size), this.strides = Bs(e); } set(e, ...t) { t.length === 0 && (t = [0]), E(t.length === this.rank, () => `The number of provided coordinates (${t.length}) must match the rank (${this.rank})`); let n = this.locToIndex(t); this.values[n] = e; } get(...e) { e.length === 0 && (e = [0]); let t = 0; for (let o of e) { if (o < 0 || o >= this.shape[t]) { let s = `Requested out of range element at ${e}. Buffer shape=${this.shape}`; throw new Error(s); } t++; } let n = e[e.length - 1]; for (let o = 0; o < e.length - 1; ++o) n += this.strides[o] * e[o]; return this.values[n]; } locToIndex(e) { if (this.rank === 0) return 0; if (this.rank === 1) 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 (this.rank === 0) return []; if (this.rank === 1) return [e]; let 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 si().makeTensor(this.values, this.shape, this.dtype); } }; var si = null; var tp = null; var Pj = null; function b1(r) { si = r; } function w1(r) { tp = r; } function k1(r) { Pj = r; } var je = class { constructor(e, t, n, o) { this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t || "float32", this.size = nt(e), this.strides = Bs(e), this.dataId = n, this.id = o, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; } get rank() { return this.shape.length; } async buffer() { let e = await this.data(); return tp.buffer(this.shape, this.dtype, e); } bufferSync() { return tp.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); return Wl(this.shape, e, this.dtype === "complex64"); } arraySync() { return Wl(this.shape, this.dataSync(), this.dtype === "complex64"); } async data() { this.throwIfDisposed(); let e = si().read(this.dataId); if (this.dtype === "string") { let t = await e; try { return t.map((n) => ep(n)); } catch (n) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes()."); } } return e; } dataSync() { this.throwIfDisposed(); let e = si().readSync(this.dataId); if (this.dtype === "string") try { return e.map((t) => ep(t)); } catch (t) { 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(); let e = await si().read(this.dataId); return this.dtype === "string" ? e : new Uint8Array(e.buffer); } dispose() { this.isDisposed || (si().disposeTensor(this), this.isDisposedInternal = true); } get isDisposed() { return this.isDisposedInternal; } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed."); } print(e = false) { return tp.print(this, e); } clone() { return this.throwIfDisposed(), tp.clone(this); } toString(e = false) { let t = this.dataSync(); return x1(t, this.shape, this.dtype, e); } cast(e) { return this.throwIfDisposed(), tp.cast(this, e); } variable(e = true, t, n) { return this.throwIfDisposed(), si().makeVariable(this, e, t, n); } }; Object.defineProperty(je, Symbol.hasInstance, { value: (r) => !!r && r.data != null && r.dataSync != null && r.throwIfDisposed != null }); function Mj() { return Am("Tensor", () => je); } Mj(); var ul = class extends je { constructor(e, t, n, o) { super(e.shape, e.dtype, e.dataId, o); 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 (!Kr(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); si().disposeTensor(this), this.dataId = e.dataId, si().incRef(this, null); } dispose() { si().disposeVariable(this), this.isDisposedInternal = true; } }; Object.defineProperty(ul, Symbol.hasInstance, { value: (r) => r instanceof je && r.assign != null && r.assign instanceof Function }); var io = {}; He(io, { assertTypesMatch: () => $w, getTensorsInContainer: () => Bm, isTensorInList: () => zj, makeTypesMatch: () => Ge }); var Iw; (function(r) { r.R0 = "R0", r.R1 = "R1", r.R2 = "R2", r.R3 = "R3", r.R4 = "R4", r.R5 = "R5", r.R6 = "R6"; })(Iw || (Iw = {})); var Nw; (function(r) { r.float32 = "float32", r.int32 = "int32", r.bool = "int32", r.complex64 = "complex64"; })(Nw || (Nw = {})); var Tw; (function(r) { r.float32 = "float32", r.int32 = "int32", r.bool = "bool", r.complex64 = "complex64"; })(Tw || (Tw = {})); var Ew; (function(r) { r.float32 = "float32", r.int32 = "float32", r.bool = "float32", r.complex64 = "complex64"; })(Ew || (Ew = {})); var Aw; (function(r) { r.float32 = "complex64", r.int32 = "complex64", r.bool = "complex64", r.complex64 = "complex64"; })(Aw || (Aw = {})); var Lj = { float32: Ew, int32: Nw, bool: Tw, complex64: Aw }; function pr(r, e) { if (r === "string" || e === "string") { if (r === "string" && e === "string") return "string"; throw new Error(`Can not upcast ${r} with ${e}`); } return Lj[r][e]; } function Zl(r) { return pr(r, "int32"); } function Ge(r, e) { if (r.dtype === e.dtype) return [r, e]; let t = pr(r.dtype, e.dtype); return [r.cast(t), e.cast(t)]; } function $w(r, e) { E(r.dtype === e.dtype, () => `The dtypes of the first(${r.dtype}) and second(${e.dtype}) input must match`); } function zj(r, e) { return e.some((t) => t.id === r.id); } function Bm(r) { let e = [], t = new Set(); return _1(r, e, t), e; } function _1(r, e, t) { if (r == null) return; if (r instanceof je) { e.push(r); return; } if (!Bj(r)) return; let n = r; for (let o in n) { let s = n[o]; t.has(s) || (t.add(s), _1(s, e, t)); } } function Bj(r) { return Array.isArray(r) || typeof r == "object"; } function Dw(r) { return r.kernelName != null; } var Rw = class { 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 = false, 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 (let e in this.registeredVariables) this.registeredVariables[e].dispose(); } }; var Jl = class { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new Rw(); } async ready() { if (this.pendingBackendInit != null) return this.pendingBackendInit.then(() => { }); if (this.backendInstance != null) return; let e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { let n = e[t]; if (await this.initializeBackend(n).success) { await this.setBackend(n); return; } } throw new Error("Could not initialize any backends, all backend initializations failed."); } get backend() { if (this.pendingBackendInit != null) 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 (this.backendInstance == null) { let { 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) { let { asyncInit: t } = this.initializeBackend(e); if (t) return null; } else 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 ? (Vn(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = { factory: t, priority: n }, true); } async setBackend(e) { if (this.registryFactory[e] == null) throw new Error(`Backend name '${e}' not found in registry`); if (this.backendName = e, this.registry[e] == null) { this.backendInstance = null; let { success: t, asyncInit: n } = this.initializeBackend(e); if (!(n ? await t : t)) return false; } return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new Cw(this.backendInstance), true; } setupRegisteredKernels() { Jh(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { Jh(e).forEach((n) => { n.disposeFunc != null && n.disposeFunc(this.registry[e]); }); } initializeBackend(e) { let t = this.registryFactory[e]; if (t == null) throw new Error(`Cannot initialize backend ${e}, no registration found.`); try { let n = t.factory(); if (n && !(n instanceof Ls) && typeof n.then == "function") { let o = ++this.pendingBackendInitId, s = n.then((a) => o < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (o < this.pendingBackendInitId || (this.pendingBackendInit = null, Vn(`Initialization of backend ${e} failed`), Vn(a.stack || a.message)), false)); return this.pendingBackendInit = s, { success: s, asyncInit: true }; } else return this.registry[e] = n, { success: true, asyncInit: false }; } catch (n) { return Vn(`Initialization of backend ${e} failed`), Vn(n.stack || n.message), { success: false, asyncInit: false }; } } removeBackend(e) { if (!(e in this.registryFactory)) throw new Error(`${e} backend not found in registry`); this.backendName === e && this.pendingBackendInit != null && 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 (Object.keys(this.registryFactory).length === 0) 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() { let e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { let n = e[t], { success: o, asyncInit: s } = this.initializeBackend(n); if (s || o) return { name: n, asyncInit: s }; } throw new Error("Could not initialize any backends, all backend initializations failed."); } moveData(e, t) { let n = this.state.tensorInfo.get(t), o = n.backend, s = this.readSync(t), a = o.refCount(t); o.disposeData(t, true), n.backend = e, e.move(t, s, n.shape, n.dtype, a), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++; } tidy(e, t) { let n = null; if (t == null) { if (typeof e != "function") throw new Error("Please provide a function to tidy()"); t = e; } else { if (typeof e != "string" && !(e instanceof String)) throw new Error("When calling with two arguments, the first argument to tidy() must be a string"); if (typeof t != "function") throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function"); n = e; } let o; return this.scopedRun(() => this.startScope(n), () => this.endScope(o), () => (o = t(), o instanceof Promise && console.error("Cannot return a Promise inside of tidy."), o)); } scopedRun(e, t, n) { e(); try { let o = n(); return t(), o; } catch (o) { throw t(), o; } } nextTensorId() { return Jl.nextTensorId++; } nextVariableId() { return Jl.nextVariableId++; } clone(e) { let t = T.runKernel(to, { x: e }), n = { x: e }, o = (a) => ({ x: () => { let i = "float32", l = { x: a }, u = { dtype: i }; return T.runKernel(Qn, l, u); } }), s = []; return this.addTapeNode(this.state.activeScope.name, n, [t], o, s, {}), t; } runKernel(e, t, n) { if (this.backendName == null && this.backend, !(Om(e, this.backendName) != null)) 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) { let o = this.backend.numDataIds(), s = 0; n.forEach((l) => { s += l.dtype === "complex64" ? 3 : 1; }); let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = o - t - s - a; if (i > 0) throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`); } runKernelFunc(e) { let t, n = [], o = this.isTapeOn(), s = this.state.numBytes, a = this.state.numTensors; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0); let i; this.backendName == null && this.backend; let l, u = Dw(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; if (Dw(e)) { let { kernelName: d, inputs: h, attrs: g } = e; this.backendName == null && this.backend; let y = Om(d, this.backendName); E(y != null, () => `Cannot find registered kernel '${d}' for backend '${this.backendName}'`), i = () => { let w = this.backend.numDataIds(); l = y.kernelFunc({ inputs: h, attrs: g, backend: this.backend }); let x = Array.isArray(l) ? l : [l]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(d, w, x); let k = x.map((C) => { if (C.rank != null) return C; let { dataId: A, shape: $, dtype: R } = C; return this.makeTensorFromDataId(A, $, R); }); if (o) { let C = this.getTensorsForGradient(d, h, k); n = this.saveTensorsForBackwardMode(C); } return k; }; } else { let { forwardFunc: d } = e, h = (g) => { !o || (n = g.map((y) => this.keep(this.clone(y)))); }; i = () => { let g = this.backend.numDataIds(); l = this.tidy(() => d(this.backend, h)); let y = Array.isArray(l) ? l : [l]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, g, y), y; }; } let { inputs: c, attrs: p } = e, m = Dw(e) ? null : e.backwardsFunc, f; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = i() : (f = this.profiler.profileKernel(u, c, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(f), t = f.outputs); }), o && this.addTapeNode(u, c, t, m, n, p), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - s, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(c).map((d) => c[d] != null ? c[d].shape : null), outputShapes: t.map((d) => d.shape), kernelTimeMs: f.timeMs, extraInfo: f.extraInfo }), Array.isArray(l) ? t : t[0]; } saveTensorsForBackwardMode(e) { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { let o = bw(e); if (o != null) { let s = o.inputsToSave || [], a = o.outputsToSave || [], i; o.saveAllInputs ? (E(Array.isArray(t), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t).map((u) => t[u])) : i = s.map((u) => t[u]); let l = n.filter((u, c) => a[c]); return i.concat(l); } return []; } makeTensor(e, t, n, o) { if (e == null) throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", o = o || this.backend; let s = e; n === "string" && Co(e[0]) && (s = e.map((l) => ll(l))); let a = o.write(s, t, n), i = new je(t, n, a, this.nextTensorId()); if (this.trackTensor(i, o), n === "string") { let l = this.state.tensorInfo.get(a), u = hw(s); this.state.numBytes += u - l.bytes, l.bytes = u; } return i; } makeTensorFromDataId(e, t, n, o) { n = n || "float32"; let s = new je(t, n, e, this.nextTensorId()); return this.trackTensor(s, o), s; } makeVariable(e, t = true, n, o) { n = n || this.nextVariableId().toString(), o != null && o !== e.dtype && (e = e.cast(o)); let s = new ul(e, t, n, this.nextTensorId()); if (this.state.registeredVariables[s.name] != null) throw new Error(`Variable with name ${s.name} was already registered`); return this.state.registeredVariables[s.name] = s, this.incRef(s, this.backend), s; } trackTensor(e, t) { this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++; let n = 0; e.dtype !== "complex64" && e.dtype !== "string" && (n = e.size * Xh(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 ul || 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; let t = this.state.tensorInfo.get(e.dataId); if (this.state.numTensors--, e.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= t.bytes), e.dtype !== "complex64" && e.dtype !== "string") { let n = e.size * Xh(e.dtype); this.state.numBytes -= n; } t.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t.backend); } disposeVariables() { for (let e in this.state.registeredVariables) { let t = this.state.registeredVariables[e]; this.disposeVariable(t); } } disposeVariable(e) { this.disposeTensor(e), this.state.registeredVariables[e.name] != null && delete this.state.registeredVariables[e.name]; } memory() { let 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 = true, e.reasons == null && (e.reasons = []), e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")), e; } async profile(e) { this.state.profiling = true; let t = this.state.numBytes, n = this.state.numTensors; this.state.activeProfile.kernels = [], this.state.activeProfile.result = await e(), this.state.profiling = false, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((o) => o.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - t, this.state.activeProfile.newTensors = this.state.numTensors - n; for (let o of this.state.activeProfile.kernels) o.kernelTimeMs = await o.kernelTimeMs, o.extraInfo = await o.extraInfo; return this.state.activeProfile; } isTapeOn() { return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; } addTapeNode(e, t, n, o, s, a) { let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: s }, l = bw(e); l != null && (o = l.gradFunc), o != null && (i.gradient = (u) => (u = u.map((c, p) => { if (c == null) { let m = n[p], f = hc(m.size, m.dtype); return this.makeTensor(f, m.shape, m.dtype); } return c; }), o(u.length > 1 ? u : u[0], s, a))), this.state.activeTape.push(i); } keep(e) { return e.kept = true, e; } startTape() { this.state.gradientDepth === 0 && (this.state.activeTape = []), this.state.gradientDepth++; } endTape() { this.state.gradientDepth--; } startScope(e) { let t = { track: [], name: "unnamed scope", id: this.state.nextScopeId++ }; e && (t.name = e), this.state.scopeStack.push(t), this.state.activeScope = t; } endScope(e) { let t = Bm(e), n = new Set(t.map((s) => s.id)); for (let s = 0; s < this.state.activeScope.track.length; s++) { let a = this.state.activeScope.track[s]; !a.kept && !n.has(a.id) && a.dispose(); } let o = this.state.scopeStack.pop(); this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t.forEach((s) => { !s.kept && s.scopeId === o.id && this.track(s); }); } gradients(e, t, n, o = false) { if (E(t.length > 0, () => "gradients() received an empty list of xs."), n != null && n.dtype !== "float32") throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`); let s = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", e)); E(s instanceof je, () => "The result y returned by f() must be a tensor."); let a = d1(this.state.activeTape, t, s); if (!o && a.length === 0 && 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", () => { let i = {}; i[s.id] = n == null ? Vj(s.shape) : n, h1(i, a, (u) => this.tidy(u), Wj); let l = t.map((u) => i[u.id]); return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((u) => { for (let c of u.saved) c.dispose(); }), this.state.activeTape = null), { value: s, grads: l }; }); } customGrad(e) { return E(zs(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { E(t.every((i) => i instanceof je), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors"); let n, o = {}; t.forEach((i, l) => { o[l] = i; }); let s = (i, l) => (n = e(...t, l), E(n.value instanceof je, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), E(zs(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (i, l) => { let u = n.gradFunc(i, l), c = Array.isArray(u) ? u : [u]; E(c.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(...)."), E(c.every((m) => m instanceof je), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."); let p = {}; return c.forEach((m, f) => { p[f] = () => m; }), p; }; return this.runKernelFunc({ forwardFunc: s, backwardsFunc: a, inputs: o }); }; } readSync(e) { return this.state.tensorInfo.get(e).backend.readSync(e); } read(e) { return this.state.tensorInfo.get(e).backend.read(e); } async time(e) { let t = Yl(), n = await this.backend.time(e); return n.wallMs = Yl() - t, n; } track(e) { return this.state.activeScope != null && (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 Rw(); for (let e in this.registry) this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]; this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null; } }; Jl.nextTensorId = 0; Jl.nextVariableId = 0; function Vj(r) { let e = Nm(nt(r), "float32"); return T.makeTensor(e, r, "float32"); } function Fw() { let r = yw(); if (r._tfengine == null) { let e = new Yh(r); r._tfengine = new Jl(e); } return KI(r._tfengine.ENV), b1(() => r._tfengine), r._tfengine; } var T = Fw(); function Wj(r, e) { let t = { a: r, b: e }; return T.runKernel(Wn, t); } var Ql = {}; He(Ql, { isBrowser: () => Ow, isMobile: () => Gj }); function jj() { return typeof navigator != "undefined" && navigator != null; } function Gj(r) { if (r || jj()) { if (r || (r = navigator), r.product === "ReactNative") return true; let e = r.userAgent || r.vendor || (typeof window != "undefined" ? window.opera : ""); if (!e) { let t = r; 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(e) || /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(e.substr(0, 4)); } return false; } function Ow() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } var ws = j(); ws.registerFlag("DEBUG", () => false, (r) => { r && 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."); }); ws.registerFlag("IS_BROWSER", () => Ow()); ws.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); ws.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); ws.registerFlag("PROD", () => false); ws.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => ws.getBool("DEBUG")); ws.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true); ws.registerFlag("IS_TEST", () => false); ws.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true); ws.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); function Ar(r, e) { let t = r; if (cr(r)) return e === "string" ? [] : [r.length]; if (!Array.isArray(r)) return []; let n = []; for (; Array.isArray(t) || cr(t) && e !== "string"; ) n.push(t.length), t = t[0]; return Array.isArray(r) && j().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && v1(r, n, []), n; } function v1(r, e, t) { if (t = t || [], !Array.isArray(r) && !cr(r)) { E(e.length === 0, () => `Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`); return; } E(e.length > 0, () => `Element arr[${t.join("][")}] should be a primitive, but is an array of ${r.length} elements`), E(r.length === e[0], () => `Element arr[${t.join("][")}] should have ${e[0]} elements, but has ${r.length} elements`); let n = e.slice(1); for (let o = 0; o < r.length; ++o) v1(r[o], n, t.concat(o)); } function C1(r, e, t, n) { if (r !== "string_or_numeric") { if (r == null) throw new Error("Expected dtype cannot be null."); if (r !== "numeric" && r !== e || r === "numeric" && e === "string") throw new Error(`Argument '${t}' passed to '${n}' must be ${r} tensor, but got ${e} tensor`); } } function _(r, e, t, n = "numeric") { if (r instanceof je) return C1(n, r.dtype, e, t), r; let o = fc(r); if (o !== "string" && ["bool", "int32", "float32"].indexOf(n) >= 0 && (o = n), C1(n, o, e, t), r == null || !cr(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string") { let l = r == null ? "null" : r.constructor.name; throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${l}'`); } let s = Ar(r, o); !cr(r) && !Array.isArray(r) && (r = [r]); let i = o !== "string" ? Qc(r, o) : vo(r, [], true); return T.makeTensor(i, s, o); } function fa(r, e, t, n = "numeric") { if (!Array.isArray(r)) throw new Error(`Argument ${e} passed to ${t} must be a \`Tensor[]\` or \`TensorLike[]\``); return r.map((s, a) => _(s, `${e}[${a}]`, t, n)); } var S1 = "__op"; function I(r) { let e = Object.keys(r); if (e.length !== 1) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`); let t = e[0], n = r[t]; t.endsWith("_") && (t = t.substring(0, t.length - 1)), t = t + S1; let o = (...s) => { T.startScope(t); try { let a = n(...s); return Em(a) && console.error("Cannot return a Promise inside of tidy."), T.endScope(a), a; } catch (a) { throw T.endScope(null), a; } }; return Object.defineProperty(o, "name", { value: t, configurable: true }), o; } function Uj(r, e) { let t = _(r, "real", "complex"), n = _(e, "imag", "complex"); $t(t.shape, n.shape, `real and imag shapes, ${t.shape} and ${n.shape}, must match in call to tf.complex().`); let o = { real: t, imag: n }; return T.runKernel(bc, o); } var $n = I({ complex_: Uj }); function Yr(r, e, t, n) { if (n == null && (n = fc(r)), n === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if (!cr(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string") 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 (e != null) { Tm(e); let o = nt(e), s = nt(t); E(o === s, () => `Based on the provided shape, [${e}], the tensor should have ${o} values but has ${s}`); for (let a = 0; a < t.length; ++a) { let i = t[a], l = a === t.length - 1 ? i !== nt(e.slice(a)) : true; E(t[a] === e[a] || !l, () => `Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `); } } return !cr(r) && !Array.isArray(r) && (r = [r]), e = e || t, r = n !== "string" ? Qc(r, n) : vo(r, [], true), T.makeTensor(r, e, n); } function vr(r, e, t) { let n = Ar(r, t); return Yr(r, e, n, t); } var Vm = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; var rg = 4; async function I1(r, e) { let t = [], n = [], o = Array.isArray(r) ? r.map((a) => a.name) : Object.keys(r); for (let a = 0; a < o.length; ++a) { let i = o[a], l = Array.isArray(r) ? r[a].tensor : r[i]; if (l.dtype !== "float32" && l.dtype !== "int32" && l.dtype !== "bool" && l.dtype !== "string" && l.dtype !== "complex64") throw new Error(`Unsupported dtype in weight '${i}': ${l.dtype}`); let u = { name: i, shape: l.shape, dtype: l.dtype }; if (l.dtype === "string") { let c = new Promise(async (p) => { let m = await l.bytes(), f = m.reduce((g, y) => g + y.length, 0) + rg * m.length, d = new Uint8Array(f), h = 0; for (let g = 0; g < m.length; g++) { let y = m[g], w = new Uint8Array(new Uint32Array([y.length]).buffer); d.set(w, h), h += rg, d.set(y, h), h += y.length; } p(d); }); n.push(c); } else n.push(l.data()); e != null && (u.group = e), t.push(u); } let s = await Promise.all(n); return { data: Hj(s), specs: t }; } function ng(r, e) { let t = {}, n, o = 0; for (let s of e) { let a = s.name, i = s.dtype, l = s.shape, u = nt(l), c; if ("quantization" in s) { let p = s.quantization; if (p.dtype === "uint8" || p.dtype === "uint16") { if (!("min" in p && "scale" in p)) throw new Error(`Weight ${s.name} with quantization ${p.dtype} doesn't have corresponding metadata min and scale.`); } else if (p.dtype === "float16") { if (i !== "float32") throw new Error(`Weight ${s.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${i}.`); } else throw new Error(`Weight ${s.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); let m = Vm[p.dtype], f = r.slice(o, o + u * m), d = p.dtype === "uint8" ? new Uint8Array(f) : new Uint16Array(f); if (i === "float32") if (p.dtype === "uint8" || p.dtype === "uint16") { c = new Float32Array(d.length); for (let h = 0; h < d.length; h++) { let g = d[h]; c[h] = g * p.scale + p.min; } } else if (p.dtype === "float16") n === void 0 && (n = Yj()), c = n(d); else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`); else if (i === "int32") { if (p.dtype !== "uint8" && p.dtype !== "uint16") throw new Error(`Unsupported quantization type ${p.dtype} for weight type int32.`); c = new Int32Array(d.length); for (let h = 0; h < d.length; h++) { let g = d[h]; c[h] = Math.round(g * p.scale + p.min); } } else throw new Error(`Unsupported dtype in weight '${a}': ${i}`); o += u * m; } else if (i === "string") { let p = nt(s.shape); c = []; for (let m = 0; m < p; m++) { let f = new Uint32Array(r.slice(o, o + rg))[0]; o += rg; let d = new Uint8Array(r.slice(o, o + f)); c.push(d), o += f; } } else { let p = Vm[i], m = r.slice(o, o + u * p); if (i === "float32") c = new Float32Array(m); else if (i === "int32") c = new Int32Array(m); else if (i === "bool") c = new Uint8Array(m); else if (i === "complex64") { c = new Float32Array(m); let f = new Float32Array(c.length / 2), d = new Float32Array(c.length / 2); for (let y = 0; y < f.length; y++) f[y] = c[y * 2], d[y] = c[y * 2 + 1]; let h = vr(f, l, "float32"), g = vr(d, l, "float32"); t[a] = $n(h, g), h.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${a}': ${i}`); o += u * p; } i !== "complex64" && (t[a] = vr(c, l, i)); } return t; } function Hj(r) { if (r === null) throw new Error(`Invalid input value: ${JSON.stringify(r)}`); let e = 0, t = []; r.forEach((s) => { if (e += s.byteLength, t.push(s.byteLength === s.buffer.byteLength ? s : new s.constructor(s)), !(s instanceof Float32Array || s instanceof Int32Array || s instanceof Uint8Array)) throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`); }); let n = new Uint8Array(e), o = 0; return t.forEach((s) => { n.set(new Uint8Array(s.buffer), o), o += s.byteLength; }), n.buffer; } var Pw = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); function N1(r) { return Pw ? Buffer.byteLength(r) : new Blob([r]).size; } function T1(r) { if (Pw) return Buffer.from(r).toString("base64"); let e = new Uint8Array(r), t = ""; for (let n = 0, o = e.length; n < o; n++) t += String.fromCharCode(e[n]); return btoa(t); } function E1(r) { if (Pw) { let n = Buffer.from(r, "base64"); return n.buffer.slice(n.byteOffset, n.byteOffset + n.byteLength); } let e = atob(r), t = new Uint8Array(e.length); for (let n = 0; n < e.length; ++n) t.set([e.charCodeAt(n)], n); return t.buffer; } function rp(r) { if (r.length === 1) return r[0]; let e = 0; r.forEach((o) => { e += o.byteLength; }); let t = new Uint8Array(e), n = 0; return r.forEach((o) => { t.set(new Uint8Array(o), n), n += o.byteLength; }), t.buffer; } function Mw(r) { let e = "/"; for (r = r.trim(); r.endsWith(e); ) r = r.slice(0, r.length - 1); let t = r.split(e); return t[t.length - 1]; } function og(r, e) { let t = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy, weightsManifest: e }; return r.signature != null && (t.signature = r.signature), r.userDefinedMetadata != null && (t.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (t.modelInitializer = r.modelInitializer), r.trainingConfig != null && (t.trainingConfig = r.trainingConfig), t; } async function np(r, e) { let t = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy }; if (r.trainingConfig != null && (t.trainingConfig = r.trainingConfig), r.weightsManifest != null) { let [n, o] = await e(r.weightsManifest); t.weightSpecs = n, t.weightData = o; } return r.signature != null && (t.signature = r.signature), r.userDefinedMetadata != null && (t.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (t.modelInitializer = r.modelInitializer), t; } function ii(r) { if (r.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer."); return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: r.modelTopology == null ? 0 : N1(JSON.stringify(r.modelTopology)), weightSpecsBytes: r.weightSpecs == null ? 0 : N1(JSON.stringify(r.weightSpecs)), weightDataBytes: r.weightData == null ? 0 : r.weightData.byteLength }; } function qj() { let r = (t) => { let n = t << 13, o = 0; for (; (n & 8388608) == 0; ) o -= 8388608, n <<= 1; return n &= ~8388608, o += 947912704, n | o; }, e = new Uint32Array(2048); e[0] = 0; for (let t = 1; t < 1024; t++) e[t] = r(t); for (let t = 1024; t < 2048; t++) e[t] = 939524096 + (t - 1024 << 13); return e; } function Kj() { let r = new Uint32Array(64); r[0] = 0, r[31] = 1199570944, r[32] = 2147483648, r[63] = 3347054592; for (let e = 1; e < 31; e++) r[e] = e << 23; for (let e = 33; e < 63; e++) r[e] = 2147483648 + (e - 32 << 23); return r; } function Xj() { let r = new Uint32Array(64); for (let e = 0; e < 64; e++) r[e] = 1024; return r[0] = r[32] = 0, r; } function Yj() { let r = qj(), e = Kj(), t = Xj(); return (n) => { let o = new ArrayBuffer(4 * n.length), s = new Uint32Array(o); for (let a = 0; a < n.length; a++) { let i = n[a], l = r[t[i >> 10] + (i & 1023)] + e[i >> 10]; s[a] = l; } return new Float32Array(o); }; } var vt = class { constructor() { this.saveRouters = [], this.loadRouters = []; } static getInstance() { return vt.instance == null && (vt.instance = new vt()), vt.instance; } static registerSaveRouter(e) { vt.getInstance().saveRouters.push(e); } static registerLoadRouter(e) { vt.getInstance().loadRouters.push(e); } static getSaveHandlers(e) { return vt.getHandlers(e, "save"); } static getLoadHandlers(e, t) { return vt.getHandlers(e, "load", t); } static getHandlers(e, t, n) { let o = []; return (t === "load" ? vt.getInstance().loadRouters : vt.getInstance().saveRouters).forEach((a) => { let i = a(e, n); i !== null && o.push(i); }), o; } }; var A1 = (r) => vt.registerSaveRouter(r); var $1 = (r) => vt.registerLoadRouter(r); var D1 = (r) => vt.getSaveHandlers(r); var R1 = (r, e) => vt.getLoadHandlers(r, e); var Lw = "tensorflowjs"; var zw = 1; var eu = "models_store"; var cl = "model_info_store"; function F1() { if (!j().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); let r = typeof window == "undefined" ? self : window, e = r.indexedDB || r.mozIndexedDB || r.webkitIndexedDB || r.msIndexedDB || r.shimIndexedDB; if (e == null) throw new Error("The current browser does not appear to support IndexedDB."); return e; } function Bw(r) { let e = r.result; e.createObjectStore(eu, { keyPath: "modelPath" }), e.createObjectStore(cl, { keyPath: "modelPath" }); } var da = class { constructor(e) { if (this.indexedDB = F1(), e == null || !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((n, o) => { let s = this.indexedDB.open(Lw, zw); s.onupgradeneeded = () => Bw(s), s.onsuccess = () => { let a = s.result; if (t == null) { let i = a.transaction(eu, "readonly"), u = i.objectStore(eu).get(this.modelPath); u.onsuccess = () => { if (u.result == null) return a.close(), o(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`)); n(u.result.modelArtifacts); }, u.onerror = (c) => (a.close(), o(u.error)), i.oncomplete = () => a.close(); } else { let i = ii(t), l = a.transaction(cl, "readwrite"), u = l.objectStore(cl), c = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), p; c.onsuccess = () => { p = a.transaction(eu, "readwrite"); let f = p.objectStore(eu).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); f.onsuccess = () => n({ modelArtifactsInfo: i }), f.onerror = (d) => { u = l.objectStore(cl); let h = u.delete(this.modelPath); h.onsuccess = () => (a.close(), o(f.error)), h.onerror = (g) => (a.close(), o(f.error)); }; }, c.onerror = (m) => (a.close(), o(c.error)), l.oncomplete = () => { p == null ? a.close() : p.oncomplete = () => a.close(); }; } }, s.onerror = (a) => o(s.error); }); } }; da.URL_SCHEME = "indexeddb://"; var O1 = (r) => j().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(da.URL_SCHEME) ? Zj(r.slice(da.URL_SCHEME.length)) : null; vt.registerSaveRouter(O1); vt.registerLoadRouter(O1); function Zj(r) { return new da(r); } function Jj(r) { return r.startsWith(da.URL_SCHEME) ? r.slice(da.URL_SCHEME.length) : r; } var Vw = class { constructor() { this.indexedDB = F1(); } async listModels() { return new Promise((e, t) => { let n = this.indexedDB.open(Lw, zw); n.onupgradeneeded = () => Bw(n), n.onsuccess = () => { let o = n.result, s = o.transaction(cl, "readonly"), i = s.objectStore(cl).getAll(); i.onsuccess = () => { let l = {}; for (let u of i.result) l[u.modelPath] = u.modelArtifactsInfo; e(l); }, i.onerror = (l) => (o.close(), t(i.error)), s.oncomplete = () => o.close(); }, n.onerror = (o) => t(n.error); }); } async removeModel(e) { return e = Jj(e), new Promise((t, n) => { let o = this.indexedDB.open(Lw, zw); o.onupgradeneeded = () => Bw(o), o.onsuccess = () => { let s = o.result, a = s.transaction(cl, "readwrite"), i = a.objectStore(cl), l = i.get(e), u; l.onsuccess = () => { if (l.result == null) return s.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { let c = i.delete(e), p = () => { u = s.transaction(eu, "readwrite"); let f = u.objectStore(eu).delete(e); f.onsuccess = () => t(l.result.modelArtifactsInfo), f.onerror = (d) => n(l.error); }; c.onsuccess = p, c.onerror = (m) => (p(), s.close(), n(l.error)); } }, l.onerror = (c) => (s.close(), n(l.error)), a.oncomplete = () => { u == null ? s.close() : u.oncomplete = () => s.close(); }; }, o.onerror = (s) => n(o.error); }); } }; var ha = "/"; var op = "tensorflowjs_models"; var P1 = "info"; var Qj = "model_topology"; var eG = "weight_specs"; var tG = "weight_data"; var rG = "model_metadata"; function M1(r) { return { info: [op, r, P1].join(ha), topology: [op, r, Qj].join(ha), weightSpecs: [op, r, eG].join(ha), weightData: [op, r, tG].join(ha), modelMetadata: [op, r, rG].join(ha) }; } function L1(r) { for (let e of Object.values(r)) window.localStorage.removeItem(e); } function nG(r) { let e = r.split(ha); if (e.length < 3) throw new Error(`Invalid key format: ${r}`); return e.slice(1, e.length - 1).join(ha); } function oG(r) { return r.startsWith(ga.URL_SCHEME) ? r.slice(ga.URL_SCHEME.length) : r; } var ga = class { constructor(e) { if (!j().getBool("IS_BROWSER") || typeof window == "undefined" || typeof window.localStorage == "undefined") throw new Error("The current environment does not support local storage."); if (this.LS = window.localStorage, e == null || !e) throw new Error("For local storage, modelPath must not be null, undefined or empty."); this.modelPath = e, this.keys = M1(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."); { let t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), o = ii(e); try { this.LS.setItem(this.keys.info, JSON.stringify(o)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, T1(e.weightData)); let s = { format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, signature: e.signature != null ? e.signature : void 0, userDefinedMetadata: e.userDefinedMetadata != null ? e.userDefinedMetadata : void 0, modelInitializer: e.modelInitializer != null ? e.modelInitializer : void 0, trainingConfig: e.trainingConfig != null ? e.trainingConfig : void 0 }; return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(s)), { modelArtifactsInfo: o }; } catch (s) { throw L1(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=${o.modelTopologyBytes}, weightSpecsBytes=${o.weightSpecsBytes}, weightDataBytes=${o.weightDataBytes}.`); } } } async load() { let e = JSON.parse(this.LS.getItem(this.keys.info)); if (e == null) throw new Error(`In local storage, there is no model with name '${this.modelPath}'`); if (e.modelTopologyType !== "JSON") throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet."); let t = {}, n = JSON.parse(this.LS.getItem(this.keys.topology)); if (n == null) throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`); t.modelTopology = n; let o = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); if (o == null) throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`); t.weightSpecs = o; let s = this.LS.getItem(this.keys.modelMetadata); if (s != null) { let i = JSON.parse(s); t.format = i.format, t.generatedBy = i.generatedBy, t.convertedBy = i.convertedBy, i.signature != null && (t.signature = i.signature), i.userDefinedMetadata != null && (t.userDefinedMetadata = i.userDefinedMetadata), i.modelInitializer != null && (t.modelInitializer = i.modelInitializer), i.trainingConfig != null && (t.trainingConfig = i.trainingConfig); } let a = this.LS.getItem(this.keys.weightData); if (a == null) throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`); return t.weightData = E1(a), t; } }; ga.URL_SCHEME = "localstorage://"; var z1 = (r) => j().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(ga.URL_SCHEME) ? sG(r.slice(ga.URL_SCHEME.length)) : null; vt.registerSaveRouter(z1); vt.registerLoadRouter(z1); function sG(r) { return new ga(r); } var Ww = class { constructor() { E(j().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), E(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage; } async listModels() { let e = {}, t = op + ha, n = ha + P1; for (let o = 0; o < this.LS.length; ++o) { let s = this.LS.key(o); if (s.startsWith(t) && s.endsWith(n)) { let a = nG(s); e[a] = JSON.parse(this.LS.getItem(s)); } } return e; } async removeModel(e) { e = oG(e); let t = M1(e); if (this.LS.getItem(t.info) == null) throw new Error(`Cannot find model at path '${e}'`); let n = JSON.parse(this.LS.getItem(t.info)); return L1(t), n; } }; var sp = "://"; var Zr = class { constructor() { this.managers = {}; } static getInstance() { return Zr.instance == null && (Zr.instance = new Zr()), Zr.instance; } static registerManager(e, t) { E(e != null, () => "scheme must not be undefined or null."), e.endsWith(sp) && (e = e.slice(0, e.indexOf(sp))), E(e.length > 0, () => "scheme must not be an empty string."); let n = Zr.getInstance(); E(n.managers[e] == null, () => `A model store manager is already registered for scheme '${e}'.`), n.managers[e] = t; } static getManager(e) { let t = this.getInstance().managers[e]; if (t == null) throw new Error(`Cannot find model manager for scheme '${e}'`); return t; } static getSchemes() { return Object.keys(this.getInstance().managers); } }; function sg(r) { if (r.indexOf(sp) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Zr.getSchemes().join(",")}`); return { scheme: r.split(sp)[0], path: r.split(sp)[1] }; } async function B1(r, e, t = false) { E(r !== e, () => `Old path and new path are the same: '${r}'`); let n = vt.getLoadHandlers(r); E(n.length > 0, () => `Copying failed because no load handler is found for source URL ${r}.`), E(n.length < 2, () => `Copying failed because more than one (${n.length}) load handlers for source URL ${r}.`); let o = n[0], s = vt.getSaveHandlers(e); E(s.length > 0, () => `Copying failed because no save handler is found for destination URL ${e}.`), E(s.length < 2, () => `Copying failed because more than one (${n.length}) save handlers for destination URL ${e}.`); let a = s[0], i = sg(r).scheme, l = sg(r).path, u = i === sg(r).scheme, c = await o.load(); t && u && await Zr.getManager(i).removeModel(l); let p = await a.save(c); return t && !u && await Zr.getManager(i).removeModel(l), p.modelArtifactsInfo; } async function V1() { let r = Zr.getSchemes(), e = {}; for (let t of r) { let n = await Zr.getManager(t).listModels(); for (let o in n) { let s = t + sp + o; e[s] = n[o]; } } return e; } async function W1(r) { let e = sg(r); return Zr.getManager(e.scheme).removeModel(e.path); } async function j1(r, e) { return B1(r, e, false); } async function G1(r, e) { return B1(r, e, true); } var U1 = class { fetch(e, t) { return fetch(e, t); } now() { return performance.now(); } encode(e, t) { if (t !== "utf-8" && t !== "utf8") throw new Error(`Browser's encoder only supports utf-8, but got ${t}`); return this.textEncoder == null && (this.textEncoder = new TextEncoder()), this.textEncoder.encode(e); } decode(e, t) { return new TextDecoder(t).decode(e); } }; if (j().get("IS_BROWSER")) { j().setPlatform("browser", new U1()); try { Zr.registerManager(ga.URL_SCHEME, new Ww()); } catch (r) { } try { Zr.registerManager(da.URL_SCHEME, new Vw()); } catch (r) { } } var iG = { importFetch: () => H1() }; var jw; var q1 = class { constructor() { this.util = pc("util"), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { return j().global.fetch != null ? j().global.fetch(e, t) : (jw == null && (jw = iG.importFetch()), jw(e, t)); } now() { let e = process.hrtime(); return e[0] * 1e3 + e[1] / 1e6; } encode(e, t) { if (t !== "utf-8" && t !== "utf8") throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`); return this.textEncoder.encode(e); } decode(e, t) { return e.length === 0 ? "" : new this.util.TextDecoder(t).decode(e); } }; j().get("IS_NODE") && j().setPlatform("node", new q1()); function Se(r, e = "float32", t) { return e = e || "float32", Tm(r), new ct(r, e, t); } function aG(r, e) { let t = _(r, "x", "cast"); if (!dw(e)) throw new Error(`Failed to cast to unknown dtype ${e}`); if (e === "string" && t.dtype !== "string" || e !== "string" && t.dtype === "string") throw new Error("Only strings can be casted to strings"); let n = { x: t }, o = { dtype: e }; return T.runKernel(Qn, n, o); } var J = I({ cast_: aG }); function lG(r) { let t = { x: _(r, "x", "clone", "string_or_numeric") }; return T.runKernel(to, t); } var hn = I({ clone_: lG }); function Gw(r, e = false) { console.log(r.toString(e)); } Fw(); var uG = { buffer: Se, cast: J, clone: hn, print: Gw }; w1(uG); var $r = {}; He($r, { browserFiles: () => Y1, browserHTTPRequest: () => Q1, concatenateArrayBuffers: () => rp, copyModel: () => j1, decodeWeights: () => ng, encodeWeights: () => I1, fromMemory: () => tN, getLoadHandlers: () => R1, getModelArtifactsForJSON: () => np, getModelArtifactsInfoForJSON: () => ii, getSaveHandlers: () => D1, http: () => lg, isHTTPScheme: () => ag, listModels: () => V1, loadWeights: () => Z1, moveModel: () => G1, registerLoadRouter: () => $1, registerSaveRouter: () => A1, removeModel: () => W1, weightsLoaderFactory: () => qw, withSaveHandler: () => rN }); var cG = "model"; var pG = ".json"; var mG = ".weights.bin"; function K1(r) { return new Promise((e) => setTimeout(e)).then(r); } var pl = class { constructor(e) { if (!j().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(pl.URL_SCHEME) && (e = e.slice(pl.URL_SCHEME.length)), (e == null || e.length === 0) && (e = cG), this.modelJsonFileName = e + pG, this.weightDataFileName = e + mG; } async save(e) { if (typeof document == "undefined") throw new Error("Browser downloads are not supported in this environment since `document` is not present"); let t = window.URL.createObjectURL(new Blob([e.weightData], { type: "application/octet-stream" })); if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet."); { let n = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], o = og(e, n), s = window.URL.createObjectURL(new Blob([JSON.stringify(o)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; if (a.download = this.modelJsonFileName, a.href = s, await K1(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) { let i = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; i.download = this.weightDataFileName, i.href = t, await K1(() => i.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: ii(e) }; } } }; pl.URL_SCHEME = "downloads://"; var X1 = class { constructor(e) { if (e == null || 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) => { let n = new FileReader(); n.onload = (o) => { let s = JSON.parse(o.target.result), a = s.modelTopology; if (a == null) { t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); return; } if (s.weightsManifest == null) { t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`)); return; } if (this.weightsFiles.length === 0) { e({ modelTopology: a }); return; } let l = np(s, (u) => this.loadWeights(u)); e(l); }, n.onerror = (o) => 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) { let t = [], n = []; for (let a of e) t.push(...a.weights), n.push(...a.paths); let o = this.checkManifestAndWeightFiles(e), s = n.map((a) => this.loadWeightsFile(a, o[a])); return Promise.all(s).then((a) => [t, rp(a)]); } loadWeightsFile(e, t) { return new Promise((n, o) => { let s = new FileReader(); s.onload = (a) => { let i = a.target.result; n(i); }, s.onerror = (a) => o(`Failed to weights data from file of path '${e}'.`), s.readAsArrayBuffer(t); }); } checkManifestAndWeightFiles(e) { let t = [], n = this.weightsFiles.map((s) => Mw(s.name)), o = {}; for (let s of e) s.paths.forEach((a) => { let i = Mw(a); if (t.indexOf(i) !== -1) throw new Error(`Duplicate file basename found in weights manifest: '${i}'`); if (t.push(i), n.indexOf(i) === -1) throw new Error(`Weight file with basename '${i}' is not provided.`); o[a] = 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 o; } }; var fG = (r) => j().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(pl.URL_SCHEME) ? dG(r.slice(pl.URL_SCHEME.length)) : null; vt.registerSaveRouter(fG); function dG(r = "model") { return new pl(r); } function Y1(r) { return new X1(r); } function Uw(r, e, t, n) { a(r), t = t == null ? 0 : t, n = n == null ? 1 : n, i(t, n); let o = 0, s = (l) => (l.then((u) => { let c = t + ++o / r.length * (n - t); return e(c), u; }), l); function a(l) { E(l != null && Array.isArray(l) && l.length > 0, () => "promises must be a none empty array"); } function i(l, u) { E(l >= 0 && l <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${l}`), E(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${u}`), E(u >= l, () => `startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`); } return Promise.all(r.map(s)); } async function Hw(r, e) { e == null && (e = {}); let t = e.fetchFunc == null ? j().platform.fetch : e.fetchFunc, n = r.map((p) => t(p, e.requestInit, { isBinary: true })), o = 0, s = 0.5, i = (e.onProgress == null ? await Promise.all(n) : await Uw(n, e.onProgress, o, s)).map((p) => p.arrayBuffer()), l = 0.5, u = 1; return e.onProgress == null ? await Promise.all(i) : await Uw(i, e.onProgress, l, u); } async function Z1(r, e = "", t, n) { return qw((a) => Hw(a, { requestInit: n }))(r, e, t); } function qw(r) { return async (e, t = "", n) => { let o = e.map(() => false), s = {}, a = n != null ? n.map(() => false) : [], i = []; if (e.forEach((f, d) => { let h = 0; f.weights.forEach((g) => { let y = "quantization" in g ? g.quantization.dtype : g.dtype, w = Vm[y] * nt(g.shape), x = () => { o[d] = true, s[d] == null && (s[d] = []), s[d].push({ manifestEntry: g, groupOffset: h, sizeBytes: w }); }; n != null ? n.forEach((k, C) => { k === g.name && (x(), a[C] = true); }) : x(), i.push(g.name), h += w; }); }), !a.every((f) => f)) { let f = n.filter((d, h) => !a[h]); throw new Error(`Could not find weights in manifest with names: ${f.join(", ")}. Manifest JSON has weights with names: ${i.join(", ")}.`); } let l = o.reduce((f, d, h) => (d && f.push(h), f), []), u = []; l.forEach((f) => { e[f].paths.forEach((d) => { let h = t + (t.endsWith("/") ? "" : "/") + d; u.push(h); }); }); let c = await r(u), p = {}, m = 0; return l.forEach((f) => { let d = e[f].paths.length, h = 0; for (let k = 0; k < d; k++) h += c[m + k].byteLength; let g = new ArrayBuffer(h), y = new Uint8Array(g), w = 0; for (let k = 0; k < d; k++) { let C = new Uint8Array(c[m + k]); y.set(C, w), w += C.byteLength; } s[f].forEach((k) => { let C = g.slice(k.groupOffset, k.groupOffset + k.sizeBytes), A = ng(C, [k.manifestEntry]); for (let $ in A) p[$] = A[$]; }), m += d; }), p; }; } var hG = "application/octet-stream"; var gG = "application/json"; var ig = class { constructor(e, t) { if (this.DEFAULT_METHOD = "POST", t == null && (t = {}), this.weightPathPrefix = t.weightPathPrefix, this.onProgress = t.onProgress, this.weightUrlConverter = t.weightUrlConverter, t.fetchFunc != null ? (E(typeof t.fetchFunc == "function", () => "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 = j().platform.fetch, E(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && E(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t.requestInit != null && t.requestInit.body != null) throw new Error("requestInit is expected to have no pre-existing body, but has one."); this.requestInit = t.requestInit || {}; } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); let t = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit); t.body = new FormData(); let n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], o = og(e, n); t.body.append("model.json", new Blob([JSON.stringify(o)], { type: gG }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: hG }), "model.weights.bin"); let s = await this.fetch(this.path, t); if (s.ok) return { modelArtifactsInfo: ii(e), responses: [s] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.status}.`); } async load() { let 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 (s) { let a = `Failed to parse model JSON of response from ${this.path}.`; throw this.path.endsWith(".pb") ? a += " 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." : a += " Please make sure the server is serving valid JSON for this request.", new Error(a); } let n = t.modelTopology, o = t.weightsManifest; if (n == null && o == null) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); return np(t, (s) => this.loadWeights(s)); } async loadWeights(e) { let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, o] = xG(t), s = this.weightPathPrefix || n, a = []; for (let c of e) a.push(...c.weights); let i = [], l = []; for (let c of e) for (let p of c.paths) this.weightUrlConverter != null ? l.push(this.weightUrlConverter(p)) : i.push(s + p + o); this.weightUrlConverter && i.push(...await Promise.all(l)); let u = await Hw(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); return [a, rp(u)]; } }; ig.URL_SCHEME_REGEX = /^https?:\/\//; function xG(r) { let e = r.lastIndexOf("/"), t = r.lastIndexOf("?"), n = r.substring(0, e), o = t > e ? r.substring(t) : ""; return [n + "/", o]; } function ag(r) { return r.match(ig.URL_SCHEME_REGEX) != null; } var J1 = (r, e) => { if (typeof fetch == "undefined" && (e == null || e.fetchFunc == null)) return null; { let t = true; if (Array.isArray(r) ? t = r.every((n) => ag(n)) : t = ag(r), t) return lg(r, e); } return null; }; vt.registerSaveRouter(J1); vt.registerLoadRouter(J1); function lg(r, e) { return new ig(r, e); } function Q1(r, e) { return lg(r, e); } var ug = class { constructor(e) { this.modelArtifacts = e; } async load() { return this.modelArtifacts; } }; var eN = class { constructor(e) { this.saveHandler = e; } async save(e) { return this.saveHandler(e); } }; function tN(r, e, t, n) { return arguments.length === 1 ? r.modelTopology != null || r.weightSpecs != null ? new ug(r) : (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 ug({ modelTopology: r })) : (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 ug({ modelTopology: r, weightSpecs: e, weightData: t, trainingConfig: n })); } function rN(r) { return new eN(r); } var oN = {}; He(oN, { confusionMatrix: () => nN }); function yG(r, e, t = false, n = false) { let o = _(r, "a", "matMul"), s = _(e, "b", "matMul"); [o, s] = Ge(o, s); let a = { a: o, b: s }, i = { transposeA: t, transposeB: n }; return T.runKernel(To, a, i); } var Me = I({ matMul_: yG }); function bG(r, e, t = 1, n = 0) { if (e < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`); let s = { indices: _(r, "indices", "oneHot", "int32") }, a = { depth: e, onValue: t, offValue: n }; return T.runKernel(Qo, s, a); } var xa = I({ oneHot_: bG }); function wG(r, e) { let t = _(r, "x", "transpose"); if (e == null && (e = t.shape.map((s, a) => a).reverse()), E(t.rank === e.length, () => `Error in transpose: rank of input ${t.rank} must match length of perm ${e}.`), e.forEach((s) => { E(s >= 0 && s < t.rank, () => `All entries in 'perm' must be between 0 and ${t.rank - 1} but got ${e}`); }), t.rank <= 1) return t.clone(); let n = { x: t }, o = { perm: e }; return T.runKernel(ys, n, o); } var Ve = I({ transpose_: wG }); function kG(r, e, t) { let n = _(r, "labels", "confusionMatrix"), o = _(e, "predictions", "confusionMatrix"); E(t == null || t > 0 && Number.isInteger(t), () => `If provided, numClasses must be a positive integer, but got ${t}`), E(n.rank === 1, () => `Expected the rank of labels to be 1, but got ${n.rank}`), E(o.rank === 1, () => `Expected the rank of predictions to be 1, but got ${o.rank}`), E(n.shape[0] === o.shape[0], () => `Mismatch in the number of examples: ${n.shape[0]} vs. ${o.shape[0]}. Labels and predictions should have the same number of elements.`), E(t > 0 && Number.isInteger(t), () => `numClasses is required to be a positive integer, but got ${t}`); let s = xa(J(n, "int32"), t), a = xa(J(o, "int32"), t), i = Ve(s), l = Me(i, a); return J(l, "int32"); } var nN = I({ confusionMatrix_: kG }); var cg = {}; He(cg, { fromPixels: () => TG, fromPixelsAsync: () => IG, toPixels: () => NG }); function Kw(r, e, t) { if (Bn(r), e != null && e.length !== 3) throw new Error("tensor3d() requires shape to have three numbers"); let n = Ar(r, t); if (n.length !== 3 && n.length !== 1) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (n.length === 1 && e == null) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); return Yr(r, e, n, t); } var ip; function sN(r, e = 3) { if (e > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (r == null) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); let t = false, n = false, o = false, s = false, a = false, i = false; if (r.data instanceof Uint8Array) t = true; else if (typeof ImageData != "undefined" && r instanceof ImageData) n = true; else if (typeof HTMLVideoElement != "undefined" && r instanceof HTMLVideoElement) o = true; else if (typeof HTMLImageElement != "undefined" && r instanceof HTMLImageElement) s = true; else if (r.getContext != null) a = true; else if (typeof ImageBitmap != "undefined" && r instanceof ImageBitmap) i = true; else 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 ${r.constructor.name}`); if (o) { let d = 2; if (o && r.readyState < d) throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the