/* Human homepage: author: ' */ var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all2) => { for (var name in all2) __defProp(target, name, { get: all2[name], enumerable: true }); }; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; 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/util/util.ts function log(...msg) { const dt2 = new Date(); const ts2 = `${dt2.getHours().toString().padStart(2, "0")}:${dt2.getMinutes().toString().padStart(2, "0")}:${dt2.getSeconds().toString().padStart(2, "0")}.${dt2.getMilliseconds().toString().padStart(3, "0")}`; if (msg) console.log(ts2, "Human:", ...msg); } 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(`modelpath error: expecting json file: ${path}`); return path; } var now = () => { if (typeof performance !== "undefined") return performance.now(); return parseInt((Number(process.hrtime.bigint()) / 1e3 / 1e3).toString()); }; function validate(defaults, config3, parent = "config", msgs = []) { for (const key of Object.keys(config3)) { if (typeof config3[key] === "object") { validate(defaults[key], config3[key], key, msgs); } else { const defined = defaults && typeof defaults[key] !== "undefined"; if (!defined) msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` }); const same = defaults && typeof defaults[key] === typeof config3[key]; if (defined && !same) msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] }); } } if (config3.debug && parent === "config" && msgs.length > 0) log("invalid configuration", msgs); return msgs; } 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: "", modelBasePath: "", cacheModels: true, wasmPath: "", debug: true, async: true, warmup: "full", cacheSensitivity: 0.7, skipAllowed: false, deallocate: false, filter: { enabled: true, equalization: false, 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: 1, skipFrames: 99, skipTime: 2500, minConfidence: 0.2, iouThreshold: 0.1, mask: false, return: false }, mesh: { enabled: true, modelPath: "facemesh.json" }, iris: { enabled: true, modelPath: "iris.json" }, emotion: { enabled: true, minConfidence: 0.1, skipFrames: 99, skipTime: 1500, modelPath: "emotion.json" }, description: { enabled: true, modelPath: "faceres.json", skipFrames: 99, skipTime: 3e3, minConfidence: 0.1 }, antispoof: { enabled: false, skipFrames: 99, skipTime: 4e3, modelPath: "antispoof.json" }, liveness: { enabled: false, skipFrames: 99, skipTime: 4e3, modelPath: "liveness.json" } }, body: { enabled: true, modelPath: "movenet-lightning.json", maxDetected: -1, minConfidence: 0.3, skipFrames: 1, skipTime: 200 }, hand: { enabled: true, rotation: true, skipFrames: 99, skipTime: 1e3, minConfidence: 0.5, iouThreshold: 0.2, maxDetected: -1, landmarks: true, detector: { modelPath: "handtrack.json" }, skeleton: { modelPath: "handlandmark-full.json" } }, object: { enabled: false, modelPath: "mb3-centernet.json", minConfidence: 0.2, iouThreshold: 0.4, maxDetected: 10, skipFrames: 99, skipTime: 2e3 }, segmentation: { enabled: false, modelPath: "selfie.json", blur: 8 } }; // dist/tfjs.esm.js var tfjs_esm_exports = {}; __export(tfjs_esm_exports, { Abs: () => so, Acos: () => nl, Acosh: () => sl, AdadeltaOptimizer: () => Jg, AdagradOptimizer: () => eb, AdamOptimizer: () => tb, AdamaxOptimizer: () => nb, Add: () => Cr, AddN: () => wa, All: () => rl, Any: () => al, ArgMax: () => ka, ArgMin: () => il, Asin: () => ol, Asinh: () => ul, Atan: () => ll, Atan2: () => dl, Atanh: () => cl, AvgPool: () => Ia, AvgPool3D: () => Md, AvgPool3DGrad: () => qm, AvgPoolGrad: () => Hm, BackendWasm: () => Bce, BatchMatMul: () => Sa, BatchToSpaceND: () => ro, Bincount: () => jm, BroadcastArgs: () => Km, BroadcastTo: () => t$, Callback: () => X4, CallbackList: () => oL, Cast: () => Ca, Ceil: () => Na, ClipByValue: () => Nr, Complex: () => Ld, ComplexAbs: () => Bd, Concat: () => ao, Conv2D: () => Ta, Conv2DBackpropFilter: () => Xm, Conv2DBackpropInput: () => $a, Conv3D: () => Vd, Conv3DBackpropFilterV2: () => Ym, Conv3DBackpropInputV2: () => Qm, Cos: () => Aa, Cosh: () => Ea, CropAndResize: () => oo, Cumsum: () => io, CustomCallback: () => cL, DataStorage: () => Od, DenseBincount: () => Zm, DepthToSpace: () => uo, DepthwiseConv2dNative: () => _a, DepthwiseConv2dNativeBackpropFilter: () => Jm, DepthwiseConv2dNativeBackpropInput: () => eg, Diag: () => tg, Dilation2D: () => Wd, Dilation2DBackpropFilter: () => zf, Dilation2DBackpropInput: () => Pf, ENV: () => Cw, EarlyStopping: () => Y4, Einsum: () => Ud, Elu: () => Da, EluGrad: () => ng, Environment: () => XT, Equal: () => lo, Erf: () => pl, Exp: () => Fa, ExpandDims: () => co, Expm1: () => po, FFT: () => sg, Fill: () => hl, FlipLeftRight: () => ho, Floor: () => Oa, FloorDiv: () => Pa, FromPixels: () => id, FusedBatchNorm: () => za, FusedConv2D: () => ra, FusedDepthwiseConv2D: () => aa, GPGPUContext: () => Ff, GatherNd: () => mo, GatherV2: () => fo, GraphModel: () => tW, Greater: () => go, GreaterEqual: () => Ma, History: () => lL, IFFT: () => rg, Identity: () => La, Imag: () => Gd, InputSpec: () => Rt, IsFinite: () => fl, IsInf: () => ml, IsNan: () => gl, KernelBackend: () => tl, LRN: () => qd, LRNGrad: () => ig, LayerVariable: () => eL, LayersModel: () => mr, LeakyRelu: () => Ba, Less: () => bo, LessEqual: () => yo, LinSpace: () => ag, Log: () => Va, Log1p: () => bl, LogSoftmax: () => n$, LogicalAnd: () => vo, LogicalNot: () => yl, LogicalOr: () => Hd, MathBackendCPU: () => cS, MathBackendWebGL: () => uC, Max: () => Wa, MaxPool: () => Ga, MaxPool3D: () => jd, MaxPool3DGrad: () => ug, MaxPoolGrad: () => og, MaxPoolWithArgmax: () => lg, Maximum: () => Ua, Mean: () => Ha, Min: () => qa, Minimum: () => ja, MirrorPad: () => Ka, Mod: () => vl, MomentumOptimizer: () => sb, Multinomial: () => cg, Multiply: () => Xa, Neg: () => xo, NonMaxSuppressionV3: () => ko, NonMaxSuppressionV4: () => xl, NonMaxSuppressionV5: () => Io, NotEqual: () => wo, OP_SCOPE_SUFFIX: () => F$, OneHot: () => Co, OnesLike: () => So, Optimizer: () => _r, OptimizerConstructors: () => Wr, Pack: () => No, PadV2: () => Ya, Pool: () => qce, Pow: () => Qa, Prelu: () => Za, Prod: () => To, RMSPropOptimizer: () => rb, RNN: () => Rr, Range: () => wl, Rank: () => C$, Real: () => Kd, RealDiv: () => Ra, Reciprocal: () => kl, Reduction: () => EF, Relu: () => Ja, Relu6: () => ti, Reshape: () => $o, ResizeBilinear: () => ei, ResizeBilinearGrad: () => pg, ResizeNearestNeighbor: () => Il, ResizeNearestNeighborGrad: () => dg, Reverse: () => Ao, RotateWithOffset: () => Uo, Round: () => Eo, Rsqrt: () => ni, SGDOptimizer: () => fp, ScatterNd: () => _o, Select: () => Ro, Selu: () => Sl, Sequential: () => $b, Sigmoid: () => ri, Sign: () => Cl, Sin: () => si, Sinh: () => Fo, Slice: () => Do, Softmax: () => oi, Softplus: () => Nl, SpaceToBatchND: () => Oo, SparseFillEmptyRows: () => Xd, SparseReshape: () => Tl, SparseSegmentMean: () => Yd, SparseSegmentSum: () => Qd, SparseToDense: () => Zd, SplitV: () => Po, Sqrt: () => ai, Square: () => $l, SquaredDifference: () => ui, Step: () => pi, StridedSlice: () => zo, StringNGrams: () => Jd, StringSplit: () => hg, StringToHashBucketFast: () => fg, Sub: () => li, Sum: () => ii, SymbolicTensor: () => Ns, Tan: () => Mo, Tanh: () => ci, Tensor: () => tt, TensorBuffer: () => Vt, Tile: () => Tr, TopK: () => Lo, Transform: () => Bo, Transpose: () => di, Unique: () => mg, Unpack: () => Vo, UnsortedSegmentSum: () => ep, Variable: () => ud, ZerosLike: () => Wo, _FusedMatMul: () => sa, abs: () => Mt, acos: () => mE, acosh: () => bE, add: () => oe, addN: () => vE, all: () => yk, any: () => Zf, argMax: () => Gu, argMin: () => SE, asin: () => NE, asinh: () => $E, atan: () => EE, atan2: () => RE, atanh: () => FE, avgPool: () => Ag, avgPool3d: () => kk, backend: () => uE, backend_util: () => N, basicLSTMCell: () => cde, batchNorm: () => qu, batchNorm2d: () => JE, batchNorm3d: () => t_, batchNorm4d: () => s_, batchToSpaceND: () => Eg, bincount: () => Ik, booleanMaskAsync: () => Mde, broadcastArgs: () => i_, broadcastTo: () => Kc, broadcast_util: () => Go, browser: () => Zw, buffer: () => _e, callbacks: () => Kde, cast: () => pe, ceil: () => l_, clipByValue: () => Vn, clone: () => pr, complex: () => ia, concat: () => Dt, concat1d: () => p_, concat2d: () => f_, concat3d: () => g_, concat4d: () => y_, constraints: () => uM, conv1d: () => Sk, conv2d: () => la, conv2dTranspose: () => Ck, conv3d: () => Nk, conv3dTranspose: () => N_, copyRegisteredKernels: () => Xce, cos: () => Rg, cosh: () => $k, cosineWindow: () => Jk, cumsum: () => Ak, customGrad: () => qs, data: () => nW, denseBincount: () => __, deprecationWarn: () => gk, depthToSpace: () => D_, depthwiseConv2d: () => rp, deregisterOp: () => Yde, device_util: () => Rl, diag: () => dde, dilation2d: () => z_, disableDeprecationWarnings: () => Jce, dispose: () => Ee, disposeVariables: () => ede, div: () => Se, divNoNan: () => W_, dot: () => pde, dropout: () => C3, einsum: () => H_, elu: () => ap, enableDebugMode: () => Zce, enableProdMode: () => Qce, enclosingPowerOfTwo: () => N3, engine: () => ks, env: () => X, equal: () => Yn, erf: () => K_, exp: () => Qn, expandDims: () => Pn, expm1: () => Z_, eye: () => Ek, fft: () => Kg, fill: () => Ol, findBackend: () => ode, findBackendFactory: () => ude, floor: () => ip, floorDiv: () => bk, forceHalfFloat: () => hX, fused: () => pa, gather: () => ju, gatherND: () => k3, gather_util: () => ek, getBackend: () => ade, getGradient: () => Rv, getKernel: () => Mf, getKernelsForBackend: () => Lf, getThreadsCount: () => ipe, gpgpu_util: () => tK, grad: () => mde, grads: () => gde, greater: () => Un, greaterEqual: () => Ho, ifft: () => md, imag: () => Dg, image: () => ls, inTopKAsync: () => Bde, initializers: () => gM, input: () => aB, io: () => An, irfft: () => qk, isFinite: () => hde, isInf: () => fde, isNaN: () => lR, keep: () => jt, kernel_impls: () => ys, layers: () => ZM, leakyRelu: () => Fg, less: () => _k, lessEqual: () => qo, linalg: () => cO, linspace: () => hR, loadGraphModel: () => Qde, loadLayersModel: () => qde, localResponseNormalization: () => mR, log: () => Zn, log1p: () => Og, logSigmoid: () => vde, logSoftmax: () => Rk, logSumExp: () => AR, logicalAnd: () => _s, logicalNot: () => Mg, logicalOr: () => Pk, logicalXor: () => xde, losses: () => Ude, matMul: () => Me, math: () => _A, max: () => $s, maxPool: () => Lg, maxPool3d: () => zk, maxPoolWithArgmax: () => zR, maximum: () => Er, mean: () => St, memory: () => Qf, meshgrid: () => wde, metrics: () => $4, min: () => em, minimum: () => up, mirrorPad: () => UR, mod: () => HR, model: () => Gde, models: () => G4, moments: () => Bg, movingAverage: () => Lde, mul: () => V, multiRNNCell: () => kde, multinomial: () => YR, neg: () => It, nextFrame: () => pO, norm: () => Qk, notEqual: () => Ku, oneHot: () => dd, ones: () => Mn, onesLike: () => Jn, op: () => B, outerProduct: () => Ide, pad: () => hi, pad1d: () => Sde, pad2d: () => Cde, pad3d: () => Nde, pad4d: () => Tde, pool: () => $de, pow: () => da, prelu: () => Wg, print: () => fA, prod: () => Mk, profile: () => tde, rand: () => Ade, randomGamma: () => Ede, randomNormal: () => bD, randomUniform: () => zl, range: () => Xu, ready: () => rde, real: () => hd, reciprocal: () => wD, registerBackend: () => sp, registerCallbackConstructor: () => jde, registerGradient: () => r$, registerKernel: () => Al, registerOp: () => Xde, regularizers: () => H4, relu: () => Ks, relu6: () => Lk, removeBackend: () => ide, reshape: () => G, reverse: () => es, reverse1d: () => _de, reverse2d: () => Rde, reverse3d: () => Dde, reverse4d: () => Fde, rfft: () => Xg, round: () => Bk, rsqrt: () => Vk, scalar: () => Ce, scatterND: () => y3, scatter_util: () => nk, selu: () => Wk, separableConv2d: () => DD, sequential: () => Hde, serialization: () => ae, setBackend: () => sde, setPlatform: () => lde, setThreadsCount: () => ape, setWasmPath: () => spe, setWasmPaths: () => rpe, setWebGLContext: () => qj, setdiff1dAsync: () => OD, shared: () => zy, sigmoid: () => Hs, sign: () => zD, signal: () => Wde, sin: () => Uk, sinh: () => Gk, slice: () => He, slice1d: () => Hg, slice2d: () => Hk, slice3d: () => qg, slice4d: () => fd, slice_util: () => kt, softmax: () => jg, softplus: () => Pl, spaceToBatchND: () => Vg, sparse: () => Fc, sparseToDense: () => Zk, spectral: () => Vde, split: () => Bn, sqrt: () => rn, square: () => ct, squaredDifference: () => jk, squeeze: () => yr, stack: () => ts, step: () => lp, stridedSlice: () => n3, string: () => Sf, sub: () => be, sum: () => ve, sumOutType: () => np, tan: () => r3, tanh: () => Hu, tensor: () => ds, tensor1d: () => Jt, tensor2d: () => Hi, tensor3d: () => zA, tensor4d: () => Ode, tensor5d: () => Pde, tensor6d: () => zde, tensor_util: () => Ts, test_util: () => eE, tidy: () => H, tile: () => us, time: () => nde, topk: () => i3, train: () => _i, transpose: () => qe, truncatedNormal: () => Yg, unique: () => Uv, unregisterGradient: () => Kce, unregisterKernel: () => jce, unsortedSegmentSum: () => c3, unstack: () => Rs, upcastType: () => vn, util: () => w, valueAndGrad: () => bde, valueAndGrads: () => yde, variable: () => p3, variableGrads: () => yR, version: () => upe, version_converter: () => Zde, version_core: () => Yce, version_cpu: () => Jde, version_layers: () => DI, version_wasm: () => ope, version_webgl: () => epe, webgl: () => tpe, webgl_util: () => Hj, webgpu: () => Cie, where: () => xn, whereAsync: () => Xk, zeros: () => Tt, zerosLike: () => je }); var cT = Object.create; var Dd = Object.defineProperty; var dT = Object.getOwnPropertyDescriptor; var hw = Object.getOwnPropertyNames; var pT = Object.getPrototypeOf; var hT = Object.prototype.hasOwnProperty; var fT = (e) => Dd(e, "__esModule", { value: true }); var Pt = (e, t) => function() { return t || (0, e[hw(e)[0]])((t = { exports: {} }).exports, t), t.exports; }; var Ae = (e, t) => { for (var n in t) Dd(e, n, { get: t[n], enumerable: true }); }; var mT = (e, t, n, s) => { if (t && typeof t == "object" || typeof t == "function") for (let r of hw(t)) !hT.call(e, r) && (n || r !== "default") && Dd(e, r, { get: () => t[r], enumerable: !(s = dT(t, r)) || s.enumerable }); return e; }; var va = (e, t) => mT(fT(Dd(e != null ? cT(pT(e)) : {}, "default", !t && e && e.__esModule ? { get: () => e.default, enumerable: true } : { value: e, enumerable: true })), e); var gT = Pt({ "src/node_modules/long/src/long.js"(e, t) { t.exports = s; var n = null; try { n = 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 (F) { } function s(F, $, z) { this.low = F | 0, this.high = $ | 0, this.unsigned = !!z; } s.prototype.__isLong__, Object.defineProperty(s.prototype, "__isLong__", { value: true }); function r(F) { return (F && F.__isLong__) === true; } s.isLong = r; var a = {}, i = {}; function o(F, $) { var z, W, q; return $ ? (F >>>= 0, (q = 0 <= F && F < 256) && (W = i[F], W) ? W : (z = c(F, (F | 0) < 0 ? -1 : 0, true), q && (i[F] = z), z)) : (F |= 0, (q = -128 <= F && F < 128) && (W = a[F], W) ? W : (z = c(F, F < 0 ? -1 : 0, false), q && (a[F] = z), z)); } s.fromInt = o; function u(F, $) { if (isNaN(F)) return $ ? x : v; if ($) { if (F < 0) return x; if (F >= g) return _; } else { if (F <= -b) return P; if (F + 1 >= b) return R; } return F < 0 ? u(-F, $).neg() : c(F % m | 0, F / m | 0, $); } s.fromNumber = u; function c(F, $, z) { return new s(F, $, z); } s.fromBits = c; var l = Math.pow; function d(F, $, z) { if (F.length === 0) throw Error("empty string"); if (F === "NaN" || F === "Infinity" || F === "+Infinity" || F === "-Infinity") return v; if (typeof $ == "number" ? (z = $, $ = false) : $ = !!$, z = z || 10, z < 2 || 36 < z) throw RangeError("radix"); var W; if ((W = F.indexOf("-")) > 0) throw Error("interior hyphen"); if (W === 0) return d(F.substring(1), $, z).neg(); for (var q = u(l(z, 8)), K = v, j = 0; j < F.length; j += 8) { var Q = Math.min(8, F.length - j), J = parseInt(F.substring(j, j + Q), z); if (Q < 8) { var ne = u(l(z, Q)); K = K.mul(ne).add(u(J)); } else K = K.mul(q), K = K.add(u(J)); } return K.unsigned = $, K; } s.fromString = d; function p(F, $) { return typeof F == "number" ? u(F, $) : typeof F == "string" ? d(F, $) : c(F.low, F.high, typeof $ == "boolean" ? $ : F.unsigned); } s.fromValue = p; var h = 1 << 16, f = 1 << 24, m = h * h, g = m * m, b = g / 2, y = o(f), v = o(0); s.ZERO = v; var x = o(0, true); s.UZERO = x; var k = o(1); s.ONE = k; var T = o(1, true); s.UONE = T; var C = o(-1); s.NEG_ONE = C; var R = c(-1, 2147483647, false); s.MAX_VALUE = R; var _ = c(-1, -1, true); s.MAX_UNSIGNED_VALUE = _; var P = c(0, -2147483648, false); s.MIN_VALUE = P; var D = s.prototype; D.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low; }, D.toNumber = function() { return this.unsigned ? (this.high >>> 0) * m + (this.low >>> 0) : this.high * m + (this.low >>> 0); }, D.toString = function($) { if ($ = $ || 10, $ < 2 || 36 < $) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) if (this.eq(P)) { var z = u($), W = this.div(z), q = W.mul(z).sub(this); return W.toString($) + q.toInt().toString($); } else return "-" + this.neg().toString($); for (var K = u(l($, 6), this.unsigned), j = this, Q = ""; ; ) { var J = j.div(K), ne = j.sub(J.mul(K)).toInt() >>> 0, se = ne.toString($); if (j = J, j.isZero()) return se + Q; for (; se.length < 6; ) se = "0" + se; Q = "" + se + Q; } }, D.getHighBits = function() { return this.high; }, D.getHighBitsUnsigned = function() { return this.high >>> 0; }, D.getLowBits = function() { return this.low; }, D.getLowBitsUnsigned = function() { return this.low >>> 0; }, D.getNumBitsAbs = function() { if (this.isNegative()) return this.eq(P) ? 64 : this.neg().getNumBitsAbs(); for (var $ = this.high != 0 ? this.high : this.low, z = 31; z > 0 && ($ & 1 << z) == 0; z--) ; return this.high != 0 ? z + 33 : z + 1; }, D.isZero = function() { return this.high === 0 && this.low === 0; }, D.eqz = D.isZero, D.isNegative = function() { return !this.unsigned && this.high < 0; }, D.isPositive = function() { return this.unsigned || this.high >= 0; }, D.isOdd = function() { return (this.low & 1) === 1; }, D.isEven = function() { return (this.low & 1) === 0; }, D.equals = function($) { return r($) || ($ = p($)), this.unsigned !== $.unsigned && this.high >>> 31 === 1 && $.high >>> 31 === 1 ? false : this.high === $.high && this.low === $.low; }, D.eq = D.equals, D.notEquals = function($) { return !this.eq($); }, D.neq = D.notEquals, D.ne = D.notEquals, D.lessThan = function($) { return this.comp($) < 0; }, D.lt = D.lessThan, D.lessThanOrEqual = function($) { return this.comp($) <= 0; }, D.lte = D.lessThanOrEqual, D.le = D.lessThanOrEqual, D.greaterThan = function($) { return this.comp($) > 0; }, D.gt = D.greaterThan, D.greaterThanOrEqual = function($) { return this.comp($) >= 0; }, D.gte = D.greaterThanOrEqual, D.ge = D.greaterThanOrEqual, D.compare = function($) { if (r($) || ($ = p($)), this.eq($)) return 0; var z = this.isNegative(), W = $.isNegative(); return z && !W ? -1 : !z && W ? 1 : this.unsigned ? $.high >>> 0 > this.high >>> 0 || $.high === this.high && $.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub($).isNegative() ? -1 : 1; }, D.comp = D.compare, D.negate = function() { return !this.unsigned && this.eq(P) ? P : this.not().add(k); }, D.neg = D.negate, D.add = function($) { r($) || ($ = p($)); var z = this.high >>> 16, W = this.high & 65535, q = this.low >>> 16, K = this.low & 65535, j = $.high >>> 16, Q = $.high & 65535, J = $.low >>> 16, ne = $.low & 65535, se = 0, te = 0, ie = 0, ee = 0; return ee += K + ne, ie += ee >>> 16, ee &= 65535, ie += q + J, te += ie >>> 16, ie &= 65535, te += W + Q, se += te >>> 16, te &= 65535, se += z + j, se &= 65535, c(ie << 16 | ee, se << 16 | te, this.unsigned); }, D.subtract = function($) { return r($) || ($ = p($)), this.add($.neg()); }, D.sub = D.subtract, D.multiply = function($) { if (this.isZero()) return v; if (r($) || ($ = p($)), n) { var z = n.mul(this.low, this.high, $.low, $.high); return c(z, n.get_high(), this.unsigned); } if ($.isZero()) return v; if (this.eq(P)) return $.isOdd() ? P : v; if ($.eq(P)) return this.isOdd() ? P : v; if (this.isNegative()) return $.isNegative() ? this.neg().mul($.neg()) : this.neg().mul($).neg(); if ($.isNegative()) return this.mul($.neg()).neg(); if (this.lt(y) && $.lt(y)) return u(this.toNumber() * $.toNumber(), this.unsigned); var W = this.high >>> 16, q = this.high & 65535, K = this.low >>> 16, j = this.low & 65535, Q = $.high >>> 16, J = $.high & 65535, ne = $.low >>> 16, se = $.low & 65535, te = 0, ie = 0, ee = 0, ce = 0; return ce += j * se, ee += ce >>> 16, ce &= 65535, ee += K * se, ie += ee >>> 16, ee &= 65535, ee += j * ne, ie += ee >>> 16, ee &= 65535, ie += q * se, te += ie >>> 16, ie &= 65535, ie += K * ne, te += ie >>> 16, ie &= 65535, ie += j * J, te += ie >>> 16, ie &= 65535, te += W * se + q * ne + K * J + j * Q, te &= 65535, c(ee << 16 | ce, te << 16 | ie, this.unsigned); }, D.mul = D.multiply, D.divide = function($) { if (r($) || ($ = p($)), $.isZero()) throw Error("division by zero"); if (n) { if (!this.unsigned && this.high === -2147483648 && $.low === -1 && $.high === -1) return this; var z = (this.unsigned ? n.div_u : n.div_s)(this.low, this.high, $.low, $.high); return c(z, n.get_high(), this.unsigned); } if (this.isZero()) return this.unsigned ? x : v; var W, q, K; if (this.unsigned) { if ($.unsigned || ($ = $.toUnsigned()), $.gt(this)) return x; if ($.gt(this.shru(1))) return T; K = x; } else { if (this.eq(P)) { if ($.eq(k) || $.eq(C)) return P; if ($.eq(P)) return k; var j = this.shr(1); return W = j.div($).shl(1), W.eq(v) ? $.isNegative() ? k : C : (q = this.sub($.mul(W)), K = W.add(q.div($)), K); } else if ($.eq(P)) return this.unsigned ? x : v; if (this.isNegative()) return $.isNegative() ? this.neg().div($.neg()) : this.neg().div($).neg(); if ($.isNegative()) return this.div($.neg()).neg(); K = v; } for (q = this; q.gte($); ) { W = Math.max(1, Math.floor(q.toNumber() / $.toNumber())); for (var Q = Math.ceil(Math.log(W) / Math.LN2), J = Q <= 48 ? 1 : l(2, Q - 48), ne = u(W), se = ne.mul($); se.isNegative() || se.gt(q); ) W -= J, ne = u(W, this.unsigned), se = ne.mul($); ne.isZero() && (ne = k), K = K.add(ne), q = q.sub(se); } return K; }, D.div = D.divide, D.modulo = function($) { if (r($) || ($ = p($)), n) { var z = (this.unsigned ? n.rem_u : n.rem_s)(this.low, this.high, $.low, $.high); return c(z, n.get_high(), this.unsigned); } return this.sub(this.div($).mul($)); }, D.mod = D.modulo, D.rem = D.modulo, D.not = function() { return c(~this.low, ~this.high, this.unsigned); }, D.and = function($) { return r($) || ($ = p($)), c(this.low & $.low, this.high & $.high, this.unsigned); }, D.or = function($) { return r($) || ($ = p($)), c(this.low | $.low, this.high | $.high, this.unsigned); }, D.xor = function($) { return r($) || ($ = p($)), c(this.low ^ $.low, this.high ^ $.high, this.unsigned); }, D.shiftLeft = function($) { return r($) && ($ = $.toInt()), ($ &= 63) === 0 ? this : $ < 32 ? c(this.low << $, this.high << $ | this.low >>> 32 - $, this.unsigned) : c(0, this.low << $ - 32, this.unsigned); }, D.shl = D.shiftLeft, D.shiftRight = function($) { return r($) && ($ = $.toInt()), ($ &= 63) === 0 ? this : $ < 32 ? c(this.low >>> $ | this.high << 32 - $, this.high >> $, this.unsigned) : c(this.high >> $ - 32, this.high >= 0 ? 0 : -1, this.unsigned); }, D.shr = D.shiftRight, D.shiftRightUnsigned = function($) { if (r($) && ($ = $.toInt()), $ &= 63, $ === 0) return this; var z = this.high; if ($ < 32) { var W = this.low; return c(W >>> $ | z << 32 - $, z >>> $, this.unsigned); } else return $ === 32 ? c(z, 0, this.unsigned) : c(z >>> $ - 32, 0, this.unsigned); }, D.shru = D.shiftRightUnsigned, D.shr_u = D.shiftRightUnsigned, D.toSigned = function() { return this.unsigned ? c(this.low, this.high, false) : this; }, D.toUnsigned = function() { return this.unsigned ? this : c(this.low, this.high, true); }, D.toBytes = function($) { return $ ? this.toBytesLE() : this.toBytesBE(); }, D.toBytesLE = function() { var $ = this.high, z = this.low; return [z & 255, z >>> 8 & 255, z >>> 16 & 255, z >>> 24, $ & 255, $ >>> 8 & 255, $ >>> 16 & 255, $ >>> 24]; }, D.toBytesBE = function() { var $ = this.high, z = this.low; return [$ >>> 24, $ >>> 16 & 255, $ >>> 8 & 255, $ & 255, z >>> 24, z >>> 16 & 255, z >>> 8 & 255, z & 255]; }, s.fromBytes = function($, z, W) { return W ? s.fromBytesLE($, z) : s.fromBytesBE($, z); }, s.fromBytesLE = function($, z) { return new s($[0] | $[1] << 8 | $[2] << 16 | $[3] << 24, $[4] | $[5] << 8 | $[6] << 16 | $[7] << 24, z); }, s.fromBytesBE = function($, z) { return new s($[4] << 24 | $[5] << 16 | $[6] << 8 | $[7], $[0] << 24 | $[1] << 16 | $[2] << 8 | $[3], z); }; } }); var bT = Pt({ "(disabled):src/node_modules/node-fetch/browser.js"() { } }); var yT = Pt({ "(disabled):util"() { } }); var vT = Pt({ "src/node_modules/seedrandom/lib/alea.js"(e, t) { (function(n, s, r) { function a(c) { var l = this, d = u(); l.next = function() { var p = 2091639 * l.s0 + l.c * 23283064365386963e-26; return l.s0 = l.s1, l.s1 = l.s2, l.s2 = p - (l.c = p | 0); }, l.c = 1, l.s0 = d(" "), l.s1 = d(" "), l.s2 = d(" "), l.s0 -= d(c), l.s0 < 0 && (l.s0 += 1), l.s1 -= d(c), l.s1 < 0 && (l.s1 += 1), l.s2 -= d(c), l.s2 < 0 && (l.s2 += 1), d = null; } function i(c, l) { return l.c = c.c, l.s0 = c.s0, l.s1 = c.s1, l.s2 = c.s2, l; } function o(c, l) { var d = new a(c), p = l && l.state, h = d.next; return h.int32 = function() { return d.next() * 4294967296 | 0; }, h.double = function() { return h() + (h() * 2097152 | 0) * 11102230246251565e-32; }, h.quick = h, p && (typeof p == "object" && i(p, d), h.state = function() { return i(d, {}); }), h; } function u() { var c = 4022871197, l = function(d) { d = String(d); for (var p = 0; p < d.length; p++) { c += d.charCodeAt(p); var h = 0.02519603282416938 * c; c = h >>> 0, h -= c, h *= c, c = h >>> 0, h -= c, c += h * 4294967296; } return (c >>> 0) * 23283064365386963e-26; }; return l; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.alea = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var xT = Pt({ "src/node_modules/seedrandom/lib/xor128.js"(e, t) { (function(n, s, r) { function a(u) { var c = this, l = ""; c.x = 0, c.y = 0, c.z = 0, c.w = 0, c.next = function() { var p = c.x ^ c.x << 11; return c.x = c.y, c.y = c.z, c.z = c.w, c.w ^= c.w >>> 19 ^ p ^ p >>> 8; }, u === (u | 0) ? c.x = u : l += u; for (var d = 0; d < l.length + 64; d++) c.x ^= l.charCodeAt(d) | 0, c.next(); } function i(u, c) { return c.x = u.x, c.y = u.y, c.z = u.z, c.w = u.w, c; } function o(u, c) { var l = new a(u), d = c && c.state, p = function() { return (l.next() >>> 0) / 4294967296; }; return p.double = function() { do var h = l.next() >>> 11, f = (l.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, p.int32 = l.next, p.quick = p, d && (typeof d == "object" && i(d, l), p.state = function() { return i(l, {}); }), p; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xor128 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var wT = Pt({ "src/node_modules/seedrandom/lib/xorwow.js"(e, t) { (function(n, s, r) { function a(u) { var c = this, l = ""; c.next = function() { var p = c.x ^ c.x >>> 2; return c.x = c.y, c.y = c.z, c.z = c.w, c.w = c.v, (c.d = c.d + 362437 | 0) + (c.v = c.v ^ c.v << 4 ^ (p ^ p << 1)) | 0; }, c.x = 0, c.y = 0, c.z = 0, c.w = 0, c.v = 0, u === (u | 0) ? c.x = u : l += u; for (var d = 0; d < l.length + 64; d++) c.x ^= l.charCodeAt(d) | 0, d == l.length && (c.d = c.x << 10 ^ c.x >>> 4), c.next(); } function i(u, c) { return c.x = u.x, c.y = u.y, c.z = u.z, c.w = u.w, c.v = u.v, c.d = u.d, c; } function o(u, c) { var l = new a(u), d = c && c.state, p = function() { return (l.next() >>> 0) / 4294967296; }; return p.double = function() { do var h = l.next() >>> 11, f = (l.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, p.int32 = l.next, p.quick = p, d && (typeof d == "object" && i(d, l), p.state = function() { return i(l, {}); }), p; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xorwow = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var kT = Pt({ "src/node_modules/seedrandom/lib/xorshift7.js"(e, t) { (function(n, s, r) { function a(u) { var c = this; c.next = function() { var d = c.x, p = c.i, h, f, m; return h = d[p], h ^= h >>> 7, f = h ^ h << 24, h = d[p + 1 & 7], f ^= h ^ h >>> 10, h = d[p + 3 & 7], f ^= h ^ h >>> 3, h = d[p + 4 & 7], f ^= h ^ h << 7, h = d[p + 7 & 7], h = h ^ h << 13, f ^= h ^ h << 9, d[p] = f, c.i = p + 1 & 7, f; }; function l(d, p) { var h, f, m = []; if (p === (p | 0)) f = m[0] = p; else for (p = "" + p, h = 0; h < p.length; ++h) m[h & 7] = m[h & 7] << 15 ^ p.charCodeAt(h) + m[h + 1 & 7] << 13; for (; m.length < 8; ) m.push(0); for (h = 0; h < 8 && m[h] === 0; ++h) ; for (h == 8 ? f = m[7] = -1 : f = m[h], d.x = m, d.i = 0, h = 256; h > 0; --h) d.next(); } l(c, u); } function i(u, c) { return c.x = u.x.slice(), c.i = u.i, c; } function o(u, c) { u == null && (u = +new Date()); var l = new a(u), d = c && c.state, p = function() { return (l.next() >>> 0) / 4294967296; }; return p.double = function() { do var h = l.next() >>> 11, f = (l.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, p.int32 = l.next, p.quick = p, d && (d.x && i(d, l), p.state = function() { return i(l, {}); }), p; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xorshift7 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var IT = Pt({ "src/node_modules/seedrandom/lib/xor4096.js"(e, t) { (function(n, s, r) { function a(u) { var c = this; c.next = function() { var d = c.w, p = c.X, h = c.i, f, m; return c.w = d = d + 1640531527 | 0, m = p[h + 34 & 127], f = p[h = h + 1 & 127], m ^= m << 13, f ^= f << 17, m ^= m >>> 15, f ^= f >>> 12, m = p[h] = m ^ f, c.i = h, m + (d ^ d >>> 16) | 0; }; function l(d, p) { var h, f, m, g, b, y = [], v = 128; for (p === (p | 0) ? (f = p, p = null) : (p = p + "\0", f = 0, v = Math.max(v, p.length)), m = 0, g = -32; g < v; ++g) p && (f ^= p.charCodeAt((g + 32) % p.length)), g === 0 && (b = f), f ^= f << 10, f ^= f >>> 15, f ^= f << 4, f ^= f >>> 13, g >= 0 && (b = b + 1640531527 | 0, h = y[g & 127] ^= f + b, m = h == 0 ? m + 1 : 0); for (m >= 128 && (y[(p && p.length || 0) & 127] = -1), m = 127, g = 4 * 128; g > 0; --g) f = y[m + 34 & 127], h = y[m = m + 1 & 127], f ^= f << 13, h ^= h << 17, f ^= f >>> 15, h ^= h >>> 12, y[m] = f ^ h; d.w = b, d.X = y, d.i = m; } l(c, u); } function i(u, c) { return c.i = u.i, c.w = u.w, c.X = u.X.slice(), c; } function o(u, c) { u == null && (u = +new Date()); var l = new a(u), d = c && c.state, p = function() { return (l.next() >>> 0) / 4294967296; }; return p.double = function() { do var h = l.next() >>> 11, f = (l.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, p.int32 = l.next, p.quick = p, d && (d.X && i(d, l), p.state = function() { return i(l, {}); }), p; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xor4096 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var ST = Pt({ "src/node_modules/seedrandom/lib/tychei.js"(e, t) { (function(n, s, r) { function a(u) { var c = this, l = ""; c.next = function() { var p = c.b, h = c.c, f = c.d, m = c.a; return p = p << 25 ^ p >>> 7 ^ h, h = h - f | 0, f = f << 24 ^ f >>> 8 ^ m, m = m - p | 0, c.b = p = p << 20 ^ p >>> 12 ^ h, c.c = h = h - f | 0, c.d = f << 16 ^ h >>> 16 ^ m, c.a = m - p | 0; }, c.a = 0, c.b = 0, c.c = -1640531527, c.d = 1367130551, u === Math.floor(u) ? (c.a = u / 4294967296 | 0, c.b = u | 0) : l += u; for (var d = 0; d < l.length + 20; d++) c.b ^= l.charCodeAt(d) | 0, c.next(); } function i(u, c) { return c.a = u.a, c.b = u.b, c.c = u.c, c.d = u.d, c; } function o(u, c) { var l = new a(u), d = c && c.state, p = function() { return (l.next() >>> 0) / 4294967296; }; return p.double = function() { do var h = l.next() >>> 11, f = (l.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, p.int32 = l.next, p.quick = p, d && (typeof d == "object" && i(d, l), p.state = function() { return i(l, {}); }), p; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.tychei = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var CT = Pt({ "(disabled):crypto"() { } }); var NT = Pt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { (function(n, s, r) { var a = 256, i = 6, o = 52, u = "random", c = r.pow(a, i), l = r.pow(2, o), d = l * 2, p = a - 1, h; function f(k, T, C) { var R = []; T = T == true ? { entropy: true } : T || {}; var _ = y(b(T.entropy ? [k, x(s)] : k == null ? v() : k, 3), R), P = new m(R), D = function() { for (var F = P.g(i), $ = c, z = 0; F < l; ) F = (F + z) * a, $ *= a, z = P.g(1); for (; F >= d; ) F /= 2, $ /= 2, z >>>= 1; return (F + z) / $; }; return D.int32 = function() { return P.g(4) | 0; }, D.quick = function() { return P.g(4) / 4294967296; }, D.double = D, y(x(P.S), s), (T.pass || C || function(F, $, z, W) { return W && (W.S && g(W, P), F.state = function() { return g(P, {}); }), z ? (r[u] = F, $) : F; })(D, _, "global" in T ? T.global : this == r, T.state); } function m(k) { var T, C = k.length, R = this, _ = 0, P = R.i = R.j = 0, D = R.S = []; for (C || (k = [C++]); _ < a; ) D[_] = _++; for (_ = 0; _ < a; _++) D[_] = D[P = p & P + k[_ % C] + (T = D[_])], D[P] = T; (R.g = function(F) { for (var $, z = 0, W = R.i, q = R.j, K = R.S; F--; ) $ = K[W = p & W + 1], z = z * a + K[p & (K[W] = K[q = p & q + $]) + (K[q] = $)]; return R.i = W, R.j = q, z; })(a); } function g(k, T) { return T.i = k.i, T.j = k.j, T.S = k.S.slice(), T; } function b(k, T) { var C = [], R = typeof k, _; if (T && R == "object") for (_ in k) try { C.push(b(k[_], T - 1)); } catch (P) { } return C.length ? C : R == "string" ? k : k + "\0"; } function y(k, T) { for (var C = k + "", R, _ = 0; _ < C.length; ) T[p & _] = p & (R ^= T[p & _] * 19) + C.charCodeAt(_++); return x(T); } function v() { try { var k; return h && (k = h.randomBytes) ? k = k(a) : (k = new Uint8Array(a), (n.crypto || n.msCrypto).getRandomValues(k)), x(k); } catch (R) { var T = n.navigator, C = T && T.plugins; return [+new Date(), n, C, n.screen, x(s)]; } } function x(k) { return String.fromCharCode.apply(0, k); } if (y(r.random(), s), typeof t == "object" && t.exports) { t.exports = f; try { h = CT(); } catch (k) { } } else typeof define == "function" && define.amd ? define(function() { return f; }) : r["seed" + u] = f; })(typeof self != "undefined" ? self : e, [], Math); } }); var Fd = Pt({ "src/node_modules/seedrandom/index.js"(e, t) { var n = vT(), s = xT(), r = wT(), a = kT(), i = IT(), o = ST(), u = NT(); u.alea = n, u.xor128 = s, u.xorwow = r, u.xorshift7 = a, u.xor4096 = i, u.tychei = o, t.exports = u; } }); var fw = Pt({ "(disabled):src/node_modules/string_decoder/index.js"() { } }); var sd = Pt({ "(disabled):fs"() { } }); var Ou = Pt({ "(disabled):path"() { } }); var TT = Pt({ "(disabled):worker_threads"() { } }); var $T = Pt({ "(disabled):perf_hooks"() { } }); var AT = Pt({ "(disabled):os"() { } }); var ET = Pt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e, t) { var n = function() { var s = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (s = s || __filename), function(r) { r = r || {}; function a() { return ee.buffer != Qe && fn(ee.buffer), Sn; } function i() { return ee.buffer != Qe && fn(ee.buffer), Ht; } function o() { return ee.buffer != Qe && fn(ee.buffer), Cn; } function u() { return ee.buffer != Qe && fn(ee.buffer), Rn; } function c() { return ee.buffer != Qe && fn(ee.buffer), Dn; } var l = typeof r != "undefined" ? r : {}, d, p; l.ready = new Promise(function(S, A) { d = S, p = A; }); var h; typeof process != "undefined" && process.listeners && (h = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var f = {}, m; for (m in l) l.hasOwnProperty(m) && (f[m] = l[m]); var g = [], b = "./this.program", y = function(S, A) { throw A; }, v = false, x = false, k = false, T = false; v = typeof window == "object", x = typeof importScripts == "function", k = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", T = !v && !k && !x; var C = l.ENVIRONMENT_IS_PTHREAD || false; C && (Qe = l.buffer); var R = ""; function _(S) { return l.locateFile ? l.locateFile(S, R) : R + S; } var P, D, F, $, z, W; if (k) { x ? R = Ou().dirname(R) + "/" : R = __dirname + "/", P = function(A, M) { return z || (z = sd()), W || (W = Ou()), A = W.normalize(A), z.readFileSync(A, M ? null : "utf8"); }, F = function(A) { var M = P(A, true); return M.buffer || (M = new Uint8Array(M)), we(M.buffer), M; }, process.argv.length > 1 && (b = process.argv[1].replace(/\\/g, "/")), g = process.argv.slice(2), process.on("uncaughtException", function(S) { if (!(S instanceof wu)) throw S; }), process.on("unhandledRejection", zs), y = function(S) { process.exit(S); }, l.inspect = function() { return "[Emscripten Module object]"; }; var q; try { q = TT(); } catch (S) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), S; } global.Worker = q.Worker; } else T ? (typeof read != "undefined" && (P = function(A) { return read(A); }), F = function(A) { var M; return typeof readbuffer == "function" ? new Uint8Array(readbuffer(A)) : (M = read(A, "binary"), we(typeof M == "object"), M); }, typeof scriptArgs != "undefined" ? g = scriptArgs : typeof arguments != "undefined" && (g = arguments), typeof quit == "function" && (y = function(S) { quit(S); }), typeof print != "undefined" && (typeof console == "undefined" && (console = {}), console.log = print, console.warn = console.error = typeof printErr != "undefined" ? printErr : print)) : (v || x) && (x ? R = self.location.href : typeof document != "undefined" && document.currentScript && (R = document.currentScript.src), typeof s != "undefined" && s && (R = s), R.indexOf("blob:") !== 0 ? R = R.substr(0, R.lastIndexOf("/") + 1) : R = "", k ? (P = function(A, M) { return z || (z = sd()), W || (W = Ou()), A = W.normalize(A), z.readFileSync(A, M ? null : "utf8"); }, F = function(A) { var M = P(A, true); return M.buffer || (M = new Uint8Array(M)), we(M.buffer), M; }) : (P = function(S) { var A = new XMLHttpRequest(); return A.open("GET", S, false), A.send(null), A.responseText; }, x && (F = function(S) { var A = new XMLHttpRequest(); return A.open("GET", S, false), A.responseType = "arraybuffer", A.send(null), new Uint8Array(A.response); }), D = function(S, A, M) { var Y = new XMLHttpRequest(); Y.open("GET", S, true), Y.responseType = "arraybuffer", Y.onload = function() { if (Y.status == 200 || Y.status == 0 && Y.response) { A(Y.response); return; } M(); }, Y.onerror = M, Y.send(null); }), $ = function(S) { document.title = S; }); k && typeof performance == "undefined" && (global.performance = $T().performance); var K = l.print || console.log.bind(console), j = l.printErr || console.warn.bind(console); for (m in f) f.hasOwnProperty(m) && (l[m] = f[m]); f = null, l.arguments && (g = l.arguments), l.thisProgram && (b = l.thisProgram), l.quit && (y = l.quit); function Q(S) { Q.shown || (Q.shown = {}), Q.shown[S] || (Q.shown[S] = 1, j(S)); } var J = Atomics.load, ne = Atomics.store, se = Atomics.compareExchange, te; l.wasmBinary && (te = l.wasmBinary); var ie = l.noExitRuntime || true; typeof WebAssembly != "object" && zs("no native wasm support detected"); var ee, ce, me = false, Ie; function we(S, A) { S || zs("Assertion failed: " + A); } function Te(S) { var A = l["_" + S]; return we(A, "Cannot call unknown function " + S + ", make sure it is exported"), A; } function Fe(S, A, M, Y, de) { var ue = { string: function(en) { var Ei = 0; if (en != null && en !== 0) { var Ev = (en.length << 2) + 1; Ei = Ti(Ev), Ye(en, Ei, Ev); } return Ei; }, array: function(en) { var Ei = Ti(en.length); return ht(en, Ei), Ei; } }; function le(en) { return A === "string" ? Be(en) : A === "boolean" ? Boolean(en) : en; } var ye = Te(S), et = [], zt = 0; if (Y) for (var Et = 0; Et < Y.length; Et++) { var ar = ue[M[Et]]; ar ? (zt === 0 && (zt = xu()), et[Et] = ar(Y[Et])) : et[Et] = Y[Et]; } var Ai = ye.apply(null, et); return Ai = le(Ai), zt !== 0 && Ni(zt), Ai; } function Xe(S, A, M, Y) { M = M || []; var de = M.every(function(le) { return le === "number"; }), ue = A !== "string"; return ue && de && !Y ? Te(S) : function() { return Fe(S, A, M, arguments, Y); }; } function We(S, A, M) { for (var Y = A + M, de = ""; !(A >= Y); ) { var ue = S[A++]; if (!ue) return de; if (!(ue & 128)) { de += String.fromCharCode(ue); continue; } var le = S[A++] & 63; if ((ue & 224) == 192) { de += String.fromCharCode((ue & 31) << 6 | le); continue; } var ye = S[A++] & 63; if ((ue & 240) == 224 ? ue = (ue & 15) << 12 | le << 6 | ye : ue = (ue & 7) << 18 | le << 12 | ye << 6 | S[A++] & 63, ue < 65536) de += String.fromCharCode(ue); else { var et = ue - 65536; de += String.fromCharCode(55296 | et >> 10, 56320 | et & 1023); } } return de; } function Be(S, A) { return S ? We(i(), S, A) : ""; } function rt(S, A, M, Y) { if (!(Y > 0)) return 0; for (var de = M, ue = M + Y - 1, le = 0; le < S.length; ++le) { var ye = S.charCodeAt(le); if (ye >= 55296 && ye <= 57343) { var et = S.charCodeAt(++le); ye = 65536 + ((ye & 1023) << 10) | et & 1023; } if (ye <= 127) { if (M >= ue) break; A[M++] = ye; } else if (ye <= 2047) { if (M + 1 >= ue) break; A[M++] = 192 | ye >> 6, A[M++] = 128 | ye & 63; } else if (ye <= 65535) { if (M + 2 >= ue) break; A[M++] = 224 | ye >> 12, A[M++] = 128 | ye >> 6 & 63, A[M++] = 128 | ye & 63; } else { if (M + 3 >= ue) break; A[M++] = 240 | ye >> 18, A[M++] = 128 | ye >> 12 & 63, A[M++] = 128 | ye >> 6 & 63, A[M++] = 128 | ye & 63; } } return A[M] = 0, M - de; } function Ye(S, A, M) { return rt(S, i(), A, M); } function at(S) { for (var A = 0, M = 0; M < S.length; ++M) { var Y = S.charCodeAt(M); Y >= 55296 && Y <= 57343 && (Y = 65536 + ((Y & 1023) << 10) | S.charCodeAt(++M) & 1023), Y <= 127 ? ++A : Y <= 2047 ? A += 2 : Y <= 65535 ? A += 3 : A += 4; } return A; } function ht(S, A) { a().set(S, A); } function pn(S, A) { return S % A > 0 && (S += A - S % A), S; } var Qe, Sn, Ht, Hn, hn, Cn, Rn, qn, Dn; function fn(S) { Qe = S, l.HEAP8 = Sn = new Int8Array(S), l.HEAP16 = Hn = new Int16Array(S), l.HEAP32 = Cn = new Int32Array(S), l.HEAPU8 = Ht = new Uint8Array(S), l.HEAPU16 = hn = new Uint16Array(S), l.HEAPU32 = Rn = new Uint32Array(S), l.HEAPF32 = qn = new Float32Array(S), l.HEAPF64 = Dn = new Float64Array(S); } var Zs = l.INITIAL_MEMORY || 16777216; if (C) ee = l.wasmMemory, Qe = l.buffer; else if (l.wasmMemory) ee = l.wasmMemory; else if (ee = new WebAssembly.Memory({ initial: Zs / 65536, maximum: 32768, shared: true }), !(ee.buffer instanceof SharedArrayBuffer)) throw j("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"), k && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); ee && (Qe = ee.buffer), Zs = Qe.byteLength, fn(Qe); var Qt, Js = [], Fn = [], lu = [], cu = [], Ps = [], ic = false, qp = false; C || Fn.push({ func: function() { Sc(); } }); function oc() { if (!C) { if (l.preRun) for (typeof l.preRun == "function" && (l.preRun = [l.preRun]); l.preRun.length; ) jp(l.preRun.shift()); wi(Js); } } function uc() { ic = true, !C && wi(Fn); } function lc() { C || wi(lu); } function mn() { C || (qp = true); } function cc() { if (!C) { if (l.postRun) for (typeof l.postRun == "function" && (l.postRun = [l.postRun]); l.postRun.length; ) Kp(l.postRun.shift()); wi(Ps); } } function jp(S) { Js.unshift(S); } function Kp(S) { Ps.unshift(S); } var jn = 0, du = null, zr = null; function Xp(S) { we(!C, "addRunDependency cannot be used in a pthread worker"), jn++, l.monitorRunDependencies && l.monitorRunDependencies(jn); } function Yp(S) { if (jn--, l.monitorRunDependencies && l.monitorRunDependencies(jn), jn == 0 && (du !== null && (clearInterval(du), du = null), zr)) { var A = zr; zr = null, A(); } } l.preloadedImages = {}, l.preloadedAudios = {}; function zs(S) { l.onAbort && l.onAbort(S), C && console.error("Pthread aborting at " + new Error().stack), S += "", j(S), me = true, Ie = 1, S = "abort(" + S + "). Build with -s ASSERTIONS=1 for more info."; var A = new WebAssembly.RuntimeError(S); throw p(A), A; } function Mr(S, A) { return String.prototype.startsWith ? S.startsWith(A) : S.indexOf(A) === 0; } var Qp = "data:application/octet-stream;base64,"; function dc(S) { return Mr(S, Qp); } var Zp = "file://"; function pc(S) { return Mr(S, Zp); } var gn = "tfjs-backend-wasm-threaded-simd.wasm"; dc(gn) || (gn = _(gn)); function Jp(S) { try { if (S == gn && te) return new Uint8Array(te); if (F) return F(S); throw "both async and sync fetching of the wasm failed"; } catch (A) { zs(A); } } function hc() { if (!te && (v || x)) { if (typeof fetch == "function" && !pc(gn)) return fetch(gn, { credentials: "same-origin" }).then(function(S) { if (!S.ok) throw "failed to load wasm binary file at '" + gn + "'"; return S.arrayBuffer(); }).catch(function() { return Jp(gn); }); if (D) return new Promise(function(S, A) { D(gn, function(M) { S(new Uint8Array(M)); }, A); }); } return Promise.resolve().then(function() { return Jp(gn); }); } function eh() { var S = { a: qh }; function A(le, ye) { var et = le.exports; if (l.asm = et, Qt = l.asm.nb, ce = ye, !C) { var zt = ke.unusedWorkers.length; ke.unusedWorkers.forEach(function(Et) { ke.loadWasmModuleToWorker(Et, function() { --zt || Yp("wasm-instantiate"); }); }); } } C || Xp("wasm-instantiate"); function M(le) { A(le.instance, le.module); } function Y(le) { return hc().then(function(ye) { return WebAssembly.instantiate(ye, S); }).then(le, function(ye) { j("failed to asynchronously prepare wasm: " + ye), zs(ye); }); } function de() { return !te && typeof WebAssembly.instantiateStreaming == "function" && !dc(gn) && !pc(gn) && typeof fetch == "function" ? fetch(gn, { credentials: "same-origin" }).then(function(le) { var ye = WebAssembly.instantiateStreaming(le, S); return ye.then(M, function(et) { return j("wasm streaming compile failed: " + et), j("falling back to ArrayBuffer instantiation"), Y(M); }); }) : Y(M); } if (l.instantiateWasm) try { var ue = l.instantiateWasm(S, A); return ue; } catch (le) { return j("Module.instantiateWasm callback failed with error: " + le), false; } return de().catch(p), {}; } var fc = { 10216: function() { throw "Canceled!"; }, 10234: function(S, A) { setTimeout(function() { Sv(S, A); }, 0); } }; function th() { ke.initRuntime(); } function wi(S) { for (; S.length > 0; ) { var A = S.shift(); if (typeof A == "function") { A(l); continue; } var M = A.func; typeof M == "number" ? A.arg === void 0 ? Qt.get(M)() : Qt.get(M)(A.arg) : M(A.arg === void 0 ? null : A.arg); } } var er = { EPERM: 63, ENOENT: 44, ESRCH: 71, EINTR: 27, EIO: 29, ENXIO: 60, E2BIG: 1, ENOEXEC: 45, EBADF: 8, ECHILD: 12, EAGAIN: 6, EWOULDBLOCK: 6, ENOMEM: 48, EACCES: 2, EFAULT: 21, ENOTBLK: 105, EBUSY: 10, EEXIST: 20, EXDEV: 75, ENODEV: 43, ENOTDIR: 54, EISDIR: 31, EINVAL: 28, ENFILE: 41, EMFILE: 33, ENOTTY: 59, ETXTBSY: 74, EFBIG: 22, ENOSPC: 51, ESPIPE: 70, EROFS: 69, EMLINK: 34, EPIPE: 64, EDOM: 18, ERANGE: 68, ENOMSG: 49, EIDRM: 24, ECHRNG: 106, EL2NSYNC: 156, EL3HLT: 107, EL3RST: 108, ELNRNG: 109, EUNATCH: 110, ENOCSI: 111, EL2HLT: 112, EDEADLK: 16, ENOLCK: 46, EBADE: 113, EBADR: 114, EXFULL: 115, ENOANO: 104, EBADRQC: 103, EBADSLT: 102, EDEADLOCK: 16, EBFONT: 101, ENOSTR: 100, ENODATA: 116, ETIME: 117, ENOSR: 118, ENONET: 119, ENOPKG: 120, EREMOTE: 121, ENOLINK: 47, EADV: 122, ESRMNT: 123, ECOMM: 124, EPROTO: 65, EMULTIHOP: 36, EDOTDOT: 125, EBADMSG: 9, ENOTUNIQ: 126, EBADFD: 127, EREMCHG: 128, ELIBACC: 129, ELIBBAD: 130, ELIBSCN: 131, ELIBMAX: 132, ELIBEXEC: 133, ENOSYS: 52, ENOTEMPTY: 55, ENAMETOOLONG: 37, ELOOP: 32, EOPNOTSUPP: 138, EPFNOSUPPORT: 139, ECONNRESET: 15, ENOBUFS: 42, EAFNOSUPPORT: 5, EPROTOTYPE: 67, ENOTSOCK: 57, ENOPROTOOPT: 50, ESHUTDOWN: 140, ECONNREFUSED: 14, EADDRINUSE: 3, ECONNABORTED: 13, ENETUNREACH: 40, ENETDOWN: 38, ETIMEDOUT: 73, EHOSTDOWN: 142, EHOSTUNREACH: 23, EINPROGRESS: 26, EALREADY: 7, EDESTADDRREQ: 17, EMSGSIZE: 35, EPROTONOSUPPORT: 66, ESOCKTNOSUPPORT: 137, EADDRNOTAVAIL: 4, ENETRESET: 39, EISCONN: 30, ENOTCONN: 53, ETOOMANYREFS: 141, EUSERS: 136, EDQUOT: 19, ESTALE: 72, ENOTSUP: 138, ENOMEDIUM: 148, EILSEQ: 25, EOVERFLOW: 61, ECANCELED: 11, ENOTRECOVERABLE: 56, EOWNERDEAD: 62, ESTRPIPE: 135 }; function pu(S, A) { if (S <= 0 || S > a().length || S & true || A < 0) return -28; if (A == 0) return 0; A >= 2147483647 && (A = 1 / 0); var M = Atomics.load(o(), $i >> 2), Y = 0; if (M == S) { var de = Atomics.compareExchange(o(), $i >> 2, M, 0); if (de == M && (--A, Y = 1, A <= 0)) return 1; } var ue = Atomics.notify(o(), S >> 2, A); if (ue >= 0) return ue + Y; throw "Atomics.notify returned an unexpected value " + ue; } l._emscripten_futex_wake = pu; function nh(S) { if (C) throw "Internal Error! killThread() can only ever be called from main application thread!"; if (!S) throw "Internal Error! Null pthread_ptr in killThread!"; o()[S + 12 >> 2] = 0; var A = ke.pthreads[S]; A.worker.terminate(), ke.freeThreadData(A), ke.runningWorkers.splice(ke.runningWorkers.indexOf(A.worker), 1), A.worker.pthread = void 0; } function sh(S) { if (C) throw "Internal Error! cancelThread() can only ever be called from main application thread!"; if (!S) throw "Internal Error! Null pthread_ptr in cancelThread!"; var A = ke.pthreads[S]; A.worker.postMessage({ cmd: "cancel" }); } function mc(S) { if (C) throw "Internal Error! cleanupThread() can only ever be called from main application thread!"; if (!S) throw "Internal Error! Null pthread_ptr in cleanupThread!"; var A = ke.pthreads[S]; if (A) { o()[S + 12 >> 2] = 0; var M = A.worker; ke.returnWorkerToPool(M); } } var ke = { unusedWorkers: [], runningWorkers: [], initMainThreadBlock: function() { for (var S = 8, A = 0; A < S; ++A) ke.allocateUnusedWorker(); }, initRuntime: function() { for (var S = Br(228), A = 0; A < 228 / 4; ++A) u()[S / 4 + A] = 0; o()[S + 12 >> 2] = S; var M = S + 152; o()[M >> 2] = M; for (var Y = Br(512), A = 0; A < 128; ++A) u()[Y / 4 + A] = 0; Atomics.store(u(), S + 100 >> 2, Y), Atomics.store(u(), S + 40 >> 2, S), bf(S, !x, 1), kv(S); }, initWorker: function() { }, pthreads: {}, threadExitHandlers: [], setThreadStatus: function() { }, runExitHandlers: function() { for (; ke.threadExitHandlers.length > 0; ) ke.threadExitHandlers.pop()(); C && rr() && wv(); }, runExitHandlersAndDeinitThread: function(S, A) { Atomics.store(u(), S + 56 >> 2, 1), Atomics.store(u(), S + 60 >> 2, 0), ke.runExitHandlers(), Atomics.store(u(), S + 4 >> 2, A), Atomics.store(u(), S + 0 >> 2, 1), pu(S + 0, 2147483647), bf(0, 0, 0); }, threadExit: function(S) { var A = rr(); A && (ke.runExitHandlersAndDeinitThread(A, S), C && postMessage({ cmd: "exit" })); }, threadCancel: function() { ke.runExitHandlersAndDeinitThread(rr(), -1), postMessage({ cmd: "cancelDone" }); }, terminateAllThreads: function() { for (var S in ke.pthreads) { var A = ke.pthreads[S]; A && A.worker && ke.returnWorkerToPool(A.worker); } ke.pthreads = {}; for (var M = 0; M < ke.unusedWorkers.length; ++M) { var Y = ke.unusedWorkers[M]; Y.terminate(); } ke.unusedWorkers = []; for (var M = 0; M < ke.runningWorkers.length; ++M) { var Y = ke.runningWorkers[M], A = Y.pthread; ke.freeThreadData(A), Y.terminate(); } ke.runningWorkers = []; }, freeThreadData: function(S) { if (!!S) { if (S.threadInfoStruct) { var A = o()[S.threadInfoStruct + 100 >> 2]; o()[S.threadInfoStruct + 100 >> 2] = 0, vu(A), vu(S.threadInfoStruct); } S.threadInfoStruct = 0, S.allocatedOwnStack && S.stackBase && vu(S.stackBase), S.stackBase = 0, S.worker && (S.worker.pthread = null); } }, returnWorkerToPool: function(S) { ke.runWithoutMainThreadQueuedCalls(function() { delete ke.pthreads[S.pthread.threadInfoStruct], ke.unusedWorkers.push(S), ke.runningWorkers.splice(ke.runningWorkers.indexOf(S), 1), ke.freeThreadData(S.pthread), S.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(S) { o()[Av >> 2] = 0; try { S(); } finally { o()[Av >> 2] = 1; } }, receiveObjectTransfer: function(S) { }, loadWasmModuleToWorker: function(S, A) { S.onmessage = function(M) { var Y = M.data, de = Y.cmd; if (S.pthread && (ke.currentProxiedOperationCallerThread = S.pthread.threadInfoStruct), Y.targetThread && Y.targetThread != rr()) { var ue = ke.pthreads[Y.targetThread]; ue ? ue.worker.postMessage(M.data, Y.transferList) : console.error('Internal error! Worker sent a message "' + de + '" to target pthread ' + Y.targetThread + ", but that thread no longer exists!"), ke.currentProxiedOperationCallerThread = void 0; return; } if (de === "processQueuedMainThreadWork") Ac(); else if (de === "spawnThread") kc(M.data); else if (de === "cleanupThread") mc(Y.thread); else if (de === "killThread") nh(Y.thread); else if (de === "cancelThread") sh(Y.thread); else if (de === "loaded") S.loaded = true, A && A(S), S.runPthread && (S.runPthread(), delete S.runPthread); else if (de === "print") K("Thread " + Y.threadId + ": " + Y.text); else if (de === "printErr") j("Thread " + Y.threadId + ": " + Y.text); else if (de === "alert") alert("Thread " + Y.threadId + ": " + Y.text); else if (de === "exit") { var le = S.pthread && Atomics.load(u(), S.pthread.threadInfoStruct + 64 >> 2); le && ke.returnWorkerToPool(S); } else if (de === "exitProcess") try { uT(Y.returnCode); } catch (ye) { if (ye instanceof wu) return; throw ye; } else de === "cancelDone" ? ke.returnWorkerToPool(S) : de === "objectTransfer" ? ke.receiveObjectTransfer(M.data) : M.data.target === "setimmediate" ? S.postMessage(M.data) : j("worker sent an unknown command " + de); ke.currentProxiedOperationCallerThread = void 0; }, S.onerror = function(M) { j("pthread sent an error! " + M.filename + ":" + M.lineno + ": " + M.message); }, k && (S.on("message", function(M) { S.onmessage({ data: M }); }), S.on("error", function(M) { S.onerror(M); }), S.on("exit", function(M) { })), S.postMessage({ cmd: "load", urlOrBlob: l.mainScriptUrlOrBlob || s, wasmMemory: ee, wasmModule: ce }); }, allocateUnusedWorker: function() { var S = _("tfjs-backend-wasm-threaded-simd.worker.js"); ke.unusedWorkers.push(new Worker(S)); }, getNewWorker: function() { return ke.unusedWorkers.length == 0 && (ke.allocateUnusedWorker(), ke.loadWasmModuleToWorker(ke.unusedWorkers[0])), ke.unusedWorkers.length > 0 ? ke.unusedWorkers.pop() : null; }, busySpinWait: function(S) { for (var A = performance.now() + S; performance.now() < A; ) ; } }; function rh(S, A) { Tv(S, A), Ni(S); } l.establishStackSpace = rh; function ah() { return ie; } l.getNoExitRuntime = ah; function ih(S, A) { return Qt.get(S)(A); } l.invokeEntryPoint = ih; function oh(S, A, M, Y) { zs("Assertion failed: " + Be(S) + ", at: " + [A ? Be(A) : "unknown filename", M, Y ? Be(Y) : "unknown function"]); } function uh(S, A) { var M = _main(S, A); } var Lr; k ? Lr = function() { var S = process.hrtime(); return S[0] * 1e3 + S[1] / 1e6; } : C ? Lr = function() { return performance.now() - l.__performance_now_clock_drift; } : typeof dateNow != "undefined" ? Lr = dateNow : Lr = function() { return performance.now(); }; function lh(S) { return o()[vv() >> 2] = S, S; } function ch(S, A) { if (C) return tr(1, 1, S, A); } function dh(S, A) { if (S == A) postMessage({ cmd: "processQueuedMainThreadWork" }); else if (C) postMessage({ targetThread: S, cmd: "processThreadQueue" }); else { var M = ke.pthreads[S], Y = M && M.worker; if (!Y) return; Y.postMessage({ cmd: "processThreadQueue" }); } return 1; } function ph() { zs(); } function hh(S, A, M) { var Y = bh(A, M); return fc[S].apply(null, Y); } function fh(S, A) { } function gc(S, A, M) { if (S <= 0 || S > a().length || S & true) return -28; if (v) { if (Atomics.load(o(), S >> 2) != A) return -6; for (var de = performance.now(), ue = de + M, le = Atomics.exchange(o(), $i >> 2, S); ; ) { if (de = performance.now(), de > ue) return le = Atomics.exchange(o(), $i >> 2, 0), -73; if (le = Atomics.exchange(o(), $i >> 2, 0), le == 0) break; if (Ac(), Atomics.load(o(), S >> 2) != A) return -6; le = Atomics.exchange(o(), $i >> 2, S); } return 0; } else { var Y = Atomics.wait(o(), S >> 2, A, M); if (Y === "timed-out") return -73; if (Y === "not-equal") return -6; if (Y === "ok") return 0; throw "Atomics.wait returned an unexpected value " + Y; } } function mh(S, A, M) { i().copyWithin(S, A, A + M); } function gh() { return k ? AT().cpus().length : navigator.hardwareConcurrency; } function tr(S, A) { for (var M = arguments.length - 2, Y = xu(), de = M, ue = Ti(de * 8), le = ue >> 3, ye = 0; ye < M; ye++) { var et = arguments[2 + ye]; c()[le + ye] = et; } var zt = Nv(S, de, ue, A); return Ni(Y), zt; } var hu = [], fu = []; function bh(S, A) { fu.length = 0; var M; for (A >>= 2; M = i()[S++]; ) { var Y = M < 105; Y && A & 1 && A++, fu.push(Y ? c()[A++ >> 1] : o()[A]), ++A; } return fu; } function yh(S, A, M) { hu.length = A; for (var Y = M >> 3, de = 0; de < A; de++) hu[de] = c()[Y + de]; var ue = S < 0, le = ue ? fc[-S - 1] : Hh[S]; return le.apply(null, hu); } function vh() { return i().length; } function xh(S) { try { return ee.grow(S - Qe.byteLength + 65535 >>> 16), fn(ee.buffer), 1; } catch (A) { } } function wh(S) { var A = vh(); if (S <= A) return false; var M = 2147483648; if (S > M) return false; for (var Y = 1; Y <= 4; Y *= 2) { var de = A * (1 + 0.2 / Y); de = Math.min(de, S + 100663296); var ue = Math.min(M, pn(Math.max(S, de), 65536)), le = xh(ue); if (le) return true; } return false; } var Pe = { inEventHandler: 0, removeAllEventListeners: function() { for (var S = Pe.eventHandlers.length - 1; S >= 0; --S) Pe._removeHandler(S); Pe.eventHandlers = [], Pe.deferredCalls = []; }, registerRemoveEventListeners: function() { Pe.removeEventListenersRegistered || (cu.push(Pe.removeAllEventListeners), Pe.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(S, A, M) { function Y(le, ye) { if (le.length != ye.length) return false; for (var et in le) if (le[et] != ye[et]) return false; return true; } for (var de in Pe.deferredCalls) { var ue = Pe.deferredCalls[de]; if (ue.targetFunction == S && Y(ue.argsList, M)) return; } Pe.deferredCalls.push({ targetFunction: S, precedence: A, argsList: M }), Pe.deferredCalls.sort(function(le, ye) { return le.precedence < ye.precedence; }); }, removeDeferredCalls: function(S) { for (var A = 0; A < Pe.deferredCalls.length; ++A) Pe.deferredCalls[A].targetFunction == S && (Pe.deferredCalls.splice(A, 1), --A); }, canPerformEventHandlerRequests: function() { return Pe.inEventHandler && Pe.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { if (!!Pe.canPerformEventHandlerRequests()) for (var S = 0; S < Pe.deferredCalls.length; ++S) { var A = Pe.deferredCalls[S]; Pe.deferredCalls.splice(S, 1), --S, A.targetFunction.apply(null, A.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(S, A) { for (var M = 0; M < Pe.eventHandlers.length; ++M) Pe.eventHandlers[M].target == S && (!A || A == Pe.eventHandlers[M].eventTypeString) && Pe._removeHandler(M--); }, _removeHandler: function(S) { var A = Pe.eventHandlers[S]; A.target.removeEventListener(A.eventTypeString, A.eventListenerFunc, A.useCapture), Pe.eventHandlers.splice(S, 1); }, registerOrRemoveHandler: function(S) { var A = function(de) { ++Pe.inEventHandler, Pe.currentEventHandler = S, Pe.runDeferredCalls(), S.handlerFunc(de), Pe.runDeferredCalls(), --Pe.inEventHandler; }; if (S.callbackfunc) S.eventListenerFunc = A, S.target.addEventListener(S.eventTypeString, A, S.useCapture), Pe.eventHandlers.push(S), Pe.registerRemoveEventListeners(); else for (var M = 0; M < Pe.eventHandlers.length; ++M) Pe.eventHandlers[M].target == S.target && Pe.eventHandlers[M].eventTypeString == S.eventTypeString && Pe._removeHandler(M--); }, queueEventHandlerOnThread_iiii: function(S, A, M, Y, de) { var ue = xu(), le = Ti(12); o()[le >> 2] = M, o()[le + 4 >> 2] = Y, o()[le + 8 >> 2] = de, gf(0, S, 637534208, A, Y, le), Ni(ue); }, getTargetThreadForEventCallback: function(S) { switch (S) { case 1: return 0; case 2: return ke.currentProxiedOperationCallerThread; default: return S; } }, getNodeNameForTarget: function(S) { return S ? S == window ? "#window" : S == screen ? "#screen" : S && S.nodeName ? S.nodeName : "" : ""; }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; function kh(S) { var A = at(S) + 1, M = Br(A); return Ye(S, M, A), M; } function Ih(S, A, M, Y) { var de = xu(), ue = Ti(12), le = 0; A && (le = kh(A)), o()[ue >> 2] = le, o()[ue + 4 >> 2] = M, o()[ue + 8 >> 2] = Y, gf(0, S, 657457152, 0, le, ue), Ni(de); } function Sh(S, A, M, Y) { A = A ? Be(A) : "", Ih(S, A, M, Y); } function Ch(S) { return S > 2 ? Be(S) : S; } var Nh = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; function Th(S) { S = Ch(S); var A = Nh[S] || (typeof document != "undefined" ? document.querySelector(S) : void 0); return A; } function mu(S) { return Th(S); } function bc(S, A, M) { var Y = mu(S); if (!Y) return -4; if (Y.canvasSharedPtr && (o()[Y.canvasSharedPtr >> 2] = A, o()[Y.canvasSharedPtr + 4 >> 2] = M), Y.offscreenCanvas || !Y.controlTransferredOffscreen) { Y.offscreenCanvas && (Y = Y.offscreenCanvas); var de = false; if (Y.GLctxObject && Y.GLctxObject.GLctx) { var ue = Y.GLctxObject.GLctx.getParameter(2978); de = ue[0] === 0 && ue[1] === 0 && ue[2] === Y.width && ue[3] === Y.height; } Y.width = A, Y.height = M, de && Y.GLctxObject.GLctx.viewport(0, 0, A, M); } else if (Y.canvasSharedPtr) { var le = o()[Y.canvasSharedPtr + 8 >> 2]; return Sh(le, S, A, M), 1; } else return -4; return 0; } function yc(S, A, M) { return C ? tr(2, 1, S, A, M) : bc(S, A, M); } function $h(S, A, M) { var Y = mu(S); return Y ? bc(S, A, M) : yc(S, A, M); } function Ah(S) { } function Eh(S, A) { } function _h(S) { var A = S.getExtension("ANGLE_instanced_arrays"); if (A) return S.vertexAttribDivisor = function(M, Y) { A.vertexAttribDivisorANGLE(M, Y); }, S.drawArraysInstanced = function(M, Y, de, ue) { A.drawArraysInstancedANGLE(M, Y, de, ue); }, S.drawElementsInstanced = function(M, Y, de, ue, le) { A.drawElementsInstancedANGLE(M, Y, de, ue, le); }, 1; } function Rh(S) { var A = S.getExtension("OES_vertex_array_object"); if (A) return S.createVertexArray = function() { return A.createVertexArrayOES(); }, S.deleteVertexArray = function(M) { A.deleteVertexArrayOES(M); }, S.bindVertexArray = function(M) { A.bindVertexArrayOES(M); }, S.isVertexArray = function(M) { return A.isVertexArrayOES(M); }, 1; } function Dh(S) { var A = S.getExtension("WEBGL_draw_buffers"); if (A) return S.drawBuffers = function(M, Y) { A.drawBuffersWEBGL(M, Y); }, 1; } function Fh(S) { return !!(S.multiDrawWebgl = S.getExtension("WEBGL_multi_draw")); } var Je = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], uniforms: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, timerQueriesEXT: [], programInfos: {}, stringCache: {}, unpackAlignment: 4, recordError: function(A) { Je.lastError || (Je.lastError = A); }, getNewId: function(S) { for (var A = Je.counter++, M = S.length; M < A; M++) S[M] = null; return A; }, getSource: function(S, A, M, Y) { for (var de = "", ue = 0; ue < A; ++ue) { var le = Y ? o()[Y + ue * 4 >> 2] : -1; de += Be(o()[M + ue * 4 >> 2], le < 0 ? void 0 : le); } return de; }, createContext: function(S, A) { var M = S.getContext("webgl", A); if (!M) return 0; var Y = Je.registerContext(M, A); return Y; }, registerContext: function(S, A) { var M = Br(8); o()[M + 4 >> 2] = rr(); var Y = { handle: M, attributes: A, version: A.majorVersion, GLctx: S }; return S.canvas && (S.canvas.GLctxObject = Y), Je.contexts[M] = Y, (typeof A.enableExtensionsByDefault == "undefined" || A.enableExtensionsByDefault) && Je.initExtensions(Y), M; }, makeContextCurrent: function(S) { return Je.currentContext = Je.contexts[S], l.ctx = nr = Je.currentContext && Je.currentContext.GLctx, !(S && !nr); }, getContext: function(S) { return Je.contexts[S]; }, deleteContext: function(S) { Je.currentContext === Je.contexts[S] && (Je.currentContext = null), typeof Pe == "object" && Pe.removeAllHandlersOnTarget(Je.contexts[S].GLctx.canvas), Je.contexts[S] && Je.contexts[S].GLctx.canvas && (Je.contexts[S].GLctx.canvas.GLctxObject = void 0), vu(Je.contexts[S].handle), Je.contexts[S] = null; }, initExtensions: function(S) { if (S || (S = Je.currentContext), !S.initExtensionsDone) { S.initExtensionsDone = true; var A = S.GLctx; _h(A), Rh(A), Dh(A), A.disjointTimerQueryExt = A.getExtension("EXT_disjoint_timer_query"), Fh(A); var M = A.getSupportedExtensions() || []; M.forEach(function(Y) { Y.indexOf("lose_context") < 0 && Y.indexOf("debug") < 0 && A.getExtension(Y); }); } }, populateUniformTable: function(S) { for (var A = Je.programs[S], M = Je.programInfos[S] = { uniforms: {}, maxUniformLength: 0, maxAttributeLength: -1, maxUniformBlockNameLength: -1 }, Y = M.uniforms, de = nr.getProgramParameter(A, 35718), ue = 0; ue < de; ++ue) { var le = nr.getActiveUniform(A, ue), ye = le.name; M.maxUniformLength = Math.max(M.maxUniformLength, ye.length + 1), ye.slice(-1) == "]" && (ye = ye.slice(0, ye.lastIndexOf("["))); var et = nr.getUniformLocation(A, ye); if (et) { var zt = Je.getNewId(Je.uniforms); Y[ye] = [le.size, zt], Je.uniforms[zt] = et; for (var Et = 1; Et < le.size; ++Et) { var ar = ye + "[" + Et + "]"; et = nr.getUniformLocation(A, ar), zt = Je.getNewId(Je.uniforms), Je.uniforms[zt] = et; } } } } }, Oh = ["default", "low-power", "high-performance"]; function Ph(S, A) { var M = A >> 2, Y = o()[M + 6], de = { alpha: !!o()[M + 0], depth: !!o()[M + 1], stencil: !!o()[M + 2], antialias: !!o()[M + 3], premultipliedAlpha: !!o()[M + 4], preserveDrawingBuffer: !!o()[M + 5], powerPreference: Oh[Y], failIfMajorPerformanceCaveat: !!o()[M + 7], majorVersion: o()[M + 8], minorVersion: o()[M + 9], enableExtensionsByDefault: o()[M + 10], explicitSwapControl: o()[M + 11], proxyContextToMainThread: o()[M + 12], renderViaOffscreenBackBuffer: o()[M + 13] }, ue = mu(S); if (!ue || de.explicitSwapControl) return 0; var le = Je.createContext(ue, de); return le; } function zh(S, A) { return Ph(S, A); } var ki = { mappings: {}, buffers: [null, [], []], printChar: function(S, A) { var M = ki.buffers[S]; A === 0 || A === 10 ? ((S === 1 ? K : j)(We(M, 0)), M.length = 0) : M.push(A); }, varargs: void 0, get: function() { ki.varargs += 4; var S = o()[ki.varargs - 4 >> 2]; return S; }, getStr: function(S) { var A = Be(S); return A; }, get64: function(S, A) { return S; } }; function vc(S) { return C ? tr(3, 1, S) : 0; } function xc(S, A, M, Y, de) { if (C) return tr(4, 1, S, A, M, Y, de); } function wc(S, A, M, Y) { if (C) return tr(5, 1, S, A, M, Y); for (var de = 0, ue = 0; ue < M; ue++) { for (var le = o()[A + ue * 8 >> 2], ye = o()[A + (ue * 8 + 4) >> 2], et = 0; et < ye; et++) ki.printChar(S, i()[le + et]); de += ye; } return o()[Y >> 2] = de, 0; } function Mh(S) { var A = ke.threadExitHandlers.pop(); S && A(); } function Lh(S, A) { ke.threadExitHandlers.push(function() { Qt.get(S)(A); }); } function kc(S) { if (C) throw "Internal Error! spawnThread() can only ever be called from main application thread!"; var A = ke.getNewWorker(); if (A.pthread !== void 0) throw "Internal error!"; if (!S.pthread_ptr) throw "Internal error, no pthread ptr!"; ke.runningWorkers.push(A); for (var M = Br(128 * 4), Y = 0; Y < 128; ++Y) o()[M + Y * 4 >> 2] = 0; var de = S.stackBase + S.stackSize, ue = ke.pthreads[S.pthread_ptr] = { worker: A, stackBase: S.stackBase, stackSize: S.stackSize, allocatedOwnStack: S.allocatedOwnStack, threadInfoStruct: S.pthread_ptr }, le = ue.threadInfoStruct >> 2; Atomics.store(u(), le + 16, S.detached), Atomics.store(u(), le + 25, M), Atomics.store(u(), le + 10, ue.threadInfoStruct), Atomics.store(u(), le + 20, S.stackSize), Atomics.store(u(), le + 19, de), Atomics.store(u(), le + 26, S.stackSize), Atomics.store(u(), le + 28, de), Atomics.store(u(), le + 29, S.detached); var ye = xv(), et = ye + 40; Atomics.store(u(), le + 43, et), A.pthread = ue; var zt = { cmd: "run", start_routine: S.startRoutine, arg: S.arg, threadInfoStruct: S.pthread_ptr, stackBase: S.stackBase, stackSize: S.stackSize }; A.runPthread = function() { zt.time = performance.now(), A.postMessage(zt, S.transferList); }, A.loaded && (A.runPthread(), delete A.runPthread); } function Bh(S, A, M, Y) { if (typeof SharedArrayBuffer == "undefined") return j("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; if (!S) return j("pthread_create called with a null thread pointer!"), 28; var de = [], ue = 0; if (C && (de.length === 0 || ue)) return Cv(687865856, S, A, M, Y); if (ue) return ue; var le = 0, ye = 0, et = 0; A && A != -1 ? (le = o()[A >> 2], le += 81920, ye = o()[A + 8 >> 2], et = o()[A + 12 >> 2] !== 0) : le = 2097152; var zt = ye == 0; zt ? ye = $v(16, le) : (ye -= le, we(ye > 0)); for (var Et = Br(228), ar = 0; ar < 57; ++ar) u()[(Et >> 2) + ar] = 0; o()[S >> 2] = Et, o()[Et + 12 >> 2] = Et; var Ai = Et + 152; o()[Ai >> 2] = Ai; var en = { stackBase: ye, stackSize: le, allocatedOwnStack: zt, detached: et, startRoutine: M, pthread_ptr: Et, arg: Y, transferList: de }; return C ? (en.cmd = "spawnThread", postMessage(en, de)) : kc(en), 0; } function Vh() { if (!!C) { var S = rr(); if (!!S) { var A = Atomics.load(u(), S + 56 >> 2); if (!A) { var M = Atomics.load(u(), S + 0 >> 2); if (M == 2) throw "Canceled!"; } } } } function Wh() { k || x || Q("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); } function Uh(S, A, M) { if (!S) return j("pthread_join attempted on a null thread pointer!"), er.ESRCH; if (C && rr() == S) return j("PThread " + S + " is attempting to join to itself!"), er.EDEADLK; if (!C && Iv() == S) return j("Main thread " + S + " is attempting to join to itself!"), er.EDEADLK; var Y = o()[S + 12 >> 2]; if (Y !== S) return j("pthread_join attempted on thread " + S + ", which does not point to a valid thread, or does not exist anymore!"), er.ESRCH; var de = Atomics.load(u(), S + 64 >> 2); if (de) return j("Attempted to join thread " + S + ", which was already detached!"), er.EINVAL; for (M && Wh(); ; ) { var ue = Atomics.load(u(), S + 0 >> 2); if (ue == 1) { var le = Atomics.load(u(), S + 4 >> 2); return A && (o()[A >> 2] = le), Atomics.store(u(), S + 64 >> 2, 1), C ? postMessage({ cmd: "cleanupThread", thread: S }) : mc(S), 0; } if (!M) return er.EBUSY; Vh(), C || Ac(), gc(S + 0, ue, C ? 100 : 1); } } function Gh(S, A) { return Uh(S, A, true); } function Ic(S) { if (C) return tr(6, 1, S); switch (S) { case 30: return 16384; case 85: var A = 2147483648; return A / 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 lh(28), -1; } C || ke.initMainThreadBlock(); var nr, Hh = [null, ch, yc, vc, xc, wc, Ic], qh = { e: oh, r: uh, x: dh, b: ph, y: hh, j: fh, d: gc, c: pu, f: Lr, p: mh, A: gh, u: yh, q: wh, v: $h, i: Ah, s: Eh, w: zh, l: vc, n: xc, g: wc, o: th, a: ee || l.wasmMemory, z: Mh, k: Lh, h: Bh, m: Gh, t: Ic }, yv = eh(), Sc = l.___wasm_call_ctors = function() { return (Sc = l.___wasm_call_ctors = l.asm.B).apply(null, arguments); }, jh = l._init = function() { return (jh = l._init = l.asm.C).apply(null, arguments); }, Kh = l._init_with_threads_count = function() { return (Kh = l._init_with_threads_count = l.asm.D).apply(null, arguments); }, Xh = l._get_threads_count = function() { return (Xh = l._get_threads_count = l.asm.E).apply(null, arguments); }, Yh = l._register_tensor = function() { return (Yh = l._register_tensor = l.asm.F).apply(null, arguments); }, Qh = l._dispose_data = function() { return (Qh = l._dispose_data = l.asm.G).apply(null, arguments); }, Zh = l._dispose = function() { return (Zh = l._dispose = l.asm.H).apply(null, arguments); }, Jh = l._Abs = function() { return (Jh = l._Abs = l.asm.I).apply(null, arguments); }, ef = l._Add = function() { return (ef = l._Add = l.asm.J).apply(null, arguments); }, tf = l._AddN = function() { return (tf = l._AddN = l.asm.K).apply(null, arguments); }, nf = l._All = function() { return (nf = l._All = l.asm.L).apply(null, arguments); }, sf = l._Any = function() { return (sf = l._Any = l.asm.M).apply(null, arguments); }, rf = l._ArgMax = function() { return (rf = l._ArgMax = l.asm.N).apply(null, arguments); }, af = l._AvgPool = function() { return (af = l._AvgPool = l.asm.O).apply(null, arguments); }, of = l._BatchMatMul = function() { return (of = l._BatchMatMul = l.asm.P).apply(null, arguments); }, uf = l._Ceil = function() { return (uf = l._Ceil = l.asm.Q).apply(null, arguments); }, lf = l._ClipByValue = function() { return (lf = l._ClipByValue = l.asm.R).apply(null, arguments); }, cf = l._Conv2D = function() { return (cf = l._Conv2D = l.asm.S).apply(null, arguments); }, df = l._Conv2DBackpropInput = function() { return (df = l._Conv2DBackpropInput = l.asm.T).apply(null, arguments); }, pf = l._Cos = function() { return (pf = l._Cos = l.asm.U).apply(null, arguments); }, hf = l._Cosh = function() { return (hf = l._Cosh = l.asm.V).apply(null, arguments); }, Cc = l._CropAndResize = function() { return (Cc = l._CropAndResize = l.asm.W).apply(null, arguments); }, Nc = l._Cumsum = function() { return (Nc = l._Cumsum = l.asm.X).apply(null, arguments); }, gu = l._DepthToSpace = function() { return (gu = l._DepthToSpace = l.asm.Y).apply(null, arguments); }, Ii = l._DepthwiseConv2dNative = function() { return (Ii = l._DepthwiseConv2dNative = l.asm.Z).apply(null, arguments); }, ff = l._Elu = function() { return (ff = l._Elu = l.asm._).apply(null, arguments); }, bu = l._Equal = function() { return (bu = l._Equal = l.asm.$).apply(null, arguments); }, Si = l._Exp = function() { return (Si = l._Exp = l.asm.aa).apply(null, arguments); }, Ci = l._FlipLeftRight = function() { return (Ci = l._FlipLeftRight = l.asm.ba).apply(null, arguments); }, mf = l._Floor = function() { return (mf = l._Floor = l.asm.ca).apply(null, arguments); }, Z = l._FloorDiv = function() { return (Z = l._FloorDiv = l.asm.da).apply(null, arguments); }, re = l._FusedBatchNorm = function() { return (re = l._FusedBatchNorm = l.asm.ea).apply(null, arguments); }, ge = l._FusedConv2D = function() { return (ge = l._FusedConv2D = l.asm.fa).apply(null, arguments); }, Ze = l._FusedDepthwiseConv2D = function() { return (Ze = l._FusedDepthwiseConv2D = l.asm.ga).apply(null, arguments); }, xt = l._Gather = function() { return (xt = l._Gather = l.asm.ha).apply(null, arguments); }, ft = l._GatherNd = function() { return (ft = l._GatherNd = l.asm.ia).apply(null, arguments); }, Ve = l._Greater = function() { return (Ve = l._Greater = l.asm.ja).apply(null, arguments); }, Ue = l._GreaterEqual = function() { return (Ue = l._GreaterEqual = l.asm.ka).apply(null, arguments); }, qt = l._LeakyRelu = function() { return (qt = l._LeakyRelu = l.asm.la).apply(null, arguments); }, Ms = l._Less = function() { return (Ms = l._Less = l.asm.ma).apply(null, arguments); }, Ls = l._LessEqual = function() { return (Ls = l._LessEqual = l.asm.na).apply(null, arguments); }, Tc = l._Log = function() { return (Tc = l._Log = l.asm.oa).apply(null, arguments); }, yu = l._LogicalAnd = function() { return (yu = l._LogicalAnd = l.asm.pa).apply(null, arguments); }, Nn = l._Max = function() { return (Nn = l._Max = l.asm.qa).apply(null, arguments); }, sr = l._MaxPool = function() { return (sr = l._MaxPool = l.asm.ra).apply(null, arguments); }, $c = l._Maximum = function() { return ($c = l._Maximum = l.asm.sa).apply(null, arguments); }, mN = l._Mean = function() { return (mN = l._Mean = l.asm.ta).apply(null, arguments); }, gN = l._Min = function() { return (gN = l._Min = l.asm.ua).apply(null, arguments); }, bN = l._Minimum = function() { return (bN = l._Minimum = l.asm.va).apply(null, arguments); }, yN = l._MirrorPad = function() { return (yN = l._MirrorPad = l.asm.wa).apply(null, arguments); }, vN = l._Multiply = function() { return (vN = l._Multiply = l.asm.xa).apply(null, arguments); }, xN = l._Neg = function() { return (xN = l._Neg = l.asm.ya).apply(null, arguments); }, wN = l._NonMaxSuppressionV3 = function() { return (wN = l._NonMaxSuppressionV3 = l.asm.za).apply(null, arguments); }, kN = l._NonMaxSuppressionV4 = function() { return (kN = l._NonMaxSuppressionV4 = l.asm.Aa).apply(null, arguments); }, IN = l._NonMaxSuppressionV5 = function() { return (IN = l._NonMaxSuppressionV5 = l.asm.Ba).apply(null, arguments); }, SN = l._NotEqual = function() { return (SN = l._NotEqual = l.asm.Ca).apply(null, arguments); }, CN = l._OneHot = function() { return (CN = l._OneHot = l.asm.Da).apply(null, arguments); }, NN = l._PadV2 = function() { return (NN = l._PadV2 = l.asm.Ea).apply(null, arguments); }, TN = l._Pow = function() { return (TN = l._Pow = l.asm.Fa).apply(null, arguments); }, $N = l._Prelu = function() { return ($N = l._Prelu = l.asm.Ga).apply(null, arguments); }, AN = l._Prod = function() { return (AN = l._Prod = l.asm.Ha).apply(null, arguments); }, EN = l._RealDiv = function() { return (EN = l._RealDiv = l.asm.Ia).apply(null, arguments); }, _N = l._Relu = function() { return (_N = l._Relu = l.asm.Ja).apply(null, arguments); }, RN = l._Relu6 = function() { return (RN = l._Relu6 = l.asm.Ka).apply(null, arguments); }, DN = l._ResizeBilinear = function() { return (DN = l._ResizeBilinear = l.asm.La).apply(null, arguments); }, FN = l._Reverse = function() { return (FN = l._Reverse = l.asm.Ma).apply(null, arguments); }, ON = l._RotateWithOffset = function() { return (ON = l._RotateWithOffset = l.asm.Na).apply(null, arguments); }, PN = l._Round = function() { return (PN = l._Round = l.asm.Oa).apply(null, arguments); }, zN = l._Rsqrt = function() { return (zN = l._Rsqrt = l.asm.Pa).apply(null, arguments); }, MN = l._ScatterNd = function() { return (MN = l._ScatterNd = l.asm.Qa).apply(null, arguments); }, LN = l._SelectV2 = function() { return (LN = l._SelectV2 = l.asm.Ra).apply(null, arguments); }, BN = l._Sigmoid = function() { return (BN = l._Sigmoid = l.asm.Sa).apply(null, arguments); }, VN = l._Sin = function() { return (VN = l._Sin = l.asm.Ta).apply(null, arguments); }, WN = l._Softmax = function() { return (WN = l._Softmax = l.asm.Ua).apply(null, arguments); }, UN = l._SparseFillEmptyRows = function() { return (UN = l._SparseFillEmptyRows = l.asm.Va).apply(null, arguments); }, GN = l._SparseReshape = function() { return (GN = l._SparseReshape = l.asm.Wa).apply(null, arguments); }, HN = l._SparseSegmentReduction = function() { return (HN = l._SparseSegmentReduction = l.asm.Xa).apply(null, arguments); }, qN = l._Sqrt = function() { return (qN = l._Sqrt = l.asm.Ya).apply(null, arguments); }, jN = l._Square = function() { return (jN = l._Square = l.asm.Za).apply(null, arguments); }, KN = l._SquaredDifference = function() { return (KN = l._SquaredDifference = l.asm._a).apply(null, arguments); }, XN = l._Step = function() { return (XN = l._Step = l.asm.$a).apply(null, arguments); }, YN = l._StridedSlice = function() { return (YN = l._StridedSlice = l.asm.ab).apply(null, arguments); }, QN = l._Sub = function() { return (QN = l._Sub = l.asm.bb).apply(null, arguments); }, ZN = l._Sum = function() { return (ZN = l._Sum = l.asm.cb).apply(null, arguments); }, JN = l._Tan = function() { return (JN = l._Tan = l.asm.db).apply(null, arguments); }, eT = l._Tanh = function() { return (eT = l._Tanh = l.asm.eb).apply(null, arguments); }, tT = l._Tile = function() { return (tT = l._Tile = l.asm.fb).apply(null, arguments); }, nT = l._TopK = function() { return (nT = l._TopK = l.asm.gb).apply(null, arguments); }, sT = l._Transform = function() { return (sT = l._Transform = l.asm.hb).apply(null, arguments); }, rT = l._Transpose = function() { return (rT = l._Transpose = l.asm.ib).apply(null, arguments); }, aT = l.__FusedMatMul = function() { return (aT = l.__FusedMatMul = l.asm.jb).apply(null, arguments); }, Br = l._malloc = function() { return (Br = l._malloc = l.asm.kb).apply(null, arguments); }, vu = l._free = function() { return (vu = l._free = l.asm.lb).apply(null, arguments); }, vv = l.___errno_location = function() { return (vv = l.___errno_location = l.asm.mb).apply(null, arguments); }, xv = l._emscripten_get_global_libc = function() { return (xv = l._emscripten_get_global_libc = l.asm.ob).apply(null, arguments); }, rr = l._pthread_self = function() { return (rr = l._pthread_self = l.asm.pb).apply(null, arguments); }, wv = l.___pthread_tsd_run_dtors = function() { return (wv = l.___pthread_tsd_run_dtors = l.asm.qb).apply(null, arguments); }, Ac = l._emscripten_main_thread_process_queued_calls = function() { return (Ac = l._emscripten_main_thread_process_queued_calls = l.asm.rb).apply(null, arguments); }, iT = l._emscripten_current_thread_process_queued_calls = function() { return (iT = l._emscripten_current_thread_process_queued_calls = l.asm.sb).apply(null, arguments); }, kv = l._emscripten_register_main_browser_thread_id = function() { return (kv = l._emscripten_register_main_browser_thread_id = l.asm.tb).apply(null, arguments); }, Iv = l._emscripten_main_browser_thread_id = function() { return (Iv = l._emscripten_main_browser_thread_id = l.asm.ub).apply(null, arguments); }, Sv = l.__emscripten_do_dispatch_to_thread = function() { return (Sv = l.__emscripten_do_dispatch_to_thread = l.asm.vb).apply(null, arguments); }, Cv = l._emscripten_sync_run_in_main_thread_4 = function() { return (Cv = l._emscripten_sync_run_in_main_thread_4 = l.asm.wb).apply(null, arguments); }, Nv = l._emscripten_run_in_main_runtime_thread_js = function() { return (Nv = l._emscripten_run_in_main_runtime_thread_js = l.asm.xb).apply(null, arguments); }, gf = l.__emscripten_call_on_thread = function() { return (gf = l.__emscripten_call_on_thread = l.asm.yb).apply(null, arguments); }, oT = l._emscripten_tls_init = function() { return (oT = l._emscripten_tls_init = l.asm.zb).apply(null, arguments); }, bf = l.__emscripten_thread_init = function() { return (bf = l.__emscripten_thread_init = l.asm.Ab).apply(null, arguments); }, xu = l.stackSave = function() { return (xu = l.stackSave = l.asm.Bb).apply(null, arguments); }, Ni = l.stackRestore = function() { return (Ni = l.stackRestore = l.asm.Cb).apply(null, arguments); }, Ti = l.stackAlloc = function() { return (Ti = l.stackAlloc = l.asm.Db).apply(null, arguments); }, Tv = l._emscripten_stack_set_limits = function() { return (Tv = l._emscripten_stack_set_limits = l.asm.Eb).apply(null, arguments); }, $v = l._memalign = function() { return ($v = l._memalign = l.asm.Fb).apply(null, arguments); }, Av = l.__emscripten_allow_main_runtime_queued_calls = 10208, $i = l.__emscripten_main_thread_futex = 10412; l.cwrap = Xe, l.PThread = ke, l.PThread = ke, l.wasmMemory = ee, l.ExitStatus = wu; var Ec; function wu(S) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + S + ")", this.status = S; } zr = function S() { Ec || yf(), Ec || (zr = S); }; function yf(S) { if (S = S || g, jn > 0) return; if (C) { d(l), uc(), postMessage({ cmd: "loaded" }); return; } if (oc(), jn > 0) return; function A() { Ec || (Ec = true, l.calledRun = true, !me && (uc(), lc(), d(l), l.onRuntimeInitialized && l.onRuntimeInitialized(), cc())); } l.setStatus ? (l.setStatus("Running..."), setTimeout(function() { setTimeout(function() { l.setStatus(""); }, 1), A(); }, 1)) : A(); } l.run = yf; function uT(S, A) { if (!(A && ie && S === 0)) { if (!A && C) throw postMessage({ cmd: "exitProcess", returnCode: S }), new wu(S); ie || (ke.terminateAllThreads(), Ie = S, mn(), l.onExit && l.onExit(S), me = true), y(S, new wu(S)); } } if (l.preInit) for (typeof l.preInit == "function" && (l.preInit = [l.preInit]); l.preInit.length > 0; ) l.preInit.pop()(); C && (ie = false, ke.initWorker()), yf(); var _c; h && (_c = { uncaughtException: process.listeners("uncaughtException").filter(function(S) { return !h.uncaughtException.indexOf(S) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(S) { return !h.unhandledRejection.indexOf(S) > -1; }) }); var Rc; if (typeof WasmBackendModule != "undefined") Rc = WasmBackendModule; else if (typeof r != "undefined") Rc = r; else throw new Error("Could not find wasm module in post.js"); if (_c) { var lT = Rc._dispose; Rc._dispose = function() { lT(), _c.uncaughtException.forEach(function(S) { process.removeListener("uncaughtException", S); }), _c.unhandledRejection.forEach(function(S) { process.removeListener("unhandledRejection", S); }); }; } return r.ready; }; }(); typeof e == "object" && typeof t == "object" ? t.exports = n : typeof define == "function" && define.amd ? define([], function() { return n; }) : typeof e == "object" && (e.WasmBackendModuleThreadedSimd = n); } }); var _T = Pt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { var n = function() { var s = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (s = s || __filename), function(r) { r = r || {}; var a = typeof r != "undefined" ? r : {}, i, o; a.ready = new Promise(function(Z, re) { i = Z, o = re; }); var u; typeof process != "undefined" && process.listeners && (u = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var c = {}, l; for (l in a) a.hasOwnProperty(l) && (c[l] = a[l]); var d = [], p = "./this.program", h = function(Z, re) { throw re; }, f = false, m = false, g = false, b = false; f = typeof window == "object", m = typeof importScripts == "function", g = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", b = !f && !g && !m; var y = ""; function v(Z) { return a.locateFile ? a.locateFile(Z, y) : y + Z; } var x, k, T, C, R, _; g ? (m ? y = Ou().dirname(y) + "/" : y = __dirname + "/", x = function(re, ge) { return R || (R = sd()), _ || (_ = Ou()), re = _.normalize(re), R.readFileSync(re, ge ? null : "utf8"); }, T = function(re) { var ge = x(re, true); return ge.buffer || (ge = new Uint8Array(ge)), K(ge.buffer), ge; }, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), d = process.argv.slice(2), process.on("uncaughtException", function(Z) { if (!(Z instanceof ff)) throw Z; }), process.on("unhandledRejection", Ps), h = function(Z) { process.exit(Z); }, a.inspect = function() { return "[Emscripten Module object]"; }) : b ? (typeof read != "undefined" && (x = function(re) { return read(re); }), T = function(re) { var ge; return typeof readbuffer == "function" ? new Uint8Array(readbuffer(re)) : (ge = read(re, "binary"), K(typeof ge == "object"), ge); }, typeof scriptArgs != "undefined" ? d = scriptArgs : typeof arguments != "undefined" && (d = arguments), typeof quit == "function" && (h = function(Z) { quit(Z); }), typeof print != "undefined" && (typeof console == "undefined" && (console = {}), console.log = print, console.warn = console.error = typeof printErr != "undefined" ? printErr : print)) : (f || m) && (m ? y = self.location.href : typeof document != "undefined" && document.currentScript && (y = document.currentScript.src), s && (y = s), y.indexOf("blob:") !== 0 ? y = y.substr(0, y.lastIndexOf("/") + 1) : y = "", x = function(Z) { var re = new XMLHttpRequest(); return re.open("GET", Z, false), re.send(null), re.responseText; }, m && (T = function(Z) { var re = new XMLHttpRequest(); return re.open("GET", Z, false), re.responseType = "arraybuffer", re.send(null), new Uint8Array(re.response); }), k = function(Z, re, ge) { var Ze = new XMLHttpRequest(); Ze.open("GET", Z, true), Ze.responseType = "arraybuffer", Ze.onload = function() { if (Ze.status == 200 || Ze.status == 0 && Ze.response) { re(Ze.response); return; } ge(); }, Ze.onerror = ge, Ze.send(null); }, C = function(Z) { document.title = Z; }); var P = a.print || console.log.bind(console), D = a.printErr || console.warn.bind(console); for (l in c) c.hasOwnProperty(l) && (a[l] = c[l]); c = null, a.arguments && (d = a.arguments), a.thisProgram && (p = a.thisProgram), a.quit && (h = a.quit); var F; a.wasmBinary && (F = a.wasmBinary); var $ = a.noExitRuntime || true; typeof WebAssembly != "object" && Ps("no native wasm support detected"); var z, W = false, q; function K(Z, re) { Z || Ps("Assertion failed: " + re); } function j(Z) { var re = a["_" + Z]; return K(re, "Cannot call unknown function " + Z + ", make sure it is exported"), re; } function Q(Z, re, ge, Ze, xt) { var ft = { string: function(Nn) { var sr = 0; if (Nn != null && Nn !== 0) { var $c = (Nn.length << 2) + 1; sr = gu($c), ee(Nn, sr, $c); } return sr; }, array: function(Nn) { var sr = gu(Nn.length); return ce(Nn, sr), sr; } }; function Ve(Nn) { return re === "string" ? te(Nn) : re === "boolean" ? Boolean(Nn) : Nn; } var Ue = j(Z), qt = [], Ms = 0; if (Ze) for (var Ls = 0; Ls < Ze.length; Ls++) { var Tc = ft[ge[Ls]]; Tc ? (Ms === 0 && (Ms = Cc()), qt[Ls] = Tc(Ze[Ls])) : qt[Ls] = Ze[Ls]; } var yu = Ue.apply(null, qt); return yu = Ve(yu), Ms !== 0 && Nc(Ms), yu; } function J(Z, re, ge, Ze) { ge = ge || []; var xt = ge.every(function(Ve) { return Ve === "number"; }), ft = re !== "string"; return ft && xt && !Ze ? j(Z) : function() { return Q(Z, re, ge, arguments, Ze); }; } var ne = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; function se(Z, re, ge) { for (var Ze = re + ge, xt = re; Z[xt] && !(xt >= Ze); ) ++xt; if (xt - re > 16 && Z.subarray && ne) return ne.decode(Z.subarray(re, xt)); for (var ft = ""; re < xt; ) { var Ve = Z[re++]; if (!(Ve & 128)) { ft += String.fromCharCode(Ve); continue; } var Ue = Z[re++] & 63; if ((Ve & 224) == 192) { ft += String.fromCharCode((Ve & 31) << 6 | Ue); continue; } var qt = Z[re++] & 63; if ((Ve & 240) == 224 ? Ve = (Ve & 15) << 12 | Ue << 6 | qt : Ve = (Ve & 7) << 18 | Ue << 12 | qt << 6 | Z[re++] & 63, Ve < 65536) ft += String.fromCharCode(Ve); else { var Ms = Ve - 65536; ft += String.fromCharCode(55296 | Ms >> 10, 56320 | Ms & 1023); } } return ft; } function te(Z, re) { return Z ? se(Te, Z, re) : ""; } function ie(Z, re, ge, Ze) { if (!(Ze > 0)) return 0; for (var xt = ge, ft = ge + Ze - 1, Ve = 0; Ve < Z.length; ++Ve) { var Ue = Z.charCodeAt(Ve); if (Ue >= 55296 && Ue <= 57343) { var qt = Z.charCodeAt(++Ve); Ue = 65536 + ((Ue & 1023) << 10) | qt & 1023; } if (Ue <= 127) { if (ge >= ft) break; re[ge++] = Ue; } else if (Ue <= 2047) { if (ge + 1 >= ft) break; re[ge++] = 192 | Ue >> 6, re[ge++] = 128 | Ue & 63; } else if (Ue <= 65535) { if (ge + 2 >= ft) break; re[ge++] = 224 | Ue >> 12, re[ge++] = 128 | Ue >> 6 & 63, re[ge++] = 128 | Ue & 63; } else { if (ge + 3 >= ft) break; re[ge++] = 240 | Ue >> 18, re[ge++] = 128 | Ue >> 12 & 63, re[ge++] = 128 | Ue >> 6 & 63, re[ge++] = 128 | Ue & 63; } } return re[ge] = 0, ge - xt; } function ee(Z, re, ge) { return ie(Z, Te, re, ge); } function ce(Z, re) { we.set(Z, re); } function me(Z, re) { return Z % re > 0 && (Z += re - Z % re), Z; } var Ie, we, Te, Fe, Xe, We, Be, rt, Ye; function at(Z) { Ie = Z, a.HEAP8 = we = new Int8Array(Z), a.HEAP16 = Fe = new Int16Array(Z), a.HEAP32 = We = new Int32Array(Z), a.HEAPU8 = Te = new Uint8Array(Z), a.HEAPU16 = Xe = new Uint16Array(Z), a.HEAPU32 = Be = new Uint32Array(Z), a.HEAPF32 = rt = new Float32Array(Z), a.HEAPF64 = Ye = new Float64Array(Z); } var ht = a.INITIAL_MEMORY || 16777216, pn, Qe = [], Sn = [], Ht = [], Hn = [], hn = false; Sn.push({ func: function() { hc(); } }); function Cn() { if (a.preRun) for (typeof a.preRun == "function" && (a.preRun = [a.preRun]); a.preRun.length; ) fn(a.preRun.shift()); jn(Qe); } function Rn() { hn = true, jn(Sn); } function qn() { jn(Ht); } function Dn() { if (a.postRun) for (typeof a.postRun == "function" && (a.postRun = [a.postRun]); a.postRun.length; ) Zs(a.postRun.shift()); jn(Hn); } function fn(Z) { Qe.unshift(Z); } function Zs(Z) { Hn.unshift(Z); } var Qt = 0, Js = null, Fn = null; function lu(Z) { Qt++, a.monitorRunDependencies && a.monitorRunDependencies(Qt); } function cu(Z) { if (Qt--, a.monitorRunDependencies && a.monitorRunDependencies(Qt), Qt == 0 && (Js !== null && (clearInterval(Js), Js = null), Fn)) { var re = Fn; Fn = null, re(); } } a.preloadedImages = {}, a.preloadedAudios = {}; function Ps(Z) { a.onAbort && a.onAbort(Z), Z += "", D(Z), W = true, q = 1, Z = "abort(" + Z + "). Build with -s ASSERTIONS=1 for more info."; var re = new WebAssembly.RuntimeError(Z); throw o(re), re; } function ic(Z, re) { return String.prototype.startsWith ? Z.startsWith(re) : Z.indexOf(re) === 0; } var qp = "data:application/octet-stream;base64,"; function oc(Z) { return ic(Z, qp); } var uc = "file://"; function lc(Z) { return ic(Z, uc); } var mn = "tfjs-backend-wasm.wasm"; oc(mn) || (mn = v(mn)); function cc(Z) { try { if (Z == mn && F) return new Uint8Array(F); if (T) return T(Z); throw "both async and sync fetching of the wasm failed"; } catch (re) { Ps(re); } } function jp() { if (!F && (f || m)) { if (typeof fetch == "function" && !lc(mn)) return fetch(mn, { credentials: "same-origin" }).then(function(Z) { if (!Z.ok) throw "failed to load wasm binary file at '" + mn + "'"; return Z.arrayBuffer(); }).catch(function() { return cc(mn); }); if (k) return new Promise(function(Z, re) { k(mn, function(ge) { Z(new Uint8Array(ge)); }, re); }); } return Promise.resolve().then(function() { return cc(mn); }); } function Kp() { var Z = { a: gn }; function re(Ve, Ue) { var qt = Ve.exports; a.asm = qt, z = a.asm.h, at(z.buffer), pn = a.asm.Va, cu("wasm-instantiate"); } lu("wasm-instantiate"); function ge(Ve) { re(Ve.instance); } function Ze(Ve) { return jp().then(function(Ue) { return WebAssembly.instantiate(Ue, Z); }).then(Ve, function(Ue) { D("failed to asynchronously prepare wasm: " + Ue), Ps(Ue); }); } function xt() { return !F && typeof WebAssembly.instantiateStreaming == "function" && !oc(mn) && !lc(mn) && typeof fetch == "function" ? fetch(mn, { credentials: "same-origin" }).then(function(Ve) { var Ue = WebAssembly.instantiateStreaming(Ve, Z); return Ue.then(ge, function(qt) { return D("wasm streaming compile failed: " + qt), D("falling back to ArrayBuffer instantiation"), Ze(ge); }); }) : Ze(ge); } if (a.instantiateWasm) try { var ft = a.instantiateWasm(Z, re); return ft; } catch (Ve) { return D("Module.instantiateWasm callback failed with error: " + Ve), false; } return xt().catch(o), {}; } function jn(Z) { for (; Z.length > 0; ) { var re = Z.shift(); if (typeof re == "function") { re(a); continue; } var ge = re.func; typeof ge == "number" ? re.arg === void 0 ? pn.get(ge)() : pn.get(ge)(re.arg) : ge(re.arg === void 0 ? null : re.arg); } } function du() { Ps(); } function zr(Z, re, ge) { Te.copyWithin(Z, re, re + ge); } function Xp() { return Te.length; } function Yp(Z) { try { return z.grow(Z - Ie.byteLength + 65535 >>> 16), at(z.buffer), 1; } catch (re) { } } function zs(Z) { var re = Xp(), ge = 2147483648; if (Z > ge) return false; for (var Ze = 1; Ze <= 4; Ze *= 2) { var xt = re * (1 + 0.2 / Ze); xt = Math.min(xt, Z + 100663296); var ft = Math.min(ge, me(Math.max(Z, xt), 65536)), Ve = Yp(ft); if (Ve) return true; } return false; } var Mr = { mappings: {}, buffers: [null, [], []], printChar: function(Z, re) { var ge = Mr.buffers[Z]; re === 0 || re === 10 ? ((Z === 1 ? P : D)(se(ge, 0)), ge.length = 0) : ge.push(re); }, varargs: void 0, get: function() { Mr.varargs += 4; var Z = We[Mr.varargs - 4 >> 2]; return Z; }, getStr: function(Z) { var re = te(Z); return re; }, get64: function(Z, re) { return Z; } }; function Qp(Z) { return 0; } function dc(Z, re, ge, Ze, xt) { } function Zp(Z, re, ge, Ze) { for (var xt = 0, ft = 0; ft < ge; ft++) { for (var Ve = We[re + ft * 8 >> 2], Ue = We[re + (ft * 8 + 4) >> 2], qt = 0; qt < Ue; qt++) Mr.printChar(Z, Te[Ve + qt]); xt += Ue; } return We[Ze >> 2] = xt, 0; } function pc() { return 28; } var gn = { a: du, d: zr, e: zs, f: Qp, c: dc, b: Zp, g: pc }, Jp = Kp(), hc = a.___wasm_call_ctors = function() { return (hc = a.___wasm_call_ctors = a.asm.i).apply(null, arguments); }, eh = a._init = function() { return (eh = a._init = a.asm.j).apply(null, arguments); }, fc = a._init_with_threads_count = function() { return (fc = a._init_with_threads_count = a.asm.k).apply(null, arguments); }, th = a._get_threads_count = function() { return (th = a._get_threads_count = a.asm.l).apply(null, arguments); }, wi = a._register_tensor = function() { return (wi = a._register_tensor = a.asm.m).apply(null, arguments); }, er = a._dispose_data = function() { return (er = a._dispose_data = a.asm.n).apply(null, arguments); }, pu = a._dispose = function() { return (pu = a._dispose = a.asm.o).apply(null, arguments); }, nh = a._Abs = function() { return (nh = a._Abs = a.asm.p).apply(null, arguments); }, sh = a._Add = function() { return (sh = a._Add = a.asm.q).apply(null, arguments); }, mc = a._AddN = function() { return (mc = a._AddN = a.asm.r).apply(null, arguments); }, ke = a._All = function() { return (ke = a._All = a.asm.s).apply(null, arguments); }, rh = a._Any = function() { return (rh = a._Any = a.asm.t).apply(null, arguments); }, ah = a._ArgMax = function() { return (ah = a._ArgMax = a.asm.u).apply(null, arguments); }, ih = a._AvgPool = function() { return (ih = a._AvgPool = a.asm.v).apply(null, arguments); }, oh = a._BatchMatMul = function() { return (oh = a._BatchMatMul = a.asm.w).apply(null, arguments); }, uh = a._Ceil = function() { return (uh = a._Ceil = a.asm.x).apply(null, arguments); }, Lr = a._ClipByValue = function() { return (Lr = a._ClipByValue = a.asm.y).apply(null, arguments); }, lh = a._Conv2D = function() { return (lh = a._Conv2D = a.asm.z).apply(null, arguments); }, ch = a._Conv2DBackpropInput = function() { return (ch = a._Conv2DBackpropInput = a.asm.A).apply(null, arguments); }, dh = a._Cos = function() { return (dh = a._Cos = a.asm.B).apply(null, arguments); }, ph = a._Cosh = function() { return (ph = a._Cosh = a.asm.C).apply(null, arguments); }, hh = a._CropAndResize = function() { return (hh = a._CropAndResize = a.asm.D).apply(null, arguments); }, fh = a._Cumsum = function() { return (fh = a._Cumsum = a.asm.E).apply(null, arguments); }, gc = a._DepthToSpace = function() { return (gc = a._DepthToSpace = a.asm.F).apply(null, arguments); }, mh = a._DepthwiseConv2dNative = function() { return (mh = a._DepthwiseConv2dNative = a.asm.G).apply(null, arguments); }, gh = a._Elu = function() { return (gh = a._Elu = a.asm.H).apply(null, arguments); }, tr = a._Equal = function() { return (tr = a._Equal = a.asm.I).apply(null, arguments); }, hu = a._Exp = function() { return (hu = a._Exp = a.asm.J).apply(null, arguments); }, fu = a._FlipLeftRight = function() { return (fu = a._FlipLeftRight = a.asm.K).apply(null, arguments); }, bh = a._Floor = function() { return (bh = a._Floor = a.asm.L).apply(null, arguments); }, yh = a._FloorDiv = function() { return (yh = a._FloorDiv = a.asm.M).apply(null, arguments); }, vh = a._FusedBatchNorm = function() { return (vh = a._FusedBatchNorm = a.asm.N).apply(null, arguments); }, xh = a._FusedConv2D = function() { return (xh = a._FusedConv2D = a.asm.O).apply(null, arguments); }, wh = a._FusedDepthwiseConv2D = function() { return (wh = a._FusedDepthwiseConv2D = a.asm.P).apply(null, arguments); }, Pe = a._Gather = function() { return (Pe = a._Gather = a.asm.Q).apply(null, arguments); }, kh = a._GatherNd = function() { return (kh = a._GatherNd = a.asm.R).apply(null, arguments); }, Ih = a._Greater = function() { return (Ih = a._Greater = a.asm.S).apply(null, arguments); }, Sh = a._GreaterEqual = function() { return (Sh = a._GreaterEqual = a.asm.T).apply(null, arguments); }, Ch = a._LeakyRelu = function() { return (Ch = a._LeakyRelu = a.asm.U).apply(null, arguments); }, Nh = a._Less = function() { return (Nh = a._Less = a.asm.V).apply(null, arguments); }, Th = a._LessEqual = function() { return (Th = a._LessEqual = a.asm.W).apply(null, arguments); }, mu = a._Log = function() { return (mu = a._Log = a.asm.X).apply(null, arguments); }, bc = a._LogicalAnd = function() { return (bc = a._LogicalAnd = a.asm.Y).apply(null, arguments); }, yc = a._Max = function() { return (yc = a._Max = a.asm.Z).apply(null, arguments); }, $h = a._MaxPool = function() { return ($h = a._MaxPool = a.asm._).apply(null, arguments); }, Ah = a._Maximum = function() { return (Ah = a._Maximum = a.asm.$).apply(null, arguments); }, Eh = a._Mean = function() { return (Eh = a._Mean = a.asm.aa).apply(null, arguments); }, _h = a._Min = function() { return (_h = a._Min = a.asm.ba).apply(null, arguments); }, Rh = a._Minimum = function() { return (Rh = a._Minimum = a.asm.ca).apply(null, arguments); }, Dh = a._MirrorPad = function() { return (Dh = a._MirrorPad = a.asm.da).apply(null, arguments); }, Fh = a._Multiply = function() { return (Fh = a._Multiply = a.asm.ea).apply(null, arguments); }, Je = a._Neg = function() { return (Je = a._Neg = a.asm.fa).apply(null, arguments); }, Oh = a._NonMaxSuppressionV3 = function() { return (Oh = a._NonMaxSuppressionV3 = a.asm.ga).apply(null, arguments); }, Ph = a._NonMaxSuppressionV4 = function() { return (Ph = a._NonMaxSuppressionV4 = a.asm.ha).apply(null, arguments); }, zh = a._NonMaxSuppressionV5 = function() { return (zh = a._NonMaxSuppressionV5 = a.asm.ia).apply(null, arguments); }, ki = a._NotEqual = function() { return (ki = a._NotEqual = a.asm.ja).apply(null, arguments); }, vc = a._OneHot = function() { return (vc = a._OneHot = a.asm.ka).apply(null, arguments); }, xc = a._PadV2 = function() { return (xc = a._PadV2 = a.asm.la).apply(null, arguments); }, wc = a._Pow = function() { return (wc = a._Pow = a.asm.ma).apply(null, arguments); }, Mh = a._Prelu = function() { return (Mh = a._Prelu = a.asm.na).apply(null, arguments); }, Lh = a._Prod = function() { return (Lh = a._Prod = a.asm.oa).apply(null, arguments); }, kc = a._RealDiv = function() { return (kc = a._RealDiv = a.asm.pa).apply(null, arguments); }, Bh = a._Relu = function() { return (Bh = a._Relu = a.asm.qa).apply(null, arguments); }, Vh = a._Relu6 = function() { return (Vh = a._Relu6 = a.asm.ra).apply(null, arguments); }, Wh = a._ResizeBilinear = function() { return (Wh = a._ResizeBilinear = a.asm.sa).apply(null, arguments); }, Uh = a._Reverse = function() { return (Uh = a._Reverse = a.asm.ta).apply(null, arguments); }, Gh = a._RotateWithOffset = function() { return (Gh = a._RotateWithOffset = a.asm.ua).apply(null, arguments); }, Ic = a._Round = function() { return (Ic = a._Round = a.asm.va).apply(null, arguments); }, nr = a._Rsqrt = function() { return (nr = a._Rsqrt = a.asm.wa).apply(null, arguments); }, Hh = a._ScatterNd = function() { return (Hh = a._ScatterNd = a.asm.xa).apply(null, arguments); }, qh = a._SelectV2 = function() { return (qh = a._SelectV2 = a.asm.ya).apply(null, arguments); }, yv = a._Sigmoid = function() { return (yv = a._Sigmoid = a.asm.za).apply(null, arguments); }, Sc = a._Sin = function() { return (Sc = a._Sin = a.asm.Aa).apply(null, arguments); }, jh = a._Softmax = function() { return (jh = a._Softmax = a.asm.Ba).apply(null, arguments); }, Kh = a._SparseFillEmptyRows = function() { return (Kh = a._SparseFillEmptyRows = a.asm.Ca).apply(null, arguments); }, Xh = a._SparseReshape = function() { return (Xh = a._SparseReshape = a.asm.Da).apply(null, arguments); }, Yh = a._SparseSegmentReduction = function() { return (Yh = a._SparseSegmentReduction = a.asm.Ea).apply(null, arguments); }, Qh = a._Sqrt = function() { return (Qh = a._Sqrt = a.asm.Fa).apply(null, arguments); }, Zh = a._Square = function() { return (Zh = a._Square = a.asm.Ga).apply(null, arguments); }, Jh = a._SquaredDifference = function() { return (Jh = a._SquaredDifference = a.asm.Ha).apply(null, arguments); }, ef = a._Step = function() { return (ef = a._Step = a.asm.Ia).apply(null, arguments); }, tf = a._StridedSlice = function() { return (tf = a._StridedSlice = a.asm.Ja).apply(null, arguments); }, nf = a._Sub = function() { return (nf = a._Sub = a.asm.Ka).apply(null, arguments); }, sf = a._Sum = function() { return (sf = a._Sum = a.asm.La).apply(null, arguments); }, rf = a._Tan = function() { return (rf = a._Tan = a.asm.Ma).apply(null, arguments); }, af = a._Tanh = function() { return (af = a._Tanh = a.asm.Na).apply(null, arguments); }, of = a._Tile = function() { return (of = a._Tile = a.asm.Oa).apply(null, arguments); }, uf = a._TopK = function() { return (uf = a._TopK = a.asm.Pa).apply(null, arguments); }, lf = a._Transform = function() { return (lf = a._Transform = a.asm.Qa).apply(null, arguments); }, cf = a._Transpose = function() { return (cf = a._Transpose = a.asm.Ra).apply(null, arguments); }, df = a.__FusedMatMul = function() { return (df = a.__FusedMatMul = a.asm.Sa).apply(null, arguments); }, pf = a._malloc = function() { return (pf = a._malloc = a.asm.Ta).apply(null, arguments); }, hf = a._free = function() { return (hf = a._free = a.asm.Ua).apply(null, arguments); }, Cc = a.stackSave = function() { return (Cc = a.stackSave = a.asm.Wa).apply(null, arguments); }, Nc = a.stackRestore = function() { return (Nc = a.stackRestore = a.asm.Xa).apply(null, arguments); }, gu = a.stackAlloc = function() { return (gu = a.stackAlloc = a.asm.Ya).apply(null, arguments); }; a.cwrap = J; var Ii; function ff(Z) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + Z + ")", this.status = Z; } Fn = function Z() { Ii || bu(), Ii || (Fn = Z); }; function bu(Z) { if (Z = Z || d, Qt > 0 || (Cn(), Qt > 0)) return; function re() { Ii || (Ii = true, a.calledRun = true, !W && (Rn(), qn(), i(a), a.onRuntimeInitialized && a.onRuntimeInitialized(), Dn())); } a.setStatus ? (a.setStatus("Running..."), setTimeout(function() { setTimeout(function() { a.setStatus(""); }, 1), re(); }, 1)) : re(); } if (a.run = bu, a.preInit) for (typeof a.preInit == "function" && (a.preInit = [a.preInit]); a.preInit.length > 0; ) a.preInit.pop()(); bu(); var Si; u && (Si = { uncaughtException: process.listeners("uncaughtException").filter(function(Z) { return !u.uncaughtException.indexOf(Z) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(Z) { return !u.unhandledRejection.indexOf(Z) > -1; }) }); var Ci; if (typeof r != "undefined") Ci = r; else if (typeof WasmBackendModuleThreadedSimd != "undefined") Ci = WasmBackendModuleThreadedSimd; else throw new Error("Could not find wasm module in post.js"); if (Si) { var mf = Ci._dispose; Ci._dispose = function() { mf(), Si.uncaughtException.forEach(function(Z) { process.removeListener("uncaughtException", Z); }), Si.unhandledRejection.forEach(function(Z) { process.removeListener("unhandledRejection", Z); }); }; } return r.ready; }; }(); typeof e == "object" && typeof t == "object" ? t.exports = n : typeof define == "function" && define.amd ? define([], function() { return n; }) : typeof e == "object" && (e.WasmBackendModule = n); } }); var RT = 1e-7; var DT = 1e-4; var Od = class { constructor(e, t) { this.backend = e, this.dataMover = t, this.data = /* @__PURE__ */ 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 tl = class { refCount(e) { return On("refCount"); } incRef(e) { return On("incRef"); } timerAvailable() { return true; } time(e) { return On("time"); } read(e) { return On("read"); } readSync(e) { return On("readSync"); } readToGPU(e, t) { return On("readToGPU"); } numDataIds() { return On("numDataIds"); } disposeData(e, t) { return On("disposeData"); } write(e, t, n) { return On("write"); } move(e, t, n, s, r) { return On("move"); } memory() { return On("memory"); } floatPrecision() { return On("floatPrecision"); } epsilon() { return this.floatPrecision() === 32 ? RT : DT; } dispose() { return On("dispose"); } }; function On(e) { throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`); } function mw(e) { let t = e.length, n = 0; for (; t > 0; ) n = Math.random() * t | 0, t--, rd(e, t, n); } function FT(e, t) { if (e.length !== t.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`); let n = e.length, s = 0; for (; n > 0; ) s = Math.random() * n | 0, n--, rd(e, n, s), rd(t, n, s); } function Bu(e, t, n) { return Math.max(e, Math.min(t, n)); } function OT(e) { return e % 2 === 0 ? e : e + 1; } function rd(e, t, n) { let s = e[t]; e[t] = e[n], e[n] = s; } function PT(e) { let t = 0; for (let n = 0; n < e.length; n++) t += e[n]; return t; } function zT(e, t) { let n = Math.random(); return t * n + (1 - n) * e; } function MT(e, t) { let n = 0; for (let s = 0; s < e.length; s++) { let r = Number(e[s]) - Number(t[s]); n += r * r; } return n; } function O(e, t) { if (!e) throw new Error(typeof t == "string" ? t : t()); } function on(e, t, n = "") { O(Sr(e, t), () => n + ` Shapes ${e} and ${t} must match`); } function xa(e) { O(e != null, () => "The input to the tensor constructor must be a non-null value."); } function na(e, t = [], n = false) { if (t == null && (t = []), Array.isArray(e) || Zt(e) && !n) for (let s = 0; s < e.length; ++s) na(e[s], t, n); else t.push(e); return t; } function pt(e) { if (e.length === 0) return 1; let t = e[0]; for (let n = 1; n < e.length; n++) t *= e[n]; return t; } function LT(e) { return e.length === 0; } function Sr(e, t) { if (e === t) return true; if (e == null || t == null || e.length !== t.length) return false; for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return false; return true; } function ji(e) { return e % 1 === 0; } function BT(e) { if (Math.tanh != null) return Math.tanh(e); if (e === 1 / 0) return 1; if (e === -1 / 0) return -1; { let t = Math.exp(2 * e); return (t - 1) / (t + 1); } } function VT(e) { let t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)]; } function WT(e) { let t = new Uint32Array(e); for (let n = 0; n < e; ++n) t[n] = n; return mw(t), t; } function Pu(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length); } function UT(e, t = (s) => 0, n) { return new Promise((s, r) => { let a = 0, i = () => { if (e()) { s(); return; } a++; let o = t(a); if (n != null && a >= n) { r(); return; } setTimeout(i, o); }; i(); }); } function GT(e, t) { let n = 1, s = -1; for (let a = 0; a < e.length; ++a) if (e[a] >= 0) n *= e[a]; else if (e[a] === -1) { if (s !== -1) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`); s = a; } else if (e[a] < 0) throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`); if (s === -1) { if (t > 0 && t !== n) throw Error(`Size(${t}) must match the product of shape ${e}`); return e; } if (n === 0) throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`); if (t % n !== 0) throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`); let r = e.slice(); return r[s] = t / n, r; } function ss(e, t) { let n = t.length; return e = e == null ? t.map((s, r) => r) : [].concat(e), O(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), O(e.every((s) => ji(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s); } function gw(e, t) { let n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : ss(t, e).sort(), i = 0; for (let o = 0; o < e.length; ++o) { if (a != null) { if (a[i] === o && e[o] !== 1) throw new Error(`Can't squeeze axis ${o} since its dim '${e[o]}' is not 1`); (a[i] == null || a[i] > o) && e[o] === 1 && (n.push(e[o]), s.push(o)), a[i] <= o && i++; } e[o] !== 1 && (n.push(e[o]), s.push(o)); } return { newShape: n, keptDims: s }; } function bw(e, t) { let n = null; if (e == null || e === "float32") n = new Float32Array(t); else if (e === "int32") n = new Int32Array(t); else if (e === "bool") n = new Uint8Array(t); else throw new Error(`Unknown data type ${e}`); return n; } function yw(e, t) { let n = null; if (e == null || e === "float32") n = new Float32Array(t); else if (e === "int32") n = new Int32Array(t); else if (e === "bool") n = new Uint8Array(t); else if (e === "string") n = new Array(t); else throw new Error(`Unknown data type ${e}`); return n; } function vw(e, t) { for (let n = 0; n < e.length; n++) { let s = e[n]; if (isNaN(s) || !isFinite(s)) throw Error(`A tensor of type ${t} being uploaded contains ${s}.`); } } function xw(e) { return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string"; } function HT(e, t) { return !(t === "complex64" || t === "float32" && e !== "complex64" || t === "int32" && e !== "float32" && e !== "complex64" || t === "bool" && e === "bool"); } function Zt(e) { return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray; } function Of(e) { if (e === "float32" || e === "int32") return 4; if (e === "complex64") return 8; if (e === "bool") return 1; throw new Error(`Unknown dtype ${e}`); } function ww(e) { if (e == null) return 0; let t = 0; return e.forEach((n) => t += n.length), t; } function lr(e) { return typeof e == "string" || e instanceof String; } function kw(e) { return typeof e == "boolean"; } function Iw(e) { return typeof e == "number"; } function Pd(e) { return Array.isArray(e) ? Pd(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : Iw(e) ? "float32" : lr(e) ? "string" : kw(e) ? "bool" : "float32"; } function gr(e) { return !!(e && e.constructor && e.call && e.apply); } function ad(e, t) { for (let n = t; n < e; ++n) if (e % n === 0) return n; return e; } function no(e) { let t = e.length; if (t < 2) return []; let n = new Array(t - 1); n[t - 2] = e[t - 1]; for (let s = t - 3; s >= 0; --s) n[s] = n[s + 1] * e[s + 1]; return n; } function Sw(e, t, n, s = false) { let r = new Array(); if (t.length === 1) { let a = t[0] * (s ? 2 : 1); for (let i = 0; i < a; i++) r[i] = n[e + i]; } else { let a = t[0], i = t.slice(1), o = i.reduce((u, c) => u * c) * (s ? 2 : 1); for (let u = 0; u < a; u++) r[u] = Sw(e + u * o, i, n, s); } return r; } function Wi(e, t, n = false) { if (e.length === 0) return t[0]; let s = e.reduce((r, a) => r * a) * (n ? 2 : 1); if (s === 0) return []; if (s !== t.length) throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`); return Sw(0, e, t, n); } function Vm(e, t) { let n = zd(e, t); for (let s = 0; s < n.length; s++) n[s] = 1; return n; } function zd(e, t) { if (t == null || t === "float32" || t === "complex64") return new Float32Array(e); if (t === "int32") return new Int32Array(e); if (t === "bool") return new Uint8Array(e); throw new Error(`Unknown data type ${t}`); } function qT(e, t) { let n = e.reduce((s, r) => s * r, 1); if (t == null || t === "float32") return Wi(e, new Float32Array(n)); if (t === "int32") return Wi(e, new Int32Array(n)); if (t === "bool") return Wi(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`); } function Wm(e) { e.forEach((t) => { O(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`); }); } function jT(e, t, n) { if (t === 0) return 0; if (t === 1) return e[0]; let s = e[e.length - 1]; for (let r = 0; r < e.length - 1; ++r) s += n[r] * e[r]; return s; } function KT(e, t, n) { if (t === 0) return []; if (t === 1) return [e]; let s = new Array(t); for (let r = 0; r < s.length - 1; ++r) s[r] = Math.floor(e / n[r]), e -= s[r] * n[r]; return s[s.length - 1] = e, s; } function Um(e) { return e && e.then && typeof e.then == "function"; } var _v = "tfjsflags"; var XT = class { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = YT, this.populateURLFlags(); } setPlatform(e, t) { this.platform != null && (X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t; } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, this.urlFlags[e] != null) { let s = this.urlFlags[e]; X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${s}.`), this.set(e, s); } } 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 (Um(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); _v in e && e[_v].split(",").forEach((n) => { let [s, r] = n.split(":"); this.urlFlags[s] = ZT(s, r); }); } }; function YT(e) { let t = {}; return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (QT(t, s[0], s[1]), s.join("="))), t; } function QT(e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || ""); } function ZT(e, t) { if (t = t.toLowerCase(), t === "true" || t === "false") return t === "true"; if (`${+t}` === t) return +t; throw new Error(`Could not parse value flag value ${t} for flag ${e}.`); } function X() { return Cw; } var Cw = null; function JT(e) { Cw = e; } var vf; function Nw() { if (vf == null) { let e; if (typeof window != "undefined") e = window; else if (typeof global != "undefined") e = global; else if (typeof process != "undefined") e = process; else if (typeof self != "undefined") e = self; else throw new Error("Could not find a global object"); vf = e; } return vf; } function e$() { let e = Nw(); return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals; } function Gm(e, t) { let n = e$(); if (n.has(e)) return n.get(e); { let s = t(); return n.set(e, s), n.get(e); } } var so = "Abs"; var nl = "Acos"; var sl = "Acosh"; var Cr = "Add"; var wa = "AddN"; var rl = "All"; var al = "Any"; var ka = "ArgMax"; var il = "ArgMin"; var ol = "Asin"; var ul = "Asinh"; var ll = "Atan"; var cl = "Atanh"; var dl = "Atan2"; var Ia = "AvgPool"; var Hm = "AvgPoolGrad"; var Md = "AvgPool3D"; var qm = "AvgPool3DGrad"; var Sa = "BatchMatMul"; var ro = "BatchToSpaceND"; var jm = "Bincount"; var t$ = "BroadcastTo"; var Km = "BroadcastArgs"; var Ca = "Cast"; var Na = "Ceil"; var Nr = "ClipByValue"; var Ld = "Complex"; var Bd = "ComplexAbs"; var ao = "Concat"; var Ta = "Conv2D"; var Xm = "Conv2DBackpropFilter"; var $a = "Conv2DBackpropInput"; var Vd = "Conv3D"; var Ym = "Conv3DBackpropFilterV2"; var Qm = "Conv3DBackpropInputV2"; var Aa = "Cos"; var Ea = "Cosh"; var io = "Cumsum"; var oo = "CropAndResize"; var Zm = "DenseBincount"; var uo = "DepthToSpace"; var _a = "DepthwiseConv2dNative"; var Jm = "DepthwiseConv2dNativeBackpropFilter"; var eg = "DepthwiseConv2dNativeBackpropInput"; var tg = "Diag"; var Wd = "Dilation2D"; var Pf = "Dilation2DBackpropInput"; var zf = "Dilation2DBackpropFilter"; var Ra = "RealDiv"; var Ud = "Einsum"; var Da = "Elu"; var ng = "EluGrad"; var pl = "Erf"; var lo = "Equal"; var Fa = "Exp"; var co = "ExpandDims"; var po = "Expm1"; var sg = "FFT"; var hl = "Fill"; var ho = "FlipLeftRight"; var Oa = "Floor"; var Pa = "FloorDiv"; var za = "FusedBatchNorm"; var fo = "GatherV2"; var mo = "GatherNd"; var go = "Greater"; var Ma = "GreaterEqual"; var La = "Identity"; var rg = "IFFT"; var Gd = "Imag"; var fl = "IsFinite"; var ml = "IsInf"; var gl = "IsNan"; var Ba = "LeakyRelu"; var bo = "Less"; var yo = "LessEqual"; var ag = "LinSpace"; var Va = "Log"; var bl = "Log1p"; var vo = "LogicalAnd"; var yl = "LogicalNot"; var Hd = "LogicalOr"; var n$ = "LogSoftmax"; var qd = "LRN"; var ig = "LRNGrad"; var Wa = "Max"; var Ua = "Maximum"; var Ga = "MaxPool"; var og = "MaxPoolGrad"; var jd = "MaxPool3D"; var ug = "MaxPool3DGrad"; var lg = "MaxPoolWithArgmax"; var Ha = "Mean"; var qa = "Min"; var ja = "Minimum"; var Ka = "MirrorPad"; var vl = "Mod"; var cg = "Multinomial"; var Xa = "Multiply"; var xo = "Neg"; var wo = "NotEqual"; var ko = "NonMaxSuppressionV3"; var xl = "NonMaxSuppressionV4"; var Io = "NonMaxSuppressionV5"; var So = "OnesLike"; var Co = "OneHot"; var No = "Pack"; var Ya = "PadV2"; var qce = "Pool"; var Qa = "Pow"; var Za = "Prelu"; var To = "Prod"; var wl = "Range"; var Kd = "Real"; var kl = "Reciprocal"; var Ja = "Relu"; var $o = "Reshape"; var Il = "ResizeNearestNeighbor"; var dg = "ResizeNearestNeighborGrad"; var ei = "ResizeBilinear"; var pg = "ResizeBilinearGrad"; var ti = "Relu6"; var Ao = "Reverse"; var Eo = "Round"; var ni = "Rsqrt"; var _o = "ScatterNd"; var Ro = "Select"; var Sl = "Selu"; var Do = "Slice"; var si = "Sin"; var Fo = "Sinh"; var Cl = "Sign"; var ri = "Sigmoid"; var Nl = "Softplus"; var ai = "Sqrt"; var ii = "Sum"; var Oo = "SpaceToBatchND"; var Po = "SplitV"; var oi = "Softmax"; var Xd = "SparseFillEmptyRows"; var Tl = "SparseReshape"; var Yd = "SparseSegmentMean"; var Qd = "SparseSegmentSum"; var Zd = "SparseToDense"; var ui = "SquaredDifference"; var $l = "Square"; var zo = "StridedSlice"; var Jd = "StringNGrams"; var hg = "StringSplit"; var fg = "StringToHashBucketFast"; var li = "Sub"; var Mo = "Tan"; var ci = "Tanh"; var Tr = "Tile"; var Lo = "TopK"; var Bo = "Transform"; var di = "Transpose"; var mg = "Unique"; var Vo = "Unpack"; var ep = "UnsortedSegmentSum"; var Wo = "ZerosLike"; var pi = "Step"; var id = "FromPixels"; var Uo = "RotateWithOffset"; var sa = "_FusedMatMul"; var ra = "FusedConv2D"; var aa = "FusedDepthwiseConv2D"; function ur(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(...e); } function s$(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.log(...e); } var Ki = Gm("kernelRegistry", () => /* @__PURE__ */ new Map()); var Vu = Gm("gradRegistry", () => /* @__PURE__ */ new Map()); function Mf(e, t) { let n = gg(e, t); return Ki.get(n); } function Rv(e) { return Vu.get(e); } function Lf(e) { let t = Ki.entries(), n = []; for (; ; ) { let { done: s, value: r } = t.next(); if (s) break; let [a, i] = r, [o] = a.split("_"); o === e && n.push(i); } return n; } function Al(e) { let { kernelName: t, backendName: n } = e, s = gg(t, n); Ki.has(s) && ur(`The kernel '${t}' for backend '${n}' is already registered`), Ki.set(s, e); } function r$(e) { let { kernelName: t } = e; Vu.has(t) && X().getBool("DEBUG") && ur(`Overriding the gradient for '${t}'`), Vu.set(t, e); } function jce(e, t) { let n = gg(e, t); if (!Ki.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); Ki.delete(n); } function Kce(e) { if (!Vu.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); Vu.delete(e); } function Xce(e, t) { Lf(e).forEach((s) => { let r = Object.assign({}, s, { backendName: t }); Al(r); }); } function gg(e, t) { return `${t}_${e}`; } var w = {}; Ae(w, { arraysEqual: () => Sr, assert: () => O, assertNonNegativeIntegerDimensions: () => Wm, assertNonNull: () => xa, assertShapesMatch: () => on, bytesFromStringArray: () => ww, bytesPerElement: () => Of, checkConversionForErrors: () => vw, clamp: () => Bu, computeStrides: () => no, createScalarValue: () => c$, createShuffledIndices: () => WT, decodeString: () => od, distSquared: () => MT, encodeString: () => _l, fetch: () => p$, fingerPrint64: () => l$, flatten: () => na, getArrayFromDType: () => yw, getTypedArrayFromDType: () => bw, hasEncodingLoss: () => HT, hexToLong: () => El, indexToLoc: () => KT, inferDtype: () => Pd, inferFromImplicitShape: () => GT, isBoolean: () => kw, isFunction: () => gr, isInt: () => ji, isNumber: () => Iw, isPromise: () => Um, isScalarShape: () => LT, isString: () => lr, isTypedArray: () => Zt, isValidDtype: () => xw, locToIndex: () => jT, makeOnesTypedArray: () => Vm, makeZerosNestedTypedArray: () => qT, makeZerosTypedArray: () => zd, nearestDivisor: () => ad, nearestLargerEven: () => OT, now: () => Wu, parseAxisParam: () => ss, randUniform: () => zT, repeatedTry: () => UT, rightPad: () => Pu, shuffle: () => mw, shuffleCombo: () => FT, sizeFromShape: () => pt, sizeToSquarishShape: () => VT, squeezeShape: () => gw, sum: () => PT, swap: () => rd, tanh: () => BT, toNestedArray: () => Wi, toTypedArray: () => tp }); var Dv = va(gT()); var Hr = Dv.default || Dv; function El(e) { return Hr.fromString(e, true, 16); } var Tw = El("c3a5c85c97cb3127"); var Gr = El("b492b66fbe98f273"); var tn = El("9ae16a3b2f90404f"); function Bf(e) { return e.xor(e.shru(47)); } function $w(e, t, n) { let s = e.slice(t, t + n); return Hr.fromBytes(Array.from(s), true, true); } function lt(e, t) { return $w(e, t, 8); } function Fv(e, t) { return $w(e, t, 4); } function Lt(e, t) { return t === 0 ? e : e.shru(t).or(e.shl(64 - t)); } function dr(e, t, n = El("9ddfea08eb382d69")) { let s = e.xor(t).mul(n); s = s.xor(s.shru(47)); let r = t.xor(s).mul(n); return r = r.xor(r.shru(47)), r = r.mul(n), r; } function a$(e, t, n, s, r, a) { r = r.add(e), a = Lt(a.add(r).add(s), 21); let i = r; return r = r.add(t), r = r.add(n), a = a.add(Lt(r, 44)), [r.add(s), a.add(i)]; } function Dc(e, t, n, s) { return a$(lt(e, t), lt(e, t + 8), lt(e, t + 16), lt(e, t + 24), n, s); } function i$(e, t = e.length) { if (t >= 8) { let n = tn.add(t * 2), s = lt(e, 0).add(tn), r = lt(e, t - 8), a = Lt(r, 37).mul(n).add(s), i = Lt(s, 25).add(r).mul(n); return dr(a, i, n); } if (t >= 4) { let n = tn.add(t * 2), s = Fv(e, 0); return dr(s.shl(3).add(t), Fv(e, t - 4), n); } if (t > 0) { let n = e[0], s = e[t >> 1], r = e[t - 1], a = n + (s << 8), i = t + (r << 2); return Bf(tn.mul(a).xor(Tw.mul(i))).mul(tn); } return tn; } function o$(e, t = e.length) { let n = tn.add(t * 2), s = lt(e, 0).mul(Gr), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(tn); return dr(Lt(s.add(r), 43).add(Lt(a, 30)).add(i), s.add(Lt(r.add(tn), 18)).add(a), n); } function u$(e, t = e.length) { let n = tn.add(t * 2), s = lt(e, 0).mul(tn), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(tn), o = Lt(s.add(r), 43).add(Lt(a, 30)).add(i), u = dr(o, s.add(Lt(r.add(tn), 18)).add(a), n), c = lt(e, 16).mul(n), l = lt(e, 24), d = o.add(lt(e, t - 32)).mul(n), p = u.add(lt(e, t - 24)).mul(n); return dr(Lt(c.add(l), 43).add(Lt(d, 30)).add(p), c.add(Lt(l.add(s), 18)).add(d), n); } function l$(e, t = e.length) { let n = Hr.fromNumber(81, true); if (t <= 32) return t <= 16 ? i$(e, t) : o$(e, t); if (t <= 64) return u$(e, t); let s = n, r = n.mul(Gr).add(113), a = Bf(r.mul(tn).add(113)).mul(tn), i = [Hr.UZERO, Hr.UZERO], o = [Hr.UZERO, Hr.UZERO]; s = s.mul(tn).add(lt(e, 0)); let u = 0, c = (t - 1 >> 6) * 64, l = c + (t - 1 & 63) - 63; do s = Lt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(Gr), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(Gr), s = s.xor(o[1]), r = r.add(i[0]).add(lt(e, u + 40)), a = Lt(a.add(o[0]), 33).mul(Gr), i = Dc(e, u, i[1].mul(Gr), s.add(o[0])), o = Dc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], u += 64; while (u !== c); let d = Gr.add(a.and(255).shl(1)); return u = l, o[0] = o[0].add(t - 1 & 63), i[0] = i[0].add(o[0]), o[0] = o[0].add(i[0]), s = Lt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(d), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(d), s = s.xor(o[1].mul(9)), r = r.add(i[0].mul(9).add(lt(e, u + 40))), a = Lt(a.add(o[0]), 33).mul(d), i = Dc(e, u, i[1].mul(d), s.add(o[0])), o = Dc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], dr(dr(i[0], o[0], d).add(Bf(r).mul(Tw)).add(a), dr(i[1], o[1], d).add(s), d); } function c$(e, t) { return t === "string" ? _l(e) : tp([e], t); } function d$(e, t) { return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool"; } function tp(e, t) { if (t === "string") throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(e) && (e = na(e)), X().getBool("DEBUG") && vw(e, t), d$(e, t)) return e; if (t == null || t === "float32" || t === "complex64") return new Float32Array(e); if (t === "int32") return new Int32Array(e); if (t === "bool") { let n = new Uint8Array(e.length); for (let s = 0; s < n.length; ++s) Math.round(e[s]) !== 0 && (n[s] = 1); return n; } else throw new Error(`Unknown data type ${t}`); } function Wu() { return X().platform.now(); } function p$(e, t) { return X().platform.fetch(e, t); } function _l(e, t = "utf-8") { return t = t || "utf-8", X().platform.encode(e, t); } function od(e, t = "utf-8") { return t = t || "utf-8", X().platform.decode(e, t); } var h$ = class { constructor(e, t) { this.backendTimer = e, this.logger = t, t == null && (this.logger = new m$()); } profileKernel(e, t, n) { let s, r = () => { s = n(); }, a, i = Wu(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(r); else { r(); for (let u of s) u.dataSync(); a = Promise.resolve({ kernelMs: Wu() - i }); } if (X().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < s.length; u++) { let c = s[u]; c.data().then((l) => { f$(l, c.dtype, e); }); } return { kernelName: e, outputs: s, 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: s, inputs: r, extraInfo: a } = e; n.forEach((i) => { Promise.all([i.data(), s, a]).then((o) => { this.logger.logKernelProfile(t, i, o[0], o[1], r, o[2]); }); }); } }; function f$(e, t, n) { if (t !== "float32") return false; for (let s = 0; s < e.length; s++) { let r = e[s]; if (isNaN(r) || !isFinite(r)) return console.warn(`Found ${r} in the result of '${n}'`), true; } return false; } var m$ = class { logKernelProfile(e, t, n, s, r, a) { let i = typeof s == "number" ? Pu(`${s}ms`, 9) : s.error, o = Pu(e, 25), u = t.rank, c = t.size, l = Pu(t.shape.toString(), 14), d = ""; for (let p in r) { let h = r[p]; if (h != null) { let f = h.shape || t.shape, m = f.length; d += `${p}: ${m}D ${m > 0 ? f : ""} `; } } console.log(`%c${o} %c${i} %c${u}D ${l} %c${c} %c${d} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; function g$(e, t, n) { let s = {}, r = {}; for (let u = 0; u < t.length; u++) s[t[u].id] = true; for (let u = 0; u < e.length; u++) { let c = e[u], l = c.inputs; for (let d in l) { let p = l[d], h = false; for (let f = 0; f < t.length; f++) if (s[p.id]) { c.outputs.forEach((m) => s[m.id] = true), h = true, r[c.id] = true; break; } if (h) break; } } let a = {}; a[n.id] = true; let i = {}; for (let u = e.length - 1; u >= 0; u--) { let c = e[u], l = c.inputs; for (let d = 0; d < c.outputs.length; d++) if (a[c.outputs[d].id]) { for (let p in l) a[l[p].id] = true, i[c.id] = true; break; } } let o = []; for (let u = 0; u < e.length; u++) { let c = e[u]; if (r[c.id] && i[c.id]) { let l = {}; for (let p in c.inputs) { let h = c.inputs[p]; s[h.id] && (l[p] = h); } let d = Object.assign({}, c); d.inputs = l, d.outputs = c.outputs, o.push(d); } } return o; } function b$(e, t, n, s) { for (let r = t.length - 1; r >= 0; r--) { let a = t[r], i = []; if (a.outputs.forEach((u) => { let c = e[u.id]; c != null ? i.push(c) : i.push(null); }), a.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`); let o = a.gradient(i); for (let u in a.inputs) { if (!(u in o)) throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(o)}.`); let c = n(() => o[u]()); if (c.dtype !== "float32") throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${c.dtype}'`); let l = a.inputs[u]; if (!Sr(c.shape, l.shape)) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${c.shape}', which does not match the shape of the input '${l.shape}'`); if (e[l.id] == null) e[l.id] = c; else { let d = e[l.id]; e[l.id] = s(d, c), d.dispose(); } } } } var Ov = 20; var ku = 3; var xf = 7; function y$(e, t, n, s) { let r = no(t), a = v$(e, t, n, r), i = t.length, o = qc(e, t, n, r, a), u = ["Tensor"]; return s && (u.push(` dtype: ${n}`), u.push(` rank: ${i}`), u.push(` shape: [${t}]`), u.push(" values:")), u.push(o.map((c) => " " + c).join(` `)), u.join(` `); } function v$(e, t, n, s) { let r = pt(t), a = s[s.length - 1], i = new Array(a).fill(0), o = t.length, u = n === "complex64" ? Tu(e) : e; if (o > 1) for (let c = 0; c < r / a; c++) { let l = c * a; for (let d = 0; d < a; d++) i[d] = Math.max(i[d], Nu(u[l + d], 0, n).length); } return i; } function Nu(e, t, n) { let s; return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(xf))} + ${parseFloat(e[1].toFixed(xf))}j` : lr(e) ? s = `'${e}'` : n === "bool" ? s = Aw(e) : s = parseFloat(e.toFixed(xf)).toString(), Pu(s, t); } function Aw(e) { return e === 0 ? "false" : "true"; } function qc(e, t, n, s, r, a = true) { let i = n === "complex64" ? 2 : 1, o = t[0], u = t.length; if (u === 0) { if (n === "complex64") { let m = Tu(e); return [Nu(m[0], 0, n)]; } return n === "bool" ? [Aw(e[0])] : [e[0].toString()]; } if (u === 1) { if (o > Ov) { let g = ku * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - ku) * i, o * i)); return n === "complex64" && (b = Tu(b), y = Tu(y)), ["[" + b.map((v, x) => Nu(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => Nu(v, r[o - ku + x], n)).join(", ") + "]"]; } let m = n === "complex64" ? Tu(e) : Array.from(e); return ["[" + m.map((g, b) => Nu(g, r[b], n)).join(", ") + "]"]; } let c = t.slice(1), l = s.slice(1), d = s[0] * i, p = []; if (o > Ov) { for (let m = 0; m < ku; m++) { let g = m * d, b = g + d; p.push(...qc(e.slice(g, b), c, n, l, r, false)); } p.push("..."); for (let m = o - ku; m < o; m++) { let g = m * d, b = g + d; p.push(...qc(e.slice(g, b), c, n, l, r, m === o - 1)); } } else for (let m = 0; m < o; m++) { let g = m * d, b = g + d; p.push(...qc(e.slice(g, b), c, n, l, r, m === o - 1)); } let h = u === 2 ? "," : ""; p[0] = "[" + p[0] + h; for (let m = 1; m < p.length - 1; m++) p[m] = " " + p[m] + h; let f = `, `; for (let m = 2; m < u; m++) f += ` `; return p[p.length - 1] = " " + p[p.length - 1] + "]" + (a ? "" : f), p; } function Tu(e) { let t = []; for (let n = 0; n < e.length; n += 2) t.push([e[n], e[n + 1]]); return t; } var Vt = class { constructor(e, t, n) { if (this.dtype = t, this.shape = e.slice(), this.size = pt(e), n != null) { let s = n.length; O(s === this.size, () => `Length of values '${s}' 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 || yw(t, this.size), this.strides = no(e); } set(e, ...t) { t.length === 0 && (t = [0]), O(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 s of e) { if (s < 0 || s >= this.shape[t]) { let r = `Requested out of range element at ${e}. Buffer shape=${this.shape}`; throw new Error(r); } t++; } let n = e[e.length - 1]; for (let s = 0; s < e.length - 1; ++s) n += this.strides[s] * e[s]; 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 is().makeTensor(this.values, this.shape, this.dtype); } }; var is = null; var Mi = null; var x$ = null; function w$(e) { is = e; } function k$(e) { Mi = e; } function I$(e) { x$ = e; } var tt = class { constructor(e, t, n, s) { this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t || "float32", this.size = pt(e), this.strides = no(e), this.dataId = n, this.id = s, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; } get rank() { return this.shape.length; } async buffer() { let e = await this.data(); return Mi.buffer(this.shape, this.dtype, e); } bufferSync() { return Mi.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); return Wi(this.shape, e, this.dtype === "complex64"); } arraySync() { return Wi(this.shape, this.dataSync(), this.dtype === "complex64"); } async data() { this.throwIfDisposed(); let e = is().read(this.dataId); if (this.dtype === "string") { let t = await e; try { return t.map((n) => od(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; } dataToGPU(e) { return this.throwIfDisposed(), is().readToGPU(this.dataId, e); } dataSync() { this.throwIfDisposed(); let e = is().readSync(this.dataId); if (this.dtype === "string") try { return e.map((t) => od(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 is().read(this.dataId); return this.dtype === "string" ? e : new Uint8Array(e.buffer); } dispose() { this.isDisposed || (is().disposeTensor(this), this.isDisposedInternal = true); } get isDisposed() { return this.isDisposedInternal; } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed."); } print(e = false) { return Mi.print(this, e); } clone() { return this.throwIfDisposed(), Mi.clone(this); } toString(e = false) { let t = this.dataSync(); return y$(t, this.shape, this.dtype, e); } cast(e) { return this.throwIfDisposed(), Mi.cast(this, e); } variable(e = true, t, n) { return this.throwIfDisposed(), is().makeVariable(this, e, t, n); } }; Object.defineProperty(tt, Symbol.hasInstance, { value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null }); function S$() { return Gm("Tensor", () => tt); } S$(); var ud = class extends tt { constructor(e, t, n, s) { super(e.shape, e.dtype, e.dataId, s); 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 (!Sr(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); is().disposeTensor(this), this.dataId = e.dataId, is().incRef(this, null); } dispose() { is().disposeVariable(this), this.isDisposedInternal = true; } }; Object.defineProperty(ud, Symbol.hasInstance, { value: (e) => e instanceof tt && e.assign != null && e.assign instanceof Function }); var Ts = {}; Ae(Ts, { assertTypesMatch: () => Fw, getTensorsInContainer: () => bg, isTensorInList: () => T$, makeTypesMatch: () => vt }); var C$ = ((e) => (e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6", e))(C$ || {}); var Ew = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64", e))(Ew || {}); var _w = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64", e))(_w || {}); var Rw = ((e) => (e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64", e))(Rw || {}); var Dw = ((e) => (e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64", e))(Dw || {}); var N$ = { float32: Rw, int32: Ew, bool: _w, complex64: Dw }; function vn(e, t) { if (e === "string" || t === "string") { if (e === "string" && t === "string") return "string"; throw new Error(`Can not upcast ${e} with ${t}`); } return N$[e][t]; } function np(e) { return vn(e, "int32"); } function vt(e, t) { if (e.dtype === t.dtype) return [e, t]; let n = vn(e.dtype, t.dtype); return [e.cast(n), t.cast(n)]; } function Fw(e, t) { O(e.dtype === t.dtype, () => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`); } function T$(e, t) { return t.some((n) => n.id === e.id); } function bg(e) { let t = []; return Ow(e, t, /* @__PURE__ */ new Set()), t; } function Ow(e, t, n) { if (e == null) return; if (e instanceof tt) { t.push(e); return; } if (!$$(e)) return; let s = e; for (let r in s) { let a = s[r]; n.has(a) || (n.add(a), Ow(a, t, n)); } } function $$(e) { return Array.isArray(e) || typeof e == "object"; } function wf(e) { return e.kernelName != null; } var Pv = 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 = /* @__PURE__ */ 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 Vf = class { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new Pv(); } 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 ? (ur(`${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 h$(this.backendInstance), true; } setupRegisteredKernels() { Lf(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { Lf(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 tl) && typeof n.then == "function") { let s = ++this.pendingBackendInitId, r = n.then((a) => s < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (s < this.pendingBackendInitId || (this.pendingBackendInit = null, ur(`Initialization of backend ${e} failed`), ur(a.stack || a.message)), false)); return this.pendingBackendInit = r, { success: r, asyncInit: true }; } else return this.registry[e] = n, { success: true, asyncInit: false }; } catch (n) { return ur(`Initialization of backend ${e} failed`), ur(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: s, asyncInit: r } = this.initializeBackend(n); if (r || s) return { name: n, asyncInit: r }; } throw new Error("Could not initialize any backends, all backend initializations failed."); } moveData(e, t) { let n = this.state.tensorInfo.get(t), s = n.backend, r = this.readSync(t), a = s.refCount(t); s.disposeData(t, true), n.backend = e, e.move(t, r, 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 s; return this.scopedRun(() => this.startScope(n), () => this.endScope(s), () => (s = t(), s instanceof Promise && console.error("Cannot return a Promise inside of tidy."), s)); } scopedRun(e, t, n) { e(); try { let s = n(); return t(), s; } catch (s) { throw t(), s; } } nextTensorId() { return Vf.nextTensorId++; } nextVariableId() { return Vf.nextVariableId++; } clone(e) { let t = L.runKernel(La, { x: e }), n = { x: e }, s = (a) => ({ x: () => { let i = "float32", o = { x: a }, u = { dtype: i }; return L.runKernel(Ca, o, u); } }), r = []; return this.addTapeNode(this.state.activeScope.name, n, [t], s, r, {}), t; } runKernel(e, t, n) { if (this.backendName == null && this.backend, !(Mf(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 s = this.backend.numDataIds(), r = 0; n.forEach((o) => { r += o.dtype === "complex64" ? 3 : 1; }); let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = s - t - r - 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 = [], s = this.isTapeOn(), r = this.state.numBytes, a = this.state.numTensors; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0); let i; this.backendName == null && this.backend; let o, u = wf(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; if (wf(e)) { let { kernelName: h, inputs: f, attrs: m } = e; this.backendName == null && this.backend; let g = Mf(h, this.backendName); O(g != null, () => `Cannot find registered kernel '${h}' for backend '${this.backendName}'`), i = () => { let b = this.backend.numDataIds(); o = g.kernelFunc({ inputs: f, attrs: m, backend: this.backend }); let y = Array.isArray(o) ? o : [o]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(h, b, y); let v = y.map((x) => { if (x.rank != null) return x; let { dataId: k, shape: T, dtype: C } = x; return this.makeTensorFromDataId(k, T, C); }); if (s) { let x = this.getTensorsForGradient(h, f, v); n = this.saveTensorsForBackwardMode(x); } return v; }; } else { let { forwardFunc: h } = e, f = (m) => { !s || (n = m.map((g) => this.keep(this.clone(g)))); }; i = () => { let m = this.backend.numDataIds(); o = this.tidy(() => h(this.backend, f)); let g = Array.isArray(o) ? o : [o]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, m, g), g; }; } let { inputs: c, attrs: l } = e, d = wf(e) ? null : e.backwardsFunc, p; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = i() : (p = this.profiler.profileKernel(u, c, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(p), t = p.outputs); }), s && this.addTapeNode(u, c, t, d, n, l), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - r, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(c).map((h) => c[h] != null ? c[h].shape : null), outputShapes: t.map((h) => h.shape), kernelTimeMs: p.timeMs, extraInfo: p.extraInfo }), Array.isArray(o) ? t : t[0]; } saveTensorsForBackwardMode(e) { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { let s = Rv(e); if (s != null) { let r = s.inputsToSave || [], a = s.outputsToSave || [], i; s.saveAllInputs ? (O(Array.isArray(t), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t).map((u) => t[u])) : i = r.map((u) => t[u]); let o = n.filter((u, c) => a[c]); return i.concat(o); } return []; } makeTensor(e, t, n, s) { if (e == null) throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", s = s || this.backend; let r = e; n === "string" && lr(e[0]) && (r = e.map((o) => _l(o))); let a = s.write(r, t, n), i = new tt(t, n, a, this.nextTensorId()); if (this.trackTensor(i, s), n === "string") { let o = this.state.tensorInfo.get(a), u = ww(r); this.state.numBytes += u - o.bytes, o.bytes = u; } return i; } makeTensorFromDataId(e, t, n, s) { n = n || "float32"; let r = new tt(t, n, e, this.nextTensorId()); return this.trackTensor(r, s), r; } makeVariable(e, t = true, n, s) { n = n || this.nextVariableId().toString(), s != null && s !== e.dtype && (e = e.cast(s)); let r = new ud(e, t, n, this.nextTensorId()); if (this.state.registeredVariables[r.name] != null) throw new Error(`Variable with name ${r.name} was already registered`); return this.state.registeredVariables[r.name] = r, this.incRef(r, this.backend), r; } trackTensor(e, t) { this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++; let n = 0; e.dtype !== "complex64" && e.dtype !== "string" && (n = e.size * Of(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 ud || 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 * Of(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((s) => s.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - t, this.state.activeProfile.newTensors = this.state.numTensors - n; for (let s of this.state.activeProfile.kernels) s.kernelTimeMs = await s.kernelTimeMs, s.extraInfo = await s.extraInfo; return this.state.activeProfile; } isTapeOn() { return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; } addTapeNode(e, t, n, s, r, a) { let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: r }, o = Rv(e); o != null && (s = o.gradFunc), s != null && (i.gradient = (u) => (u = u.map((c, l) => { if (c == null) { let d = n[l], p = zd(d.size, d.dtype); return this.makeTensor(p, d.shape, d.dtype); } return c; }), s(u.length > 1 ? u : u[0], r, 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 = bg(e), n = new Set(t.map((r) => r.id)); for (let r = 0; r < this.state.activeScope.track.length; r++) { let a = this.state.activeScope.track[r]; !a.kept && !n.has(a.id) && a.dispose(); } let s = this.state.scopeStack.pop(); this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t.forEach((r) => { !r.kept && r.scopeId === s.id && this.track(r); }); } gradients(e, t, n, s = false) { if (O(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 r = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", e)); O(r instanceof tt, () => "The result y returned by f() must be a tensor."); let a = g$(this.state.activeTape, t, r); if (!s && 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[r.id] = n == null ? A$(r.shape) : n, b$(i, a, (u) => this.tidy(u), E$); let o = 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: r, grads: o }; }); } customGrad(e) { return O(gr(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { O(t.every((i) => i instanceof tt), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors"); let n, s = {}; t.forEach((i, o) => { s[o] = i; }); let r = (i, o) => (n = e(...t, o), O(n.value instanceof tt, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), O(gr(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (i, o) => { let u = n.gradFunc(i, o), c = Array.isArray(u) ? u : [u]; O(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(...)."), O(c.every((d) => d instanceof tt), () => "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 l = {}; return c.forEach((d, p) => { l[p] = () => d; }), l; }; return this.runKernelFunc({ forwardFunc: r, backwardsFunc: a, inputs: s }); }; } readSync(e) { return this.state.tensorInfo.get(e).backend.readSync(e); } read(e) { return this.state.tensorInfo.get(e).backend.read(e); } readToGPU(e, t) { return this.state.tensorInfo.get(e).backend.readToGPU(e, t); } async time(e) { let t = Wu(), n = await this.backend.time(e); return n.wallMs = Wu() - 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 Pv(); 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; } }; var yg = Vf; yg.nextTensorId = 0; yg.nextVariableId = 0; function A$(e) { let t = Vm(pt(e), "float32"); return L.makeTensor(t, e, "float32"); } function Pw() { let e = Nw(); if (e._tfengine == null) { let t = new XT(e); e._tfengine = new yg(t); } return JT(e._tfengine.ENV), w$(() => e._tfengine), e._tfengine; } var L = Pw(); function E$(e, t) { let n = { a: e, b: t }; return L.runKernel(Cr, n); } var Rl = {}; Ae(Rl, { isBrowser: () => zw, isMobile: () => D$, mockIsMobile: () => R$ }); function _$() { return typeof navigator != "undefined" && navigator != null; } var Wf; function R$(e) { Wf = e; } function D$(e) { if (Wf !== void 0) return Wf; if (e || _$()) { if (e || (e = navigator), e.product === "ReactNative") return true; let t = e.userAgent || e.vendor || (typeof window != "undefined" ? window.opera : ""); if (!t) { let n = e; return n.userAgentData && n.userAgentData.mobile; } return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4)); } return false; } function zw() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } var fs = X(); fs.registerFlag("DEBUG", () => false, (e) => { e && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance."); }); fs.registerFlag("IS_BROWSER", () => zw()); fs.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); fs.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); fs.registerFlag("PROD", () => false); fs.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => fs.getBool("DEBUG")); fs.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true); fs.registerFlag("IS_TEST", () => false); fs.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true); fs.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); function Es(e, t) { let n = e; if (Zt(e)) return t === "string" ? [] : [e.length]; if (!Array.isArray(e)) return []; let s = []; for (; Array.isArray(n) || Zt(n) && t !== "string"; ) s.push(n.length), n = n[0]; return Array.isArray(e) && X().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && Mw(e, s, []), s; } function Mw(e, t, n) { if (n = n || [], !Array.isArray(e) && !Zt(e)) { O(t.length === 0, () => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`); return; } O(t.length > 0, () => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`), O(e.length === t[0], () => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`); let s = t.slice(1); for (let r = 0; r < e.length; ++r) Mw(e[r], s, n.concat(r)); } function zv(e, t, n, s) { if (e !== "string_or_numeric") { if (e == null) throw new Error("Expected dtype cannot be null."); if (e !== "numeric" && e !== t || e === "numeric" && t === "string") throw new Error(`Argument '${n}' passed to '${s}' must be ${e} tensor, but got ${t} tensor`); } } function E(e, t, n, s = "numeric") { if (e instanceof tt) return zv(s, e.dtype, t, n), e; let r = Pd(e); if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), zv(s, r, t, n), e == null || !Zt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") { let u = e == null ? "null" : e.constructor.name; throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${u}'`); } let a = Es(e, r); !Zt(e) && !Array.isArray(e) && (e = [e]); let o = r !== "string" ? tp(e, r) : na(e, [], true); return L.makeTensor(o, a, r); } function Uu(e, t, n, s = "numeric") { if (!Array.isArray(e)) throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``); return e.map((a, i) => E(a, `${t}[${i}]`, n, s)); } var F$ = "__op"; function B(e) { let t = Object.keys(e); if (t.length !== 1) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`); let n = t[0], s = e[n]; n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n + F$; let r = (...a) => { L.startScope(n); try { let i = s(...a); return Um(i) && console.error("Cannot return a Promise inside of tidy."), L.endScope(i), i; } catch (i) { throw L.endScope(null), i; } }; return Object.defineProperty(r, "name", { value: n, configurable: true }), r; } function O$(e, t) { let n = E(e, "real", "complex"), s = E(t, "imag", "complex"); on(n.shape, s.shape, `real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`); let r = { real: n, imag: s }; return L.runKernel(Ld, r); } var ia = B({ complex_: O$ }); function $r(e, t, n, s) { if (s == null && (s = Pd(e)), s === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if (!Zt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "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 (t != null) { Wm(t); let r = pt(t), a = pt(n); O(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`); for (let i = 0; i < n.length; ++i) { let o = n[i], u = i === n.length - 1 ? o !== pt(t.slice(i)) : true; O(n[i] === t[i] || !u, () => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `); } } return !Zt(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? tp(e, s) : na(e, [], true), L.makeTensor(e, t, s); } function ds(e, t, n) { let s = Es(e, n); return $r(e, t, s, n); } var Uf = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; var ld = 4; async function P$(e, t) { let n = [], s = [], r = Array.isArray(e) ? e.map((i) => i.name) : Object.keys(e); for (let i = 0; i < r.length; ++i) { let o = r[i], u = Array.isArray(e) ? e[i].tensor : e[o]; if (u.dtype !== "float32" && u.dtype !== "int32" && u.dtype !== "bool" && u.dtype !== "string" && u.dtype !== "complex64") throw new Error(`Unsupported dtype in weight '${o}': ${u.dtype}`); let c = { name: o, shape: u.shape, dtype: u.dtype }; if (u.dtype === "string") { let l = new Promise(async (d) => { let p = await u.bytes(), h = p.reduce((g, b) => g + b.length, 0) + ld * p.length, f = new Uint8Array(h), m = 0; for (let g = 0; g < p.length; g++) { let b = p[g], y = new Uint8Array(new Uint32Array([b.length]).buffer); f.set(y, m), m += ld, f.set(b, m), m += b.length; } d(f); }); s.push(l); } else s.push(u.data()); t != null && (c.group = t), n.push(c); } let a = await Promise.all(s); return { data: z$(a), specs: n }; } function Lw(e, t) { let n = {}, s, r = 0; for (let a of t) { let i = a.name, o = a.dtype, u = a.shape, c = pt(u), l; if ("quantization" in a) { let d = a.quantization; if (d.dtype === "uint8" || d.dtype === "uint16") { if (!("min" in d && "scale" in d)) throw new Error(`Weight ${a.name} with quantization ${d.dtype} doesn't have corresponding metadata min and scale.`); } else if (d.dtype === "float16") { if (o !== "float32") throw new Error(`Weight ${a.name} is quantized with ${d.dtype} which only supports weights of type float32 not ${o}.`); } else throw new Error(`Weight ${a.name} has unknown quantization dtype ${d.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); let p = Uf[d.dtype], h = e.slice(r, r + c * p), f = d.dtype === "uint8" ? new Uint8Array(h) : new Uint16Array(h); if (o === "float32") if (d.dtype === "uint8" || d.dtype === "uint16") { l = new Float32Array(f.length); for (let m = 0; m < f.length; m++) { let g = f[m]; l[m] = g * d.scale + d.min; } } else if (d.dtype === "float16") s === void 0 && (s = U$()), l = s(f); else throw new Error(`Unsupported quantization type ${d.dtype} for weight type float32.`); else if (o === "int32") { if (d.dtype !== "uint8" && d.dtype !== "uint16") throw new Error(`Unsupported quantization type ${d.dtype} for weight type int32.`); l = new Int32Array(f.length); for (let m = 0; m < f.length; m++) { let g = f[m]; l[m] = Math.round(g * d.scale + d.min); } } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += c * p; } else if (o === "string") { let d = pt(a.shape); l = []; for (let p = 0; p < d; p++) { let h = new Uint32Array(e.slice(r, r + ld))[0]; r += ld; let f = new Uint8Array(e.slice(r, r + h)); l.push(f), r += h; } } else { let d = Uf[o], p = e.slice(r, r + c * d); if (o === "float32") l = new Float32Array(p); else if (o === "int32") l = new Int32Array(p); else if (o === "bool") l = new Uint8Array(p); else if (o === "complex64") { l = new Float32Array(p); let h = new Float32Array(l.length / 2), f = new Float32Array(l.length / 2); for (let b = 0; b < h.length; b++) h[b] = l[b * 2], f[b] = l[b * 2 + 1]; let m = ds(h, u, "float32"), g = ds(f, u, "float32"); n[i] = ia(m, g), m.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += c * d; } o !== "complex64" && (n[i] = ds(l, u, o)); } return n; } function z$(e) { if (e === null) throw new Error(`Invalid input value: ${JSON.stringify(e)}`); let t = 0, n = []; e.forEach((a) => { if (t += a.byteLength, n.push(a.byteLength === a.buffer.byteLength ? a : new a.constructor(a)), !(a instanceof Float32Array || a instanceof Int32Array || a instanceof Uint8Array)) throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`); }); let s = new Uint8Array(t), r = 0; return n.forEach((a) => { s.set(new Uint8Array(a.buffer), r), r += a.byteLength; }), s.buffer; } var vg = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); function Mv(e) { return vg ? Buffer.byteLength(e) : new Blob([e]).size; } function M$(e) { if (vg) return Buffer.from(e).toString("base64"); let t = new Uint8Array(e), n = ""; for (let s = 0, r = t.length; s < r; s++) n += String.fromCharCode(t[s]); return btoa(n); } function L$(e) { if (vg) { let s = Buffer.from(e, "base64"); return s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength); } let t = atob(e), n = new Uint8Array(t.length); for (let s = 0; s < t.length; ++s) n.set([t.charCodeAt(s)], s); return n.buffer; } function xg(e) { if (e.length === 1) return e[0]; let t = 0; e.forEach((r) => { t += r.byteLength; }); let n = new Uint8Array(t), s = 0; return e.forEach((r) => { n.set(new Uint8Array(r), s), s += r.byteLength; }), n.buffer; } function Lv(e) { let t = "/"; for (e = e.trim(); e.endsWith(t); ) e = e.slice(0, e.length - 1); let n = e.split(t); return n[n.length - 1]; } function Bw(e, t) { let n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, weightsManifest: t }; return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), n; } async function wg(e, t) { let n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy }; if (e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), e.weightsManifest != null) { let [s, r] = await t(e.weightsManifest); n.weightSpecs = s, n.weightData = r; } return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), n; } function Dl(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer."); return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: e.modelTopology == null ? 0 : Mv(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : Mv(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; } function B$() { let e = (n) => { let s = n << 13, r = 0; for (; (s & 8388608) === 0; ) r -= 8388608, s <<= 1; return s &= -8388609, r += 947912704, s | r; }, t = new Uint32Array(2048); t[0] = 0; for (let n = 1; n < 1024; n++) t[n] = e(n); for (let n = 1024; n < 2048; n++) t[n] = 939524096 + (n - 1024 << 13); return t; } function V$() { let e = new Uint32Array(64); e[0] = 0, e[31] = 1199570944, e[32] = 2147483648, e[63] = 3347054592; for (let t = 1; t < 31; t++) e[t] = t << 23; for (let t = 33; t < 63; t++) e[t] = 2147483648 + (t - 32 << 23); return e; } function W$() { let e = new Uint32Array(64); for (let t = 0; t < 64; t++) e[t] = 1024; return e[0] = e[32] = 0, e; } function U$() { let e = B$(), t = V$(), n = W$(); return (s) => { let r = new ArrayBuffer(4 * s.length), a = new Uint32Array(r); for (let i = 0; i < s.length; i++) { let o = s[i], u = e[n[o >> 10] + (o & 1023)] + t[o >> 10]; a[i] = u; } return new Float32Array(r); }; } var wt = class { constructor() { this.saveRouters = [], this.loadRouters = []; } static getInstance() { return wt.instance == null && (wt.instance = new wt()), wt.instance; } static registerSaveRouter(e) { wt.getInstance().saveRouters.push(e); } static registerLoadRouter(e) { wt.getInstance().loadRouters.push(e); } static getSaveHandlers(e) { return wt.getHandlers(e, "save"); } static getLoadHandlers(e, t) { return wt.getHandlers(e, "load", t); } static getHandlers(e, t, n) { let s = []; return (t === "load" ? wt.getInstance().loadRouters : wt.getInstance().saveRouters).forEach((a) => { let i = a(e, n); i !== null && s.push(i); }), s; } }; var G$ = (e) => wt.registerSaveRouter(e); var H$ = (e) => wt.registerLoadRouter(e); var q$ = (e) => wt.getSaveHandlers(e); var j$ = (e, t) => wt.getLoadHandlers(e, t); var Gf = "tensorflowjs"; var Hf = 1; var Xr = "models_store"; var cr = "model_info_store"; function Vw() { if (!X().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); let e = typeof window == "undefined" ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB; if (t == null) throw new Error("The current browser does not appear to support IndexedDB."); return t; } function qf(e) { let t = e.result; t.createObjectStore(Xr, { keyPath: "modelPath" }), t.createObjectStore(cr, { keyPath: "modelPath" }); } var oa = class { constructor(e) { if (this.indexedDB = Vw(), 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, s) => { let r = this.indexedDB.open(Gf, Hf); r.onupgradeneeded = () => qf(r), r.onsuccess = () => { let a = r.result; if (t == null) { let i = a.transaction(Xr, "readonly"), u = i.objectStore(Xr).get(this.modelPath); u.onsuccess = () => { if (u.result == null) return a.close(), s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`)); n(u.result.modelArtifacts); }, u.onerror = (c) => (a.close(), s(u.error)), i.oncomplete = () => a.close(); } else { let i = Dl(t), o = a.transaction(cr, "readwrite"), u = o.objectStore(cr), c = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), l; c.onsuccess = () => { l = a.transaction(Xr, "readwrite"); let p = l.objectStore(Xr).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); p.onsuccess = () => n({ modelArtifactsInfo: i }), p.onerror = (h) => { u = o.objectStore(cr); let f = u.delete(this.modelPath); f.onsuccess = () => (a.close(), s(p.error)), f.onerror = (m) => (a.close(), s(p.error)); }; }, c.onerror = (d) => (a.close(), s(c.error)), o.oncomplete = () => { l == null ? a.close() : l.oncomplete = () => a.close(); }; } }, r.onerror = (a) => s(r.error); }); } }; oa.URL_SCHEME = "indexeddb://"; var Ww = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(oa.URL_SCHEME) ? K$(e.slice(oa.URL_SCHEME.length)) : null; wt.registerSaveRouter(Ww); wt.registerLoadRouter(Ww); function K$(e) { return new oa(e); } function X$(e) { return e.startsWith(oa.URL_SCHEME) ? e.slice(oa.URL_SCHEME.length) : e; } var Y$ = class { constructor() { this.indexedDB = Vw(); } async listModels() { return new Promise((e, t) => { let n = this.indexedDB.open(Gf, Hf); n.onupgradeneeded = () => qf(n), n.onsuccess = () => { let s = n.result, r = s.transaction(cr, "readonly"), i = r.objectStore(cr).getAll(); i.onsuccess = () => { let o = {}; for (let u of i.result) o[u.modelPath] = u.modelArtifactsInfo; e(o); }, i.onerror = (o) => (s.close(), t(i.error)), r.oncomplete = () => s.close(); }, n.onerror = (s) => t(n.error); }); } async removeModel(e) { return e = X$(e), new Promise((t, n) => { let s = this.indexedDB.open(Gf, Hf); s.onupgradeneeded = () => qf(s), s.onsuccess = () => { let r = s.result, a = r.transaction(cr, "readwrite"), i = a.objectStore(cr), o = i.get(e), u; o.onsuccess = () => { if (o.result == null) return r.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { let c = i.delete(e), l = () => { u = r.transaction(Xr, "readwrite"); let p = u.objectStore(Xr).delete(e); p.onsuccess = () => t(o.result.modelArtifactsInfo), p.onerror = (h) => n(o.error); }; c.onsuccess = l, c.onerror = (d) => (l(), r.close(), n(o.error)); } }, o.onerror = (c) => (r.close(), n(o.error)), a.oncomplete = () => { u == null ? r.close() : u.oncomplete = () => r.close(); }; }, s.onerror = (r) => n(s.error); }); } }; var Us = "/"; var Li = "tensorflowjs_models"; var Uw = "info"; var Q$ = "model_topology"; var Z$ = "weight_specs"; var J$ = "weight_data"; var eA = "model_metadata"; function Gw(e) { return { info: [Li, e, Uw].join(Us), topology: [Li, e, Q$].join(Us), weightSpecs: [Li, e, Z$].join(Us), weightData: [Li, e, J$].join(Us), modelMetadata: [Li, e, eA].join(Us) }; } function Hw(e) { for (let t of Object.values(e)) window.localStorage.removeItem(t); } function tA(e) { let t = e.split(Us); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); return t.slice(1, t.length - 1).join(Us); } function nA(e) { return e.startsWith(ua.URL_SCHEME) ? e.slice(ua.URL_SCHEME.length) : e; } var ua = class { constructor(e) { if (!X().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 = Gw(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), s = Dl(e); try { this.LS.setItem(this.keys.info, JSON.stringify(s)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, M$(e.weightData)); let r = { 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(r)), { modelArtifactsInfo: s }; } catch (r) { throw Hw(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=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.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 s = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); if (s == null) throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`); t.weightSpecs = s; let r = this.LS.getItem(this.keys.modelMetadata); if (r != null) { let i = JSON.parse(r); 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 = L$(a), t; } }; ua.URL_SCHEME = "localstorage://"; var qw = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(ua.URL_SCHEME) ? sA(e.slice(ua.URL_SCHEME.length)) : null; wt.registerSaveRouter(qw); wt.registerLoadRouter(qw); function sA(e) { return new ua(e); } var rA = class { constructor() { O(X().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), O(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage; } async listModels() { let e = {}, t = Li + Us, n = Us + Uw; for (let s = 0; s < this.LS.length; ++s) { let r = this.LS.key(s); if (r.startsWith(t) && r.endsWith(n)) { let a = tA(r); e[a] = JSON.parse(this.LS.getItem(r)); } } return e; } async removeModel(e) { e = nA(e); let t = Gw(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 Hw(t), n; } }; var Ui = "://"; var zn = class { constructor() { this.managers = {}; } static getInstance() { return zn.instance == null && (zn.instance = new zn()), zn.instance; } static registerManager(e, t) { O(e != null, () => "scheme must not be undefined or null."), e.endsWith(Ui) && (e = e.slice(0, e.indexOf(Ui))), O(e.length > 0, () => "scheme must not be an empty string."); let n = zn.getInstance(); O(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 jc(e) { if (e.indexOf(Ui) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(",")}`); return { scheme: e.split(Ui)[0], path: e.split(Ui)[1] }; } async function jw(e, t, n = false) { O(e !== t, () => `Old path and new path are the same: '${e}'`); let s = wt.getLoadHandlers(e); O(s.length > 0, () => `Copying failed because no load handler is found for source URL ${e}.`), O(s.length < 2, () => `Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`); let r = s[0], a = wt.getSaveHandlers(t); O(a.length > 0, () => `Copying failed because no save handler is found for destination URL ${t}.`), O(a.length < 2, () => `Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`); let i = a[0], o = jc(e).scheme, u = jc(e).path, c = o === jc(e).scheme, l = await r.load(); n && c && await zn.getManager(o).removeModel(u); let d = await i.save(l); return n && !c && await zn.getManager(o).removeModel(u), d.modelArtifactsInfo; } async function aA() { let e = zn.getSchemes(), t = {}; for (let n of e) { let s = await zn.getManager(n).listModels(); for (let r in s) { let a = n + Ui + r; t[a] = s[r]; } } return t; } async function iA(e) { let t = jc(e); return zn.getManager(t.scheme).removeModel(t.path); } async function oA(e, t) { return jw(e, t, false); } async function uA(e, t) { return jw(e, t, true); } var lA = 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 (X().get("IS_BROWSER")) { X().setPlatform("browser", new lA()); try { zn.registerManager(ua.URL_SCHEME, new rA()); } catch (e) { } try { zn.registerManager(oa.URL_SCHEME, new Y$()); } catch (e) { } } var cA = { importFetch: () => bT() }; var kf; var dA = class { constructor() { this.util = yT(), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { return X().global.fetch != null ? X().global.fetch(e, t) : (kf == null && (kf = cA.importFetch()), kf(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); } }; X().get("IS_NODE") && !X().get("IS_BROWSER") && X().setPlatform("node", new dA()); function _e(e, t = "float32", n) { return t = t || "float32", Wm(e), new Vt(e, t, n); } function pA(e, t) { let n = E(e, "x", "cast"); if (!xw(t)) throw new Error(`Failed to cast to unknown dtype ${t}`); if (t === "string" && n.dtype !== "string" || t !== "string" && n.dtype === "string") throw new Error("Only strings can be casted to strings"); let s = { x: n }, r = { dtype: t }; return L.runKernel(Ca, s, r); } var pe = B({ cast_: pA }); function hA(e) { let n = { x: E(e, "x", "clone", "string_or_numeric") }; return L.runKernel(La, n); } var pr = B({ clone_: hA }); function fA(e, t = false) { console.log(e.toString(t)); } Pw(); var mA = { buffer: _e, cast: pe, clone: pr, print: fA }; k$(mA); var An = {}; Ae(An, { browserFiles: () => kA, browserHTTPRequest: () => TA, concatenateArrayBuffers: () => xg, copyModel: () => oA, decodeWeights: () => Lw, encodeWeights: () => P$, fromMemory: () => AA, getLoadHandlers: () => j$, getModelArtifactsForJSON: () => wg, getModelArtifactsInfoForJSON: () => Dl, getSaveHandlers: () => q$, http: () => Ig, isHTTPScheme: () => Kf, listModels: () => aA, loadWeights: () => IA, moveModel: () => uA, registerLoadRouter: () => H$, registerSaveRouter: () => G$, removeModel: () => iA, weightsLoaderFactory: () => Xw, withSaveHandler: () => EA }); var gA = "model"; var bA = ".json"; var yA = ".weights.bin"; function Bv(e) { return new Promise((t) => setTimeout(t)).then(e); } var jf = class { constructor(e) { if (!X().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(jf.URL_SCHEME) && (e = e.slice(jf.URL_SCHEME.length)), (e == null || e.length === 0) && (e = gA), this.modelJsonFileName = e + bA, this.weightDataFileName = e + yA; } 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 }], s = Bw(e, n), r = window.URL.createObjectURL(new Blob([JSON.stringify(s)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; if (a.download = this.modelJsonFileName, a.href = r, await Bv(() => 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 Bv(() => i.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: Dl(e) }; } } }; var cd = jf; cd.URL_SCHEME = "downloads://"; var vA = 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 = (s) => { let r = JSON.parse(s.target.result), a = r.modelTopology; if (a == null) { t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); return; } if (r.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 o = wg(r, (u) => this.loadWeights(u)); e(o); }, n.onerror = (s) => 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 s = this.checkManifestAndWeightFiles(e), r = n.map((a) => this.loadWeightsFile(a, s[a])); return Promise.all(r).then((a) => [t, xg(a)]); } loadWeightsFile(e, t) { return new Promise((n, s) => { let r = new FileReader(); r.onload = (a) => { let i = a.target.result; n(i); }, r.onerror = (a) => s(`Failed to weights data from file of path '${e}'.`), r.readAsArrayBuffer(t); }); } checkManifestAndWeightFiles(e) { let t = [], n = this.weightsFiles.map((r) => Lv(r.name)), s = {}; for (let r of e) r.paths.forEach((a) => { let i = Lv(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.`); s[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 s; } }; var xA = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(cd.URL_SCHEME) ? wA(e.slice(cd.URL_SCHEME.length)) : null; wt.registerSaveRouter(xA); function wA(e = "model") { return new cd(e); } function kA(e) { return new vA(e); } function Vv(e, t, n, s) { i(e), n = n == null ? 0 : n, s = s == null ? 1 : s, o(n, s); let r = 0, a = (u) => (u.then((c) => { let l = n + ++r / e.length * (s - n); return t(l), c; }), u); function i(u) { O(u != null && Array.isArray(u) && u.length > 0, () => "promises must be a none empty array"); } function o(u, c) { O(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${u}`), O(c >= 0 && c <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${c}`), O(c >= u, () => `startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${c}`); } return Promise.all(e.map(a)); } async function Kw(e, t) { t == null && (t = {}); let n = t.fetchFunc == null ? X().platform.fetch : t.fetchFunc, s = e.map((d) => n(d, t.requestInit, { isBinary: true })), r = 0, a = 0.5, o = (t.onProgress == null ? await Promise.all(s) : await Vv(s, t.onProgress, r, a)).map((d) => d.arrayBuffer()), u = 0.5, c = 1; return t.onProgress == null ? await Promise.all(o) : await Vv(o, t.onProgress, u, c); } async function IA(e, t = "", n, s) { return Xw((i) => Kw(i, { requestInit: s }))(e, t, n); } function Xw(e) { return async (t, n = "", s) => { let r = t.map(() => false), a = {}, i = s != null ? s.map(() => false) : [], o = []; if (t.forEach((h, f) => { let m = 0; h.weights.forEach((g) => { let b = "quantization" in g ? g.quantization.dtype : g.dtype, y = Uf[b] * pt(g.shape), v = () => { r[f] = true, a[f] == null && (a[f] = []), a[f].push({ manifestEntry: g, groupOffset: m, sizeBytes: y }); }; s != null ? s.forEach((x, k) => { x === g.name && (v(), i[k] = true); }) : v(), o.push(g.name), m += y; }); }), !i.every((h) => h)) { let h = s.filter((f, m) => !i[m]); throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`); } let u = r.reduce((h, f, m) => (f && h.push(m), h), []), c = []; u.forEach((h) => { t[h].paths.forEach((f) => { let m = n + (n.endsWith("/") ? "" : "/") + f; c.push(m); }); }); let l = await e(c), d = {}, p = 0; return u.forEach((h) => { let f = t[h].paths.length, m = 0; for (let x = 0; x < f; x++) m += l[p + x].byteLength; let g = new ArrayBuffer(m), b = new Uint8Array(g), y = 0; for (let x = 0; x < f; x++) { let k = new Uint8Array(l[p + x]); b.set(k, y), y += k.byteLength; } a[h].forEach((x) => { let k = g.slice(x.groupOffset, x.groupOffset + x.sizeBytes), T = Lw(k, [x.manifestEntry]); for (let C in T) d[C] = T[C]; }), p += f; }), d; }; } var SA = "application/octet-stream"; var CA = "application/json"; var kg = 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 ? (O(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 = X().platform.fetch, O(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && O(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 }], s = Bw(e, n); t.body.append("model.json", new Blob([JSON.stringify(s)], { type: CA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: SA }), "model.weights.bin"); let r = await this.fetch(this.path, t); if (r.ok) return { modelArtifactsInfo: Dl(e), responses: [r] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.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 (r) { 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, s = t.weightsManifest; if (n == null && s == null) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); return wg(t, (r) => this.loadWeights(r)); } async loadWeights(e) { let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, s] = NA(t), r = this.weightPathPrefix || n, a = []; for (let c of e) a.push(...c.weights); let i = [], o = []; for (let c of e) for (let l of c.paths) this.weightUrlConverter != null ? o.push(this.weightUrlConverter(l)) : i.push(r + l + s); this.weightUrlConverter && i.push(...await Promise.all(o)); let u = await Kw(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); return [a, xg(u)]; } }; kg.URL_SCHEME_REGEX = /^https?:\/\//; function NA(e) { let t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), s = e.substring(0, t), r = n > t ? e.substring(n) : ""; return [s + "/", r]; } function Kf(e) { return e.match(kg.URL_SCHEME_REGEX) != null; } var Yw = (e, t) => { if (typeof fetch == "undefined" && (t == null || t.fetchFunc == null)) return null; { let n = true; if (Array.isArray(e) ? n = e.every((s) => Kf(s)) : n = Kf(e), n) return Ig(e, t); } return null; }; wt.registerSaveRouter(Yw); wt.registerLoadRouter(Yw); function Ig(e, t) { return new kg(e, t); } function TA(e, t) { return Ig(e, t); } var If = class { constructor(e) { this.modelArtifacts = e; } async load() { return this.modelArtifacts; } }; var $A = class { constructor(e) { this.saveHandler = e; } async save(e) { return this.saveHandler(e); } }; function AA(e, t, n, s) { return arguments.length === 1 ? e.modelTopology != null || e.weightSpecs != null ? new If(e) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new If({ modelTopology: e })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new If({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: s })); } function EA(e) { return new $A(e); } var _A = {}; Ae(_A, { confusionMatrix: () => PA }); function RA(e, t, n = false, s = false) { let r = E(e, "a", "matMul"), a = E(t, "b", "matMul"); [r, a] = vt(r, a); let i = { a: r, b: a }, o = { transposeA: n, transposeB: s }; return L.runKernel(Sa, i, o); } var Me = B({ matMul_: RA }); function DA(e, t, n = 1, s = 0) { if (t < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`); let a = { indices: E(e, "indices", "oneHot", "int32") }, i = { depth: t, onValue: n, offValue: s }; return L.runKernel(Co, a, i); } var dd = B({ oneHot_: DA }); function FA(e, t) { let n = E(e, "x", "transpose"); if (t == null && (t = n.shape.map((a, i) => i).reverse()), O(n.rank === t.length, () => `Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`), t.forEach((a) => { O(a >= 0 && a < n.rank, () => `All entries in 'perm' must be between 0 and ${n.rank - 1} but got ${t}`); }), n.rank <= 1) return n.clone(); let s = { x: n }, r = { perm: t }; return L.runKernel(di, s, r); } var qe = B({ transpose_: FA }); function OA(e, t, n) { let s = E(e, "labels", "confusionMatrix"), r = E(t, "predictions", "confusionMatrix"); O(n == null || n > 0 && Number.isInteger(n), () => `If provided, numClasses must be a positive integer, but got ${n}`), O(s.rank === 1, () => `Expected the rank of labels to be 1, but got ${s.rank}`), O(r.rank === 1, () => `Expected the rank of predictions to be 1, but got ${r.rank}`), O(s.shape[0] === r.shape[0], () => `Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`), O(n > 0 && Number.isInteger(n), () => `numClasses is required to be a positive integer, but got ${n}`); let a = dd(pe(s, "int32"), n), i = dd(pe(r, "int32"), n), o = qe(a), u = Me(o, i); return pe(u, "int32"); } var PA = B({ confusionMatrix_: OA }); var Go = {}; Ae(Go, { assertAndGetBroadcastShape: () => ot, getBroadcastDims: () => Qw, getReductionAxes: () => $t }); function Qw(e, t) { let n = e.length, s = []; for (let r = 0; r < n; r++) { let a = n - 1 - r, i = e[a] || 1; (t[t.length - 1 - r] || 1) > 1 && i === 1 && s.unshift(a); } return s; } function $t(e, t) { let n = []; for (let s = 0; s < t.length; s++) { let r = e[e.length - s - 1], a = t.length - s - 1, i = t[a]; (r == null || r === 1 && i > 1) && n.unshift(a); } return n; } function ot(e, t) { let n = [], s = Math.max(e.length, t.length); for (let r = 0; r < s; r++) { let a = e[e.length - r - 1]; a == null && (a = 1); let i = t[t.length - r - 1]; if (i == null && (i = 1), a === 1) n.unshift(i); else if (i === 1) n.unshift(a); else if (a !== i) { let o = `Operands could not be broadcast together with shapes ${e} and ${t}.`; throw Error(o); } else n.unshift(a); } return n; } var Zw = {}; Ae(Zw, { fromPixels: () => GA, fromPixelsAsync: () => WA, toPixels: () => UA }); function zA(e, t, n) { if (xa(e), t != null && t.length !== 3) throw new Error("tensor3d() requires shape to have three numbers"); let s = Es(e, n); if (s.length !== 3 && s.length !== 1) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (s.length === 1 && t == null) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); return $r(e, t, s, n); } var Vr; function Jw(e, t = 3) { if (t > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (e == null) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); let n = false, s = false, r = false, a = false, i = false, o = false; if (e.data instanceof Uint8Array) n = true; else if (typeof ImageData != "undefined" && e instanceof ImageData) s = true; else if (typeof HTMLVideoElement != "undefined" && e instanceof HTMLVideoElement) r = true; else if (typeof HTMLImageElement != "undefined" && e instanceof HTMLImageElement) a = true; else if (e.getContext != null) i = true; else if (typeof ImageBitmap != "undefined" && e instanceof ImageBitmap) o = 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 ${e.constructor.name}`); if (r && r && e.readyState < 2) throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the