/* 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: "", wasmPlatformFetch: false, 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: () => ao, Acos: () => nl, Acosh: () => sl, AdadeltaOptimizer: () => fb, AdagradOptimizer: () => mb, AdamOptimizer: () => gb, AdamaxOptimizer: () => bb, Add: () => Ir, AddN: () => wa, All: () => rl, Any: () => al, ArgMax: () => ka, ArgMin: () => il, Asin: () => ol, Asinh: () => ul, Atan: () => ll, Atan2: () => dl, Atanh: () => cl, AvgPool: () => Ia, AvgPool3D: () => qd, AvgPool3DGrad: () => og, AvgPoolGrad: () => ig, BackendWasm: () => kde, BatchMatMul: () => Sa, BatchToSpaceND: () => io, Bincount: () => ug, BroadcastArgs: () => lg, BroadcastTo: () => A$, Callback: () => CW, CallbackList: () => zL, Cast: () => Ca, Ceil: () => Na, ClipByValue: () => Sr, Complex: () => jd, ComplexAbs: () => Kd, Concat: () => oo, Conv2D: () => Ta, Conv2DBackpropFilter: () => cg, Conv2DBackpropInput: () => $a, Conv3D: () => Xd, Conv3DBackpropFilterV2: () => dg, Conv3DBackpropInputV2: () => pg, Cos: () => _a, Cosh: () => Aa, CropAndResize: () => lo, Cumprod: () => pl, Cumsum: () => uo, CustomCallback: () => BL, DataStorage: () => Ud, DenseBincount: () => hg, DepthToSpace: () => co, DepthwiseConv2dNative: () => Ea, DepthwiseConv2dNativeBackpropFilter: () => fg, DepthwiseConv2dNativeBackpropInput: () => mg, Diag: () => gg, Dilation2D: () => Yd, Dilation2DBackpropFilter: () => Qf, Dilation2DBackpropInput: () => Yf, ENV: () => Jw, EarlyStopping: () => NW, Einsum: () => Qd, Elu: () => Da, EluGrad: () => bg, Environment: () => S$, Equal: () => po, Erf: () => hl, Exp: () => Fa, ExpandDims: () => ho, Expm1: () => fo, FFT: () => yg, Fill: () => fl, FlipLeftRight: () => mo, Floor: () => Oa, FloorDiv: () => Pa, FromPixels: () => fd, FusedBatchNorm: () => za, FusedConv2D: () => ra, FusedDepthwiseConv2D: () => aa, GPGPUContext: () => Kf, GatherNd: () => bo, GatherV2: () => go, GraphModel: () => E4, Greater: () => yo, GreaterEqual: () => Ma, History: () => LL, IFFT: () => vg, Identity: () => La, Imag: () => Zd, InputSpec: () => Dt, IsFinite: () => ml, IsInf: () => gl, IsNan: () => bl, KernelBackend: () => tl, LRN: () => ep, LRNGrad: () => wg, LayerVariable: () => AL, LayersModel: () => pr, LeakyRelu: () => Ba, Less: () => vo, LessEqual: () => xo, LinSpace: () => xg, Log: () => Va, Log1p: () => yl, LogSoftmax: () => E$, LogicalAnd: () => wo, LogicalNot: () => vl, LogicalOr: () => Jd, MathBackendCPU: () => L0, MathBackendWebGL: () => M1, Max: () => Wa, MaxPool: () => Ga, MaxPool3D: () => tp, MaxPool3DGrad: () => Ig, MaxPoolGrad: () => kg, MaxPoolWithArgmax: () => Sg, Maximum: () => Ua, Mean: () => Ha, Min: () => qa, Minimum: () => ja, MirrorPad: () => Ka, Mod: () => xl, MomentumOptimizer: () => yb, Multinomial: () => Cg, Multiply: () => Xa, Neg: () => ko, NonMaxSuppressionV3: () => So, NonMaxSuppressionV4: () => wl, NonMaxSuppressionV5: () => Co, NotEqual: () => Io, OP_SCOPE_SUFFIX: () => l_, OneHot: () => To, OnesLike: () => No, Optimizer: () => _r, OptimizerConstructors: () => Wr, Pack: () => $o, PadV2: () => Ya, Pool: () => $de, Pow: () => Qa, Prelu: () => Za, Prod: () => _o, RMSPropOptimizer: () => vb, RNN: () => Ar, Range: () => kl, Rank: () => e_, Real: () => np, RealDiv: () => Ra, Reciprocal: () => Il, Reduction: () => oO, Relu: () => Ja, Relu6: () => ti, Reshape: () => Ao, ResizeBilinear: () => ei, ResizeBilinearGrad: () => Tg, ResizeNearestNeighbor: () => Sl, ResizeNearestNeighborGrad: () => Ng, Reverse: () => Eo, RotateWithOffset: () => Ho, Round: () => Ro, Rsqrt: () => ni, SGDOptimizer: () => Ip, ScatterNd: () => Do, Select: () => Fo, Selu: () => Cl, Sequential: () => Ub, Sigmoid: () => ri, Sign: () => Nl, Sin: () => si, Sinh: () => Po, Slice: () => Oo, Softmax: () => oi, Softplus: () => Tl, SpaceToBatchND: () => zo, SparseFillEmptyRows: () => sp, SparseReshape: () => $l, SparseSegmentMean: () => rp, SparseSegmentSum: () => ap, SparseToDense: () => ip, SplitV: () => Mo, Sqrt: () => ai, Square: () => _l, SquaredDifference: () => ui, Step: () => pi, StridedSlice: () => Lo, StringNGrams: () => op, StringSplit: () => $g, StringToHashBucketFast: () => _g, Sub: () => li, Sum: () => ii, SymbolicTensor: () => $s, Tan: () => Bo, Tanh: () => ci, Tensor: () => et, TensorBuffer: () => Vt, Tile: () => Cr, TopK: () => Vo, Transform: () => Wo, Transpose: () => di, Unique: () => Ag, Unpack: () => Uo, UnsortedSegmentSum: () => up, Variable: () => gd, ZerosLike: () => Go, _FusedMatMul: () => sa, abs: () => Mt, acos: () => GA, acosh: () => qA, add: () => ie, addN: () => KA, all: () => qk, any: () => pm, argMax: () => Gu, argMin: () => JA, asin: () => tE, asinh: () => sE, atan: () => aE, atan2: () => oE, atanh: () => lE, avgPool: () => Gg, avgPool3d: () => Yk, backend: () => zA, backend_util: () => S, basicLSTMCell: () => qde, batchNorm: () => qu, batchNorm2d: () => $E, batchNorm3d: () => AE, batchNorm4d: () => RE, batchToSpaceND: () => Hg, bincount: () => Qk, booleanMaskAsync: () => xpe, broadcastArgs: () => OE, broadcastTo: () => nd, broadcast_util: () => qo, browser: () => Nk, buffer: () => De, callbacks: () => Ape, cast: () => ce, ceil: () => ME, clipByValue: () => Vn, clone: () => lr, complex: () => ia, concat: () => Ft, concat1d: () => VE, concat2d: () => UE, concat3d: () => HE, concat4d: () => jE, constraints: () => MM, conv1d: () => Zk, conv2d: () => la, conv2dTranspose: () => Jk, conv3d: () => eI, conv3dTranspose: () => tR, copyRegisteredKernels: () => Ede, cos: () => jg, cosh: () => nI, cosineWindow: () => TI, cumprod: () => aR, cumsum: () => sI, customGrad: () => js, data: () => R4, denseBincount: () => uR, deprecationWarn: () => Gk, depthToSpace: () => cR, depthwiseConv2d: () => hp, deregisterOp: () => Rpe, device_util: () => dp, diag: () => jde, dilation2d: () => fR, disableDeprecationWarnings: () => Ode, dispose: () => Re, disposeVariables: () => Pde, div: () => xe, divNoNan: () => vR, dot: () => Kde, dropout: () => nF, einsum: () => kR, elu: () => fp, enableDebugMode: () => Fde, enableProdMode: () => Dde, enclosingPowerOfTwo: () => sF, engine: () => Ss, env: () => X, equal: () => Kn, erf: () => CR, exp: () => Xn, expandDims: () => Pn, expm1: () => _R, eye: () => rI, fft: () => lb, fill: () => Ol, findBackend: () => Ude, findBackendFactory: () => Gde, floor: () => mp, floorDiv: () => Hk, forceHalfFloat: () => GX, fused: () => pa, gather: () => ju, gatherND: () => J3, gather_util: () => $k, getBackend: () => Vde, getGradient: () => nx, getKernel: () => Zf, getKernelsForBackend: () => Jf, getThreadsCount: () => Wpe, gpgpu_util: () => RK, grad: () => Qde, grads: () => Zde, greater: () => Wn, greaterEqual: () => jo, ifft: () => Id, imag: () => Kg, image: () => qn, inTopKAsync: () => kpe, initializers: () => qM, input: () => OB, io: () => En, irfft: () => xI, isFinite: () => Xde, isInf: () => Yde, isNaN: () => BR, keep: () => Ht, kernel_impls: () => xs, layers: () => $L, leakyRelu: () => Xg, less: () => aI, lessEqual: () => Ko, linalg: () => VO, linspace: () => GR, loadGraphModel: () => Dpe, loadLayersModel: () => $pe, localResponseNormalization: () => qR, log: () => Yn, log1p: () => Yg, logSigmoid: () => tpe, logSoftmax: () => iI, logSumExp: () => iD, logicalAnd: () => Ds, logicalNot: () => Jg, logicalOr: () => cI, logicalXor: () => npe, losses: () => Cpe, matMul: () => We, math: () => iA, max: () => As, maxPool: () => eb, maxPool3d: () => dI, maxPoolWithArgmax: () => fD, maximum: () => $r, mean: () => St, memory: () => dm, meshgrid: () => spe, metrics: () => rW, min: () => fm, minimum: () => bp, mirrorPad: () => xD, mod: () => kD, model: () => Npe, models: () => xW, moments: () => tb, movingAverage: () => wpe, mul: () => V, multiRNNCell: () => rpe, multinomial: () => TD, neg: () => kt, nextFrame: () => OI, norm: () => CI, notEqual: () => Ku, oneHot: () => vd, ones: () => Mn, onesLike: () => Qn, op: () => L, outerProduct: () => ape, pad: () => hi, pad1d: () => ipe, pad2d: () => ope, pad3d: () => upe, pad4d: () => lpe, pool: () => cpe, pow: () => da, prelu: () => sb, print: () => U_, prod: () => pI, profile: () => zde, rand: () => dpe, randomGamma: () => ppe, randomNormal: () => KD, randomUniform: () => zl, range: () => Xu, ready: () => Bde, real: () => wd, reciprocal: () => ZD, registerBackend: () => pp, registerCallbackConstructor: () => _pe, registerGradient: () => D$, registerKernel: () => Al, registerOp: () => Epe, regularizers: () => wW, relu: () => Xs, relu6: () => hI, removeBackend: () => Wde, reshape: () => G, reverse: () => Zn, reverse1d: () => hpe, reverse2d: () => fpe, reverse3d: () => mpe, reverse4d: () => gpe, rfft: () => cb, round: () => fI, rsqrt: () => mI, scalar: () => Ie, scatterND: () => X3, scatter_util: () => Ak, selu: () => gI, separableConv2d: () => c3, sequential: () => Tpe, serialization: () => ae, setBackend: () => Lde, setPlatform: () => Hde, setThreadsCount: () => Vpe, setWasmPath: () => Lpe, setWasmPaths: () => Bpe, setWebGLContext: () => S5, setdiff1dAsync: () => p3, shared: () => Zy, sigmoid: () => qs, sign: () => f3, signal: () => Spe, sin: () => bI, sinh: () => yI, slice: () => He, slice1d: () => ib, slice2d: () => vI, slice3d: () => ob, slice4d: () => kd, slice_util: () => wt, softmax: () => ub, softplus: () => Pl, spaceToBatchND: () => nb, sparse: () => Wc, sparseToDense: () => NI, spectral: () => Ipe, split: () => Bn, sqrt: () => dn, square: () => ct, squaredDifference: () => wI, squeeze: () => mr, stack: () => Jn, step: () => yp, stridedSlice: () => D3, string: () => Mf, sub: () => ge, sum: () => ve, sumOutType: () => cp, tan: () => O3, tanh: () => Hu, tensor: () => fs, tensor1d: () => Zt, tensor2d: () => Ki, tensor3d: () => pA, tensor4d: () => bpe, tensor5d: () => ype, tensor6d: () => vpe, tensor_util: () => _s, test_util: () => _A, tidy: () => j, tile: () => ps, time: () => Mde, topk: () => z3, train: () => Oi, transpose: () => qe, truncatedNormal: () => db, unique: () => hx, unregisterGradient: () => Ade, unregisterKernel: () => _de, unsortedSegmentSum: () => V3, unstack: () => Fs, upcastType: () => cn, util: () => x, valueAndGrad: () => Jde, valueAndGrads: () => epe, variable: () => U3, variableGrads: () => XR, version: () => Gpe, version_converter: () => Fpe, version_core: () => Rde, version_cpu: () => Ope, version_layers: () => uS, version_wasm: () => Upe, version_webgl: () => Ppe, webgl: () => zpe, webgl_util: () => I5, webgpu: () => roe, where: () => vn, whereAsync: () => II, zeros: () => $t, zerosLike: () => je }); var LT = Object.create; var Vd = Object.defineProperty; var BT = Object.getOwnPropertyDescriptor; var Vw = Object.getOwnPropertyNames; var VT = Object.getPrototypeOf; var WT = Object.prototype.hasOwnProperty; var UT = (e) => Vd(e, "__esModule", { value: true }); var zt = (e, t) => function() { return t || (0, e[Vw(e)[0]])((t = { exports: {} }).exports, t), t.exports; }; var Ae = (e, t) => { for (var n in t) Vd(e, n, { get: t[n], enumerable: true }); }; var GT = (e, t, n, s) => { if (t && typeof t == "object" || typeof t == "function") for (let r of Vw(t)) !WT.call(e, r) && (n || r !== "default") && Vd(e, r, { get: () => t[r], enumerable: !(s = BT(t, r)) || s.enumerable }); return e; }; var va = (e, t) => GT(UT(Vd(e != null ? LT(VT(e)) : {}, "default", !t && e && e.__esModule ? { get: () => e.default, enumerable: true } : { value: e, enumerable: true })), e); var HT = zt({ "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 = l(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 = l(F, F < 0 ? -1 : 0, false), q && (a[F] = z), z)); } s.fromInt = o; function u(F, $) { if (isNaN(F)) return $ ? w : v; if ($) { if (F < 0) return w; if (F >= g) return A; } else { if (F <= -b) return P; if (F + 1 >= b) return E; } return F < 0 ? u(-F, $).neg() : l(F % m | 0, F / m | 0, $); } s.fromNumber = u; function l(F, $, z) { return new s(F, $, z); } s.fromBits = l; var c = Math.pow; function p(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 p(F.substring(1), $, z).neg(); for (var q = u(c(z, 8)), K = v, Y = 0; Y < F.length; Y += 8) { var Z = Math.min(8, F.length - Y), te = parseInt(F.substring(Y, Y + Z), z); if (Z < 8) { var ee = u(c(z, Z)); K = K.mul(ee).add(u(te)); } else K = K.mul(q), K = K.add(u(te)); } return K.unsigned = $, K; } s.fromString = p; function d(F, $) { return typeof F == "number" ? u(F, $) : typeof F == "string" ? p(F, $) : l(F.low, F.high, typeof $ == "boolean" ? $ : F.unsigned); } s.fromValue = d; 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 w = o(0, true); s.UZERO = w; var k = o(1); s.ONE = k; var T = o(1, true); s.UONE = T; var N = o(-1); s.NEG_ONE = N; var E = l(-1, 2147483647, false); s.MAX_VALUE = E; var A = l(-1, -1, true); s.MAX_UNSIGNED_VALUE = A; var P = l(0, -2147483648, false); s.MIN_VALUE = P; var R = s.prototype; R.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low; }, R.toNumber = function() { return this.unsigned ? (this.high >>> 0) * m + (this.low >>> 0) : this.high * m + (this.low >>> 0); }, R.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(c($, 6), this.unsigned), Y = this, Z = ""; ; ) { var te = Y.div(K), ee = Y.sub(te.mul(K)).toInt() >>> 0, se = ee.toString($); if (Y = te, Y.isZero()) return se + Z; for (; se.length < 6; ) se = "0" + se; Z = "" + se + Z; } }, R.getHighBits = function() { return this.high; }, R.getHighBitsUnsigned = function() { return this.high >>> 0; }, R.getLowBits = function() { return this.low; }, R.getLowBitsUnsigned = function() { return this.low >>> 0; }, R.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; }, R.isZero = function() { return this.high === 0 && this.low === 0; }, R.eqz = R.isZero, R.isNegative = function() { return !this.unsigned && this.high < 0; }, R.isPositive = function() { return this.unsigned || this.high >= 0; }, R.isOdd = function() { return (this.low & 1) === 1; }, R.isEven = function() { return (this.low & 1) === 0; }, R.equals = function($) { return r($) || ($ = d($)), this.unsigned !== $.unsigned && this.high >>> 31 === 1 && $.high >>> 31 === 1 ? false : this.high === $.high && this.low === $.low; }, R.eq = R.equals, R.notEquals = function($) { return !this.eq($); }, R.neq = R.notEquals, R.ne = R.notEquals, R.lessThan = function($) { return this.comp($) < 0; }, R.lt = R.lessThan, R.lessThanOrEqual = function($) { return this.comp($) <= 0; }, R.lte = R.lessThanOrEqual, R.le = R.lessThanOrEqual, R.greaterThan = function($) { return this.comp($) > 0; }, R.gt = R.greaterThan, R.greaterThanOrEqual = function($) { return this.comp($) >= 0; }, R.gte = R.greaterThanOrEqual, R.ge = R.greaterThanOrEqual, R.compare = function($) { if (r($) || ($ = d($)), 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; }, R.comp = R.compare, R.negate = function() { return !this.unsigned && this.eq(P) ? P : this.not().add(k); }, R.neg = R.negate, R.add = function($) { r($) || ($ = d($)); var z = this.high >>> 16, W = this.high & 65535, q = this.low >>> 16, K = this.low & 65535, Y = $.high >>> 16, Z = $.high & 65535, te = $.low >>> 16, ee = $.low & 65535, se = 0, ne = 0, oe = 0, re = 0; return re += K + ee, oe += re >>> 16, re &= 65535, oe += q + te, ne += oe >>> 16, oe &= 65535, ne += W + Z, se += ne >>> 16, ne &= 65535, se += z + Y, se &= 65535, l(oe << 16 | re, se << 16 | ne, this.unsigned); }, R.subtract = function($) { return r($) || ($ = d($)), this.add($.neg()); }, R.sub = R.subtract, R.multiply = function($) { if (this.isZero()) return v; if (r($) || ($ = d($)), n) { var z = n.mul(this.low, this.high, $.low, $.high); return l(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, Y = this.low & 65535, Z = $.high >>> 16, te = $.high & 65535, ee = $.low >>> 16, se = $.low & 65535, ne = 0, oe = 0, re = 0, le = 0; return le += Y * se, re += le >>> 16, le &= 65535, re += K * se, oe += re >>> 16, re &= 65535, re += Y * ee, oe += re >>> 16, re &= 65535, oe += q * se, ne += oe >>> 16, oe &= 65535, oe += K * ee, ne += oe >>> 16, oe &= 65535, oe += Y * te, ne += oe >>> 16, oe &= 65535, ne += W * se + q * ee + K * te + Y * Z, ne &= 65535, l(re << 16 | le, ne << 16 | oe, this.unsigned); }, R.mul = R.multiply, R.divide = function($) { if (r($) || ($ = d($)), $.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 l(z, n.get_high(), this.unsigned); } if (this.isZero()) return this.unsigned ? w : v; var W, q, K; if (this.unsigned) { if ($.unsigned || ($ = $.toUnsigned()), $.gt(this)) return w; if ($.gt(this.shru(1))) return T; K = w; } else { if (this.eq(P)) { if ($.eq(k) || $.eq(N)) return P; if ($.eq(P)) return k; var Y = this.shr(1); return W = Y.div($).shl(1), W.eq(v) ? $.isNegative() ? k : N : (q = this.sub($.mul(W)), K = W.add(q.div($)), K); } else if ($.eq(P)) return this.unsigned ? w : 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 Z = Math.ceil(Math.log(W) / Math.LN2), te = Z <= 48 ? 1 : c(2, Z - 48), ee = u(W), se = ee.mul($); se.isNegative() || se.gt(q); ) W -= te, ee = u(W, this.unsigned), se = ee.mul($); ee.isZero() && (ee = k), K = K.add(ee), q = q.sub(se); } return K; }, R.div = R.divide, R.modulo = function($) { if (r($) || ($ = d($)), n) { var z = (this.unsigned ? n.rem_u : n.rem_s)(this.low, this.high, $.low, $.high); return l(z, n.get_high(), this.unsigned); } return this.sub(this.div($).mul($)); }, R.mod = R.modulo, R.rem = R.modulo, R.not = function() { return l(~this.low, ~this.high, this.unsigned); }, R.and = function($) { return r($) || ($ = d($)), l(this.low & $.low, this.high & $.high, this.unsigned); }, R.or = function($) { return r($) || ($ = d($)), l(this.low | $.low, this.high | $.high, this.unsigned); }, R.xor = function($) { return r($) || ($ = d($)), l(this.low ^ $.low, this.high ^ $.high, this.unsigned); }, R.shiftLeft = function($) { return r($) && ($ = $.toInt()), ($ &= 63) === 0 ? this : $ < 32 ? l(this.low << $, this.high << $ | this.low >>> 32 - $, this.unsigned) : l(0, this.low << $ - 32, this.unsigned); }, R.shl = R.shiftLeft, R.shiftRight = function($) { return r($) && ($ = $.toInt()), ($ &= 63) === 0 ? this : $ < 32 ? l(this.low >>> $ | this.high << 32 - $, this.high >> $, this.unsigned) : l(this.high >> $ - 32, this.high >= 0 ? 0 : -1, this.unsigned); }, R.shr = R.shiftRight, R.shiftRightUnsigned = function($) { if (r($) && ($ = $.toInt()), $ &= 63, $ === 0) return this; var z = this.high; if ($ < 32) { var W = this.low; return l(W >>> $ | z << 32 - $, z >>> $, this.unsigned); } else return $ === 32 ? l(z, 0, this.unsigned) : l(z >>> $ - 32, 0, this.unsigned); }, R.shru = R.shiftRightUnsigned, R.shr_u = R.shiftRightUnsigned, R.toSigned = function() { return this.unsigned ? l(this.low, this.high, false) : this; }, R.toUnsigned = function() { return this.unsigned ? this : l(this.low, this.high, true); }, R.toBytes = function($) { return $ ? this.toBytesLE() : this.toBytesBE(); }, R.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]; }, R.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 qT = zt({ "(disabled):src/node_modules/node-fetch/browser.js"() { } }); var jT = zt({ "(disabled):util"() { } }); var KT = zt({ "src/node_modules/seedrandom/lib/alea.js"(e, t) { (function(n, s, r) { function a(l) { var c = this, p = u(); c.next = function() { var d = 2091639 * c.s0 + c.c * 23283064365386963e-26; return c.s0 = c.s1, c.s1 = c.s2, c.s2 = d - (c.c = d | 0); }, c.c = 1, c.s0 = p(" "), c.s1 = p(" "), c.s2 = p(" "), c.s0 -= p(l), c.s0 < 0 && (c.s0 += 1), c.s1 -= p(l), c.s1 < 0 && (c.s1 += 1), c.s2 -= p(l), c.s2 < 0 && (c.s2 += 1), p = null; } function i(l, c) { return c.c = l.c, c.s0 = l.s0, c.s1 = l.s1, c.s2 = l.s2, c; } function o(l, c) { var p = new a(l), d = c && c.state, h = p.next; return h.int32 = function() { return p.next() * 4294967296 | 0; }, h.double = function() { return h() + (h() * 2097152 | 0) * 11102230246251565e-32; }, h.quick = h, d && (typeof d == "object" && i(d, p), h.state = function() { return i(p, {}); }), h; } function u() { var l = 4022871197, c = function(p) { p = String(p); for (var d = 0; d < p.length; d++) { l += p.charCodeAt(d); var h = 0.02519603282416938 * l; l = h >>> 0, h -= l, h *= l, l = h >>> 0, h -= l, l += h * 4294967296; } return (l >>> 0) * 23283064365386963e-26; }; return c; } 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 = zt({ "src/node_modules/seedrandom/lib/xor128.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; l.x = 0, l.y = 0, l.z = 0, l.w = 0, l.next = function() { var d = l.x ^ l.x << 11; return l.x = l.y, l.y = l.z, l.z = l.w, l.w ^= l.w >>> 19 ^ d ^ d >>> 8; }, u === (u | 0) ? l.x = u : c += u; for (var p = 0; p < c.length + 64; p++) l.x ^= c.charCodeAt(p) | 0, l.next(); } function i(u, l) { return l.x = u.x, l.y = u.y, l.z = u.z, l.w = u.w, l; } function o(u, l) { var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (typeof p == "object" && i(p, c), d.state = function() { return i(c, {}); }), d; } 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 YT = zt({ "src/node_modules/seedrandom/lib/xorwow.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; l.next = function() { var d = l.x ^ l.x >>> 2; return l.x = l.y, l.y = l.z, l.z = l.w, l.w = l.v, (l.d = l.d + 362437 | 0) + (l.v = l.v ^ l.v << 4 ^ (d ^ d << 1)) | 0; }, l.x = 0, l.y = 0, l.z = 0, l.w = 0, l.v = 0, u === (u | 0) ? l.x = u : c += u; for (var p = 0; p < c.length + 64; p++) l.x ^= c.charCodeAt(p) | 0, p == c.length && (l.d = l.x << 10 ^ l.x >>> 4), l.next(); } function i(u, l) { return l.x = u.x, l.y = u.y, l.z = u.z, l.w = u.w, l.v = u.v, l.d = u.d, l; } function o(u, l) { var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (typeof p == "object" && i(p, c), d.state = function() { return i(c, {}); }), d; } 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 QT = zt({ "src/node_modules/seedrandom/lib/xorshift7.js"(e, t) { (function(n, s, r) { function a(u) { var l = this; l.next = function() { var p = l.x, d = l.i, h, f, m; return h = p[d], h ^= h >>> 7, f = h ^ h << 24, h = p[d + 1 & 7], f ^= h ^ h >>> 10, h = p[d + 3 & 7], f ^= h ^ h >>> 3, h = p[d + 4 & 7], f ^= h ^ h << 7, h = p[d + 7 & 7], h = h ^ h << 13, f ^= h ^ h << 9, p[d] = f, l.i = d + 1 & 7, f; }; function c(p, d) { var h, f, m = []; if (d === (d | 0)) f = m[0] = d; else for (d = "" + d, h = 0; h < d.length; ++h) m[h & 7] = m[h & 7] << 15 ^ d.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], p.x = m, p.i = 0, h = 256; h > 0; --h) p.next(); } c(l, u); } function i(u, l) { return l.x = u.x.slice(), l.i = u.i, l; } function o(u, l) { u == null && (u = +new Date()); var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (p.x && i(p, c), d.state = function() { return i(c, {}); }), d; } 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 ZT = zt({ "src/node_modules/seedrandom/lib/xor4096.js"(e, t) { (function(n, s, r) { function a(u) { var l = this; l.next = function() { var p = l.w, d = l.X, h = l.i, f, m; return l.w = p = p + 1640531527 | 0, m = d[h + 34 & 127], f = d[h = h + 1 & 127], m ^= m << 13, f ^= f << 17, m ^= m >>> 15, f ^= f >>> 12, m = d[h] = m ^ f, l.i = h, m + (p ^ p >>> 16) | 0; }; function c(p, d) { var h, f, m, g, b, y = [], v = 128; for (d === (d | 0) ? (f = d, d = null) : (d = d + "\0", f = 0, v = Math.max(v, d.length)), m = 0, g = -32; g < v; ++g) d && (f ^= d.charCodeAt((g + 32) % d.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[(d && d.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; p.w = b, p.X = y, p.i = m; } c(l, u); } function i(u, l) { return l.i = u.i, l.w = u.w, l.X = u.X.slice(), l; } function o(u, l) { u == null && (u = +new Date()); var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (p.X && i(p, c), d.state = function() { return i(c, {}); }), d; } 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 JT = zt({ "src/node_modules/seedrandom/lib/tychei.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; l.next = function() { var d = l.b, h = l.c, f = l.d, m = l.a; return d = d << 25 ^ d >>> 7 ^ h, h = h - f | 0, f = f << 24 ^ f >>> 8 ^ m, m = m - d | 0, l.b = d = d << 20 ^ d >>> 12 ^ h, l.c = h = h - f | 0, l.d = f << 16 ^ h >>> 16 ^ m, l.a = m - d | 0; }, l.a = 0, l.b = 0, l.c = -1640531527, l.d = 1367130551, u === Math.floor(u) ? (l.a = u / 4294967296 | 0, l.b = u | 0) : c += u; for (var p = 0; p < c.length + 20; p++) l.b ^= c.charCodeAt(p) | 0, l.next(); } function i(u, l) { return l.a = u.a, l.b = u.b, l.c = u.c, l.d = u.d, l; } function o(u, l) { var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (typeof p == "object" && i(p, c), d.state = function() { return i(c, {}); }), d; } 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 e$ = zt({ "(disabled):crypto"() { } }); var t$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { (function(n, s, r) { var a = 256, i = 6, o = 52, u = "random", l = r.pow(a, i), c = r.pow(2, o), p = c * 2, d = a - 1, h; function f(k, T, N) { var E = []; T = T == true ? { entropy: true } : T || {}; var A = y(b(T.entropy ? [k, w(s)] : k == null ? v() : k, 3), E), P = new m(E), R = function() { for (var F = P.g(i), $ = l, z = 0; F < c; ) F = (F + z) * a, $ *= a, z = P.g(1); for (; F >= p; ) F /= 2, $ /= 2, z >>>= 1; return (F + z) / $; }; return R.int32 = function() { return P.g(4) | 0; }, R.quick = function() { return P.g(4) / 4294967296; }, R.double = R, y(w(P.S), s), (T.pass || N || function(F, $, z, W) { return W && (W.S && g(W, P), F.state = function() { return g(P, {}); }), z ? (r[u] = F, $) : F; })(R, A, "global" in T ? T.global : this == r, T.state); } function m(k) { var T, N = k.length, E = this, A = 0, P = E.i = E.j = 0, R = E.S = []; for (N || (k = [N++]); A < a; ) R[A] = A++; for (A = 0; A < a; A++) R[A] = R[P = d & P + k[A % N] + (T = R[A])], R[P] = T; (E.g = function(F) { for (var $, z = 0, W = E.i, q = E.j, K = E.S; F--; ) $ = K[W = d & W + 1], z = z * a + K[d & (K[W] = K[q = d & q + $]) + (K[q] = $)]; return E.i = W, E.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 N = [], E = typeof k, A; if (T && E == "object") for (A in k) try { N.push(b(k[A], T - 1)); } catch (P) { } return N.length ? N : E == "string" ? k : k + "\0"; } function y(k, T) { for (var N = k + "", E, A = 0; A < N.length; ) T[d & A] = d & (E ^= T[d & A] * 19) + N.charCodeAt(A++); return w(T); } function v() { try { var k; return h && (k = h.randomBytes) ? k = k(a) : (k = new Uint8Array(a), (n.crypto || n.msCrypto).getRandomValues(k)), w(k); } catch (E) { var T = n.navigator, N = T && T.plugins; return [+new Date(), n, N, n.screen, w(s)]; } } function w(k) { return String.fromCharCode.apply(0, k); } if (y(r.random(), s), typeof t == "object" && t.exports) { t.exports = f; try { h = e$(); } catch (k) { } } else typeof define == "function" && define.amd ? define(function() { return f; }) : r["seed" + u] = f; })(typeof self != "undefined" ? self : e, [], Math); } }); var Wd = zt({ "src/node_modules/seedrandom/index.js"(e, t) { var n = KT(), s = XT(), r = YT(), a = QT(), i = ZT(), o = JT(), u = t$(); u.alea = n, u.xor128 = s, u.xorwow = r, u.xorshift7 = a, u.xor4096 = i, u.tychei = o, t.exports = u; } }); var Ww = zt({ "(disabled):src/node_modules/string_decoder/index.js"() { } }); var tg = zt({ "(disabled):fs"() { } }); var dd = zt({ "(disabled):path"() { } }); var n$ = zt({ "(disabled):worker_threads"() { } }); var s$ = zt({ "(disabled):perf_hooks"() { } }); var r$ = zt({ "(disabled):os"() { } }); var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e, t) { var n = (() => { 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 Ce.buffer != nn && rs(Ce.buffer), ic; } function i() { return Ce.buffer != nn && rs(Ce.buffer), oc; } function o() { return Ce.buffer != nn && rs(Ce.buffer), pu; } function u() { return Ce.buffer != nn && rs(Ce.buffer), uc; } function l() { return Ce.buffer != nn && rs(Ce.buffer), lc; } function c() { return Ce.buffer != nn && rs(Ce.buffer), cc; } function p() { return Ce.buffer != nn && rs(Ce.buffer), dc; } var d = typeof r != "undefined" ? r : {}, h, f; d.ready = new Promise(function(C, D) { h = C, f = D; }); var m; typeof process != "undefined" && process.listeners && (m = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var g = Object.assign({}, d), b = [], y = "./this.program", v = (C, D) => { throw D; }, w = typeof window == "object", k = typeof importScripts == "function", T = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", N = d.ENVIRONMENT_IS_PTHREAD || false, E = ""; function A(C) { return d.locateFile ? d.locateFile(C, E) : E + C; } var P, R, F, $; function z(C) { if (C instanceof wu) return; ee("exiting due to exception: " + C); } var W, q, K; if (T) { k ? E = dd().dirname(E) + "/" : E = __dirname + "/", K = () => { q || (W = tg(), q = dd()); }, P = function(B, Q) { return K(), B = q.normalize(B), W.readFileSync(B, Q ? void 0 : "utf8"); }, F = (D) => { var B = P(D, true); return B.buffer || (B = new Uint8Array(B)), B; }, R = (D, B, Q) => { K(), D = q.normalize(D), W.readFile(D, function(ue, pe) { ue ? Q(ue) : B(pe.buffer); }); }, process.argv.length > 1 && (y = process.argv[1].replace(/\\/g, "/")), b = process.argv.slice(2), process.on("uncaughtException", function(D) { if (!(D instanceof wu)) throw D; }), process.on("unhandledRejection", function(D) { throw D; }), v = (D, B) => { if (Pr()) throw process.exitCode = D, B; z(B), process.exit(D); }, d.inspect = function() { return "[Emscripten Module object]"; }; let C; try { C = n$(); } catch (D) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), D; } global.Worker = C.Worker; } else (w || k) && (k ? E = self.location.href : typeof document != "undefined" && document.currentScript && (E = document.currentScript.src), typeof s != "undefined" && s && (E = s), E.indexOf("blob:") !== 0 ? E = E.substr(0, E.replace(/[?#].*/, "").lastIndexOf("/") + 1) : E = "", T || (P = (C) => { var D = new XMLHttpRequest(); return D.open("GET", C, false), D.send(null), D.responseText; }, k && (F = (C) => { var D = new XMLHttpRequest(); return D.open("GET", C, false), D.responseType = "arraybuffer", D.send(null), new Uint8Array(D.response); }), R = (C, D, B) => { var Q = new XMLHttpRequest(); Q.open("GET", C, true), Q.responseType = "arraybuffer", Q.onload = () => { if (Q.status == 200 || Q.status == 0 && Q.response) { D(Q.response); return; } B(); }, Q.onerror = B, Q.send(null); }), $ = (C) => document.title = C); T && typeof performance == "undefined" && (global.performance = s$().performance); var Y = console.log.bind(console), Z = console.warn.bind(console); T && (K(), Y = (C) => W.writeSync(1, C + ` `), Z = (C) => W.writeSync(2, C + ` `)); var te = d.print || Y, ee = d.printErr || Z; Object.assign(d, g), g = null, d.arguments && (b = d.arguments), d.thisProgram && (y = d.thisProgram), d.quit && (v = d.quit); var se = 4; function ne(C) { ne.shown || (ne.shown = {}), ne.shown[C] || (ne.shown[C] = 1, ee(C)); } function oe(C, D) { if (typeof WebAssembly.Function == "function") { for (var B = { i: "i32", j: "i64", f: "f32", d: "f64" }, Q = { parameters: [], results: D[0] == "v" ? [] : [B[D[0]]] }, ue = 1; ue < D.length; ++ue) Q.parameters.push(B[D[ue]]); return new WebAssembly.Function(Q, C); } var pe = [1, 0, 1, 96], ye = D.slice(0, 1), Te = D.slice(1), bt = { i: 127, j: 126, f: 125, d: 124 }; pe.push(Te.length); for (var ue = 0; ue < Te.length; ++ue) pe.push(bt[Te[ue]]); ye == "v" ? pe.push(0) : pe = pe.concat([1, bt[ye]]), pe[1] = pe.length - 2; var us = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(pe, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), ls = new WebAssembly.Module(us), Bc = new WebAssembly.Instance(ls, { e: { f: C } }), ku = Bc.exports.f; return ku; } var re = [], le; function me() { if (re.length) return re.pop(); try { Fn.grow(1); } catch (C) { throw C instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : C; } return Fn.length - 1; } function we(C, D) { for (var B = C; B < C + D; B++) { var Q = Ti(B); Q && le.set(Q, B); } } var Se = 0, Ee = (C) => { Se = C; }, Pe = Atomics.load, Xe = Atomics.store, Je = Atomics.compareExchange, Ye; d.wasmBinary && (Ye = d.wasmBinary); var tt = d.noExitRuntime || true; typeof WebAssembly != "object" && Si("no native wasm support detected"); var Ce, ut, at = false, Jt; function Nt(C, D) { C || Si(D); } function Cn(C) { var D = d["_" + C]; return D; } function Et(C, D, B, Q, ue) { var pe = { string: function($n) { var Fi = 0; if ($n != null && $n !== 0) { var ex = ($n.length << 2) + 1; Fi = Di(ex), Ls($n, Fi, ex); } return Fi; }, array: function($n) { var Fi = Di($n.length); return Bs($n, Fi), Fi; } }; function ye($n) { return D === "string" ? tn($n) : D === "boolean" ? Boolean($n) : $n; } var Te = Cn(C), bt = [], us = 0; if (Q) for (var ls = 0; ls < Q.length; ls++) { var Bc = pe[B[ls]]; Bc ? (us === 0 && (us = Ef()), bt[ls] = Bc(Q[ls])) : bt[ls] = Q[ls]; } var ku = Te.apply(null, bt); function MT($n) { return us !== 0 && Pc(us), ye($n); } return ku = MT(ku), ku; } function en(C, D, B, Q) { B = B || []; var ue = B.every(function(ye) { return ye === "number"; }), pe = D !== "string"; return pe && ue && !Q ? Cn(C) : function() { return Et(C, D, B, arguments, Q); }; } var Nn = 1; function Tn(C) { var D = new TextDecoder(C); this.decode = (B) => (B.buffer instanceof SharedArrayBuffer && (B = new Uint8Array(B)), D.decode.call(D, B)); } var Yt = typeof TextDecoder != "undefined" ? new Tn("utf8") : void 0; function Dn(C, D, B) { for (var Q = D + B, ue = D; C[ue] && !(ue >= Q); ) ++ue; if (ue - D > 16 && C.subarray && Yt) return Yt.decode(C.subarray(D, ue)); for (var pe = ""; D < ue; ) { var ye = C[D++]; if (!(ye & 128)) { pe += String.fromCharCode(ye); continue; } var Te = C[D++] & 63; if ((ye & 224) == 192) { pe += String.fromCharCode((ye & 31) << 6 | Te); continue; } var bt = C[D++] & 63; if ((ye & 240) == 224 ? ye = (ye & 15) << 12 | Te << 6 | bt : ye = (ye & 7) << 18 | Te << 12 | bt << 6 | C[D++] & 63, ye < 65536) pe += String.fromCharCode(ye); else { var us = ye - 65536; pe += String.fromCharCode(55296 | us >> 10, 56320 | us & 1023); } } return pe; } function tn(C, D) { return C ? Dn(i(), C, D) : ""; } function Ms(C, D, B, Q) { if (!(Q > 0)) return 0; for (var ue = B, pe = B + Q - 1, ye = 0; ye < C.length; ++ye) { var Te = C.charCodeAt(ye); if (Te >= 55296 && Te <= 57343) { var bt = C.charCodeAt(++ye); Te = 65536 + ((Te & 1023) << 10) | bt & 1023; } if (Te <= 127) { if (B >= pe) break; D[B++] = Te; } else if (Te <= 2047) { if (B + 1 >= pe) break; D[B++] = 192 | Te >> 6, D[B++] = 128 | Te & 63; } else if (Te <= 65535) { if (B + 2 >= pe) break; D[B++] = 224 | Te >> 12, D[B++] = 128 | Te >> 6 & 63, D[B++] = 128 | Te & 63; } else { if (B + 3 >= pe) break; D[B++] = 240 | Te >> 18, D[B++] = 128 | Te >> 12 & 63, D[B++] = 128 | Te >> 6 & 63, D[B++] = 128 | Te & 63; } } return D[B] = 0, B - ue; } function Ls(C, D, B) { return Ms(C, i(), D, B); } function wi(C) { for (var D = 0, B = 0; B < C.length; ++B) { var Q = C.charCodeAt(B); Q >= 55296 && Q <= 57343 && (Q = 65536 + ((Q & 1023) << 10) | C.charCodeAt(++B) & 1023), Q <= 127 ? ++D : Q <= 2047 ? D += 2 : Q <= 65535 ? D += 3 : D += 4; } return D; } var Js = typeof TextDecoder != "undefined" ? new Tn("utf-16le") : void 0; function Bs(C, D) { a().set(C, D); } function du(C, D, B) { for (var Q = 0; Q < C.length; ++Q) a()[D++ >> 0] = C.charCodeAt(Q); B || (a()[D >> 0] = 0); } function ki(C, D) { return C % D > 0 && (C += D - C % D), C; } var nn, ic, oc, pu, uc, lc, Fv, cc, dc; N && (nn = d.buffer); function rs(C) { nn = C, d.HEAP8 = ic = new Int8Array(C), d.HEAP16 = pu = new Int16Array(C), d.HEAP32 = lc = new Int32Array(C), d.HEAPU8 = oc = new Uint8Array(C), d.HEAPU16 = uc = new Uint16Array(C), d.HEAPU32 = Fv = new Uint32Array(C), d.HEAPF32 = cc = new Float32Array(C), d.HEAPF64 = dc = new Float64Array(C); } var pc = d.INITIAL_MEMORY || 16777216; if (N) Ce = d.wasmMemory, nn = d.buffer; else if (d.wasmMemory) Ce = d.wasmMemory; else if (Ce = new WebAssembly.Memory({ initial: pc / 65536, maximum: 32768, shared: true }), !(Ce.buffer instanceof SharedArrayBuffer)) throw ee("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"), T && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); Ce && (nn = Ce.buffer), pc = nn.byteLength, rs(nn); var Fn, Ii = [], er = [], th = [], hc = [], Or = false, nh = false, fc = 0; function Pr() { return tt || fc > 0; } function sn() { if (d.preRun) for (typeof d.preRun == "function" && (d.preRun = [d.preRun]); d.preRun.length; ) Ov(d.preRun.shift()); vc(Ii); } function hu() { Or = true, !N && vc(er); } function sh() { N || ($e.terminateAllThreads(), nh = true); } function rh() { if (!N) { if (d.postRun) for (typeof d.postRun == "function" && (d.postRun = [d.postRun]); d.postRun.length; ) fu(d.postRun.shift()); vc(hc); } } function Ov(C) { Ii.unshift(C); } function Pv(C) { er.unshift(C); } function fu(C) { hc.unshift(C); } var tr = 0, mc = null, as = null; function mu(C) { tr++, d.monitorRunDependencies && d.monitorRunDependencies(tr); } function zv(C) { if (tr--, d.monitorRunDependencies && d.monitorRunDependencies(tr), tr == 0 && (mc !== null && (clearInterval(mc), mc = null), as)) { var D = as; as = null, D(); } } d.preloadedImages = {}, d.preloadedAudios = {}; function Si(C) { N ? postMessage({ cmd: "onAbort", arg: C }) : d.onAbort && d.onAbort(C), C = "Aborted(" + C + ")", ee(C), at = true, Jt = 1, C += ". Build with -s ASSERTIONS=1 for more info."; var D = new WebAssembly.RuntimeError(C); throw f(D), D; } var ah = "data:application/octet-stream;base64,"; function gc(C) { return C.startsWith(ah); } function bc(C) { return C.startsWith("file://"); } var rn; rn = "tfjs-backend-wasm-threaded-simd.wasm", gc(rn) || (rn = A(rn)); function yc(C) { try { if (C == rn && Ye) return new Uint8Array(Ye); if (F) return F(C); throw "both async and sync fetching of the wasm failed"; } catch (D) { Si(D); } } function Ci() { if (!Ye && (w || k)) { if (typeof fetch == "function" && !bc(rn)) return fetch(rn, { credentials: "same-origin" }).then(function(C) { if (!C.ok) throw "failed to load wasm binary file at '" + rn + "'"; return C.arrayBuffer(); }).catch(function() { return yc(rn); }); if (R) return new Promise(function(C, D) { R(rn, function(B) { C(new Uint8Array(B)); }, D); }); } return Promise.resolve().then(function() { return yc(rn); }); } function ih() { var C = { env: Ec, wasi_snapshot_preview1: Ec }; function D(ye, Te) { var bt = ye.exports; if (d.asm = bt, hh(d.asm.emscripten_tls_init), Fn = d.asm.__indirect_function_table, Pv(d.asm.__wasm_call_ctors), ut = Te, !N) { var us = $e.unusedWorkers.length; $e.unusedWorkers.forEach(function(ls) { $e.loadWasmModuleToWorker(ls, function() { --us || zv("wasm-instantiate"); }); }); } } N || mu("wasm-instantiate"); function B(ye) { D(ye.instance, ye.module); } function Q(ye) { return Ci().then(function(Te) { return WebAssembly.instantiate(Te, C); }).then(function(Te) { return Te; }).then(ye, function(Te) { ee("failed to asynchronously prepare wasm: " + Te), Si(Te); }); } function ue() { return !Ye && typeof WebAssembly.instantiateStreaming == "function" && !gc(rn) && !bc(rn) && typeof fetch == "function" ? fetch(rn, { credentials: "same-origin" }).then(function(ye) { var Te = WebAssembly.instantiateStreaming(ye, C); return Te.then(B, function(bt) { return ee("wasm streaming compile failed: " + bt), ee("falling back to ArrayBuffer instantiation"), Q(B); }); }) : Q(B); } if (d.instantiateWasm) try { var pe = d.instantiateWasm(C, D); return pe; } catch (ye) { return ee("Module.instantiateWasm callback failed with error: " + ye), false; } return ue().catch(f), {}; } var Mv, Lv, oh = {}; function vc(C) { for (; C.length > 0; ) { var D = C.shift(); if (typeof D == "function") { D(d); continue; } var B = D.func; typeof B == "number" ? D.arg === void 0 ? Ti(B)() : Ti(B)(D.arg) : B(D.arg === void 0 ? null : D.arg); } } function Ni(C) { var D = Ef(), B = C(); return Pc(D), B; } function qN(C) { return C; } function Bv(C) { var D = /\b_Z[\w\d_]+/g; return C.replace(D, function(B) { var Q = B; return B === Q ? B : Q + " [" + B + "]"; }); } function uh(C) { l()[C >> 2] = 0; var D = $e.pthreads[C]; delete $e.pthreads[C], D.worker.terminate(), Af(C), $e.runningWorkers.splice($e.runningWorkers.indexOf(D.worker), 1), D.worker.pthread = void 0; } function lh(C) { var D = $e.pthreads[C]; D.worker.postMessage({ cmd: "cancel" }); } function xc(C) { var D = $e.pthreads[C]; if (D) { l()[C >> 2] = 0; var B = D.worker; $e.returnWorkerToPool(B); } } function wc(C) { OT(C); } function ch(C) { if (C instanceof wu || C == "unwind") return Jt; v(1, C); } var $e = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], init: function() { N ? $e.initWorker() : $e.initMainThread(); }, initMainThread: function() { for (var C = 8, D = 0; D < C; ++D) $e.allocateUnusedWorker(); }, initWorker: function() { tt = false; }, pthreads: {}, setExitStatus: function(C) { Jt = C; }, terminateAllThreads: function() { for (var C in $e.pthreads) { var D = $e.pthreads[C]; D && D.worker && $e.returnWorkerToPool(D.worker); } for (var B = 0; B < $e.unusedWorkers.length; ++B) { var Q = $e.unusedWorkers[B]; Q.terminate(); } $e.unusedWorkers = []; }, returnWorkerToPool: function(C) { $e.runWithoutMainThreadQueuedCalls(function() { delete $e.pthreads[C.pthread.threadInfoStruct], $e.unusedWorkers.push(C), $e.runningWorkers.splice($e.runningWorkers.indexOf(C), 1), Af(C.pthread.threadInfoStruct), C.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(C) { l()[Jv >> 2] = 0; try { C(); } finally { l()[Jv >> 2] = 1; } }, receiveObjectTransfer: function(C) { }, threadInit: function() { for (var C in $e.tlsInitFunctions) $e.tlsInitFunctions[C](); }, loadWasmModuleToWorker: function(C, D) { C.onmessage = (B) => { var Q = B.data, ue = Q.cmd; if (C.pthread && ($e.currentProxiedOperationCallerThread = C.pthread.threadInfoStruct), Q.targetThread && Q.targetThread != Oc()) { var pe = $e.pthreads[Q.targetThread]; pe ? pe.worker.postMessage(Q, Q.transferList) : ee('Internal error! Worker sent a message "' + ue + '" to target pthread ' + Q.targetThread + ", but that thread no longer exists!"), $e.currentProxiedOperationCallerThread = void 0; return; } ue === "processQueuedMainThreadWork" ? Kv() : ue === "spawnThread" ? Ic(Q) : ue === "cleanupThread" ? xc(Q.thread) : ue === "killThread" ? uh(Q.thread) : ue === "cancelThread" ? lh(Q.thread) : ue === "loaded" ? (C.loaded = true, D && D(C), C.runPthread && (C.runPthread(), delete C.runPthread)) : ue === "print" ? te("Thread " + Q.threadId + ": " + Q.text) : ue === "printErr" ? ee("Thread " + Q.threadId + ": " + Q.text) : ue === "alert" ? alert("Thread " + Q.threadId + ": " + Q.text) : Q.target === "setimmediate" ? C.postMessage(Q) : ue === "onAbort" ? d.onAbort && d.onAbort(Q.arg) : ee("worker sent an unknown command " + ue), $e.currentProxiedOperationCallerThread = void 0; }, C.onerror = (B) => { var Q = "worker sent an error!"; throw ee(Q + " " + B.filename + ":" + B.lineno + ": " + B.message), B; }, T && (C.on("message", function(B) { C.onmessage({ data: B }); }), C.on("error", function(B) { C.onerror(B); }), C.on("detachedExit", function() { })), C.postMessage({ cmd: "load", urlOrBlob: d.mainScriptUrlOrBlob || s, wasmMemory: Ce, wasmModule: ut }); }, allocateUnusedWorker: function() { var C = A("tfjs-backend-wasm-threaded-simd.worker.js"); $e.unusedWorkers.push(new Worker(C)); }, getNewWorker: function() { return $e.unusedWorkers.length == 0 && ($e.allocateUnusedWorker(), $e.loadWasmModuleToWorker($e.unusedWorkers[0])), $e.unusedWorkers.pop(); } }; function dh() { var C = Oc(), D = l()[C + 44 >> 2], B = l()[C + 48 >> 2], Q = D - B; Zv(D, Q), Pc(D); } d.establishStackSpace = dh; function kc(C) { if (N) return Lr(1, 0, C); try { wc(C); } catch (D) { ch(D); } } var zr = []; function Ti(C) { var D = zr[C]; return D || (C >= zr.length && (zr.length = C + 1), zr[C] = D = Fn.get(C)), D; } function ph(C, D) { return Ti(C)(D); } d.invokeEntryPoint = ph; function Vv() { var C = new Error(); if (!C.stack) { try { throw new Error(); } catch (D) { C = D; } if (!C.stack) return "(no stack trace available)"; } return C.stack.toString(); } function hh(C, D, B) { $e.tlsInitFunctions.push(C); } function Wv(C, D) { Fn.set(C, D), zr[C] = D; } var Mr; T ? Mr = () => { var C = process.hrtime(); return C[0] * 1e3 + C[1] / 1e6; } : N ? Mr = () => performance.now() - d.__performance_now_clock_drift : Mr = () => performance.now(); var fh = true; function mh(C) { return l()[jv() >> 2] = C, C; } function gh(C, D) { var B; if (C === 0) B = Date.now(); else if ((C === 1 || C === 4) && fh) B = Mr(); else return mh(28), -1; return l()[D >> 2] = B / 1e3 | 0, l()[D + 4 >> 2] = B % 1e3 * 1e3 * 1e3 | 0, 0; } function bh(C, D) { return gh(C, D); } function yh(C) { Xv(C, !k, 1, !w), $e.threadInit(); } function vh(C) { N ? postMessage({ cmd: "cleanupThread", thread: C }) : xc(C); } function Ic(C) { var D = $e.getNewWorker(); if (!D) return 6; $e.runningWorkers.push(D); var B = $e.pthreads[C.pthread_ptr] = { worker: D, threadInfoStruct: C.pthread_ptr }; D.pthread = B; var Q = { cmd: "run", start_routine: C.startRoutine, arg: C.arg, threadInfoStruct: C.pthread_ptr }; return D.runPthread = () => { Q.time = performance.now(), D.postMessage(Q, C.transferList); }, D.loaded && (D.runPthread(), delete D.runPthread), 0; } function xh(C, D, B, Q) { if (typeof SharedArrayBuffer == "undefined") return ee("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; var ue = [], pe = 0; if (N && (ue.length === 0 || pe)) return Yv(687865856, C, D, B, Q); if (pe) return pe; var ye = { startRoutine: B, pthread_ptr: C, arg: Q, transferList: ue }; return N ? (ye.cmd = "spawnThread", postMessage(ye, ue), 0) : Ic(ye); } function wh() { return 2097152; } function kh(C, D) { if (C == D) postMessage({ cmd: "processQueuedMainThreadWork" }); else if (N) postMessage({ targetThread: C, cmd: "processThreadQueue" }); else { var B = $e.pthreads[C], Q = B && B.worker; if (!Q) return; Q.postMessage({ cmd: "processThreadQueue" }); } return 1; } function Ih() { Si(""); } function Sh() { T || k || ne("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); } function Sc() { return 2147483648; } function Ch(C, D, B) { i().copyWithin(C, D, D + B); } function Nh() { return T ? r$().cpus().length : navigator.hardwareConcurrency; } function Lr(C, D) { var B = arguments.length - 2, Q = arguments; return Ni(function() { for (var ue = B, pe = Di(ue * 8), ye = pe >> 3, Te = 0; Te < B; Te++) { var bt = Q[2 + Te]; p()[ye + Te] = bt; } return Qv(C, ue, pe, D); }); } var gu = []; function Th(C, D, B) { gu.length = D; for (var Q = B >> 3, ue = 0; ue < D; ue++) gu[ue] = p()[Q + ue]; var pe = C < 0, ye = pe ? oh[-C - 1] : qh[C]; return ye.apply(null, gu); } function $h(C) { try { return Ce.grow(C - nn.byteLength + 65535 >>> 16), rs(Ce.buffer), 1; } catch (D) { } } function _h(C) { var D = i().length; if (C = C >>> 0, C <= D) return false; var B = Sc(); if (C > B) return false; for (var Q = 1; Q <= 4; Q *= 2) { var ue = D * (1 + 0.2 / Q); ue = Math.min(ue, C + 100663296); var pe = Math.min(B, ki(Math.max(C, ue), 65536)), ye = $h(pe); if (ye) return true; } return false; } var Le = { inEventHandler: 0, removeAllEventListeners: function() { for (var C = Le.eventHandlers.length - 1; C >= 0; --C) Le._removeHandler(C); Le.eventHandlers = [], Le.deferredCalls = []; }, registerRemoveEventListeners: function() { Le.removeEventListenersRegistered || (th.push(Le.removeAllEventListeners), Le.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(C, D, B) { function Q(ye, Te) { if (ye.length != Te.length) return false; for (var bt in ye) if (ye[bt] != Te[bt]) return false; return true; } for (var ue in Le.deferredCalls) { var pe = Le.deferredCalls[ue]; if (pe.targetFunction == C && Q(pe.argsList, B)) return; } Le.deferredCalls.push({ targetFunction: C, precedence: D, argsList: B }), Le.deferredCalls.sort(function(ye, Te) { return ye.precedence < Te.precedence; }); }, removeDeferredCalls: function(C) { for (var D = 0; D < Le.deferredCalls.length; ++D) Le.deferredCalls[D].targetFunction == C && (Le.deferredCalls.splice(D, 1), --D); }, canPerformEventHandlerRequests: function() { return Le.inEventHandler && Le.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { if (!!Le.canPerformEventHandlerRequests()) for (var C = 0; C < Le.deferredCalls.length; ++C) { var D = Le.deferredCalls[C]; Le.deferredCalls.splice(C, 1), --C, D.targetFunction.apply(null, D.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(C, D) { for (var B = 0; B < Le.eventHandlers.length; ++B) Le.eventHandlers[B].target == C && (!D || D == Le.eventHandlers[B].eventTypeString) && Le._removeHandler(B--); }, _removeHandler: function(C) { var D = Le.eventHandlers[C]; D.target.removeEventListener(D.eventTypeString, D.eventListenerFunc, D.useCapture), Le.eventHandlers.splice(C, 1); }, registerOrRemoveHandler: function(C) { var D = function(ue) { ++Le.inEventHandler, Le.currentEventHandler = C, Le.runDeferredCalls(), C.handlerFunc(ue), Le.runDeferredCalls(), --Le.inEventHandler; }; if (C.callbackfunc) C.eventListenerFunc = D, C.target.addEventListener(C.eventTypeString, D, C.useCapture), Le.eventHandlers.push(C), Le.registerRemoveEventListeners(); else for (var B = 0; B < Le.eventHandlers.length; ++B) Le.eventHandlers[B].target == C.target && Le.eventHandlers[B].eventTypeString == C.eventTypeString && Le._removeHandler(B--); }, queueEventHandlerOnThread_iiii: function(C, D, B, Q, ue) { Ni(function() { var pe = Di(12); l()[pe >> 2] = B, l()[pe + 4 >> 2] = Q, l()[pe + 8 >> 2] = ue, _f(C, 637534208, D, Q, pe); }); }, getTargetThreadForEventCallback: function(C) { switch (C) { case 1: return 0; case 2: return $e.currentProxiedOperationCallerThread; default: return C; } }, getNodeNameForTarget: function(C) { return C ? C == window ? "#window" : C == screen ? "#screen" : C && C.nodeName ? C.nodeName : "" : ""; }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; function Ah(C) { var D = wi(C) + 1, B = $f(D); return Ls(C, B, D), B; } function Eh(C, D, B, Q) { Ni(function() { var ue = Di(12), pe = 0; D && (pe = Ah(D)), l()[ue >> 2] = pe, l()[ue + 4 >> 2] = B, l()[ue + 8 >> 2] = Q, _f(C, 657457152, 0, pe, ue); }); } function Rh(C, D, B, Q) { D = D ? tn(D) : "", Eh(C, D, B, Q); } function Dh(C) { return C > 2 ? tn(C) : C; } var Fh = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; function Oh(C) { C = Dh(C); var D = Fh[C] || (typeof document != "undefined" ? document.querySelector(C) : void 0); return D; } function bu(C) { return Oh(C); } function Cc(C, D, B) { var Q = bu(C); if (!Q) return -4; if (Q.canvasSharedPtr && (l()[Q.canvasSharedPtr >> 2] = D, l()[Q.canvasSharedPtr + 4 >> 2] = B), Q.offscreenCanvas || !Q.controlTransferredOffscreen) { Q.offscreenCanvas && (Q = Q.offscreenCanvas); var ue = false; if (Q.GLctxObject && Q.GLctxObject.GLctx) { var pe = Q.GLctxObject.GLctx.getParameter(2978); ue = pe[0] === 0 && pe[1] === 0 && pe[2] === Q.width && pe[3] === Q.height; } Q.width = D, Q.height = B, ue && Q.GLctxObject.GLctx.viewport(0, 0, D, B); } else if (Q.canvasSharedPtr) { var ye = l()[Q.canvasSharedPtr + 8 >> 2]; return Rh(ye, C, D, B), 1; } else return -4; return 0; } function Nc(C, D, B) { return N ? Lr(2, 1, C, D, B) : Cc(C, D, B); } function Ph(C, D, B) { var Q = bu(C); return Q ? Cc(C, D, B) : Nc(C, D, B); } function zh() { throw "unwind"; } function Mh(C) { var D = C.getExtension("ANGLE_instanced_arrays"); if (D) return C.vertexAttribDivisor = function(B, Q) { D.vertexAttribDivisorANGLE(B, Q); }, C.drawArraysInstanced = function(B, Q, ue, pe) { D.drawArraysInstancedANGLE(B, Q, ue, pe); }, C.drawElementsInstanced = function(B, Q, ue, pe, ye) { D.drawElementsInstancedANGLE(B, Q, ue, pe, ye); }, 1; } function Lh(C) { var D = C.getExtension("OES_vertex_array_object"); if (D) return C.createVertexArray = function() { return D.createVertexArrayOES(); }, C.deleteVertexArray = function(B) { D.deleteVertexArrayOES(B); }, C.bindVertexArray = function(B) { D.bindVertexArrayOES(B); }, C.isVertexArray = function(B) { return D.isVertexArrayOES(B); }, 1; } function Bh(C) { var D = C.getExtension("WEBGL_draw_buffers"); if (D) return C.drawBuffers = function(B, Q) { D.drawBuffersWEBGL(B, Q); }, 1; } function Vh(C) { return !!(C.multiDrawWebgl = C.getExtension("WEBGL_multi_draw")); } var gt = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, queries: [], stringCache: {}, unpackAlignment: 4, recordError: function(D) { gt.lastError || (gt.lastError = D); }, getNewId: function(C) { for (var D = gt.counter++, B = C.length; B < D; B++) C[B] = null; return D; }, getSource: function(C, D, B, Q) { for (var ue = "", pe = 0; pe < D; ++pe) { var ye = Q ? l()[Q + pe * 4 >> 2] : -1; ue += tn(l()[B + pe * 4 >> 2], ye < 0 ? void 0 : ye); } return ue; }, createContext: function(C, D) { C.getContextSafariWebGL2Fixed || (C.getContextSafariWebGL2Fixed = C.getContext, C.getContext = function(ue, pe) { var ye = C.getContextSafariWebGL2Fixed(ue, pe); return ue == "webgl" == ye instanceof WebGLRenderingContext ? ye : null; }); var B = C.getContext("webgl", D); if (!B) return 0; var Q = gt.registerContext(B, D); return Q; }, registerContext: function(C, D) { var B = $f(8); l()[B + 4 >> 2] = Oc(); var Q = { handle: B, attributes: D, version: D.majorVersion, GLctx: C }; return C.canvas && (C.canvas.GLctxObject = Q), gt.contexts[B] = Q, (typeof D.enableExtensionsByDefault == "undefined" || D.enableExtensionsByDefault) && gt.initExtensions(Q), B; }, makeContextCurrent: function(C) { return gt.currentContext = gt.contexts[C], d.ctx = Ac = gt.currentContext && gt.currentContext.GLctx, !(C && !Ac); }, getContext: function(C) { return gt.contexts[C]; }, deleteContext: function(C) { gt.currentContext === gt.contexts[C] && (gt.currentContext = null), typeof Le == "object" && Le.removeAllHandlersOnTarget(gt.contexts[C].GLctx.canvas), gt.contexts[C] && gt.contexts[C].GLctx.canvas && (gt.contexts[C].GLctx.canvas.GLctxObject = void 0), qv(gt.contexts[C].handle), gt.contexts[C] = null; }, initExtensions: function(C) { if (C || (C = gt.currentContext), !C.initExtensionsDone) { C.initExtensionsDone = true; var D = C.GLctx; Mh(D), Lh(D), Bh(D), D.disjointTimerQueryExt = D.getExtension("EXT_disjoint_timer_query"), Vh(D); var B = D.getSupportedExtensions() || []; B.forEach(function(Q) { !Q.includes("lose_context") && !Q.includes("debug") && D.getExtension(Q); }); } } }, Wh = ["default", "low-power", "high-performance"]; function Uh(C, D) { var B = D >> 2, Q = l()[B + 6], ue = { alpha: !!l()[B + 0], depth: !!l()[B + 1], stencil: !!l()[B + 2], antialias: !!l()[B + 3], premultipliedAlpha: !!l()[B + 4], preserveDrawingBuffer: !!l()[B + 5], powerPreference: Wh[Q], failIfMajorPerformanceCaveat: !!l()[B + 7], majorVersion: l()[B + 8], minorVersion: l()[B + 9], enableExtensionsByDefault: l()[B + 10], explicitSwapControl: l()[B + 11], proxyContextToMainThread: l()[B + 12], renderViaOffscreenBackBuffer: l()[B + 13] }, pe = bu(C); if (!pe || ue.explicitSwapControl) return 0; var ye = gt.createContext(pe, ue); return ye; } function Gh(C, D) { return Uh(C, D); } var $i = { mappings: {}, buffers: [null, [], []], printChar: function(C, D) { var B = $i.buffers[C]; D === 0 || D === 10 ? ((C === 1 ? te : ee)(Dn(B, 0)), B.length = 0) : B.push(D); }, varargs: void 0, get: function() { $i.varargs += 4; var C = l()[$i.varargs - 4 >> 2]; return C; }, getStr: function(C) { var D = tn(C); return D; }, get64: function(C, D) { return C; } }; function Tc(C) { return N ? Lr(3, 1, C) : 0; } function $c(C, D, B, Q, ue) { if (N) return Lr(4, 1, C, D, B, Q, ue); } function _c(C, D, B, Q) { if (N) return Lr(5, 1, C, D, B, Q); for (var ue = 0, pe = 0; pe < B; pe++) { var ye = l()[D >> 2], Te = l()[D + 4 >> 2]; D += 8; for (var bt = 0; bt < Te; bt++) $i.printChar(C, i()[ye + bt]); ue += Te; } return l()[Q >> 2] = ue, 0; } function Hh(C) { Ee(C); } $e.init(); var Ac, qh = [null, kc, Nc, Tc, $c, _c], Uv = false, Ec = { __clock_gettime: bh, __emscripten_init_main_thread_js: yh, __emscripten_thread_cleanup: vh, __pthread_create_js: xh, _emscripten_default_pthread_stack_size: wh, _emscripten_notify_thread_queue: kh, abort: Ih, emscripten_check_blocking_allowed: Sh, emscripten_get_heap_max: Sc, emscripten_get_now: Mr, emscripten_memcpy_big: Ch, emscripten_num_logical_cores: Nh, emscripten_receive_on_main_thread_js: Th, emscripten_resize_heap: _h, emscripten_set_canvas_element_size: Ph, emscripten_unwind_to_js_event_loop: zh, emscripten_webgl_create_context: Gh, exit: wc, fd_close: Tc, fd_seek: $c, fd_write: _c, memory: Ce || d.wasmMemory, setTempRet0: Hh }, Gv = ih(), jh = d.___wasm_call_ctors = function() { return (jh = d.___wasm_call_ctors = d.asm.__wasm_call_ctors).apply(null, arguments); }, Kh = d._init = function() { return (Kh = d._init = d.asm.init).apply(null, arguments); }, Xh = d._init_with_threads_count = function() { return (Xh = d._init_with_threads_count = d.asm.init_with_threads_count).apply(null, arguments); }, Yh = d._get_threads_count = function() { return (Yh = d._get_threads_count = d.asm.get_threads_count).apply(null, arguments); }, Qh = d._register_tensor = function() { return (Qh = d._register_tensor = d.asm.register_tensor).apply(null, arguments); }, Zh = d._dispose_data = function() { return (Zh = d._dispose_data = d.asm.dispose_data).apply(null, arguments); }, Jh = d._dispose = function() { return (Jh = d._dispose = d.asm.dispose).apply(null, arguments); }, ef = d._Abs = function() { return (ef = d._Abs = d.asm.Abs).apply(null, arguments); }, tf = d._Add = function() { return (tf = d._Add = d.asm.Add).apply(null, arguments); }, nf = d._AddN = function() { return (nf = d._AddN = d.asm.AddN).apply(null, arguments); }, sf = d._All = function() { return (sf = d._All = d.asm.All).apply(null, arguments); }, rf = d._Any = function() { return (rf = d._Any = d.asm.Any).apply(null, arguments); }, af = d._ArgMax = function() { return (af = d._ArgMax = d.asm.ArgMax).apply(null, arguments); }, of = d._AvgPool = function() { return (of = d._AvgPool = d.asm.AvgPool).apply(null, arguments); }, uf = d._BatchMatMul = function() { return (uf = d._BatchMatMul = d.asm.BatchMatMul).apply(null, arguments); }, lf = d._Ceil = function() { return (lf = d._Ceil = d.asm.Ceil).apply(null, arguments); }, cf = d._ClipByValue = function() { return (cf = d._ClipByValue = d.asm.ClipByValue).apply(null, arguments); }, df = d._Conv2D = function() { return (df = d._Conv2D = d.asm.Conv2D).apply(null, arguments); }, pf = d._Conv2DBackpropInput = function() { return (pf = d._Conv2DBackpropInput = d.asm.Conv2DBackpropInput).apply(null, arguments); }, hf = d._Cos = function() { return (hf = d._Cos = d.asm.Cos).apply(null, arguments); }, ff = d._Cosh = function() { return (ff = d._Cosh = d.asm.Cosh).apply(null, arguments); }, mf = d._CropAndResize = function() { return (mf = d._CropAndResize = d.asm.CropAndResize).apply(null, arguments); }, gf = d._Cumprod = function() { return (gf = d._Cumprod = d.asm.Cumprod).apply(null, arguments); }, bf = d._Cumsum = function() { return (bf = d._Cumsum = d.asm.Cumsum).apply(null, arguments); }, yf = d._DepthToSpace = function() { return (yf = d._DepthToSpace = d.asm.DepthToSpace).apply(null, arguments); }, vf = d._DepthwiseConv2dNative = function() { return (vf = d._DepthwiseConv2dNative = d.asm.DepthwiseConv2dNative).apply(null, arguments); }, xf = d._Elu = function() { return (xf = d._Elu = d.asm.Elu).apply(null, arguments); }, wf = d._Equal = function() { return (wf = d._Equal = d.asm.Equal).apply(null, arguments); }, kf = d._Exp = function() { return (kf = d._Exp = d.asm.Exp).apply(null, arguments); }, If = d._FlipLeftRight = function() { return (If = d._FlipLeftRight = d.asm.FlipLeftRight).apply(null, arguments); }, Rc = d._Floor = function() { return (Rc = d._Floor = d.asm.Floor).apply(null, arguments); }, Dc = d._FloorDiv = function() { return (Dc = d._FloorDiv = d.asm.FloorDiv).apply(null, arguments); }, yu = d._FusedBatchNorm = function() { return (yu = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); }, Sf = d._FusedConv2D = function() { return (Sf = d._FusedConv2D = d.asm.FusedConv2D).apply(null, arguments); }, Cf = d._FusedDepthwiseConv2D = function() { return (Cf = d._FusedDepthwiseConv2D = d.asm.FusedDepthwiseConv2D).apply(null, arguments); }, _i = d._Gather = function() { return (_i = d._Gather = d.asm.Gather).apply(null, arguments); }, vu = d._GatherNd = function() { return (vu = d._GatherNd = d.asm.GatherNd).apply(null, arguments); }, xu = d._Greater = function() { return (xu = d._Greater = d.asm.Greater).apply(null, arguments); }, Hv = d._GreaterEqual = function() { return (Hv = d._GreaterEqual = d.asm.GreaterEqual).apply(null, arguments); }, Ai = d._LeakyRelu = function() { return (Ai = d._LeakyRelu = d.asm.LeakyRelu).apply(null, arguments); }, Ei = d._Less = function() { return (Ei = d._Less = d.asm.Less).apply(null, arguments); }, Nf = d._LessEqual = function() { return (Nf = d._LessEqual = d.asm.LessEqual).apply(null, arguments); }, H = d._Log = function() { return (H = d._Log = d.asm.Log).apply(null, arguments); }, J = d._LogicalAnd = function() { return (J = d._LogicalAnd = d.asm.LogicalAnd).apply(null, arguments); }, de = d._Max = function() { return (de = d._Max = d.asm.Max).apply(null, arguments); }, ke = d._MaxPool = function() { return (ke = d._MaxPool = d.asm.MaxPool).apply(null, arguments); }, Qe = d._Maximum = function() { return (Qe = d._Maximum = d.asm.Maximum).apply(null, arguments); }, Ze = d._Mean = function() { return (Ze = d._Mean = d.asm.Mean).apply(null, arguments); }, Ve = d._Min = function() { return (Ve = d._Min = d.asm.Min).apply(null, arguments); }, ze = d._Minimum = function() { return (ze = d._Minimum = d.asm.Minimum).apply(null, arguments); }, Tt = d._MirrorPad = function() { return (Tt = d._MirrorPad = d.asm.MirrorPad).apply(null, arguments); }, is = d._Multiply = function() { return (is = d._Multiply = d.asm.Multiply).apply(null, arguments); }, os = d._Neg = function() { return (os = d._Neg = d.asm.Neg).apply(null, arguments); }, Ri = d._NonMaxSuppressionV3 = function() { return (Ri = d._NonMaxSuppressionV3 = d.asm.NonMaxSuppressionV3).apply(null, arguments); }, Br = d._NonMaxSuppressionV4 = function() { return (Br = d._NonMaxSuppressionV4 = d.asm.NonMaxSuppressionV4).apply(null, arguments); }, Tf = d._NonMaxSuppressionV5 = function() { return (Tf = d._NonMaxSuppressionV5 = d.asm.NonMaxSuppressionV5).apply(null, arguments); }, an = d._NotEqual = function() { return (an = d._NotEqual = d.asm.NotEqual).apply(null, arguments); }, nr = d._OneHot = function() { return (nr = d._OneHot = d.asm.OneHot).apply(null, arguments); }, Fc = d._PadV2 = function() { return (Fc = d._PadV2 = d.asm.PadV2).apply(null, arguments); }, jN = d._Pow = function() { return (jN = d._Pow = d.asm.Pow).apply(null, arguments); }, KN = d._Prelu = function() { return (KN = d._Prelu = d.asm.Prelu).apply(null, arguments); }, XN = d._Prod = function() { return (XN = d._Prod = d.asm.Prod).apply(null, arguments); }, YN = d._RealDiv = function() { return (YN = d._RealDiv = d.asm.RealDiv).apply(null, arguments); }, QN = d._Relu = function() { return (QN = d._Relu = d.asm.Relu).apply(null, arguments); }, ZN = d._Relu6 = function() { return (ZN = d._Relu6 = d.asm.Relu6).apply(null, arguments); }, JN = d._ResizeBilinear = function() { return (JN = d._ResizeBilinear = d.asm.ResizeBilinear).apply(null, arguments); }, eT = d._Reverse = function() { return (eT = d._Reverse = d.asm.Reverse).apply(null, arguments); }, tT = d._RotateWithOffset = function() { return (tT = d._RotateWithOffset = d.asm.RotateWithOffset).apply(null, arguments); }, nT = d._Round = function() { return (nT = d._Round = d.asm.Round).apply(null, arguments); }, sT = d._Rsqrt = function() { return (sT = d._Rsqrt = d.asm.Rsqrt).apply(null, arguments); }, rT = d._ScatterNd = function() { return (rT = d._ScatterNd = d.asm.ScatterNd).apply(null, arguments); }, aT = d._SelectV2 = function() { return (aT = d._SelectV2 = d.asm.SelectV2).apply(null, arguments); }, iT = d._Sigmoid = function() { return (iT = d._Sigmoid = d.asm.Sigmoid).apply(null, arguments); }, oT = d._Sin = function() { return (oT = d._Sin = d.asm.Sin).apply(null, arguments); }, uT = d._Softmax = function() { return (uT = d._Softmax = d.asm.Softmax).apply(null, arguments); }, lT = d._SparseFillEmptyRows = function() { return (lT = d._SparseFillEmptyRows = d.asm.SparseFillEmptyRows).apply(null, arguments); }, cT = d._SparseReshape = function() { return (cT = d._SparseReshape = d.asm.SparseReshape).apply(null, arguments); }, dT = d._SparseSegmentReduction = function() { return (dT = d._SparseSegmentReduction = d.asm.SparseSegmentReduction).apply(null, arguments); }, pT = d._Sqrt = function() { return (pT = d._Sqrt = d.asm.Sqrt).apply(null, arguments); }, hT = d._Square = function() { return (hT = d._Square = d.asm.Square).apply(null, arguments); }, fT = d._SquaredDifference = function() { return (fT = d._SquaredDifference = d.asm.SquaredDifference).apply(null, arguments); }, mT = d._Step = function() { return (mT = d._Step = d.asm.Step).apply(null, arguments); }, gT = d._StridedSlice = function() { return (gT = d._StridedSlice = d.asm.StridedSlice).apply(null, arguments); }, bT = d._Sub = function() { return (bT = d._Sub = d.asm.Sub).apply(null, arguments); }, yT = d._Sum = function() { return (yT = d._Sum = d.asm.Sum).apply(null, arguments); }, vT = d._Tan = function() { return (vT = d._Tan = d.asm.Tan).apply(null, arguments); }, xT = d._Tanh = function() { return (xT = d._Tanh = d.asm.Tanh).apply(null, arguments); }, wT = d._Tile = function() { return (wT = d._Tile = d.asm.Tile).apply(null, arguments); }, kT = d._TopK = function() { return (kT = d._TopK = d.asm.TopK).apply(null, arguments); }, IT = d._Transform = function() { return (IT = d._Transform = d.asm.Transform).apply(null, arguments); }, ST = d._Transpose = function() { return (ST = d._Transpose = d.asm.Transpose).apply(null, arguments); }, CT = d.__FusedMatMul = function() { return (CT = d.__FusedMatMul = d.asm._FusedMatMul).apply(null, arguments); }, $f = d._malloc = function() { return ($f = d._malloc = d.asm.malloc).apply(null, arguments); }, qv = d._free = function() { return (qv = d._free = d.asm.free).apply(null, arguments); }, NT = d._emscripten_tls_init = function() { return (NT = d._emscripten_tls_init = d.asm.emscripten_tls_init).apply(null, arguments); }, jv = d.___errno_location = function() { return (jv = d.___errno_location = d.asm.__errno_location).apply(null, arguments); }, Oc = d._pthread_self = function() { return (Oc = d._pthread_self = d.asm.pthread_self).apply(null, arguments); }, Kv = d._emscripten_main_thread_process_queued_calls = function() { return (Kv = d._emscripten_main_thread_process_queued_calls = d.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); }, TT = d.__emscripten_thread_crashed = function() { return (TT = d.__emscripten_thread_crashed = d.asm._emscripten_thread_crashed).apply(null, arguments); }, Xv = d.__emscripten_thread_init = function() { return (Xv = d.__emscripten_thread_init = d.asm._emscripten_thread_init).apply(null, arguments); }, $T = d._emscripten_current_thread_process_queued_calls = function() { return ($T = d._emscripten_current_thread_process_queued_calls = d.asm.emscripten_current_thread_process_queued_calls).apply(null, arguments); }, _T = d._emscripten_main_browser_thread_id = function() { return (_T = d._emscripten_main_browser_thread_id = d.asm.emscripten_main_browser_thread_id).apply(null, arguments); }, AT = d._emscripten_sync_run_in_main_thread_2 = function() { return (AT = d._emscripten_sync_run_in_main_thread_2 = d.asm.emscripten_sync_run_in_main_thread_2).apply(null, arguments); }, Yv = d._emscripten_sync_run_in_main_thread_4 = function() { return (Yv = d._emscripten_sync_run_in_main_thread_4 = d.asm.emscripten_sync_run_in_main_thread_4).apply(null, arguments); }, Qv = d._emscripten_run_in_main_runtime_thread_js = function() { return (Qv = d._emscripten_run_in_main_runtime_thread_js = d.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments); }, _f = d._emscripten_dispatch_to_thread_ = function() { return (_f = d._emscripten_dispatch_to_thread_ = d.asm.emscripten_dispatch_to_thread_).apply(null, arguments); }, Af = d.__emscripten_thread_free_data = function() { return (Af = d.__emscripten_thread_free_data = d.asm._emscripten_thread_free_data).apply(null, arguments); }, ET = d.__emscripten_thread_exit = function() { return (ET = d.__emscripten_thread_exit = d.asm._emscripten_thread_exit).apply(null, arguments); }, RT = d._memalign = function() { return (RT = d._memalign = d.asm.memalign).apply(null, arguments); }, Zv = d._emscripten_stack_set_limits = function() { return (Zv = d._emscripten_stack_set_limits = d.asm.emscripten_stack_set_limits).apply(null, arguments); }, Ef = d.stackSave = function() { return (Ef = d.stackSave = d.asm.stackSave).apply(null, arguments); }, Pc = d.stackRestore = function() { return (Pc = d.stackRestore = d.asm.stackRestore).apply(null, arguments); }, Di = d.stackAlloc = function() { return (Di = d.stackAlloc = d.asm.stackAlloc).apply(null, arguments); }, DT = d.dynCall_iijjiiii = function() { return (DT = d.dynCall_iijjiiii = d.asm.dynCall_iijjiiii).apply(null, arguments); }, FT = d.dynCall_jiji = function() { return (FT = d.dynCall_jiji = d.asm.dynCall_jiji).apply(null, arguments); }, Jv = d.__emscripten_allow_main_runtime_queued_calls = 21456; d.cwrap = en, d.keepRuntimeAlive = Pr, d.PThread = $e, d.PThread = $e, d.wasmMemory = Ce, d.ExitStatus = wu; var zc; function wu(C) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + C + ")", this.status = C; } as = function C() { zc || Rf(), zc || (as = C); }; function Rf(C) { if (C = C || b, tr > 0) return; if (N) { h(d), hu(), postMessage({ cmd: "loaded" }); return; } if (sn(), tr > 0) return; function D() { zc || (zc = true, d.calledRun = true, !at && (hu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), rh())); } d.setStatus ? (d.setStatus("Running..."), setTimeout(function() { setTimeout(function() { d.setStatus(""); }, 1), D(); }, 1)) : D(); } d.run = Rf; function OT(C, D) { if (Jt = C, !D && N) throw kc(C), "unwind"; Pr() || sh(), PT(C); } function PT(C) { Jt = C, Pr() || ($e.terminateAllThreads(), d.onExit && d.onExit(C), at = true), v(C, new wu(C)); } if (d.preInit) for (typeof d.preInit == "function" && (d.preInit = [d.preInit]); d.preInit.length > 0; ) d.preInit.pop()(); Rf(); var Mc; m && (Mc = { uncaughtException: process.listeners("uncaughtException").filter(function(C) { return !m.uncaughtException.indexOf(C) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(C) { return !m.unhandledRejection.indexOf(C) > -1; }) }); var Lc; if (typeof WasmBackendModule != "undefined") Lc = WasmBackendModule; else if (typeof r != "undefined") Lc = r; else throw new Error("Could not find wasm module in post.js"); if (Mc) { var zT = Lc._dispose; Lc._dispose = function() { zT(), Mc.uncaughtException.forEach(function(C) { process.removeListener("uncaughtException", C); }), Mc.unhandledRejection.forEach(function(C) { process.removeListener("unhandledRejection", C); }); }; } 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 i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { var n = (() => { 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(H, J) { i = H, o = J; }); var u; typeof process != "undefined" && process.listeners && (u = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var l = Object.assign({}, a), c = [], p = "./this.program", d = (H, J) => { throw J; }, h = typeof window == "object", f = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", g = ""; function b(H) { return a.locateFile ? a.locateFile(H, g) : g + H; } var y, v, w, k; function T(H) { if (H instanceof vu) return; R("exiting due to exception: " + H); } var N, E, A; m ? (f ? g = dd().dirname(g) + "/" : g = __dirname + "/", A = () => { E || (N = tg(), E = dd()); }, y = function(J, de) { return A(), J = E.normalize(J), N.readFileSync(J, de ? void 0 : "utf8"); }, w = (H) => { var J = y(H, true); return J.buffer || (J = new Uint8Array(J)), J; }, v = (H, J, de) => { A(), H = E.normalize(H), N.readFile(H, function(ke, Qe) { ke ? de(ke) : J(Qe.buffer); }); }, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), c = process.argv.slice(2), process.on("uncaughtException", function(H) { if (!(H instanceof vu)) throw H; }), process.on("unhandledRejection", function(H) { throw H; }), d = (H, J) => { if (pu()) throw process.exitCode = H, J; T(J), process.exit(H); }, a.inspect = function() { return "[Emscripten Module object]"; }) : (h || f) && (f ? g = self.location.href : typeof document != "undefined" && document.currentScript && (g = document.currentScript.src), s && (g = s), g.indexOf("blob:") !== 0 ? g = g.substr(0, g.replace(/[?#].*/, "").lastIndexOf("/") + 1) : g = "", y = (H) => { var J = new XMLHttpRequest(); return J.open("GET", H, false), J.send(null), J.responseText; }, f && (w = (H) => { var J = new XMLHttpRequest(); return J.open("GET", H, false), J.responseType = "arraybuffer", J.send(null), new Uint8Array(J.response); }), v = (H, J, de) => { var ke = new XMLHttpRequest(); ke.open("GET", H, true), ke.responseType = "arraybuffer", ke.onload = () => { if (ke.status == 200 || ke.status == 0 && ke.response) { J(ke.response); return; } de(); }, ke.onerror = de, ke.send(null); }, k = (H) => document.title = H); var P = a.print || console.log.bind(console), R = a.printErr || console.warn.bind(console); Object.assign(a, l), l = null, a.arguments && (c = a.arguments), a.thisProgram && (p = a.thisProgram), a.quit && (d = a.quit); var F = 4; function $(H) { $.shown || ($.shown = {}), $.shown[H] || ($.shown[H] = 1, R(H)); } function z(H, J) { if (typeof WebAssembly.Function == "function") { for (var de = { i: "i32", j: "i64", f: "f32", d: "f64" }, ke = { parameters: [], results: J[0] == "v" ? [] : [de[J[0]]] }, Qe = 1; Qe < J.length; ++Qe) ke.parameters.push(de[J[Qe]]); return new WebAssembly.Function(ke, H); } var Ze = [1, 0, 1, 96], Ve = J.slice(0, 1), ze = J.slice(1), Tt = { i: 127, j: 126, f: 125, d: 124 }; Ze.push(ze.length); for (var Qe = 0; Qe < ze.length; ++Qe) Ze.push(Tt[ze[Qe]]); Ve == "v" ? Ze.push(0) : Ze = Ze.concat([1, Tt[Ve]]), Ze[1] = Ze.length - 2; var is = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(Ze, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), os = new WebAssembly.Module(is), Ri = new WebAssembly.Instance(os, { e: { f: H } }), Br = Ri.exports.f; return Br; } var W = [], q; function K() { if (W.length) return W.pop(); try { Js.grow(1); } catch (H) { throw H instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : H; } return Js.length - 1; } function Y(H, J) { for (var de = H; de < H + J; de++) { var ke = mu(de); ke && q.set(ke, de); } } var Z = 0, te = (H) => { Z = H; }, ee; a.wasmBinary && (ee = a.wasmBinary); var se = a.noExitRuntime || true; typeof WebAssembly != "object" && Or("no native wasm support detected"); var ne, oe = false, re; function le(H, J) { H || Or(J); } function me(H) { var J = a["_" + H]; return J; } function we(H, J, de, ke, Qe) { var Ze = { string: function(an) { var nr = 0; if (an != null && an !== 0) { var Fc = (an.length << 2) + 1; nr = yu(Fc), tt(an, nr, Fc); } return nr; }, array: function(an) { var nr = yu(an.length); return at(an, nr), nr; } }; function Ve(an) { return J === "string" ? Je(an) : J === "boolean" ? Boolean(an) : an; } var ze = me(H), Tt = [], is = 0; if (ke) for (var os = 0; os < ke.length; os++) { var Ri = Ze[de[os]]; Ri ? (is === 0 && (is = Rc()), Tt[os] = Ri(ke[os])) : Tt[os] = ke[os]; } var Br = ze.apply(null, Tt); function Tf(an) { return is !== 0 && Dc(is), Ve(an); } return Br = Tf(Br), Br; } function Se(H, J, de, ke) { de = de || []; var Qe = de.every(function(Ve) { return Ve === "number"; }), Ze = J !== "string"; return Ze && Qe && !ke ? me(H) : function() { return we(H, J, de, arguments, ke); }; } var Ee = 1, Pe = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; function Xe(H, J, de) { for (var ke = J + de, Qe = J; H[Qe] && !(Qe >= ke); ) ++Qe; if (Qe - J > 16 && H.subarray && Pe) return Pe.decode(H.subarray(J, Qe)); for (var Ze = ""; J < Qe; ) { var Ve = H[J++]; if (!(Ve & 128)) { Ze += String.fromCharCode(Ve); continue; } var ze = H[J++] & 63; if ((Ve & 224) == 192) { Ze += String.fromCharCode((Ve & 31) << 6 | ze); continue; } var Tt = H[J++] & 63; if ((Ve & 240) == 224 ? Ve = (Ve & 15) << 12 | ze << 6 | Tt : Ve = (Ve & 7) << 18 | ze << 12 | Tt << 6 | H[J++] & 63, Ve < 65536) Ze += String.fromCharCode(Ve); else { var is = Ve - 65536; Ze += String.fromCharCode(55296 | is >> 10, 56320 | is & 1023); } } return Ze; } function Je(H, J) { return H ? Xe(en, H, J) : ""; } function Ye(H, J, de, ke) { if (!(ke > 0)) return 0; for (var Qe = de, Ze = de + ke - 1, Ve = 0; Ve < H.length; ++Ve) { var ze = H.charCodeAt(Ve); if (ze >= 55296 && ze <= 57343) { var Tt = H.charCodeAt(++Ve); ze = 65536 + ((ze & 1023) << 10) | Tt & 1023; } if (ze <= 127) { if (de >= Ze) break; J[de++] = ze; } else if (ze <= 2047) { if (de + 1 >= Ze) break; J[de++] = 192 | ze >> 6, J[de++] = 128 | ze & 63; } else if (ze <= 65535) { if (de + 2 >= Ze) break; J[de++] = 224 | ze >> 12, J[de++] = 128 | ze >> 6 & 63, J[de++] = 128 | ze & 63; } else { if (de + 3 >= Ze) break; J[de++] = 240 | ze >> 18, J[de++] = 128 | ze >> 12 & 63, J[de++] = 128 | ze >> 6 & 63, J[de++] = 128 | ze & 63; } } return J[de] = 0, de - Qe; } function tt(H, J, de) { return Ye(H, en, J, de); } function Ce(H) { for (var J = 0, de = 0; de < H.length; ++de) { var ke = H.charCodeAt(de); ke >= 55296 && ke <= 57343 && (ke = 65536 + ((ke & 1023) << 10) | H.charCodeAt(++de) & 1023), ke <= 127 ? ++J : ke <= 2047 ? J += 2 : ke <= 65535 ? J += 3 : J += 4; } return J; } var ut = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : void 0; function at(H, J) { Et.set(H, J); } function Jt(H, J, de) { for (var ke = 0; ke < H.length; ++ke) Et[J++ >> 0] = H.charCodeAt(ke); de || (Et[J >> 0] = 0); } function Nt(H, J) { return H % J > 0 && (H += J - H % J), H; } var Cn, Et, en, Nn, Tn, Yt, Dn, tn, Ms; function Ls(H) { Cn = H, a.HEAP8 = Et = new Int8Array(H), a.HEAP16 = Nn = new Int16Array(H), a.HEAP32 = Yt = new Int32Array(H), a.HEAPU8 = en = new Uint8Array(H), a.HEAPU16 = Tn = new Uint16Array(H), a.HEAPU32 = Dn = new Uint32Array(H), a.HEAPF32 = tn = new Float32Array(H), a.HEAPF64 = Ms = new Float64Array(H); } var wi = a.INITIAL_MEMORY || 16777216, Js, Bs = [], du = [], ki = [], nn = false, ic = false, oc = 0; function pu() { return se || oc > 0; } function uc() { if (a.preRun) for (typeof a.preRun == "function" && (a.preRun = [a.preRun]); a.preRun.length; ) dc(a.preRun.shift()); fu(Bs); } function lc() { nn = true, fu(du); } function Fv() { ic = true; } function cc() { if (a.postRun) for (typeof a.postRun == "function" && (a.postRun = [a.postRun]); a.postRun.length; ) pc(a.postRun.shift()); fu(ki); } function dc(H) { Bs.unshift(H); } function rs(H) { du.unshift(H); } function pc(H) { ki.unshift(H); } var Fn = 0, Ii = null, er = null; function th(H) { Fn++, a.monitorRunDependencies && a.monitorRunDependencies(Fn); } function hc(H) { if (Fn--, a.monitorRunDependencies && a.monitorRunDependencies(Fn), Fn == 0 && (Ii !== null && (clearInterval(Ii), Ii = null), er)) { var J = er; er = null, J(); } } a.preloadedImages = {}, a.preloadedAudios = {}; function Or(H) { a.onAbort && a.onAbort(H), H = "Aborted(" + H + ")", R(H), oe = true, re = 1, H += ". Build with -s ASSERTIONS=1 for more info."; var J = new WebAssembly.RuntimeError(H); throw o(J), J; } var nh = "data:application/octet-stream;base64,"; function fc(H) { return H.startsWith(nh); } function Pr(H) { return H.startsWith("file://"); } var sn; sn = "tfjs-backend-wasm.wasm", fc(sn) || (sn = b(sn)); function hu(H) { try { if (H == sn && ee) return new Uint8Array(ee); if (w) return w(H); throw "both async and sync fetching of the wasm failed"; } catch (J) { Or(J); } } function sh() { if (!ee && (h || f)) { if (typeof fetch == "function" && !Pr(sn)) return fetch(sn, { credentials: "same-origin" }).then(function(H) { if (!H.ok) throw "failed to load wasm binary file at '" + sn + "'"; return H.arrayBuffer(); }).catch(function() { return hu(sn); }); if (v) return new Promise(function(H, J) { v(sn, function(de) { H(new Uint8Array(de)); }, J); }); } return Promise.resolve().then(function() { return hu(sn); }); } function rh() { var H = { env: Ni, wasi_snapshot_preview1: Ni }; function J(Ve, ze) { var Tt = Ve.exports; a.asm = Tt, ne = a.asm.memory, Ls(ne.buffer), Js = a.asm.__indirect_function_table, rs(a.asm.__wasm_call_ctors), hc("wasm-instantiate"); } th("wasm-instantiate"); function de(Ve) { J(Ve.instance); } function ke(Ve) { return sh().then(function(ze) { return WebAssembly.instantiate(ze, H); }).then(function(ze) { return ze; }).then(Ve, function(ze) { R("failed to asynchronously prepare wasm: " + ze), Or(ze); }); } function Qe() { return !ee && typeof WebAssembly.instantiateStreaming == "function" && !fc(sn) && !Pr(sn) && typeof fetch == "function" ? fetch(sn, { credentials: "same-origin" }).then(function(Ve) { var ze = WebAssembly.instantiateStreaming(Ve, H); return ze.then(de, function(Tt) { return R("wasm streaming compile failed: " + Tt), R("falling back to ArrayBuffer instantiation"), ke(de); }); }) : ke(de); } if (a.instantiateWasm) try { var Ze = a.instantiateWasm(H, J); return Ze; } catch (Ve) { return R("Module.instantiateWasm callback failed with error: " + Ve), false; } return Qe().catch(o), {}; } var Ov, Pv; function fu(H) { for (; H.length > 0; ) { var J = H.shift(); if (typeof J == "function") { J(a); continue; } var de = J.func; typeof de == "number" ? J.arg === void 0 ? mu(de)() : mu(de)(J.arg) : de(J.arg === void 0 ? null : J.arg); } } function tr(H) { return H; } function mc(H) { var J = /\b_Z[\w\d_]+/g; return H.replace(J, function(de) { var ke = de; return de === ke ? de : ke + " [" + de + "]"; }); } var as = []; function mu(H) { var J = as[H]; return J || (H >= as.length && (as.length = H + 1), as[H] = J = Js.get(H)), J; } function zv() { var H = new Error(); if (!H.stack) { try { throw new Error(); } catch (J) { H = J; } if (!H.stack) return "(no stack trace available)"; } return H.stack.toString(); } function Si(H, J) { Js.set(H, J), as[H] = J; } function ah() { Or(""); } function gc(H, J, de) { en.copyWithin(H, J, J + de); } function bc() { return 2147483648; } function rn(H) { try { return ne.grow(H - Cn.byteLength + 65535 >>> 16), Ls(ne.buffer), 1; } catch (J) { } } function yc(H) { var J = en.length; H = H >>> 0; var de = bc(); if (H > de) return false; for (var ke = 1; ke <= 4; ke *= 2) { var Qe = J * (1 + 0.2 / ke); Qe = Math.min(Qe, H + 100663296); var Ze = Math.min(de, Nt(Math.max(H, Qe), 65536)), Ve = rn(Ze); if (Ve) return true; } return false; } var Ci = { mappings: {}, buffers: [null, [], []], printChar: function(H, J) { var de = Ci.buffers[H]; J === 0 || J === 10 ? ((H === 1 ? P : R)(Xe(de, 0)), de.length = 0) : de.push(J); }, varargs: void 0, get: function() { Ci.varargs += 4; var H = Yt[Ci.varargs - 4 >> 2]; return H; }, getStr: function(H) { var J = Je(H); return J; }, get64: function(H, J) { return H; } }; function ih(H) { return 0; } function Mv(H, J, de, ke, Qe) { } function Lv(H, J, de, ke) { for (var Qe = 0, Ze = 0; Ze < de; Ze++) { var Ve = Yt[J >> 2], ze = Yt[J + 4 >> 2]; J += 8; for (var Tt = 0; Tt < ze; Tt++) Ci.printChar(H, en[Ve + Tt]); Qe += ze; } return Yt[ke >> 2] = Qe, 0; } function oh(H) { te(H); } var vc = false, Ni = { abort: ah, emscripten_memcpy_big: gc, emscripten_resize_heap: yc, fd_close: ih, fd_seek: Mv, fd_write: Lv, setTempRet0: oh }, qN = rh(), Bv = a.___wasm_call_ctors = function() { return (Bv = a.___wasm_call_ctors = a.asm.__wasm_call_ctors).apply(null, arguments); }, uh = a._init = function() { return (uh = a._init = a.asm.init).apply(null, arguments); }, lh = a._init_with_threads_count = function() { return (lh = a._init_with_threads_count = a.asm.init_with_threads_count).apply(null, arguments); }, xc = a._get_threads_count = function() { return (xc = a._get_threads_count = a.asm.get_threads_count).apply(null, arguments); }, wc = a._register_tensor = function() { return (wc = a._register_tensor = a.asm.register_tensor).apply(null, arguments); }, ch = a._dispose_data = function() { return (ch = a._dispose_data = a.asm.dispose_data).apply(null, arguments); }, $e = a._dispose = function() { return ($e = a._dispose = a.asm.dispose).apply(null, arguments); }, dh = a._Abs = function() { return (dh = a._Abs = a.asm.Abs).apply(null, arguments); }, kc = a._Add = function() { return (kc = a._Add = a.asm.Add).apply(null, arguments); }, zr = a._AddN = function() { return (zr = a._AddN = a.asm.AddN).apply(null, arguments); }, Ti = a._All = function() { return (Ti = a._All = a.asm.All).apply(null, arguments); }, ph = a._Any = function() { return (ph = a._Any = a.asm.Any).apply(null, arguments); }, Vv = a._ArgMax = function() { return (Vv = a._ArgMax = a.asm.ArgMax).apply(null, arguments); }, hh = a._AvgPool = function() { return (hh = a._AvgPool = a.asm.AvgPool).apply(null, arguments); }, Wv = a._BatchMatMul = function() { return (Wv = a._BatchMatMul = a.asm.BatchMatMul).apply(null, arguments); }, Mr = a._Ceil = function() { return (Mr = a._Ceil = a.asm.Ceil).apply(null, arguments); }, fh = a._ClipByValue = function() { return (fh = a._ClipByValue = a.asm.ClipByValue).apply(null, arguments); }, mh = a._Conv2D = function() { return (mh = a._Conv2D = a.asm.Conv2D).apply(null, arguments); }, gh = a._Conv2DBackpropInput = function() { return (gh = a._Conv2DBackpropInput = a.asm.Conv2DBackpropInput).apply(null, arguments); }, bh = a._Cos = function() { return (bh = a._Cos = a.asm.Cos).apply(null, arguments); }, yh = a._Cosh = function() { return (yh = a._Cosh = a.asm.Cosh).apply(null, arguments); }, vh = a._CropAndResize = function() { return (vh = a._CropAndResize = a.asm.CropAndResize).apply(null, arguments); }, Ic = a._Cumprod = function() { return (Ic = a._Cumprod = a.asm.Cumprod).apply(null, arguments); }, xh = a._Cumsum = function() { return (xh = a._Cumsum = a.asm.Cumsum).apply(null, arguments); }, wh = a._DepthToSpace = function() { return (wh = a._DepthToSpace = a.asm.DepthToSpace).apply(null, arguments); }, kh = a._DepthwiseConv2dNative = function() { return (kh = a._DepthwiseConv2dNative = a.asm.DepthwiseConv2dNative).apply(null, arguments); }, Ih = a._Elu = function() { return (Ih = a._Elu = a.asm.Elu).apply(null, arguments); }, Sh = a._Equal = function() { return (Sh = a._Equal = a.asm.Equal).apply(null, arguments); }, Sc = a._Exp = function() { return (Sc = a._Exp = a.asm.Exp).apply(null, arguments); }, Ch = a._FlipLeftRight = function() { return (Ch = a._FlipLeftRight = a.asm.FlipLeftRight).apply(null, arguments); }, Nh = a._Floor = function() { return (Nh = a._Floor = a.asm.Floor).apply(null, arguments); }, Lr = a._FloorDiv = function() { return (Lr = a._FloorDiv = a.asm.FloorDiv).apply(null, arguments); }, gu = a._FusedBatchNorm = function() { return (gu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); }, Th = a._FusedConv2D = function() { return (Th = a._FusedConv2D = a.asm.FusedConv2D).apply(null, arguments); }, $h = a._FusedDepthwiseConv2D = function() { return ($h = a._FusedDepthwiseConv2D = a.asm.FusedDepthwiseConv2D).apply(null, arguments); }, _h = a._Gather = function() { return (_h = a._Gather = a.asm.Gather).apply(null, arguments); }, Le = a._GatherNd = function() { return (Le = a._GatherNd = a.asm.GatherNd).apply(null, arguments); }, Ah = a._Greater = function() { return (Ah = a._Greater = a.asm.Greater).apply(null, arguments); }, Eh = a._GreaterEqual = function() { return (Eh = a._GreaterEqual = a.asm.GreaterEqual).apply(null, arguments); }, Rh = a._LeakyRelu = function() { return (Rh = a._LeakyRelu = a.asm.LeakyRelu).apply(null, arguments); }, Dh = a._Less = function() { return (Dh = a._Less = a.asm.Less).apply(null, arguments); }, Fh = a._LessEqual = function() { return (Fh = a._LessEqual = a.asm.LessEqual).apply(null, arguments); }, Oh = a._Log = function() { return (Oh = a._Log = a.asm.Log).apply(null, arguments); }, bu = a._LogicalAnd = function() { return (bu = a._LogicalAnd = a.asm.LogicalAnd).apply(null, arguments); }, Cc = a._Max = function() { return (Cc = a._Max = a.asm.Max).apply(null, arguments); }, Nc = a._MaxPool = function() { return (Nc = a._MaxPool = a.asm.MaxPool).apply(null, arguments); }, Ph = a._Maximum = function() { return (Ph = a._Maximum = a.asm.Maximum).apply(null, arguments); }, zh = a._Mean = function() { return (zh = a._Mean = a.asm.Mean).apply(null, arguments); }, Mh = a._Min = function() { return (Mh = a._Min = a.asm.Min).apply(null, arguments); }, Lh = a._Minimum = function() { return (Lh = a._Minimum = a.asm.Minimum).apply(null, arguments); }, Bh = a._MirrorPad = function() { return (Bh = a._MirrorPad = a.asm.MirrorPad).apply(null, arguments); }, Vh = a._Multiply = function() { return (Vh = a._Multiply = a.asm.Multiply).apply(null, arguments); }, gt = a._Neg = function() { return (gt = a._Neg = a.asm.Neg).apply(null, arguments); }, Wh = a._NonMaxSuppressionV3 = function() { return (Wh = a._NonMaxSuppressionV3 = a.asm.NonMaxSuppressionV3).apply(null, arguments); }, Uh = a._NonMaxSuppressionV4 = function() { return (Uh = a._NonMaxSuppressionV4 = a.asm.NonMaxSuppressionV4).apply(null, arguments); }, Gh = a._NonMaxSuppressionV5 = function() { return (Gh = a._NonMaxSuppressionV5 = a.asm.NonMaxSuppressionV5).apply(null, arguments); }, $i = a._NotEqual = function() { return ($i = a._NotEqual = a.asm.NotEqual).apply(null, arguments); }, Tc = a._OneHot = function() { return (Tc = a._OneHot = a.asm.OneHot).apply(null, arguments); }, $c = a._PadV2 = function() { return ($c = a._PadV2 = a.asm.PadV2).apply(null, arguments); }, _c = a._Pow = function() { return (_c = a._Pow = a.asm.Pow).apply(null, arguments); }, Hh = a._Prelu = function() { return (Hh = a._Prelu = a.asm.Prelu).apply(null, arguments); }, Ac = a._Prod = function() { return (Ac = a._Prod = a.asm.Prod).apply(null, arguments); }, qh = a._RealDiv = function() { return (qh = a._RealDiv = a.asm.RealDiv).apply(null, arguments); }, Uv = a._Relu = function() { return (Uv = a._Relu = a.asm.Relu).apply(null, arguments); }, Ec = a._Relu6 = function() { return (Ec = a._Relu6 = a.asm.Relu6).apply(null, arguments); }, Gv = a._ResizeBilinear = function() { return (Gv = a._ResizeBilinear = a.asm.ResizeBilinear).apply(null, arguments); }, jh = a._Reverse = function() { return (jh = a._Reverse = a.asm.Reverse).apply(null, arguments); }, Kh = a._RotateWithOffset = function() { return (Kh = a._RotateWithOffset = a.asm.RotateWithOffset).apply(null, arguments); }, Xh = a._Round = function() { return (Xh = a._Round = a.asm.Round).apply(null, arguments); }, Yh = a._Rsqrt = function() { return (Yh = a._Rsqrt = a.asm.Rsqrt).apply(null, arguments); }, Qh = a._ScatterNd = function() { return (Qh = a._ScatterNd = a.asm.ScatterNd).apply(null, arguments); }, Zh = a._SelectV2 = function() { return (Zh = a._SelectV2 = a.asm.SelectV2).apply(null, arguments); }, Jh = a._Sigmoid = function() { return (Jh = a._Sigmoid = a.asm.Sigmoid).apply(null, arguments); }, ef = a._Sin = function() { return (ef = a._Sin = a.asm.Sin).apply(null, arguments); }, tf = a._Softmax = function() { return (tf = a._Softmax = a.asm.Softmax).apply(null, arguments); }, nf = a._SparseFillEmptyRows = function() { return (nf = a._SparseFillEmptyRows = a.asm.SparseFillEmptyRows).apply(null, arguments); }, sf = a._SparseReshape = function() { return (sf = a._SparseReshape = a.asm.SparseReshape).apply(null, arguments); }, rf = a._SparseSegmentReduction = function() { return (rf = a._SparseSegmentReduction = a.asm.SparseSegmentReduction).apply(null, arguments); }, af = a._Sqrt = function() { return (af = a._Sqrt = a.asm.Sqrt).apply(null, arguments); }, of = a._Square = function() { return (of = a._Square = a.asm.Square).apply(null, arguments); }, uf = a._SquaredDifference = function() { return (uf = a._SquaredDifference = a.asm.SquaredDifference).apply(null, arguments); }, lf = a._Step = function() { return (lf = a._Step = a.asm.Step).apply(null, arguments); }, cf = a._StridedSlice = function() { return (cf = a._StridedSlice = a.asm.StridedSlice).apply(null, arguments); }, df = a._Sub = function() { return (df = a._Sub = a.asm.Sub).apply(null, arguments); }, pf = a._Sum = function() { return (pf = a._Sum = a.asm.Sum).apply(null, arguments); }, hf = a._Tan = function() { return (hf = a._Tan = a.asm.Tan).apply(null, arguments); }, ff = a._Tanh = function() { return (ff = a._Tanh = a.asm.Tanh).apply(null, arguments); }, mf = a._Tile = function() { return (mf = a._Tile = a.asm.Tile).apply(null, arguments); }, gf = a._TopK = function() { return (gf = a._TopK = a.asm.TopK).apply(null, arguments); }, bf = a._Transform = function() { return (bf = a._Transform = a.asm.Transform).apply(null, arguments); }, yf = a._Transpose = function() { return (yf = a._Transpose = a.asm.Transpose).apply(null, arguments); }, vf = a.__FusedMatMul = function() { return (vf = a.__FusedMatMul = a.asm._FusedMatMul).apply(null, arguments); }, xf = a._malloc = function() { return (xf = a._malloc = a.asm.malloc).apply(null, arguments); }, wf = a._free = function() { return (wf = a._free = a.asm.free).apply(null, arguments); }, kf = a.___errno_location = function() { return (kf = a.___errno_location = a.asm.__errno_location).apply(null, arguments); }, If = a._emscripten_main_thread_process_queued_calls = function() { return (If = a._emscripten_main_thread_process_queued_calls = a.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); }, Rc = a.stackSave = function() { return (Rc = a.stackSave = a.asm.stackSave).apply(null, arguments); }, Dc = a.stackRestore = function() { return (Dc = a.stackRestore = a.asm.stackRestore).apply(null, arguments); }, yu = a.stackAlloc = function() { return (yu = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); }, Sf = a.dynCall_iijjiiii = function() { return (Sf = a.dynCall_iijjiiii = a.asm.dynCall_iijjiiii).apply(null, arguments); }, Cf = a.dynCall_jiji = function() { return (Cf = a.dynCall_jiji = a.asm.dynCall_jiji).apply(null, arguments); }; a.cwrap = Se; var _i; function vu(H) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + H + ")", this.status = H; } er = function H() { _i || xu(), _i || (er = H); }; function xu(H) { if (H = H || c, Fn > 0 || (uc(), Fn > 0)) return; function J() { _i || (_i = true, a.calledRun = true, !oe && (lc(), i(a), a.onRuntimeInitialized && a.onRuntimeInitialized(), cc())); } a.setStatus ? (a.setStatus("Running..."), setTimeout(function() { setTimeout(function() { a.setStatus(""); }, 1), J(); }, 1)) : J(); } a.run = xu; function Hv(H) { re = H, pu() || (a.onExit && a.onExit(H), oe = true), d(H, new vu(H)); } if (a.preInit) for (typeof a.preInit == "function" && (a.preInit = [a.preInit]); a.preInit.length > 0; ) a.preInit.pop()(); xu(); var Ai; u && (Ai = { uncaughtException: process.listeners("uncaughtException").filter(function(H) { return !u.uncaughtException.indexOf(H) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(H) { return !u.unhandledRejection.indexOf(H) > -1; }) }); var Ei; if (typeof r != "undefined") Ei = r; else if (typeof WasmBackendModuleThreadedSimd != "undefined") Ei = WasmBackendModuleThreadedSimd; else throw new Error("Could not find wasm module in post.js"); if (Ai) { var Nf = Ei._dispose; Ei._dispose = function() { Nf(), Ai.uncaughtException.forEach(function(H) { process.removeListener("uncaughtException", H); }), Ai.unhandledRejection.forEach(function(H) { process.removeListener("unhandledRejection", H); }); }; } 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 o$ = 1e-7; var u$ = 1e-4; var Ud = 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 ? o$ : u$; } 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 Uw(e) { let t = e.length, n = 0; for (; t > 0; ) n = Math.random() * t | 0, t--, pd(e, t, n); } function l$(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--, pd(e, n, s), pd(t, n, s); } function Bu(e, t, n) { return Math.max(e, Math.min(t, n)); } function c$(e) { return e % 2 === 0 ? e : e + 1; } function pd(e, t, n) { let s = e[t]; e[t] = e[n], e[n] = s; } function d$(e) { let t = 0; for (let n = 0; n < e.length; n++) t += e[n]; return t; } function p$(e, t) { let n = Math.random(); return t * n + (1 - n) * e; } function h$(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 pn(e, t, n = "") { O(kr(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) || Qt(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 f$(e) { return e.length === 0; } function kr(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 Yi(e) { return e % 1 === 0; } function m$(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 g$(e) { let t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)]; } function b$(e) { let t = new Uint32Array(e); for (let n = 0; n < e; ++n) t[n] = n; return Uw(t), t; } function Pu(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length); } function y$(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 v$(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 ts(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) => Yi(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 : ts(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 Hw(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 qw(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 jw(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 Kw(e) { return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string"; } function x$(e, t) { return !(t === "complex64" || t === "float32" && e !== "complex64" || t === "int32" && e !== "float32" && e !== "complex64" || t === "bool" && e === "bool"); } function Qt(e) { return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray; } function Xf(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 Xw(e) { if (e == null) return 0; let t = 0; return e.forEach((n) => t += n.length), t; } function ir(e) { return typeof e == "string" || e instanceof String; } function Yw(e) { return typeof e == "boolean"; } function Qw(e) { return typeof e == "number"; } function Gd(e) { return Array.isArray(e) ? Gd(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : Qw(e) ? "float32" : ir(e) ? "string" : Yw(e) ? "bool" : "float32"; } function hr(e) { return !!(e && e.constructor && e.call && e.apply); } function hd(e, t) { for (let n = t; n < e; ++n) if (e % n === 0) return n; return e; } function ro(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 Zw(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, l) => u * l) * (s ? 2 : 1); for (let u = 0; u < a; u++) r[u] = Zw(e + u * o, i, n, s); } return r; } function Hi(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 Zw(0, e, t, n); } function ng(e, t) { let n = Hd(e, t); for (let s = 0; s < n.length; s++) n[s] = 1; return n; } function Hd(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 w$(e, t) { let n = e.reduce((s, r) => s * r, 1); if (t == null || t === "float32") return Hi(e, new Float32Array(n)); if (t === "int32") return Hi(e, new Int32Array(n)); if (t === "bool") return Hi(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`); } function sg(e) { e.forEach((t) => { O(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`); }); } function k$(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 I$(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 rg(e) { return e && e.then && typeof e.then == "function"; } var tx = "tfjsflags"; var S$ = class { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = C$, 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 (rg(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); tx in e && e[tx].split(",").forEach((n) => { let [s, r] = n.split(":"); this.urlFlags[s] = T$(s, r); }); } }; function C$(e) { let t = {}; return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (N$(t, s[0], s[1]), s.join("="))), t; } function N$(e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || ""); } function T$(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 Jw; } var Jw = null; function $$(e) { Jw = e; } var Df; function ek() { if (Df == 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"); Df = e; } return Df; } function _$() { let e = ek(); return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals; } function ag(e, t) { let n = _$(); if (n.has(e)) return n.get(e); { let s = t(); return n.set(e, s), n.get(e); } } var ao = "Abs"; var nl = "Acos"; var sl = "Acosh"; var Ir = "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 ig = "AvgPoolGrad"; var qd = "AvgPool3D"; var og = "AvgPool3DGrad"; var Sa = "BatchMatMul"; var io = "BatchToSpaceND"; var ug = "Bincount"; var A$ = "BroadcastTo"; var lg = "BroadcastArgs"; var Ca = "Cast"; var Na = "Ceil"; var Sr = "ClipByValue"; var jd = "Complex"; var Kd = "ComplexAbs"; var oo = "Concat"; var Ta = "Conv2D"; var cg = "Conv2DBackpropFilter"; var $a = "Conv2DBackpropInput"; var Xd = "Conv3D"; var dg = "Conv3DBackpropFilterV2"; var pg = "Conv3DBackpropInputV2"; var _a = "Cos"; var Aa = "Cosh"; var pl = "Cumprod"; var uo = "Cumsum"; var lo = "CropAndResize"; var hg = "DenseBincount"; var co = "DepthToSpace"; var Ea = "DepthwiseConv2dNative"; var fg = "DepthwiseConv2dNativeBackpropFilter"; var mg = "DepthwiseConv2dNativeBackpropInput"; var gg = "Diag"; var Yd = "Dilation2D"; var Yf = "Dilation2DBackpropInput"; var Qf = "Dilation2DBackpropFilter"; var Ra = "RealDiv"; var Qd = "Einsum"; var Da = "Elu"; var bg = "EluGrad"; var hl = "Erf"; var po = "Equal"; var Fa = "Exp"; var ho = "ExpandDims"; var fo = "Expm1"; var yg = "FFT"; var fl = "Fill"; var mo = "FlipLeftRight"; var Oa = "Floor"; var Pa = "FloorDiv"; var za = "FusedBatchNorm"; var go = "GatherV2"; var bo = "GatherNd"; var yo = "Greater"; var Ma = "GreaterEqual"; var La = "Identity"; var vg = "IFFT"; var Zd = "Imag"; var ml = "IsFinite"; var gl = "IsInf"; var bl = "IsNan"; var Ba = "LeakyRelu"; var vo = "Less"; var xo = "LessEqual"; var xg = "LinSpace"; var Va = "Log"; var yl = "Log1p"; var wo = "LogicalAnd"; var vl = "LogicalNot"; var Jd = "LogicalOr"; var E$ = "LogSoftmax"; var ep = "LRN"; var wg = "LRNGrad"; var Wa = "Max"; var Ua = "Maximum"; var Ga = "MaxPool"; var kg = "MaxPoolGrad"; var tp = "MaxPool3D"; var Ig = "MaxPool3DGrad"; var Sg = "MaxPoolWithArgmax"; var Ha = "Mean"; var qa = "Min"; var ja = "Minimum"; var Ka = "MirrorPad"; var xl = "Mod"; var Cg = "Multinomial"; var Xa = "Multiply"; var ko = "Neg"; var Io = "NotEqual"; var So = "NonMaxSuppressionV3"; var wl = "NonMaxSuppressionV4"; var Co = "NonMaxSuppressionV5"; var No = "OnesLike"; var To = "OneHot"; var $o = "Pack"; var Ya = "PadV2"; var $de = "Pool"; var Qa = "Pow"; var Za = "Prelu"; var _o = "Prod"; var kl = "Range"; var np = "Real"; var Il = "Reciprocal"; var Ja = "Relu"; var Ao = "Reshape"; var Sl = "ResizeNearestNeighbor"; var Ng = "ResizeNearestNeighborGrad"; var ei = "ResizeBilinear"; var Tg = "ResizeBilinearGrad"; var ti = "Relu6"; var Eo = "Reverse"; var Ro = "Round"; var ni = "Rsqrt"; var Do = "ScatterNd"; var Fo = "Select"; var Cl = "Selu"; var Oo = "Slice"; var si = "Sin"; var Po = "Sinh"; var Nl = "Sign"; var ri = "Sigmoid"; var Tl = "Softplus"; var ai = "Sqrt"; var ii = "Sum"; var zo = "SpaceToBatchND"; var Mo = "SplitV"; var oi = "Softmax"; var sp = "SparseFillEmptyRows"; var $l = "SparseReshape"; var rp = "SparseSegmentMean"; var ap = "SparseSegmentSum"; var ip = "SparseToDense"; var ui = "SquaredDifference"; var _l = "Square"; var Lo = "StridedSlice"; var op = "StringNGrams"; var $g = "StringSplit"; var _g = "StringToHashBucketFast"; var li = "Sub"; var Bo = "Tan"; var ci = "Tanh"; var Cr = "Tile"; var Vo = "TopK"; var Wo = "Transform"; var di = "Transpose"; var Ag = "Unique"; var Uo = "Unpack"; var up = "UnsortedSegmentSum"; var Go = "ZerosLike"; var pi = "Step"; var fd = "FromPixels"; var Ho = "RotateWithOffset"; var sa = "_FusedMatMul"; var ra = "FusedConv2D"; var aa = "FusedDepthwiseConv2D"; function ar(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(...e); } function R$(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.log(...e); } var Qi = ag("kernelRegistry", () => /* @__PURE__ */ new Map()); var Vu = ag("gradRegistry", () => /* @__PURE__ */ new Map()); function Zf(e, t) { let n = Eg(e, t); return Qi.get(n); } function nx(e) { return Vu.get(e); } function Jf(e) { let t = Qi.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 = Eg(t, n); Qi.has(s) && ar(`The kernel '${t}' for backend '${n}' is already registered`), Qi.set(s, e); } function D$(e) { let { kernelName: t } = e; Vu.has(t) && X().getBool("DEBUG") && ar(`Overriding the gradient for '${t}'`), Vu.set(t, e); } function _de(e, t) { let n = Eg(e, t); if (!Qi.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); Qi.delete(n); } function Ade(e) { if (!Vu.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); Vu.delete(e); } function Ede(e, t) { Jf(e).forEach((s) => { let r = Object.assign({}, s, { backendName: t }); Al(r); }); } function Eg(e, t) { return `${t}_${e}`; } var x = {}; Ae(x, { arraysEqual: () => kr, assert: () => O, assertNonNegativeIntegerDimensions: () => sg, assertNonNull: () => xa, assertShapesMatch: () => pn, bytesFromStringArray: () => Xw, bytesPerElement: () => Xf, checkConversionForErrors: () => jw, clamp: () => Bu, computeStrides: () => ro, createScalarValue: () => L$, createShuffledIndices: () => b$, decodeString: () => md, distSquared: () => h$, encodeString: () => Rl, fetch: () => V$, fingerPrint64: () => M$, flatten: () => na, getArrayFromDType: () => qw, getTypedArrayFromDType: () => Hw, hasEncodingLoss: () => x$, hexToLong: () => El, indexToLoc: () => I$, inferDtype: () => Gd, inferFromImplicitShape: () => v$, isBoolean: () => Yw, isFunction: () => hr, isInt: () => Yi, isNumber: () => Qw, isPromise: () => rg, isScalarShape: () => f$, isString: () => ir, isTypedArray: () => Qt, isValidDtype: () => Kw, locToIndex: () => k$, makeOnesTypedArray: () => ng, makeZerosNestedTypedArray: () => w$, makeZerosTypedArray: () => Hd, nearestDivisor: () => hd, nearestLargerEven: () => c$, now: () => Wu, parseAxisParam: () => ts, randUniform: () => p$, repeatedTry: () => y$, rightPad: () => Pu, shuffle: () => Uw, shuffleCombo: () => l$, sizeFromShape: () => pt, sizeToSquarishShape: () => g$, squeezeShape: () => Gw, sum: () => d$, swap: () => pd, tanh: () => m$, toNestedArray: () => Hi, toTypedArray: () => lp }); var sx = va(HT()); var Hr = sx.default || sx; function El(e) { return Hr.fromString(e, true, 16); } var tk = El("c3a5c85c97cb3127"); var Gr = El("b492b66fbe98f273"); var on = El("9ae16a3b2f90404f"); function em(e) { return e.xor(e.shru(47)); } function nk(e, t, n) { let s = e.slice(t, t + n); return Hr.fromBytes(Array.from(s), true, true); } function lt(e, t) { return nk(e, t, 8); } function rx(e, t) { return nk(e, t, 4); } function Lt(e, t) { return t === 0 ? e : e.shru(t).or(e.shl(64 - t)); } function ur(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 F$(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 Vc(e, t, n, s) { return F$(lt(e, t), lt(e, t + 8), lt(e, t + 16), lt(e, t + 24), n, s); } function O$(e, t = e.length) { if (t >= 8) { let n = on.add(t * 2), s = lt(e, 0).add(on), r = lt(e, t - 8), a = Lt(r, 37).mul(n).add(s), i = Lt(s, 25).add(r).mul(n); return ur(a, i, n); } if (t >= 4) { let n = on.add(t * 2), s = rx(e, 0); return ur(s.shl(3).add(t), rx(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 em(on.mul(a).xor(tk.mul(i))).mul(on); } return on; } function P$(e, t = e.length) { let n = on.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(on); return ur(Lt(s.add(r), 43).add(Lt(a, 30)).add(i), s.add(Lt(r.add(on), 18)).add(a), n); } function z$(e, t = e.length) { let n = on.add(t * 2), s = lt(e, 0).mul(on), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(on), o = Lt(s.add(r), 43).add(Lt(a, 30)).add(i), u = ur(o, s.add(Lt(r.add(on), 18)).add(a), n), l = lt(e, 16).mul(n), c = lt(e, 24), p = o.add(lt(e, t - 32)).mul(n), d = u.add(lt(e, t - 24)).mul(n); return ur(Lt(l.add(c), 43).add(Lt(p, 30)).add(d), l.add(Lt(c.add(s), 18)).add(p), n); } function M$(e, t = e.length) { let n = Hr.fromNumber(81, true); if (t <= 32) return t <= 16 ? O$(e, t) : P$(e, t); if (t <= 64) return z$(e, t); let s = n, r = n.mul(Gr).add(113), a = em(r.mul(on).add(113)).mul(on), i = [Hr.UZERO, Hr.UZERO], o = [Hr.UZERO, Hr.UZERO]; s = s.mul(on).add(lt(e, 0)); let u = 0, l = (t - 1 >> 6) * 64, c = l + (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 = Vc(e, u, i[1].mul(Gr), s.add(o[0])), o = Vc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], u += 64; while (u !== l); let p = Gr.add(a.and(255).shl(1)); return u = c, 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(p), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(p), 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(p), i = Vc(e, u, i[1].mul(p), s.add(o[0])), o = Vc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], ur(ur(i[0], o[0], p).add(em(r).mul(tk)).add(a), ur(i[1], o[1], p).add(s), p); } function L$(e, t) { return t === "string" ? Rl(e) : lp([e], t); } function B$(e, t) { return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool"; } function lp(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") && jw(e, t), B$(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 V$(e, t) { return X().platform.fetch(e, t); } function Rl(e, t = "utf-8") { return t = t || "utf-8", X().platform.encode(e, t); } function md(e, t = "utf-8") { return t = t || "utf-8", X().platform.decode(e, t); } var W$ = class { constructor(e, t) { this.backendTimer = e, this.logger = t, t == null && (this.logger = new G$()); } 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 l = s[u]; l.data().then((c) => { U$(c, l.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 U$(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 G$ = 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, l = t.size, c = Pu(t.shape.toString(), 14), p = ""; for (let d in r) { let h = r[d]; if (h != null) { let f = h.shape || t.shape, m = f.length; p += `${d}: ${m}D ${m > 0 ? f : ""} `; } } console.log(`%c${o} %c${i} %c${u}D ${c} %c${l} %c${p} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; function H$(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 l = e[u], c = l.inputs; for (let p in c) { let d = c[p], h = false; for (let f = 0; f < t.length; f++) if (s[d.id]) { l.outputs.forEach((m) => s[m.id] = true), h = true, r[l.id] = true; break; } if (h) break; } } let a = {}; a[n.id] = true; let i = {}; for (let u = e.length - 1; u >= 0; u--) { let l = e[u], c = l.inputs; for (let p = 0; p < l.outputs.length; p++) if (a[l.outputs[p].id]) { for (let d in c) a[c[d].id] = true, i[l.id] = true; break; } } let o = []; for (let u = 0; u < e.length; u++) { let l = e[u]; if (r[l.id] && i[l.id]) { let c = {}; for (let d in l.inputs) { let h = l.inputs[d]; s[h.id] && (c[d] = h); } let p = Object.assign({}, l); p.inputs = c, p.outputs = l.outputs, o.push(p); } } return o; } function q$(e, t, n, s) { for (let r = t.length - 1; r >= 0; r--) { let a = t[r], i = []; if (a.outputs.forEach((u) => { let l = e[u.id]; l != null ? i.push(l) : 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 l = n(() => o[u]()); if (l.dtype !== "float32") throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`); let c = a.inputs[u]; if (!kr(l.shape, c.shape)) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`); if (e[c.id] == null) e[c.id] = l; else { let p = e[c.id]; e[c.id] = s(p, l), p.dispose(); } } } } var ax = 20; var Iu = 3; var Ff = 7; function j$(e, t, n, s) { let r = ro(t), a = K$(e, t, n, r), i = t.length, o = ed(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((l) => " " + l).join(` `)), u.join(` `); } function K$(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" ? $u(e) : e; if (o > 1) for (let l = 0; l < r / a; l++) { let c = l * a; for (let p = 0; p < a; p++) i[p] = Math.max(i[p], Tu(u[c + p], 0, n).length); } return i; } function Tu(e, t, n) { let s; return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(Ff))} + ${parseFloat(e[1].toFixed(Ff))}j` : ir(e) ? s = `'${e}'` : n === "bool" ? s = sk(e) : s = parseFloat(e.toFixed(Ff)).toString(), Pu(s, t); } function sk(e) { return e === 0 ? "false" : "true"; } function ed(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 = $u(e); return [Tu(m[0], 0, n)]; } return n === "bool" ? [sk(e[0])] : [e[0].toString()]; } if (u === 1) { if (o > ax) { let g = Iu * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - Iu) * i, o * i)); return n === "complex64" && (b = $u(b), y = $u(y)), ["[" + b.map((v, w) => Tu(v, r[w], n)).join(", ") + ", ..., " + y.map((v, w) => Tu(v, r[o - Iu + w], n)).join(", ") + "]"]; } let m = n === "complex64" ? $u(e) : Array.from(e); return ["[" + m.map((g, b) => Tu(g, r[b], n)).join(", ") + "]"]; } let l = t.slice(1), c = s.slice(1), p = s[0] * i, d = []; if (o > ax) { for (let m = 0; m < Iu; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, false)); } d.push("..."); for (let m = o - Iu; m < o; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); } } else for (let m = 0; m < o; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); } let h = u === 2 ? "," : ""; d[0] = "[" + d[0] + h; for (let m = 1; m < d.length - 1; m++) d[m] = " " + d[m] + h; let f = `, `; for (let m = 2; m < u; m++) f += ` `; return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : f), d; } function $u(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 || qw(t, this.size), this.strides = ro(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 cs().makeTensor(this.values, this.shape, this.dtype); } }; var cs = null; var Vi = null; var X$ = null; function Y$(e) { cs = e; } function Q$(e) { Vi = e; } function Z$(e) { X$ = e; } var et = 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 = ro(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 Vi.buffer(this.shape, this.dtype, e); } bufferSync() { return Vi.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); return Hi(this.shape, e, this.dtype === "complex64"); } arraySync() { return Hi(this.shape, this.dataSync(), this.dtype === "complex64"); } async data() { this.throwIfDisposed(); let e = cs().read(this.dataId); if (this.dtype === "string") { let t = await e; try { return t.map((n) => md(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(), cs().readToGPU(this.dataId, e); } dataSync() { this.throwIfDisposed(); let e = cs().readSync(this.dataId); if (this.dtype === "string") try { return e.map((t) => md(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 cs().read(this.dataId); return this.dtype === "string" ? e : new Uint8Array(e.buffer); } dispose() { this.isDisposed || (cs().disposeTensor(this), this.isDisposedInternal = true); } get isDisposed() { return this.isDisposedInternal; } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed."); } print(e = false) { return Vi.print(this, e); } clone() { return this.throwIfDisposed(), Vi.clone(this); } toString(e = false) { let t = this.dataSync(); return j$(t, this.shape, this.dtype, e); } cast(e) { return this.throwIfDisposed(), Vi.cast(this, e); } variable(e = true, t, n) { return this.throwIfDisposed(), cs().makeVariable(this, e, t, n); } }; Object.defineProperty(et, Symbol.hasInstance, { value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null }); function J$() { return ag("Tensor", () => et); } J$(); var gd = class extends et { 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 (!kr(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); cs().disposeTensor(this), this.dataId = e.dataId, cs().incRef(this, null); } dispose() { cs().disposeVariable(this), this.isDisposedInternal = true; } }; Object.defineProperty(gd, Symbol.hasInstance, { value: (e) => e instanceof et && e.assign != null && e.assign instanceof Function }); var _s = {}; Ae(_s, { assertTypesMatch: () => uk, getTensorsInContainer: () => Rg, isTensorInList: () => n_, makeTypesMatch: () => vt }); var e_ = ((e) => (e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6", e))(e_ || {}); var rk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64", e))(rk || {}); var ak = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64", e))(ak || {}); var ik = ((e) => (e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64", e))(ik || {}); var ok = ((e) => (e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64", e))(ok || {}); var t_ = { float32: ik, int32: rk, bool: ak, complex64: ok }; function cn(e, t) { if (e === "string" || t === "string") { if (e === "string" && t === "string") return "string"; throw new Error(`Can not upcast ${e} with ${t}`); } return t_[e][t]; } function cp(e) { return cn(e, "int32"); } function vt(e, t) { if (e.dtype === t.dtype) return [e, t]; let n = cn(e.dtype, t.dtype); return [e.cast(n), t.cast(n)]; } function uk(e, t) { O(e.dtype === t.dtype, () => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`); } function n_(e, t) { return t.some((n) => n.id === e.id); } function Rg(e) { let t = []; return lk(e, t, /* @__PURE__ */ new Set()), t; } function lk(e, t, n) { if (e == null) return; if (e instanceof et) { t.push(e); return; } if (!s_(e)) return; let s = e; for (let r in s) { let a = s[r]; n.has(a) || (n.add(a), lk(a, t, n)); } } function s_(e) { return Array.isArray(e) || typeof e == "object"; } function Of(e) { return e.kernelName != null; } var ix = 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 tm = class { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new ix(); } 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 ? (ar(`${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 W$(this.backendInstance), true; } setupRegisteredKernels() { Jf(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { Jf(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, ar(`Initialization of backend ${e} failed`), ar(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 ar(`Initialization of backend ${e} failed`), ar(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 tm.nextTensorId++; } nextVariableId() { return tm.nextVariableId++; } clone(e) { let t = M.runKernel(La, { x: e }), n = { x: e }, s = (a) => ({ x: () => { let i = "float32", o = { x: a }, u = { dtype: i }; return M.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, !(Zf(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 = Of(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; if (Of(e)) { let { kernelName: h, inputs: f, attrs: m } = e; this.backendName == null && this.backend; let g = Zf(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((w) => { if (w.rank != null) return w; let { dataId: k, shape: T, dtype: N } = w; return this.makeTensorFromDataId(k, T, N); }); if (s) { let w = this.getTensorsForGradient(h, f, v); n = this.saveTensorsForBackwardMode(w); } 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: l, attrs: c } = e, p = Of(e) ? null : e.backwardsFunc, d; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = i() : (d = this.profiler.profileKernel(u, l, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(d), t = d.outputs); }), s && this.addTapeNode(u, l, t, p, n, c), 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(l).map((h) => l[h] != null ? l[h].shape : null), outputShapes: t.map((h) => h.shape), kernelTimeMs: d.timeMs, extraInfo: d.extraInfo }), Array.isArray(o) ? t : t[0]; } saveTensorsForBackwardMode(e) { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { let s = nx(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, l) => a[l]); 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" && ir(e[0]) && (r = e.map((o) => Rl(o))); let a = s.write(r, t, n), i = new et(t, n, a, this.nextTensorId()); if (this.trackTensor(i, s), n === "string") { let o = this.state.tensorInfo.get(a), u = Xw(r); this.state.numBytes += u - o.bytes, o.bytes = u; } return i; } makeTensorFromDataId(e, t, n, s) { n = n || "float32"; let r = new et(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 gd(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 * Xf(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 gd || 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 * Xf(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 = nx(e); o != null && (s = o.gradFunc), s != null && (i.gradient = (u) => (u = u.map((l, c) => { if (l == null) { let p = n[c], d = Hd(p.size, p.dtype); return this.makeTensor(d, p.shape, p.dtype); } return l; }), 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 = Rg(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 et, () => "The result y returned by f() must be a tensor."); let a = H$(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 ? r_(r.shape) : n, q$(i, a, (u) => this.tidy(u), a_); let o = t.map((u) => i[u.id]); return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((u) => { for (let l of u.saved) l.dispose(); }), this.state.activeTape = null), { value: r, grads: o }; }); } customGrad(e) { return O(hr(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { O(t.every((i) => i instanceof et), () => "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 et, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), O(hr(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), l = Array.isArray(u) ? u : [u]; O(l.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(l.every((p) => p instanceof et), () => "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 c = {}; return l.forEach((p, d) => { c[d] = () => p; }), c; }; 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 ix(); 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 Dg = tm; Dg.nextTensorId = 0; Dg.nextVariableId = 0; function r_(e) { let t = ng(pt(e), "float32"); return M.makeTensor(t, e, "float32"); } function ck() { let e = ek(); if (e._tfengine == null) { let t = new S$(e); e._tfengine = new Dg(t); } return $$(e._tfengine.ENV), Y$(() => e._tfengine), e._tfengine; } var M = ck(); function a_(e, t) { let n = { a: e, b: t }; return M.runKernel(Ir, n); } var dp = {}; Ae(dp, { isBrowser: () => dk, isMobile: () => u_, mockIsMobile: () => o_ }); function i_() { return typeof navigator != "undefined" && navigator != null; } var nm; function o_(e) { nm = e; } function u_(e) { if (nm !== void 0) return nm; if (e || i_()) { 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 dk() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } var jn = X(); jn.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."); }); jn.registerFlag("IS_BROWSER", () => dk()); jn.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); jn.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); jn.registerFlag("PROD", () => false); jn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => jn.getBool("DEBUG")); jn.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true); jn.registerFlag("IS_TEST", () => false); jn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true); jn.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); jn.registerFlag("ENGINE_COMPILE_ONLY", () => false); function Rs(e, t) { let n = e; if (Qt(e)) return t === "string" ? [] : [e.length]; if (!Array.isArray(e)) return []; let s = []; for (; Array.isArray(n) || Qt(n) && t !== "string"; ) s.push(n.length), n = n[0]; return Array.isArray(e) && X().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && pk(e, s, []), s; } function pk(e, t, n) { if (n = n || [], !Array.isArray(e) && !Qt(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) pk(e[r], s, n.concat(r)); } function ox(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, t, n, s = "numeric") { if (e instanceof et) return ox(s, e.dtype, t, n), e; let r = Gd(e); if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), ox(s, r, t, n), e == null || !Qt(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 = Rs(e, r); !Qt(e) && !Array.isArray(e) && (e = [e]); let o = r !== "string" ? lp(e, r) : na(e, [], true); return M.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) => _(a, `${t}[${i}]`, n, s)); } var l_ = "__op"; function L(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 + l_; let r = (...a) => { M.startScope(n); try { let i = s(...a); return rg(i) && console.error("Cannot return a Promise inside of tidy."), M.endScope(i), i; } catch (i) { throw M.endScope(null), i; } }; return Object.defineProperty(r, "name", { value: n, configurable: true }), r; } function c_(e, t) { let n = _(e, "real", "complex"), s = _(t, "imag", "complex"); pn(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 M.runKernel(jd, r); } var ia = L({ complex_: c_ }); function Nr(e, t, n, s) { if (s == null && (s = Gd(e)), s === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if (!Qt(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) { sg(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 !Qt(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? lp(e, s) : na(e, [], true), M.makeTensor(e, t, s); } function fs(e, t, n) { let s = Rs(e, n); return Nr(e, t, s, n); } var sm = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; var bd = 4; async function d_(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 l = { name: o, shape: u.shape, dtype: u.dtype }; if (u.dtype === "string") { let c = new Promise(async (p) => { let d = await u.bytes(), h = d.reduce((g, b) => g + b.length, 0) + bd * d.length, f = new Uint8Array(h), m = 0; for (let g = 0; g < d.length; g++) { let b = d[g], y = new Uint8Array(new Uint32Array([b.length]).buffer); f.set(y, m), m += bd, f.set(b, m), m += b.length; } p(f); }); s.push(c); } else s.push(u.data()); t != null && (l.group = t), n.push(l); } let a = await Promise.all(s); return { data: p_(a), specs: n }; } function hk(e, t) { let n = {}, s, r = 0; for (let a of t) { let i = a.name, o = a.dtype, u = a.shape, l = pt(u), c; if ("quantization" in a) { let p = a.quantization; if (p.dtype === "uint8" || p.dtype === "uint16") { if (!("min" in p && "scale" in p)) throw new Error(`Weight ${a.name} with quantization ${p.dtype} doesn't have corresponding metadata min and scale.`); } else if (p.dtype === "float16") { if (o !== "float32") throw new Error(`Weight ${a.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${o}.`); } else throw new Error(`Weight ${a.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); let d = sm[p.dtype], h = e.slice(r, r + l * d), f = p.dtype === "uint8" ? new Uint8Array(h) : new Uint16Array(h); if (o === "float32") if (p.dtype === "uint8" || p.dtype === "uint16") { c = new Float32Array(f.length); for (let m = 0; m < f.length; m++) { let g = f[m]; c[m] = g * p.scale + p.min; } } else if (p.dtype === "float16") s === void 0 && (s = y_()), c = s(f); else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`); else if (o === "int32") { if (p.dtype !== "uint8" && p.dtype !== "uint16") throw new Error(`Unsupported quantization type ${p.dtype} for weight type int32.`); c = new Int32Array(f.length); for (let m = 0; m < f.length; m++) { let g = f[m]; c[m] = Math.round(g * p.scale + p.min); } } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += l * d; } else if (o === "string") { let p = pt(a.shape); c = []; for (let d = 0; d < p; d++) { let h = new Uint32Array(e.slice(r, r + bd))[0]; r += bd; let f = new Uint8Array(e.slice(r, r + h)); c.push(f), r += h; } } else { let p = sm[o], d = e.slice(r, r + l * p); if (o === "float32") c = new Float32Array(d); else if (o === "int32") c = new Int32Array(d); else if (o === "bool") c = new Uint8Array(d); else if (o === "complex64") { c = new Float32Array(d); let h = new Float32Array(c.length / 2), f = new Float32Array(c.length / 2); for (let b = 0; b < h.length; b++) h[b] = c[b * 2], f[b] = c[b * 2 + 1]; let m = fs(h, u, "float32"), g = fs(f, u, "float32"); n[i] = ia(m, g), m.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += l * p; } o !== "complex64" && (n[i] = fs(c, u, o)); } return n; } function p_(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 Fg = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); function ux(e) { return Fg ? Buffer.byteLength(e) : new Blob([e]).size; } function h_(e) { if (Fg) 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 f_(e) { if (Fg) { 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 Og(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 lx(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 fk(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 Pg(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 : ux(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : ux(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; } function m_() { 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 g_() { 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 b_() { let e = new Uint32Array(64); for (let t = 0; t < 64; t++) e[t] = 1024; return e[0] = e[32] = 0, e; } function y_() { let e = m_(), t = g_(), n = b_(); 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 xt = class { constructor() { this.saveRouters = [], this.loadRouters = []; } static getInstance() { return xt.instance == null && (xt.instance = new xt()), xt.instance; } static registerSaveRouter(e) { xt.getInstance().saveRouters.push(e); } static registerLoadRouter(e) { xt.getInstance().loadRouters.push(e); } static getSaveHandlers(e) { return xt.getHandlers(e, "save"); } static getLoadHandlers(e, t) { return xt.getHandlers(e, "load", t); } static getHandlers(e, t, n) { let s = []; return (t === "load" ? xt.getInstance().loadRouters : xt.getInstance().saveRouters).forEach((a) => { let i = a(e, n); i !== null && s.push(i); }), s; } }; var v_ = (e) => xt.registerSaveRouter(e); var x_ = (e) => xt.registerLoadRouter(e); var w_ = (e) => xt.getSaveHandlers(e); var k_ = (e, t) => xt.getLoadHandlers(e, t); var rm = "tensorflowjs"; var am = 1; var Xr = "models_store"; var or = "model_info_store"; function mk() { 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 im(e) { let t = e.result; t.createObjectStore(Xr, { keyPath: "modelPath" }), t.createObjectStore(or, { keyPath: "modelPath" }); } var oa = class { constructor(e) { if (this.indexedDB = mk(), 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(rm, am); r.onupgradeneeded = () => im(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 = (l) => (a.close(), s(u.error)), i.oncomplete = () => a.close(); } else { let i = Dl(t), o = a.transaction(or, "readwrite"), u = o.objectStore(or), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), c; l.onsuccess = () => { c = a.transaction(Xr, "readwrite"); let d = c.objectStore(Xr).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); d.onsuccess = () => n({ modelArtifactsInfo: i }), d.onerror = (h) => { u = o.objectStore(or); let f = u.delete(this.modelPath); f.onsuccess = () => (a.close(), s(d.error)), f.onerror = (m) => (a.close(), s(d.error)); }; }, l.onerror = (p) => (a.close(), s(l.error)), o.oncomplete = () => { c == null ? a.close() : c.oncomplete = () => a.close(); }; } }, r.onerror = (a) => s(r.error); }); } }; oa.URL_SCHEME = "indexeddb://"; var gk = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(oa.URL_SCHEME) ? I_(e.slice(oa.URL_SCHEME.length)) : null; xt.registerSaveRouter(gk); xt.registerLoadRouter(gk); function I_(e) { return new oa(e); } function S_(e) { return e.startsWith(oa.URL_SCHEME) ? e.slice(oa.URL_SCHEME.length) : e; } var C_ = class { constructor() { this.indexedDB = mk(); } async listModels() { return new Promise((e, t) => { let n = this.indexedDB.open(rm, am); n.onupgradeneeded = () => im(n), n.onsuccess = () => { let s = n.result, r = s.transaction(or, "readonly"), i = r.objectStore(or).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 = S_(e), new Promise((t, n) => { let s = this.indexedDB.open(rm, am); s.onupgradeneeded = () => im(s), s.onsuccess = () => { let r = s.result, a = r.transaction(or, "readwrite"), i = a.objectStore(or), 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 l = i.delete(e), c = () => { u = r.transaction(Xr, "readwrite"); let d = u.objectStore(Xr).delete(e); d.onsuccess = () => t(o.result.modelArtifactsInfo), d.onerror = (h) => n(o.error); }; l.onsuccess = c, l.onerror = (p) => (c(), r.close(), n(o.error)); } }, o.onerror = (l) => (r.close(), n(o.error)), a.oncomplete = () => { u == null ? r.close() : u.oncomplete = () => r.close(); }; }, s.onerror = (r) => n(s.error); }); } }; var Gs = "/"; var Wi = "tensorflowjs_models"; var bk = "info"; var N_ = "model_topology"; var T_ = "weight_specs"; var $_ = "weight_data"; var __ = "model_metadata"; function yk(e) { return { info: [Wi, e, bk].join(Gs), topology: [Wi, e, N_].join(Gs), weightSpecs: [Wi, e, T_].join(Gs), weightData: [Wi, e, $_].join(Gs), modelMetadata: [Wi, e, __].join(Gs) }; } function vk(e) { for (let t of Object.values(e)) window.localStorage.removeItem(t); } function A_(e) { let t = e.split(Gs); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); return t.slice(1, t.length - 1).join(Gs); } function E_(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 = yk(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, h_(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 vk(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 = f_(a), t; } }; ua.URL_SCHEME = "localstorage://"; var xk = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(ua.URL_SCHEME) ? R_(e.slice(ua.URL_SCHEME.length)) : null; xt.registerSaveRouter(xk); xt.registerLoadRouter(xk); function R_(e) { return new ua(e); } var D_ = 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 = Wi + Gs, n = Gs + bk; for (let s = 0; s < this.LS.length; ++s) { let r = this.LS.key(s); if (r.startsWith(t) && r.endsWith(n)) { let a = A_(r); e[a] = JSON.parse(this.LS.getItem(r)); } } return e; } async removeModel(e) { e = E_(e); let t = yk(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 vk(t), n; } }; var qi = "://"; 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(qi) && (e = e.slice(0, e.indexOf(qi))), 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 td(e) { if (e.indexOf(qi) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(",")}`); return { scheme: e.split(qi)[0], path: e.split(qi)[1] }; } async function wk(e, t, n = false) { O(e !== t, () => `Old path and new path are the same: '${e}'`); let s = xt.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 = xt.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 = td(e).scheme, u = td(e).path, l = o === td(e).scheme, c = await r.load(); n && l && await zn.getManager(o).removeModel(u); let p = await i.save(c); return n && !l && await zn.getManager(o).removeModel(u), p.modelArtifactsInfo; } async function F_() { 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 + qi + r; t[a] = s[r]; } } return t; } async function O_(e) { let t = td(e); return zn.getManager(t.scheme).removeModel(t.path); } async function P_(e, t) { return wk(e, t, false); } async function z_(e, t) { return wk(e, t, true); } var M_ = 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 M_()); try { zn.registerManager(ua.URL_SCHEME, new D_()); } catch (e) { } try { zn.registerManager(oa.URL_SCHEME, new C_()); } catch (e) { } } var L_ = { importFetch: () => qT() }; var Pf; var B_ = class { constructor() { this.util = jT(), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { return X().global.fetch != null ? X().global.fetch(e, t) : (Pf == null && (Pf = L_.importFetch()), Pf(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 B_()); function De(e, t = "float32", n) { return t = t || "float32", sg(e), new Vt(e, t, n); } function V_(e, t) { let n = _(e, "x", "cast"); if (!Kw(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 M.runKernel(Ca, s, r); } var ce = L({ cast_: V_ }); function W_(e) { let n = { x: _(e, "x", "clone", "string_or_numeric") }; return M.runKernel(La, n); } var lr = L({ clone_: W_ }); function U_(e, t = false) { console.log(e.toString(t)); } ck(); var G_ = { buffer: De, cast: ce, clone: lr, print: U_ }; Q$(G_); var En = {}; Ae(En, { browserFiles: () => Q_, browserHTTPRequest: () => nA, concatenateArrayBuffers: () => Og, copyModel: () => P_, decodeWeights: () => hk, encodeWeights: () => d_, fromMemory: () => rA, getLoadHandlers: () => k_, getModelArtifactsForJSON: () => Pg, getModelArtifactsInfoForJSON: () => Dl, getSaveHandlers: () => w_, http: () => Mg, isHTTPScheme: () => um, listModels: () => F_, loadWeights: () => Z_, moveModel: () => z_, registerLoadRouter: () => x_, registerSaveRouter: () => v_, removeModel: () => O_, weightsLoaderFactory: () => Ik, withSaveHandler: () => aA }); var H_ = "model"; var q_ = ".json"; var j_ = ".weights.bin"; function cx(e) { return new Promise((t) => setTimeout(t)).then(e); } var om = class { constructor(e) { if (!X().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(om.URL_SCHEME) && (e = e.slice(om.URL_SCHEME.length)), (e == null || e.length === 0) && (e = H_), this.modelJsonFileName = e + q_, this.weightDataFileName = e + j_; } 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 = fk(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 cx(() => 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 cx(() => i.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: Dl(e) }; } } }; var yd = om; yd.URL_SCHEME = "downloads://"; var K_ = 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 = Pg(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, Og(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) => lx(r.name)), s = {}; for (let r of e) r.paths.forEach((a) => { let i = lx(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 X_ = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(yd.URL_SCHEME) ? Y_(e.slice(yd.URL_SCHEME.length)) : null; xt.registerSaveRouter(X_); function Y_(e = "model") { return new yd(e); } function Q_(e) { return new K_(e); } function dx(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((l) => { let c = n + ++r / e.length * (s - n); return t(c), l; }), u); function i(u) { O(u != null && Array.isArray(u) && u.length > 0, () => "promises must be a none empty array"); } function o(u, l) { O(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${u}`), O(l >= 0 && l <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${l}`), O(l >= u, () => `startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`); } return Promise.all(e.map(a)); } async function kk(e, t) { t == null && (t = {}); let n = t.fetchFunc == null ? X().platform.fetch : t.fetchFunc, s = e.map((p) => n(p, t.requestInit, { isBinary: true })), r = 0, a = 0.5, o = (t.onProgress == null ? await Promise.all(s) : await dx(s, t.onProgress, r, a)).map((p) => p.arrayBuffer()), u = 0.5, l = 1; return t.onProgress == null ? await Promise.all(o) : await dx(o, t.onProgress, u, l); } async function Z_(e, t = "", n, s) { return Ik((i) => kk(i, { requestInit: s }))(e, t, n); } function Ik(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 = sm[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((w, k) => { w === 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), []), l = []; u.forEach((h) => { t[h].paths.forEach((f) => { let m = n + (n.endsWith("/") ? "" : "/") + f; l.push(m); }); }); let c = await e(l), p = {}, d = 0; return u.forEach((h) => { let f = t[h].paths.length, m = 0; for (let w = 0; w < f; w++) m += c[d + w].byteLength; let g = new ArrayBuffer(m), b = new Uint8Array(g), y = 0; for (let w = 0; w < f; w++) { let k = new Uint8Array(c[d + w]); b.set(k, y), y += k.byteLength; } a[h].forEach((w) => { let k = g.slice(w.groupOffset, w.groupOffset + w.sizeBytes), T = hk(k, [w.manifestEntry]); for (let N in T) p[N] = T[N]; }), d += f; }), p; }; } var J_ = "application/octet-stream"; var eA = "application/json"; var zg = 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 = fk(e, n); t.body.append("model.json", new Blob([JSON.stringify(s)], { type: eA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: J_ }), "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 Pg(t, (r) => this.loadWeights(r)); } async loadWeights(e) { let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, s] = tA(t), r = this.weightPathPrefix || n, a = []; for (let l of e) a.push(...l.weights); let i = [], o = []; for (let l of e) for (let c of l.paths) this.weightUrlConverter != null ? o.push(this.weightUrlConverter(c)) : i.push(r + c + s); this.weightUrlConverter && i.push(...await Promise.all(o)); let u = await kk(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); return [a, Og(u)]; } }; zg.URL_SCHEME_REGEX = /^https?:\/\//; function tA(e) { let t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), s = e.substring(0, t), r = n > t ? e.substring(n) : ""; return [s + "/", r]; } function um(e) { return e.match(zg.URL_SCHEME_REGEX) != null; } var Sk = (e, t) => { if (typeof fetch == "undefined" && (t == null || t.fetchFunc == null)) return null; { let n = true; if (Array.isArray(e) ? n = e.every((s) => um(s)) : n = um(e), n) return Mg(e, t); } return null; }; xt.registerSaveRouter(Sk); xt.registerLoadRouter(Sk); function Mg(e, t) { return new zg(e, t); } function nA(e, t) { return Mg(e, t); } var zf = class { constructor(e) { this.modelArtifacts = e; } async load() { return this.modelArtifacts; } }; var sA = class { constructor(e) { this.saveHandler = e; } async save(e) { return this.saveHandler(e); } }; function rA(e, t, n, s) { return arguments.length === 1 ? e.modelTopology != null || e.weightSpecs != null ? new zf(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 zf({ 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 zf({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: s })); } function aA(e) { return new sA(e); } var iA = {}; Ae(iA, { confusionMatrix: () => dA }); function oA(e, t, n = false, s = false) { let r = _(e, "a", "matMul"), a = _(t, "b", "matMul"); [r, a] = vt(r, a); let i = { a: r, b: a }, o = { transposeA: n, transposeB: s }; return M.runKernel(Sa, i, o); } var We = L({ matMul_: oA }); function uA(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, "indices", "oneHot", "int32") }, i = { depth: t, onValue: n, offValue: s }; return M.runKernel(To, a, i); } var vd = L({ oneHot_: uA }); function lA(e, t) { let n = _(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 M.runKernel(di, s, r); } var qe = L({ transpose_: lA }); function cA(e, t, n) { let s = _(e, "labels", "confusionMatrix"), r = _(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 = vd(ce(s, "int32"), n), i = vd(ce(r, "int32"), n), o = qe(a), u = We(o, i); return ce(u, "int32"); } var dA = L({ confusionMatrix_: cA }); var qo = {}; Ae(qo, { assertAndGetBroadcastShape: () => ot, getBroadcastDims: () => Ck, getReductionAxes: () => _t }); function Ck(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 Nk = {}; Ae(Nk, { fromPixels: () => vA, fromPixelsAsync: () => bA, toPixels: () => yA }); function pA(e, t, n) { if (xa(e), t != null && t.length !== 3) throw new Error("tensor3d() requires shape to have three numbers"); let s = Rs(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 Nr(e, t, s, n); } var Vr; function Tk(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