/* 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", keepInvalid: false }, attention: { enabled: false, modelPath: "facemesh-attention.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: () => di, Acos: () => ul, Acosh: () => ll, AdadeltaOptimizer: () => Nb, AdagradOptimizer: () => Tb, AdamOptimizer: () => $b, AdamaxOptimizer: () => _b, Add: () => Cr, AddN: () => Sa, All: () => cl, Any: () => dl, ArgMax: () => Ia, ArgMin: () => pl, Asin: () => hl, Asinh: () => fl, Atan: () => ml, Atan2: () => bl, Atanh: () => gl, AvgPool: () => Ca, AvgPool3D: () => tp, AvgPool3DGrad: () => yg, AvgPoolGrad: () => bg, BackendWasm: () => vpe, BatchMatMul: () => Na, BatchToSpaceND: () => pi, Bincount: () => vg, BroadcastArgs: () => xg, BroadcastTo: () => j$, Callback: () => JW, CallbackList: () => mB, Cast: () => Ta, Ceil: () => $a, ClipByValue: () => Nr, Complex: () => np, ComplexAbs: () => sp, Concat: () => hi, Conv2D: () => _a, Conv2DBackpropFilter: () => wg, Conv2DBackpropInput: () => Aa, Conv3D: () => rp, Conv3DBackpropFilterV2: () => kg, Conv3DBackpropInputV2: () => Sg, Cos: () => Ea, Cosh: () => Ra, CropAndResize: () => mi, Cumprod: () => fi, Cumsum: () => Da, CustomCallback: () => yB, DataStorage: () => Zd, DenseBincount: () => Ig, DepthToSpace: () => gi, DepthwiseConv2dNative: () => Fa, DepthwiseConv2dNativeBackpropFilter: () => Cg, DepthwiseConv2dNativeBackpropInput: () => Ng, Diag: () => Tg, Dilation2D: () => ap, Dilation2DBackpropFilter: () => um, Dilation2DBackpropInput: () => im, ENV: () => fk, EarlyStopping: () => e4, Einsum: () => op, Elu: () => Pa, EluGrad: () => $g, Environment: () => V$, Equal: () => bi, Erf: () => yl, Exp: () => za, ExpandDims: () => yi, Expm1: () => vi, FFT: () => _g, Fill: () => vl, FlipLeftRight: () => xi, Floor: () => La, FloorDiv: () => Ma, FromPixels: () => xd, FusedBatchNorm: () => Ba, FusedConv2D: () => ia, FusedDepthwiseConv2D: () => ua, GPGPUContext: () => am, GatherNd: () => ki, GatherV2: () => wi, GraphModel: () => P0, Greater: () => Si, GreaterEqual: () => Va, History: () => bB, IFFT: () => Ag, Identity: () => Wa, Imag: () => ip, InputSpec: () => Dt, IsFinite: () => xl, IsInf: () => wl, IsNan: () => kl, KernelBackend: () => il, LRN: () => up, LRNGrad: () => Rg, LayerVariable: () => Az, LayersModel: () => pr, LeakyRelu: () => Ua, Less: () => Ii, LessEqual: () => Ci, LinSpace: () => Eg, Log: () => Ga, Log1p: () => Sl, LogSoftmax: () => X$, LogicalAnd: () => Ni, LogicalNot: () => Ti, LogicalOr: () => Il, LogicalXor: () => K$, LowerBound: () => Cpe, MathBackendCPU: () => rC, MathBackendWebGL: () => n2, Max: () => Ha, MaxPool: () => ja, MaxPool3D: () => lp, MaxPool3DGrad: () => Fg, MaxPoolGrad: () => Dg, MaxPoolWithArgmax: () => Og, Maximum: () => qa, Mean: () => Ka, Min: () => Xa, Minimum: () => Ya, MirrorPad: () => Qa, Mod: () => Cl, MomentumOptimizer: () => Ab, Multinomial: () => Pg, Multiply: () => Za, Neg: () => $i, NonMaxSuppressionV3: () => Ai, NonMaxSuppressionV4: () => Nl, NonMaxSuppressionV5: () => Ei, NotEqual: () => _i, OP_SCOPE_SUFFIX: () => T_, OneHot: () => Di, OnesLike: () => Ri, Optimizer: () => Er, OptimizerConstructors: () => Gr, Pack: () => Fi, PadV2: () => Ja, Pool: () => Npe, Pow: () => eo, Prelu: () => to, Prod: () => no, RMSPropOptimizer: () => Eb, RNN: () => Rr, Range: () => Tl, Rank: () => y_, Real: () => cp, RealDiv: () => Oa, Reciprocal: () => $l, Reduction: () => AO, Relu: () => so, Relu6: () => ao, Reshape: () => Oi, ResizeBilinear: () => ro, ResizeBilinearGrad: () => Lg, ResizeNearestNeighbor: () => _l, ResizeNearestNeighborGrad: () => zg, Reverse: () => Pi, RotateWithOffset: () => Yi, Round: () => zi, Rsqrt: () => oo, SGDOptimizer: () => Rp, ScatterNd: () => Li, SearchSorted: () => Mg, Select: () => Mi, Selu: () => Al, Sequential: () => ty, Sigmoid: () => uo, Sign: () => El, Sin: () => io, Sinh: () => Vi, Slice: () => Bi, Softmax: () => po, Softplus: () => Rl, SpaceToBatchND: () => Wi, SparseFillEmptyRows: () => dp, SparseReshape: () => Dl, SparseSegmentMean: () => pp, SparseSegmentSum: () => hp, SparseToDense: () => fp, SplitV: () => Ui, Sqrt: () => lo, Square: () => Fl, SquaredDifference: () => ho, Step: () => go, StridedSlice: () => Gi, StringNGrams: () => mp, StringSplit: () => Bg, StringToHashBucketFast: () => Vg, Sub: () => fo, Sum: () => co, SymbolicTensor: () => $s, Tan: () => Hi, Tanh: () => mo, Tensor: () => et, TensorBuffer: () => Vt, Tile: () => Tr, TopK: () => qi, Transform: () => ji, Transpose: () => Hs, Unique: () => Wg, Unpack: () => Ki, UnsortedSegmentSum: () => gp, UpperBound: () => Tpe, Variable: () => kd, ZerosLike: () => Xi, _FusedMatMul: () => oa, abs: () => Lt, acos: () => pE, acosh: () => fE, add: () => oe, addN: () => gE, all: () => lS, any: () => Sm, argMax: () => Yu, argMin: () => wE, asin: () => SE, asinh: () => CE, atan: () => TE, atan2: () => _E, atanh: () => EE, avgPool: () => nb, avgPool3d: () => hS, backend: () => $A, backend_util: () => C, basicLSTMCell: () => Hpe, batchNorm: () => Zu, batchNorm2d: () => YE, batchNorm3d: () => ZE, batchNorm4d: () => eR, batchToSpaceND: () => sb, bincount: () => fS, booleanMaskAsync: () => vhe, broadcastArgs: () => sR, broadcastTo: () => id, broadcast_util: () => Qi, browser: () => Gk, buffer: () => Ae, callbacks: () => _he, cast: () => le, ceil: () => oR, clipByValue: () => Wn, clone: () => lr, complex: () => mr, concat: () => Ft, concat1d: () => lR, concat2d: () => dR, concat3d: () => hR, concat4d: () => mR, constraints: () => qM, conv1d: () => mS, conv2d: () => da, conv2dTranspose: () => gS, conv3d: () => bS, conv3dTranspose: () => SR, copyRegisteredKernels: () => Ape, cos: () => ab, cosh: () => vS, cosineWindow: () => GS, cumprod: () => Cm, cumsum: () => xS, customGrad: () => js, data: () => oU, denseBincount: () => _R, deprecationWarn: () => Wk, depthToSpace: () => ER, depthwiseConv2d: () => kp, deregisterOp: () => Ehe, device_util: () => vp, diag: () => qpe, dilation2d: () => OR, disableDeprecationWarnings: () => Dpe, dispose: () => De, disposeVariables: () => Fpe, div: () => xe, divNoNan: () => BR, dot: () => jpe, dropout: () => CF, einsum: () => UR, elu: () => Sp, enableDebugMode: () => Rpe, enableProdMode: () => Epe, enclosingPowerOfTwo: () => NF, engine: () => ds, env: () => K, equal: () => Xn, erf: () => qR, euclideanNorm: () => sD, exp: () => Yn, expandDims: () => Pn, expm1: () => iD, eye: () => CS, fft: () => wb, fill: () => Bl, findBackend: () => Vpe, findBackendFactory: () => Wpe, floor: () => Ip, floorDiv: () => uS, forceHalfFloat: () => I8, fused: () => fa, gather: () => Ju, gatherND: () => kF, gather_util: () => qk, getBackend: () => Mpe, getGradient: () => hx, getKernel: () => lm, getKernelsForBackend: () => cm, getThreadsCount: () => Whe, gpgpu_util: () => dX, grad: () => Ype, grads: () => Qpe, greater: () => Gn, greaterEqual: () => Zi, ifft: () => $d, imag: () => wp, image: () => Kn, inTopKAsync: () => whe, initializers: () => QM, input: () => lV, io: () => An, irfft: () => MS, isFinite: () => Kpe, isInf: () => Xpe, isNaN: () => bD, keep: () => qt, kernel_impls: () => ws, layers: () => hB, leakyRelu: () => lb, less: () => NS, lessEqual: () => Ji, linalg: () => cP, linspace: () => wD, loadGraphModel: () => Rhe, loadGraphModelSync: () => Dhe, loadLayersModel: () => The, localResponseNormalization: () => SD, log: () => Qn, log1p: () => cb, logSigmoid: () => ehe, logSoftmax: () => TS, logSumExp: () => RD, logicalAnd: () => Ds, logicalNot: () => db, logicalOr: () => $S, logicalXor: () => the, losses: () => Ihe, lowerBound: () => LD, matMul: () => We, math: () => CA, max: () => As, maxPool: () => pb, maxPool3d: () => AS, maxPoolWithArgmax: () => WD, maximum: () => Ar, mean: () => It, memory: () => xm, meshgrid: () => nhe, metrics: () => RW, min: () => Nm, minimum: () => Np, mirrorPad: () => jD, mod: () => XD, model: () => Che, models: () => KW, moments: () => hb, movingAverage: () => xhe, mul: () => V, multiRNNCell: () => she, multinomial: () => JD, neg: () => vt, nextFrame: () => ZS, norm: () => ub, notEqual: () => el, oneHot: () => Cd, ones: () => Ln, onesLike: () => Zn, op: () => M, outerProduct: () => rhe, pad: () => bo, pad1d: () => ahe, pad2d: () => ohe, pad3d: () => ihe, pad4d: () => uhe, pool: () => lhe, pow: () => ha, prelu: () => mb, print: () => iA, prod: () => ES, profile: () => Ope, rand: () => che, randomGamma: () => dhe, randomNormal: () => v3, randomUniform: () => Wl, range: () => tl, ready: () => Lpe, real: () => Xu, reciprocal: () => k3, registerBackend: () => xp, registerCallbackConstructor: () => $he, registerGradient: () => Q$, registerKernel: () => Ol, registerOp: () => Ahe, regularizers: () => XW, relu: () => Xs, relu6: () => RS, removeBackend: () => Bpe, reshape: () => U, reverse: () => Jn, reverse1d: () => phe, reverse2d: () => hhe, reverse3d: () => fhe, reverse4d: () => mhe, rfft: () => kb, round: () => DS, rsqrt: () => FS, scalar: () => we, scatterND: () => yF, scatter_util: () => Kk, searchSorted: () => _S, selu: () => OS, separableConv2d: () => F3, sequential: () => Nhe, serialization: () => re, setBackend: () => zpe, setPlatform: () => Upe, setThreadsCount: () => Vhe, setWasmPath: () => Mhe, setWasmPaths: () => Bhe, setWebGLContext: () => sK, setdiff1dAsync: () => P3, shared: () => cv, sigmoid: () => qs, sign: () => L3, signal: () => She, sin: () => PS, sinh: () => zS, slice: () => qe, slice1d: () => yb, slice2d: () => LS, slice3d: () => vb, slice4d: () => Td, slice_util: () => kt, softmax: () => xb, softplus: () => Vl, spaceToBatchND: () => fb, sparse: () => jc, sparseToDense: () => US, spectral: () => khe, split: () => Bn, sqrt: () => dn, square: () => ct, squaredDifference: () => BS, squeeze: () => br, stack: () => es, step: () => Tp, stridedSlice: () => nF, string: () => Yf, sub: () => ge, sum: () => ve, sumOutType: () => yp, tan: () => rF, tanh: () => Qu, tensor: () => ms, tensor1d: () => Zt, tensor2d: () => Zo, tensor3d: () => OA, tensor4d: () => ghe, tensor5d: () => bhe, tensor6d: () => yhe, tensor_util: () => _s, test_util: () => ZA, tidy: () => q, tile: () => hs, time: () => Ppe, topk: () => oF, train: () => Mo, transpose: () => Ge, truncatedNormal: () => Sb, unique: () => Ix, unregisterGradient: () => _pe, unregisterKernel: () => $pe, unsortedSegmentSum: () => cF, unstack: () => Fs, upcastType: () => cn, upperBound: () => pF, util: () => w, valueAndGrad: () => Zpe, valueAndGrads: () => Jpe, variable: () => hF, variableGrads: () => ND, version: () => Ghe, version_converter: () => Fhe, version_core: () => Gpe, version_cpu: () => Ohe, version_layers: () => NI, version_wasm: () => Uhe, version_webgl: () => Phe, webgl: () => zhe, webgl_util: () => nK, webgpu: () => Yie, where: () => vn, whereAsync: () => WS, zeros: () => $t, zerosLike: () => je }); var n$ = Object.create; var Yd = Object.defineProperty; var s$ = Object.getOwnPropertyDescriptor; var nk = Object.getOwnPropertyNames; var r$ = Object.getPrototypeOf; var a$ = Object.prototype.hasOwnProperty; var o$ = (e) => Yd(e, "__esModule", { value: true }); var zt = (e, t) => function() { return t || (0, e[nk(e)[0]])((t = { exports: {} }).exports, t), t.exports; }; var Ee = (e, t) => { for (var n in t) Yd(e, n, { get: t[n], enumerable: true }); }; var i$ = (e, t, n, s) => { if (t && typeof t == "object" || typeof t == "function") for (let r of nk(t)) !a$.call(e, r) && (n || r !== "default") && Yd(e, r, { get: () => t[r], enumerable: !(s = s$(t, r)) || s.enumerable }); return e; }; var wa = (e, t) => i$(o$(Yd(e != null ? n$(r$(e)) : {}, "default", !t && e && e.__esModule ? { get: () => e.default, enumerable: true } : { value: e, enumerable: true })), e); var u$ = 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 (D) { } function s(D, T, L) { this.low = D | 0, this.high = T | 0, this.unsigned = !!L; } s.prototype.__isLong__, Object.defineProperty(s.prototype, "__isLong__", { value: true }); function r(D) { return (D && D.__isLong__) === true; } s.isLong = r; var a = {}, o = {}; function i(D, T) { var L, W, j; return T ? (D >>>= 0, (j = 0 <= D && D < 256) && (W = o[D], W) ? W : (L = l(D, (D | 0) < 0 ? -1 : 0, true), j && (o[D] = L), L)) : (D |= 0, (j = -128 <= D && D < 128) && (W = a[D], W) ? W : (L = l(D, D < 0 ? -1 : 0, false), j && (a[D] = L), L)); } s.fromInt = i; function u(D, T) { if (isNaN(D)) return T ? x : v; if (T) { if (D < 0) return x; if (D >= g) return E; } else { if (D <= -b) return P; if (D + 1 >= b) return R; } return D < 0 ? u(-D, T).neg() : l(D % m | 0, D / m | 0, T); } s.fromNumber = u; function l(D, T, L) { return new s(D, T, L); } s.fromBits = l; var c = Math.pow; function p(D, T, L) { if (D.length === 0) throw Error("empty string"); if (D === "NaN" || D === "Infinity" || D === "+Infinity" || D === "-Infinity") return v; if (typeof T == "number" ? (L = T, T = false) : T = !!T, L = L || 10, L < 2 || 36 < L) throw RangeError("radix"); var W; if ((W = D.indexOf("-")) > 0) throw Error("interior hyphen"); if (W === 0) return p(D.substring(1), T, L).neg(); for (var j = u(c(L, 8)), Y = v, X = 0; X < D.length; X += 8) { var Z = Math.min(8, D.length - X), ne = parseInt(D.substring(X, X + Z), L); if (Z < 8) { var ee = u(c(L, Z)); Y = Y.mul(ee).add(u(ne)); } else Y = Y.mul(j), Y = Y.add(u(ne)); } return Y.unsigned = T, Y; } s.fromString = p; function d(D, T) { return typeof D == "number" ? u(D, T) : typeof D == "string" ? p(D, T) : l(D.low, D.high, typeof T == "boolean" ? T : D.unsigned); } s.fromValue = d; var h = 1 << 16, f = 1 << 24, m = h * h, g = m * m, b = g / 2, y = i(f), v = i(0); s.ZERO = v; var x = i(0, true); s.UZERO = x; var k = i(1); s.ONE = k; var I = i(1, true); s.UONE = I; var $ = i(-1); s.NEG_ONE = $; var R = l(-1, 2147483647, false); s.MAX_VALUE = R; var E = l(-1, -1, true); s.MAX_UNSIGNED_VALUE = E; var P = l(0, -2147483648, false); s.MIN_VALUE = P; var A = s.prototype; A.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low; }, A.toNumber = function() { return this.unsigned ? (this.high >>> 0) * m + (this.low >>> 0) : this.high * m + (this.low >>> 0); }, A.toString = function(T) { if (T = T || 10, T < 2 || 36 < T) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) if (this.eq(P)) { var L = u(T), W = this.div(L), j = W.mul(L).sub(this); return W.toString(T) + j.toInt().toString(T); } else return "-" + this.neg().toString(T); for (var Y = u(c(T, 6), this.unsigned), X = this, Z = ""; ; ) { var ne = X.div(Y), ee = X.sub(ne.mul(Y)).toInt() >>> 0, se = ee.toString(T); if (X = ne, X.isZero()) return se + Z; for (; se.length < 6; ) se = "0" + se; Z = "" + se + Z; } }, A.getHighBits = function() { return this.high; }, A.getHighBitsUnsigned = function() { return this.high >>> 0; }, A.getLowBits = function() { return this.low; }, A.getLowBitsUnsigned = function() { return this.low >>> 0; }, A.getNumBitsAbs = function() { if (this.isNegative()) return this.eq(P) ? 64 : this.neg().getNumBitsAbs(); for (var T = this.high != 0 ? this.high : this.low, L = 31; L > 0 && (T & 1 << L) == 0; L--) ; return this.high != 0 ? L + 33 : L + 1; }, A.isZero = function() { return this.high === 0 && this.low === 0; }, A.eqz = A.isZero, A.isNegative = function() { return !this.unsigned && this.high < 0; }, A.isPositive = function() { return this.unsigned || this.high >= 0; }, A.isOdd = function() { return (this.low & 1) === 1; }, A.isEven = function() { return (this.low & 1) === 0; }, A.equals = function(T) { return r(T) || (T = d(T)), this.unsigned !== T.unsigned && this.high >>> 31 === 1 && T.high >>> 31 === 1 ? false : this.high === T.high && this.low === T.low; }, A.eq = A.equals, A.notEquals = function(T) { return !this.eq(T); }, A.neq = A.notEquals, A.ne = A.notEquals, A.lessThan = function(T) { return this.comp(T) < 0; }, A.lt = A.lessThan, A.lessThanOrEqual = function(T) { return this.comp(T) <= 0; }, A.lte = A.lessThanOrEqual, A.le = A.lessThanOrEqual, A.greaterThan = function(T) { return this.comp(T) > 0; }, A.gt = A.greaterThan, A.greaterThanOrEqual = function(T) { return this.comp(T) >= 0; }, A.gte = A.greaterThanOrEqual, A.ge = A.greaterThanOrEqual, A.compare = function(T) { if (r(T) || (T = d(T)), this.eq(T)) return 0; var L = this.isNegative(), W = T.isNegative(); return L && !W ? -1 : !L && W ? 1 : this.unsigned ? T.high >>> 0 > this.high >>> 0 || T.high === this.high && T.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(T).isNegative() ? -1 : 1; }, A.comp = A.compare, A.negate = function() { return !this.unsigned && this.eq(P) ? P : this.not().add(k); }, A.neg = A.negate, A.add = function(T) { r(T) || (T = d(T)); var L = this.high >>> 16, W = this.high & 65535, j = this.low >>> 16, Y = this.low & 65535, X = T.high >>> 16, Z = T.high & 65535, ne = T.low >>> 16, ee = T.low & 65535, se = 0, te = 0, ie = 0, ae = 0; return ae += Y + ee, ie += ae >>> 16, ae &= 65535, ie += j + ne, te += ie >>> 16, ie &= 65535, te += W + Z, se += te >>> 16, te &= 65535, se += L + X, se &= 65535, l(ie << 16 | ae, se << 16 | te, this.unsigned); }, A.subtract = function(T) { return r(T) || (T = d(T)), this.add(T.neg()); }, A.sub = A.subtract, A.multiply = function(T) { if (this.isZero()) return v; if (r(T) || (T = d(T)), n) { var L = n.mul(this.low, this.high, T.low, T.high); return l(L, n.get_high(), this.unsigned); } if (T.isZero()) return v; if (this.eq(P)) return T.isOdd() ? P : v; if (T.eq(P)) return this.isOdd() ? P : v; if (this.isNegative()) return T.isNegative() ? this.neg().mul(T.neg()) : this.neg().mul(T).neg(); if (T.isNegative()) return this.mul(T.neg()).neg(); if (this.lt(y) && T.lt(y)) return u(this.toNumber() * T.toNumber(), this.unsigned); var W = this.high >>> 16, j = this.high & 65535, Y = this.low >>> 16, X = this.low & 65535, Z = T.high >>> 16, ne = T.high & 65535, ee = T.low >>> 16, se = T.low & 65535, te = 0, ie = 0, ae = 0, de = 0; return de += X * se, ae += de >>> 16, de &= 65535, ae += Y * se, ie += ae >>> 16, ae &= 65535, ae += X * ee, ie += ae >>> 16, ae &= 65535, ie += j * se, te += ie >>> 16, ie &= 65535, ie += Y * ee, te += ie >>> 16, ie &= 65535, ie += X * ne, te += ie >>> 16, ie &= 65535, te += W * se + j * ee + Y * ne + X * Z, te &= 65535, l(ae << 16 | de, te << 16 | ie, this.unsigned); }, A.mul = A.multiply, A.divide = function(T) { if (r(T) || (T = d(T)), T.isZero()) throw Error("division by zero"); if (n) { if (!this.unsigned && this.high === -2147483648 && T.low === -1 && T.high === -1) return this; var L = (this.unsigned ? n.div_u : n.div_s)(this.low, this.high, T.low, T.high); return l(L, n.get_high(), this.unsigned); } if (this.isZero()) return this.unsigned ? x : v; var W, j, Y; if (this.unsigned) { if (T.unsigned || (T = T.toUnsigned()), T.gt(this)) return x; if (T.gt(this.shru(1))) return I; Y = x; } else { if (this.eq(P)) { if (T.eq(k) || T.eq($)) return P; if (T.eq(P)) return k; var X = this.shr(1); return W = X.div(T).shl(1), W.eq(v) ? T.isNegative() ? k : $ : (j = this.sub(T.mul(W)), Y = W.add(j.div(T)), Y); } else if (T.eq(P)) return this.unsigned ? x : v; if (this.isNegative()) return T.isNegative() ? this.neg().div(T.neg()) : this.neg().div(T).neg(); if (T.isNegative()) return this.div(T.neg()).neg(); Y = v; } for (j = this; j.gte(T); ) { W = Math.max(1, Math.floor(j.toNumber() / T.toNumber())); for (var Z = Math.ceil(Math.log(W) / Math.LN2), ne = Z <= 48 ? 1 : c(2, Z - 48), ee = u(W), se = ee.mul(T); se.isNegative() || se.gt(j); ) W -= ne, ee = u(W, this.unsigned), se = ee.mul(T); ee.isZero() && (ee = k), Y = Y.add(ee), j = j.sub(se); } return Y; }, A.div = A.divide, A.modulo = function(T) { if (r(T) || (T = d(T)), n) { var L = (this.unsigned ? n.rem_u : n.rem_s)(this.low, this.high, T.low, T.high); return l(L, n.get_high(), this.unsigned); } return this.sub(this.div(T).mul(T)); }, A.mod = A.modulo, A.rem = A.modulo, A.not = function() { return l(~this.low, ~this.high, this.unsigned); }, A.and = function(T) { return r(T) || (T = d(T)), l(this.low & T.low, this.high & T.high, this.unsigned); }, A.or = function(T) { return r(T) || (T = d(T)), l(this.low | T.low, this.high | T.high, this.unsigned); }, A.xor = function(T) { return r(T) || (T = d(T)), l(this.low ^ T.low, this.high ^ T.high, this.unsigned); }, A.shiftLeft = function(T) { return r(T) && (T = T.toInt()), (T &= 63) === 0 ? this : T < 32 ? l(this.low << T, this.high << T | this.low >>> 32 - T, this.unsigned) : l(0, this.low << T - 32, this.unsigned); }, A.shl = A.shiftLeft, A.shiftRight = function(T) { return r(T) && (T = T.toInt()), (T &= 63) === 0 ? this : T < 32 ? l(this.low >>> T | this.high << 32 - T, this.high >> T, this.unsigned) : l(this.high >> T - 32, this.high >= 0 ? 0 : -1, this.unsigned); }, A.shr = A.shiftRight, A.shiftRightUnsigned = function(T) { if (r(T) && (T = T.toInt()), T &= 63, T === 0) return this; var L = this.high; if (T < 32) { var W = this.low; return l(W >>> T | L << 32 - T, L >>> T, this.unsigned); } else return T === 32 ? l(L, 0, this.unsigned) : l(L >>> T - 32, 0, this.unsigned); }, A.shru = A.shiftRightUnsigned, A.shr_u = A.shiftRightUnsigned, A.toSigned = function() { return this.unsigned ? l(this.low, this.high, false) : this; }, A.toUnsigned = function() { return this.unsigned ? this : l(this.low, this.high, true); }, A.toBytes = function(T) { return T ? this.toBytesLE() : this.toBytesBE(); }, A.toBytesLE = function() { var T = this.high, L = this.low; return [L & 255, L >>> 8 & 255, L >>> 16 & 255, L >>> 24, T & 255, T >>> 8 & 255, T >>> 16 & 255, T >>> 24]; }, A.toBytesBE = function() { var T = this.high, L = this.low; return [T >>> 24, T >>> 16 & 255, T >>> 8 & 255, T & 255, L >>> 24, L >>> 16 & 255, L >>> 8 & 255, L & 255]; }, s.fromBytes = function(T, L, W) { return W ? s.fromBytesLE(T, L) : s.fromBytesBE(T, L); }, s.fromBytesLE = function(T, L) { return new s(T[0] | T[1] << 8 | T[2] << 16 | T[3] << 24, T[4] | T[5] << 8 | T[6] << 16 | T[7] << 24, L); }, s.fromBytesBE = function(T, L) { return new s(T[4] << 24 | T[5] << 16 | T[6] << 8 | T[7], T[0] << 24 | T[1] << 16 | T[2] << 8 | T[3], L); }; } }); var l$ = zt({ "(disabled):src/node_modules/node-fetch/browser.js"() { } }); var c$ = zt({ "(disabled):util"() { } }); var d$ = 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 o(l, c) { return c.c = l.c, c.s0 = l.s0, c.s1 = l.s1, c.s2 = l.s2, c; } function i(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" && o(d, p), h.state = function() { return o(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 = i : r && r.amd ? r(function() { return i; }) : this.alea = i; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var p$ = 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 o(u, l) { return l.x = u.x, l.y = u.y, l.z = u.z, l.w = u.w, l; } function i(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" && o(p, c), d.state = function() { return o(c, {}); }), d; } s && s.exports ? s.exports = i : r && r.amd ? r(function() { return i; }) : this.xor128 = i; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var h$ = 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 o(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 i(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" && o(p, c), d.state = function() { return o(c, {}); }), d; } s && s.exports ? s.exports = i : r && r.amd ? r(function() { return i; }) : this.xorwow = i; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var f$ = 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 o(u, l) { return l.x = u.x.slice(), l.i = u.i, l; } function i(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 && o(p, c), d.state = function() { return o(c, {}); }), d; } s && s.exports ? s.exports = i : r && r.amd ? r(function() { return i; }) : this.xorshift7 = i; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var m$ = 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 o(u, l) { return l.i = u.i, l.w = u.w, l.X = u.X.slice(), l; } function i(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 && o(p, c), d.state = function() { return o(c, {}); }), d; } s && s.exports ? s.exports = i : r && r.amd ? r(function() { return i; }) : this.xor4096 = i; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var g$ = 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 o(u, l) { return l.a = u.a, l.b = u.b, l.c = u.c, l.d = u.d, l; } function i(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" && o(p, c), d.state = function() { return o(c, {}); }), d; } s && s.exports ? s.exports = i : r && r.amd ? r(function() { return i; }) : this.tychei = i; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var b$ = zt({ "(disabled):crypto"() { } }); var y$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { (function(n, s, r) { var a = 256, o = 6, i = 52, u = "random", l = r.pow(a, o), c = r.pow(2, i), p = c * 2, d = a - 1, h; function f(k, I, $) { var R = []; I = I == true ? { entropy: true } : I || {}; var E = y(b(I.entropy ? [k, x(s)] : k == null ? v() : k, 3), R), P = new m(R), A = function() { for (var D = P.g(o), T = l, L = 0; D < c; ) D = (D + L) * a, T *= a, L = P.g(1); for (; D >= p; ) D /= 2, T /= 2, L >>>= 1; return (D + L) / T; }; return A.int32 = function() { return P.g(4) | 0; }, A.quick = function() { return P.g(4) / 4294967296; }, A.double = A, y(x(P.S), s), (I.pass || $ || function(D, T, L, W) { return W && (W.S && g(W, P), D.state = function() { return g(P, {}); }), L ? (r[u] = D, T) : D; })(A, E, "global" in I ? I.global : this == r, I.state); } function m(k) { var I, $ = k.length, R = this, E = 0, P = R.i = R.j = 0, A = R.S = []; for ($ || (k = [$++]); E < a; ) A[E] = E++; for (E = 0; E < a; E++) A[E] = A[P = d & P + k[E % $] + (I = A[E])], A[P] = I; (R.g = function(D) { for (var T, L = 0, W = R.i, j = R.j, Y = R.S; D--; ) T = Y[W = d & W + 1], L = L * a + Y[d & (Y[W] = Y[j = d & j + T]) + (Y[j] = T)]; return R.i = W, R.j = j, L; })(a); } function g(k, I) { return I.i = k.i, I.j = k.j, I.S = k.S.slice(), I; } function b(k, I) { var $ = [], R = typeof k, E; if (I && R == "object") for (E in k) try { $.push(b(k[E], I - 1)); } catch (P) { } return $.length ? $ : R == "string" ? k : k + "\0"; } function y(k, I) { for (var $ = k + "", R, E = 0; E < $.length; ) I[d & E] = d & (R ^= I[d & E] * 19) + $.charCodeAt(E++); return x(I); } function v() { try { var k; return h && (k = h.randomBytes) ? k = k(a) : (k = new Uint8Array(a), (n.crypto || n.msCrypto).getRandomValues(k)), x(k); } catch (R) { var I = n.navigator, $ = I && I.plugins; return [+new Date(), n, $, n.screen, x(s)]; } } function x(k) { return String.fromCharCode.apply(0, k); } if (y(r.random(), s), typeof t == "object" && t.exports) { t.exports = f; try { h = b$(); } catch (k) { } } else typeof define == "function" && define.amd ? define(function() { return f; }) : r["seed" + u] = f; })(typeof self != "undefined" ? self : e, [], Math); } }); var Qd = zt({ "src/node_modules/seedrandom/index.js"(e, t) { var n = d$(), s = p$(), r = h$(), a = f$(), o = m$(), i = g$(), u = y$(); u.alea = n, u.xor128 = s, u.xorwow = r, u.xorshift7 = a, u.xor4096 = o, u.tychei = i, t.exports = u; } }); var sk = zt({ "(disabled):src/node_modules/string_decoder/index.js"() { } }); var pg = zt({ "(disabled):fs"() { } }); var bd = zt({ "(disabled):path"() { } }); var v$ = zt({ "(disabled):worker_threads"() { } }); var x$ = zt({ "(disabled):perf_hooks"() { } }); var w$ = zt({ "(disabled):os"() { } }); var k$ = 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), cc; } function o() { return Ce.buffer != nn && rs(Ce.buffer), dc; } function i() { return Ce.buffer != nn && rs(Ce.buffer), bu; } function u() { return Ce.buffer != nn && rs(Ce.buffer), pc; } function l() { return Ce.buffer != nn && rs(Ce.buffer), hc; } function c() { return Ce.buffer != nn && rs(Ce.buffer), fc; } function p() { return Ce.buffer != nn && rs(Ce.buffer), mc; } var d = typeof r != "undefined" ? r : {}, h, f; d.ready = new Promise(function(N, F) { h = N, f = F; }); 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 = (N, F) => { throw F; }, x = typeof window == "object", k = typeof importScripts == "function", I = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", $ = d.ENVIRONMENT_IS_PTHREAD || false, R = ""; function E(N) { return d.locateFile ? d.locateFile(N, R) : R + N; } var P, A, D, T; function L(N) { if (N instanceof Nu) return; ee("exiting due to exception: " + N); } var W, j, Y; if (I) { k ? R = bd().dirname(R) + "/" : R = __dirname + "/", Y = () => { j || (W = pg(), j = bd()); }, P = function(B, Q) { return Y(), B = j.normalize(B), W.readFileSync(B, Q ? void 0 : "utf8"); }, D = (F) => { var B = P(F, true); return B.buffer || (B = new Uint8Array(B)), B; }, A = (F, B, Q) => { Y(), F = j.normalize(F), W.readFile(F, function(ue, he) { ue ? Q(ue) : B(he.buffer); }); }, process.argv.length > 1 && (y = process.argv[1].replace(/\\/g, "/")), b = process.argv.slice(2), process.on("uncaughtException", function(F) { if (!(F instanceof Nu)) throw F; }), process.on("unhandledRejection", function(F) { throw F; }), v = (F, B) => { if (Lr()) throw process.exitCode = F, B; L(B), process.exit(F); }, d.inspect = function() { return "[Emscripten Module object]"; }; let N; try { N = v$(); } catch (F) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), F; } global.Worker = N.Worker; } else (x || k) && (k ? R = self.location.href : typeof document != "undefined" && document.currentScript && (R = document.currentScript.src), typeof s != "undefined" && s && (R = s), R.indexOf("blob:") !== 0 ? R = R.substr(0, R.replace(/[?#].*/, "").lastIndexOf("/") + 1) : R = "", I || (P = (N) => { var F = new XMLHttpRequest(); return F.open("GET", N, false), F.send(null), F.responseText; }, k && (D = (N) => { var F = new XMLHttpRequest(); return F.open("GET", N, false), F.responseType = "arraybuffer", F.send(null), new Uint8Array(F.response); }), A = (N, F, B) => { var Q = new XMLHttpRequest(); Q.open("GET", N, true), Q.responseType = "arraybuffer", Q.onload = () => { if (Q.status == 200 || Q.status == 0 && Q.response) { F(Q.response); return; } B(); }, Q.onerror = B, Q.send(null); }), T = (N) => document.title = N); I && typeof performance == "undefined" && (global.performance = x$().performance); var X = console.log.bind(console), Z = console.warn.bind(console); I && (Y(), X = (N) => W.writeSync(1, N + ` `), Z = (N) => W.writeSync(2, N + ` `)); var ne = d.print || X, 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 te(N) { te.shown || (te.shown = {}), te.shown[N] || (te.shown[N] = 1, ee(N)); } function ie(N, F) { if (typeof WebAssembly.Function == "function") { for (var B = { i: "i32", j: "i64", f: "f32", d: "f64" }, Q = { parameters: [], results: F[0] == "v" ? [] : [B[F[0]]] }, ue = 1; ue < F.length; ++ue) Q.parameters.push(B[F[ue]]); return new WebAssembly.Function(Q, N); } var he = [1, 0, 1, 96], ye = F.slice(0, 1), Te = F.slice(1), bt = { i: 127, j: 126, f: 125, d: 124 }; he.push(Te.length); for (var ue = 0; ue < Te.length; ++ue) he.push(bt[Te[ue]]); ye == "v" ? he.push(0) : he = he.concat([1, bt[ye]]), he[1] = he.length - 2; var us = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(he, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), ls = new WebAssembly.Module(us), Gc = new WebAssembly.Instance(ls, { e: { f: N } }), Tu = Gc.exports.f; return Tu; } var ae = [], de; function me() { if (ae.length) return ae.pop(); try { Fn.grow(1); } catch (N) { throw N instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : N; } return Fn.length - 1; } function ke(N, F) { for (var B = N; B < N + F; B++) { var Q = Eo(B); Q && de.set(Q, B); } } var Ie = 0, Re = (N) => { Ie = N; }, Pe = Atomics.load, Xe = Atomics.store, Je = Atomics.compareExchange, Ye; d.wasmBinary && (Ye = d.wasmBinary); var tt = d.noExitRuntime || true; typeof WebAssembly != "object" && $o("no native wasm support detected"); var Ce, ut, ot = false, Jt; function Nt(N, F) { N || $o(F); } function In(N) { var F = d["_" + N]; return F; } function Et(N, F, B, Q, ue) { var he = { string: function(Tn) { var Lo = 0; if (Tn != null && Tn !== 0) { var dx = (Tn.length << 2) + 1; Lo = zo(dx), Ls(Tn, Lo, dx); } return Lo; }, array: function(Tn) { var Lo = zo(Tn.length); return Ms(Tn, Lo), Lo; } }; function ye(Tn) { return F === "string" ? tn(Tn) : F === "boolean" ? Boolean(Tn) : Tn; } var Te = In(N), bt = [], us = 0; if (Q) for (var ls = 0; ls < Q.length; ls++) { var Gc = he[B[ls]]; Gc ? (us === 0 && (us = Uf()), bt[ls] = Gc(Q[ls])) : bt[ls] = Q[ls]; } var Tu = Te.apply(null, bt); function t$(Tn) { return us !== 0 && Bc(us), ye(Tn); } return Tu = t$(Tu), Tu; } function en(N, F, B, Q) { B = B || []; var ue = B.every(function(ye) { return ye === "number"; }), he = F !== "string"; return he && ue && !Q ? In(N) : function() { return Et(N, F, B, arguments, Q); }; } var Cn = 1; function Nn(N) { var F = new TextDecoder(N); this.decode = (B) => (B.buffer instanceof SharedArrayBuffer && (B = new Uint8Array(B)), F.decode.call(F, B)); } var Yt = typeof TextDecoder != "undefined" ? new Nn("utf8") : void 0; function Dn(N, F, B) { for (var Q = F + B, ue = F; N[ue] && !(ue >= Q); ) ++ue; if (ue - F > 16 && N.subarray && Yt) return Yt.decode(N.subarray(F, ue)); for (var he = ""; F < ue; ) { var ye = N[F++]; if (!(ye & 128)) { he += String.fromCharCode(ye); continue; } var Te = N[F++] & 63; if ((ye & 224) == 192) { he += String.fromCharCode((ye & 31) << 6 | Te); continue; } var bt = N[F++] & 63; if ((ye & 240) == 224 ? ye = (ye & 15) << 12 | Te << 6 | bt : ye = (ye & 7) << 18 | Te << 12 | bt << 6 | N[F++] & 63, ye < 65536) he += String.fromCharCode(ye); else { var us = ye - 65536; he += String.fromCharCode(55296 | us >> 10, 56320 | us & 1023); } } return he; } function tn(N, F) { return N ? Dn(o(), N, F) : ""; } function zs(N, F, B, Q) { if (!(Q > 0)) return 0; for (var ue = B, he = B + Q - 1, ye = 0; ye < N.length; ++ye) { var Te = N.charCodeAt(ye); if (Te >= 55296 && Te <= 57343) { var bt = N.charCodeAt(++ye); Te = 65536 + ((Te & 1023) << 10) | bt & 1023; } if (Te <= 127) { if (B >= he) break; F[B++] = Te; } else if (Te <= 2047) { if (B + 1 >= he) break; F[B++] = 192 | Te >> 6, F[B++] = 128 | Te & 63; } else if (Te <= 65535) { if (B + 2 >= he) break; F[B++] = 224 | Te >> 12, F[B++] = 128 | Te >> 6 & 63, F[B++] = 128 | Te & 63; } else { if (B + 3 >= he) break; F[B++] = 240 | Te >> 18, F[B++] = 128 | Te >> 12 & 63, F[B++] = 128 | Te >> 6 & 63, F[B++] = 128 | Te & 63; } } return F[B] = 0, B - ue; } function Ls(N, F, B) { return zs(N, o(), F, B); } function Co(N) { for (var F = 0, B = 0; B < N.length; ++B) { var Q = N.charCodeAt(B); Q >= 55296 && Q <= 57343 && (Q = 65536 + ((Q & 1023) << 10) | N.charCodeAt(++B) & 1023), Q <= 127 ? ++F : Q <= 2047 ? F += 2 : Q <= 65535 ? F += 3 : F += 4; } return F; } var Zs = typeof TextDecoder != "undefined" ? new Nn("utf-16le") : void 0; function Ms(N, F) { a().set(N, F); } function gu(N, F, B) { for (var Q = 0; Q < N.length; ++Q) a()[F++ >> 0] = N.charCodeAt(Q); B || (a()[F >> 0] = 0); } function No(N, F) { return N % F > 0 && (N += F - N % F), N; } var nn, cc, dc, bu, pc, hc, Hv, fc, mc; $ && (nn = d.buffer); function rs(N) { nn = N, d.HEAP8 = cc = new Int8Array(N), d.HEAP16 = bu = new Int16Array(N), d.HEAP32 = hc = new Int32Array(N), d.HEAPU8 = dc = new Uint8Array(N), d.HEAPU16 = pc = new Uint16Array(N), d.HEAPU32 = Hv = new Uint32Array(N), d.HEAPF32 = fc = new Float32Array(N), d.HEAPF64 = mc = new Float64Array(N); } var gc = d.INITIAL_MEMORY || 16777216; if ($) Ce = d.wasmMemory, nn = d.buffer; else if (d.wasmMemory) Ce = d.wasmMemory; else if (Ce = new WebAssembly.Memory({ initial: gc / 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"), I && 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), gc = nn.byteLength, rs(nn); var Fn, To = [], Js = [], ch = [], bc = [], zr = false, dh = false, yc = 0; function Lr() { return tt || yc > 0; } function sn() { if (d.preRun) for (typeof d.preRun == "function" && (d.preRun = [d.preRun]); d.preRun.length; ) qv(d.preRun.shift()); Sc(To); } function yu() { zr = true, !$ && Sc(Js); } function ph() { $ || ($e.terminateAllThreads(), dh = true); } function hh() { if (!$) { if (d.postRun) for (typeof d.postRun == "function" && (d.postRun = [d.postRun]); d.postRun.length; ) vu(d.postRun.shift()); Sc(bc); } } function qv(N) { To.unshift(N); } function jv(N) { Js.unshift(N); } function vu(N) { bc.unshift(N); } var er = 0, vc = null, as = null; function xu(N) { er++, d.monitorRunDependencies && d.monitorRunDependencies(er); } function Kv(N) { if (er--, d.monitorRunDependencies && d.monitorRunDependencies(er), er == 0 && (vc !== null && (clearInterval(vc), vc = null), as)) { var F = as; as = null, F(); } } d.preloadedImages = {}, d.preloadedAudios = {}; function $o(N) { $ ? postMessage({ cmd: "onAbort", arg: N }) : d.onAbort && d.onAbort(N), N = "Aborted(" + N + ")", ee(N), ot = true, Jt = 1, N += ". Build with -s ASSERTIONS=1 for more info."; var F = new WebAssembly.RuntimeError(N); throw f(F), F; } var fh = "data:application/octet-stream;base64,"; function xc(N) { return N.startsWith(fh); } function wc(N) { return N.startsWith("file://"); } var rn; rn = "tfjs-backend-wasm-threaded-simd.wasm", xc(rn) || (rn = E(rn)); function kc(N) { try { if (N == rn && Ye) return new Uint8Array(Ye); if (D) return D(N); throw "both async and sync fetching of the wasm failed"; } catch (F) { $o(F); } } function _o() { if (!Ye && (x || k)) { if (typeof fetch == "function" && !wc(rn)) return fetch(rn, { credentials: "same-origin" }).then(function(N) { if (!N.ok) throw "failed to load wasm binary file at '" + rn + "'"; return N.arrayBuffer(); }).catch(function() { return kc(rn); }); if (A) return new Promise(function(N, F) { A(rn, function(B) { N(new Uint8Array(B)); }, F); }); } return Promise.resolve().then(function() { return kc(rn); }); } function mh() { var N = { env: Oc, wasi_snapshot_preview1: Oc }; function F(ye, Te) { var bt = ye.exports; if (d.asm = bt, kh(d.asm.emscripten_tls_init), Fn = d.asm.__indirect_function_table, jv(d.asm.__wasm_call_ctors), ut = Te, !$) { var us = $e.unusedWorkers.length; $e.unusedWorkers.forEach(function(ls) { $e.loadWasmModuleToWorker(ls, function() { --us || Kv("wasm-instantiate"); }); }); } } $ || xu("wasm-instantiate"); function B(ye) { F(ye.instance, ye.module); } function Q(ye) { return _o().then(function(Te) { return WebAssembly.instantiate(Te, N); }).then(function(Te) { return Te; }).then(ye, function(Te) { ee("failed to asynchronously prepare wasm: " + Te), $o(Te); }); } function ue() { return !Ye && typeof WebAssembly.instantiateStreaming == "function" && !xc(rn) && !wc(rn) && typeof fetch == "function" ? fetch(rn, { credentials: "same-origin" }).then(function(ye) { var Te = WebAssembly.instantiateStreaming(ye, N); 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 he = d.instantiateWasm(N, F); return he; } catch (ye) { return ee("Module.instantiateWasm callback failed with error: " + ye), false; } return ue().catch(f), {}; } var Xv, Yv, gh = {}; function Sc(N) { for (; N.length > 0; ) { var F = N.shift(); if (typeof F == "function") { F(d); continue; } var B = F.func; typeof B == "number" ? F.arg === void 0 ? Eo(B)() : Eo(B)(F.arg) : B(F.arg === void 0 ? null : F.arg); } } function Ao(N) { var F = Uf(), B = N(); return Bc(F), B; } function lT(N) { return N; } function Qv(N) { var F = /\b_Z[\w\d_]+/g; return N.replace(F, function(B) { var Q = B; return B === Q ? B : Q + " [" + B + "]"; }); } function bh(N) { l()[N >> 2] = 0; var F = $e.pthreads[N]; delete $e.pthreads[N], F.worker.terminate(), Wf(N), $e.runningWorkers.splice($e.runningWorkers.indexOf(F.worker), 1), F.worker.pthread = void 0; } function yh(N) { var F = $e.pthreads[N]; F.worker.postMessage({ cmd: "cancel" }); } function Ic(N) { var F = $e.pthreads[N]; if (F) { l()[N >> 2] = 0; var B = F.worker; $e.returnWorkerToPool(B); } } function Cc(N) { ZT(N); } function vh(N) { if (N instanceof Nu || N == "unwind") return Jt; v(1, N); } var $e = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], init: function() { $ ? $e.initWorker() : $e.initMainThread(); }, initMainThread: function() { for (var N = 8, F = 0; F < N; ++F) $e.allocateUnusedWorker(); }, initWorker: function() { tt = false; }, pthreads: {}, setExitStatus: function(N) { Jt = N; }, terminateAllThreads: function() { for (var N in $e.pthreads) { var F = $e.pthreads[N]; F && F.worker && $e.returnWorkerToPool(F.worker); } for (var B = 0; B < $e.unusedWorkers.length; ++B) { var Q = $e.unusedWorkers[B]; Q.terminate(); } $e.unusedWorkers = []; }, returnWorkerToPool: function(N) { $e.runWithoutMainThreadQueuedCalls(function() { delete $e.pthreads[N.pthread.threadInfoStruct], $e.unusedWorkers.push(N), $e.runningWorkers.splice($e.runningWorkers.indexOf(N), 1), Wf(N.pthread.threadInfoStruct), N.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(N) { l()[cx >> 2] = 0; try { N(); } finally { l()[cx >> 2] = 1; } }, receiveObjectTransfer: function(N) { }, threadInit: function() { for (var N in $e.tlsInitFunctions) $e.tlsInitFunctions[N](); }, loadWasmModuleToWorker: function(N, F) { N.onmessage = (B) => { var Q = B.data, ue = Q.cmd; if (N.pthread && ($e.currentProxiedOperationCallerThread = N.pthread.threadInfoStruct), Q.targetThread && Q.targetThread != Mc()) { var he = $e.pthreads[Q.targetThread]; he ? he.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" ? ax() : ue === "spawnThread" ? Tc(Q) : ue === "cleanupThread" ? Ic(Q.thread) : ue === "killThread" ? bh(Q.thread) : ue === "cancelThread" ? yh(Q.thread) : ue === "loaded" ? (N.loaded = true, F && F(N), N.runPthread && (N.runPthread(), delete N.runPthread)) : ue === "print" ? ne("Thread " + Q.threadId + ": " + Q.text) : ue === "printErr" ? ee("Thread " + Q.threadId + ": " + Q.text) : ue === "alert" ? alert("Thread " + Q.threadId + ": " + Q.text) : Q.target === "setimmediate" ? N.postMessage(Q) : ue === "onAbort" ? d.onAbort && d.onAbort(Q.arg) : ee("worker sent an unknown command " + ue), $e.currentProxiedOperationCallerThread = void 0; }, N.onerror = (B) => { var Q = "worker sent an error!"; throw ee(Q + " " + B.filename + ":" + B.lineno + ": " + B.message), B; }, I && (N.on("message", function(B) { N.onmessage({ data: B }); }), N.on("error", function(B) { N.onerror(B); }), N.on("detachedExit", function() { })), N.postMessage({ cmd: "load", urlOrBlob: d.mainScriptUrlOrBlob || s, wasmMemory: Ce, wasmModule: ut }); }, allocateUnusedWorker: function() { var N = E("tfjs-backend-wasm-threaded-simd.worker.js"); $e.unusedWorkers.push(new Worker(N)); }, getNewWorker: function() { return $e.unusedWorkers.length == 0 && ($e.allocateUnusedWorker(), $e.loadWasmModuleToWorker($e.unusedWorkers[0])), $e.unusedWorkers.pop(); } }; function xh() { var N = Mc(), F = l()[N + 44 >> 2], B = l()[N + 48 >> 2], Q = F - B; lx(F, Q), Bc(F); } d.establishStackSpace = xh; function Nc(N) { if ($) return Vr(1, 0, N); try { Cc(N); } catch (F) { vh(F); } } var Mr = []; function Eo(N) { var F = Mr[N]; return F || (N >= Mr.length && (Mr.length = N + 1), Mr[N] = F = Fn.get(N)), F; } function wh(N, F) { return Eo(N)(F); } d.invokeEntryPoint = wh; function Zv() { var N = new Error(); if (!N.stack) { try { throw new Error(); } catch (F) { N = F; } if (!N.stack) return "(no stack trace available)"; } return N.stack.toString(); } function kh(N, F, B) { $e.tlsInitFunctions.push(N); } function Jv(N, F) { Fn.set(N, F), Mr[N] = F; } var Br; I ? Br = () => { var N = process.hrtime(); return N[0] * 1e3 + N[1] / 1e6; } : $ ? Br = () => performance.now() - d.__performance_now_clock_drift : Br = () => performance.now(); var Sh = true; function Ih(N) { return l()[rx() >> 2] = N, N; } function Ch(N, F) { var B; if (N === 0) B = Date.now(); else if ((N === 1 || N === 4) && Sh) B = Br(); else return Ih(28), -1; return l()[F >> 2] = B / 1e3 | 0, l()[F + 4 >> 2] = B % 1e3 * 1e3 * 1e3 | 0, 0; } function Nh(N, F) { return Ch(N, F); } function Th(N) { ox(N, !k, 1, !x), $e.threadInit(); } function $h(N) { $ ? postMessage({ cmd: "cleanupThread", thread: N }) : Ic(N); } function Tc(N) { var F = $e.getNewWorker(); if (!F) return 6; $e.runningWorkers.push(F); var B = $e.pthreads[N.pthread_ptr] = { worker: F, threadInfoStruct: N.pthread_ptr }; F.pthread = B; var Q = { cmd: "run", start_routine: N.startRoutine, arg: N.arg, threadInfoStruct: N.pthread_ptr }; return F.runPthread = () => { Q.time = performance.now(), F.postMessage(Q, N.transferList); }, F.loaded && (F.runPthread(), delete F.runPthread), 0; } function _h(N, F, B, Q) { if (typeof SharedArrayBuffer == "undefined") return ee("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; var ue = [], he = 0; if ($ && (ue.length === 0 || he)) return ix(687865856, N, F, B, Q); if (he) return he; var ye = { startRoutine: B, pthread_ptr: N, arg: Q, transferList: ue }; return $ ? (ye.cmd = "spawnThread", postMessage(ye, ue), 0) : Tc(ye); } function Ah() { return 2097152; } function Eh(N, F) { if (N == F) postMessage({ cmd: "processQueuedMainThreadWork" }); else if ($) postMessage({ targetThread: N, cmd: "processThreadQueue" }); else { var B = $e.pthreads[N], Q = B && B.worker; if (!Q) return; Q.postMessage({ cmd: "processThreadQueue" }); } return 1; } function Rh() { $o(""); } function Dh() { I || k || te("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); } function $c() { return 2147483648; } function Fh(N, F, B) { o().copyWithin(N, F, F + B); } function Oh() { return I ? w$().cpus().length : navigator.hardwareConcurrency; } function Vr(N, F) { var B = arguments.length - 2, Q = arguments; return Ao(function() { for (var ue = B, he = zo(ue * 8), ye = he >> 3, Te = 0; Te < B; Te++) { var bt = Q[2 + Te]; p()[ye + Te] = bt; } return ux(N, ue, he, F); }); } var wu = []; function Ph(N, F, B) { wu.length = F; for (var Q = B >> 3, ue = 0; ue < F; ue++) wu[ue] = p()[Q + ue]; var he = N < 0, ye = he ? gh[-N - 1] : tf[N]; return ye.apply(null, wu); } function zh(N) { try { return Ce.grow(N - nn.byteLength + 65535 >>> 16), rs(Ce.buffer), 1; } catch (F) { } } function Lh(N) { var F = o().length; if (N = N >>> 0, N <= F) return false; var B = $c(); if (N > B) return false; for (var Q = 1; Q <= 4; Q *= 2) { var ue = F * (1 + 0.2 / Q); ue = Math.min(ue, N + 100663296); var he = Math.min(B, No(Math.max(N, ue), 65536)), ye = zh(he); if (ye) return true; } return false; } var Me = { inEventHandler: 0, removeAllEventListeners: function() { for (var N = Me.eventHandlers.length - 1; N >= 0; --N) Me._removeHandler(N); Me.eventHandlers = [], Me.deferredCalls = []; }, registerRemoveEventListeners: function() { Me.removeEventListenersRegistered || (ch.push(Me.removeAllEventListeners), Me.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(N, F, 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 Me.deferredCalls) { var he = Me.deferredCalls[ue]; if (he.targetFunction == N && Q(he.argsList, B)) return; } Me.deferredCalls.push({ targetFunction: N, precedence: F, argsList: B }), Me.deferredCalls.sort(function(ye, Te) { return ye.precedence < Te.precedence; }); }, removeDeferredCalls: function(N) { for (var F = 0; F < Me.deferredCalls.length; ++F) Me.deferredCalls[F].targetFunction == N && (Me.deferredCalls.splice(F, 1), --F); }, canPerformEventHandlerRequests: function() { return Me.inEventHandler && Me.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { if (!!Me.canPerformEventHandlerRequests()) for (var N = 0; N < Me.deferredCalls.length; ++N) { var F = Me.deferredCalls[N]; Me.deferredCalls.splice(N, 1), --N, F.targetFunction.apply(null, F.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(N, F) { for (var B = 0; B < Me.eventHandlers.length; ++B) Me.eventHandlers[B].target == N && (!F || F == Me.eventHandlers[B].eventTypeString) && Me._removeHandler(B--); }, _removeHandler: function(N) { var F = Me.eventHandlers[N]; F.target.removeEventListener(F.eventTypeString, F.eventListenerFunc, F.useCapture), Me.eventHandlers.splice(N, 1); }, registerOrRemoveHandler: function(N) { var F = function(ue) { ++Me.inEventHandler, Me.currentEventHandler = N, Me.runDeferredCalls(), N.handlerFunc(ue), Me.runDeferredCalls(), --Me.inEventHandler; }; if (N.callbackfunc) N.eventListenerFunc = F, N.target.addEventListener(N.eventTypeString, F, N.useCapture), Me.eventHandlers.push(N), Me.registerRemoveEventListeners(); else for (var B = 0; B < Me.eventHandlers.length; ++B) Me.eventHandlers[B].target == N.target && Me.eventHandlers[B].eventTypeString == N.eventTypeString && Me._removeHandler(B--); }, queueEventHandlerOnThread_iiii: function(N, F, B, Q, ue) { Ao(function() { var he = zo(12); l()[he >> 2] = B, l()[he + 4 >> 2] = Q, l()[he + 8 >> 2] = ue, Vf(N, 637534208, F, Q, he); }); }, getTargetThreadForEventCallback: function(N) { switch (N) { case 1: return 0; case 2: return $e.currentProxiedOperationCallerThread; default: return N; } }, getNodeNameForTarget: function(N) { return N ? N == window ? "#window" : N == screen ? "#screen" : N && N.nodeName ? N.nodeName : "" : ""; }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; function Mh(N) { var F = Co(N) + 1, B = Bf(F); return Ls(N, B, F), B; } function Bh(N, F, B, Q) { Ao(function() { var ue = zo(12), he = 0; F && (he = Mh(F)), l()[ue >> 2] = he, l()[ue + 4 >> 2] = B, l()[ue + 8 >> 2] = Q, Vf(N, 657457152, 0, he, ue); }); } function Vh(N, F, B, Q) { F = F ? tn(F) : "", Bh(N, F, B, Q); } function Wh(N) { return N > 2 ? tn(N) : N; } var Uh = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; function Gh(N) { N = Wh(N); var F = Uh[N] || (typeof document != "undefined" ? document.querySelector(N) : void 0); return F; } function ku(N) { return Gh(N); } function _c(N, F, B) { var Q = ku(N); if (!Q) return -4; if (Q.canvasSharedPtr && (l()[Q.canvasSharedPtr >> 2] = F, 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 he = Q.GLctxObject.GLctx.getParameter(2978); ue = he[0] === 0 && he[1] === 0 && he[2] === Q.width && he[3] === Q.height; } Q.width = F, Q.height = B, ue && Q.GLctxObject.GLctx.viewport(0, 0, F, B); } else if (Q.canvasSharedPtr) { var ye = l()[Q.canvasSharedPtr + 8 >> 2]; return Vh(ye, N, F, B), 1; } else return -4; return 0; } function Ac(N, F, B) { return $ ? Vr(2, 1, N, F, B) : _c(N, F, B); } function Hh(N, F, B) { var Q = ku(N); return Q ? _c(N, F, B) : Ac(N, F, B); } function qh() { throw "unwind"; } function jh(N) { var F = N.getExtension("ANGLE_instanced_arrays"); if (F) return N.vertexAttribDivisor = function(B, Q) { F.vertexAttribDivisorANGLE(B, Q); }, N.drawArraysInstanced = function(B, Q, ue, he) { F.drawArraysInstancedANGLE(B, Q, ue, he); }, N.drawElementsInstanced = function(B, Q, ue, he, ye) { F.drawElementsInstancedANGLE(B, Q, ue, he, ye); }, 1; } function Kh(N) { var F = N.getExtension("OES_vertex_array_object"); if (F) return N.createVertexArray = function() { return F.createVertexArrayOES(); }, N.deleteVertexArray = function(B) { F.deleteVertexArrayOES(B); }, N.bindVertexArray = function(B) { F.bindVertexArrayOES(B); }, N.isVertexArray = function(B) { return F.isVertexArrayOES(B); }, 1; } function Xh(N) { var F = N.getExtension("WEBGL_draw_buffers"); if (F) return N.drawBuffers = function(B, Q) { F.drawBuffersWEBGL(B, Q); }, 1; } function Yh(N) { return !!(N.multiDrawWebgl = N.getExtension("WEBGL_multi_draw")); } var gt = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, queries: [], stringCache: {}, unpackAlignment: 4, recordError: function(F) { gt.lastError || (gt.lastError = F); }, getNewId: function(N) { for (var F = gt.counter++, B = N.length; B < F; B++) N[B] = null; return F; }, getSource: function(N, F, B, Q) { for (var ue = "", he = 0; he < F; ++he) { var ye = Q ? l()[Q + he * 4 >> 2] : -1; ue += tn(l()[B + he * 4 >> 2], ye < 0 ? void 0 : ye); } return ue; }, createContext: function(N, F) { N.getContextSafariWebGL2Fixed || (N.getContextSafariWebGL2Fixed = N.getContext, N.getContext = function(ue, he) { var ye = N.getContextSafariWebGL2Fixed(ue, he); return ue == "webgl" == ye instanceof WebGLRenderingContext ? ye : null; }); var B = N.getContext("webgl", F); if (!B) return 0; var Q = gt.registerContext(B, F); return Q; }, registerContext: function(N, F) { var B = Bf(8); l()[B + 4 >> 2] = Mc(); var Q = { handle: B, attributes: F, version: F.majorVersion, GLctx: N }; return N.canvas && (N.canvas.GLctxObject = Q), gt.contexts[B] = Q, (typeof F.enableExtensionsByDefault == "undefined" || F.enableExtensionsByDefault) && gt.initExtensions(Q), B; }, makeContextCurrent: function(N) { return gt.currentContext = gt.contexts[N], d.ctx = Fc = gt.currentContext && gt.currentContext.GLctx, !(N && !Fc); }, getContext: function(N) { return gt.contexts[N]; }, deleteContext: function(N) { gt.currentContext === gt.contexts[N] && (gt.currentContext = null), typeof Me == "object" && Me.removeAllHandlersOnTarget(gt.contexts[N].GLctx.canvas), gt.contexts[N] && gt.contexts[N].GLctx.canvas && (gt.contexts[N].GLctx.canvas.GLctxObject = void 0), sx(gt.contexts[N].handle), gt.contexts[N] = null; }, initExtensions: function(N) { if (N || (N = gt.currentContext), !N.initExtensionsDone) { N.initExtensionsDone = true; var F = N.GLctx; jh(F), Kh(F), Xh(F), F.disjointTimerQueryExt = F.getExtension("EXT_disjoint_timer_query"), Yh(F); var B = F.getSupportedExtensions() || []; B.forEach(function(Q) { !Q.includes("lose_context") && !Q.includes("debug") && F.getExtension(Q); }); } } }, Qh = ["default", "low-power", "high-performance"]; function Zh(N, F) { var B = F >> 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: Qh[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] }, he = ku(N); if (!he || ue.explicitSwapControl) return 0; var ye = gt.createContext(he, ue); return ye; } function Jh(N, F) { return Zh(N, F); } var Ro = { mappings: {}, buffers: [null, [], []], printChar: function(N, F) { var B = Ro.buffers[N]; F === 0 || F === 10 ? ((N === 1 ? ne : ee)(Dn(B, 0)), B.length = 0) : B.push(F); }, varargs: void 0, get: function() { Ro.varargs += 4; var N = l()[Ro.varargs - 4 >> 2]; return N; }, getStr: function(N) { var F = tn(N); return F; }, get64: function(N, F) { return N; } }; function Ec(N) { return $ ? Vr(3, 1, N) : 0; } function Rc(N, F, B, Q, ue) { if ($) return Vr(4, 1, N, F, B, Q, ue); } function Dc(N, F, B, Q) { if ($) return Vr(5, 1, N, F, B, Q); for (var ue = 0, he = 0; he < B; he++) { var ye = l()[F >> 2], Te = l()[F + 4 >> 2]; F += 8; for (var bt = 0; bt < Te; bt++) Ro.printChar(N, o()[ye + bt]); ue += Te; } return l()[Q >> 2] = ue, 0; } function ef(N) { Re(N); } $e.init(); var Fc, tf = [null, Nc, Ac, Ec, Rc, Dc], ex = false, Oc = { __clock_gettime: Nh, __emscripten_init_main_thread_js: Th, __emscripten_thread_cleanup: $h, __pthread_create_js: _h, _emscripten_default_pthread_stack_size: Ah, _emscripten_notify_thread_queue: Eh, abort: Rh, emscripten_check_blocking_allowed: Dh, emscripten_get_heap_max: $c, emscripten_get_now: Br, emscripten_memcpy_big: Fh, emscripten_num_logical_cores: Oh, emscripten_receive_on_main_thread_js: Ph, emscripten_resize_heap: Lh, emscripten_set_canvas_element_size: Hh, emscripten_unwind_to_js_event_loop: qh, emscripten_webgl_create_context: Jh, exit: Cc, fd_close: Ec, fd_seek: Rc, fd_write: Dc, memory: Ce || d.wasmMemory, setTempRet0: ef }, tx = mh(), nf = d.___wasm_call_ctors = function() { return (nf = d.___wasm_call_ctors = d.asm.__wasm_call_ctors).apply(null, arguments); }, sf = d._init = function() { return (sf = d._init = d.asm.init).apply(null, arguments); }, rf = d._init_with_threads_count = function() { return (rf = d._init_with_threads_count = d.asm.init_with_threads_count).apply(null, arguments); }, af = d._get_threads_count = function() { return (af = d._get_threads_count = d.asm.get_threads_count).apply(null, arguments); }, of = d._register_tensor = function() { return (of = d._register_tensor = d.asm.register_tensor).apply(null, arguments); }, uf = d._dispose_data = function() { return (uf = d._dispose_data = d.asm.dispose_data).apply(null, arguments); }, lf = d._dispose = function() { return (lf = d._dispose = d.asm.dispose).apply(null, arguments); }, cf = d._Abs = function() { return (cf = d._Abs = d.asm.Abs).apply(null, arguments); }, df = d._Add = function() { return (df = d._Add = d.asm.Add).apply(null, arguments); }, pf = d._AddN = function() { return (pf = d._AddN = d.asm.AddN).apply(null, arguments); }, hf = d._All = function() { return (hf = d._All = d.asm.All).apply(null, arguments); }, ff = d._Any = function() { return (ff = d._Any = d.asm.Any).apply(null, arguments); }, mf = d._ArgMax = function() { return (mf = d._ArgMax = d.asm.ArgMax).apply(null, arguments); }, gf = d._AvgPool = function() { return (gf = d._AvgPool = d.asm.AvgPool).apply(null, arguments); }, bf = d._BatchMatMul = function() { return (bf = d._BatchMatMul = d.asm.BatchMatMul).apply(null, arguments); }, yf = d._Ceil = function() { return (yf = d._Ceil = d.asm.Ceil).apply(null, arguments); }, vf = d._ClipByValue = function() { return (vf = d._ClipByValue = d.asm.ClipByValue).apply(null, arguments); }, xf = d._Conv2D = function() { return (xf = d._Conv2D = d.asm.Conv2D).apply(null, arguments); }, wf = d._Conv2DBackpropInput = function() { return (wf = d._Conv2DBackpropInput = d.asm.Conv2DBackpropInput).apply(null, arguments); }, kf = d._Cos = function() { return (kf = d._Cos = d.asm.Cos).apply(null, arguments); }, Sf = d._Cosh = function() { return (Sf = d._Cosh = d.asm.Cosh).apply(null, arguments); }, If = d._CropAndResize = function() { return (If = d._CropAndResize = d.asm.CropAndResize).apply(null, arguments); }, Cf = d._Cumprod = function() { return (Cf = d._Cumprod = d.asm.Cumprod).apply(null, arguments); }, Nf = d._Cumsum = function() { return (Nf = d._Cumsum = d.asm.Cumsum).apply(null, arguments); }, Tf = d._DepthToSpace = function() { return (Tf = d._DepthToSpace = d.asm.DepthToSpace).apply(null, arguments); }, $f = d._DepthwiseConv2dNative = function() { return ($f = d._DepthwiseConv2dNative = d.asm.DepthwiseConv2dNative).apply(null, arguments); }, _f = d._Elu = function() { return (_f = d._Elu = d.asm.Elu).apply(null, arguments); }, Af = d._Equal = function() { return (Af = d._Equal = d.asm.Equal).apply(null, arguments); }, Ef = d._Exp = function() { return (Ef = d._Exp = d.asm.Exp).apply(null, arguments); }, Rf = d._FlipLeftRight = function() { return (Rf = d._FlipLeftRight = d.asm.FlipLeftRight).apply(null, arguments); }, Df = d._Floor = function() { return (Df = d._Floor = d.asm.Floor).apply(null, arguments); }, Ff = d._FloorDiv = function() { return (Ff = d._FloorDiv = d.asm.FloorDiv).apply(null, arguments); }, Of = d._FusedBatchNorm = function() { return (Of = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); }, Pc = d._FusedConv2D = function() { return (Pc = d._FusedConv2D = d.asm.FusedConv2D).apply(null, arguments); }, zc = d._FusedDepthwiseConv2D = function() { return (zc = d._FusedDepthwiseConv2D = d.asm.FusedDepthwiseConv2D).apply(null, arguments); }, Su = d._Gather = function() { return (Su = d._Gather = d.asm.Gather).apply(null, arguments); }, Pf = d._GatherNd = function() { return (Pf = d._GatherNd = d.asm.GatherNd).apply(null, arguments); }, zf = d._Greater = function() { return (zf = d._Greater = d.asm.Greater).apply(null, arguments); }, Do = d._GreaterEqual = function() { return (Do = d._GreaterEqual = d.asm.GreaterEqual).apply(null, arguments); }, Iu = d._LeakyRelu = function() { return (Iu = d._LeakyRelu = d.asm.LeakyRelu).apply(null, arguments); }, Cu = d._Less = function() { return (Cu = d._Less = d.asm.Less).apply(null, arguments); }, nx = d._LessEqual = function() { return (nx = d._LessEqual = d.asm.LessEqual).apply(null, arguments); }, Fo = d._Log = function() { return (Fo = d._Log = d.asm.Log).apply(null, arguments); }, Oo = d._LogicalAnd = function() { return (Oo = d._LogicalAnd = d.asm.LogicalAnd).apply(null, arguments); }, Lf = d._LogicalNot = function() { return (Lf = d._LogicalNot = d.asm.LogicalNot).apply(null, arguments); }, H = d._LogicalOr = function() { return (H = d._LogicalOr = d.asm.LogicalOr).apply(null, arguments); }, J = d._LogicalXor = function() { return (J = d._LogicalXor = d.asm.LogicalXor).apply(null, arguments); }, ce = d._Max = function() { return (ce = d._Max = d.asm.Max).apply(null, arguments); }, Se = d._MaxPool = function() { return (Se = 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); }, Be = d._Min = function() { return (Be = 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); }, os = d._Multiply = function() { return (os = d._Multiply = d.asm.Multiply).apply(null, arguments); }, is = d._Neg = function() { return (is = d._Neg = d.asm.Neg).apply(null, arguments); }, Po = d._NonMaxSuppressionV3 = function() { return (Po = d._NonMaxSuppressionV3 = d.asm.NonMaxSuppressionV3).apply(null, arguments); }, Wr = d._NonMaxSuppressionV4 = function() { return (Wr = d._NonMaxSuppressionV4 = d.asm.NonMaxSuppressionV4).apply(null, arguments); }, Mf = d._NonMaxSuppressionV5 = function() { return (Mf = d._NonMaxSuppressionV5 = d.asm.NonMaxSuppressionV5).apply(null, arguments); }, an = d._NotEqual = function() { return (an = d._NotEqual = d.asm.NotEqual).apply(null, arguments); }, tr = d._OneHot = function() { return (tr = d._OneHot = d.asm.OneHot).apply(null, arguments); }, Lc = d._PadV2 = function() { return (Lc = d._PadV2 = d.asm.PadV2).apply(null, arguments); }, cT = d._Pow = function() { return (cT = d._Pow = d.asm.Pow).apply(null, arguments); }, dT = d._Prelu = function() { return (dT = d._Prelu = d.asm.Prelu).apply(null, arguments); }, pT = d._Prod = function() { return (pT = d._Prod = d.asm.Prod).apply(null, arguments); }, hT = d._RealDiv = function() { return (hT = d._RealDiv = d.asm.RealDiv).apply(null, arguments); }, fT = d._Relu = function() { return (fT = d._Relu = d.asm.Relu).apply(null, arguments); }, mT = d._Relu6 = function() { return (mT = d._Relu6 = d.asm.Relu6).apply(null, arguments); }, gT = d._ResizeBilinear = function() { return (gT = d._ResizeBilinear = d.asm.ResizeBilinear).apply(null, arguments); }, bT = d._Reverse = function() { return (bT = d._Reverse = d.asm.Reverse).apply(null, arguments); }, yT = d._RotateWithOffset = function() { return (yT = d._RotateWithOffset = d.asm.RotateWithOffset).apply(null, arguments); }, vT = d._Round = function() { return (vT = d._Round = d.asm.Round).apply(null, arguments); }, xT = d._Rsqrt = function() { return (xT = d._Rsqrt = d.asm.Rsqrt).apply(null, arguments); }, wT = d._ScatterNd = function() { return (wT = d._ScatterNd = d.asm.ScatterNd).apply(null, arguments); }, kT = d._SelectV2 = function() { return (kT = d._SelectV2 = d.asm.SelectV2).apply(null, arguments); }, ST = d._Sigmoid = function() { return (ST = d._Sigmoid = d.asm.Sigmoid).apply(null, arguments); }, IT = d._Sin = function() { return (IT = d._Sin = d.asm.Sin).apply(null, arguments); }, CT = d._Softmax = function() { return (CT = d._Softmax = d.asm.Softmax).apply(null, arguments); }, NT = d._SparseFillEmptyRows = function() { return (NT = d._SparseFillEmptyRows = d.asm.SparseFillEmptyRows).apply(null, arguments); }, TT = d._SparseReshape = function() { return (TT = d._SparseReshape = d.asm.SparseReshape).apply(null, arguments); }, $T = d._SparseSegmentReduction = function() { return ($T = d._SparseSegmentReduction = d.asm.SparseSegmentReduction).apply(null, arguments); }, _T = d._Sqrt = function() { return (_T = d._Sqrt = d.asm.Sqrt).apply(null, arguments); }, AT = d._Square = function() { return (AT = d._Square = d.asm.Square).apply(null, arguments); }, ET = d._SquaredDifference = function() { return (ET = d._SquaredDifference = d.asm.SquaredDifference).apply(null, arguments); }, RT = d._Step = function() { return (RT = d._Step = d.asm.Step).apply(null, arguments); }, DT = d._StridedSlice = function() { return (DT = d._StridedSlice = d.asm.StridedSlice).apply(null, arguments); }, FT = d._Sub = function() { return (FT = d._Sub = d.asm.Sub).apply(null, arguments); }, OT = d._Sum = function() { return (OT = d._Sum = d.asm.Sum).apply(null, arguments); }, PT = d._Tan = function() { return (PT = d._Tan = d.asm.Tan).apply(null, arguments); }, zT = d._Tanh = function() { return (zT = d._Tanh = d.asm.Tanh).apply(null, arguments); }, LT = d._Tile = function() { return (LT = d._Tile = d.asm.Tile).apply(null, arguments); }, MT = d._TopK = function() { return (MT = d._TopK = d.asm.TopK).apply(null, arguments); }, BT = d._Transform = function() { return (BT = d._Transform = d.asm.Transform).apply(null, arguments); }, VT = d._Transpose = function() { return (VT = d._Transpose = d.asm.Transpose).apply(null, arguments); }, WT = d.__FusedMatMul = function() { return (WT = d.__FusedMatMul = d.asm._FusedMatMul).apply(null, arguments); }, Bf = d._malloc = function() { return (Bf = d._malloc = d.asm.malloc).apply(null, arguments); }, sx = d._free = function() { return (sx = d._free = d.asm.free).apply(null, arguments); }, UT = d._emscripten_tls_init = function() { return (UT = d._emscripten_tls_init = d.asm.emscripten_tls_init).apply(null, arguments); }, rx = d.___errno_location = function() { return (rx = d.___errno_location = d.asm.__errno_location).apply(null, arguments); }, Mc = d._pthread_self = function() { return (Mc = d._pthread_self = d.asm.pthread_self).apply(null, arguments); }, ax = d._emscripten_main_thread_process_queued_calls = function() { return (ax = d._emscripten_main_thread_process_queued_calls = d.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); }, GT = d.__emscripten_thread_crashed = function() { return (GT = d.__emscripten_thread_crashed = d.asm._emscripten_thread_crashed).apply(null, arguments); }, ox = d.__emscripten_thread_init = function() { return (ox = d.__emscripten_thread_init = d.asm._emscripten_thread_init).apply(null, arguments); }, HT = d._emscripten_current_thread_process_queued_calls = function() { return (HT = d._emscripten_current_thread_process_queued_calls = d.asm.emscripten_current_thread_process_queued_calls).apply(null, arguments); }, qT = d._emscripten_main_browser_thread_id = function() { return (qT = d._emscripten_main_browser_thread_id = d.asm.emscripten_main_browser_thread_id).apply(null, arguments); }, jT = d._emscripten_sync_run_in_main_thread_2 = function() { return (jT = d._emscripten_sync_run_in_main_thread_2 = d.asm.emscripten_sync_run_in_main_thread_2).apply(null, arguments); }, ix = d._emscripten_sync_run_in_main_thread_4 = function() { return (ix = d._emscripten_sync_run_in_main_thread_4 = d.asm.emscripten_sync_run_in_main_thread_4).apply(null, arguments); }, ux = d._emscripten_run_in_main_runtime_thread_js = function() { return (ux = d._emscripten_run_in_main_runtime_thread_js = d.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments); }, Vf = d._emscripten_dispatch_to_thread_ = function() { return (Vf = d._emscripten_dispatch_to_thread_ = d.asm.emscripten_dispatch_to_thread_).apply(null, arguments); }, Wf = d.__emscripten_thread_free_data = function() { return (Wf = d.__emscripten_thread_free_data = d.asm._emscripten_thread_free_data).apply(null, arguments); }, KT = d.__emscripten_thread_exit = function() { return (KT = d.__emscripten_thread_exit = d.asm._emscripten_thread_exit).apply(null, arguments); }, XT = d._memalign = function() { return (XT = d._memalign = d.asm.memalign).apply(null, arguments); }, lx = d._emscripten_stack_set_limits = function() { return (lx = d._emscripten_stack_set_limits = d.asm.emscripten_stack_set_limits).apply(null, arguments); }, Uf = d.stackSave = function() { return (Uf = d.stackSave = d.asm.stackSave).apply(null, arguments); }, Bc = d.stackRestore = function() { return (Bc = d.stackRestore = d.asm.stackRestore).apply(null, arguments); }, zo = d.stackAlloc = function() { return (zo = d.stackAlloc = d.asm.stackAlloc).apply(null, arguments); }, YT = d.dynCall_iijjiiii = function() { return (YT = d.dynCall_iijjiiii = d.asm.dynCall_iijjiiii).apply(null, arguments); }, QT = d.dynCall_jiji = function() { return (QT = d.dynCall_jiji = d.asm.dynCall_jiji).apply(null, arguments); }, cx = d.__emscripten_allow_main_runtime_queued_calls = 21664; d.cwrap = en, d.keepRuntimeAlive = Lr, d.PThread = $e, d.PThread = $e, d.wasmMemory = Ce, d.ExitStatus = Nu; var Vc; function Nu(N) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + N + ")", this.status = N; } as = function N() { Vc || Gf(), Vc || (as = N); }; function Gf(N) { if (N = N || b, er > 0) return; if ($) { h(d), yu(), postMessage({ cmd: "loaded" }); return; } if (sn(), er > 0) return; function F() { Vc || (Vc = true, d.calledRun = true, !ot && (yu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), hh())); } d.setStatus ? (d.setStatus("Running..."), setTimeout(function() { setTimeout(function() { d.setStatus(""); }, 1), F(); }, 1)) : F(); } d.run = Gf; function ZT(N, F) { if (Jt = N, !F && $) throw Nc(N), "unwind"; Lr() || ph(), JT(N); } function JT(N) { Jt = N, Lr() || ($e.terminateAllThreads(), d.onExit && d.onExit(N), ot = true), v(N, new Nu(N)); } if (d.preInit) for (typeof d.preInit == "function" && (d.preInit = [d.preInit]); d.preInit.length > 0; ) d.preInit.pop()(); Gf(); var Wc; m && (Wc = { uncaughtException: process.listeners("uncaughtException").filter(function(N) { return !m.uncaughtException.indexOf(N) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(N) { return !m.unhandledRejection.indexOf(N) > -1; }) }); var Uc; if (typeof WasmBackendModule != "undefined") Uc = WasmBackendModule; else if (typeof r != "undefined") Uc = r; else throw new Error("Could not find wasm module in post.js"); if (Wc) { var e$ = Uc._dispose; Uc._dispose = function() { e$(), Wc.uncaughtException.forEach(function(N) { process.removeListener("uncaughtException", N); }), Wc.unhandledRejection.forEach(function(N) { process.removeListener("unhandledRejection", N); }); }; } 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 S$ = 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 : {}, o, i; a.ready = new Promise(function(H, J) { o = H, i = 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, x, k; function I(H) { if (H instanceof Iu) return; A("exiting due to exception: " + H); } var $, R, E; m ? (f ? g = bd().dirname(g) + "/" : g = __dirname + "/", E = () => { R || ($ = pg(), R = bd()); }, y = function(J, ce) { return E(), J = R.normalize(J), $.readFileSync(J, ce ? void 0 : "utf8"); }, x = (H) => { var J = y(H, true); return J.buffer || (J = new Uint8Array(J)), J; }, v = (H, J, ce) => { E(), H = R.normalize(H), $.readFile(H, function(Se, Qe) { Se ? ce(Se) : 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 Iu)) throw H; }), process.on("unhandledRejection", function(H) { throw H; }), d = (H, J) => { if (bu()) throw process.exitCode = H, J; I(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 && (x = (H) => { var J = new XMLHttpRequest(); return J.open("GET", H, false), J.responseType = "arraybuffer", J.send(null), new Uint8Array(J.response); }), v = (H, J, ce) => { var Se = new XMLHttpRequest(); Se.open("GET", H, true), Se.responseType = "arraybuffer", Se.onload = () => { if (Se.status == 200 || Se.status == 0 && Se.response) { J(Se.response); return; } ce(); }, Se.onerror = ce, Se.send(null); }, k = (H) => document.title = H); var P = a.print || console.log.bind(console), A = 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 D = 4; function T(H) { T.shown || (T.shown = {}), T.shown[H] || (T.shown[H] = 1, A(H)); } function L(H, J) { if (typeof WebAssembly.Function == "function") { for (var ce = { i: "i32", j: "i64", f: "f32", d: "f64" }, Se = { parameters: [], results: J[0] == "v" ? [] : [ce[J[0]]] }, Qe = 1; Qe < J.length; ++Qe) Se.parameters.push(ce[J[Qe]]); return new WebAssembly.Function(Se, H); } var Ze = [1, 0, 1, 96], Be = 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]]); Be == "v" ? Ze.push(0) : Ze = Ze.concat([1, Tt[Be]]), Ze[1] = Ze.length - 2; var os = 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])), is = new WebAssembly.Module(os), Po = new WebAssembly.Instance(is, { e: { f: H } }), Wr = Po.exports.f; return Wr; } var W = [], j; function Y() { if (W.length) return W.pop(); try { Zs.grow(1); } catch (H) { throw H instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : H; } return Zs.length - 1; } function X(H, J) { for (var ce = H; ce < H + J; ce++) { var Se = xu(ce); Se && j.set(Se, ce); } } var Z = 0, ne = (H) => { Z = H; }, ee; a.wasmBinary && (ee = a.wasmBinary); var se = a.noExitRuntime || true; typeof WebAssembly != "object" && zr("no native wasm support detected"); var te, ie = false, ae; function de(H, J) { H || zr(J); } function me(H) { var J = a["_" + H]; return J; } function ke(H, J, ce, Se, Qe) { var Ze = { string: function(an) { var tr = 0; if (an != null && an !== 0) { var Lc = (an.length << 2) + 1; tr = Su(Lc), tt(an, tr, Lc); } return tr; }, array: function(an) { var tr = Su(an.length); return ot(an, tr), tr; } }; function Be(an) { return J === "string" ? Je(an) : J === "boolean" ? Boolean(an) : an; } var ze = me(H), Tt = [], os = 0; if (Se) for (var is = 0; is < Se.length; is++) { var Po = Ze[ce[is]]; Po ? (os === 0 && (os = Pc()), Tt[is] = Po(Se[is])) : Tt[is] = Se[is]; } var Wr = ze.apply(null, Tt); function Mf(an) { return os !== 0 && zc(os), Be(an); } return Wr = Mf(Wr), Wr; } function Ie(H, J, ce, Se) { ce = ce || []; var Qe = ce.every(function(Be) { return Be === "number"; }), Ze = J !== "string"; return Ze && Qe && !Se ? me(H) : function() { return ke(H, J, ce, arguments, Se); }; } var Re = 1, Pe = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; function Xe(H, J, ce) { for (var Se = J + ce, Qe = J; H[Qe] && !(Qe >= Se); ) ++Qe; if (Qe - J > 16 && H.subarray && Pe) return Pe.decode(H.subarray(J, Qe)); for (var Ze = ""; J < Qe; ) { var Be = H[J++]; if (!(Be & 128)) { Ze += String.fromCharCode(Be); continue; } var ze = H[J++] & 63; if ((Be & 224) == 192) { Ze += String.fromCharCode((Be & 31) << 6 | ze); continue; } var Tt = H[J++] & 63; if ((Be & 240) == 224 ? Be = (Be & 15) << 12 | ze << 6 | Tt : Be = (Be & 7) << 18 | ze << 12 | Tt << 6 | H[J++] & 63, Be < 65536) Ze += String.fromCharCode(Be); else { var os = Be - 65536; Ze += String.fromCharCode(55296 | os >> 10, 56320 | os & 1023); } } return Ze; } function Je(H, J) { return H ? Xe(en, H, J) : ""; } function Ye(H, J, ce, Se) { if (!(Se > 0)) return 0; for (var Qe = ce, Ze = ce + Se - 1, Be = 0; Be < H.length; ++Be) { var ze = H.charCodeAt(Be); if (ze >= 55296 && ze <= 57343) { var Tt = H.charCodeAt(++Be); ze = 65536 + ((ze & 1023) << 10) | Tt & 1023; } if (ze <= 127) { if (ce >= Ze) break; J[ce++] = ze; } else if (ze <= 2047) { if (ce + 1 >= Ze) break; J[ce++] = 192 | ze >> 6, J[ce++] = 128 | ze & 63; } else if (ze <= 65535) { if (ce + 2 >= Ze) break; J[ce++] = 224 | ze >> 12, J[ce++] = 128 | ze >> 6 & 63, J[ce++] = 128 | ze & 63; } else { if (ce + 3 >= Ze) break; J[ce++] = 240 | ze >> 18, J[ce++] = 128 | ze >> 12 & 63, J[ce++] = 128 | ze >> 6 & 63, J[ce++] = 128 | ze & 63; } } return J[ce] = 0, ce - Qe; } function tt(H, J, ce) { return Ye(H, en, J, ce); } function Ce(H) { for (var J = 0, ce = 0; ce < H.length; ++ce) { var Se = H.charCodeAt(ce); Se >= 55296 && Se <= 57343 && (Se = 65536 + ((Se & 1023) << 10) | H.charCodeAt(++ce) & 1023), Se <= 127 ? ++J : Se <= 2047 ? J += 2 : Se <= 65535 ? J += 3 : J += 4; } return J; } var ut = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : void 0; function ot(H, J) { Et.set(H, J); } function Jt(H, J, ce) { for (var Se = 0; Se < H.length; ++Se) Et[J++ >> 0] = H.charCodeAt(Se); ce || (Et[J >> 0] = 0); } function Nt(H, J) { return H % J > 0 && (H += J - H % J), H; } var In, Et, en, Cn, Nn, Yt, Dn, tn, zs; function Ls(H) { In = H, a.HEAP8 = Et = new Int8Array(H), a.HEAP16 = Cn = new Int16Array(H), a.HEAP32 = Yt = new Int32Array(H), a.HEAPU8 = en = new Uint8Array(H), a.HEAPU16 = Nn = new Uint16Array(H), a.HEAPU32 = Dn = new Uint32Array(H), a.HEAPF32 = tn = new Float32Array(H), a.HEAPF64 = zs = new Float64Array(H); } var Co = a.INITIAL_MEMORY || 16777216, Zs, Ms = [], gu = [], No = [], nn = false, cc = false, dc = 0; function bu() { return se || dc > 0; } function pc() { if (a.preRun) for (typeof a.preRun == "function" && (a.preRun = [a.preRun]); a.preRun.length; ) mc(a.preRun.shift()); vu(Ms); } function hc() { nn = true, vu(gu); } function Hv() { cc = true; } function fc() { if (a.postRun) for (typeof a.postRun == "function" && (a.postRun = [a.postRun]); a.postRun.length; ) gc(a.postRun.shift()); vu(No); } function mc(H) { Ms.unshift(H); } function rs(H) { gu.unshift(H); } function gc(H) { No.unshift(H); } var Fn = 0, To = null, Js = null; function ch(H) { Fn++, a.monitorRunDependencies && a.monitorRunDependencies(Fn); } function bc(H) { if (Fn--, a.monitorRunDependencies && a.monitorRunDependencies(Fn), Fn == 0 && (To !== null && (clearInterval(To), To = null), Js)) { var J = Js; Js = null, J(); } } a.preloadedImages = {}, a.preloadedAudios = {}; function zr(H) { a.onAbort && a.onAbort(H), H = "Aborted(" + H + ")", A(H), ie = true, ae = 1, H += ". Build with -s ASSERTIONS=1 for more info."; var J = new WebAssembly.RuntimeError(H); throw i(J), J; } var dh = "data:application/octet-stream;base64,"; function yc(H) { return H.startsWith(dh); } function Lr(H) { return H.startsWith("file://"); } var sn; sn = "tfjs-backend-wasm.wasm", yc(sn) || (sn = b(sn)); function yu(H) { try { if (H == sn && ee) return new Uint8Array(ee); if (x) return x(H); throw "both async and sync fetching of the wasm failed"; } catch (J) { zr(J); } } function ph() { if (!ee && (h || f)) { if (typeof fetch == "function" && !Lr(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 yu(sn); }); if (v) return new Promise(function(H, J) { v(sn, function(ce) { H(new Uint8Array(ce)); }, J); }); } return Promise.resolve().then(function() { return yu(sn); }); } function hh() { var H = { env: Ao, wasi_snapshot_preview1: Ao }; function J(Be, ze) { var Tt = Be.exports; a.asm = Tt, te = a.asm.memory, Ls(te.buffer), Zs = a.asm.__indirect_function_table, rs(a.asm.__wasm_call_ctors), bc("wasm-instantiate"); } ch("wasm-instantiate"); function ce(Be) { J(Be.instance); } function Se(Be) { return ph().then(function(ze) { return WebAssembly.instantiate(ze, H); }).then(function(ze) { return ze; }).then(Be, function(ze) { A("failed to asynchronously prepare wasm: " + ze), zr(ze); }); } function Qe() { return !ee && typeof WebAssembly.instantiateStreaming == "function" && !yc(sn) && !Lr(sn) && typeof fetch == "function" ? fetch(sn, { credentials: "same-origin" }).then(function(Be) { var ze = WebAssembly.instantiateStreaming(Be, H); return ze.then(ce, function(Tt) { return A("wasm streaming compile failed: " + Tt), A("falling back to ArrayBuffer instantiation"), Se(ce); }); }) : Se(ce); } if (a.instantiateWasm) try { var Ze = a.instantiateWasm(H, J); return Ze; } catch (Be) { return A("Module.instantiateWasm callback failed with error: " + Be), false; } return Qe().catch(i), {}; } var qv, jv; function vu(H) { for (; H.length > 0; ) { var J = H.shift(); if (typeof J == "function") { J(a); continue; } var ce = J.func; typeof ce == "number" ? J.arg === void 0 ? xu(ce)() : xu(ce)(J.arg) : ce(J.arg === void 0 ? null : J.arg); } } function er(H) { return H; } function vc(H) { var J = /\b_Z[\w\d_]+/g; return H.replace(J, function(ce) { var Se = ce; return ce === Se ? ce : Se + " [" + ce + "]"; }); } var as = []; function xu(H) { var J = as[H]; return J || (H >= as.length && (as.length = H + 1), as[H] = J = Zs.get(H)), J; } function Kv() { 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 $o(H, J) { Zs.set(H, J), as[H] = J; } function fh() { zr(""); } function xc(H, J, ce) { en.copyWithin(H, J, J + ce); } function wc() { return 2147483648; } function rn(H) { try { return te.grow(H - In.byteLength + 65535 >>> 16), Ls(te.buffer), 1; } catch (J) { } } function kc(H) { var J = en.length; H = H >>> 0; var ce = wc(); if (H > ce) return false; for (var Se = 1; Se <= 4; Se *= 2) { var Qe = J * (1 + 0.2 / Se); Qe = Math.min(Qe, H + 100663296); var Ze = Math.min(ce, Nt(Math.max(H, Qe), 65536)), Be = rn(Ze); if (Be) return true; } return false; } var _o = { mappings: {}, buffers: [null, [], []], printChar: function(H, J) { var ce = _o.buffers[H]; J === 0 || J === 10 ? ((H === 1 ? P : A)(Xe(ce, 0)), ce.length = 0) : ce.push(J); }, varargs: void 0, get: function() { _o.varargs += 4; var H = Yt[_o.varargs - 4 >> 2]; return H; }, getStr: function(H) { var J = Je(H); return J; }, get64: function(H, J) { return H; } }; function mh(H) { return 0; } function Xv(H, J, ce, Se, Qe) { } function Yv(H, J, ce, Se) { for (var Qe = 0, Ze = 0; Ze < ce; Ze++) { var Be = Yt[J >> 2], ze = Yt[J + 4 >> 2]; J += 8; for (var Tt = 0; Tt < ze; Tt++) _o.printChar(H, en[Be + Tt]); Qe += ze; } return Yt[Se >> 2] = Qe, 0; } function gh(H) { ne(H); } var Sc = false, Ao = { abort: fh, emscripten_memcpy_big: xc, emscripten_resize_heap: kc, fd_close: mh, fd_seek: Xv, fd_write: Yv, setTempRet0: gh }, lT = hh(), Qv = a.___wasm_call_ctors = function() { return (Qv = a.___wasm_call_ctors = a.asm.__wasm_call_ctors).apply(null, arguments); }, bh = a._init = function() { return (bh = a._init = a.asm.init).apply(null, arguments); }, yh = a._init_with_threads_count = function() { return (yh = a._init_with_threads_count = a.asm.init_with_threads_count).apply(null, arguments); }, Ic = a._get_threads_count = function() { return (Ic = a._get_threads_count = a.asm.get_threads_count).apply(null, arguments); }, Cc = a._register_tensor = function() { return (Cc = a._register_tensor = a.asm.register_tensor).apply(null, arguments); }, vh = a._dispose_data = function() { return (vh = a._dispose_data = a.asm.dispose_data).apply(null, arguments); }, $e = a._dispose = function() { return ($e = a._dispose = a.asm.dispose).apply(null, arguments); }, xh = a._Abs = function() { return (xh = a._Abs = a.asm.Abs).apply(null, arguments); }, Nc = a._Add = function() { return (Nc = a._Add = a.asm.Add).apply(null, arguments); }, Mr = a._AddN = function() { return (Mr = a._AddN = a.asm.AddN).apply(null, arguments); }, Eo = a._All = function() { return (Eo = a._All = a.asm.All).apply(null, arguments); }, wh = a._Any = function() { return (wh = a._Any = a.asm.Any).apply(null, arguments); }, Zv = a._ArgMax = function() { return (Zv = a._ArgMax = a.asm.ArgMax).apply(null, arguments); }, kh = a._AvgPool = function() { return (kh = a._AvgPool = a.asm.AvgPool).apply(null, arguments); }, Jv = a._BatchMatMul = function() { return (Jv = a._BatchMatMul = a.asm.BatchMatMul).apply(null, arguments); }, Br = a._Ceil = function() { return (Br = a._Ceil = a.asm.Ceil).apply(null, arguments); }, Sh = a._ClipByValue = function() { return (Sh = a._ClipByValue = a.asm.ClipByValue).apply(null, arguments); }, Ih = a._Conv2D = function() { return (Ih = a._Conv2D = a.asm.Conv2D).apply(null, arguments); }, Ch = a._Conv2DBackpropInput = function() { return (Ch = a._Conv2DBackpropInput = a.asm.Conv2DBackpropInput).apply(null, arguments); }, Nh = a._Cos = function() { return (Nh = a._Cos = a.asm.Cos).apply(null, arguments); }, Th = a._Cosh = function() { return (Th = a._Cosh = a.asm.Cosh).apply(null, arguments); }, $h = a._CropAndResize = function() { return ($h = a._CropAndResize = a.asm.CropAndResize).apply(null, arguments); }, Tc = a._Cumprod = function() { return (Tc = a._Cumprod = a.asm.Cumprod).apply(null, arguments); }, _h = a._Cumsum = function() { return (_h = a._Cumsum = a.asm.Cumsum).apply(null, arguments); }, Ah = a._DepthToSpace = function() { return (Ah = a._DepthToSpace = a.asm.DepthToSpace).apply(null, arguments); }, Eh = a._DepthwiseConv2dNative = function() { return (Eh = a._DepthwiseConv2dNative = a.asm.DepthwiseConv2dNative).apply(null, arguments); }, Rh = a._Elu = function() { return (Rh = a._Elu = a.asm.Elu).apply(null, arguments); }, Dh = a._Equal = function() { return (Dh = a._Equal = a.asm.Equal).apply(null, arguments); }, $c = a._Exp = function() { return ($c = a._Exp = a.asm.Exp).apply(null, arguments); }, Fh = a._FlipLeftRight = function() { return (Fh = a._FlipLeftRight = a.asm.FlipLeftRight).apply(null, arguments); }, Oh = a._Floor = function() { return (Oh = a._Floor = a.asm.Floor).apply(null, arguments); }, Vr = a._FloorDiv = function() { return (Vr = a._FloorDiv = a.asm.FloorDiv).apply(null, arguments); }, wu = a._FusedBatchNorm = function() { return (wu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); }, Ph = a._FusedConv2D = function() { return (Ph = a._FusedConv2D = a.asm.FusedConv2D).apply(null, arguments); }, zh = a._FusedDepthwiseConv2D = function() { return (zh = a._FusedDepthwiseConv2D = a.asm.FusedDepthwiseConv2D).apply(null, arguments); }, Lh = a._Gather = function() { return (Lh = a._Gather = a.asm.Gather).apply(null, arguments); }, Me = a._GatherNd = function() { return (Me = a._GatherNd = a.asm.GatherNd).apply(null, arguments); }, Mh = a._Greater = function() { return (Mh = a._Greater = a.asm.Greater).apply(null, arguments); }, Bh = a._GreaterEqual = function() { return (Bh = a._GreaterEqual = a.asm.GreaterEqual).apply(null, arguments); }, Vh = a._LeakyRelu = function() { return (Vh = a._LeakyRelu = a.asm.LeakyRelu).apply(null, arguments); }, Wh = a._Less = function() { return (Wh = a._Less = a.asm.Less).apply(null, arguments); }, Uh = a._LessEqual = function() { return (Uh = a._LessEqual = a.asm.LessEqual).apply(null, arguments); }, Gh = a._Log = function() { return (Gh = a._Log = a.asm.Log).apply(null, arguments); }, ku = a._LogicalAnd = function() { return (ku = a._LogicalAnd = a.asm.LogicalAnd).apply(null, arguments); }, _c = a._LogicalNot = function() { return (_c = a._LogicalNot = a.asm.LogicalNot).apply(null, arguments); }, Ac = a._LogicalOr = function() { return (Ac = a._LogicalOr = a.asm.LogicalOr).apply(null, arguments); }, Hh = a._LogicalXor = function() { return (Hh = a._LogicalXor = a.asm.LogicalXor).apply(null, arguments); }, qh = a._Max = function() { return (qh = a._Max = a.asm.Max).apply(null, arguments); }, jh = a._MaxPool = function() { return (jh = a._MaxPool = a.asm.MaxPool).apply(null, arguments); }, Kh = a._Maximum = function() { return (Kh = a._Maximum = a.asm.Maximum).apply(null, arguments); }, Xh = a._Mean = function() { return (Xh = a._Mean = a.asm.Mean).apply(null, arguments); }, Yh = a._Min = function() { return (Yh = a._Min = a.asm.Min).apply(null, arguments); }, gt = a._Minimum = function() { return (gt = a._Minimum = a.asm.Minimum).apply(null, arguments); }, Qh = a._MirrorPad = function() { return (Qh = a._MirrorPad = a.asm.MirrorPad).apply(null, arguments); }, Zh = a._Multiply = function() { return (Zh = a._Multiply = a.asm.Multiply).apply(null, arguments); }, Jh = a._Neg = function() { return (Jh = a._Neg = a.asm.Neg).apply(null, arguments); }, Ro = a._NonMaxSuppressionV3 = function() { return (Ro = a._NonMaxSuppressionV3 = a.asm.NonMaxSuppressionV3).apply(null, arguments); }, Ec = a._NonMaxSuppressionV4 = function() { return (Ec = a._NonMaxSuppressionV4 = a.asm.NonMaxSuppressionV4).apply(null, arguments); }, Rc = a._NonMaxSuppressionV5 = function() { return (Rc = a._NonMaxSuppressionV5 = a.asm.NonMaxSuppressionV5).apply(null, arguments); }, Dc = a._NotEqual = function() { return (Dc = a._NotEqual = a.asm.NotEqual).apply(null, arguments); }, ef = a._OneHot = function() { return (ef = a._OneHot = a.asm.OneHot).apply(null, arguments); }, Fc = a._PadV2 = function() { return (Fc = a._PadV2 = a.asm.PadV2).apply(null, arguments); }, tf = a._Pow = function() { return (tf = a._Pow = a.asm.Pow).apply(null, arguments); }, ex = a._Prelu = function() { return (ex = a._Prelu = a.asm.Prelu).apply(null, arguments); }, Oc = a._Prod = function() { return (Oc = a._Prod = a.asm.Prod).apply(null, arguments); }, tx = a._RealDiv = function() { return (tx = a._RealDiv = a.asm.RealDiv).apply(null, arguments); }, nf = a._Relu = function() { return (nf = a._Relu = a.asm.Relu).apply(null, arguments); }, sf = a._Relu6 = function() { return (sf = a._Relu6 = a.asm.Relu6).apply(null, arguments); }, rf = a._ResizeBilinear = function() { return (rf = a._ResizeBilinear = a.asm.ResizeBilinear).apply(null, arguments); }, af = a._Reverse = function() { return (af = a._Reverse = a.asm.Reverse).apply(null, arguments); }, of = a._RotateWithOffset = function() { return (of = a._RotateWithOffset = a.asm.RotateWithOffset).apply(null, arguments); }, uf = a._Round = function() { return (uf = a._Round = a.asm.Round).apply(null, arguments); }, lf = a._Rsqrt = function() { return (lf = a._Rsqrt = a.asm.Rsqrt).apply(null, arguments); }, cf = a._ScatterNd = function() { return (cf = a._ScatterNd = a.asm.ScatterNd).apply(null, arguments); }, df = a._SelectV2 = function() { return (df = a._SelectV2 = a.asm.SelectV2).apply(null, arguments); }, pf = a._Sigmoid = function() { return (pf = a._Sigmoid = a.asm.Sigmoid).apply(null, arguments); }, hf = a._Sin = function() { return (hf = a._Sin = a.asm.Sin).apply(null, arguments); }, ff = a._Softmax = function() { return (ff = a._Softmax = a.asm.Softmax).apply(null, arguments); }, mf = a._SparseFillEmptyRows = function() { return (mf = a._SparseFillEmptyRows = a.asm.SparseFillEmptyRows).apply(null, arguments); }, gf = a._SparseReshape = function() { return (gf = a._SparseReshape = a.asm.SparseReshape).apply(null, arguments); }, bf = a._SparseSegmentReduction = function() { return (bf = a._SparseSegmentReduction = a.asm.SparseSegmentReduction).apply(null, arguments); }, yf = a._Sqrt = function() { return (yf = a._Sqrt = a.asm.Sqrt).apply(null, arguments); }, vf = a._Square = function() { return (vf = a._Square = a.asm.Square).apply(null, arguments); }, xf = a._SquaredDifference = function() { return (xf = a._SquaredDifference = a.asm.SquaredDifference).apply(null, arguments); }, wf = a._Step = function() { return (wf = a._Step = a.asm.Step).apply(null, arguments); }, kf = a._StridedSlice = function() { return (kf = a._StridedSlice = a.asm.StridedSlice).apply(null, arguments); }, Sf = a._Sub = function() { return (Sf = a._Sub = a.asm.Sub).apply(null, arguments); }, If = a._Sum = function() { return (If = a._Sum = a.asm.Sum).apply(null, arguments); }, Cf = a._Tan = function() { return (Cf = a._Tan = a.asm.Tan).apply(null, arguments); }, Nf = a._Tanh = function() { return (Nf = a._Tanh = a.asm.Tanh).apply(null, arguments); }, Tf = a._Tile = function() { return (Tf = a._Tile = a.asm.Tile).apply(null, arguments); }, $f = a._TopK = function() { return ($f = a._TopK = a.asm.TopK).apply(null, arguments); }, _f = a._Transform = function() { return (_f = a._Transform = a.asm.Transform).apply(null, arguments); }, Af = a._Transpose = function() { return (Af = a._Transpose = a.asm.Transpose).apply(null, arguments); }, Ef = a.__FusedMatMul = function() { return (Ef = a.__FusedMatMul = a.asm._FusedMatMul).apply(null, arguments); }, Rf = a._malloc = function() { return (Rf = a._malloc = a.asm.malloc).apply(null, arguments); }, Df = a._free = function() { return (Df = a._free = a.asm.free).apply(null, arguments); }, Ff = a.___errno_location = function() { return (Ff = a.___errno_location = a.asm.__errno_location).apply(null, arguments); }, Of = a._emscripten_main_thread_process_queued_calls = function() { return (Of = a._emscripten_main_thread_process_queued_calls = a.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); }, Pc = a.stackSave = function() { return (Pc = a.stackSave = a.asm.stackSave).apply(null, arguments); }, zc = a.stackRestore = function() { return (zc = a.stackRestore = a.asm.stackRestore).apply(null, arguments); }, Su = a.stackAlloc = function() { return (Su = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); }, Pf = a.dynCall_iijjiiii = function() { return (Pf = a.dynCall_iijjiiii = a.asm.dynCall_iijjiiii).apply(null, arguments); }, zf = a.dynCall_jiji = function() { return (zf = a.dynCall_jiji = a.asm.dynCall_jiji).apply(null, arguments); }; a.cwrap = Ie; var Do; function Iu(H) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + H + ")", this.status = H; } Js = function H() { Do || Cu(), Do || (Js = H); }; function Cu(H) { if (H = H || c, Fn > 0 || (pc(), Fn > 0)) return; function J() { Do || (Do = true, a.calledRun = true, !ie && (hc(), o(a), a.onRuntimeInitialized && a.onRuntimeInitialized(), fc())); } a.setStatus ? (a.setStatus("Running..."), setTimeout(function() { setTimeout(function() { a.setStatus(""); }, 1), J(); }, 1)) : J(); } a.run = Cu; function nx(H) { ae = H, bu() || (a.onExit && a.onExit(H), ie = true), d(H, new Iu(H)); } if (a.preInit) for (typeof a.preInit == "function" && (a.preInit = [a.preInit]); a.preInit.length > 0; ) a.preInit.pop()(); Cu(); var Fo; u && (Fo = { 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 Oo; if (typeof r != "undefined") Oo = r; else if (typeof WasmBackendModuleThreadedSimd != "undefined") Oo = WasmBackendModuleThreadedSimd; else throw new Error("Could not find wasm module in post.js"); if (Fo) { var Lf = Oo._dispose; Oo._dispose = function() { Lf(), Fo.uncaughtException.forEach(function(H) { process.removeListener("uncaughtException", H); }), Fo.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 I$ = 1e-7; var C$ = 1e-4; var Zd = 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 il = 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 ? I$ : C$; } 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 rk(e) { let t = e.length, n = 0; for (; t > 0; ) n = Math.random() * t | 0, t--, yd(e, t, n); } function N$(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--, yd(e, n, s), yd(t, n, s); } function Hu(e, t, n) { return Math.max(e, Math.min(t, n)); } function T$(e) { return e % 2 === 0 ? e : e + 1; } function yd(e, t, n) { let s = e[t]; e[t] = e[n], e[n] = s; } function $$(e) { let t = 0; for (let n = 0; n < e.length; n++) t += e[n]; return t; } function _$(e, t) { let n = Math.random(); return t * n + (1 - n) * e; } function A$(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 hn(e, t, n = "") { O(Ir(e, t), () => n + ` Shapes ${e} and ${t} must match`); } function ka(e) { O(e != null, () => "The input to the tensor constructor must be a non-null value."); } function aa(e, t = [], n = false) { if (t == null && (t = []), Array.isArray(e) || Qt(e) && !n) for (let s = 0; s < e.length; ++s) aa(e[s], t, n); else t.push(e); return t; } function dt(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 E$(e) { return e.length === 0; } function Ir(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 ei(e) { return e % 1 === 0; } function R$(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 D$(e) { let t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)]; } function F$(e) { let t = new Uint32Array(e); for (let n = 0; n < e; ++n) t[n] = n; return rk(t), t; } function Vu(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length); } function O$(e, t = (s) => 0, n) { return new Promise((s, r) => { let a = 0, o = () => { if (e()) { s(); return; } a++; let i = t(a); if (n != null && a >= n) { r(); return; } setTimeout(o, i); }; o(); }); } function P$(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) => ei(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s); } function ak(e, t) { let n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : ts(t, e).sort(), o = 0; for (let i = 0; i < e.length; ++i) { if (a != null) { if (a[o] === i && e[i] !== 1) throw new Error(`Can't squeeze axis ${i} since its dim '${e[i]}' is not 1`); (a[o] == null || a[o] > i) && e[i] === 1 && (n.push(e[i]), s.push(i)), a[o] <= i && o++; } e[i] !== 1 && (n.push(e[i]), s.push(i)); } return { newShape: n, keptDims: s }; } function ok(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 ik(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 uk(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 lk(e) { return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string"; } function z$(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 om(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 ck(e) { if (e == null) return 0; let t = 0; return e.forEach((n) => t += n.length), t; } function or(e) { return typeof e == "string" || e instanceof String; } function dk(e) { return typeof e == "boolean"; } function pk(e) { return typeof e == "number"; } function Jd(e) { return Array.isArray(e) ? Jd(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : pk(e) ? "float32" : or(e) ? "string" : dk(e) ? "bool" : "float32"; } function fr(e) { return !!(e && e.constructor && e.call && e.apply); } function vd(e, t) { for (let n = t; n < e; ++n) if (e % n === 0) return n; return e; } function ci(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 hk(e, t, n, s = false) { let r = new Array(); if (t.length === 1) { let a = t[0] * (s ? 2 : 1); for (let o = 0; o < a; o++) r[o] = n[e + o]; } else { let a = t[0], o = t.slice(1), i = o.reduce((u, l) => u * l) * (s ? 2 : 1); for (let u = 0; u < a; u++) r[u] = hk(e + u * i, o, n, s); } return r; } function Xo(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 hk(0, e, t, n); } function hg(e, t) { let n = ep(e, t); for (let s = 0; s < n.length; s++) n[s] = 1; return n; } function ep(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 L$(e, t) { let n = e.reduce((s, r) => s * r, 1); if (t == null || t === "float32") return Xo(e, new Float32Array(n)); if (t === "int32") return Xo(e, new Int32Array(n)); if (t === "bool") return Xo(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`); } function fg(e) { e.forEach((t) => { O(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`); }); } function M$(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 B$(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 mg(e) { return e && e.then && typeof e.then == "function"; } var px = "tfjsflags"; var V$ = class { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = W$, this.populateURLFlags(); } setPlatform(e, t) { this.platform != null && (K().getBool("IS_TEST") || K().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]; K().getBool("IS_TEST") || K().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 (mg(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); px in e && e[px].split(",").forEach((n) => { let [s, r] = n.split(":"); this.urlFlags[s] = G$(s, r); }); } }; function W$(e) { let t = {}; return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (U$(t, s[0], s[1]), s.join("="))), t; } function U$(e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || ""); } function G$(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 K() { return fk; } var fk = null; function H$(e) { fk = e; } var Hf; function mk() { if (Hf == 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"); Hf = e; } return Hf; } function q$() { let e = mk(); return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals; } function gg(e, t) { let n = q$(); if (n.has(e)) return n.get(e); { let s = t(); return n.set(e, s), n.get(e); } } var di = "Abs"; var ul = "Acos"; var ll = "Acosh"; var Cr = "Add"; var Sa = "AddN"; var cl = "All"; var dl = "Any"; var Ia = "ArgMax"; var pl = "ArgMin"; var hl = "Asin"; var fl = "Asinh"; var ml = "Atan"; var gl = "Atanh"; var bl = "Atan2"; var Ca = "AvgPool"; var bg = "AvgPoolGrad"; var tp = "AvgPool3D"; var yg = "AvgPool3DGrad"; var Na = "BatchMatMul"; var pi = "BatchToSpaceND"; var vg = "Bincount"; var j$ = "BroadcastTo"; var xg = "BroadcastArgs"; var Ta = "Cast"; var $a = "Ceil"; var Nr = "ClipByValue"; var np = "Complex"; var sp = "ComplexAbs"; var hi = "Concat"; var _a = "Conv2D"; var wg = "Conv2DBackpropFilter"; var Aa = "Conv2DBackpropInput"; var rp = "Conv3D"; var kg = "Conv3DBackpropFilterV2"; var Sg = "Conv3DBackpropInputV2"; var Ea = "Cos"; var Ra = "Cosh"; var fi = "Cumprod"; var Da = "Cumsum"; var mi = "CropAndResize"; var Ig = "DenseBincount"; var gi = "DepthToSpace"; var Fa = "DepthwiseConv2dNative"; var Cg = "DepthwiseConv2dNativeBackpropFilter"; var Ng = "DepthwiseConv2dNativeBackpropInput"; var Tg = "Diag"; var ap = "Dilation2D"; var im = "Dilation2DBackpropInput"; var um = "Dilation2DBackpropFilter"; var Oa = "RealDiv"; var op = "Einsum"; var Pa = "Elu"; var $g = "EluGrad"; var yl = "Erf"; var bi = "Equal"; var za = "Exp"; var yi = "ExpandDims"; var vi = "Expm1"; var _g = "FFT"; var vl = "Fill"; var xi = "FlipLeftRight"; var La = "Floor"; var Ma = "FloorDiv"; var Ba = "FusedBatchNorm"; var wi = "GatherV2"; var ki = "GatherNd"; var Si = "Greater"; var Va = "GreaterEqual"; var Wa = "Identity"; var Ag = "IFFT"; var ip = "Imag"; var xl = "IsFinite"; var wl = "IsInf"; var kl = "IsNan"; var Ua = "LeakyRelu"; var Ii = "Less"; var Ci = "LessEqual"; var Eg = "LinSpace"; var Ga = "Log"; var Sl = "Log1p"; var Ni = "LogicalAnd"; var Ti = "LogicalNot"; var Il = "LogicalOr"; var K$ = "LogicalXor"; var X$ = "LogSoftmax"; var Cpe = "LowerBound"; var up = "LRN"; var Rg = "LRNGrad"; var Ha = "Max"; var qa = "Maximum"; var ja = "MaxPool"; var Dg = "MaxPoolGrad"; var lp = "MaxPool3D"; var Fg = "MaxPool3DGrad"; var Og = "MaxPoolWithArgmax"; var Ka = "Mean"; var Xa = "Min"; var Ya = "Minimum"; var Qa = "MirrorPad"; var Cl = "Mod"; var Pg = "Multinomial"; var Za = "Multiply"; var $i = "Neg"; var _i = "NotEqual"; var Ai = "NonMaxSuppressionV3"; var Nl = "NonMaxSuppressionV4"; var Ei = "NonMaxSuppressionV5"; var Ri = "OnesLike"; var Di = "OneHot"; var Fi = "Pack"; var Ja = "PadV2"; var Npe = "Pool"; var eo = "Pow"; var to = "Prelu"; var no = "Prod"; var Tl = "Range"; var cp = "Real"; var $l = "Reciprocal"; var so = "Relu"; var Oi = "Reshape"; var _l = "ResizeNearestNeighbor"; var zg = "ResizeNearestNeighborGrad"; var ro = "ResizeBilinear"; var Lg = "ResizeBilinearGrad"; var ao = "Relu6"; var Pi = "Reverse"; var zi = "Round"; var oo = "Rsqrt"; var Li = "ScatterNd"; var Mg = "SearchSorted"; var Mi = "Select"; var Al = "Selu"; var Bi = "Slice"; var io = "Sin"; var Vi = "Sinh"; var El = "Sign"; var uo = "Sigmoid"; var Rl = "Softplus"; var lo = "Sqrt"; var co = "Sum"; var Wi = "SpaceToBatchND"; var Ui = "SplitV"; var po = "Softmax"; var dp = "SparseFillEmptyRows"; var Dl = "SparseReshape"; var pp = "SparseSegmentMean"; var hp = "SparseSegmentSum"; var fp = "SparseToDense"; var ho = "SquaredDifference"; var Fl = "Square"; var Gi = "StridedSlice"; var mp = "StringNGrams"; var Bg = "StringSplit"; var Vg = "StringToHashBucketFast"; var fo = "Sub"; var Hi = "Tan"; var mo = "Tanh"; var Tr = "Tile"; var qi = "TopK"; var ji = "Transform"; var Hs = "Transpose"; var Wg = "Unique"; var Ki = "Unpack"; var gp = "UnsortedSegmentSum"; var Tpe = "UpperBound"; var Xi = "ZerosLike"; var go = "Step"; var xd = "FromPixels"; var Yi = "RotateWithOffset"; var oa = "_FusedMatMul"; var ia = "FusedConv2D"; var ua = "FusedDepthwiseConv2D"; function ar(...e) { K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(...e); } function Y$(...e) { K().getBool("IS_TEST") || K().getBool("PROD") || console.log(...e); } var ti = gg("kernelRegistry", () => /* @__PURE__ */ new Map()); var qu = gg("gradRegistry", () => /* @__PURE__ */ new Map()); function lm(e, t) { let n = Ug(e, t); return ti.get(n); } function hx(e) { return qu.get(e); } function cm(e) { let t = ti.entries(), n = []; for (; ; ) { let { done: s, value: r } = t.next(); if (s) break; let [a, o] = r, [i] = a.split("_"); i === e && n.push(o); } return n; } function Ol(e) { let { kernelName: t, backendName: n } = e, s = Ug(t, n); ti.has(s) && ar(`The kernel '${t}' for backend '${n}' is already registered`), ti.set(s, e); } function Q$(e) { let { kernelName: t } = e; qu.has(t) && K().getBool("DEBUG") && ar(`Overriding the gradient for '${t}'`), qu.set(t, e); } function $pe(e, t) { let n = Ug(e, t); if (!ti.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); ti.delete(n); } function _pe(e) { if (!qu.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); qu.delete(e); } function Ape(e, t) { cm(e).forEach((s) => { let r = Object.assign({}, s, { backendName: t }); Ol(r); }); } function Ug(e, t) { return `${t}_${e}`; } var w = {}; Ee(w, { arraysEqual: () => Ir, assert: () => O, assertNonNegativeIntegerDimensions: () => fg, assertNonNull: () => ka, assertShapesMatch: () => hn, bytesFromStringArray: () => ck, bytesPerElement: () => om, checkConversionForErrors: () => uk, clamp: () => Hu, computeStrides: () => ci, createScalarValue: () => s_, createShuffledIndices: () => F$, decodeString: () => wd, distSquared: () => A$, encodeString: () => zl, fetch: () => a_, fingerPrint64: () => n_, flatten: () => aa, getArrayFromDType: () => ik, getTypedArrayFromDType: () => ok, hasEncodingLoss: () => z$, hexToLong: () => Pl, indexToLoc: () => B$, inferDtype: () => Jd, inferFromImplicitShape: () => P$, isBoolean: () => dk, isFunction: () => fr, isInt: () => ei, isNumber: () => pk, isPromise: () => mg, isScalarShape: () => E$, isString: () => or, isTypedArray: () => Qt, isValidDtype: () => lk, locToIndex: () => M$, makeOnesTypedArray: () => hg, makeZerosNestedTypedArray: () => L$, makeZerosTypedArray: () => ep, nearestDivisor: () => vd, nearestLargerEven: () => T$, now: () => ju, parseAxisParam: () => ts, randUniform: () => _$, repeatedTry: () => O$, rightPad: () => Vu, shuffle: () => rk, shuffleCombo: () => N$, sizeFromShape: () => dt, sizeToSquarishShape: () => D$, squeezeShape: () => ak, sum: () => $$, swap: () => yd, tanh: () => R$, toNestedArray: () => Xo, toTypedArray: () => bp }); var fx = wa(u$()); var Kr = fx.default || fx; function Pl(e) { return Kr.fromString(e, true, 16); } var gk = Pl("c3a5c85c97cb3127"); var qr = Pl("b492b66fbe98f273"); var on = Pl("9ae16a3b2f90404f"); function dm(e) { return e.xor(e.shru(47)); } function bk(e, t, n) { let s = e.slice(t, t + n); return Kr.fromBytes(Array.from(s), true, true); } function lt(e, t) { return bk(e, t, 8); } function mx(e, t) { return bk(e, t, 4); } function Mt(e, t) { return t === 0 ? e : e.shru(t).or(e.shl(64 - t)); } function ur(e, t, n = Pl("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 Z$(e, t, n, s, r, a) { r = r.add(e), a = Mt(a.add(r).add(s), 21); let o = r; return r = r.add(t), r = r.add(n), a = a.add(Mt(r, 44)), [r.add(s), a.add(o)]; } function Hc(e, t, n, s) { return Z$(lt(e, t), lt(e, t + 8), lt(e, t + 16), lt(e, t + 24), n, s); } function J$(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 = Mt(r, 37).mul(n).add(s), o = Mt(s, 25).add(r).mul(n); return ur(a, o, n); } if (t >= 4) { let n = on.add(t * 2), s = mx(e, 0); return ur(s.shl(3).add(t), mx(e, t - 4), n); } if (t > 0) { let n = e[0], s = e[t >> 1], r = e[t - 1], a = n + (s << 8), o = t + (r << 2); return dm(on.mul(a).xor(gk.mul(o))).mul(on); } return on; } function e_(e, t = e.length) { let n = on.add(t * 2), s = lt(e, 0).mul(qr), r = lt(e, 8), a = lt(e, t - 8).mul(n), o = lt(e, t - 16).mul(on); return ur(Mt(s.add(r), 43).add(Mt(a, 30)).add(o), s.add(Mt(r.add(on), 18)).add(a), n); } function t_(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), o = lt(e, t - 16).mul(on), i = Mt(s.add(r), 43).add(Mt(a, 30)).add(o), u = ur(i, s.add(Mt(r.add(on), 18)).add(a), n), l = lt(e, 16).mul(n), c = lt(e, 24), p = i.add(lt(e, t - 32)).mul(n), d = u.add(lt(e, t - 24)).mul(n); return ur(Mt(l.add(c), 43).add(Mt(p, 30)).add(d), l.add(Mt(c.add(s), 18)).add(p), n); } function n_(e, t = e.length) { let n = Kr.fromNumber(81, true); if (t <= 32) return t <= 16 ? J$(e, t) : e_(e, t); if (t <= 64) return t_(e, t); let s = n, r = n.mul(qr).add(113), a = dm(r.mul(on).add(113)).mul(on), o = [Kr.UZERO, Kr.UZERO], i = [Kr.UZERO, Kr.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 = Mt(s.add(r).add(o[0]).add(lt(e, u + 8)), 37).mul(qr), r = Mt(r.add(o[1]).add(lt(e, u + 48)), 42).mul(qr), s = s.xor(i[1]), r = r.add(o[0]).add(lt(e, u + 40)), a = Mt(a.add(i[0]), 33).mul(qr), o = Hc(e, u, o[1].mul(qr), s.add(i[0])), i = Hc(e, u + 32, a.add(i[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], u += 64; while (u !== l); let p = qr.add(a.and(255).shl(1)); return u = c, i[0] = i[0].add(t - 1 & 63), o[0] = o[0].add(i[0]), i[0] = i[0].add(o[0]), s = Mt(s.add(r).add(o[0]).add(lt(e, u + 8)), 37).mul(p), r = Mt(r.add(o[1]).add(lt(e, u + 48)), 42).mul(p), s = s.xor(i[1].mul(9)), r = r.add(o[0].mul(9).add(lt(e, u + 40))), a = Mt(a.add(i[0]), 33).mul(p), o = Hc(e, u, o[1].mul(p), s.add(i[0])), i = Hc(e, u + 32, a.add(i[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], ur(ur(o[0], i[0], p).add(dm(r).mul(gk)).add(a), ur(o[1], i[1], p).add(s), p); } function s_(e, t) { return t === "string" ? zl(e) : bp([e], t); } function r_(e, t) { return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool"; } function bp(e, t) { if (t === "string") throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(e) && (e = aa(e)), K().getBool("DEBUG") && uk(e, t), r_(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 ju() { return K().platform.now(); } function a_(e, t) { return K().platform.fetch(e, t); } function zl(e, t = "utf-8") { return t = t || "utf-8", K().platform.encode(e, t); } function wd(e, t = "utf-8") { return t = t || "utf-8", K().platform.decode(e, t); } var o_ = class { constructor(e, t) { this.backendTimer = e, this.logger = t, t == null && (this.logger = new u_()); } profileKernel(e, t, n) { let s, r = () => { s = n(); }, a, o = ju(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(r); else { r(); for (let u of s) u.dataSync(); a = Promise.resolve({ kernelMs: ju() - o }); } if (K().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < s.length; u++) { let l = s[u]; l.data().then((c) => { i_(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((o) => { Promise.all([o.data(), s, a]).then((i) => { this.logger.logKernelProfile(t, o, i[0], i[1], r, i[2]); }); }); } }; function i_(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 u_ = class { logKernelProfile(e, t, n, s, r, a) { let o = typeof s == "number" ? Vu(`${s}ms`, 9) : s.error, i = Vu(e, 25), u = t.rank, l = t.size, c = Vu(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${i} %c${o} %c${u}D ${c} %c${l} %c${p} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; function l_(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 o = {}; 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, o[l.id] = true; break; } } let i = []; for (let u = 0; u < e.length; u++) { let l = e[u]; if (r[l.id] && o[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, i.push(p); } } return i; } function c_(e, t, n, s) { for (let r = t.length - 1; r >= 0; r--) { let a = t[r], o = []; if (a.outputs.forEach((u) => { let l = e[u.id]; l != null ? o.push(l) : o.push(null); }), a.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`); let i = a.gradient(o); for (let u in a.inputs) { if (!(u in i)) throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(i)}.`); let l = n(() => i[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 (!Ir(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 gx = 20; var $u = 3; var qf = 7; function d_(e, t, n, s) { let r = ci(t), a = p_(e, t, n, r), o = t.length, i = ad(e, t, n, r, a), u = ["Tensor"]; return s && (u.push(` dtype: ${n}`), u.push(` rank: ${o}`), u.push(` shape: [${t}]`), u.push(" values:")), u.push(i.map((l) => " " + l).join(` `)), u.join(` `); } function p_(e, t, n, s) { let r = dt(t), a = s[s.length - 1], o = new Array(a).fill(0), i = t.length, u = n === "complex64" ? Du(e) : e; if (i > 1) for (let l = 0; l < r / a; l++) { let c = l * a; for (let p = 0; p < a; p++) o[p] = Math.max(o[p], Ru(u[c + p], 0, n).length); } return o; } function Ru(e, t, n) { let s; return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(qf))} + ${parseFloat(e[1].toFixed(qf))}j` : or(e) ? s = `'${e}'` : n === "bool" ? s = yk(e) : s = parseFloat(e.toFixed(qf)).toString(), Vu(s, t); } function yk(e) { return e === 0 ? "false" : "true"; } function ad(e, t, n, s, r, a = true) { let o = n === "complex64" ? 2 : 1, i = t[0], u = t.length; if (u === 0) { if (n === "complex64") { let m = Du(e); return [Ru(m[0], 0, n)]; } return n === "bool" ? [yk(e[0])] : [e[0].toString()]; } if (u === 1) { if (i > gx) { let g = $u * o, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((i - $u) * o, i * o)); return n === "complex64" && (b = Du(b), y = Du(y)), ["[" + b.map((v, x) => Ru(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => Ru(v, r[i - $u + x], n)).join(", ") + "]"]; } let m = n === "complex64" ? Du(e) : Array.from(e); return ["[" + m.map((g, b) => Ru(g, r[b], n)).join(", ") + "]"]; } let l = t.slice(1), c = s.slice(1), p = s[0] * o, d = []; if (i > gx) { for (let m = 0; m < $u; m++) { let g = m * p, b = g + p; d.push(...ad(e.slice(g, b), l, n, c, r, false)); } d.push("..."); for (let m = i - $u; m < i; m++) { let g = m * p, b = g + p; d.push(...ad(e.slice(g, b), l, n, c, r, m === i - 1)); } } else for (let m = 0; m < i; m++) { let g = m * p, b = g + p; d.push(...ad(e.slice(g, b), l, n, c, r, m === i - 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 Du(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 = dt(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 || ik(t, this.size), this.strides = ci(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 Ho = null; var h_ = null; function f_(e) { cs = e; } function m_(e) { Ho = e; } function g_(e) { h_ = 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 = dt(e), this.strides = ci(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 Ho.buffer(this.shape, this.dtype, e); } bufferSync() { return Ho.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); return Xo(this.shape, e, this.dtype === "complex64"); } arraySync() { return Xo(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) => wd(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) => wd(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 Ho.print(this, e); } clone() { return this.throwIfDisposed(), Ho.clone(this); } toString(e = false) { let t = this.dataSync(); return d_(t, this.shape, this.dtype, e); } cast(e) { return this.throwIfDisposed(), Ho.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 b_() { return gg("Tensor", () => et); } b_(); var kd = 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 (!Ir(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(kd, Symbol.hasInstance, { value: (e) => e instanceof et && e.assign != null && e.assign instanceof Function }); var _s = {}; Ee(_s, { assertTypesMatch: () => Sk, getTensorsInContainer: () => Gg, isTensorInList: () => x_, makeTypesMatch: () => xt }); var y_ = ((e) => (e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6", e))(y_ || {}); var vk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64", e))(vk || {}); var xk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64", e))(xk || {}); var wk = ((e) => (e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64", e))(wk || {}); var kk = ((e) => (e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64", e))(kk || {}); var v_ = { float32: wk, int32: vk, bool: xk, complex64: kk }; 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 v_[e][t]; } function yp(e) { return cn(e, "int32"); } function xt(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 Sk(e, t) { O(e.dtype === t.dtype, () => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`); } function x_(e, t) { return t.some((n) => n.id === e.id); } function Gg(e) { let t = []; return Ik(e, t, /* @__PURE__ */ new Set()), t; } function Ik(e, t, n) { if (e == null) return; if (e instanceof et) { t.push(e); return; } if (!w_(e)) return; let s = e; for (let r in s) { let a = s[r]; n.has(a) || (n.add(a), Ik(a, t, n)); } } function w_(e) { return Array.isArray(e) || typeof e == "object"; } function jf(e) { return e.kernelName != null; } var bx = 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 pm = class { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new bx(); } 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 o_(this.backendInstance), true; } setupRegisteredKernels() { cm(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { cm(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 il) && 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 pm.nextTensorId++; } nextVariableId() { return pm.nextVariableId++; } clone(e) { let t = z.runKernel(Wa, { x: e }), n = { x: e }, s = (a) => ({ x: () => { let o = "float32", i = { x: a }, u = { dtype: o }; return z.runKernel(Ta, i, u); } }), r = []; return this.addTapeNode(this.state.activeScope.name, n, [t], s, r, {}), t; } runKernel(e, t, n) { if (this.backendName == null && this.backend, !(lm(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((i) => { r += i.dtype === "complex64" ? 3 : 1; }); let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], o = s - t - r - a; if (o > 0) throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`); } runKernelFunc(e) { let t, n = [], s = this.isTapeOn(), r = this.state.numBytes, a = this.state.numTensors; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0); let o; this.backendName == null && this.backend; let i, u = jf(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; if (jf(e)) { let { kernelName: h, inputs: f, attrs: m } = e; this.backendName == null && this.backend; let g = lm(h, this.backendName); O(g != null, () => `Cannot find registered kernel '${h}' for backend '${this.backendName}'`), o = () => { let b = this.backend.numDataIds(); i = g.kernelFunc({ inputs: f, attrs: m, backend: this.backend }); let y = Array.isArray(i) ? i : [i]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(h, b, y); let v = y.map((x) => x.rank != null ? x : this.makeTensorFromTensorInfo(x)); if (s) { let x = this.getTensorsForGradient(h, f, v); n = this.saveTensorsForBackwardMode(x); } return v; }; } else { let { forwardFunc: h } = e, f = (m) => { !s || (n = m.map((g) => this.keep(this.clone(g)))); }; o = () => { let m = this.backend.numDataIds(); i = this.tidy(() => h(this.backend, f)); let g = Array.isArray(i) ? i : [i]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, m, g), g; }; } let { inputs: l, attrs: c } = e, p = jf(e) ? null : e.backwardsFunc, d; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = o() : (d = this.profiler.profileKernel(u, l, () => o()), 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(i) ? t : t[0]; } saveTensorsForBackwardMode(e) { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { let s = hx(e); if (s != null) { let r = s.inputsToSave || [], a = s.outputsToSave || [], o; s.saveAllInputs ? (O(Array.isArray(t), () => "saveAllInputs is true, expected inputs to be an array."), o = Object.keys(t).map((u) => t[u])) : o = r.map((u) => t[u]); let i = n.filter((u, l) => a[l]); return o.concat(i); } 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" && or(e[0]) && (r = e.map((i) => zl(i))); let a = s.write(r, t, n), o = new et(t, n, a, this.nextTensorId()); if (this.trackTensor(o, s), n === "string") { let i = this.state.tensorInfo.get(a), u = ck(r); this.state.numBytes += u - i.bytes, i.bytes = u; } return o; } makeTensorFromDataId(e, t, n, s) { n = n || "float32"; let r = { dataId: e, shape: t, dtype: n }; return this.makeTensorFromTensorInfo(r, s); } makeTensorFromTensorInfo(e, t) { let { dataId: n, shape: s, dtype: r } = e, a = new et(s, r, n, this.nextTensorId()); return this.trackTensor(a, t), a; } makeVariable(e, t = true, n, s) { n = n || this.nextVariableId().toString(), s != null && s !== e.dtype && (e = e.cast(s)); let r = new kd(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 * om(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 kd || 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 * om(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 o = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: r }, i = hx(e); i != null && (s = i.gradFunc), s != null && (o.gradient = (u) => (u = u.map((l, c) => { if (l == null) { let p = n[c], d = ep(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(o); } 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 = Gg(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 = l_(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 o = {}; o[r.id] = n == null ? k_(r.shape) : n, c_(o, a, (u) => this.tidy(u), S_); let i = t.map((u) => o[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: i }; }); } customGrad(e) { return O(fr(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { O(t.every((o) => o instanceof et), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors"); let n, s = {}; t.forEach((o, i) => { s[i] = o; }); let r = (o, i) => (n = e(...t, i), O(n.value instanceof et, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), O(fr(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (o, i) => { let u = n.gradFunc(o, i), 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 = ju(), n = await this.backend.time(e); return n.wallMs = ju() - 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 bx(); 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 Hg = pm; Hg.nextTensorId = 0; Hg.nextVariableId = 0; function k_(e) { let t = hg(dt(e), "float32"); return z.makeTensor(t, e, "float32"); } function Ck() { let e = mk(); if (e._tfengine == null) { let t = new V$(e); e._tfengine = new Hg(t); } return H$(e._tfengine.ENV), f_(() => e._tfengine), e._tfengine; } var z = Ck(); function S_(e, t) { let n = { a: e, b: t }; return z.runKernel(Cr, n); } var vp = {}; Ee(vp, { isBrowser: () => Nk, isMobile: () => N_, mockIsMobile: () => C_ }); function I_() { return typeof navigator != "undefined" && navigator != null; } var hm; function C_(e) { hm = e; } function N_(e) { if (hm !== void 0) return hm; 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 Nk() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } var Vn = K(); Vn.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."); }); Vn.registerFlag("IS_BROWSER", () => Nk()); Vn.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); Vn.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); Vn.registerFlag("PROD", () => false); Vn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => Vn.getBool("DEBUG")); Vn.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true); Vn.registerFlag("IS_TEST", () => false); Vn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true); Vn.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); Vn.registerFlag("ENGINE_COMPILE_ONLY", () => false); Vn.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY", () => 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) && K().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && Tk(e, s, []), s; } function Tk(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) Tk(e[r], s, n.concat(r)); } function yx(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 yx(s, e.dtype, t, n), e; let r = Jd(e); if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), yx(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 i = r !== "string" ? bp(e, r) : aa(e, [], true); return z.makeTensor(i, a, r); } function Ku(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, o) => _(a, `${t}[${o}]`, n, s)); } var T_ = "__op"; function M(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 + T_; let r = (...a) => { z.startScope(n); try { let o = s(...a); return mg(o) && console.error("Cannot return a Promise inside of tidy."), z.endScope(o), o; } catch (o) { throw z.endScope(null), o; } }; return Object.defineProperty(r, "name", { value: n, configurable: true }), r; } function $_(e, t) { let n = _(e, "real", "complex"), s = _(t, "imag", "complex"); hn(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 z.runKernel(np, r); } var mr = M({ complex_: $_ }); function $r(e, t, n, s) { if (s == null && (s = Jd(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) { fg(t); let r = dt(t), a = dt(n); O(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`); for (let o = 0; o < n.length; ++o) { let i = n[o], u = o === n.length - 1 ? i !== dt(t.slice(o)) : true; O(n[o] === t[o] || !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" ? bp(e, s) : aa(e, [], true), z.makeTensor(e, t, s); } function ms(e, t, n) { let s = Rs(e, n); return $r(e, t, s, n); } var fm = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; var Sd = 4; async function __(e, t) { let n = [], s = [], r = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e); for (let o = 0; o < r.length; ++o) { let i = r[o], u = Array.isArray(e) ? e[o].tensor : e[i]; if (u.dtype !== "float32" && u.dtype !== "int32" && u.dtype !== "bool" && u.dtype !== "string" && u.dtype !== "complex64") throw new Error(`Unsupported dtype in weight '${i}': ${u.dtype}`); let l = { name: i, 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) + Sd * 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 += Sd, 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: A_(a), specs: n }; } function $k(e, t) { let n = {}, s, r = 0; for (let a of t) { let o = a.name, i = a.dtype, u = a.shape, l = dt(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 (i !== "float32") throw new Error(`Weight ${a.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${i}.`); } else throw new Error(`Weight ${a.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); let d = fm[p.dtype], h = e.slice(r, r + l * d), f = p.dtype === "uint8" ? new Uint8Array(h) : new Uint16Array(h); if (i === "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 = P_()), c = s(f); else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`); else if (i === "int32") { if (p.dtype !== "uint8" && p.dtype !== "uint16") throw new Error(`Unsupported quantization type ${p.dtype} for weight type int32.`); c = new Int32Array(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 '${o}': ${i}`); r += l * d; } else if (i === "string") { let p = dt(a.shape); c = []; for (let d = 0; d < p; d++) { let h = new Uint32Array(e.slice(r, r + Sd))[0]; r += Sd; let f = new Uint8Array(e.slice(r, r + h)); c.push(f), r += h; } } else { let p = fm[i], d = e.slice(r, r + l * p); if (i === "float32") c = new Float32Array(d); else if (i === "int32") c = new Int32Array(d); else if (i === "bool") c = new Uint8Array(d); else if (i === "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 = ms(h, u, "float32"), g = ms(f, u, "float32"); n[o] = mr(m, g), m.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${o}': ${i}`); r += l * p; } i !== "complex64" && (n[o] = ms(c, u, i)); } return n; } function A_(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 qg = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); function vx(e) { return qg ? Buffer.byteLength(e) : new Blob([e]).size; } function E_(e) { if (qg) 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 R_(e) { if (qg) { 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 jg(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 xx(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 _k(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 Kg(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 Ll(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 : vx(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : vx(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; } function D_() { 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 F_() { 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 O_() { let e = new Uint32Array(64); for (let t = 0; t < 64; t++) e[t] = 1024; return e[0] = e[32] = 0, e; } function P_() { let e = D_(), t = F_(), n = O_(); return (s) => { let r = new ArrayBuffer(4 * s.length), a = new Uint32Array(r); for (let o = 0; o < s.length; o++) { let i = s[o], u = e[n[i >> 10] + (i & 1023)] + t[i >> 10]; a[o] = u; } return new Float32Array(r); }; } var wt = class { constructor() { this.saveRouters = [], this.loadRouters = []; } static getInstance() { return wt.instance == null && (wt.instance = new wt()), wt.instance; } static registerSaveRouter(e) { wt.getInstance().saveRouters.push(e); } static registerLoadRouter(e) { wt.getInstance().loadRouters.push(e); } static getSaveHandlers(e) { return wt.getHandlers(e, "save"); } static getLoadHandlers(e, t) { return wt.getHandlers(e, "load", t); } static getHandlers(e, t, n) { let s = []; return (t === "load" ? wt.getInstance().loadRouters : wt.getInstance().saveRouters).forEach((a) => { let o = a(e, n); o !== null && s.push(o); }), s; } }; var z_ = (e) => wt.registerSaveRouter(e); var L_ = (e) => wt.registerLoadRouter(e); var M_ = (e) => wt.getSaveHandlers(e); var B_ = (e, t) => wt.getLoadHandlers(e, t); var mm = "tensorflowjs"; var gm = 1; var Zr = "models_store"; var ir = "model_info_store"; function Ak() { if (!K().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 bm(e) { let t = e.result; t.createObjectStore(Zr, { keyPath: "modelPath" }), t.createObjectStore(ir, { keyPath: "modelPath" }); } var la = class { constructor(e) { if (this.indexedDB = Ak(), 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(mm, gm); r.onupgradeneeded = () => bm(r), r.onsuccess = () => { let a = r.result; if (t == null) { let o = a.transaction(Zr, "readonly"), u = o.objectStore(Zr).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)), o.oncomplete = () => a.close(); } else { let o = Ll(t), i = a.transaction(ir, "readwrite"), u = i.objectStore(ir), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: o }), c; l.onsuccess = () => { c = a.transaction(Zr, "readwrite"); let d = c.objectStore(Zr).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: o }); d.onsuccess = () => n({ modelArtifactsInfo: o }), d.onerror = (h) => { u = i.objectStore(ir); 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)), i.oncomplete = () => { c == null ? a.close() : c.oncomplete = () => a.close(); }; } }, r.onerror = (a) => s(r.error); }); } }; la.URL_SCHEME = "indexeddb://"; var Ek = (e) => K().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(la.URL_SCHEME) ? V_(e.slice(la.URL_SCHEME.length)) : null; wt.registerSaveRouter(Ek); wt.registerLoadRouter(Ek); function V_(e) { return new la(e); } function W_(e) { return e.startsWith(la.URL_SCHEME) ? e.slice(la.URL_SCHEME.length) : e; } var U_ = class { constructor() { this.indexedDB = Ak(); } async listModels() { return new Promise((e, t) => { let n = this.indexedDB.open(mm, gm); n.onupgradeneeded = () => bm(n), n.onsuccess = () => { let s = n.result, r = s.transaction(ir, "readonly"), o = r.objectStore(ir).getAll(); o.onsuccess = () => { let i = {}; for (let u of o.result) i[u.modelPath] = u.modelArtifactsInfo; e(i); }, o.onerror = (i) => (s.close(), t(o.error)), r.oncomplete = () => s.close(); }, n.onerror = (s) => t(n.error); }); } async removeModel(e) { return e = W_(e), new Promise((t, n) => { let s = this.indexedDB.open(mm, gm); s.onupgradeneeded = () => bm(s), s.onsuccess = () => { let r = s.result, a = r.transaction(ir, "readwrite"), o = a.objectStore(ir), i = o.get(e), u; i.onsuccess = () => { if (i.result == null) return r.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { let l = o.delete(e), c = () => { u = r.transaction(Zr, "readwrite"); let d = u.objectStore(Zr).delete(e); d.onsuccess = () => t(i.result.modelArtifactsInfo), d.onerror = (h) => n(i.error); }; l.onsuccess = c, l.onerror = (p) => (c(), r.close(), n(i.error)); } }, i.onerror = (l) => (r.close(), n(i.error)), a.oncomplete = () => { u == null ? r.close() : u.oncomplete = () => r.close(); }; }, s.onerror = (r) => n(s.error); }); } }; var Us = "/"; var qo = "tensorflowjs_models"; var Rk = "info"; var G_ = "model_topology"; var H_ = "weight_specs"; var q_ = "weight_data"; var j_ = "model_metadata"; function Dk(e) { return { info: [qo, e, Rk].join(Us), topology: [qo, e, G_].join(Us), weightSpecs: [qo, e, H_].join(Us), weightData: [qo, e, q_].join(Us), modelMetadata: [qo, e, j_].join(Us) }; } function Fk(e) { for (let t of Object.values(e)) window.localStorage.removeItem(t); } function K_(e) { let t = e.split(Us); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); return t.slice(1, t.length - 1).join(Us); } function X_(e) { return e.startsWith(ca.URL_SCHEME) ? e.slice(ca.URL_SCHEME.length) : e; } var ca = class { constructor(e) { if (!K().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 = Dk(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 = Ll(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, E_(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 Fk(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 o = JSON.parse(r); t.format = o.format, t.generatedBy = o.generatedBy, t.convertedBy = o.convertedBy, o.signature != null && (t.signature = o.signature), o.userDefinedMetadata != null && (t.userDefinedMetadata = o.userDefinedMetadata), o.modelInitializer != null && (t.modelInitializer = o.modelInitializer), o.trainingConfig != null && (t.trainingConfig = o.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 = R_(a), t; } }; ca.URL_SCHEME = "localstorage://"; var Ok = (e) => K().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(ca.URL_SCHEME) ? Y_(e.slice(ca.URL_SCHEME.length)) : null; wt.registerSaveRouter(Ok); wt.registerLoadRouter(Ok); function Y_(e) { return new ca(e); } var Q_ = class { constructor() { O(K().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 = qo + Us, n = Us + Rk; for (let s = 0; s < this.LS.length; ++s) { let r = this.LS.key(s); if (r.startsWith(t) && r.endsWith(n)) { let a = K_(r); e[a] = JSON.parse(this.LS.getItem(r)); } } return e; } async removeModel(e) { e = X_(e); let t = Dk(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 Fk(t), n; } }; var Yo = "://"; 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(Yo) && (e = e.slice(0, e.indexOf(Yo))), 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 od(e) { if (e.indexOf(Yo) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(",")}`); return { scheme: e.split(Yo)[0], path: e.split(Yo)[1] }; } async function Pk(e, t, n = false) { O(e !== t, () => `Old path and new path are the same: '${e}'`); let s = wt.getLoadHandlers(e); O(s.length > 0, () => `Copying failed because no load handler is found for source URL ${e}.`), O(s.length < 2, () => `Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`); let r = s[0], a = wt.getSaveHandlers(t); O(a.length > 0, () => `Copying failed because no save handler is found for destination URL ${t}.`), O(a.length < 2, () => `Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`); let o = a[0], i = od(e).scheme, u = od(e).path, l = i === od(e).scheme, c = await r.load(); n && l && await zn.getManager(i).removeModel(u); let p = await o.save(c); return n && !l && await zn.getManager(i).removeModel(u), p.modelArtifactsInfo; } async function Z_() { 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 + Yo + r; t[a] = s[r]; } } return t; } async function J_(e) { let t = od(e); return zn.getManager(t.scheme).removeModel(t.path); } async function eA(e, t) { return Pk(e, t, false); } async function tA(e, t) { return Pk(e, t, true); } var nA = 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 (K().get("IS_BROWSER")) { K().setPlatform("browser", new nA()); try { zn.registerManager(ca.URL_SCHEME, new Q_()); } catch (e) { } try { zn.registerManager(la.URL_SCHEME, new U_()); } catch (e) { } } var sA = { importFetch: () => l$() }; var Kf; var rA = class { constructor() { this.util = c$(), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { return K().global.fetch != null ? K().global.fetch(e, t) : (Kf == null && (Kf = sA.importFetch()), Kf(e, t)); } now() { let e = process.hrtime(); return e[0] * 1e3 + e[1] / 1e6; } encode(e, t) { if (t !== "utf-8" && t !== "utf8") throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`); return this.textEncoder.encode(e); } decode(e, t) { return e.length === 0 ? "" : new this.util.TextDecoder(t).decode(e); } }; K().get("IS_NODE") && !K().get("IS_BROWSER") && K().setPlatform("node", new rA()); function Ae(e, t = "float32", n) { return t = t || "float32", fg(e), new Vt(e, t, n); } function aA(e, t) { let n = _(e, "x", "cast"); if (!lk(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 z.runKernel(Ta, s, r); } var le = M({ cast_: aA }); function oA(e) { let n = { x: _(e, "x", "clone", "string_or_numeric") }; return z.runKernel(Wa, n); } var lr = M({ clone_: oA }); function iA(e, t = false) { console.log(e.toString(t)); } Ck(); var uA = { buffer: Ae, cast: le, clone: lr, print: iA }; m_(uA); var An = {}; Ee(An, { browserFiles: () => mA, browserHTTPRequest: () => xA, concatenateArrayBuffers: () => jg, copyModel: () => eA, decodeWeights: () => $k, encodeWeights: () => __, fromMemory: () => kA, fromMemorySync: () => Vk, getLoadHandlers: () => B_, getModelArtifactsForJSON: () => Kg, getModelArtifactsInfoForJSON: () => Ll, getSaveHandlers: () => M_, http: () => Yg, isHTTPScheme: () => vm, listModels: () => Z_, loadWeights: () => gA, moveModel: () => tA, registerLoadRouter: () => L_, registerSaveRouter: () => z_, removeModel: () => J_, weightsLoaderFactory: () => Lk, withSaveHandler: () => SA, withSaveHandlerSync: () => IA }); var lA = "model"; var cA = ".json"; var dA = ".weights.bin"; function wx(e) { return new Promise((t) => setTimeout(t)).then(e); } var ym = class { constructor(e) { if (!K().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(ym.URL_SCHEME) && (e = e.slice(ym.URL_SCHEME.length)), (e == null || e.length === 0) && (e = lA), this.modelJsonFileName = e + cA, this.weightDataFileName = e + dA; } 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 = _k(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 wx(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) { let o = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; o.download = this.weightDataFileName, o.href = t, await wx(() => o.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: Ll(e) }; } } }; var Id = ym; Id.URL_SCHEME = "downloads://"; var pA = 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 i = Kg(r, (u) => this.loadWeights(u)); e(i); }, 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, jg(a)]); } loadWeightsFile(e, t) { return new Promise((n, s) => { let r = new FileReader(); r.onload = (a) => { let o = a.target.result; n(o); }, 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) => xx(r.name)), s = {}; for (let r of e) r.paths.forEach((a) => { let o = xx(a); if (t.indexOf(o) !== -1) throw new Error(`Duplicate file basename found in weights manifest: '${o}'`); if (t.push(o), n.indexOf(o) === -1) throw new Error(`Weight file with basename '${o}' is not provided.`); s[a] = this.weightsFiles[n.indexOf(o)]; }); 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 hA = (e) => K().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(Id.URL_SCHEME) ? fA(e.slice(Id.URL_SCHEME.length)) : null; wt.registerSaveRouter(hA); function fA(e = "model") { return new Id(e); } function mA(e) { return new pA(e); } function kx(e, t, n, s) { o(e), n = n == null ? 0 : n, s = s == null ? 1 : s, i(n, s); let r = 0, a = (u) => (u.then((l) => { let c = n + ++r / e.length * (s - n); return t(c), l; }), u); function o(u) { O(u != null && Array.isArray(u) && u.length > 0, () => "promises must be a none empty array"); } function i(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 zk(e, t) { t == null && (t = {}); let n = t.fetchFunc == null ? K().platform.fetch : t.fetchFunc, s = e.map((p) => n(p, t.requestInit, { isBinary: true })), r = 0, a = 0.5, i = (t.onProgress == null ? await Promise.all(s) : await kx(s, t.onProgress, r, a)).map((p) => p.arrayBuffer()), u = 0.5, l = 1; return t.onProgress == null ? await Promise.all(i) : await kx(i, t.onProgress, u, l); } async function gA(e, t = "", n, s) { return Lk((o) => zk(o, { requestInit: s }))(e, t, n); } function Lk(e) { return async (t, n = "", s) => { let r = t.map(() => false), a = {}, o = s != null ? s.map(() => false) : [], i = []; if (t.forEach((h, f) => { let m = 0; h.weights.forEach((g) => { let b = "quantization" in g ? g.quantization.dtype : g.dtype, y = fm[b] * dt(g.shape), v = () => { r[f] = true, a[f] == null && (a[f] = []), a[f].push({ manifestEntry: g, groupOffset: m, sizeBytes: y }); }; s != null ? s.forEach((x, k) => { x === g.name && (v(), o[k] = true); }) : v(), i.push(g.name), m += y; }); }), !o.every((h) => h)) { let h = s.filter((f, m) => !o[m]); throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${i.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 x = 0; x < f; x++) m += c[d + x].byteLength; let g = new ArrayBuffer(m), b = new Uint8Array(g), y = 0; for (let x = 0; x < f; x++) { let k = new Uint8Array(c[d + x]); b.set(k, y), y += k.byteLength; } a[h].forEach((x) => { let k = g.slice(x.groupOffset, x.groupOffset + x.sizeBytes), I = $k(k, [x.manifestEntry]); for (let $ in I) p[$] = I[$]; }), d += f; }), p; }; } var bA = "application/octet-stream"; var yA = "application/json"; var Xg = 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 = K().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 = _k(e, n); t.body.append("model.json", new Blob([JSON.stringify(s)], { type: yA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: bA }), "model.weights.bin"); let r = await this.fetch(this.path, t); if (r.ok) return { modelArtifactsInfo: Ll(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 Kg(t, (r) => this.loadWeights(r)); } async loadWeights(e) { let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, s] = vA(t), r = this.weightPathPrefix || n, a = []; for (let l of e) a.push(...l.weights); let o = [], i = []; for (let l of e) for (let c of l.paths) this.weightUrlConverter != null ? i.push(this.weightUrlConverter(c)) : o.push(r + c + s); this.weightUrlConverter && o.push(...await Promise.all(i)); let u = await zk(o, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); return [a, jg(u)]; } }; Xg.URL_SCHEME_REGEX = /^https?:\/\//; function vA(e) { let t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), s = e.substring(0, t), r = n > t ? e.substring(n) : ""; return [s + "/", r]; } function vm(e) { return e.match(Xg.URL_SCHEME_REGEX) != null; } var Mk = (e, t) => { if (typeof fetch == "undefined" && (t == null || t.fetchFunc == null)) return null; { let n = true; if (Array.isArray(e) ? n = e.every((s) => vm(s)) : n = vm(e), n) return Yg(e, t); } return null; }; wt.registerSaveRouter(Mk); wt.registerLoadRouter(Mk); function Yg(e, t) { return new Xg(e, t); } function xA(e, t) { return Yg(e, t); } var Xf = class { constructor(e) { this.modelArtifacts = e; } load() { return this.modelArtifacts; } }; var Bk = class { constructor(e) { this.saveHandler = e; } save(e) { return this.saveHandler(e); } }; var wA = class { constructor(e) { e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = (t) => Promise.resolve(e.save(t))); } }; function kA(e, t, n, s) { let r = arguments; return new wA(Vk(...r)); } function Vk(e, t, n, s) { return arguments.length === 1 ? e.modelTopology != null || e.weightSpecs != null ? new Xf(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 Xf({ 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 Xf({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: s })); } function SA(e) { return new Bk(e); } function IA(e) { return new Bk(e); } var CA = {}; Ee(CA, { confusionMatrix: () => FA }); function NA(e, t, n = false, s = false) { let r = _(e, "a", "matMul"), a = _(t, "b", "matMul"); [r, a] = xt(r, a); let o = { a: r, b: a }, i = { transposeA: n, transposeB: s }; return z.runKernel(Na, o, i); } var We = M({ matMul_: NA }); function TA(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") }, o = { depth: t, onValue: n, offValue: s }; return z.runKernel(Di, a, o); } var Cd = M({ oneHot_: TA }); function Epe() { K().set("PROD", true); } function Rpe() { K().set("DEBUG", true); } function Dpe() { K().set("DEPRECATION_WARNINGS_ENABLED", false), console.warn("TensorFlow.js deprecation warnings have been disabled."); } function Wk(e) { K().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(e + " You can disable deprecation warnings with tf.disableDeprecationWarnings()."); } g_(Wk); function Fpe() { z.disposeVariables(); } function ds() { return z; } function xm() { return z.memory(); } function Ope(e) { return z.profile(e); } function q(e, t) { return z.tidy(e, t); } function De(e) { Gg(e).forEach((n) => n.dispose()); } function qt(e) { return z.keep(e); } function Ppe(e) { return z.time(e); } function zpe(e) { return z.setBackend(e); } function Lpe() { return z.ready(); } function Mpe() { return z.backendName; } function Bpe(e) { z.removeBackend(e); } function Vpe(e) { return z.findBackend(e); } function Wpe(e) { return z.findBackendFactory(e); } function xp(e, t, n = 1) { return z.registerBackend(e, t, n); } function $A() { return z.backend; } function Upe(e, t) { K().setPlatform(e, t); } function _A(e) { let n = { input: _(e, "input", "imag") }; return z.runKernel(ip, n); } var wp = M({ imag_: _A }); function AA(e) { let n = { x: _(e, "x", "neg") }; return z.runKernel($i, n); } var vt = M({ neg_: AA }); function EA(e) { let n = { input: _(e, "input", "real") }; return z.runKernel(cp, n); } var Xu = M({ real_: EA }); function RA(e, t, n) { let s = _(e, "x", "transpose"); if (t == null && (t = s.shape.map((o, i) => i).reverse()), O(s.rank === t.length, () => `Error in transpose: rank of input ${s.rank} must match length of perm ${t}.`), t.forEach((o) => { O(o >= 0 && o < s.rank, () => `All entries in 'perm' must be between 0 and ${s.rank - 1} but got ${t}`); }), s.rank <= 1) return s.clone(); let r = { x: s }, a = { perm: t }; return s.dtype === "complex64" ? q(() => { let o = Xu(s), i = wp(s); return o = z.runKernel(Hs, { x: o }, a), i = z.runKernel(Hs, { x: i }, a), n && (i = vt(i)), mr(o, i); }) : z.runKernel(Hs, r, a); } var Ge = M({ transpose_: RA }); function DA(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 = Cd(le(s, "int32"), n), o = Cd(le(r, "int32"), n), i = Ge(a), u = We(i, o); return le(u, "int32"); } var FA = M({ confusionMatrix_: DA }); var Qi = {}; Ee(Qi, { assertAndGetBroadcastShape: () => at, getBroadcastDims: () => Uk, getReductionAxes: () => _t }); function Uk(e, t) { let n = e.length, s = []; for (let r = 0; r < n; r++) { let a = n - 1 - r, o = e[a] || 1; (t[t.length - 1 - r] || 1) > 1 && o === 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, o = t[a]; (r == null || r === 1 && o > 1) && n.unshift(a); } return n; } function at(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 o = t[t.length - r - 1]; if (o == null && (o = 1), a === 1) n.unshift(o); else if (o === 1) n.unshift(a); else if (a !== o) { let i = `Operands could not be broadcast together with shapes ${e} and ${t}.`; throw Error(i); } else n.unshift(a); } return n; } var Gk = {}; Ee(Gk, { fromPixels: () => WA, fromPixelsAsync: () => BA, toPixels: () => VA }); function OA(e, t, n) { if (ka(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 $r(e, t, s, n); } var Ur; function Hk(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, o = false, i = 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) o = true; else if (typeof ImageBitmap != "undefined" && e instanceof ImageBitmap) i = true; else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${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