{ "version": 3, "sources": ["../src/util/util.ts", "../src/config.ts", "tfjs.esm.js", "../src/image/imagefxshaders.ts", "../src/image/imagefx.ts", "../src/image/enhance.ts", "../src/image/image.ts", "../src/util/env.ts", "../src/tfjs/load.ts", "../src/models.ts", "../src/gear/gear.ts", "../src/tfjs/constants.ts", "../src/gear/ssrnet-age.ts", "../src/gear/ssrnet-gender.ts", "../src/face/antispoof.ts", "../src/face/facemeshcoords.ts", "../src/face/facemeshutil.ts", "../src/face/blazeface.ts", "../src/body/blazeposecoords.ts", "../src/body/blazeposedetector.ts", "../src/util/box.ts", "../src/body/blazepose.ts", "../src/object/labels.ts", "../src/object/centernet.ts", "../src/body/efficientposecoords.ts", "../src/body/efficientpose.ts", "../src/gear/emotion.ts", "../src/face/mobilefacenet.ts", "../src/face/iris.ts", "../src/face/attention.ts", "../src/face/facemesh.ts", "../src/face/faceres.ts", "../src/hand/handposeutil.ts", "../src/hand/handposeanchors.ts", "../src/hand/handposedetector.ts", "../src/hand/handposepipeline.ts", "../src/hand/fingerdef.ts", "../src/hand/fingergesture.ts", "../src/hand/fingerpose.ts", "../src/hand/handpose.ts", "../src/hand/handtrack.ts", "../src/face/liveness.ts", "../src/body/movenetcoords.ts", "../src/body/movenetfix.ts", "../src/body/movenet.ts", "../src/object/nanodet.ts", "../src/body/posenetutils.ts", "../src/body/posenet.ts", "../src/segmentation/segmentation.ts", "../src/tfjs/humangl.ts", "../src/tfjs/backend.ts", "../src/draw/draw.ts", "../src/draw/primitives.ts", "../src/draw/options.ts", "../src/draw/face.ts", "../src/draw/body.ts", "../src/draw/hand.ts", "../src/draw/object.ts", "../src/draw/gesture.ts", "../src/face/mask.ts", "../src/face/angles.ts", "../src/face/face.ts", "../src/gesture/gesture.ts", "../src/util/interpolate.ts", "../src/face/match.ts", "../src/util/persons.ts", "../src/sample.ts", "../src/warmup.ts", "../src/human.ts"], "sourcesContent": ["import type { Config } from '../exports';\n\n/**\n * Simple helper functions used accross codebase\n */\n\n// helper function: wrapper around console output\nexport function log(...msg): void {\n const dt = new Date();\n const ts = `${dt.getHours().toString().padStart(2, '0')}:${dt.getMinutes().toString().padStart(2, '0')}:${dt.getSeconds().toString().padStart(2, '0')}.${dt.getMilliseconds().toString().padStart(3, '0')}`;\n // eslint-disable-next-line no-console\n if (msg) console.log(ts, 'Human:', ...msg);\n}\n\n// helper function: join two paths\nexport function join(folder: string, file: string): string {\n const separator = folder.endsWith('/') ? '' : '/';\n const skipJoin = file.startsWith('.') || file.startsWith('/') || file.startsWith('http:') || file.startsWith('https:') || file.startsWith('file:');\n const path = skipJoin ? `${file}` : `${folder}${separator}${file}`;\n if (!path.toLocaleLowerCase().includes('.json')) throw new Error(`modelpath error: expecting json file: ${path}`);\n return path;\n}\n\n// helper function: gets elapsed time on both browser and nodejs\nexport const now = () => {\n if (typeof performance !== 'undefined') return performance.now();\n return parseInt((Number(process.hrtime.bigint()) / 1000 / 1000).toString());\n};\n\n// helper function: checks current config validity\nexport function validate(defaults: Partial, config: Partial, parent = 'config', msgs: Array<{ reason: string, where: string, expected?: string }> = []) {\n for (const key of Object.keys(config)) {\n if (typeof config[key] === 'object') {\n validate(defaults[key], config[key], key, msgs);\n } else {\n const defined = defaults && (typeof defaults[key] !== 'undefined');\n if (!defined) msgs.push({ reason: 'unknown property', where: `${parent}.${key} = ${config[key]}` });\n const same = defaults && typeof defaults[key] === typeof config[key];\n if (defined && !same) msgs.push({ reason: 'property type mismatch', where: `${parent}.${key} = ${config[key]}`, expected: typeof defaults[key] });\n }\n // ok = ok && defined && same;\n }\n if (config.debug && parent === 'config' && msgs.length > 0) log('invalid configuration', msgs);\n return msgs;\n}\n\n// helper function: perform deep merge of multiple objects so it allows full inheritance with overrides\nexport function mergeDeep(...objects) {\n const isObject = (obj) => obj && typeof obj === 'object';\n return objects.reduce((prev, obj) => {\n Object.keys(obj || {}).forEach((key) => {\n const pVal = prev[key];\n const oVal = obj[key];\n if (Array.isArray(pVal) && Array.isArray(oVal)) prev[key] = pVal.concat(...oVal);\n else if (isObject(pVal) && isObject(oVal)) prev[key] = mergeDeep(pVal, oVal);\n else prev[key] = oVal;\n });\n return prev;\n }, {});\n}\n\n// helper function: return min and max from input array\nexport const minmax = (data: Array) => data.reduce((acc: Array, val) => {\n acc[0] = (acc[0] === undefined || val < acc[0]) ? val : acc[0];\n acc[1] = (acc[1] === undefined || val > acc[1]) ? val : acc[1];\n return acc;\n}, []);\n\n// helper function: async wait\nexport async function wait(time: number) {\n const waiting = new Promise((resolve) => { setTimeout(() => resolve(true), time); });\n await waiting;\n}\n", "/* eslint-disable indent */\n/* eslint-disable no-multi-spaces */\n\n/** Generic config type inherited by all module types */\nexport interface GenericConfig {\n /** is module enabled? */\n enabled: boolean,\n /** path to model json file (relative to `modelBasePath` */\n modelPath: string,\n /** how many max frames to go without re-running model if cached results are acceptable\n * for two-phase models such as face and hand caching applies to bounding boxes detection only */\n skipFrames: number,\n /** how many max milliseconds to go without re-running model if cached results are acceptable\n * for two-phase models such as face and hand caching applies to bounding boxes detection only */\n skipTime: number,\n}\n\n/** Detector part of face configuration */\nexport interface FaceDetectorConfig extends GenericConfig {\n /** is face rotation correction performed after detecting face?\n * used to correctly analyze faces under high angles\n */\n rotation: boolean,\n /** maximum number of detected faces */\n maxDetected: number,\n /** minimum confidence for a detected face before results are discarded */\n minConfidence: number,\n /** minimum overlap between two detected faces before one is discarded */\n iouThreshold: number,\n /** should child models perform on masked image of a face */\n mask: boolean,\n /** should face detection return processed and cropped face tensor that can with an external model for addtional processing?\n * if enabled it must be manually deallocated to avoid memory leak */\n return: boolean,\n}\n\n/** Mesh part of face configuration */\nexport interface FaceMeshConfig extends GenericConfig {}\n\n/** Iris part of face configuration */\nexport interface FaceIrisConfig extends GenericConfig {}\n\n/** Attention part of face configuration */\nexport interface FaceAttentionConfig extends GenericConfig {}\n\n/** Description or face embedding part of face configuration\n * - also used by age and gender detection\n */\nexport interface FaceDescriptionConfig extends GenericConfig {\n /** minimum confidence for a detected face before results are discarded */\n minConfidence: number,\n}\n\n/** Emotion part of face configuration */\nexport interface FaceEmotionConfig extends GenericConfig {\n /** minimum confidence for a detected face before results are discarded */\n minConfidence: number,\n}\n\n/** Anti-spoofing part of face configuration */\nexport interface FaceAntiSpoofConfig extends GenericConfig {}\n\n/** Liveness part of face configuration */\nexport interface FaceLivenessConfig extends GenericConfig {}\n\n/** Configures all face-specific options: face detection, mesh analysis, age, gender, emotion detection and face description */\nexport interface FaceConfig extends GenericConfig {\n detector: Partial,\n mesh: Partial,\n attention: Partial,\n iris: Partial,\n description: Partial,\n emotion: Partial,\n antispoof: Partial,\n liveness: Partial,\n}\n\n/** Configures all body detection specific options */\nexport interface BodyConfig extends GenericConfig {\n /** maximum number of detected bodies */\n maxDetected: number,\n /** minimum confidence for a detected body before results are discarded */\n minConfidence: number,\n /* experimental\n /** experimental: detector used for body model before actual analysis\n detector?: {\n /** experimental: enable body detector before body landmarks\n enabled: boolean,\n /** experimental: path to optional body detector model json file\n modelPath: string,\n /** experimental: minimum confidence for a detected body before results are discarded\n minConfidence: number,\n /** experimental: minimum overlap between two detected bodies before one is discarded\n iouThreshold: number\n },\n */\n}\n\n/** Configures all hand detection specific options */\nexport interface HandConfig extends GenericConfig {\n /** should hand rotation correction be performed after hand detection? */\n rotation: boolean,\n /** minimum confidence for a detected hand before results are discarded */\n minConfidence: number,\n /** minimum overlap between two detected hands before one is discarded */\n iouThreshold: number,\n /** maximum number of detected hands */\n maxDetected: number,\n /** should hand landmarks be detected or just return detected hand box */\n landmarks: boolean,\n detector: {\n /** path to hand detector model json */\n modelPath?: string,\n },\n skeleton: {\n /** path to hand skeleton model json */\n modelPath?: string,\n },\n}\n\n/** Configures all object detection specific options */\nexport interface ObjectConfig extends GenericConfig {\n /** minimum confidence for a detected objects before results are discarded */\n minConfidence: number,\n /** minimum overlap between two detected objects before one is discarded */\n iouThreshold: number,\n /** maximum number of detected objects */\n maxDetected: number,\n}\n\n/** Configures all body segmentation module\n * removes background from input containing person\n * if segmentation is enabled it will run as preprocessing task before any other model\n * alternatively leave it disabled and use it on-demand using human.segmentation method which can\n * remove background or replace it with user-provided background\n*/\nexport interface SegmentationConfig extends GenericConfig {\n /** blur segmentation output by pixels for more realistic image */\n blur: number,\n}\n\n/** Run input through image filters before inference\n * - available only in Browser environments\n * - image filters run with near-zero latency as they are executed on the GPU using WebGL\n*/\nexport interface FilterConfig {\n /** are image filters enabled? */\n enabled: boolean,\n /** perform image histogram equalization\n * - equalization is performed on input as a whole and detected face before its passed for further analysis\n */\n equalization: boolean,\n /** resize input width\n * - if both width and height are set to 0, there is no resizing\n * - if just one is set, second one is scaled automatically\n * - if both are set, values are used as-is\n */\n width: number,\n /** resize input height\n * - if both width and height are set to 0, there is no resizing\n * - if just one is set, second one is scaled automatically\n * - if both are set, values are used as-is\n */\n height: number,\n /** return processed canvas imagedata in result */\n return: boolean,\n /** flip input as mirror image */\n flip: boolean,\n /** range: -1 (darken) to 1 (lighten) */\n brightness: number,\n /** range: -1 (reduce contrast) to 1 (increase contrast) */\n contrast: number,\n /** range: 0 (no sharpening) to 1 (maximum sharpening) */\n sharpness: number,\n /** range: 0 (no blur) to N (blur radius in pixels) */\n blur: number\n /** range: -1 (reduce saturation) to 1 (increase saturation) */\n saturation: number,\n /** range: 0 (no change) to 360 (hue rotation in degrees) */\n hue: number,\n /** image negative */\n negative: boolean,\n /** image sepia colors */\n sepia: boolean,\n /** image vintage colors */\n vintage: boolean,\n /** image kodachrome colors */\n kodachrome: boolean,\n /** image technicolor colors */\n technicolor: boolean,\n /** image polaroid camera effect */\n polaroid: boolean,\n /** range: 0 (no pixelate) to N (number of pixels to pixelate) */\n pixelate: number,\n}\n\n/** Controlls gesture detection */\nexport interface GestureConfig {\n /** is gesture detection enabled? */\n enabled: boolean,\n}\n/** Possible TensorFlow backends */\nexport type BackendType = ['cpu', 'wasm', 'webgl', 'humangl', 'tensorflow', 'webgpu'];\n\n/** Possible values for `human.warmup` */\nexport type WarmupType = ['' | 'none' | 'face' | 'full' | 'body'];\n\n/**\n * Configuration interface definition for **Human** library\n * Contains all configurable parameters\n * Defaults: [config](https://github.com/vladmandic/human/blob/main/src/config.ts#L262)\n */\nexport interface Config {\n /** Backend used for TFJS operations\n * valid build-in backends are:\n * - Browser: `cpu`, `wasm`, `webgl`, `humangl`, `webgpu`\n * - NodeJS: `cpu`, `wasm`, `tensorflow`\n * default: `humangl` for browser and `tensorflow` for nodejs\n */\n backend: '' | 'cpu' | 'wasm' | 'webgl' | 'humangl' | 'tensorflow' | 'webgpu',\n\n /** Path to *.wasm files if backend is set to `wasm`\n *\n * default: auto-detects to link to CDN `jsdelivr` when running in browser\n */\n wasmPath: string,\n\n /** Force WASM loader to use platform fetch\n *\n * default: auto-detects to link to CDN `jsdelivr` when running in browser\n */\n wasmPlatformFetch: boolean,\n\n /** Print debug statements to console\n *\n * default: `true`\n */\n debug: boolean,\n\n /** Perform model loading and inference concurrently or sequentially\n *\n * default: `true`\n */\n async: boolean,\n\n /** What to use for `human.warmup()`\n * - warmup pre-initializes all models for faster inference but can take significant time on startup\n * - used by `webgl`, `humangl` and `webgpu` backends\n *\n * default: `full`\n */\n warmup: '' | 'none' | 'face' | 'full' | 'body',\n\n /** Base model path (typically starting with file://, http:// or https://) for all models\n * - individual modelPath values are relative to this path\n *\n * default: `../models/` for browsers and `file://models/` for nodejs\n */\n modelBasePath: string,\n\n /** Cache models in IndexDB on first sucessfull load\n * default: true if indexdb is available (browsers), false if its not (nodejs)\n */\n cacheModels: boolean,\n\n /** Cache sensitivity\n * - values 0..1 where 0.01 means reset cache if input changed more than 1%\n * - set to 0 to disable caching\n *\n * default: 0.7\n */\n cacheSensitivity: number;\n\n /** Perform immediate garbage collection on deallocated tensors instead of caching them */\n deallocate: boolean;\n\n /** Internal Variable */\n skipAllowed: boolean;\n\n /** Filter config {@link FilterConfig} */\n filter: Partial,\n\n /** Gesture config {@link GestureConfig} */\n gesture: Partial;\n\n /** Face config {@link FaceConfig} */\n face: Partial,\n\n /** Body config {@link BodyConfig} */\n body: Partial,\n\n /** Hand config {@link HandConfig} */\n hand: Partial,\n\n /** Object config {@link ObjectConfig} */\n object: Partial,\n\n /** Segmentation config {@link SegmentationConfig} */\n segmentation: Partial,\n}\n\n/** - [See all default Config values...](https://github.com/vladmandic/human/blob/main/src/config.ts#L262) */\nconst config: Config = {\n backend: '',\n modelBasePath: '',\n cacheModels: true,\n wasmPath: '',\n wasmPlatformFetch: false,\n debug: true,\n async: true,\n warmup: 'full',\n cacheSensitivity: 0.70,\n skipAllowed: false,\n deallocate: false,\n filter: {\n enabled: true,\n equalization: false,\n width: 0,\n height: 0,\n flip: false,\n return: true,\n brightness: 0,\n contrast: 0,\n sharpness: 0,\n blur: 0,\n saturation: 0,\n hue: 0,\n negative: false,\n sepia: false,\n vintage: false,\n kodachrome: false,\n technicolor: false,\n polaroid: false,\n pixelate: 0,\n },\n gesture: {\n enabled: true,\n },\n face: {\n enabled: true,\n detector: {\n modelPath: 'blazeface.json',\n rotation: true,\n maxDetected: 1,\n skipFrames: 99,\n skipTime: 2500,\n minConfidence: 0.2,\n iouThreshold: 0.1,\n mask: false,\n return: false,\n },\n mesh: {\n enabled: true,\n modelPath: 'facemesh.json',\n },\n attention: {\n enabled: false,\n modelPath: 'facemesh-attention.json',\n },\n iris: {\n enabled: true,\n modelPath: 'iris.json',\n },\n emotion: {\n enabled: true,\n minConfidence: 0.1,\n skipFrames: 99,\n skipTime: 1500,\n modelPath: 'emotion.json',\n },\n description: {\n enabled: true,\n modelPath: 'faceres.json',\n skipFrames: 99,\n skipTime: 3000,\n minConfidence: 0.1,\n },\n antispoof: {\n enabled: false,\n skipFrames: 99,\n skipTime: 4000,\n modelPath: 'antispoof.json',\n },\n liveness: {\n enabled: false,\n skipFrames: 99,\n skipTime: 4000,\n modelPath: 'liveness.json',\n },\n },\n body: {\n enabled: true,\n modelPath: 'movenet-lightning.json',\n maxDetected: -1,\n minConfidence: 0.3,\n skipFrames: 1,\n skipTime: 200,\n },\n hand: {\n enabled: true,\n rotation: true,\n skipFrames: 99,\n skipTime: 1000,\n minConfidence: 0.50,\n iouThreshold: 0.2,\n maxDetected: -1,\n landmarks: true,\n detector: {\n modelPath: 'handtrack.json',\n },\n skeleton: {\n modelPath: 'handlandmark-full.json',\n },\n },\n object: {\n enabled: false,\n modelPath: 'mb3-centernet.json',\n minConfidence: 0.2,\n iouThreshold: 0.4,\n maxDetected: 10,\n skipFrames: 99,\n skipTime: 2000,\n },\n segmentation: {\n enabled: false,\n modelPath: 'selfie.json',\n blur: 8,\n },\n};\n\nexport { config as defaults };\n", "/*\n Human\n homepage: \n author: '\n*/\n\nvar jT=Object.create,Kd=Object.defineProperty,KT=Object.getOwnPropertyDescriptor,Qw=Object.getOwnPropertyNames,XT=Object.getPrototypeOf,YT=Object.prototype.hasOwnProperty,QT=e=>Kd(e,\"__esModule\",{value:!0}),Mt=(e,t)=>function(){return t||(0,e[Qw(e)[0]])((t={exports:{}}).exports,t),t.exports},Ee=(e,t)=>{for(var n in t)Kd(e,n,{get:t[n],enumerable:!0})},ZT=(e,t,n,s)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let r of Qw(t))!YT.call(e,r)&&(n||r!==\"default\")&&Kd(e,r,{get:()=>t[r],enumerable:!(s=KT(t,r))||s.enumerable});return e},wa=(e,t)=>ZT(QT(Kd(e!=null?jT(XT(e)):{},\"default\",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),JT=Mt({\"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(O){}function s(O,T,z){this.low=O|0,this.high=T|0,this.unsigned=!!z}s.prototype.__isLong__,Object.defineProperty(s.prototype,\"__isLong__\",{value:!0});function r(O){return(O&&O.__isLong__)===!0}s.isLong=r;var a={},i={};function o(O,T){var z,W,q;return T?(O>>>=0,(q=0<=O&&O<256)&&(W=i[O],W)?W:(z=l(O,(O|0)<0?-1:0,!0),q&&(i[O]=z),z)):(O|=0,(q=-128<=O&&O<128)&&(W=a[O],W)?W:(z=l(O,O<0?-1:0,!1),q&&(a[O]=z),z))}s.fromInt=o;function u(O,T){if(isNaN(O))return T?x:v;if(T){if(O<0)return x;if(O>=g)return E}else{if(O<=-b)return P;if(O+1>=b)return R}return O<0?u(-O,T).neg():l(O%m|0,O/m|0,T)}s.fromNumber=u;function l(O,T,z){return new s(O,T,z)}s.fromBits=l;var c=Math.pow;function p(O,T,z){if(O.length===0)throw Error(\"empty string\");if(O===\"NaN\"||O===\"Infinity\"||O===\"+Infinity\"||O===\"-Infinity\")return v;if(typeof T==\"number\"?(z=T,T=!1):T=!!T,z=z||10,z<2||360)throw Error(\"interior hyphen\");if(W===0)return p(O.substring(1),T,z).neg();for(var q=u(c(z,8)),X=v,Y=0;Y>>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>>0,se=J.toString(T);if(Y=te,Y.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,z=31;z>0&&(T&1<=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?!1: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 z=this.isNegative(),W=T.isNegative();return z&&!W?-1:!z&&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 z=this.high>>>16,W=this.high&65535,q=this.low>>>16,X=this.low&65535,Y=T.high>>>16,Z=T.high&65535,te=T.low>>>16,J=T.low&65535,se=0,ne=0,oe=0,ae=0;return ae+=X+J,oe+=ae>>>16,ae&=65535,oe+=q+te,ne+=oe>>>16,oe&=65535,ne+=W+Z,se+=ne>>>16,ne&=65535,se+=z+Y,se&=65535,l(oe<<16|ae,se<<16|ne,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 z=n.mul(this.low,this.high,T.low,T.high);return l(z,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,q=this.high&65535,X=this.low>>>16,Y=this.low&65535,Z=T.high>>>16,te=T.high&65535,J=T.low>>>16,se=T.low&65535,ne=0,oe=0,ae=0,de=0;return de+=Y*se,ae+=de>>>16,de&=65535,ae+=X*se,oe+=ae>>>16,ae&=65535,ae+=Y*J,oe+=ae>>>16,ae&=65535,oe+=q*se,ne+=oe>>>16,oe&=65535,oe+=X*J,ne+=oe>>>16,oe&=65535,oe+=Y*te,ne+=oe>>>16,oe&=65535,ne+=W*se+q*J+X*te+Y*Z,ne&=65535,l(ae<<16|de,ne<<16|oe,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 z=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,T.low,T.high);return l(z,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?x:v;var W,q,X;if(this.unsigned){if(T.unsigned||(T=T.toUnsigned()),T.gt(this))return x;if(T.gt(this.shru(1)))return I;X=x}else{if(this.eq(P)){if(T.eq(k)||T.eq($))return P;if(T.eq(P))return k;var Y=this.shr(1);return W=Y.div(T).shl(1),W.eq(v)?T.isNegative()?k:$:(q=this.sub(T.mul(W)),X=W.add(q.div(T)),X)}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();X=v}for(q=this;q.gte(T);){W=Math.max(1,Math.floor(q.toNumber()/T.toNumber()));for(var Z=Math.ceil(Math.log(W)/Math.LN2),te=Z<=48?1:c(2,Z-48),J=u(W),se=J.mul(T);se.isNegative()||se.gt(q);)W-=te,J=u(W,this.unsigned),se=J.mul(T);J.isZero()&&(J=k),X=X.add(J),q=q.sub(se)}return X},A.div=A.divide,A.modulo=function(T){if(r(T)||(T=d(T)),n){var z=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,T.low,T.high);return l(z,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<>>32-T,this.unsigned):l(0,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 z=this.high;if(T<32){var W=this.low;return l(W>>>T|z<<32-T,z>>>T,this.unsigned)}else return T===32?l(z,0,this.unsigned):l(z>>>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,!1):this},A.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},A.toBytes=function(T){return T?this.toBytesLE():this.toBytesBE()},A.toBytesLE=function(){var T=this.high,z=this.low;return[z&255,z>>>8&255,z>>>16&255,z>>>24,T&255,T>>>8&255,T>>>16&255,T>>>24]},A.toBytesBE=function(){var T=this.high,z=this.low;return[T>>>24,T>>>16&255,T>>>8&255,T&255,z>>>24,z>>>16&255,z>>>8&255,z&255]},s.fromBytes=function(T,z,W){return W?s.fromBytesLE(T,z):s.fromBytesBE(T,z)},s.fromBytesLE=function(T,z){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,z)},s.fromBytesBE=function(T,z){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],z)}}}),e$=Mt({\"(disabled):src/node_modules/node-fetch/browser.js\"(){}}),t$=Mt({\"(disabled):util\"(){}}),n$=Mt({\"src/node_modules/seedrandom/lib/alea.js\"(e,t){(function(n,s,r){function a(l){var c=this,p=u();c.next=function(){var d=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=d-(c.c=d|0)},c.c=1,c.s0=p(\" \"),c.s1=p(\" \"),c.s2=p(\" \"),c.s0-=p(l),c.s0<0&&(c.s0+=1),c.s1-=p(l),c.s1<0&&(c.s1+=1),c.s2-=p(l),c.s2<0&&(c.s2+=1),p=null}function i(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var p=new a(l),d=c&&c.state,h=p.next;return h.int32=function(){return p.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d==\"object\"&&i(d,p),h.state=function(){return i(p,{})}),h}function u(){var l=4022871197,c=function(p){p=String(p);for(var d=0;d>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),s$=Mt({\"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>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p==\"object\"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),r$=Mt({\"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>>4),l.next()}function i(u,l){return l.x=u.x,l.y=u.y,l.z=u.z,l.w=u.w,l.v=u.v,l.d=u.d,l}function o(u,l){var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p==\"object\"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),a$=Mt({\"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;h0;--h)p.next()}c(l,u)}function i(u,l){return l.x=u.x.slice(),l.i=u.i,l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.x&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),i$=Mt({\"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>>15,f^=f<<4,f^=f>>>13,g>=0&&(b=b+1640531527|0,h=y[g&127]^=f+b,m=h==0?m+1:0);for(m>=128&&(y[(d&&d.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=y[m+34&127],h=y[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,y[m]=f^h;p.w=b,p.X=y,p.i=m}c(l,u)}function i(u,l){return l.i=u.i,l.w=u.w,l.X=u.X.slice(),l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.X&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),o$=Mt({\"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>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p==\"object\"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),u$=Mt({\"(disabled):crypto\"(){}}),l$=Mt({\"src/node_modules/seedrandom/seedrandom.js\"(e,t){(function(n,s,r){var a=256,i=6,o=52,u=\"random\",l=r.pow(a,i),c=r.pow(2,o),p=c*2,d=a-1,h;function f(k,I,$){var R=[];I=I==!0?{entropy:!0}:I||{};var E=y(b(I.entropy?[k,x(s)]:k==null?v():k,3),R),P=new m(R),A=function(){for(var O=P.g(i),T=l,z=0;O=p;)O/=2,T/=2,z>>>=1;return(O+z)/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(O,T,z,W){return W&&(W.S&&g(W,P),O.state=function(){return g(P,{})}),z?(r[u]=O,T):O})(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{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),uc}function i(){return Ce.buffer!=nn&&rs(Ce.buffer),lc}function o(){return Ce.buffer!=nn&&rs(Ce.buffer),bu}function u(){return Ce.buffer!=nn&&rs(Ce.buffer),cc}function l(){return Ce.buffer!=nn&&rs(Ce.buffer),dc}function c(){return Ce.buffer!=nn&&rs(Ce.buffer),pc}function p(){return Ce.buffer!=nn&&rs(Ce.buffer),hc}var d=typeof r!=\"undefined\"?r:{},h,f;d.ready=new Promise(function(N,D){h=N,f=D});var m;typeof process!=\"undefined\"&&process.listeners&&(m={uncaughtException:process.listeners(\"uncaughtException\"),unhandledRejection:process.listeners(\"unhandledRejection\")});var g=Object.assign({},d),b=[],y=\"./this.program\",v=(N,D)=>{throw D},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||!1,R=\"\";function E(N){return d.locateFile?d.locateFile(N,R):R+N}var P,A,O,T;function z(N){if(N instanceof Nu)return;J(\"exiting due to exception: \"+N)}var W,q,X;if(I){k?R=md().dirname(R)+\"/\":R=__dirname+\"/\",X=()=>{q||(W=og(),q=md())},P=function(B,Q){return X(),B=q.normalize(B),W.readFileSync(B,Q?void 0:\"utf8\")},O=D=>{var B=P(D,!0);return B.buffer||(B=new Uint8Array(B)),B},A=(D,B,Q)=>{X(),D=q.normalize(D),W.readFile(D,function(ue,pe){ue?Q(ue):B(pe.buffer)})},process.argv.length>1&&(y=process.argv[1].replace(/\\\\/g,\"/\")),b=process.argv.slice(2),process.on(\"uncaughtException\",function(D){if(!(D instanceof Nu))throw D}),process.on(\"unhandledRejection\",function(D){throw D}),v=(D,B)=>{if(zr())throw process.exitCode=D,B;z(B),process.exit(D)},d.inspect=function(){return\"[Emscripten Module object]\"};let N;try{N=c$()}catch(D){throw console.error('The \"worker_threads\" module is not supported in this node.js build - perhaps a newer version is needed?'),D}global.Worker=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 D=new XMLHttpRequest;return D.open(\"GET\",N,!1),D.send(null),D.responseText},k&&(O=N=>{var D=new XMLHttpRequest;return D.open(\"GET\",N,!1),D.responseType=\"arraybuffer\",D.send(null),new Uint8Array(D.response)}),A=(N,D,B)=>{var Q=new XMLHttpRequest;Q.open(\"GET\",N,!0),Q.responseType=\"arraybuffer\",Q.onload=()=>{if(Q.status==200||Q.status==0&&Q.response){D(Q.response);return}B()},Q.onerror=B,Q.send(null)}),T=N=>document.title=N);I&&typeof performance==\"undefined\"&&(global.performance=d$().performance);var Y=console.log.bind(console),Z=console.warn.bind(console);I&&(X(),Y=N=>W.writeSync(1,N+`\n`),Z=N=>W.writeSync(2,N+`\n`));var te=d.print||Y,J=d.printErr||Z;Object.assign(d,g),g=null,d.arguments&&(b=d.arguments),d.thisProgram&&(y=d.thisProgram),d.quit&&(v=d.quit);var se=4;function ne(N){ne.shown||(ne.shown={}),ne.shown[N]||(ne.shown[N]=1,J(N))}function oe(N,D){if(typeof WebAssembly.Function==\"function\"){for(var B={i:\"i32\",j:\"i64\",f:\"f32\",d:\"f64\"},Q={parameters:[],results:D[0]==\"v\"?[]:[B[D[0]]]},ue=1;ue{Ie=N},Pe=Atomics.load,Xe=Atomics.store,Je=Atomics.compareExchange,Ye;d.wasmBinary&&(Ye=d.wasmBinary);var tt=d.noExitRuntime||!0;typeof WebAssembly!=\"object\"&&$i(\"no native wasm support detected\");var Ce,ut,at=!1,Jt;function Nt(N,D){N||$i(D)}function In(N){var D=d[\"_\"+N];return D}function Rt(N,D,B,Q,ue){var pe={string:function(Tn){var Mi=0;if(Tn!=null&&Tn!==0){var ox=(Tn.length<<2)+1;Mi=zi(ox),Ms(Tn,Mi,ox)}return Mi},array:function(Tn){var Mi=zi(Tn.length);return Ls(Tn,Mi),Mi}};function ye(Tn){return D===\"string\"?tn(Tn):D===\"boolean\"?Boolean(Tn):Tn}var Te=In(N),bt=[],us=0;if(Q)for(var ls=0;ls(B.buffer instanceof SharedArrayBuffer&&(B=new Uint8Array(B)),D.decode.call(D,B))}var Yt=typeof TextDecoder!=\"undefined\"?new Nn(\"utf8\"):void 0;function Dn(N,D,B){for(var Q=D+B,ue=D;N[ue]&&!(ue>=Q);)++ue;if(ue-D>16&&N.subarray&&Yt)return Yt.decode(N.subarray(D,ue));for(var pe=\"\";D>10,56320|us&1023)}}return pe}function tn(N,D){return N?Dn(i(),N,D):\"\"}function zs(N,D,B,Q){if(!(Q>0))return 0;for(var ue=B,pe=B+Q-1,ye=0;ye=55296&&Te<=57343){var bt=N.charCodeAt(++ye);Te=65536+((Te&1023)<<10)|bt&1023}if(Te<=127){if(B>=pe)break;D[B++]=Te}else if(Te<=2047){if(B+1>=pe)break;D[B++]=192|Te>>6,D[B++]=128|Te&63}else if(Te<=65535){if(B+2>=pe)break;D[B++]=224|Te>>12,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}else{if(B+3>=pe)break;D[B++]=240|Te>>18,D[B++]=128|Te>>12&63,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}}return D[B]=0,B-ue}function Ms(N,D,B){return zs(N,i(),D,B)}function Ci(N){for(var D=0,B=0;B=55296&&Q<=57343&&(Q=65536+((Q&1023)<<10)|N.charCodeAt(++B)&1023),Q<=127?++D:Q<=2047?D+=2:Q<=65535?D+=3:D+=4}return D}var Zs=typeof TextDecoder!=\"undefined\"?new Nn(\"utf-16le\"):void 0;function Ls(N,D){a().set(N,D)}function gu(N,D,B){for(var Q=0;Q>0]=N.charCodeAt(Q);B||(a()[D>>0]=0)}function Ni(N,D){return N%D>0&&(N+=D-N%D),N}var nn,uc,lc,bu,cc,dc,Vv,pc,hc;$&&(nn=d.buffer);function rs(N){nn=N,d.HEAP8=uc=new Int8Array(N),d.HEAP16=bu=new Int16Array(N),d.HEAP32=dc=new Int32Array(N),d.HEAPU8=lc=new Uint8Array(N),d.HEAPU16=cc=new Uint16Array(N),d.HEAPU32=Vv=new Uint32Array(N),d.HEAPF32=pc=new Float32Array(N),d.HEAPF64=hc=new Float64Array(N)}var fc=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:fc/65536,maximum:32768,shared:!0}),!(Ce.buffer instanceof SharedArrayBuffer))throw J(\"requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag\"),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),fc=nn.byteLength,rs(nn);var Fn,Ti=[],Js=[],uh=[],mc=[],Pr=!1,lh=!1,gc=0;function zr(){return tt||gc>0}function sn(){if(d.preRun)for(typeof d.preRun==\"function\"&&(d.preRun=[d.preRun]);d.preRun.length;)Wv(d.preRun.shift());wc(Ti)}function yu(){Pr=!0,!$&&wc(Js)}function ch(){$||($e.terminateAllThreads(),lh=!0)}function dh(){if(!$){if(d.postRun)for(typeof d.postRun==\"function\"&&(d.postRun=[d.postRun]);d.postRun.length;)vu(d.postRun.shift());wc(mc)}}function Wv(N){Ti.unshift(N)}function Uv(N){Js.unshift(N)}function vu(N){mc.unshift(N)}var er=0,bc=null,as=null;function xu(N){er++,d.monitorRunDependencies&&d.monitorRunDependencies(er)}function Gv(N){if(er--,d.monitorRunDependencies&&d.monitorRunDependencies(er),er==0&&(bc!==null&&(clearInterval(bc),bc=null),as)){var D=as;as=null,D()}}d.preloadedImages={},d.preloadedAudios={};function $i(N){$?postMessage({cmd:\"onAbort\",arg:N}):d.onAbort&&d.onAbort(N),N=\"Aborted(\"+N+\")\",J(N),at=!0,Jt=1,N+=\". Build with -s ASSERTIONS=1 for more info.\";var D=new WebAssembly.RuntimeError(N);throw f(D),D}var ph=\"data:application/octet-stream;base64,\";function yc(N){return N.startsWith(ph)}function vc(N){return N.startsWith(\"file://\")}var rn;rn=\"tfjs-backend-wasm-threaded-simd.wasm\",yc(rn)||(rn=E(rn));function xc(N){try{if(N==rn&&Ye)return new Uint8Array(Ye);if(O)return O(N);throw\"both async and sync fetching of the wasm failed\"}catch(D){$i(D)}}function _i(){if(!Ye&&(x||k)){if(typeof fetch==\"function\"&&!vc(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 xc(rn)});if(A)return new Promise(function(N,D){A(rn,function(B){N(new Uint8Array(B))},D)})}return Promise.resolve().then(function(){return xc(rn)})}function hh(){var N={env:Dc,wasi_snapshot_preview1:Dc};function D(ye,Te){var bt=ye.exports;if(d.asm=bt,xh(d.asm.emscripten_tls_init),Fn=d.asm.__indirect_function_table,Uv(d.asm.__wasm_call_ctors),ut=Te,!$){var us=$e.unusedWorkers.length;$e.unusedWorkers.forEach(function(ls){$e.loadWasmModuleToWorker(ls,function(){--us||Gv(\"wasm-instantiate\")})})}}$||xu(\"wasm-instantiate\");function B(ye){D(ye.instance,ye.module)}function Q(ye){return _i().then(function(Te){return WebAssembly.instantiate(Te,N)}).then(function(Te){return Te}).then(ye,function(Te){J(\"failed to asynchronously prepare wasm: \"+Te),$i(Te)})}function ue(){return!Ye&&typeof WebAssembly.instantiateStreaming==\"function\"&&!yc(rn)&&!vc(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 J(\"wasm streaming compile failed: \"+bt),J(\"falling back to ArrayBuffer instantiation\"),Q(B)})}):Q(B)}if(d.instantiateWasm)try{var pe=d.instantiateWasm(N,D);return pe}catch(ye){return J(\"Module.instantiateWasm callback failed with error: \"+ye),!1}return ue().catch(f),{}}var Hv,qv,fh={};function wc(N){for(;N.length>0;){var D=N.shift();if(typeof D==\"function\"){D(d);continue}var B=D.func;typeof B==\"number\"?D.arg===void 0?Ei(B)():Ei(B)(D.arg):B(D.arg===void 0?null:D.arg)}}function Ai(N){var D=Mf(),B=N();return Mc(D),B}function eT(N){return N}function jv(N){var D=/\\b_Z[\\w\\d_]+/g;return N.replace(D,function(B){var Q=B;return B===Q?B:Q+\" [\"+B+\"]\"})}function mh(N){l()[N>>2]=0;var D=$e.pthreads[N];delete $e.pthreads[N],D.worker.terminate(),zf(N),$e.runningWorkers.splice($e.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function gh(N){var D=$e.pthreads[N];D.worker.postMessage({cmd:\"cancel\"})}function kc(N){var D=$e.pthreads[N];if(D){l()[N>>2]=0;var B=D.worker;$e.returnWorkerToPool(B)}}function Sc(N){UT(N)}function bh(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,D=0;D>2]=0;try{N()}finally{l()[ix>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in $e.tlsInitFunctions)$e.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,D){N.onmessage=B=>{var Q=B.data,ue=Q.cmd;if(N.pthread&&($e.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),Q.targetThread&&Q.targetThread!=zc()){var pe=$e.pthreads[Q.targetThread];pe?pe.worker.postMessage(Q,Q.transferList):J('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\"?tx():ue===\"spawnThread\"?Cc(Q):ue===\"cleanupThread\"?kc(Q.thread):ue===\"killThread\"?mh(Q.thread):ue===\"cancelThread\"?gh(Q.thread):ue===\"loaded\"?(N.loaded=!0,D&&D(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):ue===\"print\"?te(\"Thread \"+Q.threadId+\": \"+Q.text):ue===\"printErr\"?J(\"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):J(\"worker sent an unknown command \"+ue),$e.currentProxiedOperationCallerThread=void 0},N.onerror=B=>{var Q=\"worker sent an error!\";throw J(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 yh(){var N=zc(),D=l()[N+44>>2],B=l()[N+48>>2],Q=D-B;ax(D,Q),Mc(D)}d.establishStackSpace=yh;function Ic(N){if($)return Br(1,0,N);try{Sc(N)}catch(D){bh(D)}}var Mr=[];function Ei(N){var D=Mr[N];return D||(N>=Mr.length&&(Mr.length=N+1),Mr[N]=D=Fn.get(N)),D}function vh(N,D){return Ei(N)(D)}d.invokeEntryPoint=vh;function Kv(){var N=new Error;if(!N.stack){try{throw new Error}catch(D){N=D}if(!N.stack)return\"(no stack trace available)\"}return N.stack.toString()}function xh(N,D,B){$e.tlsInitFunctions.push(N)}function Xv(N,D){Fn.set(N,D),Mr[N]=D}var Lr;I?Lr=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:$?Lr=()=>performance.now()-d.__performance_now_clock_drift:Lr=()=>performance.now();var wh=!0;function kh(N){return l()[ex()>>2]=N,N}function Sh(N,D){var B;if(N===0)B=Date.now();else if((N===1||N===4)&&wh)B=Lr();else return kh(28),-1;return l()[D>>2]=B/1e3|0,l()[D+4>>2]=B%1e3*1e3*1e3|0,0}function Ih(N,D){return Sh(N,D)}function Ch(N){nx(N,!k,1,!x),$e.threadInit()}function Nh(N){$?postMessage({cmd:\"cleanupThread\",thread:N}):kc(N)}function Cc(N){var D=$e.getNewWorker();if(!D)return 6;$e.runningWorkers.push(D);var B=$e.pthreads[N.pthread_ptr]={worker:D,threadInfoStruct:N.pthread_ptr};D.pthread=B;var Q={cmd:\"run\",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return D.runPthread=()=>{Q.time=performance.now(),D.postMessage(Q,N.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function Th(N,D,B,Q){if(typeof SharedArrayBuffer==\"undefined\")return J(\"Current environment does not support SharedArrayBuffer, pthreads are not available!\"),6;var ue=[],pe=0;if($&&(ue.length===0||pe))return sx(687865856,N,D,B,Q);if(pe)return pe;var ye={startRoutine:B,pthread_ptr:N,arg:Q,transferList:ue};return $?(ye.cmd=\"spawnThread\",postMessage(ye,ue),0):Cc(ye)}function $h(){return 2097152}function _h(N,D){if(N==D)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 Ah(){$i(\"\")}function Eh(){I||k||ne(\"Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread\")}function Nc(){return 2147483648}function Rh(N,D,B){i().copyWithin(N,D,D+B)}function Dh(){return I?p$().cpus().length:navigator.hardwareConcurrency}function Br(N,D){var B=arguments.length-2,Q=arguments;return Ai(function(){for(var ue=B,pe=zi(ue*8),ye=pe>>3,Te=0;Te>3,ue=0;ue>>16),rs(Ce.buffer),1}catch(D){}}function Ph(N){var D=i().length;if(N=N>>>0,N<=D)return!1;var B=Nc();if(N>B)return!1;for(var Q=1;Q<=4;Q*=2){var ue=D*(1+.2/Q);ue=Math.min(ue,N+100663296);var pe=Math.min(B,Ni(Math.max(N,ue),65536)),ye=Oh(pe);if(ye)return!0}return!1}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||(uh.push(Me.removeAllEventListeners),Me.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,D,B){function Q(ye,Te){if(ye.length!=Te.length)return!1;for(var bt in ye)if(ye[bt]!=Te[bt])return!1;return!0}for(var ue in Me.deferredCalls){var pe=Me.deferredCalls[ue];if(pe.targetFunction==N&&Q(pe.argsList,B))return}Me.deferredCalls.push({targetFunction:N,precedence:D,argsList:B}),Me.deferredCalls.sort(function(ye,Te){return ye.precedence>2]=B,l()[pe+4>>2]=Q,l()[pe+8>>2]=ue,Pf(N,637534208,D,Q,pe)})},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 zh(N){var D=Ci(N)+1,B=Of(D);return Ms(N,B,D),B}function Mh(N,D,B,Q){Ai(function(){var ue=zi(12),pe=0;D&&(pe=zh(D)),l()[ue>>2]=pe,l()[ue+4>>2]=B,l()[ue+8>>2]=Q,Pf(N,657457152,0,pe,ue)})}function Lh(N,D,B,Q){D=D?tn(D):\"\",Mh(N,D,B,Q)}function Bh(N){return N>2?tn(N):N}var Vh=[0,typeof document!=\"undefined\"?document:0,typeof window!=\"undefined\"?window:0];function Wh(N){N=Bh(N);var D=Vh[N]||(typeof document!=\"undefined\"?document.querySelector(N):void 0);return D}function ku(N){return Wh(N)}function Tc(N,D,B){var Q=ku(N);if(!Q)return-4;if(Q.canvasSharedPtr&&(l()[Q.canvasSharedPtr>>2]=D,l()[Q.canvasSharedPtr+4>>2]=B),Q.offscreenCanvas||!Q.controlTransferredOffscreen){Q.offscreenCanvas&&(Q=Q.offscreenCanvas);var ue=!1;if(Q.GLctxObject&&Q.GLctxObject.GLctx){var pe=Q.GLctxObject.GLctx.getParameter(2978);ue=pe[0]===0&&pe[1]===0&&pe[2]===Q.width&&pe[3]===Q.height}Q.width=D,Q.height=B,ue&&Q.GLctxObject.GLctx.viewport(0,0,D,B)}else if(Q.canvasSharedPtr){var ye=l()[Q.canvasSharedPtr+8>>2];return Lh(ye,N,D,B),1}else return-4;return 0}function $c(N,D,B){return $?Br(2,1,N,D,B):Tc(N,D,B)}function Uh(N,D,B){var Q=ku(N);return Q?Tc(N,D,B):$c(N,D,B)}function Gh(){throw\"unwind\"}function Hh(N){var D=N.getExtension(\"ANGLE_instanced_arrays\");if(D)return N.vertexAttribDivisor=function(B,Q){D.vertexAttribDivisorANGLE(B,Q)},N.drawArraysInstanced=function(B,Q,ue,pe){D.drawArraysInstancedANGLE(B,Q,ue,pe)},N.drawElementsInstanced=function(B,Q,ue,pe,ye){D.drawElementsInstancedANGLE(B,Q,ue,pe,ye)},1}function qh(N){var D=N.getExtension(\"OES_vertex_array_object\");if(D)return N.createVertexArray=function(){return D.createVertexArrayOES()},N.deleteVertexArray=function(B){D.deleteVertexArrayOES(B)},N.bindVertexArray=function(B){D.bindVertexArrayOES(B)},N.isVertexArray=function(B){return D.isVertexArrayOES(B)},1}function jh(N){var D=N.getExtension(\"WEBGL_draw_buffers\");if(D)return N.drawBuffers=function(B,Q){D.drawBuffersWEBGL(B,Q)},1}function Kh(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(D){gt.lastError||(gt.lastError=D)},getNewId:function(N){for(var D=gt.counter++,B=N.length;B>2]:-1;ue+=tn(l()[B+pe*4>>2],ye<0?void 0:ye)}return ue},createContext:function(N,D){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(ue,pe){var ye=N.getContextSafariWebGL2Fixed(ue,pe);return ue==\"webgl\"==ye instanceof WebGLRenderingContext?ye:null});var B=N.getContext(\"webgl\",D);if(!B)return 0;var Q=gt.registerContext(B,D);return Q},registerContext:function(N,D){var B=Of(8);l()[B+4>>2]=zc();var Q={handle:B,attributes:D,version:D.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=Q),gt.contexts[B]=Q,(typeof D.enableExtensionsByDefault==\"undefined\"||D.enableExtensionsByDefault)&>.initExtensions(Q),B},makeContextCurrent:function(N){return gt.currentContext=gt.contexts[N],d.ctx=Rc=gt.currentContext&>.currentContext.GLctx,!(N&&!Rc)},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]&>.contexts[N].GLctx.canvas&&(gt.contexts[N].GLctx.canvas.GLctxObject=void 0),Jv(gt.contexts[N].handle),gt.contexts[N]=null},initExtensions:function(N){if(N||(N=gt.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var D=N.GLctx;Hh(D),qh(D),jh(D),D.disjointTimerQueryExt=D.getExtension(\"EXT_disjoint_timer_query\"),Kh(D);var B=D.getSupportedExtensions()||[];B.forEach(function(Q){!Q.includes(\"lose_context\")&&!Q.includes(\"debug\")&&D.getExtension(Q)})}}},Xh=[\"default\",\"low-power\",\"high-performance\"];function Yh(N,D){var B=D>>2,Q=l()[B+6],ue={alpha:!!l()[B+0],depth:!!l()[B+1],stencil:!!l()[B+2],antialias:!!l()[B+3],premultipliedAlpha:!!l()[B+4],preserveDrawingBuffer:!!l()[B+5],powerPreference:Xh[Q],failIfMajorPerformanceCaveat:!!l()[B+7],majorVersion:l()[B+8],minorVersion:l()[B+9],enableExtensionsByDefault:l()[B+10],explicitSwapControl:l()[B+11],proxyContextToMainThread:l()[B+12],renderViaOffscreenBackBuffer:l()[B+13]},pe=ku(N);if(!pe||ue.explicitSwapControl)return 0;var ye=gt.createContext(pe,ue);return ye}function Qh(N,D){return Yh(N,D)}var Ri={mappings:{},buffers:[null,[],[]],printChar:function(N,D){var B=Ri.buffers[N];D===0||D===10?((N===1?te:J)(Dn(B,0)),B.length=0):B.push(D)},varargs:void 0,get:function(){Ri.varargs+=4;var N=l()[Ri.varargs-4>>2];return N},getStr:function(N){var D=tn(N);return D},get64:function(N,D){return N}};function _c(N){return $?Br(3,1,N):0}function Ac(N,D,B,Q,ue){if($)return Br(4,1,N,D,B,Q,ue)}function Ec(N,D,B,Q){if($)return Br(5,1,N,D,B,Q);for(var ue=0,pe=0;pe>2],Te=l()[D+4>>2];D+=8;for(var bt=0;bt>2]=ue,0}function Zh(N){Re(N)}$e.init();var Rc,Jh=[null,Ic,$c,_c,Ac,Ec],Yv=!1,Dc={__clock_gettime:Ih,__emscripten_init_main_thread_js:Ch,__emscripten_thread_cleanup:Nh,__pthread_create_js:Th,_emscripten_default_pthread_stack_size:$h,_emscripten_notify_thread_queue:_h,abort:Ah,emscripten_check_blocking_allowed:Eh,emscripten_get_heap_max:Nc,emscripten_get_now:Lr,emscripten_memcpy_big:Rh,emscripten_num_logical_cores:Dh,emscripten_receive_on_main_thread_js:Fh,emscripten_resize_heap:Ph,emscripten_set_canvas_element_size:Uh,emscripten_unwind_to_js_event_loop:Gh,emscripten_webgl_create_context:Qh,exit:Sc,fd_close:_c,fd_seek:Ac,fd_write:Ec,memory:Ce||d.wasmMemory,setTempRet0:Zh},Qv=hh(),ef=d.___wasm_call_ctors=function(){return(ef=d.___wasm_call_ctors=d.asm.__wasm_call_ctors).apply(null,arguments)},tf=d._init=function(){return(tf=d._init=d.asm.init).apply(null,arguments)},nf=d._init_with_threads_count=function(){return(nf=d._init_with_threads_count=d.asm.init_with_threads_count).apply(null,arguments)},sf=d._get_threads_count=function(){return(sf=d._get_threads_count=d.asm.get_threads_count).apply(null,arguments)},rf=d._register_tensor=function(){return(rf=d._register_tensor=d.asm.register_tensor).apply(null,arguments)},af=d._dispose_data=function(){return(af=d._dispose_data=d.asm.dispose_data).apply(null,arguments)},of=d._dispose=function(){return(of=d._dispose=d.asm.dispose).apply(null,arguments)},uf=d._Abs=function(){return(uf=d._Abs=d.asm.Abs).apply(null,arguments)},lf=d._Add=function(){return(lf=d._Add=d.asm.Add).apply(null,arguments)},cf=d._AddN=function(){return(cf=d._AddN=d.asm.AddN).apply(null,arguments)},df=d._All=function(){return(df=d._All=d.asm.All).apply(null,arguments)},pf=d._Any=function(){return(pf=d._Any=d.asm.Any).apply(null,arguments)},hf=d._ArgMax=function(){return(hf=d._ArgMax=d.asm.ArgMax).apply(null,arguments)},ff=d._AvgPool=function(){return(ff=d._AvgPool=d.asm.AvgPool).apply(null,arguments)},mf=d._BatchMatMul=function(){return(mf=d._BatchMatMul=d.asm.BatchMatMul).apply(null,arguments)},gf=d._Ceil=function(){return(gf=d._Ceil=d.asm.Ceil).apply(null,arguments)},bf=d._ClipByValue=function(){return(bf=d._ClipByValue=d.asm.ClipByValue).apply(null,arguments)},yf=d._Conv2D=function(){return(yf=d._Conv2D=d.asm.Conv2D).apply(null,arguments)},vf=d._Conv2DBackpropInput=function(){return(vf=d._Conv2DBackpropInput=d.asm.Conv2DBackpropInput).apply(null,arguments)},xf=d._Cos=function(){return(xf=d._Cos=d.asm.Cos).apply(null,arguments)},wf=d._Cosh=function(){return(wf=d._Cosh=d.asm.Cosh).apply(null,arguments)},kf=d._CropAndResize=function(){return(kf=d._CropAndResize=d.asm.CropAndResize).apply(null,arguments)},Sf=d._Cumprod=function(){return(Sf=d._Cumprod=d.asm.Cumprod).apply(null,arguments)},If=d._Cumsum=function(){return(If=d._Cumsum=d.asm.Cumsum).apply(null,arguments)},Cf=d._DepthToSpace=function(){return(Cf=d._DepthToSpace=d.asm.DepthToSpace).apply(null,arguments)},Nf=d._DepthwiseConv2dNative=function(){return(Nf=d._DepthwiseConv2dNative=d.asm.DepthwiseConv2dNative).apply(null,arguments)},Tf=d._Elu=function(){return(Tf=d._Elu=d.asm.Elu).apply(null,arguments)},$f=d._Equal=function(){return($f=d._Equal=d.asm.Equal).apply(null,arguments)},_f=d._Exp=function(){return(_f=d._Exp=d.asm.Exp).apply(null,arguments)},Af=d._FlipLeftRight=function(){return(Af=d._FlipLeftRight=d.asm.FlipLeftRight).apply(null,arguments)},Fc=d._Floor=function(){return(Fc=d._Floor=d.asm.Floor).apply(null,arguments)},Oc=d._FloorDiv=function(){return(Oc=d._FloorDiv=d.asm.FloorDiv).apply(null,arguments)},Su=d._FusedBatchNorm=function(){return(Su=d._FusedBatchNorm=d.asm.FusedBatchNorm).apply(null,arguments)},Ef=d._FusedConv2D=function(){return(Ef=d._FusedConv2D=d.asm.FusedConv2D).apply(null,arguments)},Rf=d._FusedDepthwiseConv2D=function(){return(Rf=d._FusedDepthwiseConv2D=d.asm.FusedDepthwiseConv2D).apply(null,arguments)},Di=d._Gather=function(){return(Di=d._Gather=d.asm.Gather).apply(null,arguments)},Iu=d._GatherNd=function(){return(Iu=d._GatherNd=d.asm.GatherNd).apply(null,arguments)},Cu=d._Greater=function(){return(Cu=d._Greater=d.asm.Greater).apply(null,arguments)},Zv=d._GreaterEqual=function(){return(Zv=d._GreaterEqual=d.asm.GreaterEqual).apply(null,arguments)},Fi=d._LeakyRelu=function(){return(Fi=d._LeakyRelu=d.asm.LeakyRelu).apply(null,arguments)},Oi=d._Less=function(){return(Oi=d._Less=d.asm.Less).apply(null,arguments)},Df=d._LessEqual=function(){return(Df=d._LessEqual=d.asm.LessEqual).apply(null,arguments)},H=d._Log=function(){return(H=d._Log=d.asm.Log).apply(null,arguments)},ee=d._LogicalAnd=function(){return(ee=d._LogicalAnd=d.asm.LogicalAnd).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)},Le=d._Min=function(){return(Le=d._Min=d.asm.Min).apply(null,arguments)},ze=d._Minimum=function(){return(ze=d._Minimum=d.asm.Minimum).apply(null,arguments)},Tt=d._MirrorPad=function(){return(Tt=d._MirrorPad=d.asm.MirrorPad).apply(null,arguments)},is=d._Multiply=function(){return(is=d._Multiply=d.asm.Multiply).apply(null,arguments)},os=d._Neg=function(){return(os=d._Neg=d.asm.Neg).apply(null,arguments)},Pi=d._NonMaxSuppressionV3=function(){return(Pi=d._NonMaxSuppressionV3=d.asm.NonMaxSuppressionV3).apply(null,arguments)},Vr=d._NonMaxSuppressionV4=function(){return(Vr=d._NonMaxSuppressionV4=d.asm.NonMaxSuppressionV4).apply(null,arguments)},Ff=d._NonMaxSuppressionV5=function(){return(Ff=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)},Pc=d._PadV2=function(){return(Pc=d._PadV2=d.asm.PadV2).apply(null,arguments)},tT=d._Pow=function(){return(tT=d._Pow=d.asm.Pow).apply(null,arguments)},nT=d._Prelu=function(){return(nT=d._Prelu=d.asm.Prelu).apply(null,arguments)},sT=d._Prod=function(){return(sT=d._Prod=d.asm.Prod).apply(null,arguments)},rT=d._RealDiv=function(){return(rT=d._RealDiv=d.asm.RealDiv).apply(null,arguments)},aT=d._Relu=function(){return(aT=d._Relu=d.asm.Relu).apply(null,arguments)},iT=d._Relu6=function(){return(iT=d._Relu6=d.asm.Relu6).apply(null,arguments)},oT=d._ResizeBilinear=function(){return(oT=d._ResizeBilinear=d.asm.ResizeBilinear).apply(null,arguments)},uT=d._Reverse=function(){return(uT=d._Reverse=d.asm.Reverse).apply(null,arguments)},lT=d._RotateWithOffset=function(){return(lT=d._RotateWithOffset=d.asm.RotateWithOffset).apply(null,arguments)},cT=d._Round=function(){return(cT=d._Round=d.asm.Round).apply(null,arguments)},dT=d._Rsqrt=function(){return(dT=d._Rsqrt=d.asm.Rsqrt).apply(null,arguments)},pT=d._ScatterNd=function(){return(pT=d._ScatterNd=d.asm.ScatterNd).apply(null,arguments)},hT=d._SelectV2=function(){return(hT=d._SelectV2=d.asm.SelectV2).apply(null,arguments)},fT=d._Sigmoid=function(){return(fT=d._Sigmoid=d.asm.Sigmoid).apply(null,arguments)},mT=d._Sin=function(){return(mT=d._Sin=d.asm.Sin).apply(null,arguments)},gT=d._Softmax=function(){return(gT=d._Softmax=d.asm.Softmax).apply(null,arguments)},bT=d._SparseFillEmptyRows=function(){return(bT=d._SparseFillEmptyRows=d.asm.SparseFillEmptyRows).apply(null,arguments)},yT=d._SparseReshape=function(){return(yT=d._SparseReshape=d.asm.SparseReshape).apply(null,arguments)},vT=d._SparseSegmentReduction=function(){return(vT=d._SparseSegmentReduction=d.asm.SparseSegmentReduction).apply(null,arguments)},xT=d._Sqrt=function(){return(xT=d._Sqrt=d.asm.Sqrt).apply(null,arguments)},wT=d._Square=function(){return(wT=d._Square=d.asm.Square).apply(null,arguments)},kT=d._SquaredDifference=function(){return(kT=d._SquaredDifference=d.asm.SquaredDifference).apply(null,arguments)},ST=d._Step=function(){return(ST=d._Step=d.asm.Step).apply(null,arguments)},IT=d._StridedSlice=function(){return(IT=d._StridedSlice=d.asm.StridedSlice).apply(null,arguments)},CT=d._Sub=function(){return(CT=d._Sub=d.asm.Sub).apply(null,arguments)},NT=d._Sum=function(){return(NT=d._Sum=d.asm.Sum).apply(null,arguments)},TT=d._Tan=function(){return(TT=d._Tan=d.asm.Tan).apply(null,arguments)},$T=d._Tanh=function(){return($T=d._Tanh=d.asm.Tanh).apply(null,arguments)},_T=d._Tile=function(){return(_T=d._Tile=d.asm.Tile).apply(null,arguments)},AT=d._TopK=function(){return(AT=d._TopK=d.asm.TopK).apply(null,arguments)},ET=d._Transform=function(){return(ET=d._Transform=d.asm.Transform).apply(null,arguments)},RT=d._Transpose=function(){return(RT=d._Transpose=d.asm.Transpose).apply(null,arguments)},DT=d.__FusedMatMul=function(){return(DT=d.__FusedMatMul=d.asm._FusedMatMul).apply(null,arguments)},Of=d._malloc=function(){return(Of=d._malloc=d.asm.malloc).apply(null,arguments)},Jv=d._free=function(){return(Jv=d._free=d.asm.free).apply(null,arguments)},FT=d._emscripten_tls_init=function(){return(FT=d._emscripten_tls_init=d.asm.emscripten_tls_init).apply(null,arguments)},ex=d.___errno_location=function(){return(ex=d.___errno_location=d.asm.__errno_location).apply(null,arguments)},zc=d._pthread_self=function(){return(zc=d._pthread_self=d.asm.pthread_self).apply(null,arguments)},tx=d._emscripten_main_thread_process_queued_calls=function(){return(tx=d._emscripten_main_thread_process_queued_calls=d.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},OT=d.__emscripten_thread_crashed=function(){return(OT=d.__emscripten_thread_crashed=d.asm._emscripten_thread_crashed).apply(null,arguments)},nx=d.__emscripten_thread_init=function(){return(nx=d.__emscripten_thread_init=d.asm._emscripten_thread_init).apply(null,arguments)},PT=d._emscripten_current_thread_process_queued_calls=function(){return(PT=d._emscripten_current_thread_process_queued_calls=d.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},zT=d._emscripten_main_browser_thread_id=function(){return(zT=d._emscripten_main_browser_thread_id=d.asm.emscripten_main_browser_thread_id).apply(null,arguments)},MT=d._emscripten_sync_run_in_main_thread_2=function(){return(MT=d._emscripten_sync_run_in_main_thread_2=d.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},sx=d._emscripten_sync_run_in_main_thread_4=function(){return(sx=d._emscripten_sync_run_in_main_thread_4=d.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},rx=d._emscripten_run_in_main_runtime_thread_js=function(){return(rx=d._emscripten_run_in_main_runtime_thread_js=d.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},Pf=d._emscripten_dispatch_to_thread_=function(){return(Pf=d._emscripten_dispatch_to_thread_=d.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},zf=d.__emscripten_thread_free_data=function(){return(zf=d.__emscripten_thread_free_data=d.asm._emscripten_thread_free_data).apply(null,arguments)},LT=d.__emscripten_thread_exit=function(){return(LT=d.__emscripten_thread_exit=d.asm._emscripten_thread_exit).apply(null,arguments)},BT=d._memalign=function(){return(BT=d._memalign=d.asm.memalign).apply(null,arguments)},ax=d._emscripten_stack_set_limits=function(){return(ax=d._emscripten_stack_set_limits=d.asm.emscripten_stack_set_limits).apply(null,arguments)},Mf=d.stackSave=function(){return(Mf=d.stackSave=d.asm.stackSave).apply(null,arguments)},Mc=d.stackRestore=function(){return(Mc=d.stackRestore=d.asm.stackRestore).apply(null,arguments)},zi=d.stackAlloc=function(){return(zi=d.stackAlloc=d.asm.stackAlloc).apply(null,arguments)},VT=d.dynCall_iijjiiii=function(){return(VT=d.dynCall_iijjiiii=d.asm.dynCall_iijjiiii).apply(null,arguments)},WT=d.dynCall_jiji=function(){return(WT=d.dynCall_jiji=d.asm.dynCall_jiji).apply(null,arguments)},ix=d.__emscripten_allow_main_runtime_queued_calls=21456;d.cwrap=en,d.keepRuntimeAlive=zr,d.PThread=$e,d.PThread=$e,d.wasmMemory=Ce,d.ExitStatus=Nu;var Lc;function Nu(N){this.name=\"ExitStatus\",this.message=\"Program terminated with exit(\"+N+\")\",this.status=N}as=function N(){Lc||Lf(),Lc||(as=N)};function Lf(N){if(N=N||b,er>0)return;if($){h(d),yu(),postMessage({cmd:\"loaded\"});return}if(sn(),er>0)return;function D(){Lc||(Lc=!0,d.calledRun=!0,!at&&(yu(),h(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),dh()))}d.setStatus?(d.setStatus(\"Running...\"),setTimeout(function(){setTimeout(function(){d.setStatus(\"\")},1),D()},1)):D()}d.run=Lf;function UT(N,D){if(Jt=N,!D&&$)throw Ic(N),\"unwind\";zr()||ch(),GT(N)}function GT(N){Jt=N,zr()||($e.terminateAllThreads(),d.onExit&&d.onExit(N),at=!0),v(N,new Nu(N))}if(d.preInit)for(typeof d.preInit==\"function\"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.pop()();Lf();var Bc;m&&(Bc={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 Vc;if(typeof WasmBackendModule!=\"undefined\")Vc=WasmBackendModule;else if(typeof r!=\"undefined\")Vc=r;else throw new Error(\"Could not find wasm module in post.js\");if(Bc){var HT=Vc._dispose;Vc._dispose=function(){HT(),Bc.uncaughtException.forEach(function(N){process.removeListener(\"uncaughtException\",N)}),Bc.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)}}),f$=Mt({\"src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js\"(e,t){var n=(()=>{var s=typeof document!=\"undefined\"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!=\"undefined\"&&(s=s||__filename),function(r){r=r||{};var a=typeof r!=\"undefined\"?r:{},i,o;a.ready=new Promise(function(H,ee){i=H,o=ee});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,ee)=>{throw ee},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=md().dirname(g)+\"/\":g=__dirname+\"/\",E=()=>{R||($=og(),R=md())},y=function(ee,ce){return E(),ee=R.normalize(ee),$.readFileSync(ee,ce?void 0:\"utf8\")},x=H=>{var ee=y(H,!0);return ee.buffer||(ee=new Uint8Array(ee)),ee},v=(H,ee,ce)=>{E(),H=R.normalize(H),$.readFile(H,function(Se,Qe){Se?ce(Se):ee(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,ee)=>{if(bu())throw process.exitCode=H,ee;I(ee),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 ee=new XMLHttpRequest;return ee.open(\"GET\",H,!1),ee.send(null),ee.responseText},f&&(x=H=>{var ee=new XMLHttpRequest;return ee.open(\"GET\",H,!1),ee.responseType=\"arraybuffer\",ee.send(null),new Uint8Array(ee.response)}),v=(H,ee,ce)=>{var Se=new XMLHttpRequest;Se.open(\"GET\",H,!0),Se.responseType=\"arraybuffer\",Se.onload=()=>{if(Se.status==200||Se.status==0&&Se.response){ee(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 O=4;function T(H){T.shown||(T.shown={}),T.shown[H]||(T.shown[H]=1,A(H))}function z(H,ee){if(typeof WebAssembly.Function==\"function\"){for(var ce={i:\"i32\",j:\"i64\",f:\"f32\",d:\"f64\"},Se={parameters:[],results:ee[0]==\"v\"?[]:[ce[ee[0]]]},Qe=1;Qe{Z=H},J;a.wasmBinary&&(J=a.wasmBinary);var se=a.noExitRuntime||!0;typeof WebAssembly!=\"object\"&&Pr(\"no native wasm support detected\");var ne,oe=!1,ae;function de(H,ee){H||Pr(ee)}function me(H){var ee=a[\"_\"+H];return ee}function ke(H,ee,ce,Se,Qe){var Ze={string:function(an){var tr=0;if(an!=null&&an!==0){var Pc=(an.length<<2)+1;tr=Su(Pc),tt(an,tr,Pc)}return tr},array:function(an){var tr=Su(an.length);return at(an,tr),tr}};function Le(an){return ee===\"string\"?Je(an):ee===\"boolean\"?Boolean(an):an}var ze=me(H),Tt=[],is=0;if(Se)for(var os=0;os=Se);)++Qe;if(Qe-ee>16&&H.subarray&&Pe)return Pe.decode(H.subarray(ee,Qe));for(var Ze=\"\";ee>10,56320|is&1023)}}return Ze}function Je(H,ee){return H?Xe(en,H,ee):\"\"}function Ye(H,ee,ce,Se){if(!(Se>0))return 0;for(var Qe=ce,Ze=ce+Se-1,Le=0;Le=55296&&ze<=57343){var Tt=H.charCodeAt(++Le);ze=65536+((ze&1023)<<10)|Tt&1023}if(ze<=127){if(ce>=Ze)break;ee[ce++]=ze}else if(ze<=2047){if(ce+1>=Ze)break;ee[ce++]=192|ze>>6,ee[ce++]=128|ze&63}else if(ze<=65535){if(ce+2>=Ze)break;ee[ce++]=224|ze>>12,ee[ce++]=128|ze>>6&63,ee[ce++]=128|ze&63}else{if(ce+3>=Ze)break;ee[ce++]=240|ze>>18,ee[ce++]=128|ze>>12&63,ee[ce++]=128|ze>>6&63,ee[ce++]=128|ze&63}}return ee[ce]=0,ce-Qe}function tt(H,ee,ce){return Ye(H,en,ee,ce)}function Ce(H){for(var ee=0,ce=0;ce=55296&&Se<=57343&&(Se=65536+((Se&1023)<<10)|H.charCodeAt(++ce)&1023),Se<=127?++ee:Se<=2047?ee+=2:Se<=65535?ee+=3:ee+=4}return ee}var ut=typeof TextDecoder!=\"undefined\"?new TextDecoder(\"utf-16le\"):void 0;function at(H,ee){Rt.set(H,ee)}function Jt(H,ee,ce){for(var Se=0;Se>0]=H.charCodeAt(Se);ce||(Rt[ee>>0]=0)}function Nt(H,ee){return H%ee>0&&(H+=ee-H%ee),H}var In,Rt,en,Cn,Nn,Yt,Dn,tn,zs;function Ms(H){In=H,a.HEAP8=Rt=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 Ci=a.INITIAL_MEMORY||16777216,Zs,Ls=[],gu=[],Ni=[],nn=!1,uc=!1,lc=0;function bu(){return se||lc>0}function cc(){if(a.preRun)for(typeof a.preRun==\"function\"&&(a.preRun=[a.preRun]);a.preRun.length;)hc(a.preRun.shift());vu(Ls)}function dc(){nn=!0,vu(gu)}function Vv(){uc=!0}function pc(){if(a.postRun)for(typeof a.postRun==\"function\"&&(a.postRun=[a.postRun]);a.postRun.length;)fc(a.postRun.shift());vu(Ni)}function hc(H){Ls.unshift(H)}function rs(H){gu.unshift(H)}function fc(H){Ni.unshift(H)}var Fn=0,Ti=null,Js=null;function uh(H){Fn++,a.monitorRunDependencies&&a.monitorRunDependencies(Fn)}function mc(H){if(Fn--,a.monitorRunDependencies&&a.monitorRunDependencies(Fn),Fn==0&&(Ti!==null&&(clearInterval(Ti),Ti=null),Js)){var ee=Js;Js=null,ee()}}a.preloadedImages={},a.preloadedAudios={};function Pr(H){a.onAbort&&a.onAbort(H),H=\"Aborted(\"+H+\")\",A(H),oe=!0,ae=1,H+=\". Build with -s ASSERTIONS=1 for more info.\";var ee=new WebAssembly.RuntimeError(H);throw o(ee),ee}var lh=\"data:application/octet-stream;base64,\";function gc(H){return H.startsWith(lh)}function zr(H){return H.startsWith(\"file://\")}var sn;sn=\"tfjs-backend-wasm.wasm\",gc(sn)||(sn=b(sn));function yu(H){try{if(H==sn&&J)return new Uint8Array(J);if(x)return x(H);throw\"both async and sync fetching of the wasm failed\"}catch(ee){Pr(ee)}}function ch(){if(!J&&(h||f)){if(typeof fetch==\"function\"&&!zr(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,ee){v(sn,function(ce){H(new Uint8Array(ce))},ee)})}return Promise.resolve().then(function(){return yu(sn)})}function dh(){var H={env:Ai,wasi_snapshot_preview1:Ai};function ee(Le,ze){var Tt=Le.exports;a.asm=Tt,ne=a.asm.memory,Ms(ne.buffer),Zs=a.asm.__indirect_function_table,rs(a.asm.__wasm_call_ctors),mc(\"wasm-instantiate\")}uh(\"wasm-instantiate\");function ce(Le){ee(Le.instance)}function Se(Le){return ch().then(function(ze){return WebAssembly.instantiate(ze,H)}).then(function(ze){return ze}).then(Le,function(ze){A(\"failed to asynchronously prepare wasm: \"+ze),Pr(ze)})}function Qe(){return!J&&typeof WebAssembly.instantiateStreaming==\"function\"&&!gc(sn)&&!zr(sn)&&typeof fetch==\"function\"?fetch(sn,{credentials:\"same-origin\"}).then(function(Le){var ze=WebAssembly.instantiateStreaming(Le,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,ee);return Ze}catch(Le){return A(\"Module.instantiateWasm callback failed with error: \"+Le),!1}return Qe().catch(o),{}}var Wv,Uv;function vu(H){for(;H.length>0;){var ee=H.shift();if(typeof ee==\"function\"){ee(a);continue}var ce=ee.func;typeof ce==\"number\"?ee.arg===void 0?xu(ce)():xu(ce)(ee.arg):ce(ee.arg===void 0?null:ee.arg)}}function er(H){return H}function bc(H){var ee=/\\b_Z[\\w\\d_]+/g;return H.replace(ee,function(ce){var Se=ce;return ce===Se?ce:Se+\" [\"+ce+\"]\"})}var as=[];function xu(H){var ee=as[H];return ee||(H>=as.length&&(as.length=H+1),as[H]=ee=Zs.get(H)),ee}function Gv(){var H=new Error;if(!H.stack){try{throw new Error}catch(ee){H=ee}if(!H.stack)return\"(no stack trace available)\"}return H.stack.toString()}function $i(H,ee){Zs.set(H,ee),as[H]=ee}function ph(){Pr(\"\")}function yc(H,ee,ce){en.copyWithin(H,ee,ee+ce)}function vc(){return 2147483648}function rn(H){try{return ne.grow(H-In.byteLength+65535>>>16),Ms(ne.buffer),1}catch(ee){}}function xc(H){var ee=en.length;H=H>>>0;var ce=vc();if(H>ce)return!1;for(var Se=1;Se<=4;Se*=2){var Qe=ee*(1+.2/Se);Qe=Math.min(Qe,H+100663296);var Ze=Math.min(ce,Nt(Math.max(H,Qe),65536)),Le=rn(Ze);if(Le)return!0}return!1}var _i={mappings:{},buffers:[null,[],[]],printChar:function(H,ee){var ce=_i.buffers[H];ee===0||ee===10?((H===1?P:A)(Xe(ce,0)),ce.length=0):ce.push(ee)},varargs:void 0,get:function(){_i.varargs+=4;var H=Yt[_i.varargs-4>>2];return H},getStr:function(H){var ee=Je(H);return ee},get64:function(H,ee){return H}};function hh(H){return 0}function Hv(H,ee,ce,Se,Qe){}function qv(H,ee,ce,Se){for(var Qe=0,Ze=0;Ze>2],ze=Yt[ee+4>>2];ee+=8;for(var Tt=0;Tt>2]=Qe,0}function fh(H){te(H)}var wc=!1,Ai={abort:ph,emscripten_memcpy_big:yc,emscripten_resize_heap:xc,fd_close:hh,fd_seek:Hv,fd_write:qv,setTempRet0:fh},eT=dh(),jv=a.___wasm_call_ctors=function(){return(jv=a.___wasm_call_ctors=a.asm.__wasm_call_ctors).apply(null,arguments)},mh=a._init=function(){return(mh=a._init=a.asm.init).apply(null,arguments)},gh=a._init_with_threads_count=function(){return(gh=a._init_with_threads_count=a.asm.init_with_threads_count).apply(null,arguments)},kc=a._get_threads_count=function(){return(kc=a._get_threads_count=a.asm.get_threads_count).apply(null,arguments)},Sc=a._register_tensor=function(){return(Sc=a._register_tensor=a.asm.register_tensor).apply(null,arguments)},bh=a._dispose_data=function(){return(bh=a._dispose_data=a.asm.dispose_data).apply(null,arguments)},$e=a._dispose=function(){return($e=a._dispose=a.asm.dispose).apply(null,arguments)},yh=a._Abs=function(){return(yh=a._Abs=a.asm.Abs).apply(null,arguments)},Ic=a._Add=function(){return(Ic=a._Add=a.asm.Add).apply(null,arguments)},Mr=a._AddN=function(){return(Mr=a._AddN=a.asm.AddN).apply(null,arguments)},Ei=a._All=function(){return(Ei=a._All=a.asm.All).apply(null,arguments)},vh=a._Any=function(){return(vh=a._Any=a.asm.Any).apply(null,arguments)},Kv=a._ArgMax=function(){return(Kv=a._ArgMax=a.asm.ArgMax).apply(null,arguments)},xh=a._AvgPool=function(){return(xh=a._AvgPool=a.asm.AvgPool).apply(null,arguments)},Xv=a._BatchMatMul=function(){return(Xv=a._BatchMatMul=a.asm.BatchMatMul).apply(null,arguments)},Lr=a._Ceil=function(){return(Lr=a._Ceil=a.asm.Ceil).apply(null,arguments)},wh=a._ClipByValue=function(){return(wh=a._ClipByValue=a.asm.ClipByValue).apply(null,arguments)},kh=a._Conv2D=function(){return(kh=a._Conv2D=a.asm.Conv2D).apply(null,arguments)},Sh=a._Conv2DBackpropInput=function(){return(Sh=a._Conv2DBackpropInput=a.asm.Conv2DBackpropInput).apply(null,arguments)},Ih=a._Cos=function(){return(Ih=a._Cos=a.asm.Cos).apply(null,arguments)},Ch=a._Cosh=function(){return(Ch=a._Cosh=a.asm.Cosh).apply(null,arguments)},Nh=a._CropAndResize=function(){return(Nh=a._CropAndResize=a.asm.CropAndResize).apply(null,arguments)},Cc=a._Cumprod=function(){return(Cc=a._Cumprod=a.asm.Cumprod).apply(null,arguments)},Th=a._Cumsum=function(){return(Th=a._Cumsum=a.asm.Cumsum).apply(null,arguments)},$h=a._DepthToSpace=function(){return($h=a._DepthToSpace=a.asm.DepthToSpace).apply(null,arguments)},_h=a._DepthwiseConv2dNative=function(){return(_h=a._DepthwiseConv2dNative=a.asm.DepthwiseConv2dNative).apply(null,arguments)},Ah=a._Elu=function(){return(Ah=a._Elu=a.asm.Elu).apply(null,arguments)},Eh=a._Equal=function(){return(Eh=a._Equal=a.asm.Equal).apply(null,arguments)},Nc=a._Exp=function(){return(Nc=a._Exp=a.asm.Exp).apply(null,arguments)},Rh=a._FlipLeftRight=function(){return(Rh=a._FlipLeftRight=a.asm.FlipLeftRight).apply(null,arguments)},Dh=a._Floor=function(){return(Dh=a._Floor=a.asm.Floor).apply(null,arguments)},Br=a._FloorDiv=function(){return(Br=a._FloorDiv=a.asm.FloorDiv).apply(null,arguments)},wu=a._FusedBatchNorm=function(){return(wu=a._FusedBatchNorm=a.asm.FusedBatchNorm).apply(null,arguments)},Fh=a._FusedConv2D=function(){return(Fh=a._FusedConv2D=a.asm.FusedConv2D).apply(null,arguments)},Oh=a._FusedDepthwiseConv2D=function(){return(Oh=a._FusedDepthwiseConv2D=a.asm.FusedDepthwiseConv2D).apply(null,arguments)},Ph=a._Gather=function(){return(Ph=a._Gather=a.asm.Gather).apply(null,arguments)},Me=a._GatherNd=function(){return(Me=a._GatherNd=a.asm.GatherNd).apply(null,arguments)},zh=a._Greater=function(){return(zh=a._Greater=a.asm.Greater).apply(null,arguments)},Mh=a._GreaterEqual=function(){return(Mh=a._GreaterEqual=a.asm.GreaterEqual).apply(null,arguments)},Lh=a._LeakyRelu=function(){return(Lh=a._LeakyRelu=a.asm.LeakyRelu).apply(null,arguments)},Bh=a._Less=function(){return(Bh=a._Less=a.asm.Less).apply(null,arguments)},Vh=a._LessEqual=function(){return(Vh=a._LessEqual=a.asm.LessEqual).apply(null,arguments)},Wh=a._Log=function(){return(Wh=a._Log=a.asm.Log).apply(null,arguments)},ku=a._LogicalAnd=function(){return(ku=a._LogicalAnd=a.asm.LogicalAnd).apply(null,arguments)},Tc=a._Max=function(){return(Tc=a._Max=a.asm.Max).apply(null,arguments)},$c=a._MaxPool=function(){return($c=a._MaxPool=a.asm.MaxPool).apply(null,arguments)},Uh=a._Maximum=function(){return(Uh=a._Maximum=a.asm.Maximum).apply(null,arguments)},Gh=a._Mean=function(){return(Gh=a._Mean=a.asm.Mean).apply(null,arguments)},Hh=a._Min=function(){return(Hh=a._Min=a.asm.Min).apply(null,arguments)},qh=a._Minimum=function(){return(qh=a._Minimum=a.asm.Minimum).apply(null,arguments)},jh=a._MirrorPad=function(){return(jh=a._MirrorPad=a.asm.MirrorPad).apply(null,arguments)},Kh=a._Multiply=function(){return(Kh=a._Multiply=a.asm.Multiply).apply(null,arguments)},gt=a._Neg=function(){return(gt=a._Neg=a.asm.Neg).apply(null,arguments)},Xh=a._NonMaxSuppressionV3=function(){return(Xh=a._NonMaxSuppressionV3=a.asm.NonMaxSuppressionV3).apply(null,arguments)},Yh=a._NonMaxSuppressionV4=function(){return(Yh=a._NonMaxSuppressionV4=a.asm.NonMaxSuppressionV4).apply(null,arguments)},Qh=a._NonMaxSuppressionV5=function(){return(Qh=a._NonMaxSuppressionV5=a.asm.NonMaxSuppressionV5).apply(null,arguments)},Ri=a._NotEqual=function(){return(Ri=a._NotEqual=a.asm.NotEqual).apply(null,arguments)},_c=a._OneHot=function(){return(_c=a._OneHot=a.asm.OneHot).apply(null,arguments)},Ac=a._PadV2=function(){return(Ac=a._PadV2=a.asm.PadV2).apply(null,arguments)},Ec=a._Pow=function(){return(Ec=a._Pow=a.asm.Pow).apply(null,arguments)},Zh=a._Prelu=function(){return(Zh=a._Prelu=a.asm.Prelu).apply(null,arguments)},Rc=a._Prod=function(){return(Rc=a._Prod=a.asm.Prod).apply(null,arguments)},Jh=a._RealDiv=function(){return(Jh=a._RealDiv=a.asm.RealDiv).apply(null,arguments)},Yv=a._Relu=function(){return(Yv=a._Relu=a.asm.Relu).apply(null,arguments)},Dc=a._Relu6=function(){return(Dc=a._Relu6=a.asm.Relu6).apply(null,arguments)},Qv=a._ResizeBilinear=function(){return(Qv=a._ResizeBilinear=a.asm.ResizeBilinear).apply(null,arguments)},ef=a._Reverse=function(){return(ef=a._Reverse=a.asm.Reverse).apply(null,arguments)},tf=a._RotateWithOffset=function(){return(tf=a._RotateWithOffset=a.asm.RotateWithOffset).apply(null,arguments)},nf=a._Round=function(){return(nf=a._Round=a.asm.Round).apply(null,arguments)},sf=a._Rsqrt=function(){return(sf=a._Rsqrt=a.asm.Rsqrt).apply(null,arguments)},rf=a._ScatterNd=function(){return(rf=a._ScatterNd=a.asm.ScatterNd).apply(null,arguments)},af=a._SelectV2=function(){return(af=a._SelectV2=a.asm.SelectV2).apply(null,arguments)},of=a._Sigmoid=function(){return(of=a._Sigmoid=a.asm.Sigmoid).apply(null,arguments)},uf=a._Sin=function(){return(uf=a._Sin=a.asm.Sin).apply(null,arguments)},lf=a._Softmax=function(){return(lf=a._Softmax=a.asm.Softmax).apply(null,arguments)},cf=a._SparseFillEmptyRows=function(){return(cf=a._SparseFillEmptyRows=a.asm.SparseFillEmptyRows).apply(null,arguments)},df=a._SparseReshape=function(){return(df=a._SparseReshape=a.asm.SparseReshape).apply(null,arguments)},pf=a._SparseSegmentReduction=function(){return(pf=a._SparseSegmentReduction=a.asm.SparseSegmentReduction).apply(null,arguments)},hf=a._Sqrt=function(){return(hf=a._Sqrt=a.asm.Sqrt).apply(null,arguments)},ff=a._Square=function(){return(ff=a._Square=a.asm.Square).apply(null,arguments)},mf=a._SquaredDifference=function(){return(mf=a._SquaredDifference=a.asm.SquaredDifference).apply(null,arguments)},gf=a._Step=function(){return(gf=a._Step=a.asm.Step).apply(null,arguments)},bf=a._StridedSlice=function(){return(bf=a._StridedSlice=a.asm.StridedSlice).apply(null,arguments)},yf=a._Sub=function(){return(yf=a._Sub=a.asm.Sub).apply(null,arguments)},vf=a._Sum=function(){return(vf=a._Sum=a.asm.Sum).apply(null,arguments)},xf=a._Tan=function(){return(xf=a._Tan=a.asm.Tan).apply(null,arguments)},wf=a._Tanh=function(){return(wf=a._Tanh=a.asm.Tanh).apply(null,arguments)},kf=a._Tile=function(){return(kf=a._Tile=a.asm.Tile).apply(null,arguments)},Sf=a._TopK=function(){return(Sf=a._TopK=a.asm.TopK).apply(null,arguments)},If=a._Transform=function(){return(If=a._Transform=a.asm.Transform).apply(null,arguments)},Cf=a._Transpose=function(){return(Cf=a._Transpose=a.asm.Transpose).apply(null,arguments)},Nf=a.__FusedMatMul=function(){return(Nf=a.__FusedMatMul=a.asm._FusedMatMul).apply(null,arguments)},Tf=a._malloc=function(){return(Tf=a._malloc=a.asm.malloc).apply(null,arguments)},$f=a._free=function(){return($f=a._free=a.asm.free).apply(null,arguments)},_f=a.___errno_location=function(){return(_f=a.___errno_location=a.asm.__errno_location).apply(null,arguments)},Af=a._emscripten_main_thread_process_queued_calls=function(){return(Af=a._emscripten_main_thread_process_queued_calls=a.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Fc=a.stackSave=function(){return(Fc=a.stackSave=a.asm.stackSave).apply(null,arguments)},Oc=a.stackRestore=function(){return(Oc=a.stackRestore=a.asm.stackRestore).apply(null,arguments)},Su=a.stackAlloc=function(){return(Su=a.stackAlloc=a.asm.stackAlloc).apply(null,arguments)},Ef=a.dynCall_iijjiiii=function(){return(Ef=a.dynCall_iijjiiii=a.asm.dynCall_iijjiiii).apply(null,arguments)},Rf=a.dynCall_jiji=function(){return(Rf=a.dynCall_jiji=a.asm.dynCall_jiji).apply(null,arguments)};a.cwrap=Ie;var Di;function Iu(H){this.name=\"ExitStatus\",this.message=\"Program terminated with exit(\"+H+\")\",this.status=H}Js=function H(){Di||Cu(),Di||(Js=H)};function Cu(H){if(H=H||c,Fn>0||(cc(),Fn>0))return;function ee(){Di||(Di=!0,a.calledRun=!0,!oe&&(dc(),i(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),pc()))}a.setStatus?(a.setStatus(\"Running...\"),setTimeout(function(){setTimeout(function(){a.setStatus(\"\")},1),ee()},1)):ee()}a.run=Cu;function Zv(H){ae=H,bu()||(a.onExit&&a.onExit(H),oe=!0),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 Fi;u&&(Fi={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 Oi;if(typeof r!=\"undefined\")Oi=r;else if(typeof WasmBackendModuleThreadedSimd!=\"undefined\")Oi=WasmBackendModuleThreadedSimd;else throw new Error(\"Could not find wasm module in post.js\");if(Fi){var Df=Oi._dispose;Oi._dispose=function(){Df(),Fi.uncaughtException.forEach(function(H){process.removeListener(\"uncaughtException\",H)}),Fi.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)}}),m$=1e-7,g$=1e-4,Yd=class{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}},il=class{refCount(e){return On(\"refCount\")}incRef(e){return On(\"incRef\")}timerAvailable(){return!0}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?m$:g$}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 Jw(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,gd(e,t,n)}function b$(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--,gd(e,n,s),gd(t,n,s)}function Hu(e,t,n){return Math.max(e,Math.min(t,n))}function y$(e){return e%2===0?e:e+1}function gd(e,t,n){let s=e[t];e[t]=e[n],e[n]=s}function v$(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function ka(e){F(e!=null,()=>\"The input to the tensor constructor must be a non-null value.\")}function ra(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||Qt(e)&&!n)for(let s=0;s0,n){return new Promise((s,r)=>{let a=0,i=()=>{if(e()){s();return}a++;let o=t(a);if(n!=null&&a>=n){r();return}setTimeout(i,o)};i()})}function T$(e,t){let n=1,s=-1;for(let a=0;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),F(e.every(s=>s>=-n&&s`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),F(e.every(s=>eo(s)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(s=>s<0?n+s:s)}function ek(e,t){let n=[],s=[],r=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||r?null:ts(t,e).sort(),i=0;for(let o=0;oo)&&e[o]===1&&(n.push(e[o]),s.push(o)),a[i]<=o&&i++}e[o]!==1&&(n.push(e[o]),s.push(o))}return{newShape:n,keptDims:s}}function tk(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 nk(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 sk(e,t){for(let n=0;nt+=n.length),t}function ar(e){return typeof e==\"string\"||e instanceof String}function ik(e){return typeof e==\"boolean\"}function ok(e){return typeof e==\"number\"}function Qd(e){return Array.isArray(e)?Qd(e[0]):e instanceof Float32Array?\"float32\":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?\"int32\":ok(e)?\"float32\":ar(e)?\"string\":ik(e)?\"bool\":\"float32\"}function hr(e){return!!(e&&e.constructor&&e.call&&e.apply)}function bd(e,t){for(let n=t;n=0;--s)n[s]=n[s+1]*e[s+1];return n}function uk(e,t,n,s=!1){let r=new Array;if(t.length===1){let a=t[0]*(s?2:1);for(let i=0;iu*l)*(s?2:1);for(let u=0;ur*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 uk(0,e,t,n)}function ug(e,t){let n=Zd(e,t);for(let s=0;ss*r,1);if(t==null||t===\"float32\")return Xi(e,new Float32Array(n));if(t===\"int32\")return Xi(e,new Int32Array(n));if(t===\"bool\")return Xi(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function lg(e){e.forEach(t=>{F(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function A$(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{let[s,r]=n.split(\":\");this.urlFlags[s]=O$(s,r)})}};function D$(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(F$(t,s[0],s[1]),s.join(\"=\"))),t}function F$(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||\"\")}function O$(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 lk}var lk=null;function P$(e){lk=e}var Bf;function ck(){if(Bf==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\");Bf=e}return Bf}function z$(){let e=ck();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function dg(e,t){let n=z$();if(n.has(e))return n.get(e);{let s=t();return n.set(e,s),n.get(e)}}var po=\"Abs\",ol=\"Acos\",ul=\"Acosh\",Sr=\"Add\",Sa=\"AddN\",ll=\"All\",cl=\"Any\",Ia=\"ArgMax\",dl=\"ArgMin\",pl=\"Asin\",hl=\"Asinh\",fl=\"Atan\",ml=\"Atanh\",gl=\"Atan2\",Ca=\"AvgPool\",pg=\"AvgPoolGrad\",Jd=\"AvgPool3D\",hg=\"AvgPool3DGrad\",Na=\"BatchMatMul\",ho=\"BatchToSpaceND\",fg=\"Bincount\",M$=\"BroadcastTo\",mg=\"BroadcastArgs\",Ta=\"Cast\",$a=\"Ceil\",Ir=\"ClipByValue\",ep=\"Complex\",tp=\"ComplexAbs\",fo=\"Concat\",_a=\"Conv2D\",gg=\"Conv2DBackpropFilter\",Aa=\"Conv2DBackpropInput\",np=\"Conv3D\",bg=\"Conv3DBackpropFilterV2\",yg=\"Conv3DBackpropInputV2\",Ea=\"Cos\",Ra=\"Cosh\",mo=\"Cumprod\",Da=\"Cumsum\",go=\"CropAndResize\",vg=\"DenseBincount\",bo=\"DepthToSpace\",Fa=\"DepthwiseConv2dNative\",xg=\"DepthwiseConv2dNativeBackpropFilter\",wg=\"DepthwiseConv2dNativeBackpropInput\",kg=\"Diag\",sp=\"Dilation2D\",nm=\"Dilation2DBackpropInput\",sm=\"Dilation2DBackpropFilter\",Oa=\"RealDiv\",rp=\"Einsum\",Pa=\"Elu\",Sg=\"EluGrad\",bl=\"Erf\",yo=\"Equal\",za=\"Exp\",vo=\"ExpandDims\",xo=\"Expm1\",Ig=\"FFT\",yl=\"Fill\",wo=\"FlipLeftRight\",Ma=\"Floor\",La=\"FloorDiv\",Ba=\"FusedBatchNorm\",ko=\"GatherV2\",So=\"GatherNd\",Io=\"Greater\",Va=\"GreaterEqual\",Wa=\"Identity\",Cg=\"IFFT\",ap=\"Imag\",vl=\"IsFinite\",xl=\"IsInf\",wl=\"IsNan\",Ua=\"LeakyRelu\",Co=\"Less\",No=\"LessEqual\",Ng=\"LinSpace\",Ga=\"Log\",kl=\"Log1p\",To=\"LogicalAnd\",Sl=\"LogicalNot\",ip=\"LogicalOr\",L$=\"LogSoftmax\",rpe=\"LowerBound\",op=\"LRN\",Tg=\"LRNGrad\",Ha=\"Max\",qa=\"Maximum\",ja=\"MaxPool\",$g=\"MaxPoolGrad\",up=\"MaxPool3D\",_g=\"MaxPool3DGrad\",Ag=\"MaxPoolWithArgmax\",Ka=\"Mean\",Xa=\"Min\",Ya=\"Minimum\",Qa=\"MirrorPad\",Il=\"Mod\",Eg=\"Multinomial\",Za=\"Multiply\",$o=\"Neg\",_o=\"NotEqual\",Ao=\"NonMaxSuppressionV3\",Cl=\"NonMaxSuppressionV4\",Eo=\"NonMaxSuppressionV5\",Ro=\"OnesLike\",Do=\"OneHot\",Fo=\"Pack\",Ja=\"PadV2\",ape=\"Pool\",ei=\"Pow\",ti=\"Prelu\",ni=\"Prod\",Nl=\"Range\",lp=\"Real\",Tl=\"Reciprocal\",si=\"Relu\",Oo=\"Reshape\",$l=\"ResizeNearestNeighbor\",Rg=\"ResizeNearestNeighborGrad\",ri=\"ResizeBilinear\",Dg=\"ResizeBilinearGrad\",ai=\"Relu6\",Po=\"Reverse\",zo=\"Round\",ii=\"Rsqrt\",Mo=\"ScatterNd\",Fg=\"SearchSorted\",Lo=\"Select\",_l=\"Selu\",Bo=\"Slice\",oi=\"Sin\",Vo=\"Sinh\",Al=\"Sign\",ui=\"Sigmoid\",El=\"Softplus\",li=\"Sqrt\",ci=\"Sum\",Wo=\"SpaceToBatchND\",Uo=\"SplitV\",di=\"Softmax\",cp=\"SparseFillEmptyRows\",Rl=\"SparseReshape\",dp=\"SparseSegmentMean\",pp=\"SparseSegmentSum\",hp=\"SparseToDense\",pi=\"SquaredDifference\",Dl=\"Square\",Go=\"StridedSlice\",fp=\"StringNGrams\",Og=\"StringSplit\",Pg=\"StringToHashBucketFast\",hi=\"Sub\",Ho=\"Tan\",fi=\"Tanh\",Cr=\"Tile\",qo=\"TopK\",jo=\"Transform\",mi=\"Transpose\",zg=\"Unique\",Ko=\"Unpack\",mp=\"UnsortedSegmentSum\",ipe=\"UpperBound\",Xo=\"ZerosLike\",gi=\"Step\",yd=\"FromPixels\",Yo=\"RotateWithOffset\",aa=\"_FusedMatMul\",ia=\"FusedConv2D\",oa=\"FusedDepthwiseConv2D\";function rr(...e){K().getBool(\"IS_TEST\")||K().getBool(\"PROD\")||console.warn(...e)}function B$(...e){K().getBool(\"IS_TEST\")||K().getBool(\"PROD\")||console.log(...e)}var to=dg(\"kernelRegistry\",()=>new Map),qu=dg(\"gradRegistry\",()=>new Map);function rm(e,t){let n=Mg(e,t);return to.get(n)}function lx(e){return qu.get(e)}function am(e){let t=to.entries(),n=[];for(;;){let{done:s,value:r}=t.next();if(s)break;let[a,i]=r,[o]=a.split(\"_\");o===e&&n.push(i)}return n}function Fl(e){let{kernelName:t,backendName:n}=e,s=Mg(t,n);to.has(s)&&rr(`The kernel '${t}' for backend '${n}' is already registered`),to.set(s,e)}function V$(e){let{kernelName:t}=e;qu.has(t)&&K().getBool(\"DEBUG\")&&rr(`Overriding the gradient for '${t}'`),qu.set(t,e)}function ope(e,t){let n=Mg(e,t);if(!to.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);to.delete(n)}function upe(e){if(!qu.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);qu.delete(e)}function lpe(e,t){am(e).forEach(s=>{let r=Object.assign({},s,{backendName:t});Fl(r)})}function Mg(e,t){return`${t}_${e}`}var w={};Ee(w,{arraysEqual:()=>kr,assert:()=>F,assertNonNegativeIntegerDimensions:()=>lg,assertNonNull:()=>ka,assertShapesMatch:()=>pn,bytesFromStringArray:()=>ak,bytesPerElement:()=>tm,checkConversionForErrors:()=>sk,clamp:()=>Hu,computeStrides:()=>co,createScalarValue:()=>j$,createShuffledIndices:()=>C$,decodeString:()=>vd,distSquared:()=>w$,encodeString:()=>Pl,fetch:()=>X$,fingerPrint64:()=>q$,flatten:()=>ra,getArrayFromDType:()=>nk,getTypedArrayFromDType:()=>tk,hasEncodingLoss:()=>$$,hexToLong:()=>Ol,indexToLoc:()=>E$,inferDtype:()=>Qd,inferFromImplicitShape:()=>T$,isBoolean:()=>ik,isFunction:()=>hr,isInt:()=>eo,isNumber:()=>ok,isPromise:()=>cg,isScalarShape:()=>k$,isString:()=>ar,isTypedArray:()=>Qt,isValidDtype:()=>rk,locToIndex:()=>A$,makeOnesTypedArray:()=>ug,makeZerosNestedTypedArray:()=>_$,makeZerosTypedArray:()=>Zd,nearestDivisor:()=>bd,nearestLargerEven:()=>y$,now:()=>ju,parseAxisParam:()=>ts,randUniform:()=>x$,repeatedTry:()=>N$,rightPad:()=>Vu,shuffle:()=>Jw,shuffleCombo:()=>b$,sizeFromShape:()=>dt,sizeToSquarishShape:()=>I$,squeezeShape:()=>ek,sum:()=>v$,swap:()=>gd,tanh:()=>S$,toNestedArray:()=>Xi,toTypedArray:()=>gp});var cx=wa(JT()),jr=cx.default||cx;function Ol(e){return jr.fromString(e,!0,16)}var dk=Ol(\"c3a5c85c97cb3127\"),Hr=Ol(\"b492b66fbe98f273\"),on=Ol(\"9ae16a3b2f90404f\");function im(e){return e.xor(e.shru(47))}function pk(e,t,n){let s=e.slice(t,t+n);return jr.fromBytes(Array.from(s),!0,!0)}function lt(e,t){return pk(e,t,8)}function dx(e,t){return pk(e,t,4)}function Bt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function or(e,t,n=Ol(\"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 W$(e,t,n,s,r,a){r=r.add(e),a=Bt(a.add(r).add(s),21);let i=r;return r=r.add(t),r=r.add(n),a=a.add(Bt(r,44)),[r.add(s),a.add(i)]}function Uc(e,t,n,s){return W$(lt(e,t),lt(e,t+8),lt(e,t+16),lt(e,t+24),n,s)}function U$(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=Bt(r,37).mul(n).add(s),i=Bt(s,25).add(r).mul(n);return or(a,i,n)}if(t>=4){let n=on.add(t*2),s=dx(e,0);return or(s.shl(3).add(t),dx(e,t-4),n)}if(t>0){let n=e[0],s=e[t>>1],r=e[t-1],a=n+(s<<8),i=t+(r<<2);return im(on.mul(a).xor(dk.mul(i))).mul(on)}return on}function G$(e,t=e.length){let n=on.add(t*2),s=lt(e,0).mul(Hr),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(on);return or(Bt(s.add(r),43).add(Bt(a,30)).add(i),s.add(Bt(r.add(on),18)).add(a),n)}function H$(e,t=e.length){let n=on.add(t*2),s=lt(e,0).mul(on),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(on),o=Bt(s.add(r),43).add(Bt(a,30)).add(i),u=or(o,s.add(Bt(r.add(on),18)).add(a),n),l=lt(e,16).mul(n),c=lt(e,24),p=o.add(lt(e,t-32)).mul(n),d=u.add(lt(e,t-24)).mul(n);return or(Bt(l.add(c),43).add(Bt(p,30)).add(d),l.add(Bt(c.add(s),18)).add(p),n)}function q$(e,t=e.length){let n=jr.fromNumber(81,!0);if(t<=32)return t<=16?U$(e,t):G$(e,t);if(t<=64)return H$(e,t);let s=n,r=n.mul(Hr).add(113),a=im(r.mul(on).add(113)).mul(on),i=[jr.UZERO,jr.UZERO],o=[jr.UZERO,jr.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=Bt(s.add(r).add(i[0]).add(lt(e,u+8)),37).mul(Hr),r=Bt(r.add(i[1]).add(lt(e,u+48)),42).mul(Hr),s=s.xor(o[1]),r=r.add(i[0]).add(lt(e,u+40)),a=Bt(a.add(o[0]),33).mul(Hr),i=Uc(e,u,i[1].mul(Hr),s.add(o[0])),o=Uc(e,u+32,a.add(o[1]),r.add(lt(e,u+16))),[a,s]=[s,a],u+=64;while(u!==l);let p=Hr.add(a.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),s=Bt(s.add(r).add(i[0]).add(lt(e,u+8)),37).mul(p),r=Bt(r.add(i[1]).add(lt(e,u+48)),42).mul(p),s=s.xor(o[1].mul(9)),r=r.add(i[0].mul(9).add(lt(e,u+40))),a=Bt(a.add(o[0]),33).mul(p),i=Uc(e,u,i[1].mul(p),s.add(o[0])),o=Uc(e,u+32,a.add(o[1]),r.add(lt(e,u+16))),[a,s]=[s,a],or(or(i[0],o[0],p).add(im(r).mul(dk)).add(a),or(i[1],o[1],p).add(s),p)}function j$(e,t){return t===\"string\"?Pl(e):gp([e],t)}function K$(e,t){return e instanceof Float32Array&&t===\"float32\"||e instanceof Int32Array&&t===\"int32\"||e instanceof Uint8Array&&t===\"bool\"}function gp(e,t){if(t===\"string\")throw new Error(\"Cannot convert a string[] to a TypedArray\");if(Array.isArray(e)&&(e=ra(e)),K().getBool(\"DEBUG\")&&sk(e,t),K$(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{s=n()},a,i=ju();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(r);else{r();for(let u of s)u.dataSync();a=Promise.resolve({kernelMs:ju()-i})}if(K().getBool(\"CHECK_COMPUTATION_FOR_ERRORS\"))for(let u=0;u{Q$(c,l.dtype,e)})}return{kernelName:e,outputs:s,inputs:t,timeMs:a.then(u=>u.kernelMs),extraInfo:a.then(u=>u.getExtraProfileInfo!=null?u.getExtraProfileInfo():\"\")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:s,inputs:r,extraInfo:a}=e;n.forEach(i=>{Promise.all([i.data(),s,a]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],r,o[2])})})}};function Q$(e,t,n){if(t!==\"float32\")return!1;for(let s=0;s0?f:\"\"} `}}console.log(`%c${o}\t%c${i}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${a}`,\"font-weight:bold\",\"color:red\",\"color:blue\",\"color: orange\",\"color: green\",\"color: steelblue\")}};function J$(e,t,n){let s={},r={};for(let u=0;us[m.id]=!0),h=!0,r[l.id]=!0;break}if(h)break}}let a={};a[n.id]=!0;let i={};for(let u=e.length-1;u>=0;u--){let l=e[u],c=l.inputs;for(let p=0;p=0;r--){let a=t[r],i=[];if(a.outputs.forEach(u=>{let l=e[u.id];l!=null?i.push(l):i.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let o=a.gradient(i);for(let u in a.inputs){if(!(u in o))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(o)}.`);let l=n(()=>o[u]());if(l.dtype!==\"float32\")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`);let c=a.inputs[u];if(!kr(l.shape,c.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`);if(e[c.id]==null)e[c.id]=l;else{let p=e[c.id];e[c.id]=s(p,l),p.dispose()}}}}var px=20,$u=3,Vf=7;function t_(e,t,n,s){let r=co(t),a=n_(e,t,n,r),i=t.length,o=sd(e,t,n,r,a),u=[\"Tensor\"];return s&&(u.push(` dtype: ${n}`),u.push(` rank: ${i}`),u.push(` shape: [${t}]`),u.push(\" values:\")),u.push(o.map(l=>\" \"+l).join(`\n`)),u.join(`\n`)}function n_(e,t,n,s){let r=dt(t),a=s[s.length-1],i=new Array(a).fill(0),o=t.length,u=n===\"complex64\"?Du(e):e;if(o>1)for(let l=0;lpx){let g=$u*i,b=Array.from(e.slice(0,g)),y=Array.from(e.slice((o-$u)*i,o*i));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[o-$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]*i,d=[];if(o>px){for(let m=0;m<$u;m++){let g=m*p,b=g+p;d.push(...sd(e.slice(g,b),l,n,c,r,!1))}d.push(\"...\");for(let m=o-$u;m`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||nk(t,this.size),this.strides=co(e)}set(e,...t){t.length===0&&(t=[0]),F(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;svd(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=>vd(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=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error(\"Tensor is disposed.\")}print(e=!1){return Hi.print(this,e)}clone(){return this.throwIfDisposed(),Hi.clone(this)}toString(e=!1){let t=this.dataSync();return t_(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Hi.cast(this,e)}variable(e=!0,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 o_(){return dg(\"Tensor\",()=>et)}o_();var xd=class extends et{constructor(e,t,n,s){super(e.shape,e.dtype,e.dataId,s),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!kr(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);cs().disposeTensor(this),this.dataId=e.dataId,cs().incRef(this,null)}dispose(){cs().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(xd,Symbol.hasInstance,{value:e=>e instanceof et&&e.assign!=null&&e.assign instanceof Function});var _s={};Ee(_s,{assertTypesMatch:()=>yk,getTensorsInContainer:()=>Lg,isTensorInList:()=>c_,makeTypesMatch:()=>vt});var u_=(e=>(e.R0=\"R0\",e.R1=\"R1\",e.R2=\"R2\",e.R3=\"R3\",e.R4=\"R4\",e.R5=\"R5\",e.R6=\"R6\",e))(u_||{}),fk=(e=>(e.float32=\"float32\",e.int32=\"int32\",e.bool=\"int32\",e.complex64=\"complex64\",e))(fk||{}),mk=(e=>(e.float32=\"float32\",e.int32=\"int32\",e.bool=\"bool\",e.complex64=\"complex64\",e))(mk||{}),gk=(e=>(e.float32=\"float32\",e.int32=\"float32\",e.bool=\"float32\",e.complex64=\"complex64\",e))(gk||{}),bk=(e=>(e.float32=\"complex64\",e.int32=\"complex64\",e.bool=\"complex64\",e.complex64=\"complex64\",e))(bk||{}),l_={float32:gk,int32:fk,bool:mk,complex64:bk};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 l_[e][t]}function bp(e){return cn(e,\"int32\")}function vt(e,t){if(e.dtype===t.dtype)return[e,t];let n=cn(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function yk(e,t){F(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function c_(e,t){return t.some(n=>n.id===e.id)}function Lg(e){let t=[];return vk(e,t,new Set),t}function vk(e,t,n){if(e==null)return;if(e instanceof et){t.push(e);return}if(!d_(e))return;let s=e;for(let r in s){let a=s[r];n.has(a)||(n.add(a),vk(a,t,n))}}function d_(e){return Array.isArray(e)||typeof e==\"object\"}function Wf(e){return e.kernelName!=null}var hx=class{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(let e in this.registeredVariables)this.registeredVariables[e].dispose()}},om=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new hx}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){am(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(sthis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.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 om.nextTensorId++}nextVariableId(){return om.nextVariableId++}clone(e){let t=M.runKernel(Wa,{x:e}),n={x:e},s=a=>({x:()=>{let i=\"float32\",o={x:a},u={dtype:i};return M.runKernel(Ta,o,u)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],s,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,!(rm(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool(\"IS_TEST\")}checkKernelForMemLeak(e,t,n){let s=this.backend.numDataIds(),r=0;n.forEach(o=>{r+=o.dtype===\"complex64\"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=s-t-r-a;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],s=this.isTapeOn(),r=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,u=Wf(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:\"\";if(Wf(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=rm(h,this.backendName);F(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),i=()=>{let b=this.backend.numDataIds();o=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let y=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,b,y);let v=y.map(x=>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))))};i=()=>{let m=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,f));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,m,g),g}}let{inputs:l,attrs:c}=e,p=Wf(e)?null:e.backwardsFunc,d;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool(\"DEBUG\")&&!this.state.profiling?t=i():(d=this.profiler.profileKernel(u,l,()=>i()),this.ENV.getBool(\"DEBUG\")&&this.profiler.logKernelProfile(d),t=d.outputs)}),s&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map(h=>l[h]!=null?l[h].shape:null),outputShapes:t.map(h=>h.shape),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let s=lx(e);if(s!=null){let r=s.inputsToSave||[],a=s.outputsToSave||[],i;s.saveAllInputs?(F(Array.isArray(t),()=>\"saveAllInputs is true, expected inputs to be an array.\"),i=Object.keys(t).map(u=>t[u])):i=r.map(u=>t[u]);let o=n.filter((u,l)=>a[l]);return i.concat(o)}return[]}makeTensor(e,t,n,s){if(e==null)throw new Error(\"Values passed to engine.makeTensor() are null\");n=n||\"float32\",s=s||this.backend;let r=e;n===\"string\"&&ar(e[0])&&(r=e.map(o=>Pl(o)));let a=s.write(r,t,n),i=new et(t,n,a,this.nextTensorId());if(this.trackTensor(i,s),n===\"string\"){let o=this.state.tensorInfo.get(a),u=ak(r);this.state.numBytes+=u-o.bytes,o.bytes=u}return i}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=!0,n,s){n=n||this.nextVariableId().toString(),s!=null&&s!==e.dtype&&(e=e.cast(s));let r=new xd(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*tm(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 xd||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*tm(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=!0,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=!0;let t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,s,r,a){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},o=lx(e);o!=null&&(s=o.gradFunc),s!=null&&(i.gradient=u=>(u=u.map((l,c)=>{if(l==null){let p=n[c],d=Zd(p.size,p.dtype);return this.makeTensor(d,p.shape,p.dtype)}return l}),s(u.length>1?u:u[0],r,a))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,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=Lg(e),n=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===s.id&&this.track(r)})}gradients(e,t,n,s=!1){if(F(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));F(r instanceof et,()=>\"The result y returned by f() must be a tensor.\");let a=J$(this.state.activeTape,t,r);if(!s&&a.length===0&&t.length>0)throw new Error(\"Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.\");return this.tidy(\"backward\",()=>{let i={};i[r.id]=n==null?p_(r.shape):n,e_(i,a,u=>this.tidy(u),h_);let o=t.map(u=>i[u.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(u=>{for(let l of u.saved)l.dispose()}),this.state.activeTape=null),{value:r,grads:o}})}customGrad(e){return F(hr(e),()=>\"The f passed in customGrad(f) must be a function.\"),(...t)=>{F(t.every(i=>i instanceof et),()=>\"The args passed in customGrad(f)(x1, x2,...) must all be tensors\");let n,s={};t.forEach((i,o)=>{s[o]=i});let r=(i,o)=>(n=e(...t,o),F(n.value instanceof et,()=>\"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor\"),F(hr(n.gradFunc),()=>\"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.\"),n.value),a=(i,o)=>{let u=n.gradFunc(i,o),l=Array.isArray(u)?u:[u];F(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(...).\"),F(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 hx;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}},Bg=om;Bg.nextTensorId=0;Bg.nextVariableId=0;function p_(e){let t=ug(dt(e),\"float32\");return M.makeTensor(t,e,\"float32\")}function xk(){let e=ck();if(e._tfengine==null){let t=new R$(e);e._tfengine=new Bg(t)}return P$(e._tfengine.ENV),r_(()=>e._tfengine),e._tfengine}var M=xk();function h_(e,t){let n={a:e,b:t};return M.runKernel(Sr,n)}var yp={};Ee(yp,{isBrowser:()=>wk,isMobile:()=>g_,mockIsMobile:()=>m_});function f_(){return typeof navigator!=\"undefined\"&&navigator!=null}var um;function m_(e){um=e}function g_(e){if(um!==void 0)return um;if(e||f_()){if(e||(e=navigator),e.product===\"ReactNative\")return!0;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!1}function wk(){return typeof window!=\"undefined\"&&window.document!=null||typeof WorkerGlobalScope!=\"undefined\"}var Kn=K();Kn.registerFlag(\"DEBUG\",()=>!1,e=>{e&&console.warn(\"Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.\")});Kn.registerFlag(\"IS_BROWSER\",()=>wk());Kn.registerFlag(\"IS_NODE\",()=>typeof process!=\"undefined\"&&typeof process.versions!=\"undefined\"&&typeof process.versions.node!=\"undefined\");Kn.registerFlag(\"IS_CHROME\",()=>typeof navigator!=\"undefined\"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Kn.registerFlag(\"PROD\",()=>!1);Kn.registerFlag(\"TENSORLIKE_CHECK_SHAPE_CONSISTENCY\",()=>Kn.getBool(\"DEBUG\"));Kn.registerFlag(\"DEPRECATION_WARNINGS_ENABLED\",()=>!0);Kn.registerFlag(\"IS_TEST\",()=>!1);Kn.registerFlag(\"CHECK_COMPUTATION_FOR_ERRORS\",()=>!0);Kn.registerFlag(\"WRAP_TO_IMAGEBITMAP\",()=>!1);Kn.registerFlag(\"ENGINE_COMPILE_ONLY\",()=>!1);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\")&&kk(e,s,[]),s}function kk(e,t,n){if(n=n||[],!Array.isArray(e)&&!Qt(e)){F(t.length===0,()=>`Element arr[${n.join(\"][\")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}F(t.length>0,()=>`Element arr[${n.join(\"][\")}] should be a primitive, but is an array of ${e.length} elements`),F(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=0&&(r=s),fx(s,r,t,n),e==null||!Qt(e)&&!Array.isArray(e)&&typeof e!=\"number\"&&typeof e!=\"boolean\"&&typeof e!=\"string\"){let u=e==null?\"null\":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${u}'`)}let a=Rs(e,r);!Qt(e)&&!Array.isArray(e)&&(e=[e]);let o=r!==\"string\"?gp(e,r):ra(e,[],!0);return M.makeTensor(o,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,i)=>_(a,`${t}[${i}]`,n,s))}var b_=\"__op\";function L(e){let t=Object.keys(e);if(t.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0],s=e[n];n.endsWith(\"_\")&&(n=n.substring(0,n.length-1)),n=n+b_;let r=(...a)=>{M.startScope(n);try{let i=s(...a);return cg(i)&&console.error(\"Cannot return a Promise inside of tidy.\"),M.endScope(i),i}catch(i){throw M.endScope(null),i}};return Object.defineProperty(r,\"name\",{value:n,configurable:!0}),r}function y_(e,t){let n=_(e,\"real\",\"complex\"),s=_(t,\"imag\",\"complex\");pn(n.shape,s.shape,`real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`);let r={real:n,imag:s};return M.runKernel(ep,r)}var ua=L({complex_:y_});function Nr(e,t,n,s){if(s==null&&(s=Qd(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){lg(t);let r=dt(t),a=dt(n);F(r===a,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);for(let i=0;i`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\"?gp(e,s):ra(e,[],!0),M.makeTensor(e,t,s)}function ms(e,t,n){let s=Rs(e,n);return Nr(e,t,s,n)}var lm={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},wd=4;async function v_(e,t){let n=[],s=[],r=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let d=await u.bytes(),h=d.reduce((g,b)=>g+b.length,0)+wd*d.length,f=new Uint8Array(h),m=0;for(let g=0;g{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let s=new Uint8Array(t),r=0;return n.forEach(a=>{s.set(new Uint8Array(a.buffer),r),r+=a.byteLength}),s.buffer}var Vg=typeof Buffer!=\"undefined\"&&(typeof Blob==\"undefined\"||typeof atob==\"undefined\"||typeof btoa==\"undefined\");function mx(e){return Vg?Buffer.byteLength(e):new Blob([e]).size}function w_(e){if(Vg)return Buffer.from(e).toString(\"base64\");let t=new Uint8Array(e),n=\"\";for(let s=0,r=t.length;s{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 gx(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 Ik(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 Ug(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 zl(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:mx(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:mx(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function S_(){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 I_(){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 C_(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function N_(){let e=S_(),t=I_(),n=C_();return s=>{let r=new ArrayBuffer(4*s.length),a=new Uint32Array(r);for(let i=0;i>10]+(o&1023)]+t[o>>10];a[i]=u}return new Float32Array(r)}}var xt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return xt.instance==null&&(xt.instance=new xt),xt.instance}static registerSaveRouter(e){xt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){xt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return xt.getHandlers(e,\"save\")}static getLoadHandlers(e,t){return xt.getHandlers(e,\"load\",t)}static getHandlers(e,t,n){let s=[];return(t===\"load\"?xt.getInstance().loadRouters:xt.getInstance().saveRouters).forEach(a=>{let i=a(e,n);i!==null&&s.push(i)}),s}},T_=e=>xt.registerSaveRouter(e),$_=e=>xt.registerLoadRouter(e),__=e=>xt.getSaveHandlers(e),A_=(e,t)=>xt.getLoadHandlers(e,t),cm=\"tensorflowjs\",dm=1,Qr=\"models_store\",ir=\"model_info_store\";function Ck(){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 pm(e){let t=e.result;t.createObjectStore(Qr,{keyPath:\"modelPath\"}),t.createObjectStore(ir,{keyPath:\"modelPath\"})}var la=class{constructor(e){if(this.indexedDB=Ck(),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(cm,dm);r.onupgradeneeded=()=>pm(r),r.onsuccess=()=>{let a=r.result;if(t==null){let i=a.transaction(Qr,\"readonly\"),u=i.objectStore(Qr).get(this.modelPath);u.onsuccess=()=>{if(u.result==null)return a.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(u.result.modelArtifacts)},u.onerror=l=>(a.close(),s(u.error)),i.oncomplete=()=>a.close()}else{let i=zl(t),o=a.transaction(ir,\"readwrite\"),u=o.objectStore(ir),l=u.put({modelPath:this.modelPath,modelArtifactsInfo:i}),c;l.onsuccess=()=>{c=a.transaction(Qr,\"readwrite\");let d=c.objectStore(Qr).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=h=>{u=o.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)),o.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},r.onerror=a=>s(r.error)})}};la.URL_SCHEME=\"indexeddb://\";var Nk=e=>K().getBool(\"IS_BROWSER\")&&!Array.isArray(e)&&e.startsWith(la.URL_SCHEME)?E_(e.slice(la.URL_SCHEME.length)):null;xt.registerSaveRouter(Nk);xt.registerLoadRouter(Nk);function E_(e){return new la(e)}function R_(e){return e.startsWith(la.URL_SCHEME)?e.slice(la.URL_SCHEME.length):e}var D_=class{constructor(){this.indexedDB=Ck()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(cm,dm);n.onupgradeneeded=()=>pm(n),n.onsuccess=()=>{let s=n.result,r=s.transaction(ir,\"readonly\"),i=r.objectStore(ir).getAll();i.onsuccess=()=>{let o={};for(let u of i.result)o[u.modelPath]=u.modelArtifactsInfo;e(o)},i.onerror=o=>(s.close(),t(i.error)),r.oncomplete=()=>s.close()},n.onerror=s=>t(n.error)})}async removeModel(e){return e=R_(e),new Promise((t,n)=>{let s=this.indexedDB.open(cm,dm);s.onupgradeneeded=()=>pm(s),s.onsuccess=()=>{let r=s.result,a=r.transaction(ir,\"readwrite\"),i=a.objectStore(ir),o=i.get(e),u;o.onsuccess=()=>{if(o.result==null)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let l=i.delete(e),c=()=>{u=r.transaction(Qr,\"readwrite\");let d=u.objectStore(Qr).delete(e);d.onsuccess=()=>t(o.result.modelArtifactsInfo),d.onerror=h=>n(o.error)};l.onsuccess=c,l.onerror=p=>(c(),r.close(),n(o.error))}},o.onerror=l=>(r.close(),n(o.error)),a.oncomplete=()=>{u==null?r.close():u.oncomplete=()=>r.close()}},s.onerror=r=>n(s.error)})}},Us=\"/\",qi=\"tensorflowjs_models\",Tk=\"info\",F_=\"model_topology\",O_=\"weight_specs\",P_=\"weight_data\",z_=\"model_metadata\";function $k(e){return{info:[qi,e,Tk].join(Us),topology:[qi,e,F_].join(Us),weightSpecs:[qi,e,O_].join(Us),weightData:[qi,e,P_].join(Us),modelMetadata:[qi,e,z_].join(Us)}}function _k(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function M_(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 L_(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=$k(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=zl(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,w_(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 _k(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!==\"JSON\")throw new Error(\"BrowserLocalStorage does not support loading non-JSON model topology yet.\");let t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(n==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;let s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;let r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){let i=JSON.parse(r);t.format=i.format,t.generatedBy=i.generatedBy,t.convertedBy=i.convertedBy,i.signature!=null&&(t.signature=i.signature),i.userDefinedMetadata!=null&&(t.userDefinedMetadata=i.userDefinedMetadata),i.modelInitializer!=null&&(t.modelInitializer=i.modelInitializer),i.trainingConfig!=null&&(t.trainingConfig=i.trainingConfig)}let a=this.LS.getItem(this.keys.weightData);if(a==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=k_(a),t}};ca.URL_SCHEME=\"localstorage://\";var Ak=e=>K().getBool(\"IS_BROWSER\")&&!Array.isArray(e)&&e.startsWith(ca.URL_SCHEME)?B_(e.slice(ca.URL_SCHEME.length)):null;xt.registerSaveRouter(Ak);xt.registerLoadRouter(Ak);function B_(e){return new ca(e)}var V_=class{constructor(){F(K().getBool(\"IS_BROWSER\"),()=>\"Current environment is not a web browser\"),F(typeof window==\"undefined\"||typeof window.localStorage!=\"undefined\",()=>\"Current browser does not appear to support localStorage\"),this.LS=window.localStorage}async listModels(){let e={},t=qi+Us,n=Us+Tk;for(let s=0;s\"scheme must not be undefined or null.\"),e.endsWith(Yi)&&(e=e.slice(0,e.indexOf(Yi))),F(e.length>0,()=>\"scheme must not be an empty string.\");let n=zn.getInstance();F(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 rd(e){if(e.indexOf(Yi)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(\",\")}`);return{scheme:e.split(Yi)[0],path:e.split(Yi)[1]}}async function Ek(e,t,n=!1){F(e!==t,()=>`Old path and new path are the same: '${e}'`);let s=xt.getLoadHandlers(e);F(s.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),F(s.length<2,()=>`Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`);let r=s[0],a=xt.getSaveHandlers(t);F(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),F(a.length<2,()=>`Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`);let i=a[0],o=rd(e).scheme,u=rd(e).path,l=o===rd(e).scheme,c=await r.load();n&&l&&await zn.getManager(o).removeModel(u);let p=await i.save(c);return n&&!l&&await zn.getManager(o).removeModel(u),p.modelArtifactsInfo}async function W_(){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+Yi+r;t[a]=s[r]}}return t}async function U_(e){let t=rd(e);return zn.getManager(t.scheme).removeModel(t.path)}async function G_(e,t){return Ek(e,t,!1)}async function H_(e,t){return Ek(e,t,!0)}var q_=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 q_);try{zn.registerManager(ca.URL_SCHEME,new V_)}catch(e){}try{zn.registerManager(la.URL_SCHEME,new D_)}catch(e){}}var j_={importFetch:()=>e$()},Uf,K_=class{constructor(){this.util=t$(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return K().global.fetch!=null?K().global.fetch(e,t):(Uf==null&&(Uf=j_.importFetch()),Uf(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 K_);function Ae(e,t=\"float32\",n){return t=t||\"float32\",lg(e),new Wt(e,t,n)}function X_(e,t){let n=_(e,\"x\",\"cast\");if(!rk(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t===\"string\"&&n.dtype!==\"string\"||t!==\"string\"&&n.dtype===\"string\")throw new Error(\"Only strings can be casted to strings\");let s={x:n},r={dtype:t};return M.runKernel(Ta,s,r)}var le=L({cast_:X_});function Y_(e){let n={x:_(e,\"x\",\"clone\",\"string_or_numeric\")};return M.runKernel(Wa,n)}var ur=L({clone_:Y_});function Q_(e,t=!1){console.log(e.toString(t))}xk();var Z_={buffer:Ae,cast:le,clone:ur,print:Q_};a_(Z_);var An={};Ee(An,{browserFiles:()=>aA,browserHTTPRequest:()=>cA,concatenateArrayBuffers:()=>Wg,copyModel:()=>G_,decodeWeights:()=>Sk,encodeWeights:()=>v_,fromMemory:()=>pA,getLoadHandlers:()=>A_,getModelArtifactsForJSON:()=>Ug,getModelArtifactsInfoForJSON:()=>zl,getSaveHandlers:()=>__,http:()=>Hg,isHTTPScheme:()=>fm,listModels:()=>W_,loadWeights:()=>iA,moveModel:()=>H_,registerLoadRouter:()=>$_,registerSaveRouter:()=>T_,removeModel:()=>U_,weightsLoaderFactory:()=>Dk,withSaveHandler:()=>hA});var J_=\"model\",eA=\".json\",tA=\".weights.bin\";function bx(e){return new Promise(t=>setTimeout(t)).then(e)}var hm=class{constructor(e){if(!K().getBool(\"IS_BROWSER\"))throw new Error(\"browserDownloads() cannot proceed because the current environment is not a browser.\");e.startsWith(hm.URL_SCHEME)&&(e=e.slice(hm.URL_SCHEME.length)),(e==null||e.length===0)&&(e=J_),this.modelJsonFileName=e+eA,this.weightDataFileName=e+tA}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=Ik(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 bx(()=>a.dispatchEvent(new MouseEvent(\"click\"))),e.weightData!=null){let i=this.weightDataAnchor==null?document.createElement(\"a\"):this.weightDataAnchor;i.download=this.weightDataFileName,i.href=t,await bx(()=>i.dispatchEvent(new MouseEvent(\"click\")))}return{modelArtifactsInfo:zl(e)}}}},kd=hm;kd.URL_SCHEME=\"downloads://\";var nA=class{constructor(e){if(e==null||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{let n=new FileReader;n.onload=s=>{let r=JSON.parse(s.target.result),a=r.modelTopology;if(a==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(r.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:a});return}let o=Ug(r,u=>this.loadWeights(u));e(o)},n.onerror=s=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)})}loadWeights(e){let t=[],n=[];for(let a of e)t.push(...a.weights),n.push(...a.paths);let s=this.checkManifestAndWeightFiles(e),r=n.map(a=>this.loadWeightsFile(a,s[a]));return Promise.all(r).then(a=>[t,Wg(a)])}loadWeightsFile(e,t){return new Promise((n,s)=>{let r=new FileReader;r.onload=a=>{let i=a.target.result;n(i)},r.onerror=a=>s(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>gx(r.name)),s={};for(let r of e)r.paths.forEach(a=>{let i=gx(a);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),n.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);s[a]=this.weightsFiles[n.indexOf(i)]});if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return s}},sA=e=>K().getBool(\"IS_BROWSER\")&&!Array.isArray(e)&&e.startsWith(kd.URL_SCHEME)?rA(e.slice(kd.URL_SCHEME.length)):null;xt.registerSaveRouter(sA);function rA(e=\"model\"){return new kd(e)}function aA(e){return new nA(e)}function yx(e,t,n,s){i(e),n=n==null?0:n,s=s==null?1:s,o(n,s);let r=0,a=u=>(u.then(l=>{let c=n+ ++r/e.length*(s-n);return t(c),l}),u);function i(u){F(u!=null&&Array.isArray(u)&&u.length>0,()=>\"promises must be a none empty array\")}function o(u,l){F(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${u}`),F(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),F(l>=u,()=>`startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`)}return Promise.all(e.map(a))}async function Rk(e,t){t==null&&(t={});let n=t.fetchFunc==null?K().platform.fetch:t.fetchFunc,s=e.map(p=>n(p,t.requestInit,{isBinary:!0})),r=0,a=.5,o=(t.onProgress==null?await Promise.all(s):await yx(s,t.onProgress,r,a)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(o):await yx(o,t.onProgress,u,l)}async function iA(e,t=\"\",n,s){return Dk(i=>Rk(i,{requestInit:s}))(e,t,n)}function Dk(e){return async(t,n=\"\",s)=>{let r=t.map(()=>!1),a={},i=s!=null?s.map(()=>!1):[],o=[];if(t.forEach((h,f)=>{let m=0;h.weights.forEach(g=>{let b=\"quantization\"in g?g.quantization.dtype:g.dtype,y=lm[b]*dt(g.shape),v=()=>{r[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:y})};s!=null?s.forEach((x,k)=>{x===g.name&&(v(),i[k]=!0)}):v(),o.push(g.name),m+=y})}),!i.every(h=>h)){let h=s.filter((f,m)=>!i[m]);throw new Error(`Could not find weights in manifest with names: ${h.join(\", \")}. \nManifest JSON has weights with names: ${o.join(\", \")}.`)}let u=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),l=[];u.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith(\"/\")?\"\":\"/\")+f;l.push(m)})});let c=await e(l),p={},d=0;return u.forEach(h=>{let f=t[h].paths.length,m=0;for(let x=0;x{let k=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),I=Sk(k,[x.manifestEntry]);for(let $ in I)p[$]=I[$]}),d+=f}),p}}var oA=\"application/octet-stream\",uA=\"application/json\",Gg=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?(F(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,F(e!=null&&e.length>0,()=>\"URL path for http must not be null, undefined or empty.\"),Array.isArray(e)&&F(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=Ik(e,n);t.body.append(\"model.json\",new Blob([JSON.stringify(s)],{type:uA}),\"model.json\"),e.weightData!=null&&t.body.append(\"model.weights.bin\",new Blob([e.weightData],{type:oA}),\"model.weights.bin\");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:zl(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 Ug(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,s]=lA(t),r=this.weightPathPrefix||n,a=[];for(let l of e)a.push(...l.weights);let i=[],o=[];for(let l of e)for(let c of l.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(c)):i.push(r+c+s);this.weightUrlConverter&&i.push(...await Promise.all(o));let u=await Rk(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,Wg(u)]}};Gg.URL_SCHEME_REGEX=/^https?:\\/\\//;function lA(e){let t=e.lastIndexOf(\"/\"),n=e.lastIndexOf(\"?\"),s=e.substring(0,t),r=n>t?e.substring(n):\"\";return[s+\"/\",r]}function fm(e){return e.match(Gg.URL_SCHEME_REGEX)!=null}var Fk=(e,t)=>{if(typeof fetch==\"undefined\"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(s=>fm(s)):n=fm(e),n)return Hg(e,t)}return null};xt.registerSaveRouter(Fk);xt.registerLoadRouter(Fk);function Hg(e,t){return new Gg(e,t)}function cA(e,t){return Hg(e,t)}var Gf=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},dA=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function pA(e,t,n,s){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new Gf(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 Gf({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 Gf({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:s}))}function hA(e){return new dA(e)}var fA={};Ee(fA,{confusionMatrix:()=>vA});function mA(e,t,n=!1,s=!1){let r=_(e,\"a\",\"matMul\"),a=_(t,\"b\",\"matMul\");[r,a]=vt(r,a);let i={a:r,b:a},o={transposeA:n,transposeB:s};return M.runKernel(Na,i,o)}var Ve=L({matMul_:mA});function gA(e,t,n=1,s=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:_(e,\"indices\",\"oneHot\",\"int32\")},i={depth:t,onValue:n,offValue:s};return M.runKernel(Do,a,i)}var Sd=L({oneHot_:gA});function bA(e,t){let n=_(e,\"x\",\"transpose\");if(t==null&&(t=n.shape.map((a,i)=>i).reverse()),F(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(a=>{F(a>=0&&a`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let s={x:n},r={perm:t};return M.runKernel(mi,s,r)}var Ge=L({transpose_:bA});function yA(e,t,n){let s=_(e,\"labels\",\"confusionMatrix\"),r=_(t,\"predictions\",\"confusionMatrix\");F(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),F(s.rank===1,()=>`Expected the rank of labels to be 1, but got ${s.rank}`),F(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),F(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.`),F(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=Sd(le(s,\"int32\"),n),i=Sd(le(r,\"int32\"),n),o=Ge(a),u=Ve(o,i);return le(u,\"int32\")}var vA=L({confusionMatrix_:yA}),Qo={};Ee(Qo,{assertAndGetBroadcastShape:()=>rt,getBroadcastDims:()=>Ok,getReductionAxes:()=>At});function Ok(e,t){let n=e.length,s=[];for(let r=0;r1&&i===1&&s.unshift(a)}return s}function At(e,t){let n=[];for(let s=0;s1)&&n.unshift(a)}return n}function rt(e,t){let n=[],s=Math.max(e.length,t.length);for(let r=0;rTA,fromPixelsAsync:()=>CA,toPixels:()=>NA});function xA(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 Nr(e,t,s,n)}var Wr;function zk(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=!1,s=!1,r=!1,a=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!=\"undefined\"&&e instanceof ImageData)s=!0;else if(typeof HTMLVideoElement!=\"undefined\"&&e instanceof HTMLVideoElement)r=!0;else if(typeof HTMLImageElement!=\"undefined\"&&e instanceof HTMLImageElement)a=!0;else if(e.getContext!=null)i=!0;else if(typeof ImageBitmap!=\"undefined\"&&e instanceof ImageBitmap)o=!0;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